Loading...
Searching...
No Matches
msgb.h
Go to the documentation of this file.
#pragma once
/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/defs.h>
#define MSGB_DEBUG
struct msgb {
struct llist_head list;
/* Part of which TRX logical channel we were received / transmitted */
/* FIXME: move them into the control buffer */
union {
void *dst;
struct gsm_bts_trx *trx;
};
struct gsm_lchan *lchan;
unsigned char *l1h;
unsigned char *l2h;
unsigned char *l3h;
unsigned char *l4h;
unsigned long cb[5];
uint16_t data_len;
uint16_t len;
unsigned char *head;
unsigned char *tail;
unsigned char *data;
unsigned char _data[0];
};
extern struct msgb *msgb_alloc_c(const void *ctx, uint16_t size, const char *name);
extern struct msgb *msgb_alloc(uint16_t size, const char *name);
extern void msgb_free(struct msgb *m);
extern void msgb_enqueue(struct llist_head *queue, struct msgb *msg);
extern struct msgb *msgb_dequeue(struct llist_head *queue);
extern void msgb_reset(struct msgb *m);
uint16_t msgb_length(const struct msgb *msg);
extern const char *msgb_hexdump(const struct msgb *msg);
char *msgb_hexdump_buf(char *buf, size_t buf_len, const struct msgb *msg);
char *msgb_hexdump_c(const void *ctx, const struct msgb *msg);
extern int msgb_resize_area(struct msgb *msg, uint8_t *area,
int old_size, int new_size);
extern struct msgb *msgb_copy(const struct msgb *msg, const char *name);
extern struct msgb *msgb_copy_c(const void *ctx, const struct msgb *msg, const char *name);
extern struct msgb *msgb_copy_resize(const struct msgb *msg, uint16_t new_len, const char *name);
extern struct msgb *msgb_copy_resize_c(const void *ctx, const struct msgb *msg, uint16_t new_len, const char *name);
static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure));
static inline void msgb_queue_free(struct llist_head *queue)
{
struct msgb *msg;
while ((msg = msgb_dequeue(queue))) msgb_free(msg);
}
static inline void msgb_enqueue_count(struct llist_head *queue, struct msgb *msg,
unsigned int *count)
{
msgb_enqueue(queue, msg);
(*count)++;
}
static inline struct msgb *msgb_dequeue_count(struct llist_head *queue,
unsigned int *count)
{
struct msgb *msg = msgb_dequeue(queue);
if (msg)
(*count)--;
return msg;
}
#ifdef MSGB_DEBUG
#include <osmocom/core/panic.h>
#define MSGB_ABORT(msg, fmt, args ...) do { \
osmo_panic("msgb(%p): " fmt, msg, ## args); \
} while(0)
#else
#define MSGB_ABORT(msg, fmt, args ...)
#endif
#define msgb_l1(m) ((void *)((m)->l1h))
#define msgb_l2(m) ((void *)((m)->l2h))
#define msgb_l3(m) ((void *)((m)->l3h))
#define msgb_l4(m) ((void *)((m)->l4h))
#define msgb_sms(m) msgb_l4(m)
static inline unsigned int msgb_l1len(const struct msgb *msgb)
{
OSMO_ASSERT(msgb->l1h);
return msgb->tail - (uint8_t *)msgb_l1(msgb);
}
static inline unsigned int msgb_l2len(const struct msgb *msgb)
{
OSMO_ASSERT(msgb->l2h);
return msgb->tail - (uint8_t *)msgb_l2(msgb);
}
static inline unsigned int msgb_l3len(const struct msgb *msgb)
{
OSMO_ASSERT(msgb->l3h);
return msgb->tail - (uint8_t *)msgb_l3(msgb);
}
static inline unsigned int msgb_l4len(const struct msgb *msgb)
{
OSMO_ASSERT(msgb->l4h);
return msgb->tail - (uint8_t *)msgb_l4(msgb);
}
static inline unsigned int msgb_headlen(const struct msgb *msgb)
{
return msgb->len - msgb->data_len;
}
static inline int msgb_tailroom(const struct msgb *msgb)
{
return (msgb->head + msgb->data_len) - msgb->tail;
}
static inline int msgb_headroom(const struct msgb *msgb)
{
return (msgb->data - msgb->head);
}
static inline unsigned char *msgb_put(struct msgb *msgb, unsigned int len)
{
unsigned char *tmp = msgb->tail;
if (OSMO_UNLIKELY(msgb_tailroom(msgb) < (int) len))
MSGB_ABORT(msgb, "Not enough tailroom msgb_put"
" (allocated %u, head at %u, len %u, tailroom %u < want tailroom %u)\n",
msgb->data_len - sizeof(struct msgb),
msgb->head - msgb->_data,
msgb->len,
msgb_tailroom(msgb), len);
msgb->tail += len;
msgb->len += len;
return tmp;
}
static inline void msgb_put_u8(struct msgb *msgb, uint8_t word)
{
uint8_t *space = msgb_put(msgb, 1);
space[0] = word & 0xFF;
}
static inline void msgb_put_u16(struct msgb *msgb, uint16_t word)
{
uint8_t *space = msgb_put(msgb, 2);
osmo_store16be(word, space);
}
static inline void msgb_put_u32(struct msgb *msgb, uint32_t word)
{
uint8_t *space = msgb_put(msgb, 4);
osmo_store32be(word, space);
}
static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len)
{
if (OSMO_UNLIKELY(msgb_length(msgb) < len))
MSGB_ABORT(msgb, "msgb too small to get %u (len %u)\n",
len, msgb_length(msgb));
msgb->tail -= len;
msgb->len -= len;
return msgb->tail;
}
static inline uint8_t msgb_get_u8(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 1);
return space[0];
}
static inline uint16_t msgb_get_u16(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 2);
return osmo_load16be(space);
}
static inline uint32_t msgb_get_u32(struct msgb *msgb)
{
uint8_t *space = msgb_get(msgb, 4);
return osmo_load32be(space);
}
static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len)
{
if (OSMO_UNLIKELY(msgb_headroom(msgb) < (int) len))
MSGB_ABORT(msgb, "Not enough headroom msgb_push"
" (allocated %u, head at %u < want headroom %u, len %u, tailroom %u)\n",
msgb->data_len - sizeof(struct msgb),
msgb->head - msgb->_data,
len,
msgb->len,
msgb_tailroom(msgb));
msgb->data -= len;
msgb->len += len;
return msgb->data;
}
static inline void msgb_push_u8(struct msgb *msg, uint8_t word)
{
uint8_t *space = msgb_push(msg, 1);
space[0] = word;
}
static inline void msgb_push_u16(struct msgb *msg, uint16_t word)
{
uint16_t *space = (uint16_t *) msgb_push(msg, 2);
osmo_store16be(word, space);
}
static inline void msgb_push_u32(struct msgb *msg, uint32_t word)
{
uint32_t *space = (uint32_t *) msgb_push(msg, 4);
osmo_store32be(word, space);
}
static inline unsigned char *msgb_push_tl(struct msgb *msgb, uint8_t tag)
{
uint8_t *data = msgb_push(msgb, 2);
data[0] = tag;
data[1] = msgb->len - 2;
return data;
}
static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
{
if (OSMO_UNLIKELY(msgb_length(msgb) < len))
MSGB_ABORT(msgb, "msgb too small to pull %u (len %u)\n",
len, msgb_length(msgb));
msgb->len -= len;
return msgb->data += len;
}
static inline unsigned char *msgb_pull_to_l3(struct msgb *msg)
{
unsigned char *ret = msgb_pull(msg, msg->l3h - msg->data);
msg->l1h = msg->l2h = NULL;
return ret;
}
static inline unsigned char *msgb_pull_to_l2(struct msgb *msg)
{
unsigned char *ret = msgb_pull(msg, msg->l2h - msg->data);
msg->l1h = NULL;
return ret;
}
static inline uint8_t msgb_pull_u8(struct msgb *msgb)
{
uint8_t *space = msgb_pull(msgb, 1) - 1;
return space[0];
}
static inline uint16_t msgb_pull_u16(struct msgb *msgb)
{
uint8_t *space = msgb_pull(msgb, 2) - 2;
return osmo_load16be(space);
}
static inline uint32_t msgb_pull_u32(struct msgb *msgb)
{
uint8_t *space = msgb_pull(msgb, 4) - 4;
return osmo_load32be(space);
}
static inline void msgb_reserve(struct msgb *msg, int len)
{
msg->data += len;
msg->tail += len;
}
static inline int msgb_trim(struct msgb *msg, int len)
{
if (OSMO_UNLIKELY(len < 0))
MSGB_ABORT(msg, "Negative length is not allowed\n");
if (OSMO_UNLIKELY(len > msg->data_len))
return -1;
msg->len = len;
msg->tail = msg->data + len;
return 0;
}
static inline int msgb_l3trim(struct msgb *msg, int l3len)
{
return msgb_trim(msg, (msg->l3h - msg->data) + l3len);
}
static inline struct msgb *msgb_alloc_headroom_c(const void *ctx, uint16_t size, uint16_t headroom,
const char *name)
{
OSMO_ASSERT(size >= headroom);
struct msgb *msg = msgb_alloc_c(ctx, size, name);
if (OSMO_LIKELY(msg))
msgb_reserve(msg, headroom);
return msg;
}
static inline struct msgb *msgb_alloc_headroom(uint16_t size, uint16_t headroom,
const char *name)
{
OSMO_ASSERT(size >= headroom);
struct msgb *msg = msgb_alloc(size, name);
if (OSMO_LIKELY(msg))
msgb_reserve(msg, headroom);
return msg;
}
static inline int msgb_test_invariant(const struct msgb *msg)
{
const unsigned char *lbound;
if (!msg || !msg->data || !msg->tail ||
(msg->data + msg->len != msg->tail) ||
(msg->data < msg->head) ||
(msg->tail > msg->head + msg->data_len))
return 0;
lbound = msg->head;
if (msg->l1h) {
if (msg->l1h < lbound)
return 0;
lbound = msg->l1h;
}
if (msg->l2h) {
if (msg->l2h < lbound)
return 0;
lbound = msg->l2h;
}
if (msg->l3h) {
if (msg->l3h < lbound)
return 0;
lbound = msg->l3h;
}
if (msg->l4h) {
if (msg->l4h < lbound)
return 0;
lbound = msg->l4h;
}
return lbound <= msg->head + msg->data_len;
}
/* msgb data comparison helpers */
#define msgb_eq_data(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, false)
#define msgb_eq_l1_data(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, false)
#define msgb_eq_l2_data(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, false)
#define msgb_eq_l3_data(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, false)
#define msgb_eq_l4_data(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, false)
/* msgb test/debug helpers */
#define msgb_eq_data_print(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 0, msg, data, len, true)
#define msgb_eq_l1_data_print(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 1, msg, data, len, true)
#define msgb_eq_l2_data_print(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 2, msg, data, len, true)
#define msgb_eq_l3_data_print(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 3, msg, data, len, true)
#define msgb_eq_l4_data_print(msg, data, len) \
_msgb_eq(__FILE__, __LINE__, __func__, 4, msg, data, len, true)
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);
/* msgb data comparison */
#define msgb_eq(msg1, msg2) msgb_eq_data(msg1, msgb_data(msg2), msgb_length(msg2))
#define msgb_eq_l1(msg1, msg2) msgb_eq_l1_data(msg1, msgb_l1(msg2), msgb_l1len(msg2))
#define msgb_eq_l2(msg1, msg2) msgb_eq_l2_data(msg1, msgb_l2(msg2), msgb_l2len(msg2))
#define msgb_eq_l3(msg1, msg2) msgb_eq_l3_data(msg1, msgb_l3(msg2), msgb_l3len(msg2))
#define msgb_eq_l4(msg1, msg2) msgb_eq_l4_data(msg1, msgb_l4(msg2), msgb_l4len(msg2))
/* non inline functions to ease binding */
uint8_t *msgb_data(const struct msgb *msg);
void *msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size);
void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use msgb_talloc_ctx_init() instead");
int msgb_printf(struct msgb *msgb, const char *format, ...);
static inline const char *msgb_hexdump_l1(const struct msgb *msg)
{
if (!msgb_l1(msg) || !(msgb_l1len(msg)))
return "[]";
return osmo_hexdump((const unsigned char *) msgb_l1(msg), msgb_l1len(msg));
}
static inline const char *msgb_hexdump_l2(const struct msgb *msg)
{
if (!msgb_l2(msg) || !(msgb_l2len(msg)))
return "[]";
return osmo_hexdump((const unsigned char *) msgb_l2(msg), msgb_l2len(msg));
}
static inline const char *msgb_hexdump_l3(const struct msgb *msg)
{
if (!msgb_l3(msg) || !(msgb_l3len(msg)))
return "[]";
return osmo_hexdump((const unsigned char*) msgb_l3(msg), msgb_l3len(msg));
}
static inline const char *msgb_hexdump_l4(const struct msgb *msg)
{
if (!msgb_l4(msg) || !(msgb_l4len(msg)))
return "[]";
return osmo_hexdump((const unsigned char*) msgb_l4(msg), msgb_l4len(msg));
}
osmo_store16be
static void osmo_store16be(uint16_t x, void *p)
store unaligned 16-bit integer (big-endian encoding)
Definition bit16gen.h:121
osmo_load16be
static uint16_t osmo_load16be(const void *p)
load unaligned 16-bit integer (big-endian encoding)
Definition bit16gen.h:108
osmo_store32be
static void osmo_store32be(uint32_t x, void *p)
store unaligned 32-bit integer (big-endian encoding)
Definition bit32gen.h:121
osmo_load32be
static uint32_t osmo_load32be(const void *p)
load unaligned 32-bit integer (big-endian encoding)
Definition bit32gen.h:108
bits.h
Osmocom bit level support code.
defs.h
General definitions that are meant to be included from header files.
file
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
__attribute__
enum gsm0808_assignment_requirement __attribute__
Definition log2.h:61
msgb_pull
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:404
msgb_length
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition msgb.c:285
msgb_pull_u8
static uint8_t msgb_pull_u8(struct msgb *msgb)
remove uint8 from front of message
Definition msgb.h:447
msgb_tailroom
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition msgb.h:211
msgb_set_talloc_ctx
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:294
msgb_l4len
static unsigned int msgb_l4len(const struct msgb *msgb)
determine length of L4 message
Definition msgb.h:186
msgb_alloc
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer from tall_msgb_ctx.
Definition msgb.c:108
msgb_put_u32
static void msgb_put_u32(struct msgb *msgb, uint32_t word)
append a uint32 value to the end of the message
Definition msgb.h:279
msgb_pull_u16
static uint16_t msgb_pull_u16(struct msgb *msgb)
remove uint16 from front of message
Definition msgb.h:457
msgb_pull_to_l2
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:436
msgb_get_u32
static uint32_t msgb_get_u32(struct msgb *msgb)
remove uint32 from end of message
Definition msgb.h:323
msgb_copy_c
struct msgb * msgb_copy_c(const void *ctx, const struct msgb *msg, const char *name)
Copy an msgb.
Definition msgb.c:383
msgb_alloc_headroom
static struct msgb * msgb_alloc_headroom(uint16_t size, uint16_t headroom, const char *name)
Allocate message buffer with specified headroom.
Definition msgb.h:551
msgb_test_invariant
static int msgb_test_invariant(const struct msgb *msg) __attribute__((pure))
Check a message buffer for consistency.
Definition msgb.h:566
msgb_hexdump_l3
static const char * msgb_hexdump_l3(const struct msgb *msg)
Definition msgb.h:762
msgb_l3len
static unsigned int msgb_l3len(const struct msgb *msgb)
determine length of L3 message
Definition msgb.h:173
msgb_hexdump_c
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:553
msgb_reset
void msgb_reset(struct msgb *m)
Re-set all message buffer pointers.
Definition msgb.c:164
msgb_push_u8
static void msgb_push_u8(struct msgb *msg, uint8_t word)
prepend a uint8 value to the head of the message
Definition msgb.h:360
msgb_hexdump_l4
static const char * msgb_hexdump_l4(const struct msgb *msg)
Definition msgb.h:769
msgb_l1
#define msgb_l1(m)
obtain L1 header of msgb
Definition msgb.h:130
msgb_copy
struct msgb * msgb_copy(const struct msgb *msg, const char *name)
Copy an msgb.
Definition msgb.c:396
msgb_push_tl
static unsigned char * msgb_push_tl(struct msgb *msgb, uint8_t tag)
Definition msgb.h:386
msgb_l2len
static unsigned int msgb_l2len(const struct msgb *msgb)
determine length of L2 message
Definition msgb.h:160
msgb_talloc_ctx_init
void * msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size)
Initialize a msgb talloc context for msgb_alloc.
Definition msgb.c:307
msgb_push_u16
static void msgb_push_u16(struct msgb *msg, uint16_t word)
prepend a uint16 value to the head of the message
Definition msgb.h:370
msgb_pull_u32
static uint32_t msgb_pull_u32(struct msgb *msgb)
remove uint32 from front of message
Definition msgb.h:467
msgb_l1len
static unsigned int msgb_l1len(const struct msgb *msgb)
determine length of L1 message
Definition msgb.h:147
msgb_hexdump_l1
static const char * msgb_hexdump_l1(const struct msgb *msg)
Definition msgb.h:748
msgb_put
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition msgb.h:240
_msgb_eq
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:202
msgb_l4
#define msgb_l4(m)
obtain L4 header of msgb
Definition msgb.h:136
msgb_printf
int msgb_printf(struct msgb *msgb, const char *format,...)
Print a string to the end of message buffer.
Definition msgb.c:579
msgb_put_u16
static void msgb_put_u16(struct msgb *msgb, uint16_t word)
append a uint16 value to the end of the message
Definition msgb.h:269
msgb_dequeue_count
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:111
msgb_hexdump_buf
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:461
msgb_hexdump
const char * msgb_hexdump(const struct msgb *msg)
Return a (static) buffer containing a hexdump of the msg.
Definition msgb.c:542
msgb_alloc_headroom_c
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:529
msgb_data
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition msgb.c:184
msgb_queue_free
static void msgb_queue_free(struct llist_head *queue)
Free all msgbs from a queue built with msgb_enqueue().
Definition msgb.h:80
msgb_trim
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition msgb.h:495
msgb_get_u8
static uint8_t msgb_get_u8(struct msgb *msgb)
remove uint8 from end of message
Definition msgb.h:303
msgb_pull_to_l3
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:421
msgb_push_u32
static void msgb_push_u32(struct msgb *msg, uint32_t word)
prepend a uint32 value to the head of the message
Definition msgb.h:380
msgb_resize_area
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:414
msgb_copy_resize_c
struct msgb * msgb_copy_resize_c(const void *ctx, const struct msgb *msg, uint16_t new_len, const char *name)
Copy an msgb with memory reallocation.
Definition msgb.c:326
msgb_put_u8
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition msgb.h:259
msgb_alloc_c
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:73
msgb_enqueue
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition msgb.c:129
msgb_get
static unsigned char * msgb_get(struct msgb *msgb, unsigned int len)
remove data from end of message
Definition msgb.h:289
msgb_get_u16
static uint16_t msgb_get_u16(struct msgb *msgb)
remove uint16 from end of message
Definition msgb.h:313
msgb_enqueue_count
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:95
msgb_reserve
static void msgb_reserve(struct msgb *msg, int len)
Increase headroom of empty msgb, reducing the tailroom.
Definition msgb.h:484
msgb_l3
#define msgb_l3(m)
obtain L3 header of msgb
Definition msgb.h:134
msgb_l3trim
static int msgb_l3trim(struct msgb *msg, int l3len)
Trim the msgb to a given layer3 length.
Definition msgb.h:513
msgb_dequeue
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition msgb.c:141
msgb_free
void msgb_free(struct msgb *m)
Release given message buffer.
Definition msgb.c:117
msgb_copy_resize
struct msgb * msgb_copy_resize(const struct msgb *msg, uint16_t new_len, const char *name)
Copy an msgb with memory reallocation.
Definition msgb.c:369
msgb_headlen
static unsigned int msgb_headlen(const struct msgb *msgb)
determine the length of the header
Definition msgb.h:199
msgb_hexdump_l2
static const char * msgb_hexdump_l2(const struct msgb *msg)
Definition msgb.h:755
msgb_l2
#define msgb_l2(m)
obtain L2 header of msgb
Definition msgb.h:132
MSGB_ABORT
#define MSGB_ABORT(msg, fmt, args ...)
Definition msgb.h:122
msgb_push
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition msgb.h:341
msgb_headroom
static int msgb_headroom(const struct msgb *msgb)
determine the amount of headroom in msgb
Definition msgb.h:223
OSMO_UNLIKELY
#define OSMO_UNLIKELY(exp)
Definition utils.h:47
OSMO_ASSERT
#define OSMO_ASSERT(exp)
Helper macro to terminate when an assertion fails.
Definition utils.h:113
OSMO_LIKELY
#define OSMO_LIKELY(exp)
Branch prediction optimizations.
Definition utils.h:46
OSMO_DEPRECATED
#define OSMO_DEPRECATED(text)
Set the deprecated attribute with a message.
Definition defs.h:41
osmo_hexdump
char * osmo_hexdump(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition utils.c:402
data
uint8_t data[0]
len
uint8_t len
msg
uint8_t msg[0]
level
uint8_t level
logging level
Definition gsmtap.h:6
name
char name[32]
source file name
Definition gsmtap.h:11
linuxlist.h
Simple doubly linked list implementation.
panic.h
llist_head
(double) linked list header structure
Definition linuxlist.h:46
msgb
Osmocom message buffer.
Definition msgb.h:31
msgb::cb
unsigned long cb[5]
control buffer
Definition msgb.h:48
msgb::l2h
unsigned char * l2h
pointer to A-bis layer 2 header: OML, RSL(RLL), NS
Definition msgb.h:44
msgb::len
uint16_t len
length of bytes used in msgb
Definition msgb.h:51
msgb::data
unsigned char * data
start of message in buffer
Definition msgb.h:55
msgb::dst
void * dst
reference of origin/destination
Definition msgb.h:38
msgb::lchan
struct gsm_lchan * lchan
logical channel
Definition msgb.h:41
msgb::_data
unsigned char _data[0]
optional immediate data array
Definition msgb.h:56
msgb::l3h
unsigned char * l3h
pointer to Layer 3 header.
Definition msgb.h:45
msgb::tail
unsigned char * tail
end of message in buffer
Definition msgb.h:54
msgb::trx
struct gsm_bts_trx * trx
Definition msgb.h:39
msgb::l4h
unsigned char * l4h
pointer to layer 4 header
Definition msgb.h:46
msgb::data_len
uint16_t data_len
length of underlying data array
Definition msgb.h:50
msgb::list
struct llist_head list
linked list header
Definition msgb.h:32
msgb::head
unsigned char * head
start of underlying memory buffer
Definition msgb.h:53
msgb::l1h
unsigned char * l1h
pointer to Layer1 header (if any)
Definition msgb.h:43
utils.h