layer23: Migrate sim_ustate to enum + value_string
Change-Id: I83607caa0b76b6b30db59c53438a55726483b85d
This commit is contained in:
parent
4ea84d3ae5
commit
f05ac96fd6
|
@ -1,13 +1,22 @@
|
|||
#ifndef _SUBSCRIBER_H
|
||||
#define _SUBSCRIBER_H
|
||||
|
||||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/gsm/protocol/gsm_23_003.h>
|
||||
|
||||
/* GSM 04.08 4.1.2.2 SIM update status */
|
||||
#define GSM_SIM_U0_NULL 0
|
||||
#define GSM_SIM_U1_UPDATED 1
|
||||
#define GSM_SIM_U2_NOT_UPDATED 2
|
||||
#define GSM_SIM_U3_ROAMING_NA 3
|
||||
enum gsm_sub_sim_ustate {
|
||||
GSM_SIM_U0_NULL,
|
||||
GSM_SIM_U1_UPDATED,
|
||||
GSM_SIM_U2_NOT_UPDATED,
|
||||
GSM_SIM_U3_ROAMING_NA,
|
||||
};
|
||||
extern const struct value_string gsm_sub_sim_ustate_names[];
|
||||
static inline const char *gsm_sub_sim_ustate_name(enum gsm_sub_sim_ustate val)
|
||||
{
|
||||
return get_value_string(gsm_sub_sim_ustate_names, val);
|
||||
}
|
||||
|
||||
|
||||
struct gsm_sub_plmn_list {
|
||||
struct llist_head entry;
|
||||
|
@ -36,7 +45,7 @@ struct gsm_subscriber {
|
|||
/* status */
|
||||
uint8_t sim_type; /* type of sim */
|
||||
uint8_t sim_valid; /* sim inserted and valid */
|
||||
uint8_t ustate; /* update status */
|
||||
enum gsm_sub_sim_ustate ustate; /* update status */
|
||||
uint8_t imsi_attached; /* attached state */
|
||||
|
||||
/* IMSI & co */
|
||||
|
|
|
@ -1016,19 +1016,20 @@ int gsm_subscr_remove(struct osmocom_ms *ms)
|
|||
* state and lists
|
||||
*/
|
||||
|
||||
static const char *subscr_ustate_names[] = {
|
||||
"U0_NULL",
|
||||
"U1_UPDATED",
|
||||
"U2_NOT_UPDATED",
|
||||
"U3_ROAMING_NA"
|
||||
const struct value_string gsm_sub_sim_ustate_names[] = {
|
||||
{ GSM_SIM_U0_NULL, "U0_NULL" },
|
||||
{ GSM_SIM_U1_UPDATED, "U1_UPDATED" },
|
||||
{ GSM_SIM_U2_NOT_UPDATED, "U2_NOT_UPDATED" },
|
||||
{ GSM_SIM_U3_ROAMING_NA, "U3_ROAMING_NA" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* change to new U state */
|
||||
void new_sim_ustate(struct gsm_subscriber *subscr, int state)
|
||||
{
|
||||
LOGP(DMM, LOGL_INFO, "(ms %s) new state %s -> %s\n", subscr->ms->name,
|
||||
subscr_ustate_names[subscr->ustate],
|
||||
subscr_ustate_names[state]);
|
||||
gsm_sub_sim_ustate_name(subscr->ustate),
|
||||
gsm_sub_sim_ustate_name(state));
|
||||
|
||||
subscr->ustate = state;
|
||||
}
|
||||
|
@ -1153,7 +1154,7 @@ void gsm_subscr_dump(struct gsm_subscriber *subscr,
|
|||
if (subscr->sms_sca[0])
|
||||
print(priv, " SMS Service Center Address: %s\n",
|
||||
subscr->sms_sca);
|
||||
print(priv, " Status: %s IMSI %s", subscr_ustate_names[subscr->ustate],
|
||||
print(priv, " Status: %s IMSI %s", gsm_sub_sim_ustate_name(subscr->ustate),
|
||||
(subscr->imsi_attached) ? "attached" : "detached");
|
||||
if (subscr->tmsi != GSM_RESERVED_TMSI)
|
||||
print(priv, " TMSI 0x%08x", subscr->tmsi);
|
||||
|
|
Loading…
Reference in New Issue