aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-01-03 16:31:31 +0100
committerHarald Welte <laforge@gnumonks.org>2016-01-03 16:31:31 +0100
commit056984fab1c1d6f80b5dc28f4c83eb80515d7c25 (patch)
tree464c52e786dddd420129f0f0a177b9e48e61f106 /src
parenta95d5a5f51d2dcc6b7bffdfe971148a6307e94d9 (diff)
merge (+rename) iu_helpers.c into libosmo-ranap
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/hnbgw_hnbap.c8
-rw-r--r--src/iu_helpers.c4
-rw-r--r--src/iu_helpers.h4
-rw-r--r--src/ranap_msg_factory.c4
-rw-r--r--src/tests/Makefile.am6
-rw-r--r--src/tests/hnb-test.c4
-rw-r--r--src/tests/test-helpers.c5
-rw-r--r--src/tests/test-hnbap.c4
9 files changed, 23 insertions, 22 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 93b6fba..6dbd73e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index 87dc343..7790bfd 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.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:
diff --git a/src/iu_helpers.c b/src/iu_helpers.c
index dfe47d6..2f44e93 100644
--- a/src/iu_helpers.c
+++ b/src/iu_helpers.c
@@ -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;
diff --git a/src/iu_helpers.h b/src/iu_helpers.h
index 531d673..109b6da 100644
--- a/src/iu_helpers.h
+++ b/src/iu_helpers.h
@@ -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);
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index 3e69c48..0c015e5 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -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;
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 973cf3f..43b63cc 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -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
diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index cd07d7c..f26e222 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -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);
diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c
index 60f3d3b..b514d10 100644
--- a/src/tests/test-helpers.c
+++ b/src/tests/test-helpers.c
@@ -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)));
diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c
index 0005fe1..5101ff4 100644
--- a/src/tests/test-hnbap.c
+++ b/src/tests/test-hnbap.c
@@ -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);