diff options
author | Andrzej Zaborowski <andrew.zaborowski@intel.com> | 2009-09-17 22:43:22 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-22 00:07:06 -0500 |
commit | ee02b14836d7e30b45ee6fd62da6a8135c94c9dd (patch) | |
tree | ebe561c1cb248e4a11643fdc09e61246520cda97 /src/simutil.c | |
parent | b1c8b291f5c8d1802b889756c01cc2f7f5288641 (diff) | |
download | ofono-ee02b14836d7e30b45ee6fd62da6a8135c94c9dd.tar.bz2 |
Do PIN authentication
This adds checking whether PIN is required during SIM initialisation and
delaying the sim ready notifications until after correct PIN is given.
Diffstat (limited to 'src/simutil.c')
-rw-r--r-- | src/simutil.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/simutil.c b/src/simutil.c index b80e014d..e1b0f2aa 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -488,3 +488,39 @@ void sim_adn_build(unsigned char *data, int length, /* Ext1 unused */ *data++ = 0xff; } + +static const char *const passwd_name[] = { + [OFONO_PASSWD_NONE] = "none", + [OFONO_PASSWD_SIM_PIN] = "pin", + [OFONO_PASSWD_SIM_PUK] = "puk", + [OFONO_PASSWD_PHSIM_PIN] = "phone", + [OFONO_PASSWD_PHFSIM_PIN] = "firstphone", + [OFONO_PASSWD_PHFSIM_PUK] = "firstphonepuk", + [OFONO_PASSWD_SIM_PIN2] = "pin2", + [OFONO_PASSWD_SIM_PUK2] = "puk2", + [OFONO_PASSWD_PHNET_PIN] = "network", + [OFONO_PASSWD_PHNET_PUK] = "networkpuk", + [OFONO_PASSWD_PHNETSUB_PIN] = "netsub", + [OFONO_PASSWD_PHNETSUB_PUK] = "netsubpuk", + [OFONO_PASSWD_PHSP_PIN] = "service", + [OFONO_PASSWD_PHSP_PUK] = "servicepuk", + [OFONO_PASSWD_PHCORP_PIN] = "corp", + [OFONO_PASSWD_PHCORP_PUK] = "corppuk", +}; + +const char *sim_passwd_name(enum ofono_passwd_type type) +{ + return passwd_name[type]; +} + +enum ofono_passwd_type sim_string_to_passwd(const char *name) +{ + int len = sizeof(passwd_name) / sizeof(*passwd_name); + int i; + + for (i = 0; i < len; i++) + if (!strcmp(passwd_name[i], name)) + return i; + + return OFONO_PASSWD_NONE; +} |