libosmocore  1.0.1.85-9f28
Osmocom core library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
msgb.h
Go to the documentation of this file.
1 #pragma once
2 
3 /* (C) 2008 by Harald Welte <laforge@gnumonks.org>
4  * All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  */
21 
22 #include <stdint.h>
23 #include <osmocom/core/linuxlist.h>
24 #include <osmocom/core/utils.h>
25 #include <osmocom/core/bits.h>
26 #include <osmocom/core/defs.h>
27 
32 #define MSGB_DEBUG
33 
35 struct msgb {
36  struct llist_head list;
39  /* Part of which TRX logical channel we were received / transmitted */
40  /* FIXME: move them into the control buffer */
41  union {
42  void *dst;
43  struct gsm_bts_trx *trx;
44  };
45  struct gsm_lchan *lchan;
47  unsigned char *l1h;
48  unsigned char *l2h;
49  unsigned char *l3h;
50  unsigned char *l4h;
52  unsigned long cb[5];
54  uint16_t data_len;
55  uint16_t len;
57  unsigned char *head;
58  unsigned char *tail;
59  unsigned char *data;
60  unsigned char _data[0];
61 };
62 
63 extern struct msgb *msgb_alloc(uint16_t size, const char *name);
64 extern void msgb_free(struct msgb *m);
65 extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
66 extern struct msgb *msgb_dequeue(struct llist_head *queue);
67 extern void msgb_reset(struct msgb *m);
68 uint16_t msgb_length(const struct msgb *msg);
69 extern const char *msgb_hexdump(const struct msgb *msg);
70 extern int msgb_resize_area(struct msgb *msg, uint8_t *area,
71  int old_size, int new_size);
72 extern struct msgb *msgb_copy(const struct msgb *msg, const char *name);
73 static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure));
74 
78 static inline void msgb_queue_free(struct llist_head *queue)
79 {
80  struct msgb *msg;
81  while ((msg = msgb_dequeue(queue))) msgb_free(msg);
82 }
83 
93 static inline void msgb_enqueue_count(struct llist_head *queue, struct msgb *msg,
94  unsigned int *count)
95 {
96  msgb_enqueue(queue, msg);
97  (*count)++;
98 }
99 
109 static inline struct msgb *msgb_dequeue_count(struct llist_head *queue,
110  unsigned int *count)
111 {
112  struct msgb *msg = msgb_dequeue(queue);
113  if (msg)
114  (*count)--;
115  return msg;
116 }
117 
118 #ifdef MSGB_DEBUG
119 #include <osmocom/core/panic.h>
120 #define MSGB_ABORT(msg, fmt, args ...) do { \
121  osmo_panic("msgb(%p): " fmt, msg, ## args); \
122  } while(0)
123 #else
124 #define MSGB_ABORT(msg, fmt, args ...)
125 #endif
126 
128 #define msgb_l1(m) ((void *)(m->l1h))
129 
130 #define msgb_l2(m) ((void *)(m->l2h))
131 
132 #define msgb_l3(m) ((void *)(m->l3h))
133 
134 #define msgb_l4(m) ((void *)(m->l4h))
135 
136 #define msgb_sms(m) msgb_l4(m)
137 
145 static inline unsigned int msgb_l1len(const struct msgb *msgb)
146 {
147  return msgb->tail - (uint8_t *)msgb_l1(msgb);
148 }
149 
157 static inline unsigned int msgb_l2len(const struct msgb *msgb)
158 {
159  return msgb->tail - (uint8_t *)msgb_l2(msgb);
160 }
161 
169 static inline unsigned int msgb_l3len(const struct msgb *msgb)
170 {
171  return msgb->tail - (uint8_t *)msgb_l3(msgb);
172 }
173 
181 static inline unsigned int msgb_l4len(const struct msgb *msgb)
182 {
183  return msgb->tail - (uint8_t *)msgb_sms(msgb);
184 }
185 
193 static inline unsigned int msgb_headlen(const struct msgb *msgb)
194 {
195  return msgb->len - msgb->data_len;
196 }
197 
205 static inline int msgb_tailroom(const struct msgb *msgb)
206 {
207  return (msgb->head + msgb->data_len) - msgb->tail;
208 }
209 
217 static inline int msgb_headroom(const struct msgb *msgb)
218 {
219  return (msgb->data - msgb->head);
220 }
221 
234 static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
235 {
236  unsigned char *tmp = msgb->tail;
237  if (msgb_tailroom(msgb) < (int) len)
238  MSGB_ABORT(msgb, "Not enough tailroom msgb_put (%u < %u)\n",
239  msgb_tailroom(msgb), len);
240  msgb->tail += len;
241  msgb->len += len;
242  return tmp;
243 }
244 
249 static inline void msgb_put_u8(struct msgb *msgb, uint8_t word)
250 {
251  uint8_t *space = msgb_put(msgb, 1);
252  space[0] = word & 0xFF;
253 }
254 
259 static inline void msgb_put_u16(struct msgb *msgb, uint16_t word)
260 {
261  uint8_t *space = msgb_put(msgb, 2);
262  osmo_store16be(word, space);
263 }
264 
269 static inline void msgb_put_u32(struct msgb *msgb, uint32_t word)
270 {
271  uint8_t *space = msgb_put(msgb, 4);
272  osmo_store32be(word, space);
273 }
274 
279 static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len)
280 {
281  if (msgb_length(msgb) < len)
282  MSGB_ABORT(msgb, "msgb too small to get %u (len %u)\n",
283  len, msgb_length(msgb));
284  msgb->tail -= len;
285  msgb->len -= len;
286  return msgb->tail;
287 }
288 
293 static inline uint8_t msgb_get_u8(struct msgb *msgb)
294 {
295  uint8_t *space = msgb_get(msgb, 1);
296  return space[0];
297 }
298 
303 static inline uint16_t msgb_get_u16(struct msgb *msgb)
304 {
305  uint8_t *space = msgb_get(msgb, 2);
306  return osmo_load16be(space);
307 }
308 
313 static inline uint32_t msgb_get_u32(struct msgb *msgb)
314 {
315  uint8_t *space = msgb_get(msgb, 4);
316  return osmo_load32be(space);
317 }
318 
331 static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
332 {
333  if (msgb_headroom(msgb) < (int) len)
334  MSGB_ABORT(msgb, "Not enough headroom msgb_push (%u < %u)\n",
335  msgb_headroom(msgb), len);
336  msgb->data -= len;
337  msgb->len += len;
338  return msgb->data;
339 }
340 
345 static inline void msgb_push_u8(struct msgb *msg, uint8_t word)
346 {
347  uint8_t *space = msgb_push(msg, 1);
348  space[0] = word;
349 }
350 
355 static inline void msgb_push_u16(struct msgb *msg, uint16_t word)
356 {
357  uint16_t *space = (uint16_t *) msgb_push(msg, 2);
358  osmo_store16be(word, space);
359 }
360 
365 static inline void msgb_push_u32(struct msgb *msg, uint32_t word)
366 {
367  uint32_t *space = (uint32_t *) msgb_push(msg, 4);
368  osmo_store32be(word, space);
369 }
370 
371 static inline unsigned char *msgb_push_tl(struct msgb *msgb, uint8_t tag)
372 {
373  uint8_t *data = msgb_push(msgb, 2);
374 
375  data[0] = tag;
376  data[1] = msgb->len - 2;
377  return data;
378 }
379 
389 static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
390 {
391  if (msgb_length(msgb) < len)
392  MSGB_ABORT(msgb, "msgb too small to pull %u (len %u)\n",
393  len, msgb_length(msgb));
394  msgb->len -= len;
395  return msgb->data += len;
396 }
397 
406 static inline unsigned char *msgb_pull_to_l3(struct msgb *msg)
407 {
408  unsigned char *ret = msgb_pull(msg, msg->l3h - msg->data);
409  msg->l1h = msg->l2h = NULL;
410  return ret;
411 }
412 
421 static inline unsigned char *msgb_pull_to_l2(struct msgb *msg)
422 {
423  unsigned char *ret = msgb_pull(msg, msg->l2h - msg->data);
424  msg->l1h = NULL;
425  return ret;
426 }
427 
432 static inline uint8_t msgb_pull_u8(struct msgb *msgb)
433 {
434  uint8_t *space = msgb_pull(msgb, 1) - 1;
435  return space[0];
436 }
437 
442 static inline uint16_t msgb_pull_u16(struct msgb *msgb)
443 {
444  uint8_t *space = msgb_pull(msgb, 2) - 2;
445  return osmo_load16be(space);
446 }
447 
452 static inline uint32_t msgb_pull_u32(struct msgb *msgb)
453 {
454  uint8_t *space = msgb_pull(msgb, 4) - 4;
455  return osmo_load32be(space);
456 }
457 
469 static inline void msgb_reserve(struct msgb *msg, int len)
470 {
471  msg->data += len;
472  msg->tail += len;
473 }
474 
480 static inline int msgb_trim(struct msgb *msg, int len)
481 {
482  if (len < 0)
483  MSGB_ABORT(msg, "Negative length is not allowed\n");
484  if (len > msg->data_len)
485  return -1;
486 
487  msg->len = len;
488  msg->tail = msg->data + len;
489 
490  return 0;
491 }
492 
498 static inline int msgb_l3trim(struct msgb *msg, int l3len)
499 {
500  return msgb_trim(msg, (msg->l3h - msg->data) + l3len);
501 }
502 
513 static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
514  const char *name)
515 {
516  osmo_static_assert(size > headroom, headroom_bigger);
517 
518  struct msgb *msg = msgb_alloc(size, name);
519  if (msg)
520  msgb_reserve(msg, headroom);
521  return msg;
522 }
523 
528 static inline int msgb_test_invariant(const struct msgb *msg)
529 {
530  const unsigned char *lbound;
531  if (!msg || !msg->data || !msg->tail ||
532  (msg->data + msg->len != msg->tail) ||
533  (msg->data < msg->head) ||
534  (msg->tail > msg->head + msg->data_len))
535  return 0;
536 
537  lbound = msg->head;
538 
539  if (msg->l1h) {
540  if (msg->l1h < lbound)
541  return 0;
542  lbound = msg->l1h;
543  }
544  if (msg->l2h) {
545  if (msg->l2h < lbound)
546  return 0;
547  lbound = msg->l2h;
548  }
549  if (msg->l3h) {
550  if (msg->l3h < lbound)
551  return 0;
552  lbound = msg->l3h;
553  }
554  if (msg->l4h) {
555  if (msg->l4h < lbound)
556  return 0;
557  lbound = msg->l4h;
558  }
559 
560  return lbound <= msg->head + msg->data_len;
561 }
562 
563 
564 /* msgb data comparison helpers */
565 
572 #define msgb_eq_data(msg, data, len) \
573  _msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, false)
574 
581 #define msgb_eq_l1_data(msg, data, len) \
582  _msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, false)
583 
590 #define msgb_eq_l2_data(msg, data, len) \
591  _msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, false)
592 
599 #define msgb_eq_l3_data(msg, data, len) \
600  _msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, false)
601 
608 #define msgb_eq_l4_data(msg, data, len) \
609  _msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, false)
610 
611 
612 /* msgb test/debug helpers */
613 
620 #define msgb_eq_data_print(msg, data, len) \
621  _msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, true)
622 
629 #define msgb_eq_l1_data_print(msg, data, len) \
630  _msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, true)
631 
638 #define msgb_eq_l2_data_print(msg, data, len) \
639  _msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, true)
640 
647 #define msgb_eq_l3_data_print(msg, data, len) \
648  _msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, true)
649 
650 
657 #define msgb_eq_l4_data_print(msg, data, len) \
658  _msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, true)
659 
660 bool _msgb_eq(const char *file, size_t line, const char *func, uint8_t level,
661  const struct msgb *msg, const uint8_t *data, size_t len, bool print);
662 
663 
664 /* msgb data comparison */
665 
671 #define msgb_eq(msg1, msgb2, len) msgb_eq_data(msg1, msgb_data(msg2), msgb_length(msg2))
672 
678 #define msgb_eq_l1(msg1, msgb2, len) msgb_eq_l1_data(msg1, msgb_l1(msg2), msgb_l1len(msg2))
679 
685 #define msgb_eq_l2(msg1, msgb2, len) msgb_eq_l2_data(msg1, msgb_l2(msg2), msgb_l2len(msg2))
686 
692 #define msgb_eq_l3(msg1, msgb2, len) msgb_eq_l3_data(msg1, msgb_l3(msg2), msgb_l3len(msg2))
693 
699 #define msgb_eq_l4(msg1, msgb2, len) msgb_eq_l4_data(msg1, msgb_l4(msg2), msgb_l4len(msg2))
700 
701 
702 /* non inline functions to ease binding */
703 
704 uint8_t *msgb_data(const struct msgb *msg);
705 
706 void *msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size);
707 void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use msgb_talloc_ctx_init() instead");
708 int msgb_printf(struct msgb *msgb, const char *format, ...);
709 
710 static inline const char *msgb_hexdump_l1(const struct msgb *msg)
711 {
712  if (!msgb_l1(msg) || !(msgb_l1len(msg)))
713  return "[]";
714  return osmo_hexdump((const unsigned char *) msgb_l1(msg), msgb_l1len(msg));
715 }
716 
717 static inline const char *msgb_hexdump_l2(const struct msgb *msg)
718 {
719  if (!msgb_l2(msg) || !(msgb_l2len(msg)))
720  return "[]";
721  return osmo_hexdump((const unsigned char *) msgb_l2(msg), msgb_l2len(msg));
722 }
723 
724 static inline const char *msgb_hexdump_l3(const struct msgb *msg)
725 {
726  if (!msgb_l3(msg) || !(msgb_l3len(msg)))
727  return "[]";
728  return osmo_hexdump((const unsigned char*) msgb_l3(msg), msgb_l3len(msg));
729 }
730 
731 static inline const char *msgb_hexdump_l4(const struct msgb *msg)
732 {
733  if (!msgb_l4(msg) || !(msgb_l4len(msg)))
734  return "[]";
735  return osmo_hexdump((const unsigned char*) msgb_l4(msg), msgb_l4len(msg));
736 }
737 
#define msgb_l4(m)
obtain L4 header of msgb
Definition: msgb.h:134
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:234
static const char * msgb_hexdump_l4(const struct msgb *msg)
Definition: msgb.h:731
static uint16_t msgb_pull_u16(struct msgb *msgb)
remove uint16 from front of message
Definition: msgb.h:442
static unsigned int msgb_l3len(const struct msgb *msgb)
determine length of L3 message
Definition: msgb.h:169
unsigned long cb[5]
control buffer
Definition: msgb.h:52
#define OSMO_DEPRECATED(text)
Set the deprecated attribute with a message.
Definition: defs.h:41
unsigned char * l3h
pointer to Layer 3 header.
Definition: msgb.h:49
struct osmo_gsm48_classmark __attribute__
Definition: conv_acc_generic.c:140
#define msgb_l3(m)
obtain L3 header of msgb
Definition: msgb.h:132
#define msgb_l1(m)
obtain L1 header of msgb
Definition: msgb.h:128
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer.
Definition: msgb.c:78
unsigned char * data
start of message in buffer
Definition: msgb.h:59
static const char * msgb_hexdump_l2(const struct msgb *msg)
Definition: msgb.h:717
Osmocom message buffer.
Definition: msgb.h:35
static const char * msgb_hexdump_l1(const struct msgb *msg)
Definition: msgb.h:710
void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use msgb_talloc_ctx_init() instead")
Set the talloc context for msgb_alloc Deprecated, use msgb_talloc_ctx_init() instead.
Definition: msgb.c:281
static const char * msgb_hexdump_l3(const struct msgb *msg)
Definition: msgb.h:724
#define msgb_sms(m)
obtain SMS header of msgb
Definition: msgb.h:136
static int msgb_l3trim(struct msgb *msg, int l3len)
Trim the msgb to a given layer3 length.
Definition: msgb.h:498
General definitions that are meant to be included from header files.
static unsigned char * msgb_push_tl(struct msgb *msgb, uint8_t tag)
Definition: msgb.h:371
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:480
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
static unsigned int msgb_l4len(const struct msgb *msgb)
determine length of L4 message
Definition: msgb.h:181
uint16_t len
length of bytes used in msgb
Definition: msgb.h:55
char name[32]
source file name
Definition: gsmtap.h:124
static unsigned char * msgb_pull_to_l3(struct msgb *msg)
remove (pull) all headers in front of l3h from the message buffer.
Definition: msgb.h:406
#define osmo_static_assert(exp, name)
Definition: utils.h:64
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:104
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:205
uint8_t level
logging level
Definition: gsmtap.h:119
unsigned char * l4h
pointer to layer 4 header
Definition: msgb.h:50
static struct msgb * msgb_dequeue_count(struct llist_head *queue, unsigned int *count)
Dequeue message buffer from head of queue and decrement queue size counter.
Definition: msgb.h:109
static uint16_t osmo_load16be(const void *p)
load unaligned 16-bit integer (big-endian encoding)
Definition: bit16gen.h:89
static unsigned int msgb_l1len(const struct msgb *msgb)
determine length of L1 message
Definition: msgb.h:145
static unsigned char * msgb_get(struct msgb *msgb, unsigned int len)
remove data from end of message
Definition: msgb.h:279
const char * msgb_hexdump(const struct msgb *msg)
Return a (static) buffer containing a hexdump of the msg.
Definition: msgb.c:399
static void msgb_push_u8(struct msgb *msg, uint8_t word)
prepend a uint8 value to the head of the message
Definition: msgb.h:345
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:128
static void msgb_queue_free(struct llist_head *queue)
Free all msgbs from a queue built with msgb_enqueue().
Definition: msgb.h:78
void * msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size)
Initialize a msgb talloc context for msgb_alloc.
Definition: msgb.c:294
int msgb_resize_area(struct msgb *msg, uint8_t *area, int old_size, int new_size)
Resize an area within an msgb.
Definition: msgb.c:354
uint8_t data[0]
static uint32_t msgb_pull_u32(struct msgb *msgb)
remove uint32 from front of message
Definition: msgb.h:452
static unsigned int msgb_l2len(const struct msgb *msgb)
determine length of L2 message
Definition: msgb.h:157
static struct msgb * msgb_alloc_headroom(int size, int headroom, const char *name)
Allocate message buffer with specified headroom.
Definition: msgb.h:513
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition: msgb.h:331
Simple doubly linked list implementation.
struct gsm_bts_trx * trx
Definition: msgb.h:43
bool _msgb_eq(const char *file, size_t line, const char *func, uint8_t level, const struct msgb *msg, const uint8_t *data, size_t len, bool print)
Compare and print: check data in msgb against given data and print errors if any. ...
Definition: msgb.c:189
(double) linked list header structure
Definition: linuxlist.h:46
unsigned char * l1h
pointer to Layer1 header (if any)
Definition: msgb.h:47
static uint8_t msgb_pull_u8(struct msgb *msgb)
remove uint8 from front of message
Definition: msgb.h:432
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition: msgb.c:116
struct gsm_lchan * lchan
logical channel
Definition: msgb.h:45
void msgb_reset(struct msgb *m)
Re-set all message buffer pointers.
Definition: msgb.c:151
static void msgb_push_u32(struct msgb *msg, uint32_t word)
prepend a uint32 value to the head of the message
Definition: msgb.h:365
static void msgb_reserve(struct msgb *msg, int len)
Increase headroom of empty msgb, reducing the tailroom.
Definition: msgb.h:469
unsigned char * tail
end of message in buffer
Definition: msgb.h:58
int msgb_printf(struct msgb *msgb, const char *format,...)
Print a string to the end of message buffer.
Definition: msgb.c:494
static void msgb_put_u16(struct msgb *msgb, uint16_t word)
append a uint16 value to the end of the message
Definition: msgb.h:259
static uint8_t msgb_get_u8(struct msgb *msgb)
remove uint8 from end of message
Definition: msgb.h:293
unsigned char * l2h
pointer to A-bis layer 2 header: OML, RSL(RLL), NS
Definition: msgb.h:48
struct msgb * msgb_copy(const struct msgb *msg, const char *name)
Copy an msgb.
Definition: msgb.c:312
unsigned char * head
start of underlying memory buffer
Definition: msgb.h:57
static uint32_t msgb_get_u32(struct msgb *msgb)
remove uint32 from end of message
Definition: msgb.h:313
static int msgb_headroom(const struct msgb *msgb)
determine the amount of headroom in msgb
Definition: msgb.h:217
Osmocom bit level support code.
static size_t len(const char *str)
static uint32_t osmo_load32be(const void *p)
load unaligned 32-bit integer (big-endian encoding)
Definition: bit32gen.h:89
uint16_t data_len
length of underlying data array
Definition: msgb.h:54
static void osmo_store16be(uint16_t x, void *p)
store unaligned 16-bit integer (big-endian encoding)
Definition: bit16gen.h:102
#define MSGB_ABORT(msg, fmt, args...)
Definition: msgb.h:120
unsigned char _data[0]
optional immediate data array
Definition: msgb.h:60
struct llist_head list
linked list header
Definition: msgb.h:36
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:171
#define msgb_l2(m)
obtain L2 header of msgb
Definition: msgb.h:130
static void msgb_enqueue_count(struct llist_head *queue, struct msgb *msg, unsigned int *count)
Enqueue message buffer to tail of a queue and increment queue size counter.
Definition: msgb.h:93
static uint16_t msgb_get_u16(struct msgb *msgb)
remove uint16 from end of message
Definition: msgb.h:303
char * osmo_hexdump(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:321
void * dst
reference of origin/destination
Definition: msgb.h:42
static unsigned int msgb_headlen(const struct msgb *msgb)
determine the length of the header
Definition: msgb.h:193
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:272
static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure))
Check a message buffer for consistency.
Definition: msgb.h:528
static void msgb_put_u32(struct msgb *msgb, uint32_t word)
append a uint32 value to the end of the message
Definition: msgb.h:269
static unsigned char * msgb_pull(struct msgb *msgb, unsigned int len)
remove (pull) a header from the front of the message buffer
Definition: msgb.h:389
static void osmo_store32be(uint32_t x, void *p)
store unaligned 32-bit integer (big-endian encoding)
Definition: bit32gen.h:102
static unsigned char * msgb_pull_to_l2(struct msgb *msg)
remove (pull) all headers in front of l2h from the message buffer.
Definition: msgb.h:421
static void msgb_push_u16(struct msgb *msg, uint16_t word)
prepend a uint16 value to the head of the message
Definition: msgb.h:355
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition: msgb.h:249