aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-20 08:44:02 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 21:24:10 +0100
commit1702f102afd042b0e91a0d3f23edc83632cec94f (patch)
treef4118b8a04ba800b7597784818936fdd637aa5eb /src/tbf.cpp
parent7ce21eb042124b05faba929712de61de415973d0 (diff)
tbf: First round of removing llc handling from the rlcmac_data
The code in gprs_rlcmac_data should ask the TBF for help in packing the frames but it really shouldn't poke in the internals of the tbf structure. This is very bad capsuling and has plenty of copy and paste. At the same thime this will be the most dangerous refactoring of the code base.
Diffstat (limited to 'src/tbf.cpp')
-rw-r--r--src/tbf.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 2fcb51c2..8800cca3 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -32,6 +32,11 @@ extern "C" {
#include <errno.h>
#include <string.h>
+extern "C" {
+int bssgp_tx_llc_discarded(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
+ uint8_t num_frames, uint32_t num_octets);
+}
+
extern void *tall_pcu_ctx;
static inline void tbf_update_ms_class(struct gprs_rlcmac_tbf *tbf,
@@ -577,6 +582,50 @@ int gprs_rlcmac_tbf::rlcmac_diag()
return 0;
}
+struct msgb *gprs_rlcmac_tbf::llc_dequeue(bssgp_bvc_ctx *bctx)
+{
+ struct msgb *msg;
+ struct timeval *tv, tv_now;
+ uint32_t octets = 0, frames = 0;
+
+ gettimeofday(&tv_now, NULL);
+
+ while ((msg = msgb_dequeue(&llc_queue))) {
+ 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 */
+ LOGP(DRLCMACDL, LOGL_NOTICE, "Discarding LLC PDU of "
+ "DL TBF=%d, because lifetime limit reached\n",
+ tfi);
+ frames++;
+ octets += msg->len;
+ msgb_free(msg);
+ continue;
+ }
+ break;
+ }
+
+ if (frames) {
+ if (frames > 0xff)
+ frames = 0xff;
+ if (octets > 0xffffff)
+ octets = 0xffffff;
+ bssgp_tx_llc_discarded(bctx, tlli, frames, octets);
+ }
+
+ return msg;
+}
+
+void gprs_rlcmac_tbf::update_llc_frame(struct msgb *msg)
+{
+ /* TODO: bounds check */
+ memcpy(llc_frame, msg->data, msg->len);
+ llc_length = msg->len;
+}
+
void gprs_rlcmac_tbf::free_all(struct gprs_rlcmac_trx *trx)
{
for (uint8_t tfi = 0; tfi < 32; tfi++) {