merge (+rename) iu_helpers.c into libosmo-ranap
This commit is contained in:
parent
a95d5a5f51
commit
056984fab1
|
@ -24,9 +24,9 @@ RANAP_LIBVERSION=0:0:0
|
|||
lib_LTLIBRARIES = libosmo-ranap.la
|
||||
libosmo_ranap_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(RANAP_LIBVERSION)
|
||||
libosmo_ranap_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(ASN1C_LIBS) $(COMMON_LDADD) ranap/libosmo-asn1-ranap.la
|
||||
libosmo_ranap_la_SOURCES = ranap_common.c ranap_encoder.c ranap_decoder.c ranap_msg_factory.c
|
||||
libosmo_ranap_la_SOURCES = ranap_common.c ranap_encoder.c ranap_decoder.c ranap_msg_factory.c iu_helpers.c
|
||||
|
||||
osmoranap_HEADERS = ranap_common.h ranap_ies_defs.h ranap_msg_factory.h
|
||||
osmoranap_HEADERS = ranap_common.h ranap_ies_defs.h ranap_msg_factory.h iu_helpers.h
|
||||
osmoranapdir = $(includedir)/osmocom/ranap
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ noinst_HEADERS = hnbap_common.h hnbap_ies_defs.h \
|
|||
|
||||
osmo_hnbgw_SOURCES = hnbap_encoder.c hnbap_decoder.c hnbap_common.c \
|
||||
rua_encoder.c rua_decoder.c rua_common.c \
|
||||
iu_helpers.c asn1helpers.c sccp_helpers.c \
|
||||
asn1helpers.c sccp_helpers.c \
|
||||
hnbgw.c hnbgw_hnbap.c hnbgw_rua.c hnbgw_ranap.c \
|
||||
context_map.c hnbgw_cn.c
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ static int hnbgw_tx_ue_register_acc(struct ue_context *ue)
|
|||
size_t encoded_imsi_len;
|
||||
int rc;
|
||||
|
||||
encoded_imsi_len = encode_iu_imsi(encoded_imsi,
|
||||
encoded_imsi_len = ranap_imsi_encode(encoded_imsi,
|
||||
sizeof(encoded_imsi), ue->imsi);
|
||||
|
||||
memset(&accept, 0, sizeof(accept));
|
||||
|
@ -150,15 +150,15 @@ static int hnbgw_rx_ue_register_req(struct hnb_context *ctx, ANY_t *in)
|
|||
|
||||
switch (ies.uE_Identity.present) {
|
||||
case UE_Identity_PR_iMSI:
|
||||
decode_iu_bcd(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSI.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSI.buf,
|
||||
ies.uE_Identity.choice.iMSI.size);
|
||||
break;
|
||||
case UE_Identity_PR_iMSIDS41:
|
||||
decode_iu_bcd(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSIDS41.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSIDS41.buf,
|
||||
ies.uE_Identity.choice.iMSIDS41.size);
|
||||
break;
|
||||
case UE_Identity_PR_iMSIESN:
|
||||
decode_iu_bcd(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSIESN.iMSIDS41.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), ies.uE_Identity.choice.iMSIESN.iMSIDS41.buf,
|
||||
ies.uE_Identity.choice.iMSIESN.iMSIDS41.size);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <osmocom/core/utils.h>
|
||||
|
||||
/* decode a BCD-string as used inside ASN.1 encoded Iu interface protocols */
|
||||
int decode_iu_bcd(char *out, size_t out_len, const uint8_t *in, size_t in_len)
|
||||
int ranap_bcd_decode(char *out, size_t out_len, const uint8_t *in, size_t in_len)
|
||||
{
|
||||
const uint8_t *ch;
|
||||
char *outch = out;
|
||||
|
@ -45,7 +45,7 @@ int decode_iu_bcd(char *out, size_t out_len, const uint8_t *in, size_t in_len)
|
|||
}
|
||||
|
||||
/* decode an IMSI as used inside ASN.1 encoded Iu interface protocols */
|
||||
int encode_iu_imsi(uint8_t *out, size_t out_len, const char *in)
|
||||
int ranap_imsi_encode(uint8_t *out, size_t out_len, const char *in)
|
||||
{
|
||||
unsigned int len = strlen(in);
|
||||
unsigned int octlen;
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int decode_iu_bcd(char *out, size_t out_len, const uint8_t *in, size_t in_len);
|
||||
int encode_iu_imsi(uint8_t *out, size_t out_len, const char *in);
|
||||
int ranap_bcd_decode(char *out, size_t out_len, const uint8_t *in, size_t in_len);
|
||||
int ranap_imsi_encode(uint8_t *out, size_t out_len, const char *in);
|
||||
|
|
|
@ -276,7 +276,7 @@ struct msgb *ranap_new_msg_common_id(const char *imsi)
|
|||
|
||||
if (imsi) {
|
||||
uint8_t *imsi_buf = CALLOC(1, 16);
|
||||
rc = encode_iu_imsi(imsi_buf, 16, imsi);
|
||||
rc = ranap_imsi_encode(imsi_buf, 16, imsi);
|
||||
ies.permanentNAS_UE_ID.present = RANAP_PermanentNAS_UE_ID_PR_iMSI;
|
||||
ies.permanentNAS_UE_ID.choice.iMSI.buf = imsi_buf;
|
||||
ies.permanentNAS_UE_ID.choice.iMSI.size = rc;
|
||||
|
@ -350,7 +350,7 @@ struct msgb *ranap_new_msg_paging_cmd(const char *imsi, const uint32_t *tmsi, in
|
|||
else
|
||||
ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_cs_domain;
|
||||
|
||||
rc = encode_iu_imsi(imsi_buf, 16, imsi);
|
||||
rc = ranap_imsi_encode(imsi_buf, 16, imsi);
|
||||
ies.permanentNAS_UE_ID.present = RANAP_PermanentNAS_UE_ID_PR_iMSI;
|
||||
ies.permanentNAS_UE_ID.choice.iMSI.buf = imsi_buf;
|
||||
ies.permanentNAS_UE_ID.choice.iMSI.size = rc;
|
||||
|
|
|
@ -6,13 +6,13 @@ check_PROGRAMS = test-ranap test-helpers test-hnbap hnb-test dummy-cn
|
|||
|
||||
HNBAP_FILES = $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c $(top_builddir)/src/hnbap_encoder.c
|
||||
RUA_FILES = $(top_builddir)/src/rua_common.c $(top_builddir)/src/rua_decoder.c $(top_builddir)/src/rua_encoder.c
|
||||
HELPER_FILES = $(top_builddir)/src/iu_helpers.c $(top_builddir)/src/asn1helpers.c
|
||||
HELPER_FILES = $(top_builddir)/src/asn1helpers.c
|
||||
|
||||
test_helpers_SOURCES = $(HELPER_FILES) test-helpers.c
|
||||
test_helpers_LDADD = $(COMMON_LIBS)
|
||||
test_helpers_LDADD = $(COMMON_LIBS) $(top_builddir)/src/libosmo-ranap.la
|
||||
|
||||
test_hnbap_SOURCES = $(HELPER_FILES) $(top_builddir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c test-hnbap.c test_common.c
|
||||
test_hnbap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a
|
||||
test_hnbap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a $(top_builddir)/src/libosmo-ranap.la
|
||||
|
||||
hnb_test_SOURCES = $(HELPER_FILES) $(HNBAP_FILES) $(RUA_FILES) hnb-test.c rua_helper.c test_common.c
|
||||
hnb_test_LDADD = $(COMMON_LIBS) $(top_builddir)/src/hnbap/libosmo-asn1-hnbap.a $(top_builddir)/src/rua/libosmo-asn1-rua.a $(top_builddir)/src/libosmo-ranap.la
|
||||
|
|
|
@ -106,7 +106,7 @@ static int hnb_test_ue_register_tx(struct hnb_test *hnb_test, const char *imsi_s
|
|||
|
||||
request.uE_Identity.present = UE_Identity_PR_iMSI;
|
||||
|
||||
imsi_len = encode_iu_imsi(imsi_buf, sizeof(imsi_buf), imsi_str);
|
||||
imsi_len = ranap_imsi_encode(imsi_buf, sizeof(imsi_buf), imsi_str);
|
||||
OCTET_STRING_fromBuf(&request.uE_Identity.choice.iMSI, imsi_buf, imsi_len);
|
||||
|
||||
request.registration_Cause = Registration_Cause_normal;
|
||||
|
@ -162,7 +162,7 @@ static int hnb_test_rx_ue_register_acc(struct hnb_test *hnb, ANY_t *in)
|
|||
|
||||
ctx_id = asn1bitstr_to_u24(&accept.context_ID);
|
||||
|
||||
decode_iu_bcd(imsi, sizeof(imsi), accept.uE_Identity.choice.iMSI.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), accept.uE_Identity.choice.iMSI.buf,
|
||||
accept.uE_Identity.choice.iMSI.size);
|
||||
printf("UE Register accept for IMSI %s, context %u\n", imsi, ctx_id);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
int asn1_xer_print = 0;
|
||||
void *talloc_asn1_ctx;
|
||||
|
||||
/* use odd number of digits */
|
||||
|
@ -43,13 +44,13 @@ void test_iu_helpers(void)
|
|||
|
||||
printf("pre-encoded: %s\n", osmo_hexdump_nospc(imsi_encoded,
|
||||
sizeof(imsi_encoded)));
|
||||
rc = decode_iu_bcd(outstr, sizeof(outstr), imsi_encoded,
|
||||
rc = ranap_bcd_decode(outstr, sizeof(outstr), imsi_encoded,
|
||||
sizeof(imsi_encoded));
|
||||
ASSERT(rc >= 0);
|
||||
printf("decoded: %s\n", outstr);
|
||||
ASSERT(!strcmp(outstr, imsi_decoded));
|
||||
|
||||
rc = encode_iu_imsi(outbuf, sizeof(outbuf), imsi_decoded);
|
||||
rc = ranap_imsi_encode(outbuf, sizeof(outbuf), imsi_decoded);
|
||||
ASSERT(rc >= 0);
|
||||
printf("re-encoded: %s\n", osmo_hexdump_nospc(outbuf, rc));
|
||||
ASSERT(!memcmp(outbuf, imsi_encoded, sizeof(imsi_encoded)));
|
||||
|
|
|
@ -134,7 +134,7 @@ void test_asn1_decoding(void)
|
|||
ASSERT(rc >= 0);
|
||||
|
||||
ASSERT(ue_req_ies.uE_Identity.present == UE_Identity_PR_iMSI);
|
||||
decode_iu_bcd(imsi, sizeof(imsi), ue_req_ies.uE_Identity.choice.iMSI.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), ue_req_ies.uE_Identity.choice.iMSI.buf,
|
||||
ue_req_ies.uE_Identity.choice.iMSI.size);
|
||||
|
||||
printf("HNBAP UE Register request from IMSI %s\n", imsi);
|
||||
|
@ -154,7 +154,7 @@ void test_asn1_decoding(void)
|
|||
ASSERT(rc >= 0);
|
||||
|
||||
ASSERT(ue_acc_ies.uE_Identity.present == UE_Identity_PR_iMSI);
|
||||
decode_iu_bcd(imsi, sizeof(imsi), ue_acc_ies.uE_Identity.choice.iMSI.buf,
|
||||
ranap_bcd_decode(imsi, sizeof(imsi), ue_acc_ies.uE_Identity.choice.iMSI.buf,
|
||||
ue_acc_ies.uE_Identity.choice.iMSI.size);
|
||||
|
||||
printf("HNBAP UE Register accept to IMSI %s\n", imsi);
|
||||
|
|
Loading…
Reference in New Issue