diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-03-18 14:26:51 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2014-03-18 14:26:51 +0100 |
commit | 0f40fb6b520fd0dacd498ea4fbb28aa4aee16452 (patch) | |
tree | 4173f2a7bd021b143e2aa2a89ab54dc1f1d628c3 | |
parent | 08be9046e8976be8e10d74639181588bc671dc56 (diff) |
msgb: Add msgb_pull_to function (TODO)
This function advances msg->data to a given pointer and resets
all lXh pointer that would point before the new value.
Sponsored-by: On-Waves ehf
-rw-r--r-- | include/osmocom/core/msgb.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 1c122734..15719407 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -374,6 +374,30 @@ static inline unsigned char *msgb_pull_to_l3(struct msgb *msg) return ret; } +/*! \brief remove (pull) all headers in front of hdr from the message buffer. + * \param[in] msgb message buffer with a valid l3h + * \param[in] hdr pointer to a header within a message buffer + * \returns pointer to new start of msgb (l3h) + * + * This function moves the \a data pointer of the \ref msgb further back + * in the message, thereby shrinking the size of the message. + * All lXhin front of ret will be cleared. + */ +static inline unsigned char *msgb_pull_to(struct msgb *msg, + const unsigned char *hdr) +{ + unsigned char *ret = msgb_pull(msg, hdr - msg->data); + if (msg->l1h < ret) + msg->l1h = NULL; + if (msg->l2h < ret) + msg->l2h = NULL; + if (msg->l3h < ret) + msg->l3h = NULL; + if (msg->l4h < ret) + msg->l4h = NULL; + return ret; +} + /*! \brief remove uint8 from front of message * \param[in] msgb message buffer * \returns 8bit value taken from end of msgb |