libosmocore  0.9.3
Osmocom core library
msgb.h File Reference

Osmocom message buffers The Osmocom message buffers are modelled after the 'struct skb' inside the Linux kernel network stack. As they exist in userspace, they are much simplified. However, terminology such as headroom, tailroom, push/pull/put etc. remains the same. More...

#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/panic.h>

Go to the source code of this file.

Data Structures

struct  msgb
 Osmocom message buffer. More...

Macros

#define MSGB_DEBUG
#define MSGB_ABORT(msg, fmt, args...)
#define msgb_l1(m)   ((void *)(m->l1h))
 obtain L1 header of msgb
#define msgb_l2(m)   ((void *)(m->l2h))
 obtain L2 header of msgb
#define msgb_l3(m)   ((void *)(m->l3h))
 obtain L3 header of msgb
#define msgb_sms(m)   ((void *)(m->l4h))
 obtain SMS header of msgb

Functions

struct msgbmsgb_alloc (uint16_t size, const char *name)
 Allocate a new message buffer.
void msgb_free (struct msgb *m)
 Release given message buffer.
void msgb_enqueue (struct llist_head *queue, struct msgb *msg)
 Enqueue message buffer to tail of a queue.
struct msgbmsgb_dequeue (struct llist_head *queue)
 Dequeue message buffer from head of queue.
void msgb_reset (struct msgb *msg)
 Re-set all message buffer pointers.
uint16_t msgb_length (const struct msgb *msg)
 get length of message buffer
const char * msgb_hexdump (const struct msgb *msg)
 Return a (static) buffer containing a hexdump of the msg.
static unsigned int msgb_l1len (const struct msgb *msgb)
 determine length of L1 message
static unsigned int msgb_l2len (const struct msgb *msgb)
 determine length of L2 message
static unsigned int msgb_l3len (const struct msgb *msgb)
 determine length of L3 message
static unsigned int msgb_headlen (const struct msgb *msgb)
 determine the length of the header
static int msgb_tailroom (const struct msgb *msgb)
 determine how much tail room is left in msgb
static int msgb_headroom (const struct msgb *msgb)
 determine the amount of headroom in msgb
static unsigned char * msgb_put (struct msgb *msgb, unsigned int len)
 append data to end of message buffer
static void msgb_put_u8 (struct msgb *msgb, uint8_t word)
 append a uint8 value to the end of the message
static void msgb_put_u16 (struct msgb *msgb, uint16_t word)
 append a uint16 value to the end of the message
static void msgb_put_u32 (struct msgb *msgb, uint32_t word)
 append a uint32 value to the end of the message
static unsigned char * msgb_get (struct msgb *msgb, unsigned int len)
 remove data from end of message
static uint8_t msgb_get_u8 (struct msgb *msgb)
 remove uint8 from end of message
static uint16_t msgb_get_u16 (struct msgb *msgb)
 remove uint16 from end of message
static uint32_t msgb_get_u32 (struct msgb *msgb)
 remove uint32 from end of message
static unsigned char * msgb_push (struct msgb *msgb, unsigned int len)
 prepend (push) some data to start of message
static unsigned char * msgb_pull (struct msgb *msgb, unsigned int len)
 remove (pull) a header from the front of the message buffer
static unsigned char * msgb_pull_to_l3 (struct msgb *msg)
 remove (pull) all headers in front of l3h from the message buffer.
static uint8_t msgb_pull_u8 (struct msgb *msgb)
 remove uint8 from front of message
static uint16_t msgb_pull_u16 (struct msgb *msgb)
 remove uint16 from front of message
static uint32_t msgb_pull_u32 (struct msgb *msgb)
 remove uint32 from front of message
static void msgb_reserve (struct msgb *msg, int len)
 Increase headroom of empty msgb, reducing the tailroom.
static int msgb_trim (struct msgb *msg, int len)
 Trim the msgb to a given absolute length.
static int msgb_l3trim (struct msgb *msg, int l3len)
 Trim the msgb to a given layer3 length.
static struct msgbmsgb_alloc_headroom (int size, int headroom, const char *name)
 Allocate message buffer with specified headroom.
uint8_t * msgb_data (const struct msgb *msg)
 get pointer to data section of message buffer
void msgb_set_talloc_ctx (void *ctx)
 Set the talloc context for msgb_alloc.

Detailed Description

Osmocom message buffers The Osmocom message buffers are modelled after the 'struct skb' inside the Linux kernel network stack. As they exist in userspace, they are much simplified. However, terminology such as headroom, tailroom, push/pull/put etc. remains the same.