rename it
This commit is contained in:
parent
be70447728
commit
235c2212ae
|
@ -88,7 +88,7 @@ CORE_DECLARE(status_t) core_generate_random_bytes(
|
|||
c_uint8_t *buf, int length);
|
||||
|
||||
CORE_DECLARE(void *) core_ascii_to_hex(char *in, int len, void *out);
|
||||
CORE_DECLARE(void *) core_int_to_buffer(c_uint64_t num,
|
||||
CORE_DECLARE(void *) core_uint64_to_buffer(c_uint64_t num,
|
||||
c_uint8_t *buffer, int size);
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -29,7 +29,7 @@ void *core_ascii_to_hex(char *in, int len, void *out)
|
|||
return out;
|
||||
}
|
||||
|
||||
void *core_int_to_buffer(c_uint64_t num, c_uint8_t *buffer, int size)
|
||||
void *core_uint64_to_buffer(c_uint64_t num, c_uint8_t *buffer, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
|
|
|
@ -46,21 +46,21 @@ static void misc_test3(abts_case *tc, void *data)
|
|||
c_uint64_t num;
|
||||
|
||||
num = 0x0123456789abcdef;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 8), 8) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 8), 8) == 0);
|
||||
num = 0x0123456789abcd;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 7), 7) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 7), 7) == 0);
|
||||
num = 0x0123456789ab;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 6), 6) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 6), 6) == 0);
|
||||
num = 0x0123456789;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 5), 5) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 5), 5) == 0);
|
||||
num = 0x01234567;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 4), 4) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 4), 4) == 0);
|
||||
num = 0x012345;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 3), 3) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 3), 3) == 0);
|
||||
num = 0x0123;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 2), 2) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 2), 2) == 0);
|
||||
num = 0x01;
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_int_to_buffer(num, buf, 1), 1) == 0);
|
||||
ABTS_TRUE(tc, memcmp(tmp, core_uint64_to_buffer(num, buf, 1), 1) == 0);
|
||||
}
|
||||
|
||||
abts_suite *testmisc(abts_suite *suite)
|
||||
|
|
|
@ -74,7 +74,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
milenage_opc(ue->k, ue->op, ue->opc);
|
||||
milenage_generate(ue->opc, ue->amf, ue->k,
|
||||
core_int_to_buffer(ue->sqn, sqn, MAX_SQN_LEN), ue->rand,
|
||||
core_uint64_to_buffer(ue->sqn, sqn, MAX_SQN_LEN), ue->rand,
|
||||
autn, ik, ck, ak, xres, &xres_len);
|
||||
derive_kasme(ck, ik, hdr->avp_value->os.data, sqn, ak, kasme);
|
||||
|
||||
|
|
|
@ -162,9 +162,7 @@ status_t enb_s1_handle_s1setuprequest(enb_ctx_t *enb, s1ap_message *message)
|
|||
ies = &message->msg.s1ap_S1SetupRequestIEs;
|
||||
d_assert(ies, return CORE_ERROR, "Null param");
|
||||
|
||||
rv = s1ap_conv_uint32_from_enb_id(&enb_id, &ies->global_ENB_ID.eNB_ID);
|
||||
d_assert(rv == CORE_OK, return rv, "Null param");
|
||||
|
||||
s1ap_ENB_ID_to_uint32(&ies->global_ENB_ID.eNB_ID, &enb_id);
|
||||
if (mme_ctx_enb_find_by_id(enb_id))
|
||||
{
|
||||
S1ap_Cause_t cause;
|
||||
|
|
|
@ -34,7 +34,7 @@ status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
|
|||
plmnIdentity = (S1ap_PLMNidentity_t *)
|
||||
core_calloc(srvd_gummei->num_of_plmn_id,
|
||||
sizeof(S1ap_PLMNidentity_t));
|
||||
s1ap_conv_plmn_id_to_tbcd_string(
|
||||
s1ap_plmn_id_to_TBCD_STRING(
|
||||
&srvd_gummei->plmn_id[j], plmnIdentity);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedPLMNs, plmnIdentity);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
|
|||
mmeGroupId = (S1ap_MME_Group_ID_t *)
|
||||
core_calloc(srvd_gummei->num_of_mme_gid,
|
||||
sizeof(S1ap_MME_Group_ID_t));
|
||||
s1ap_conv_uint16_to_octet_string(
|
||||
s1ap_uint16_to_OCTET_STRING(
|
||||
srvd_gummei->mme_gid[j], mmeGroupId);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedGroupIDs, mmeGroupId);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
|
|||
mmeCode = (S1ap_MME_Code_t *)
|
||||
core_calloc(srvd_gummei->num_of_mme_code,
|
||||
sizeof(S1ap_MME_Code_t));
|
||||
s1ap_conv_uint8_to_octet_string(
|
||||
s1ap_uint8_to_OCTET_STRING(
|
||||
srvd_gummei->mme_code[j], mmeCode);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedMMECs, mmeCode);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
#include "plmn_id.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint8_to_octet_string(
|
||||
c_uint8_t uint8, OCTET_STRING_t *octet_string)
|
||||
void s1ap_uint8_to_OCTET_STRING(c_uint8_t uint8, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 1;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
@ -14,8 +13,7 @@ CORE_DECLARE(void) s1ap_conv_uint8_to_octet_string(
|
|||
octet_string->buf[0] = uint8;
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint16_to_octet_string(
|
||||
c_uint16_t uint16, OCTET_STRING_t *octet_string)
|
||||
void s1ap_uint16_to_OCTET_STRING(c_uint16_t uint16, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 2;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
@ -24,8 +22,7 @@ CORE_DECLARE(void) s1ap_conv_uint16_to_octet_string(
|
|||
octet_string->buf[1] = uint16;
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint32_to_octet_string(
|
||||
c_uint32_t uint32, OCTET_STRING_t *octet_string)
|
||||
void s1ap_uint32_to_OCTET_STRING(c_uint32_t uint32, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 4;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
@ -36,7 +33,7 @@ CORE_DECLARE(void) s1ap_conv_uint32_to_octet_string(
|
|||
octet_string->buf[0] = uint32;
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_plmn_id_to_tbcd_string(
|
||||
void s1ap_plmn_id_to_TBCD_STRING(
|
||||
plmn_id_t *plmn_id, S1ap_TBCD_STRING_t *tbcd_string)
|
||||
|
||||
{
|
||||
|
@ -46,43 +43,57 @@ CORE_DECLARE(void) s1ap_conv_plmn_id_to_tbcd_string(
|
|||
plmn_id_to_buffer(plmn_id, tbcd_string->buf);
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_macro_enb_id_to_bit_string(
|
||||
c_uint32_t enb_id, BIT_STRING_t *bit_string)
|
||||
void s1ap_uint32_to_ENB_ID(
|
||||
S1ap_ENB_ID_PR present, c_uint32_t enb_id, S1ap_ENB_ID_t *eNB_ID)
|
||||
{
|
||||
bit_string->size = 3;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
d_assert(eNB_ID, return, "Null param");
|
||||
|
||||
bit_string->buf[0] = enb_id >> 12;
|
||||
bit_string->buf[1] = enb_id >> 4;
|
||||
bit_string->buf[2] = (enb_id & 0xf) << 4;
|
||||
eNB_ID->present = present;
|
||||
if (present == S1ap_ENB_ID_PR_macroENB_ID)
|
||||
{
|
||||
BIT_STRING_t *bit_string = &eNB_ID->choice.macroENB_ID;
|
||||
d_assert(bit_string, return, "Null param");
|
||||
|
||||
bit_string->size = 3;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
|
||||
bit_string->buf[0] = enb_id >> 12;
|
||||
bit_string->buf[1] = enb_id >> 4;
|
||||
bit_string->buf[2] = (enb_id & 0xf) << 4;
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
else if (present == S1ap_ENB_ID_PR_homeENB_ID)
|
||||
{
|
||||
BIT_STRING_t *bit_string = &eNB_ID->choice.homeENB_ID;
|
||||
d_assert(bit_string, return, "Null param");
|
||||
|
||||
bit_string->size = 4;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
|
||||
bit_string->buf[0] = enb_id >> 20;
|
||||
bit_string->buf[1] = enb_id >> 12;
|
||||
bit_string->buf[2] = enb_id >> 4;
|
||||
bit_string->buf[3] = (enb_id & 0xf) << 4;
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_assert(0, return, "Invalid param");
|
||||
}
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_home_enb_id_to_bit_string(
|
||||
c_uint32_t enb_id, BIT_STRING_t *bit_string)
|
||||
void s1ap_ENB_ID_to_uint32(S1ap_ENB_ID_t *eNB_ID, c_uint32_t *uint32)
|
||||
{
|
||||
bit_string->size = 4;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
|
||||
bit_string->buf[0] = enb_id >> 20;
|
||||
bit_string->buf[1] = enb_id >> 12;
|
||||
bit_string->buf[2] = enb_id >> 4;
|
||||
bit_string->buf[3] = (enb_id & 0xf) << 4;
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_conv_uint32_from_enb_id(
|
||||
c_uint32_t *uint32, S1ap_ENB_ID_t *eNB_ID)
|
||||
{
|
||||
d_assert(uint32, return CORE_ERROR, "Null param");
|
||||
d_assert(eNB_ID, return CORE_ERROR, "Null param");
|
||||
d_assert(uint32, return, "Null param");
|
||||
d_assert(eNB_ID, return, "Null param");
|
||||
|
||||
if (eNB_ID->present == S1ap_ENB_ID_PR_homeENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.homeENB_ID.buf;
|
||||
d_assert(buf, return CORE_ERROR, "Null param");
|
||||
d_assert(buf, return, "Null param");
|
||||
*uint32 = (buf[0] << 20) + (buf[1] << 12) + (buf[2] << 4) +
|
||||
((buf[3] & 0xf0) >> 4);
|
||||
|
||||
|
@ -90,13 +101,11 @@ CORE_DECLARE(status_t) s1ap_conv_uint32_from_enb_id(
|
|||
else if (eNB_ID->present == S1ap_ENB_ID_PR_macroENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.macroENB_ID.buf;
|
||||
d_assert(buf, return CORE_ERROR, "Null param");
|
||||
d_assert(buf, return, "Null param");
|
||||
*uint32 = (buf[0] << 12) + (buf[1] << 4) + ((buf[2] & 0xf0) >> 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CORE_ERROR;
|
||||
d_assert(0, return, "Invalid param");
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
|
|
@ -8,23 +8,20 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint8_to_octet_string(
|
||||
CORE_DECLARE(void) s1ap_uint8_to_OCTET_STRING(
|
||||
c_uint8_t uint8, OCTET_STRING_t *octet_string);
|
||||
CORE_DECLARE(void) s1ap_conv_uint16_to_octet_string(
|
||||
CORE_DECLARE(void) s1ap_uint16_to_OCTET_STRING(
|
||||
c_uint16_t uint16, OCTET_STRING_t *octet_string);
|
||||
CORE_DECLARE(void) s1ap_conv_uint32_to_octet_string(
|
||||
CORE_DECLARE(void) s1ap_uint32_to_OCTET_STRING(
|
||||
c_uint32_t uint32, OCTET_STRING_t *octet_string);
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_plmn_id_to_tbcd_string(
|
||||
CORE_DECLARE(void) s1ap_plmn_id_to_TBCD_STRING(
|
||||
plmn_id_t *plmn_id, S1ap_TBCD_STRING_t *tbcd_string);
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_macro_enb_id_to_bit_string(
|
||||
c_uint32_t enb_id, BIT_STRING_t *bit_string);
|
||||
CORE_DECLARE(void) s1ap_conv_home_enb_id_to_bit_string(
|
||||
c_uint32_t enb_id, BIT_STRING_t *bit_string);
|
||||
CORE_DECLARE(status_t) s1ap_conv_uint32_from_enb_id(
|
||||
c_uint32_t *uint32, S1ap_ENB_ID_t *eNB_ID);
|
||||
|
||||
CORE_DECLARE(void) s1ap_uint32_to_ENB_ID(
|
||||
S1ap_ENB_ID_PR present, c_uint32_t enb_id, S1ap_ENB_ID_t *eNB_ID);
|
||||
CORE_DECLARE(void) s1ap_ENB_ID_to_uint32(
|
||||
S1ap_ENB_ID_t *eNB_ID, c_uint32_t *uint32);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,19 +19,18 @@ status_t s1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id)
|
|||
|
||||
ies = &message.msg.s1ap_S1SetupRequestIEs;
|
||||
|
||||
ies->global_ENB_ID.eNB_ID.present = S1ap_ENB_ID_PR_macroENB_ID;
|
||||
s1ap_conv_macro_enb_id_to_bit_string(enb_id,
|
||||
&ies->global_ENB_ID.eNB_ID.choice.macroENB_ID);
|
||||
s1ap_conv_plmn_id_to_tbcd_string(
|
||||
s1ap_uint32_to_ENB_ID(S1ap_ENB_ID_PR_macroENB_ID, enb_id,
|
||||
&ies->global_ENB_ID.eNB_ID);
|
||||
s1ap_plmn_id_to_TBCD_STRING(
|
||||
&mme_self()->plmn_id, &ies->global_ENB_ID.pLMNidentity);
|
||||
|
||||
supportedTA = (S1ap_SupportedTAs_Item_t *)
|
||||
core_calloc(1, sizeof(S1ap_SupportedTAs_Item_t));
|
||||
s1ap_conv_uint16_to_octet_string(
|
||||
s1ap_uint16_to_OCTET_STRING(
|
||||
mme_self()->tracking_area_code, &supportedTA->tAC);
|
||||
plmnIdentity = (S1ap_PLMNidentity_t *)
|
||||
core_calloc(1, sizeof(S1ap_PLMNidentity_t));
|
||||
s1ap_conv_plmn_id_to_tbcd_string(
|
||||
s1ap_plmn_id_to_TBCD_STRING(
|
||||
&mme_self()->plmn_id, plmnIdentity);
|
||||
ASN_SEQUENCE_ADD(&supportedTA->broadcastPLMNs, plmnIdentity);
|
||||
|
||||
|
|
Loading…
Reference in New Issue