forked from acouzens/open5gs
update it
This commit is contained in:
parent
d9307d3187
commit
b6ffaf6312
|
@ -96,8 +96,7 @@ CORE_DECLARE(void *) core_uint64_to_buffer(
|
|||
|
||||
CORE_DECLARE(c_uint64_t) core_buffer_to_uint64(void *buffer, int size);
|
||||
|
||||
CORE_DECLARE(void *) core_bcd_to_buffer(
|
||||
char *in, int in_len, void *out, int *out_len);
|
||||
CORE_DECLARE(void *) core_bcd_to_buffer(c_int8_t *in, void *out, int *out_len);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -53,10 +53,11 @@ c_uint64_t core_buffer_to_uint64(void *buffer, int size)
|
|||
return num;
|
||||
}
|
||||
|
||||
void *core_bcd_to_buffer(char *in, int in_len, void *out, int *out_len)
|
||||
void *core_bcd_to_buffer(c_int8_t *in, void *out, int *out_len)
|
||||
{
|
||||
int i = 0;
|
||||
c_uint8_t *out_p = out;
|
||||
int in_len = strlen(in);
|
||||
|
||||
for (i = 0; i < in_len; i++)
|
||||
{
|
||||
|
|
|
@ -86,10 +86,10 @@ static void misc_test5(abts_case *tc, void *data)
|
|||
char out[16];
|
||||
int out_len;
|
||||
#define MSISDN "491725670014"
|
||||
core_bcd_to_buffer(MSISDN, strlen(MSISDN), out, &out_len);
|
||||
core_bcd_to_buffer(MSISDN, out, &out_len);
|
||||
ABTS_TRUE(tc, memcmp("\x94\x71\x52\x76\x00\x41", out, out_len) == 0);
|
||||
#define MEI "3516020019874800"
|
||||
core_bcd_to_buffer(MEI, strlen(MEI), out, &out_len);
|
||||
core_bcd_to_buffer(MEI, out, &out_len);
|
||||
ABTS_TRUE(tc,
|
||||
memcmp("\x53\x61\x20\x00\x91\x78\x84\x00", out, out_len) == 0);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
#include "hss_context.h"
|
||||
|
||||
#define OP "5F1D289C5D354D0A140C2548F5F3E3BA"
|
||||
#define OPc "E8ED289DEBA952E4283B54E88E6183CA"
|
||||
#define AMF "8000"
|
||||
#define MAX_NUM_OF_PROFILE 8
|
||||
|
||||
static hss_context_t self;
|
||||
|
||||
pool_declare(hss_profile_pool, hss_profile_t, MAX_NUM_OF_PROFILE);
|
||||
pool_declare(hss_ue_pool, hss_ue_t, MAX_NUM_OF_UE);
|
||||
|
||||
hss_context_t* hss_self()
|
||||
|
@ -23,64 +22,46 @@ status_t hss_context_init(void)
|
|||
{
|
||||
char buf[HSS_KEY_LEN];
|
||||
|
||||
hss_profile_id_t profile_id = 1;
|
||||
hss_profile_t *profile;
|
||||
hss_ue_t *ue;
|
||||
|
||||
memset(&self, 0, sizeof(hss_context_t));
|
||||
|
||||
pool_init(&hss_profile_pool, MAX_NUM_OF_PROFILE);
|
||||
pool_init(&hss_ue_pool, MAX_NUM_OF_UE);
|
||||
|
||||
memcpy(self.op, CORE_HEX(OP, strlen(OP), buf), HSS_KEY_LEN);
|
||||
memcpy(self.amf, CORE_HEX(AMF, strlen(AMF), buf), HSS_AMF_LEN);
|
||||
list_init(&self.profile_list);
|
||||
list_init(&self.ue_list);
|
||||
|
||||
profile = hss_profile_add(profile_id);
|
||||
d_assert(profile, return -1, "UE context add failed");
|
||||
|
||||
#define OP "5F1D289C5D354D0A140C2548F5F3E3BA"
|
||||
#define AMF "8000"
|
||||
#define OPc "E8ED289DEBA952E4283B54E88E6183CA"
|
||||
#define K "465B5CE8B199B49FAA5F0A2EE238A6BC"
|
||||
memcpy(profile->op, CORE_HEX(OP, strlen(OP), buf), HSS_KEY_LEN);
|
||||
memcpy(profile->amf, CORE_HEX(AMF, strlen(AMF), buf), HSS_AMF_LEN);
|
||||
memcpy(profile->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
profile->sqn = 64;
|
||||
|
||||
#define K "465B5CE8B199B49FAA5F0A2EE238A6BC"
|
||||
#define UE1_IMSI "001010123456800"
|
||||
#define UE2_IMSI "001010123456796"
|
||||
|
||||
#define UE3_IMSI "001010123456819"
|
||||
#define UE3_RAND "20080c3818183b52 2614162c07601d0d"
|
||||
|
||||
#define MSISDN "491725670014"
|
||||
#define MEI "3516020019874800"
|
||||
|
||||
ue = hss_ue_add();
|
||||
ue = hss_ue_add(profile_id, UE1_IMSI);
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi_bcd, UE1_IMSI);
|
||||
ue->imsi_bcd_len = strlen(UE1_IMSI);
|
||||
strcpy((char*)ue->msisdn_bcd, MSISDN);
|
||||
ue->msisdn_bcd_len = strlen(MSISDN);
|
||||
strcpy((char*)ue->mei_bcd, MEI);
|
||||
ue->mei_bcd_len = strlen(MEI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, RAND_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ue_add();
|
||||
ue = hss_ue_add(profile_id, UE2_IMSI);
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi_bcd, UE2_IMSI);
|
||||
ue->imsi_bcd_len = strlen(UE2_IMSI);
|
||||
strcpy((char*)ue->msisdn_bcd, MSISDN);
|
||||
ue->msisdn_bcd_len = strlen(MSISDN);
|
||||
strcpy((char*)ue->mei_bcd, MEI);
|
||||
ue->mei_bcd_len = strlen(MEI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
core_generate_random_bytes(ue->rand, RAND_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
ue = hss_ue_add();
|
||||
ue = hss_ue_add(profile_id, UE3_IMSI);
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
||||
strcpy((char*)ue->imsi_bcd, UE3_IMSI);
|
||||
ue->imsi_bcd_len = strlen(UE3_IMSI);
|
||||
strcpy((char*)ue->msisdn_bcd, MSISDN);
|
||||
ue->msisdn_bcd_len = strlen(MSISDN);
|
||||
strcpy((char*)ue->mei_bcd, MEI);
|
||||
ue->mei_bcd_len = strlen(MEI);
|
||||
memcpy(ue->k, CORE_HEX(K, strlen(K), buf), HSS_KEY_LEN);
|
||||
memcpy(ue->rand, CORE_HEX(UE3_RAND, strlen(UE3_RAND), buf),
|
||||
RAND_LEN);
|
||||
ue->sqn = 64;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -88,29 +69,125 @@ status_t hss_context_init(void)
|
|||
void hss_context_final(void)
|
||||
{
|
||||
hss_ue_remove_all();
|
||||
hss_profile_remove_all();
|
||||
|
||||
pool_final(&hss_ue_pool);
|
||||
pool_final(&hss_profile_pool);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
hss_ue_t* hss_ue_add()
|
||||
hss_profile_t* hss_profile_add(hss_profile_id_t id)
|
||||
{
|
||||
hss_profile_t *profile = NULL;
|
||||
|
||||
pool_alloc_node(&hss_profile_pool, &profile);
|
||||
d_assert(profile, return NULL, "HSS-UE context allocation failed");
|
||||
|
||||
memset(profile, 0, sizeof(hss_profile_t));
|
||||
|
||||
profile->id = id;
|
||||
|
||||
list_append(&self.profile_list, profile);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
status_t hss_profile_remove(hss_profile_t *profile)
|
||||
{
|
||||
d_assert(profile, return CORE_ERROR, "Null param");
|
||||
|
||||
list_remove(&self.profile_list, profile);
|
||||
pool_free_node(&hss_profile_pool, profile);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t hss_profile_remove_all()
|
||||
{
|
||||
hss_profile_t *profile = NULL, *next_profile = NULL;
|
||||
|
||||
profile = list_first(&self.profile_list);
|
||||
while (profile)
|
||||
{
|
||||
next_profile = list_next(profile);
|
||||
|
||||
hss_profile_remove(profile);
|
||||
|
||||
profile = next_profile;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
hss_profile_t* hss_profile_find_by_id(hss_profile_id_t id)
|
||||
{
|
||||
hss_profile_t *profile = NULL;
|
||||
|
||||
profile = list_first(&self.profile_list);
|
||||
while (profile)
|
||||
{
|
||||
if (profile->id == id)
|
||||
break;
|
||||
|
||||
profile = list_next(profile);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
hss_profile_t* hss_profile_find_by_name(c_int8_t *name)
|
||||
{
|
||||
hss_profile_t *profile = NULL;
|
||||
|
||||
profile = list_first(&self.profile_list);
|
||||
while (profile)
|
||||
{
|
||||
if (strcmp(profile->name, name) == 0)
|
||||
break;
|
||||
|
||||
profile = list_next(profile);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
hss_profile_t* hss_profile_first()
|
||||
{
|
||||
return list_first(&self.profile_list);
|
||||
}
|
||||
|
||||
hss_profile_t* hss_profile_next(hss_profile_t *profile)
|
||||
{
|
||||
return list_next(profile);
|
||||
}
|
||||
|
||||
hss_ue_t* hss_ue_add(hss_profile_id_t id, c_int8_t *imsi_bcd)
|
||||
{
|
||||
hss_profile_t *profile = NULL;
|
||||
hss_ue_t *ue = NULL;
|
||||
|
||||
/* Allocate new eNB context */
|
||||
profile = hss_profile_find_by_id(id);
|
||||
d_assert(profile, return NULL, "Can't find Profile = %d", id);
|
||||
|
||||
pool_alloc_node(&hss_ue_pool, &ue);
|
||||
d_assert(ue, return NULL, "HSS-UE context allocation failed");
|
||||
|
||||
/* Initialize eNB context */
|
||||
memset(ue, 0, sizeof(hss_ue_t));
|
||||
|
||||
/* Add new eNB context to list */
|
||||
memcpy(ue->k, profile->k, HSS_KEY_LEN);
|
||||
memcpy(ue->op, profile->op, HSS_KEY_LEN);
|
||||
memcpy(ue->amf, profile->amf, HSS_AMF_LEN);
|
||||
|
||||
strcpy((char*)ue->imsi_bcd, imsi_bcd);
|
||||
strcpy((char*)ue->msisdn_bcd, ue->imsi_bcd);
|
||||
strcpy((char*)ue->mei_bcd, ue->imsi_bcd);
|
||||
|
||||
core_generate_random_bytes(ue->rand, RAND_LEN);
|
||||
ue->sqn = profile->sqn;
|
||||
|
||||
list_append(&self.ue_list, ue);
|
||||
|
||||
memcpy(ue->op, self.op, HSS_KEY_LEN);
|
||||
memcpy(ue->amf, self.amf, HSS_AMF_LEN);
|
||||
|
||||
return ue;
|
||||
}
|
||||
|
||||
|
@ -141,14 +218,14 @@ status_t hss_ue_remove_all()
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
hss_ue_t* hss_ue_find_by_imsi_bcd(c_uint8_t *imsi_bcd, c_uint8_t imsi_bcd_len)
|
||||
hss_ue_t* hss_ue_find_by_imsi_bcd(c_int8_t *imsi_bcd)
|
||||
{
|
||||
hss_ue_t *ue = NULL;
|
||||
|
||||
ue = list_first(&self.ue_list);
|
||||
while (ue)
|
||||
{
|
||||
if (memcmp(ue->imsi_bcd, imsi_bcd, imsi_bcd_len) == 0)
|
||||
if (strcmp(ue->imsi_bcd, imsi_bcd) == 0)
|
||||
break;
|
||||
|
||||
ue = list_next(ue);
|
||||
|
|
|
@ -9,23 +9,39 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define HSS_MAX_PROFILE_NAME_LEN 255
|
||||
|
||||
#define HSS_KEY_LEN 16
|
||||
#define HSS_AMF_LEN 2
|
||||
|
||||
typedef int hss_profile_id_t;
|
||||
|
||||
typedef struct _hss_profile_t {
|
||||
lnode_t node; /**< A node of list_t */
|
||||
|
||||
hss_profile_id_t id;
|
||||
c_int8_t name[HSS_MAX_PROFILE_NAME_LEN];
|
||||
|
||||
c_int8_t apn[MAX_APN_LEN];
|
||||
|
||||
/* Security Context */
|
||||
c_uint8_t k[HSS_KEY_LEN];
|
||||
c_uint8_t op[HSS_KEY_LEN];
|
||||
c_uint8_t amf[HSS_AMF_LEN];
|
||||
c_uint64_t sqn;
|
||||
} hss_profile_t;
|
||||
|
||||
typedef struct _hss_ue_t {
|
||||
lnode_t node; /**< A node of list_t */
|
||||
|
||||
c_uint8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
int imsi_bcd_len;
|
||||
|
||||
c_uint8_t msisdn_bcd[MAX_MSISDN_BCD_LEN+1];
|
||||
int msisdn_bcd_len;
|
||||
|
||||
c_uint8_t mei_bcd[MAX_MEI_BCD_LEN+1];
|
||||
int mei_bcd_len;
|
||||
/* UE Identitiy */
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_int8_t msisdn_bcd[MAX_MSISDN_BCD_LEN+1];
|
||||
c_int8_t mei_bcd[MAX_MEI_BCD_LEN+1];
|
||||
|
||||
plmn_id_t visited_plmn_id;
|
||||
|
||||
/* Security Context */
|
||||
c_uint8_t k[HSS_KEY_LEN];
|
||||
c_uint64_t sqn;
|
||||
c_uint8_t rand[RAND_LEN];
|
||||
|
@ -35,9 +51,7 @@ typedef struct _hss_ue_t {
|
|||
} hss_ue_t;
|
||||
|
||||
typedef struct _hss_context_t {
|
||||
c_uint8_t op[HSS_KEY_LEN];
|
||||
c_uint8_t amf[HSS_AMF_LEN];
|
||||
|
||||
list_t profile_list;
|
||||
list_t ue_list;
|
||||
} hss_context_t;
|
||||
|
||||
|
@ -45,11 +59,19 @@ CORE_DECLARE(status_t) hss_context_init(void);
|
|||
CORE_DECLARE(void) hss_context_final(void);
|
||||
CORE_DECLARE(hss_context_t*) hss_self(void);
|
||||
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_add(void);
|
||||
CORE_DECLARE(hss_profile_t*) hss_profile_add(hss_profile_id_t id);
|
||||
CORE_DECLARE(status_t) hss_profile_remove(hss_profile_t *profile);
|
||||
CORE_DECLARE(status_t) hss_profile_remove_all(void);
|
||||
CORE_DECLARE(hss_profile_t*) hss_profile_find_by_id(hss_profile_id_t id);
|
||||
CORE_DECLARE(hss_profile_t*) hss_profile_find_by_name(c_int8_t *name);
|
||||
CORE_DECLARE(hss_profile_t*) hss_profile_first(void);
|
||||
CORE_DECLARE(hss_profile_t*) hss_profile_next(hss_profile_t *profile);
|
||||
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_add(
|
||||
hss_profile_id_t id, c_int8_t *imsi_bcd);
|
||||
CORE_DECLARE(status_t) hss_ue_remove(hss_ue_t *ue);
|
||||
CORE_DECLARE(status_t) hss_ue_remove_all(void);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_find_by_imsi_bcd(
|
||||
c_uint8_t *imsi_bcd, c_uint8_t imsi_bcd_len);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_find_by_imsi_bcd(c_int8_t *imsi_bcd);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_first(void);
|
||||
CORE_DECLARE(hss_ue_t*) hss_ue_next(hss_ue_t *ue);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
union avp_value val;
|
||||
|
||||
hss_ue_t *ue = NULL;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_uint8_t sqn[HSS_SQN_LEN];
|
||||
c_uint8_t autn[AUTN_LEN];
|
||||
c_uint8_t ik[HSS_KEY_LEN];
|
||||
|
@ -60,14 +61,11 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
goto out,);
|
||||
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
|
||||
|
||||
ue = hss_ue_find_by_imsi_bcd(
|
||||
hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
strncpy(imsi_bcd, (char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
ue = hss_ue_find_by_imsi_bcd(imsi_bcd);
|
||||
if (!ue)
|
||||
{
|
||||
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
strncpy(imsi_bcd,
|
||||
(char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
d_warn("Cannot find IMSI:%s\n", imsi_bcd);
|
||||
d_warn("Cannot find IMSI:%s", imsi_bcd);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -162,6 +160,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
union avp_value val;
|
||||
|
||||
hss_ue_t *ue = NULL;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
d_assert(msg, return EINVAL,);
|
||||
|
||||
|
@ -174,14 +173,11 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
goto out,);
|
||||
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
|
||||
|
||||
ue = hss_ue_find_by_imsi_bcd(
|
||||
hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
strncpy(imsi_bcd, (char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
ue = hss_ue_find_by_imsi_bcd(imsi_bcd);
|
||||
if (!ue)
|
||||
{
|
||||
char imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
strncpy(imsi_bcd,
|
||||
(char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
d_warn("Cannot find IMSI:%s\n", imsi_bcd);
|
||||
d_warn("Cannot find IMSI:%s", imsi_bcd);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#define TRACE_MODULE _emm_handler
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "nas_message.h"
|
||||
|
||||
|
@ -64,7 +65,14 @@ void emm_handle_attach_request(
|
|||
{
|
||||
nas_imsi_to_bcd(
|
||||
&eps_mobile_identity->imsi, eps_mobile_identity->length,
|
||||
ue->imsi_bcd, &ue->imsi_bcd_len);
|
||||
ue->imsi_bcd);
|
||||
core_bcd_to_buffer(ue->imsi_bcd, ue->imsi, &ue->imsi_len);
|
||||
d_assert(ue->imsi_len, return,
|
||||
"Can't get IMSI(len:%d\n", ue->imsi_len);
|
||||
ue->msisdn_len = ue->imsi_len;
|
||||
memcpy(ue->msisdn, ue->imsi, ue->msisdn_len);
|
||||
ue->mei_len = ue->imsi_len;
|
||||
memcpy(ue->mei, ue->imsi, ue->mei_len);
|
||||
|
||||
memcpy(&ue->visited_plmn_id, &mme_self()->plmn_id, PLMN_ID_LEN);
|
||||
if (attach_request->presencemask &
|
||||
|
|
|
@ -100,13 +100,13 @@ typedef struct _mme_ue_t {
|
|||
/* UE identity */
|
||||
c_uint32_t enb_ue_s1ap_id; /** eNB-UE-S1AP-ID received from eNB */
|
||||
c_uint32_t mme_ue_s1ap_id; /** MME-UE-S1AP-ID received from MME */
|
||||
#if 0
|
||||
c_uint8_t imsi[MAX_IMSI_LEN];
|
||||
c_uint8_t imsi_len;
|
||||
#else
|
||||
c_uint8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_uint8_t imsi_bcd_len;
|
||||
#endif
|
||||
int imsi_len;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_uint8_t msisdn[MAX_MSISDN_LEN];
|
||||
int msisdn_len;
|
||||
c_uint8_t mei[MAX_MSISDN_LEN];
|
||||
int mei_len;
|
||||
|
||||
/* UE Info */
|
||||
plmn_id_t visited_plmn_id;
|
||||
|
|
|
@ -205,8 +205,8 @@ int mme_s6a_send_air(mme_ue_t *ue)
|
|||
|
||||
/* Set the User-Name AVP */
|
||||
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
|
||||
val.os.data = ue->imsi_bcd;
|
||||
val.os.len = ue->imsi_bcd_len;
|
||||
val.os.data = (c_uint8_t *)ue->imsi_bcd;
|
||||
val.os.len = strlen(ue->imsi_bcd);
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
|
||||
|
@ -451,8 +451,8 @@ int mme_s6a_send_ulr(mme_ue_t *ue)
|
|||
|
||||
/* Set the User-Name AVP */
|
||||
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
|
||||
val.os.data = ue->imsi_bcd;
|
||||
val.os.len = ue->imsi_bcd_len;
|
||||
val.os.data = (c_uint8_t *)ue->imsi_bcd;
|
||||
val.os.len = strlen(ue->imsi_bcd);
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
#include "nas_conv.h"
|
||||
|
||||
void nas_imsi_to_bcd(
|
||||
nas_mobile_identity_imsi_t *imsi, c_uint8_t imsi_len,
|
||||
c_uint8_t *bcd, c_uint8_t *bcd_len)
|
||||
nas_mobile_identity_imsi_t *imsi, c_uint8_t imsi_len, c_int8_t *bcd)
|
||||
{
|
||||
int bcd_len;
|
||||
|
||||
bcd[0] = '0' + imsi->digit1;
|
||||
bcd[1] = '0' + imsi->digit2;
|
||||
bcd[2] = '0' + imsi->digit3;
|
||||
|
@ -24,15 +25,15 @@ void nas_imsi_to_bcd(
|
|||
bcd[13] = '0' + imsi->digit14;
|
||||
bcd[14] = '0' + imsi->digit15;
|
||||
|
||||
*bcd_len = imsi_len * 2 - 1;
|
||||
bcd_len = imsi_len * 2 - 1;
|
||||
if (!imsi->odd_even) /* if bcd length is even */
|
||||
{
|
||||
if (bcd[*bcd_len] != 0xf)
|
||||
d_warn("Spec warning : bcd[%d] = 0x%x", *bcd_len, bcd[*bcd_len]);
|
||||
(*bcd_len)--;
|
||||
if (bcd[bcd_len] != 0xf)
|
||||
d_warn("Spec warning : bcd[%d] = 0x%x", bcd_len, bcd[bcd_len]);
|
||||
(bcd_len)--;
|
||||
}
|
||||
|
||||
bcd[*bcd_len] = 0;
|
||||
bcd[bcd_len] = 0;
|
||||
}
|
||||
|
||||
void nas_imsi_to_buffer(
|
||||
|
|
|
@ -12,8 +12,7 @@ CORE_DECLARE(void) nas_imsi_to_buffer(
|
|||
c_uint8_t *buf, c_uint8_t *buf_len);
|
||||
|
||||
CORE_DECLARE(void) nas_imsi_to_bcd(
|
||||
nas_mobile_identity_imsi_t *imsi, c_uint8_t imsi_len,
|
||||
c_uint8_t *bcd, c_uint8_t *bcd_len);
|
||||
nas_mobile_identity_imsi_t *imsi, c_uint8_t imsi_len, c_int8_t *bcd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue