43 struct gsm_bts_trx *
trx;
74 int old_size,
int new_size);
124 #define MSGB_ABORT(msg, fmt, args ...) do { \ 125 osmo_panic("msgb(%p): " fmt, msg, ## args); \ 128 #define MSGB_ABORT(msg, fmt, args ...) 132 #define msgb_l1(m) ((void *)(m->l1h)) 134 #define msgb_l2(m) ((void *)(m->l2h)) 136 #define msgb_l3(m) ((void *)(m->l3h)) 138 #define msgb_l4(m) ((void *)(m->l4h)) 140 #define msgb_sms(m) msgb_l4(m) 240 unsigned char *tmp = msgb->
tail;
242 MSGB_ABORT(msgb,
"Not enough tailroom msgb_put" 243 " (allocated %u, head at %u, len %u, tailroom %u < want tailroom %u)\n",
244 msgb->
data_len -
sizeof(
struct msgb),
260 space[0] = word & 0xFF;
290 MSGB_ABORT(msgb,
"msgb too small to get %u (len %u)\n",
342 MSGB_ABORT(msgb,
"Not enough headroom msgb_push" 343 " (allocated %u, head at %u < want headroom %u, len %u, tailroom %u)\n",
344 msgb->
data_len -
sizeof(
struct msgb),
370 uint16_t *space = (uint16_t *)
msgb_push(msg, 2);
380 uint32_t *space = (uint32_t *)
msgb_push(msg, 4);
389 data[1] = msgb->
len - 2;
405 MSGB_ABORT(msgb,
"msgb too small to pull %u (len %u)\n",
422 msg->
l1h = msg->
l2h = NULL;
496 MSGB_ABORT(msg,
"Negative length is not allowed\n");
566 const unsigned char *lbound;
567 if (!msg || !msg->
data || !msg->
tail ||
576 if (msg->
l1h < lbound)
581 if (msg->
l2h < lbound)
586 if (msg->
l3h < lbound)
591 if (msg->
l4h < lbound)
608 #define msgb_eq_data(msg, data, len) \ 609 _msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, false) 617 #define msgb_eq_l1_data(msg, data, len) \ 618 _msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, false) 626 #define msgb_eq_l2_data(msg, data, len) \ 627 _msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, false) 635 #define msgb_eq_l3_data(msg, data, len) \ 636 _msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, false) 644 #define msgb_eq_l4_data(msg, data, len) \ 645 _msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, false) 656 #define msgb_eq_data_print(msg, data, len) \ 657 _msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, true) 665 #define msgb_eq_l1_data_print(msg, data, len) \ 666 _msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, true) 674 #define msgb_eq_l2_data_print(msg, data, len) \ 675 _msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, true) 683 #define msgb_eq_l3_data_print(msg, data, len) \ 684 _msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, true) 693 #define msgb_eq_l4_data_print(msg, data, len) \ 694 _msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, true) 697 const struct msgb *msg,
const uint8_t *
data,
size_t len,
bool print);
707 #define msgb_eq(msg1, msg2) msgb_eq_data(msg1, msgb_data(msg2), msgb_length(msg2)) 714 #define msgb_eq_l1(msg1, msg2) msgb_eq_l1_data(msg1, msgb_l1(msg2), msgb_l1len(msg2)) 721 #define msgb_eq_l2(msg1, msg2) msgb_eq_l2_data(msg1, msgb_l2(msg2), msgb_l2len(msg2)) 728 #define msgb_eq_l3(msg1, msg2) msgb_eq_l3_data(msg1, msgb_l3(msg2), msgb_l3len(msg2)) 735 #define msgb_eq_l4(msg1, msg2) msgb_eq_l4_data(msg1, msgb_l4(msg2), msgb_l4len(msg2)) #define msgb_l4(m)
obtain L4 header of msgb
Definition: msgb.h:138
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:238
static const char * msgb_hexdump_l4(const struct msgb *msg)
Definition: msgb.h:767
static uint16_t msgb_pull_u16(struct msgb *msgb)
remove uint16 from front of message
Definition: msgb.h:455
static unsigned int msgb_l3len(const struct msgb *msgb)
determine length of L3 message
Definition: msgb.h:173
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 gsm48_classmark3 __attribute__
fls64 - find last set bit in a 64-bit word : the word to search
Definition: log2.h:61
#define msgb_l3(m)
obtain L3 header of msgb
Definition: msgb.h:136
#define msgb_l1(m)
obtain L1 header of msgb
Definition: msgb.h:132
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer from tall_msgb_ctx.
Definition: msgb.c:112
struct msgb * msgb_copy_c(const void *ctx, const struct msgb *msg, const char *name)
Copy an msgb.
Definition: msgb.c:329
struct msgb * msgb_alloc_c(const void *ctx, uint16_t size, const char *name)
Allocate a new message buffer from given talloc context.
Definition: msgb.c:77
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:753
Osmocom message buffer.
Definition: msgb.h:35
static const char * msgb_hexdump_l1(const struct msgb *msg)
Definition: msgb.h:746
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:298
static const char * msgb_hexdump_l3(const struct msgb *msg)
Definition: msgb.h:760
#define msgb_sms(m)
obtain SMS header of msgb
Definition: msgb.h:140
static int msgb_l3trim(struct msgb *msg, int l3len)
Trim the msgb to a given layer3 length.
Definition: msgb.h:511
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:384
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:493
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:185
uint16_t len
length of bytes used in msgb
Definition: msgb.h:55
char name[32]
source file name
Definition: gsmtap.h:131
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:419
#define osmo_static_assert(exp, name)
Definition: utils.h:73
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:121
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:209
uint8_t level
logging level
Definition: gsmtap.h:126
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:113
static uint16_t osmo_load16be(const void *p)
load unaligned 16-bit integer (big-endian encoding)
Definition: bit16gen.h:112
static unsigned int msgb_l1len(const struct msgb *msgb)
determine length of L1 message
Definition: msgb.h:149
static unsigned char * msgb_get(struct msgb *msgb, unsigned int len)
remove data from end of message
Definition: msgb.h:287
const char * msgb_hexdump(const struct msgb *msg)
Return a (static) buffer containing a hexdump of the msg.
Definition: msgb.c:512
static void msgb_push_u8(struct msgb *msg, uint8_t word)
prepend a uint8 value to the head of the message
Definition: msgb.h:358
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:145
static void msgb_queue_free(struct llist_head *queue)
Free all msgbs from a queue built with msgb_enqueue().
Definition: msgb.h:82
void * msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size)
Initialize a msgb talloc context for msgb_alloc.
Definition: msgb.c:311
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:384
static uint32_t msgb_pull_u32(struct msgb *msgb)
remove uint32 from front of message
Definition: msgb.h:465
static unsigned int msgb_l2len(const struct msgb *msgb)
determine length of L2 message
Definition: msgb.h:161
char * msgb_hexdump_c(const void *ctx, const struct msgb *msg)
Return a dynamically allocated buffer containing a hexdump of the msg.
Definition: msgb.c:523
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition: msgb.h:339
static struct msgb * msgb_alloc_headroom_c(const void *ctx, uint16_t size, uint16_t headroom, const char *name)
Allocate message buffer with specified headroom from specified talloc context.
Definition: msgb.h:527
Simple doubly linked list implementation.
char * msgb_hexdump_buf(char *buf, size_t buf_len, const struct msgb *msg)
fill user-provided buffer with hexdump of the msg.
Definition: msgb.c:431
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:206
(double) linked list header structure
Definition: linuxlist.h:46
unsigned char * l1h
pointer to Layer1 header (if any)
Definition: msgb.h:47
static struct msgb * msgb_alloc_headroom(uint16_t size, uint16_t headroom, const char *name)
Allocate message buffer with specified headroom.
Definition: msgb.h:549
static uint8_t msgb_pull_u8(struct msgb *msgb)
remove uint8 from front of message
Definition: msgb.h:445
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition: msgb.c:133
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:168
static void msgb_push_u32(struct msgb *msg, uint32_t word)
prepend a uint32 value to the head of the message
Definition: msgb.h:378
static void msgb_reserve(struct msgb *msg, int len)
Increase headroom of empty msgb, reducing the tailroom.
Definition: msgb.h:482
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:549
static void msgb_put_u16(struct msgb *msgb, uint16_t word)
append a uint16 value to the end of the message
Definition: msgb.h:267
static uint8_t msgb_get_u8(struct msgb *msgb)
remove uint8 from end of message
Definition: msgb.h:301
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:366
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:321
static int msgb_headroom(const struct msgb *msgb)
determine the amount of headroom in msgb
Definition: msgb.h:221
Osmocom bit level support code.
static uint32_t osmo_load32be(const void *p)
load unaligned 32-bit integer (big-endian encoding)
Definition: bit32gen.h:112
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:125
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:188
#define msgb_l2(m)
obtain L2 header of msgb
Definition: msgb.h:134
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:97
static uint16_t msgb_get_u16(struct msgb *msgb)
remove uint16 from end of message
Definition: msgb.h:311
char * osmo_hexdump(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:396
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:197
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:289
static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure))
Check a message buffer for consistency.
Definition: msgb.h:564
static void msgb_put_u32(struct msgb *msgb, uint32_t word)
append a uint32 value to the end of the message
Definition: msgb.h:277
#define MSGB_ABORT(msg, fmt, args ...)
Definition: msgb.h:124
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:402
static void osmo_store32be(uint32_t x, void *p)
store unaligned 32-bit integer (big-endian encoding)
Definition: bit32gen.h:125
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:434
static void msgb_push_u16(struct msgb *msg, uint16_t word)
prepend a uint16 value to the head of the message
Definition: msgb.h:368
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition: msgb.h:257