Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1 | #ifndef _MSGB_H |
| 2 | #define _MSGB_H |
| 3 | |
| 4 | /* (C) 2008 by Harald Welte <laforge@gnumonks.org> |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdint.h> |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 24 | #include <osmocom/core/linuxlist.h> |
| 25 | #include <osmocom/core/utils.h> |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 26 | |
Harald Welte | ba6988b | 2011-08-17 12:46:48 +0200 | [diff] [blame] | 27 | /*! \defgroup msgb Message buffers |
| 28 | * @{ |
| 29 | */ |
| 30 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 31 | /*! \file msgb.h |
| 32 | * \brief Osmocom message buffers |
| 33 | * The Osmocom message buffers are modelled after the 'struct skb' |
| 34 | * inside the Linux kernel network stack. As they exist in userspace, |
| 35 | * they are much simplified. However, terminology such as headroom, |
| 36 | * tailroom, push/pull/put etc. remains the same. |
| 37 | */ |
| 38 | |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 39 | #define MSGB_DEBUG |
| 40 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 41 | /*! \brief Osmocom message buffer */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 42 | struct msgb { |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 43 | struct llist_head list; /*!< \brief linked list header */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 44 | |
Pablo Neira Ayuso | 29cbf61 | 2011-07-07 19:46:44 +0200 | [diff] [blame] | 45 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 46 | /* Part of which TRX logical channel we were received / transmitted */ |
Harald Welte | 074c9f9 | 2010-04-30 14:29:11 +0200 | [diff] [blame] | 47 | /* FIXME: move them into the control buffer */ |
Harald Welte | c5a0ded | 2011-07-18 16:59:27 +0200 | [diff] [blame] | 48 | union { |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 49 | void *dst; /*!< \brief reference of origin/destination */ |
Harald Welte | c5a0ded | 2011-07-18 16:59:27 +0200 | [diff] [blame] | 50 | struct gsm_bts_trx *trx; |
| 51 | }; |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 52 | struct gsm_lchan *lchan; /*!< \brief logical channel */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 53 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 54 | unsigned char *l1h; /*!< \brief pointer to Layer1 header (if any) */ |
| 55 | unsigned char *l2h; /*!< \brief pointer to A-bis layer 2 header: OML, RSL(RLL), NS */ |
| 56 | unsigned char *l3h; /*!< \brief pointer to Layer 3 header. For OML: FOM; RSL: 04.08; GPRS: BSSGP */ |
| 57 | unsigned char *l4h; /*!< \brief pointer to layer 4 header */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 58 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 59 | unsigned long cb[5]; /*!< \brief control buffer */ |
Harald Welte | 074c9f9 | 2010-04-30 14:29:11 +0200 | [diff] [blame] | 60 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 61 | uint16_t data_len; /*!< \brief length of underlying data array */ |
| 62 | uint16_t len; /*!< \brief length of bytes used in msgb */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 63 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 64 | unsigned char *head; /*!< \brief start of underlying memory buffer */ |
| 65 | unsigned char *tail; /*!< \brief end of message in buffer */ |
| 66 | unsigned char *data; /*!< \brief start of message in buffer */ |
| 67 | unsigned char _data[0]; /*!< \brief optional immediate data array */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | extern struct msgb *msgb_alloc(uint16_t size, const char *name); |
| 71 | extern void msgb_free(struct msgb *m); |
| 72 | extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg); |
| 73 | extern struct msgb *msgb_dequeue(struct llist_head *queue); |
| 74 | extern void msgb_reset(struct msgb *m); |
| 75 | |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 76 | #ifdef MSGB_DEBUG |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 77 | #include <osmocom/core/panic.h> |
Harald Welte | 929d887 | 2010-11-05 07:47:41 +0100 | [diff] [blame] | 78 | #define MSGB_ABORT(msg, fmt, args ...) do { \ |
Harald Welte | dab0287 | 2010-11-09 13:42:26 +0100 | [diff] [blame] | 79 | osmo_panic("msgb(%p): " fmt, msg, ## args); \ |
Harald Welte | 929d887 | 2010-11-05 07:47:41 +0100 | [diff] [blame] | 80 | } while(0) |
| 81 | #else |
| 82 | #define MSGB_ABORT(msg, fmt, args ...) |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 83 | #endif |
| 84 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 85 | /*! \brief obtain L1 header of msgb */ |
Harald Welte | fdd0a70 | 2010-03-01 22:30:51 +0100 | [diff] [blame] | 86 | #define msgb_l1(m) ((void *)(m->l1h)) |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 87 | /*! \brief obtain L2 header of msgb */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 88 | #define msgb_l2(m) ((void *)(m->l2h)) |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 89 | /*! \brief obtain L3 header of msgb */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 90 | #define msgb_l3(m) ((void *)(m->l3h)) |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 91 | /*! \brief obtain SMS header of msgb */ |
Harald Welte | bb77c9d | 2010-04-30 14:26:12 +0200 | [diff] [blame] | 92 | #define msgb_sms(m) ((void *)(m->l4h)) |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 93 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 94 | /*! \brief determine length of L1 message |
| 95 | * \param[in] msgb message buffer |
| 96 | * \returns size of L1 message in bytes |
| 97 | * |
| 98 | * This function computes the number of bytes between the tail of the |
| 99 | * message and the layer 1 header. |
| 100 | */ |
Harald Welte | fdd0a70 | 2010-03-01 22:30:51 +0100 | [diff] [blame] | 101 | static inline unsigned int msgb_l1len(const struct msgb *msgb) |
| 102 | { |
| 103 | return msgb->tail - (uint8_t *)msgb_l1(msgb); |
| 104 | } |
| 105 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 106 | /*! \brief determine length of L2 message |
| 107 | * \param[in] msgb message buffer |
| 108 | * \returns size of L2 message in bytes |
| 109 | * |
| 110 | * This function computes the number of bytes between the tail of the |
| 111 | * message and the layer 2 header. |
| 112 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 113 | static inline unsigned int msgb_l2len(const struct msgb *msgb) |
| 114 | { |
| 115 | return msgb->tail - (uint8_t *)msgb_l2(msgb); |
| 116 | } |
| 117 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 118 | /*! \brief determine length of L3 message |
| 119 | * \param[in] msgb message buffer |
| 120 | * \returns size of L3 message in bytes |
| 121 | * |
| 122 | * This function computes the number of bytes between the tail of the |
| 123 | * message and the layer 3 header. |
| 124 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 125 | static inline unsigned int msgb_l3len(const struct msgb *msgb) |
| 126 | { |
| 127 | return msgb->tail - (uint8_t *)msgb_l3(msgb); |
| 128 | } |
| 129 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 130 | /*! \brief determine the length of the header |
| 131 | * \param[in] msgb message buffer |
| 132 | * \returns number of bytes between start of buffer and start of msg |
| 133 | * |
| 134 | * This function computes the length difference between the underlying |
| 135 | * data buffer and the used section of the \a msgb. |
| 136 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 137 | static inline unsigned int msgb_headlen(const struct msgb *msgb) |
| 138 | { |
| 139 | return msgb->len - msgb->data_len; |
| 140 | } |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 141 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 142 | /*! \brief determine how much tail room is left in msgb |
| 143 | * \param[in] msgb message buffer |
| 144 | * \returns number of bytes remaining at end of msgb |
| 145 | * |
| 146 | * This function computes the amount of octets left in the underlying |
| 147 | * data buffer after the end of the message. |
| 148 | */ |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 149 | static inline int msgb_tailroom(const struct msgb *msgb) |
| 150 | { |
| 151 | return (msgb->head + msgb->data_len) - msgb->tail; |
| 152 | } |
| 153 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 154 | /*! \brief determine the amount of headroom in msgb |
| 155 | * \param[in] msgb message buffer |
| 156 | * \returns number of bytes left ahead of message start in msgb |
| 157 | * |
| 158 | * This function computes the amount of bytes left in the underlying |
| 159 | * data buffer before the start of the actual message. |
| 160 | */ |
Harald Welte | 652a723 | 2010-07-22 21:55:24 +0200 | [diff] [blame] | 161 | static inline int msgb_headroom(const struct msgb *msgb) |
| 162 | { |
| 163 | return (msgb->data - msgb->head); |
| 164 | } |
| 165 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 166 | /*! \brief append data to end of message buffer |
| 167 | * \param[in] msgb message buffer |
| 168 | * \param[in] len number of bytes to append to message |
| 169 | * \returns pointer to start of newly-appended data |
| 170 | * |
| 171 | * This function will move the \a tail pointer of the message buffer \a |
| 172 | * len bytes further, thus enlarging the message by \a len bytes. |
| 173 | * |
| 174 | * The return value is a pointer to start of the newly added section at |
| 175 | * the end of the message and can be used for actually filling/copying |
| 176 | * data into it. |
| 177 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 178 | static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len) |
| 179 | { |
| 180 | unsigned char *tmp = msgb->tail; |
Harald Welte | 46a45a6 | 2010-11-09 13:41:48 +0100 | [diff] [blame] | 181 | if (msgb_tailroom(msgb) < (int) len) |
Harald Welte | 929d887 | 2010-11-05 07:47:41 +0100 | [diff] [blame] | 182 | MSGB_ABORT(msgb, "Not enough tailroom msgb_push (%u < %u)\n", |
| 183 | msgb_tailroom(msgb), len); |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 184 | msgb->tail += len; |
| 185 | msgb->len += len; |
| 186 | return tmp; |
| 187 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 188 | |
| 189 | /*! \brief append a uint8 value to the end of the message |
| 190 | * \param[in] msgb message buffer |
| 191 | * \param[in] word unsigned 8bit byte to be appended |
| 192 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 193 | static inline void msgb_put_u8(struct msgb *msgb, uint8_t word) |
| 194 | { |
| 195 | uint8_t *space = msgb_put(msgb, 1); |
| 196 | space[0] = word & 0xFF; |
| 197 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 198 | |
| 199 | /*! \brief append a uint16 value to the end of the message |
| 200 | * \param[in] msgb message buffer |
| 201 | * \param[in] word unsigned 16bit byte to be appended |
| 202 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 203 | static inline void msgb_put_u16(struct msgb *msgb, uint16_t word) |
| 204 | { |
| 205 | uint8_t *space = msgb_put(msgb, 2); |
| 206 | space[0] = word >> 8 & 0xFF; |
| 207 | space[1] = word & 0xFF; |
| 208 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 209 | |
| 210 | /*! \brief append a uint32 value to the end of the message |
| 211 | * \param[in] msgb message buffer |
| 212 | * \param[in] word unsigned 32bit byte to be appended |
| 213 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 214 | static inline void msgb_put_u32(struct msgb *msgb, uint32_t word) |
| 215 | { |
| 216 | uint8_t *space = msgb_put(msgb, 4); |
| 217 | space[0] = word >> 24 & 0xFF; |
| 218 | space[1] = word >> 16 & 0xFF; |
| 219 | space[2] = word >> 8 & 0xFF; |
| 220 | space[3] = word & 0xFF; |
| 221 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 222 | |
| 223 | /*! \brief remove data from end of message |
| 224 | * \param[in] msgb message buffer |
| 225 | * \param[in] len number of bytes to remove from end |
| 226 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 227 | static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len) |
| 228 | { |
| 229 | unsigned char *tmp = msgb->data; |
| 230 | msgb->data += len; |
| 231 | msgb->len -= len; |
| 232 | return tmp; |
| 233 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 234 | /*! \brief remove uint8 from end of message |
| 235 | * \param[in] msgb message buffer |
| 236 | * \returns 8bit value taken from end of msgb |
| 237 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 238 | static inline uint8_t msgb_get_u8(struct msgb *msgb) |
| 239 | { |
| 240 | uint8_t *space = msgb_get(msgb, 1); |
| 241 | return space[0]; |
| 242 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 243 | /*! \brief remove uint16 from end of message |
| 244 | * \param[in] msgb message buffer |
| 245 | * \returns 16bit value taken from end of msgb |
| 246 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 247 | static inline uint16_t msgb_get_u16(struct msgb *msgb) |
| 248 | { |
| 249 | uint8_t *space = msgb_get(msgb, 2); |
| 250 | return space[0] << 8 | space[1]; |
| 251 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 252 | /*! \brief remove uint32 from end of message |
| 253 | * \param[in] msgb message buffer |
| 254 | * \returns 32bit value taken from end of msgb |
| 255 | */ |
Ingo Albrecht | 48e17f8 | 2010-03-07 18:03:41 +0100 | [diff] [blame] | 256 | static inline uint32_t msgb_get_u32(struct msgb *msgb) |
| 257 | { |
| 258 | uint8_t *space = msgb_get(msgb, 4); |
| 259 | return space[0] << 24 | space[1] << 16 | space[2] << 8 | space[3]; |
| 260 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 261 | |
| 262 | /*! \brief prepend (push) some data to start of message |
| 263 | * \param[in] msgb message buffer |
| 264 | * \param[in] len number of bytes to pre-pend |
| 265 | * \returns pointer to newly added portion at start of \a msgb |
| 266 | * |
| 267 | * This function moves the \a data pointer of the \ref msgb further |
| 268 | * to the front (by \a len bytes), thereby enlarging the message by \a |
| 269 | * len bytes. |
| 270 | * |
| 271 | * The return value is a pointer to the newly added section in the |
| 272 | * beginning of the message. It can be used to fill/copy data into it. |
| 273 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 274 | static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len) |
| 275 | { |
Harald Welte | 46a45a6 | 2010-11-09 13:41:48 +0100 | [diff] [blame] | 276 | if (msgb_headroom(msgb) < (int) len) |
Harald Welte | 929d887 | 2010-11-05 07:47:41 +0100 | [diff] [blame] | 277 | MSGB_ABORT(msgb, "Not enough headroom msgb_push (%u < %u)\n", |
| 278 | msgb_headroom(msgb), len); |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 279 | msgb->data -= len; |
| 280 | msgb->len += len; |
| 281 | return msgb->data; |
| 282 | } |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 283 | /*! \brief remove (pull) a header from the front of the message buffer |
| 284 | * \param[in] msgb message buffer |
| 285 | * \param[in] len number of octets to be pulled |
| 286 | * \returns pointer to new start of msgb |
| 287 | * |
| 288 | * This function moves the \a data pointer of the \ref msgb further back |
| 289 | * in the message, thereby shrinking the size of the message by \a len |
| 290 | * bytes. |
| 291 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 292 | static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len) |
| 293 | { |
| 294 | msgb->len -= len; |
| 295 | return msgb->data += len; |
| 296 | } |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 297 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 298 | /*! \brief Increase headroom of empty msgb, reducing the tailroom |
| 299 | * \param[in] msg message buffer |
| 300 | * \param[in] len amount of extra octets to be reserved as headroom |
| 301 | * |
| 302 | * This function reserves some memory at the beginning of the underlying |
| 303 | * data buffer. The idea is to reserve space in case further headers |
| 304 | * have to be pushed to the \ref msgb during further processing. |
| 305 | * |
| 306 | * Calling this function leads to undefined reusults if it is called on |
| 307 | * a non-empty \ref msgb. |
| 308 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 309 | static inline void msgb_reserve(struct msgb *msg, int len) |
| 310 | { |
| 311 | msg->data += len; |
| 312 | msg->tail += len; |
| 313 | } |
| 314 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 315 | /*! \brief Allocate message buffer with specified headroom |
| 316 | * \param[in] size size in bytes, including headroom |
| 317 | * \param[in] headroom headroom in bytes |
| 318 | * \param[in] name human-readable name |
| 319 | * \returns allocated message buffer with specified headroom |
| 320 | * |
| 321 | * This function is a convenience wrapper around \ref msgb_alloc |
| 322 | * followed by \ref msgb_reserve in order to create a new \ref msgb with |
| 323 | * user-specified amount of headroom. |
| 324 | */ |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 325 | static inline struct msgb *msgb_alloc_headroom(int size, int headroom, |
| 326 | const char *name) |
| 327 | { |
Pablo Neira Ayuso | 87f7b25 | 2011-05-07 12:43:08 +0200 | [diff] [blame] | 328 | osmo_static_assert(size > headroom, headroom_bigger); |
Holger Hans Peter Freyther | 5853f08 | 2011-01-16 17:38:22 +0100 | [diff] [blame] | 329 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 330 | struct msgb *msg = msgb_alloc(size, name); |
| 331 | if (msg) |
| 332 | msgb_reserve(msg, headroom); |
| 333 | return msg; |
| 334 | } |
| 335 | |
Holger Hans Peter Freyther | acffb60 | 2010-10-18 18:22:31 +0200 | [diff] [blame] | 336 | /* non inline functions to ease binding */ |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 337 | |
Holger Hans Peter Freyther | acffb60 | 2010-10-18 18:22:31 +0200 | [diff] [blame] | 338 | uint8_t *msgb_data(const struct msgb *msg); |
| 339 | uint16_t msgb_length(const struct msgb *msg); |
Harald Welte | 9e1f060 | 2011-06-29 18:46:10 +0200 | [diff] [blame] | 340 | void msgb_set_talloc_ctx(void *ctx); |
Holger Hans Peter Freyther | acffb60 | 2010-10-18 18:22:31 +0200 | [diff] [blame] | 341 | |
Harald Welte | ba6988b | 2011-08-17 12:46:48 +0200 | [diff] [blame] | 342 | /*! }@ */ |
| 343 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 344 | #endif /* _MSGB_H */ |