aboutsummaryrefslogtreecommitdiffstats
path: root/gtp
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2018-09-16 05:10:03 +0200
committerHarald Welte <laforge@gnumonks.org>2018-09-16 10:30:10 +0000
commite1412d9493058400386f1376f21c49a5b7d25f2b (patch)
tree43697ce1d6c3eb96c6073831a4496047639d2a0d /gtp
parentd1e2342f91db4baedda3aca605fe498b61584406 (diff)
libgtp: implement gtp_clear_queues to clear req/resp queue
Clearing the request and response queue is useful for debugging to reset "some" state. Otherwise some tests will get un-expected packets. Change-Id: I279d1d7cbf5d37dd5609c2b968f317fe9a0e348d
Diffstat (limited to 'gtp')
-rw-r--r--gtp/gtp.c18
-rw-r--r--gtp/gtp.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 1d58088..b98fba0 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -496,6 +496,24 @@ static int gtp_req(struct gsn_t *gsn, uint8_t version, struct pdp_t *pdp,
return 0;
}
+
+/**
+ * @brief clear the request and response queue. Useful for debugging to reset "some" state.
+ * @param gsn The GGSN instance
+ */
+void gtp_clear_queues(struct gsn_t *gsn)
+{
+ struct qmsg_t *qmsg;
+
+ while (!queue_getfirst(gsn->queue_req, &qmsg)) {
+ queue_freemsg(gsn->queue_req, qmsg);
+ }
+
+ while (!queue_getfirst(gsn->queue_resp, &qmsg)) {
+ queue_freemsg(gsn->queue_resp, qmsg);
+ }
+}
+
/* gtp_conf
* Remove signalling packet from retransmission queue.
* return 0 on success, EOF if packet was not found */
diff --git a/gtp/gtp.h b/gtp/gtp.h
index ed594f1..5f35ab5 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -369,6 +369,8 @@ int gtp_set_cb_recovery2(struct gsn_t *gsn,
struct pdp_t * pdp,
uint8_t recovery));
+void gtp_clear_queues(struct gsn_t *gsn);
+
/* Internal functions (not part of the API */
extern int gtp_echo_req(struct gsn_t *gsn, int version, void *cbp,