diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-07 08:15:58 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-07 08:15:58 +0100 |
commit | acb5427bda2b6727b96420502ac1261ae4c8d38c (patch) | |
tree | 3afc631640927b7c4e9a15ca4a698de96274da3d /src/llc.h | |
parent | be57081721c13d1d2896f0a843f8759add7f58b9 (diff) |
llc: Move all direct accesses to the frame into the llc structure
Add some todo items where we could add assertions now that I see
the constraints and invariants of this code.
Diffstat (limited to 'src/llc.h')
-rw-r--r-- | src/llc.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,6 +19,7 @@ #pragma once #include <stdint.h> +#include <string.h> #define LLC_MAX_LEN 1543 @@ -35,11 +36,25 @@ struct gprs_llc { void update_frame(struct msgb *msg); void put_frame(const uint8_t *data, size_t len); + void consume(uint8_t *data, size_t len); void clear(BTS *bts); + uint16_t chunk_size() const; + uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */ uint16_t index; /* current write/read position of frame */ uint16_t length; /* len of current DL LLC_frame, 0 == no frame */ struct llist_head queue; /* queued LLC DL data */ }; +inline uint16_t gprs_llc::chunk_size() const +{ + return length - index; +} + +inline void gprs_llc::consume(uint8_t *data, size_t len) +{ + /* copy and increment index */ + memcpy(data, frame + index, len); + index += len; +} |