aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-11-02 18:17:50 +0100
committerHarald Welte <laforge@gnumonks.org>2011-11-02 18:17:50 +0100
commit95848bafcef145d776d70a73f7bdc3fe37e85724 (patch)
treeea0d80584ae96c53ea243e54307019db19ad95b7
parentef71162a7412a49afe5005e51e7e7b70d6cead07 (diff)
GTP: don't use magic numbers for T3-REQUESTS and N3-REQUEST
-rw-r--r--gtp/gtp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index dc3a05d..3cc0c0b 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -51,6 +51,11 @@
#include "gtpie.h"
#include "queue.h"
+/* According to section 14.2 of 3GPP TS 29.006 version 6.9.0 */
+#define N3_REQUESTS 5
+
+#define T3_REQUEST 3
+
/* Error reporting functions */
void gtp_err(int priority, char *filename, int linenum, char *fmt, ...)
@@ -462,7 +467,7 @@ int gtp_req(struct gsn_t *gsn, int version, struct pdp_t *pdp,
} else {
memcpy(&qmsg->p, packet, sizeof(union gtp_packet));
qmsg->l = len;
- qmsg->timeout = time(NULL) + 3; /* When to timeout */
+ qmsg->timeout = time(NULL) + T3_REQUEST; /* When to timeout */
qmsg->retrans = 0; /* No retransmissions so far */
qmsg->cbp = cbp;
qmsg->type = ntoh8(packet->gtp0.h.type);
@@ -511,10 +516,12 @@ int gtp_retrans(struct gsn_t *gsn)
now = time(NULL);
/*printf("Retrans: New beginning %d\n", (int) now); */
+ /* get first element in queue, as long as the timeout of that
+ * element has expired */
while ((!queue_getfirst(gsn->queue_req, &qmsg)) &&
(qmsg->timeout <= now)) {
/*printf("Retrans timeout found: %d\n", (int) time(NULL)); */
- if (qmsg->retrans > 3) { /* To many retrans */
+ if (qmsg->retrans > N3_REQUESTS) { /* To many retrans */
if (gsn->cb_conf)
gsn->cb_conf(qmsg->type, EOF, NULL, qmsg->cbp);
queue_freemsg(gsn->queue_req, qmsg);
@@ -529,7 +536,7 @@ int gtp_retrans(struct gsn_t *gsn)
qmsg->l, strerror(errno));
}
queue_back(gsn->queue_req, qmsg);
- qmsg->timeout = now + 3;
+ qmsg->timeout = now + T3_REQUEST;
qmsg->retrans++;
}
}