23 #include <osmocom/core/linuxlist.h> 50 struct gsm_bts_trx *trx;
80 #define MSGB_ABORT(msg, fmt, args ...) do { \ 81 osmo_panic("msgb(%p): " fmt, msg, ## args); \ 84 #define MSGB_ABORT(msg, fmt, args ...) 88 #define msgb_l1(m) ((void *)(m->l1h)) 90 #define msgb_l2(m) ((void *)(m->l2h)) 92 #define msgb_l3(m) ((void *)(m->l3h)) 94 #define msgb_sms(m) ((void *)(m->l4h)) 182 unsigned char *tmp = msgb->
tail;
184 MSGB_ABORT(msgb,
"Not enough tailroom msgb_push (%u < %u)\n",
198 space[0] = word & 0xFF;
208 osmo_store16be(word, space);
218 osmo_store32be(word, space);
227 unsigned char *tmp = msgb->
tail -
len;
229 MSGB_ABORT(msgb,
"msgb too small to get %u (len %u)\n",
253 return osmo_load16be(space);
263 return osmo_load32be(space);
281 MSGB_ABORT(msgb,
"Not enough headroom msgb_push (%u < %u)\n",
314 msg->
l1h = msg->
l2h = NULL;
335 return osmo_load16be(space);
345 return osmo_load32be(space);
404 osmo_static_assert(size > headroom, headroom_bigger);
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:180
static uint16_t msgb_pull_u16(struct msgb *msgb)
remove uint16 from front of message
Definition: msgb.h:332
static unsigned int msgb_l3len(const struct msgb *msgb)
determine length of L3 message
Definition: msgb.h:127
unsigned long cb[5]
control buffer
Definition: msgb.h:59
unsigned char * l3h
pointer to Layer 3 header. For OML: FOM; RSL: 04.08; GPRS: BSSGP
Definition: msgb.h:56
#define msgb_l3(m)
obtain L3 header of msgb
Definition: msgb.h:92
#define msgb_l1(m)
obtain L1 header of msgb
Definition: msgb.h:88
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer.
Definition: msgb.c:47
unsigned char * data
start of message in buffer
Definition: msgb.h:66
Osmocom message buffer.
Definition: msgb.h:42
void msgb_set_talloc_ctx(void *ctx)
Set the talloc context for msgb_alloc.
Definition: msgb.c:151
static int msgb_l3trim(struct msgb *msg, int l3len)
Trim the msgb to a given layer3 length.
Definition: msgb.h:386
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:370
uint16_t len
length of bytes used in msgb
Definition: msgb.h:62
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:311
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:70
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:151
unsigned char * l4h
pointer to layer 4 header
Definition: msgb.h:57
static unsigned int msgb_l1len(const struct msgb *msgb)
determine length of L1 message
Definition: msgb.h:103
static unsigned char * msgb_get(struct msgb *msgb, unsigned int len)
remove data from end of message
Definition: msgb.h:225
const char * msgb_hexdump(const struct msgb *msg)
Return a (static) buffer containing a hexdump of the msg.
Definition: msgb.c:160
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:94
static uint32_t msgb_pull_u32(struct msgb *msgb)
remove uint32 from front of message
Definition: msgb.h:342
static unsigned int msgb_l2len(const struct msgb *msgb)
determine length of L2 message
Definition: msgb.h:115
static struct msgb * msgb_alloc_headroom(int size, int headroom, const char *name)
Allocate message buffer with specified headroom.
Definition: msgb.h:401
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition: msgb.h:278
Definition: linuxlist.h:42
unsigned char * l1h
pointer to Layer1 header (if any)
Definition: msgb.h:54
static uint8_t msgb_pull_u8(struct msgb *msgb)
remove uint8 from front of message
Definition: msgb.h:322
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition: msgb.c:82
struct gsm_lchan * lchan
logical channel
Definition: msgb.h:52
void msgb_reset(struct msgb *m)
Re-set all message buffer pointers.
Definition: msgb.c:114
static void msgb_reserve(struct msgb *msg, int len)
Increase headroom of empty msgb, reducing the tailroom.
Definition: msgb.h:359
unsigned char * tail
end of message in buffer
Definition: msgb.h:65
static void msgb_put_u16(struct msgb *msgb, uint16_t word)
append a uint16 value to the end of the message
Definition: msgb.h:205
static uint8_t msgb_get_u8(struct msgb *msgb)
remove uint8 from end of message
Definition: msgb.h:240
unsigned char * l2h
pointer to A-bis layer 2 header: OML, RSL(RLL), NS
Definition: msgb.h:55
unsigned char * head
start of underlying memory buffer
Definition: msgb.h:64
static uint32_t msgb_get_u32(struct msgb *msgb)
remove uint32 from end of message
Definition: msgb.h:260
static int msgb_headroom(const struct msgb *msgb)
determine the amount of headroom in msgb
Definition: msgb.h:163
Osmocom bit level support code.
uint16_t data_len
length of underlying data array
Definition: msgb.h:61
unsigned char _data[0]
optional immediate data array
Definition: msgb.h:67
struct llist_head list
linked list header
Definition: msgb.h:43
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:134
#define msgb_l2(m)
obtain L2 header of msgb
Definition: msgb.h:90
static uint16_t msgb_get_u16(struct msgb *msgb)
remove uint16 from end of message
Definition: msgb.h:250
void * dst
reference of origin/destination
Definition: msgb.h:49
static unsigned int msgb_headlen(const struct msgb *msgb)
determine the length of the header
Definition: msgb.h:139
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:143
static void msgb_put_u32(struct msgb *msgb, uint32_t word)
append a uint32 value to the end of the message
Definition: msgb.h:215
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:297
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition: msgb.h:195