aboutsummaryrefslogtreecommitdiffstats
path: root/src/llc.h
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-13 16:56:15 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-13 17:08:07 +0100
commite23102602c94dc7fdd7cc6d383e7f6c576aa01ed (patch)
tree688e2172e335a6b1e1787e835a3d0339adee60a6 /src/llc.h
parentb3d5ee2934f930e611cd4447b90dce6723340062 (diff)
llc: Move some more secrets from the TBF into the LLC
Introduce a method to append data to a TBF and then reset the read pointer when the frame has been sent.
Diffstat (limited to 'src/llc.h')
-rw-r--r--src/llc.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/llc.h b/src/llc.h
index d3b940e..b22b1c2 100644
--- a/src/llc.h
+++ b/src/llc.h
@@ -37,20 +37,42 @@ struct gprs_llc {
struct msgb *dequeue();
void put_frame(const uint8_t *data, size_t len);
+ void append_frame(const uint8_t *data, size_t len);
+
+ void consume(size_t len);
void consume(uint8_t *data, size_t len);
void clear(BTS *bts);
uint16_t chunk_size() const;
+ uint16_t remaining_space() const;
+ uint16_t frame_length() const;
+
+ bool fits_in_current_frame(uint8_t 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 */
+ uint16_t m_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;
+ return m_length - index;
+}
+
+inline uint16_t gprs_llc::remaining_space() const
+{
+ return LLC_MAX_LEN - index;
+}
+
+inline uint16_t gprs_llc::frame_length() const
+{
+ return m_length;
+}
+
+inline void gprs_llc::consume(size_t len)
+{
+ index += len;
}
inline void gprs_llc::consume(uint8_t *data, size_t len)
@@ -59,3 +81,8 @@ inline void gprs_llc::consume(uint8_t *data, size_t len)
memcpy(data, frame + index, len);
index += len;
}
+
+inline bool gprs_llc::fits_in_current_frame(uint8_t chunk_size) const
+{
+ return index + chunk_size <= LLC_MAX_LEN;
+}