summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-05-25 12:26:49 +0800
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-05-25 15:57:57 +0800
commit39c430ee2929f0671203974db11dfdd4ff4841cb (patch)
treef7fedeadef2803179a16e187589f5647917279cf /openbsc/tests
parent66e7106d393368b2dd0d04c08f31781ed997380b (diff)
sgsn: Allow to resolve the IPv4 address of a GGSN through DNS
For real networks we need to check if the requested APN string is allowed and then resolve the GGSN address through DNS. There are countries with two or three digit MNCs and one could either try to keep a list of countries that have two/three digits or just try both of them. I have opted for the later for the ease of the implementation. C-Ares doesn't allow to cancel a request so we will need to have the MMCTX and the Lookup have different lifetimes. We simply set ->mmctx to NULL in case the MMCTX dies more early. The selected and verified apn_str will be copied into the out parameter. In case no static APN/GGSN config is present and the dynamic mode is enabled a request will be made.
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/sgsn/Makefile.am4
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c24
2 files changed, 19 insertions, 9 deletions
diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am
index 693cf79..3c202dd 100644
--- a/openbsc/tests/sgsn/Makefile.am
+++ b/openbsc/tests/sgsn/Makefile.am
@@ -1,5 +1,5 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS)
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBCARES_CFLAGS)
EXTRA_DIST = sgsn_test.ok
@@ -22,6 +22,7 @@ sgsn_test_LDADD = \
$(top_builddir)/src/gprs/sgsn_vty.o \
$(top_builddir)/src/gprs/sgsn_libgtp.o \
$(top_builddir)/src/gprs/sgsn_auth.o \
+ $(top_builddir)/src/gprs/sgsn_ares.o \
$(top_builddir)/src/gprs/gprs_gsup_messages.o \
$(top_builddir)/src/gprs/gprs_gsup_client.o \
$(top_builddir)/src/gprs/gprs_utils.o \
@@ -32,5 +33,6 @@ sgsn_test_LDADD = \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
+ $(LIBCARES_LIBS) \
-lgtp -lrt
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 6457003..7e5ab1a 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -1838,6 +1838,7 @@ static void test_ggsn_selection(void)
struct tlv_parsed tp;
uint8_t apn_enc[GSM_APN_LENGTH + 10];
struct sgsn_subscriber_pdp_data *pdp_data;
+ char apn_str[GSM_APN_LENGTH];
printf("Testing GGSN selection\n");
@@ -1881,29 +1882,33 @@ static void test_ggsn_selection(void)
tp.lv[GSM48_IE_GSM_APN].len =
gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn");
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc != NULL);
OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0);
tp.lv[GSM48_IE_GSM_APN].len =
gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn");
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc != NULL);
OSMO_ASSERT(ggc->id == 1);
+ OSMO_ASSERT(strcmp(apn_str, "Other.Apn") == 0);
tp.lv[GSM48_IE_GSM_APN].len = 0;
tp.lv[GSM48_IE_GSM_APN].val = NULL;
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc != NULL);
OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
actxs[3] = sgsn_apn_ctx_find_alloc("*", "123456");
actxs[3]->ggsn = ggcs[2];
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc != NULL);
OSMO_ASSERT(ggc->id == 2);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
sgsn_apn_ctx_free(actxs[3]);
tp.lv[GSM48_IE_GSM_APN].val = apn_enc;
@@ -1911,12 +1916,13 @@ static void test_ggsn_selection(void)
tp.lv[GSM48_IE_GSM_APN].len =
gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Foo.Bar");
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc == NULL);
OSMO_ASSERT(gsm_cause == GSM_CAUSE_MISSING_APN);
+ OSMO_ASSERT(strcmp(apn_str, "Foo.Bar") == 0);
tp.lv[GSM48_IE_GSM_APN].len = sizeof(apn_enc);
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc == NULL);
OSMO_ASSERT(gsm_cause == GSM_CAUSE_INV_MAND_INFO);
@@ -1927,16 +1933,18 @@ static void test_ggsn_selection(void)
tp.lv[GSM48_IE_GSM_APN].len =
gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn");
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc != NULL);
OSMO_ASSERT(ggc->id == 0);
+ OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0);
tp.lv[GSM48_IE_GSM_APN].len =
gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn");
- ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause);
+ ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str);
OSMO_ASSERT(ggc == NULL);
OSMO_ASSERT(gsm_cause == GSM_CAUSE_REQ_SERV_OPT_NOTSUB);
+ OSMO_ASSERT(strcmp(apn_str, "") == 0);
/* Cleanup */