summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2016-02-03 15:20:28 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2016-02-04 15:52:19 +0100
commit3e85daedf29161ba250824241daf041ebb62350c (patch)
tree9db9532e100950467ded731efe8059ca9a5ae961
parentfdf2d9183e42f0fa1881218586d75ad9ef9d86d5 (diff)
sgsn: Add a function to return the pdp ctx for an mm ctx and tei
-rw-r--r--openbsc/include/openbsc/gprs_sgsn.h3
-rw-r--r--openbsc/src/gprs/gprs_sgsn.c16
2 files changed, 18 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h
index e449ccea0..7d461ecb0 100644
--- a/openbsc/include/openbsc/gprs_sgsn.h
+++ b/openbsc/include/openbsc/gprs_sgsn.h
@@ -299,6 +299,9 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm,
/* look up PDP context by MM context and transaction ID */
struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm,
uint8_t tid);
+/* look up PDP context by MM context and gtp TEI */
+struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tei(const struct sgsn_mm_ctx *mm,
+ uint32_t tei);
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
uint8_t nsapi);
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 0d8c8cc45..8fea5fb82 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -40,6 +40,8 @@
#include <openbsc/signal.h>
#include "openbsc/gprs_llc.h"
+#include <pdp.h>
+
#include <time.h>
#include <openssl/rand.h>
@@ -317,6 +319,19 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm,
return NULL;
}
+/* look up PDP context by MM context and gtp TEI */
+struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tei(const struct sgsn_mm_ctx *mm,
+ uint32_t tei)
+{
+ struct sgsn_pdp_ctx *pdp;
+
+ llist_for_each_entry(pdp, &mm->pdp_list, list) {
+ if (pdp->lib->teid_own == tei)
+ return pdp;
+ }
+ return NULL;
+}
+
/* you don't want to use this directly, call sgsn_create_pdp_ctx() */
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
uint8_t nsapi)
@@ -340,7 +355,6 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
return pdp;
}
-#include <pdp.h>
/*
* This function will not trigger any GSM DEACT PDP ACK messages, so you
* probably want to call sgsn_delete_pdp_ctx() instead if the connection