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.
This commit is contained in:
Holger Hans Peter Freyther 2013-11-13 17:15:26 +01:00
parent 32f9a59ab4
commit b1302b083e
3 changed files with 11 additions and 4 deletions

View File

@ -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, >);
}

View File

@ -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();

View File

@ -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));