aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gprs_sgsn.c
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/src/gprs/gprs_sgsn.c
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/src/gprs/gprs_sgsn.c')
-rw-r--r--openbsc/src/gprs/gprs_sgsn.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 3c25840ef..cc1ae4d25 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -207,6 +207,14 @@ void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *mm)
struct sgsn_pdp_ctx *pdp, *pdp2;
struct sgsn_signal_data sig_data;
+ /* Forget about ongoing look-ups */
+ if (mm->ggsn_lookup) {
+ LOGMMCTXP(LOGL_NOTICE, mm,
+ "Cleaning mmctx with on-going query.\n");
+ mm->ggsn_lookup->mmctx = NULL;
+ mm->ggsn_lookup = NULL;
+ }
+
/* delete all existing PDP contexts for this MS */
llist_for_each_entry_safe(pdp, pdp2, &mm->pdp_list, list) {
LOGMMCTXP(LOGL_NOTICE, mm,
@@ -349,6 +357,8 @@ void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp)
lib->priv = NULL;
}
+ if (pdp->destroy_ggsn)
+ sgsn_ggsn_ctx_free(pdp->ggsn);
talloc_free(pdp);
}
@@ -614,7 +624,8 @@ static void insert_qos(struct tlv_parsed *tp, struct sgsn_subscriber_pdp_data *p
*/
struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx,
struct tlv_parsed *tp,
- enum gsm48_gsm_cause *gsm_cause)
+ enum gsm48_gsm_cause *gsm_cause,
+ char *out_apn_str)
{
char req_apn_str[GSM_APN_LENGTH] = {0};
const struct apn_ctx *apn_ctx = NULL;
@@ -623,6 +634,8 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx,
struct sgsn_ggsn_ctx *ggsn = NULL;
int allow_any_apn = 0;
+ out_apn_str[0] = '\0';
+
if (TLVP_PRESENT(tp, GSM48_IE_GSM_APN)) {
if (TLVP_LEN(tp, GSM48_IE_GSM_APN) >= GSM_APN_LENGTH - 1) {
LOGMMCTXP(LOGL_ERROR, mmctx, "APN IE too long\n");
@@ -695,6 +708,9 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx,
return NULL;
}
+ /* copy the selected apn_str */
+ strcpy(out_apn_str, selected_apn_str);
+
if (apn_ctx == NULL && selected_apn_str)
apn_ctx = sgsn_apn_ctx_match(selected_apn_str, mmctx->imsi);