aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-13 15:35:45 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-13 15:35:45 +0100
commit51e093bd1cbe6d91278f72c82fbd54711e4a9ede (patch)
tree7fd0dd0e0ae27464761eb8e5407d3522d510aeb3 /src
parent985fd114f243dfe5095cd2d5e90bf4f0c0a760a5 (diff)
llc: Use timeradd and timercmp and fix for < 1s PDU llc timeouts
Diffstat (limited to 'src')
-rw-r--r--src/llc.cpp13
-rw-r--r--src/tbf.cpp9
2 files changed, 11 insertions, 11 deletions
diff --git a/src/llc.cpp b/src/llc.cpp
index 19bf66a..88b701a 100644
--- a/src/llc.cpp
+++ b/src/llc.cpp
@@ -91,11 +91,10 @@ void gprs_llc::calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct
}
/* calculate timestamp of timeout */
- gettimeofday(tv, NULL);
- tv->tv_usec += (delay_csec % 100) * 10000;
- tv->tv_sec += delay_csec / 100;
- if (tv->tv_usec > 999999) {
- tv->tv_usec -= 1000000;
- tv->tv_sec++;
- }
+ struct timeval now, csec;
+ gettimeofday(&now, NULL);
+ csec.tv_usec = (delay_csec % 100) * 10000;
+ csec.tv_sec = delay_csec / 100;
+
+ timeradd(&now, &csec, tv);
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 25f31c3..2310f85 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -687,10 +687,11 @@ struct msgb *gprs_rlcmac_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
while ((msg = m_llc.dequeue())) {
tv = (struct timeval *)msg->data;
msgb_pull(msg, sizeof(*tv));
- if (tv->tv_sec /* not infinite */
- && (tv_now.tv_sec > tv->tv_sec /* and secs expired */
- || (tv_now.tv_sec == tv->tv_sec /* .. or if secs equal .. */
- && tv_now.tv_usec > tv->tv_usec))) { /* .. usecs expired */
+
+ /* Timeout is infinite */
+ if (tv->tv_sec == 0 && tv->tv_usec == 0)
+ break;
+ if (timercmp(&tv_now, tv, >)) {
LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU "
"because lifetime limit reached\n",
tbf_name(this));