diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-05 19:37:05 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-05 19:37:07 +0100 |
commit | fd4d435442429630969c34d20900c89c7ec1dbb7 (patch) | |
tree | fa2a7ec9f7aa068a98886f19b5830f76e61e89ce /src | |
parent | 8ec269a0e0bffc53b2447f50bb54f8d6f6bb8fd4 (diff) |
Move global apn_list inside struct sgsn_instance
This way apns are managed by the lifcycle of the main global struct
sgsn_instance automatically.
Change-Id: I8cc8e540cfb64d0f130e9c0aaedf7b0835f8fe16
Diffstat (limited to 'src')
-rw-r--r-- | src/sgsn/apn.c | 11 | ||||
-rw-r--r-- | src/sgsn/gprs_sgsn.c | 5 | ||||
-rw-r--r-- | src/sgsn/sgsn_vty.c | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/sgsn/apn.c b/src/sgsn/apn.c index d6d537204..8ed523e73 100644 --- a/src/sgsn/apn.c +++ b/src/sgsn/apn.c @@ -25,22 +25,21 @@ #include <talloc.h> #include <osmocom/sgsn/apn.h> +#include <osmocom/sgsn/sgsn.h> extern void *tall_sgsn_ctx; -LLIST_HEAD(sgsn_apn_ctxts); - static struct apn_ctx *sgsn_apn_ctx_alloc(const char *ap_name, const char *imsi_prefix) { struct apn_ctx *actx; - actx = talloc_zero(tall_sgsn_ctx, struct apn_ctx); + actx = talloc_zero(sgsn, struct apn_ctx); if (!actx) return NULL; actx->name = talloc_strdup(actx, ap_name); actx->imsi_prefix = talloc_strdup(actx, imsi_prefix); - llist_add_tail(&actx->list, &sgsn_apn_ctxts); + llist_add_tail(&actx->list, &sgsn->apn_list); return actx; } @@ -59,7 +58,7 @@ struct apn_ctx *sgsn_apn_ctx_match(const char *name, const char *imsi) size_t name_prio = 0; size_t name_req_len = strlen(name); - llist_for_each_entry(actx, &sgsn_apn_ctxts, list) { + llist_for_each_entry(actx, &sgsn->apn_list, list) { size_t name_ref_len, imsi_ref_len; const char *name_ref_start, *name_match_start; @@ -106,7 +105,7 @@ struct apn_ctx *sgsn_apn_ctx_by_name(const char *name, const char *imsi_prefix) { struct apn_ctx *actx; - llist_for_each_entry(actx, &sgsn_apn_ctxts, list) { + llist_for_each_entry(actx, &sgsn->apn_list, list) { if (strcasecmp(name, actx->name) == 0 && strcasecmp(imsi_prefix, actx->imsi_prefix) == 0) return actx; diff --git a/src/sgsn/gprs_sgsn.c b/src/sgsn/gprs_sgsn.c index c1576253a..42d1ecee3 100644 --- a/src/sgsn/gprs_sgsn.c +++ b/src/sgsn/gprs_sgsn.c @@ -658,7 +658,7 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx, insert_extra(tp, mmctx->subscr->sgsn_data, pdp); continue; } - if (!llist_empty(&sgsn_apn_ctxts)) { + if (!llist_empty(&sgsn->apn_list)) { apn_ctx = sgsn_apn_ctx_match(req_apn_str, mmctx->imsi); /* Not configured */ if (apn_ctx == NULL) @@ -711,7 +711,7 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx, if (apn_ctx != NULL) { ggsn = apn_ctx->ggsn; - } else if (llist_empty(&sgsn_apn_ctxts)) { + } else if (llist_empty(&sgsn->apn_list)) { /* No configuration -> use GGSN 0 */ ggsn = sgsn_ggsn_ctx_by_id(0); } else if (allow_any_apn && @@ -821,6 +821,7 @@ struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx) inst->rate_ctrs = rate_ctr_group_alloc(inst, &sgsn_ctrg_desc, 0); OSMO_ASSERT(inst->rate_ctrs); + INIT_LLIST_HEAD(&inst->apn_list); INIT_LLIST_HEAD(&inst->ggsn_list); INIT_LLIST_HEAD(&inst->mme_list); diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c index b678f07ed..b6d03cf00 100644 --- a/src/sgsn/sgsn_vty.c +++ b/src/sgsn/sgsn_vty.c @@ -311,9 +311,9 @@ static int config_write_sgsn(struct vty *vty) llist_for_each_entry(acl, &g_cfg->imsi_acl, list) vty_out(vty, " imsi-acl add %s%s", acl->imsi, VTY_NEWLINE); - if (llist_empty(&sgsn_apn_ctxts)) + if (llist_empty(&sgsn->apn_list)) vty_out(vty, " ! apn * ggsn 0%s", VTY_NEWLINE); - llist_for_each_entry(actx, &sgsn_apn_ctxts, list) { + llist_for_each_entry(actx, &sgsn->apn_list, list) { if (strlen(actx->imsi_prefix) > 0) vty_out(vty, " apn %s imsi-prefix %s ggsn %u%s", actx->name, actx->imsi_prefix, actx->ggsn->id, |