summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/atmodem/sim.c61
-rw-r--r--include/sim.h38
-rw-r--r--src/sim.c51
3 files changed, 77 insertions, 73 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index b6f34c20..775ce60e 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -399,24 +399,24 @@ error:
}
static struct {
- enum ofono_passwd_type type;
+ enum ofono_sim_password_type type;
const char *name;
} const at_sim_name[] = {
- { OFONO_PASSWD_SIM_PIN, "SIM PIN" },
- { OFONO_PASSWD_SIM_PUK, "SIM PUK" },
- { OFONO_PASSWD_PHSIM_PIN, "PH-SIM PIN" },
- { OFONO_PASSWD_PHFSIM_PIN, "PH-FSIM PIN" },
- { OFONO_PASSWD_PHFSIM_PUK, "PH-FSIM PUK" },
- { OFONO_PASSWD_SIM_PIN2, "SIM PIN2" },
- { OFONO_PASSWD_SIM_PUK2, "SIM PUK2" },
- { OFONO_PASSWD_PHNET_PIN, "PH-NET PIN" },
- { OFONO_PASSWD_PHNET_PUK, "PH-NET PUK" },
- { OFONO_PASSWD_PHNETSUB_PIN, "PH-NETSUB PIN" },
- { OFONO_PASSWD_PHNETSUB_PUK, "PH-NETSUB PUK" },
- { OFONO_PASSWD_PHSP_PIN, "PH-SP PIN" },
- { OFONO_PASSWD_PHSP_PUK, "PH-SP PUK" },
- { OFONO_PASSWD_PHCORP_PIN, "PH-CORP PIN" },
- { OFONO_PASSWD_PHCORP_PUK, "PH-CORP PUK" },
+ { OFONO_SIM_PASSWORD_SIM_PIN, "SIM PIN" },
+ { OFONO_SIM_PASSWORD_SIM_PUK, "SIM PUK" },
+ { OFONO_SIM_PASSWORD_PHSIM_PIN, "PH-SIM PIN" },
+ { OFONO_SIM_PASSWORD_PHFSIM_PIN, "PH-FSIM PIN" },
+ { OFONO_SIM_PASSWORD_PHFSIM_PUK, "PH-FSIM PUK" },
+ { OFONO_SIM_PASSWORD_SIM_PIN2, "SIM PIN2" },
+ { OFONO_SIM_PASSWORD_SIM_PUK2, "SIM PUK2" },
+ { OFONO_SIM_PASSWORD_PHNET_PIN, "PH-NET PIN" },
+ { OFONO_SIM_PASSWORD_PHNET_PUK, "PH-NET PUK" },
+ { OFONO_SIM_PASSWORD_PHNETSUB_PIN, "PH-NETSUB PIN" },
+ { OFONO_SIM_PASSWORD_PHNETSUB_PUK, "PH-NETSUB PUK" },
+ { OFONO_SIM_PASSWORD_PHSP_PIN, "PH-SP PIN" },
+ { OFONO_SIM_PASSWORD_PHSP_PUK, "PH-SP PUK" },
+ { OFONO_SIM_PASSWORD_PHCORP_PIN, "PH-CORP PIN" },
+ { OFONO_SIM_PASSWORD_PHCORP_PUK, "PH-CORP PUK" },
};
static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -426,7 +426,7 @@ static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_sim_passwd_cb_t cb = cbd->cb;
struct ofono_error error;
const char *pin_required;
- int pin_type;
+ int pin_type = OFONO_SIM_PASSWORD_INVALID;
int i;
int len = sizeof(at_sim_name) / sizeof(*at_sim_name);
@@ -449,7 +449,7 @@ static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
pin_type = -1;
if (!strcmp(pin_required, "READY"))
- pin_type = OFONO_PASSWD_NONE;
+ pin_type = OFONO_SIM_PASSWD_NONE;
else
for (i = 0; i < len; i++)
if (!strcmp(pin_required, at_sim_name[i].name)) {
@@ -457,7 +457,7 @@ static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
break;
}
- if (pin_type == -1) {
+ if (pin_type == OFONO_SIM_PASSWORD_INVALID) {
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
return;
}
@@ -556,14 +556,14 @@ error:
}
static const char *const at_clck_cpwd_fac[] = {
- [OFONO_PASSWD_SIM_PIN] = "SC",
- [OFONO_PASSWD_SIM_PIN2] = "P2",
- [OFONO_PASSWD_PHSIM_PIN] = "PS",
- [OFONO_PASSWD_PHFSIM_PIN] = "PF",
- [OFONO_PASSWD_PHNET_PIN] = "PN",
- [OFONO_PASSWD_PHNETSUB_PIN] = "PU",
- [OFONO_PASSWD_PHSP_PIN] = "PP",
- [OFONO_PASSWD_PHCORP_PIN] = "PC",
+ [OFONO_SIM_PASSWORD_SIM_PIN] = "SC",
+ [OFONO_SIM_PASSWORD_SIM_PIN2] = "P2",
+ [OFONO_SIM_PASSWORD_PHSIM_PIN] = "PS",
+ [OFONO_SIM_PASSWORD_PHFSIM_PIN] = "PF",
+ [OFONO_SIM_PASSWORD_PHNET_PIN] = "PN",
+ [OFONO_SIM_PASSWORD_PHNETSUB_PIN] = "PU",
+ [OFONO_SIM_PASSWORD_PHSP_PIN] = "PP",
+ [OFONO_SIM_PASSWORD_PHCORP_PIN] = "PC",
};
static void at_pin_enable(struct ofono_sim *sim, int passwd_type, int enable,
@@ -600,7 +600,8 @@ error:
CALLBACK_WITH_FAILURE(cb, data);
}
-static void at_change_passwd(struct ofono_sim *sim, int passwd_type,
+static void at_change_passwd(struct ofono_sim *sim,
+ enum ofono_sim_password_type passwd_type,
const char *old, const char *new,
ofono_sim_lock_unlock_cb_t cb, void *data)
{
@@ -608,12 +609,12 @@ static void at_change_passwd(struct ofono_sim *sim, int passwd_type,
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
int ret;
- int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
+ unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
if (!cbd)
goto error;
- if (passwd_type < 0 || passwd_type >= len ||
+ if (passwd_type >= len ||
!at_clck_cpwd_fac[passwd_type])
goto error;
diff --git a/include/sim.h b/include/sim.h
index eaa227dd..3d618270 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -37,23 +37,24 @@ enum ofono_sim_file_structure {
OFONO_SIM_FILE_STRUCTURE_CYCLIC = 3
};
-enum ofono_passwd_type {
- OFONO_PASSWD_NONE = 0,
- OFONO_PASSWD_SIM_PIN,
- OFONO_PASSWD_SIM_PUK,
- OFONO_PASSWD_PHSIM_PIN,
- OFONO_PASSWD_PHFSIM_PIN,
- OFONO_PASSWD_PHFSIM_PUK,
- OFONO_PASSWD_SIM_PIN2,
- OFONO_PASSWD_SIM_PUK2,
- OFONO_PASSWD_PHNET_PIN,
- OFONO_PASSWD_PHNET_PUK,
- OFONO_PASSWD_PHNETSUB_PIN,
- OFONO_PASSWD_PHNETSUB_PUK,
- OFONO_PASSWD_PHSP_PIN,
- OFONO_PASSWD_PHSP_PUK,
- OFONO_PASSWD_PHCORP_PIN,
- OFONO_PASSWD_PHCORP_PUK,
+enum ofono_sim_password_type {
+ OFONO_SIM_PASSWORD_NONE = 0,
+ OFONO_SIM_PASSWORD_SIM_PIN,
+ OFONO_SIM_PASSWORD_PHSIM_PIN,
+ OFONO_SIM_PASSWORD_PHFSIM_PIN,
+ OFONO_SIM_PASSWORD_SIM_PIN2,
+ OFONO_SIM_PASSWORD_PHNET_PIN,
+ OFONO_SIM_PASSWORD_PHNETSUB_PIN,
+ OFONO_SIM_PASSWORD_PHSP_PIN,
+ OFONO_SIM_PASSWORD_PHCORP_PIN,
+ OFONO_SIM_PASSWORD_SIM_PUK,
+ OFONO_SIM_PASSWORD_PHFSIM_PUK,
+ OFONO_SIM_PASSWORD_SIM_PUK2,
+ OFONO_SIM_PASSWORD_PHNET_PUK,
+ OFONO_SIM_PASSWORD_PHNETSUB_PUK,
+ OFONO_SIM_PASSWORD_PHSP_PUK,
+ OFONO_SIM_PASSWORD_PHCORP_PUK,
+ OFONO_SIM_PASSWORD_INVALID,
};
typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
@@ -122,7 +123,8 @@ struct ofono_sim_driver {
void (*reset_passwd)(struct ofono_sim *sim, const char *puk,
const char *passwd,
ofono_sim_lock_unlock_cb_t cb, void *data);
- void (*change_passwd)(struct ofono_sim *sim, int passwd_type,
+ void (*change_passwd)(struct ofono_sim *sim,
+ enum ofono_sim_password_type type,
const char *old, const char *new,
ofono_sim_lock_unlock_cb_t cb, void *data);
void (*lock)(struct ofono_sim *sim, int passwd_type, int enable,
diff --git a/src/sim.c b/src/sim.c
index 19be299a..d4a920b9 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -113,30 +113,30 @@ struct service_number {
};
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",
+ [OFONO_SIM_PASSWORD_NONE] = "none",
+ [OFONO_SIM_PASSWORD_SIM_PIN] = "pin",
+ [OFONO_SIM_PASSWORD_SIM_PUK] = "puk",
+ [OFONO_SIM_PASSWORD_PHSIM_PIN] = "phone",
+ [OFONO_SIM_PASSWORD_PHFSIM_PIN] = "firstphone",
+ [OFONO_SIM_PASSWORD_PHFSIM_PUK] = "firstphonepuk",
+ [OFONO_SIM_PASSWORD_SIM_PIN2] = "pin2",
+ [OFONO_SIM_PASSWORD_SIM_PUK2] = "puk2",
+ [OFONO_SIM_PASSWORD_PHNET_PIN] = "network",
+ [OFONO_SIM_PASSWORD_PHNET_PUK] = "networkpuk",
+ [OFONO_SIM_PASSWORD_PHNETSUB_PIN] = "netsub",
+ [OFONO_SIM_PASSWORD_PHNETSUB_PUK] = "netsubpuk",
+ [OFONO_SIM_PASSWORD_PHSP_PIN] = "service",
+ [OFONO_SIM_PASSWORD_PHSP_PUK] = "servicepuk",
+ [OFONO_SIM_PASSWORD_PHCORP_PIN] = "corp",
+ [OFONO_SIM_PASSWORD_PHCORP_PUK] = "corppuk",
};
-static const char *sim_passwd_name(enum ofono_passwd_type type)
+static const char *sim_passwd_name(enum ofono_sim_password_type type)
{
return passwd_name[type];
}
-static enum ofono_passwd_type sim_string_to_passwd(const char *name)
+static enum ofono_sim_password_type sim_string_to_passwd(const char *name)
{
int len = sizeof(passwd_name) / sizeof(*passwd_name);
int i;
@@ -145,7 +145,7 @@ static enum ofono_passwd_type sim_string_to_passwd(const char *name)
if (!strcmp(passwd_name[i], name))
return i;
- return OFONO_PASSWD_NONE;
+ return OFONO_SIM_PASSWORD_INVALID;
}
static char **get_own_numbers(GSList *own_numbers)
@@ -450,7 +450,7 @@ static DBusMessage *sim_change_pin(DBusConnection *conn, DBusMessage *msg,
struct ofono_sim *sim = data;
struct pin_enable_request *req;
DBusMessageIter iter;
- enum ofono_passwd_type type;
+ enum ofono_sim_password_type type;
const char *typestr;
const char *old;
const char *new;
@@ -467,7 +467,8 @@ static DBusMessage *sim_change_pin(DBusConnection *conn, DBusMessage *msg,
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
- if (type == OFONO_PASSWD_NONE)
+ if (type == OFONO_SIM_PASSWORD_NONE ||
+ type == OFONO_SIM_PASSWORD_INVALID)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
@@ -553,7 +554,7 @@ static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg,
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
- if (type == OFONO_PASSWD_NONE || type != sim->pin_type)
+ if (type == OFONO_SIM_PASSWORD_NONE || type != sim->pin_type)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
@@ -596,7 +597,7 @@ static DBusMessage *sim_reset_pin(DBusConnection *conn, DBusMessage *msg,
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
- if (type == OFONO_PASSWD_NONE || type != sim->pin_type)
+ if (type == OFONO_SIM_PASSWORD_NONE || type != sim->pin_type)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
@@ -889,7 +890,7 @@ static void sim_retrieve_imsi(struct ofono_sim *sim)
}
static void sim_pin_query_cb(const struct ofono_error *error, int pin_type,
- void *data)
+ void *data)
{
struct ofono_sim *sim = data;
DBusConnection *conn = ofono_dbus_get_connection();
@@ -914,7 +915,7 @@ static void sim_pin_query_cb(const struct ofono_error *error, int pin_type,
}
checkdone:
- if (pin_type == OFONO_PASSWD_NONE)
+ if (pin_type == OFONO_SIM_PASSWORD_NONE)
sim_retrieve_imsi(sim);
}