From 39c430ee2929f0671203974db11dfdd4ff4841cb Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 25 May 2015 12:26:49 +0800 Subject: 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. --- openbsc/tests/sgsn/sgsn_test.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'openbsc/tests/sgsn/sgsn_test.c') diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 64570038e..7e5ab1a91 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 */ -- cgit v1.2.3