diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-05-30 14:11:22 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-05-31 16:34:32 +0200 |
commit | 9ee8d3264b1d860792968f9456cd66a7233fd98b (patch) | |
tree | e6577f4b6e01c8995a25e8566bd8ecf6835dc4f0 | |
parent | de72d26f490460e78b4208a0ced00d83722b8918 (diff) |
pdp: Introduce new API pdp_count_secondary
Change-Id: Id2d84ad1cdb0f3b500efeda4cc0fbccb24ae0c61
-rw-r--r-- | gtp/gtp.c | 14 | ||||
-rw-r--r-- | gtp/pdp.c | 14 | ||||
-rw-r--r-- | gtp/pdp.h | 2 |
3 files changed, 20 insertions, 10 deletions
@@ -2454,8 +2454,7 @@ int gtp_delete_context_req2(struct gsn_t *gsn, struct pdp_t *pdp, void *cbp, get_default_gtp(pdp->version, GTP_DELETE_PDP_REQ, &packet); struct in_addr addr; struct pdp_t *linked_pdp; - int n; - int count = 0; + int count; if (gsna2in_addr(&addr, &pdp->gsnrc)) { gsn->err_address++; @@ -2470,9 +2469,7 @@ int gtp_delete_context_req2(struct gsn_t *gsn, struct pdp_t *pdp, void *cbp, } if (!teardown) { - for (n = 0; n < PDP_MAXNSAPI; n++) - if (linked_pdp->secondary_tei[n]) - count++; + count = pdp_count_secondary(linked_pdp); if (count <= 1) { LOGP(DLGTP, LOGL_ERROR, "Must use teardown for last context: %d\n", count); @@ -2562,8 +2559,7 @@ int gtp_delete_pdp_ind(struct gsn_t *gsn, int version, uint8_t nsapi; uint8_t teardown = 0; - int n; - int count = 0; + int count; /* Is this a duplicate ? */ if (!gtp_duplicate(gsn, version, peer, seq)) { @@ -2633,9 +2629,7 @@ int gtp_delete_pdp_ind(struct gsn_t *gsn, int version, * signalling messages will eventually lead to a consistent * situation, allowing the teardown of the PDP context.) */ - for (n = 0; n < PDP_MAXNSAPI; n++) - if (linked_pdp->secondary_tei[n]) - count++; + count = pdp_count_secondary(linked_pdp); if (count <= 1) { GTP_LOGPKG(LOGL_NOTICE, peer, pack, len, "Ignoring CTX DEL without teardown and count=%d\n", @@ -374,3 +374,17 @@ void pdp_set_imsi_nsapi(struct pdp_t *pdp, uint64_t teid) pdp->imsi = teid & 0x0fffffffffffffffull; pdp->nsapi = (teid & 0xf000000000000000ull) >> 60; } + +/* Count amount of secondary PDP contexts linked to this primary PDP context + * (itself included). Must be called on a primary PDP context. */ +unsigned int pdp_count_secondary(struct pdp_t *pdp) +{ + unsigned int n; + unsigned int count = 0; + OSMO_ASSERT(!pdp->secondary); + + for (n = 0; n < PDP_MAXNSAPI; n++) + if (pdp->secondary_tei[n]) + count++; + return count; +} @@ -260,6 +260,8 @@ int pdp_tidget(struct pdp_t **pdp, uint64_t tid); void pdp_set_imsi_nsapi(struct pdp_t *pdp, uint64_t teid); +unsigned int pdp_count_secondary(struct pdp_t *pdp); + /* int pdp_iphash(void* ipif, struct ul66_t *eua); int pdp_ipset(struct pdp_t *pdp, void* ipif, struct ul66_t *eua); |