From 5d8b2265975f93616d7677bd41edb426839a2698 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 22 Aug 2019 15:00:00 +0200 Subject: [PATCH] libgtp: Introduce cb_recovery3 Since osmo-ggsn can manage several GSN structures simultaneously, it needs the gsn_t pointer to know the ggsn it should forward the call to. Related: OS#4165 Change-Id: I33b4fe594d5833993af01cce34737e61e597b320 --- gtp/gtp.c | 17 +++++++++++++++++ gtp/gtp.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/gtp/gtp.c b/gtp/gtp.c index f0318f7..f70f534 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -219,6 +219,8 @@ static void emit_cb_recovery(struct gsn_t *gsn, struct sockaddr_in * peer, gsn->cb_recovery(peer, recovery); if (gsn->cb_recovery2) gsn->cb_recovery2(peer, pdp, recovery); + if (gsn->cb_recovery3) + gsn->cb_recovery3(gsn, peer, pdp, recovery); } int gtp_set_cb_recovery(struct gsn_t *gsn, @@ -242,6 +244,21 @@ int gtp_set_cb_recovery2(struct gsn_t *gsn, return 0; } +/* cb_recovery() + * pdp may be NULL if Recovery IE was received from a message independent + * of any PDP ctx (such as Echo Response), or because pdp ctx is unknown to the + * local setup. In case pdp is known, caller may want to keep that pdp alive to + * handle subsequent msg cb as this specific pdp ctx is still valid according to + * specs. + */ +int gtp_set_cb_recovery3(struct gsn_t *gsn, + int (*cb_recovery3) (struct gsn_t *gsn, struct sockaddr_in *peer, + struct pdp_t *pdp, uint8_t recovery)) +{ + gsn->cb_recovery3 = cb_recovery3; + return 0; +} + int gtp_set_cb_data_ind(struct gsn_t *gsn, int (*cb_data_ind) (struct pdp_t * pdp, void *pack, unsigned len)) diff --git a/gtp/gtp.h b/gtp/gtp.h index c2c5122..f2a4e1d 100644 --- a/gtp/gtp.h +++ b/gtp/gtp.h @@ -277,6 +277,7 @@ struct gsn_t { int (*cb_data_ind) (struct pdp_t * pdp, void *pack, unsigned len); int (*cb_recovery) (struct sockaddr_in * peer, uint8_t recovery); int (*cb_recovery2) (struct sockaddr_in * peer, struct pdp_t * pdp, uint8_t recovery); + int (*cb_recovery3) (struct gsn_t *gsn, struct sockaddr_in *peer, struct pdp_t *pdp, uint8_t recovery); /* Counters */ @@ -372,6 +373,11 @@ int gtp_set_cb_recovery(struct gsn_t *gsn, OSMO_DEPRECATED("Use gtp_set_cb_recovery2() instead, to obtain pdp ctx originating the recovery"); int gtp_set_cb_recovery2(struct gsn_t *gsn, int (*cb) (struct sockaddr_in * peer, + struct pdp_t * pdp, + uint8_t recovery)) + OSMO_DEPRECATED("Use gtp_set_cb_recovery3() instead, to obtain gsn handling the recovery");; +int gtp_set_cb_recovery3(struct gsn_t *gsn, + int (*cb) (struct gsn_t * gsn, struct sockaddr_in * peer, struct pdp_t * pdp, uint8_t recovery));