llc: Make the index 'private' by appending a m_ to it.
At some point in the future we can start using the private/protected keywords in this struct.
This commit is contained in:
parent
e23102602c
commit
32f9a59ab4
|
@ -31,13 +31,13 @@ extern "C" {
|
||||||
/* reset LLC frame */
|
/* reset LLC frame */
|
||||||
void gprs_llc::reset()
|
void gprs_llc::reset()
|
||||||
{
|
{
|
||||||
index = 0;
|
m_index = 0;
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::reset_frame_space()
|
void gprs_llc::reset_frame_space()
|
||||||
{
|
{
|
||||||
index = 0;
|
m_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::enqueue(struct msgb *llc_msg)
|
void gprs_llc::enqueue(struct msgb *llc_msg)
|
||||||
|
@ -48,14 +48,14 @@ void gprs_llc::enqueue(struct msgb *llc_msg)
|
||||||
void gprs_llc::put_frame(const uint8_t *data, size_t len)
|
void gprs_llc::put_frame(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* only put frames when we are empty */
|
/* only put frames when we are empty */
|
||||||
OSMO_ASSERT(index == 0 && m_length == 0);
|
OSMO_ASSERT(m_index == 0 && m_length == 0);
|
||||||
append_frame(data, len);
|
append_frame(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_llc::append_frame(const uint8_t *data, size_t len)
|
void gprs_llc::append_frame(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* TODO: bounds check */
|
/* TODO: bounds check */
|
||||||
memcpy(frame + index, data, len);
|
memcpy(frame + m_index, data, len);
|
||||||
m_length += len;
|
m_length += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/llc.h
14
src/llc.h
|
@ -50,19 +50,19 @@ struct gprs_llc {
|
||||||
bool fits_in_current_frame(uint8_t size) const;
|
bool fits_in_current_frame(uint8_t size) const;
|
||||||
|
|
||||||
uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
|
uint8_t frame[LLC_MAX_LEN]; /* current DL or UL frame */
|
||||||
uint16_t index; /* current write/read position of frame */
|
uint16_t m_index; /* current write/read position of frame */
|
||||||
uint16_t m_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 */
|
struct llist_head queue; /* queued LLC DL data */
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint16_t gprs_llc::chunk_size() const
|
inline uint16_t gprs_llc::chunk_size() const
|
||||||
{
|
{
|
||||||
return m_length - index;
|
return m_length - m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t gprs_llc::remaining_space() const
|
inline uint16_t gprs_llc::remaining_space() const
|
||||||
{
|
{
|
||||||
return LLC_MAX_LEN - index;
|
return LLC_MAX_LEN - m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t gprs_llc::frame_length() const
|
inline uint16_t gprs_llc::frame_length() const
|
||||||
|
@ -72,17 +72,17 @@ inline uint16_t gprs_llc::frame_length() const
|
||||||
|
|
||||||
inline void gprs_llc::consume(size_t len)
|
inline void gprs_llc::consume(size_t len)
|
||||||
{
|
{
|
||||||
index += len;
|
m_index += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void gprs_llc::consume(uint8_t *data, size_t len)
|
inline void gprs_llc::consume(uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
/* copy and increment index */
|
/* copy and increment index */
|
||||||
memcpy(data, frame + index, len);
|
memcpy(data, frame + m_index, len);
|
||||||
index += len;
|
consume(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool gprs_llc::fits_in_current_frame(uint8_t chunk_size) const
|
inline bool gprs_llc::fits_in_current_frame(uint8_t chunk_size) const
|
||||||
{
|
{
|
||||||
return index + chunk_size <= LLC_MAX_LEN;
|
return m_index + chunk_size <= LLC_MAX_LEN;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue