diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-07-13 16:12:22 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-07-14 15:45:05 -0500 |
commit | 5ea1326b00d330fdb0ab3697f60a3143ff380c90 (patch) | |
tree | 78647f2eaf1c2679c50b8a10e7ed960632b231d8 /src/sim.c | |
parent | f2440ebd82510d65478bb0d38bd937a212ad69bf (diff) | |
download | ofono-5ea1326b00d330fdb0ab3697f60a3143ff380c90.tar.bz2 |
Move SPDI to network.c
Diffstat (limited to 'src/sim.c')
-rw-r--r-- | src/sim.c | 126 |
1 files changed, 0 insertions, 126 deletions
@@ -245,132 +245,6 @@ check: } } -struct sim_operator { - char mcc[OFONO_MAX_MCC_LENGTH + 1]; - char mnc[OFONO_MAX_MNC_LENGTH + 1]; -}; - -static void parse_mcc_mnc(struct sim_operator *oper, const guint8 *bcd) -{ - char *mcc = oper->mcc; - char *mnc = oper->mnc; - guint8 digit; - - digit = (bcd[0] >> 0) & 0xf; - if (digit != 0xf) - *mcc ++ = '0' + digit; - digit = (bcd[0] >> 4) & 0xf; - if (digit != 0xf) - *mcc ++ = '0' + digit; - digit = (bcd[1] >> 0) & 0xf; - if (digit != 0xf) - *mcc ++ = '0' + digit; - digit = (bcd[2] >> 0) & 0xf; - if (digit != 0xf) - *mnc ++ = '0' + digit; - digit = (bcd[2] >> 4) & 0xf; - if (digit != 0xf) - *mnc ++ = '0' + digit; - digit = (bcd[1] >> 4) & 0xf; - if (digit != 0xf) - *mnc ++ = '0' + digit; -} - -static struct sim_operator *sim_operator_alloc(const guint8 *bcd) -{ - struct sim_operator *spdi = g_new0(struct sim_operator, 1); - - parse_mcc_mnc(spdi, bcd); - - return spdi; -} - -static gint spdi_operator_compare(gconstpointer a, gconstpointer b) -{ - const struct sim_operator *opa = a; - const struct sim_operator *opb = b; - gint r; - - if ((r = strcmp(opa->mcc, opb->mcc))) - return r; - - return strcmp(opa->mnc, opb->mnc); -} - -gboolean ofono_operator_in_spdi(struct ofono_modem *modem, - const struct ofono_network_operator *op) -{ - struct sim_manager_data *sim = modem->sim_manager; - struct sim_operator spdi_op; - - if (!sim) - return FALSE; - - g_strlcpy(spdi_op.mcc, op->mcc, sizeof(spdi_op.mcc)); - g_strlcpy(spdi_op.mnc, op->mnc, sizeof(spdi_op.mnc)); - - return g_slist_find_custom(sim->spdi, - &spdi_op, spdi_operator_compare) != NULL; -} - -static void sim_spdi_read_cb(const struct ofono_error *error, - const unsigned char *spdidata, - int length, void *data) -{ - struct ofono_modem *modem = data; - struct sim_manager_data *sim = modem->sim_manager; - const guint8 *plmn_list; - GSList *l; - - if (error->type != OFONO_ERROR_TYPE_NO_ERROR || length <= 5) - return; - - plmn_list = ber_tlv_find_by_tag(spdidata, 0x80, length, &length); - if (!plmn_list) { - ofono_debug("Couldn't parse the EF-SPDI contents as a TLV"); - return; - } - - for (length /= 3; length --; plmn_list += 3) { - if ((plmn_list[0] & plmn_list[1] & plmn_list[2]) == 0xff) - continue; - - sim->spdi = g_slist_insert_sorted(sim->spdi, - sim_operator_alloc(plmn_list), - spdi_operator_compare); - } - - if (sim->spdi) - for (l = sim->update_spn_notify; l; l = l->next) - sim_spn_notify(modem, l->data); -} - -static void sim_spdi_info_cb(const struct ofono_error *error, int length, - enum ofono_sim_file_structure structure, - int dummy, void *data) -{ - struct ofono_modem *modem = data; - struct sim_manager_data *sim = modem->sim_manager; - - if (error->type != OFONO_ERROR_TYPE_NO_ERROR || length <= 5 || - structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT) - return; - - sim->ops->read_file_transparent(modem, SIM_EFSPDI_FILEID, 0, length, - sim_spdi_read_cb, modem); -} - -static gboolean sim_retrieve_spdi(void *user_data) -{ - struct ofono_modem *modem = user_data; - struct sim_manager_data *sim = modem->sim_manager; - - sim->ops->read_file_info(modem, SIM_EFSPDI_FILEID, - sim_spdi_info_cb, modem); - - return FALSE; -} - struct opl_operator { struct sim_operator mcc_mnc; guint16 lac_tac_low; |