aboutsummaryrefslogtreecommitdiffstats
path: root/src/llc.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-15 14:32:33 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-22 10:39:06 +0200
commitb671dbfe94789d849880b8c6f2a036f7db04b037 (patch)
tree1007114ec5bd8cb6d4a5fee7e4e3c8c85d9066bf /src/llc.cpp
parent1e50a3dadef7823b6f50bd387f84f324029a217d (diff)
llc: Move storage of timestamps into gprs_llc_queue
Currently the receive and expiry timestamps are prepended to the LLC msgb before it is passed to gprs_llc_queue::enqueue(). Since this meta information should not be counted as LLC octets, the gprs_llc_queue needs to known about this (unless the correction was done in the LLC layer). This commit moves the meta information storage code into gprs_llc_queue. The meta data is now stored in the control block (cb) area of the msgb. Note that the info pointer that is returned from the dequeue method is only valid if that method returns a (non-NULL) msgb. It must not be used after that msgb has been modified or freed. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/llc.cpp')
-rw-r--r--src/llc.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/llc.cpp b/src/llc.cpp
index 8930d2c8..53a89356 100644
--- a/src/llc.cpp
+++ b/src/llc.cpp
@@ -104,10 +104,19 @@ void gprs_llc_queue::init()
m_avg_queue_delay = 0;
}
-void gprs_llc_queue::enqueue(struct msgb *llc_msg)
+void gprs_llc_queue::enqueue(struct msgb *llc_msg, const MetaInfo *info)
{
+ static const MetaInfo def_meta = {{0}};
+ MetaInfo *meta_storage;
+
+ osmo_static_assert(sizeof(*info) <= sizeof(llc_msg->cb), info_does_not_fit);
+
m_queue_size += 1;
- m_queue_octets += msgb_length(llc_msg) - 2*sizeof(struct timeval);
+ m_queue_octets += msgb_length(llc_msg);
+
+ meta_storage = (MetaInfo *)&llc_msg->cb[0];
+ *meta_storage = info ? *info : def_meta;
+
msgb_enqueue(&m_queue, llc_msg);
}
@@ -127,24 +136,29 @@ void gprs_llc_queue::clear(BTS *bts)
#define ALPHA 0.5f
-struct msgb *gprs_llc_queue::dequeue()
+struct msgb *gprs_llc_queue::dequeue(const MetaInfo **info)
{
struct msgb *msg;
struct timeval *tv, tv_now, tv_result;
uint32_t lifetime;
-
+ const MetaInfo *meta_storage;
msg = msgb_dequeue(&m_queue);
if (!msg)
return NULL;
+ meta_storage = (MetaInfo *)&msg->cb[0];
+
+ if (info)
+ *info = meta_storage;
+
m_queue_size -= 1;
- m_queue_octets -= msgb_length(msg) - 2*sizeof(struct timeval);
+ m_queue_octets -= msgb_length(msg);
/* take the second time */
gettimeofday(&tv_now, NULL);
tv = (struct timeval *)&msg->data[sizeof(*tv)];
- timersub(&tv_now, tv, &tv_result);
+ timersub(&tv_now, &meta_storage->recv_time, &tv_result);
lifetime = tv_result.tv_sec*1000 + tv_result.tv_usec/1000;
m_avg_queue_delay = m_avg_queue_delay * ALPHA + lifetime * (1-ALPHA);