aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn/ggsn.c
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2020-04-25 05:39:21 +0200
committerKeith <keith@rhizomatica.org>2020-04-27 07:37:44 +0200
commita6a8cc1442e266d8d53266c3a24f3cbbb4784768 (patch)
treeb92d674f31979c487652a5a79e926ee98d2f2dbd /ggsn/ggsn.c
parent04715d284f5abc6bce6cd6401c5700e3031662de (diff)
Add default APN for each EUA Typekeith/default-apns
MS may request an unknown APN. In this case we will use the APN configured in the vty as default-apn but if the type support does not match the request we will fail. The commit adds two more vty commands to configure a default vpn for v6 and for v4v6 Change-Id: I03fcf8a1532bd9988ea99a6afd3dc325174ce9d6 Fixes: OS#4511
Diffstat (limited to 'ggsn/ggsn.c')
-rw-r--r--ggsn/ggsn.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 159362f..81d8509 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -446,16 +446,44 @@ int create_context_ind(struct pdp_t *pdp)
LOGPPDP(LOGL_DEBUG, pdp, "Processing create PDP context request for APN '%s'\n",
apn_name ? name_buf : "(NONE)");
+ /* FIXME: we manually force all context requests to dynamic here! */
+ if (pdp->eua.l > 2)
+ pdp->eua.l = 2;
+
+ memset(addr, 0, sizeof(addr));
+ if ((num_addr = in46a_from_eua(&pdp->eua, addr)) < 0) {
+ LOGPPDP(LOGL_ERROR, pdp, "Cannot decode EUA from MS/SGSN: %s\n",
+ osmo_hexdump(pdp->eua.v, pdp->eua.l));
+ gtp_create_context_resp(gsn, pdp, GTPCAUSE_UNKNOWN_PDP);
+ return 0;
+ }
+
/* First find an exact APN name match */
if (apn_name != NULL)
apn = ggsn_find_apn(ggsn, name_buf);
/* ignore if the APN has not been started */
if (apn && !apn->started)
apn = NULL;
-
/* then try default (if any) */
- if (!apn)
- apn = ggsn->cfg.default_apn;
+ if (!apn) {
+ switch (num_addr) {
+ case 2:
+ apn = ggsn->cfg.default_apn_v4v6;
+ break;
+ case 1:
+ if (in46a_is_v4(&addr[0])) {
+ apn = ggsn->cfg.default_apn_v4;
+ } else {
+ apn = ggsn->cfg.default_apn_v6;
+ }
+ break;
+ default:
+ /* in46a_from_eua() returned other than 1 or 2 ? */
+ OSMO_ASSERT(0);
+ break;
+ }
+ }
+
/* ignore if the APN has not been started */
if (apn && !apn->started)
apn = NULL;
@@ -467,23 +495,11 @@ int create_context_ind(struct pdp_t *pdp)
return 0;
}
- /* FIXME: we manually force all context requests to dynamic here! */
- if (pdp->eua.l > 2)
- pdp->eua.l = 2;
-
memcpy(pdp->qos_neg0, pdp->qos_req0, sizeof(pdp->qos_req0));
memcpy(pdp->qos_neg.v, pdp->qos_req.v, pdp->qos_req.l); /* TODO */
pdp->qos_neg.l = pdp->qos_req.l;
- memset(addr, 0, sizeof(addr));
- if ((num_addr = in46a_from_eua(&pdp->eua, addr)) < 0) {
- LOGPPDP(LOGL_ERROR, pdp, "Cannot decode EUA from MS/SGSN: %s\n",
- osmo_hexdump(pdp->eua.v, pdp->eua.l));
- gtp_create_context_resp(gsn, pdp, GTPCAUSE_UNKNOWN_PDP);
- return 0;
- }
-
/* Store the actual APN for logging and the VTY */
rc = osmo_apn_from_str(pdp->apn_use.v, sizeof(pdp->apn_use.v), apn->cfg.name);
if (rc < 0) /* Unlikely this would happen, but anyway... */