From b1302b083e9d8f5dd60229570716f497ea61d26c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 13 Nov 2013 17:15:26 +0100 Subject: llc: Move the decision if a frame has expired into the LLC This way the generation of the expiry information and the check is at the same place. This should make reading the code more easy. --- src/llc.cpp | 9 +++++++++ src/llc.h | 1 + src/tbf.cpp | 5 +---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/llc.cpp b/src/llc.cpp index 2997ec14..c0c517f3 100644 --- a/src/llc.cpp +++ b/src/llc.cpp @@ -102,3 +102,12 @@ void gprs_llc::calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct timeradd(&now, &csec, tv); } + +bool gprs_llc::is_frame_expired(struct timeval *tv_now, struct timeval *tv) +{ + /* Timeout is infinite */ + if (tv->tv_sec == 0 && tv->tv_usec == 0) + return false; + + return timercmp(tv_now, tv, >); +} diff --git a/src/llc.h b/src/llc.h index f83b9f95..f1692f4b 100644 --- a/src/llc.h +++ b/src/llc.h @@ -28,6 +28,7 @@ */ struct gprs_llc { static void calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct timeval *tv); + static bool is_frame_expired(struct timeval *now, struct timeval *tv); void init(); void reset(); diff --git a/src/tbf.cpp b/src/tbf.cpp index 41a94bcd..63c8070d 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -689,10 +689,7 @@ struct msgb *gprs_rlcmac_tbf::llc_dequeue(bssgp_bvc_ctx *bctx) tv = (struct timeval *)msg->data; msgb_pull(msg, sizeof(*tv)); - /* Timeout is infinite */ - if (tv->tv_sec == 0 && tv->tv_usec == 0) - break; - if (timercmp(&tv_now, tv, >)) { + if (gprs_llc::is_frame_expired(&tv_now, tv)) { LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU " "because lifetime limit reached\n", tbf_name(this)); -- cgit v1.2.3