4 /* GSM 04.08 4.1.2.2 SIM update status */
5 #define GSM_SIM_U0_NULL 0
6 #define GSM_SIM_U1_UPDATED 1
7 #define GSM_SIM_U2_NOT_UPDATED 2
8 #define GSM_SIM_U3_ROAMING_NA 3
10 struct gsm_sub_plmn_list {
11 struct llist_head entry;
15 struct gsm_sub_plmn_na {
16 struct llist_head entry;
21 #define GSM_IMSI_LENGTH 16
24 GSM_SIM_TYPE_NONE = 0,
29 struct gsm_subscriber {
30 struct osmocom_ms *ms;
33 uint8_t sim_type; /* type of sim */
34 uint8_t sim_valid; /* sim inserted and valid */
35 uint8_t ustate; /* update status */
36 uint8_t imsi_attached; /* attached state */
39 char imsi[GSM_IMSI_LENGTH];
40 char msisdn[31]; /* may include access codes */
41 char iccid[21]; /* 20 + termination */
44 uint32_t tmsi; /* invalid tmsi: 0xffffffff */
45 uint16_t mcc, mnc, lac; /* invalid lac: 0x0000 */
49 uint8_t key_seq; /* ciphering key sequence number */
50 uint8_t key[8]; /* 64 bit */
53 struct llist_head plmn_list; /* PLMN Selector field */
54 struct llist_head plmn_na; /* not allowed PLMNs */
55 uint8_t t6m_hplmn; /* timer for hplmn search */
58 uint8_t always_search_hplmn;
59 /* search hplmn in other countries also (for test cards) */
61 /* timer to restart 'any cell selection' */
62 char sim_name[31]; /* name to load/save sim */
63 char sim_spn[17]; /* name of service privider */
65 /* PLMN last registered */
67 uint16_t plmn_mcc, plmn_mnc;
70 uint8_t acc_barr; /* if we may access, if cell barred */
71 uint16_t acc_class; /* bitmask of what we may access */
75 uint8_t sim_pin_required; /* state: wait for PIN */
76 uint8_t sim_file_index;
77 uint32_t sim_handle_query;
78 uint32_t sim_handle_update;
79 uint32_t sim_handle_key;
82 int gsm_subscr_init(struct osmocom_ms *ms);
83 int gsm_subscr_exit(struct osmocom_ms *ms);
84 int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc,
85 uint16_t lac, uint32_t tmsi);
86 int gsm_subscr_simcard(struct osmocom_ms *ms);
87 void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2,
89 int gsm_subscr_write_loci(struct osmocom_ms *ms);
90 int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq,
91 uint8_t *rand, uint8_t no_sim);
92 int gsm_subscr_remove(struct osmocom_ms *ms);
93 void new_sim_ustate(struct gsm_subscriber *subscr, int state);
94 int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
96 int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
97 uint16_t mnc, uint8_t cause);
98 int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
100 int gsm_subscr_dump_forbidden_plmn(struct osmocom_ms *ms,
101 void (*print)(void *, const char *, ...), void *priv);
102 void gsm_subscr_dump(struct gsm_subscriber *subscr,
103 void (*print)(void *, const char *, ...), void *priv);
104 char *gsm_check_imsi(const char *imsi);
106 #endif /* _SUBSCRIBER_H */