|
libosmocore 0.3.6
Osmocom core library
|
Data Structures | |
| struct | msgb |
| Osmocom message buffer. More... | |
Files | |
| file | msgb.h |
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. | |
| file | msgb.c |
Functions | |
| struct msgb * | msgb_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 msgb * | msgb_dequeue (struct llist_head *queue) |
| Dequeue message buffer from head of queue. | |
| void | msgb_reset (struct msgb *msg) |
| Re-set all message buffer pointers. | |
| 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 void | msgb_reserve (struct msgb *msg, int len) |
| Increase headroom of empty msgb, reducing the tailroom. | |
| static struct msgb * | msgb_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 | |
| uint16_t | msgb_length (const struct msgb *msg) |
| get length of message buffer | |
| void | msgb_set_talloc_ctx (void *ctx) |
| Set the talloc context for msgb_alloc. | |
Variables | |
| struct gsm_bts_trx * msgb::@5::trx | |
| union { | |
| void * dst | |
| reference of origin/destination | |
| struct gsm_bts_trx * trx | |
| }; | |
| struct gsm_lchan * | msgb::lchan |
| logical channel | |
| unsigned char * | msgb::l1h |
| pointer to Layer1 header (if any) | |
| unsigned char * | msgb::l2h |
| pointer to A-bis layer 2 header: OML, RSL(RLL), NS | |
| unsigned char * | msgb::l3h |
| pointer to Layer 3 header. For OML: FOM; RSL: 04.08; GPRS: BSSGP | |
| unsigned char * | msgb::l4h |
| pointer to layer 4 header | |
| unsigned long | msgb::cb [5] |
| control buffer | |
| uint16_t | msgb::data_len |
| length of underlying data array | |
| uint16_t | msgb::len |
| length of bytes used in msgb | |
| unsigned char * | msgb::head |
| start of underlying memory buffer | |
| unsigned char * | msgb::tail |
| end of message in buffer | |
| unsigned char * | msgb::data |
| start of message in buffer | |
| unsigned char | msgb::_data [0] |
| optional immediate data array | |
| void * | tall_msgb_ctx |
| struct msgb * msgb_alloc | ( | uint16_t | size, |
| const char * | name | ||
| ) | [read] |
Allocate a new message buffer.
| [in] | size | Length in octets, including headroom |
| [in] | name | Human-readable name to be associated with msgb |
This function allocates a 'struct msgb' as well as the underlying memory buffer for the actual message data (size specified by size) using the talloc memory context previously set by msgb_set_talloc_ctx
References _data, data, data_len, head, len, and tail.
Referenced by gsmtap_makemsg(), and msgb_alloc_headroom().
| static struct msgb* msgb_alloc_headroom | ( | int | size, |
| int | headroom, | ||
| const char * | name | ||
| ) | [static, read] |
Allocate message buffer with specified headroom.
| [in] | size | size in bytes, including headroom |
| [in] | headroom | headroom in bytes |
| [in] | name | human-readable name |
This function is a convenience wrapper around msgb_alloc followed by msgb_reserve in order to create a new Message buffers with user-specified amount of headroom.
References msgb_alloc(), and msgb_reserve().
| uint8_t * msgb_data | ( | const struct msgb * | msg | ) |
get pointer to data section of message buffer
| [in] | msg | message buffer |
References data.
| struct msgb * msgb_dequeue | ( | struct llist_head * | queue | ) | [read] |
Dequeue message buffer from head of queue.
| [in] | queue | linked list header of queue |
The function will remove the first message buffer from the queue implemented by 'ref llist_head queue.
Referenced by osmo_wqueue_bfd_cb(), and osmo_wqueue_clear().
| void msgb_enqueue | ( | struct llist_head * | queue, |
| struct msgb * | msg | ||
| ) |
Enqueue message buffer to tail of a queue.
| [in] | queue | linked list header of queue |
| [in] | msgb | message buffer to be added to the queue |
The function will append the specified message buffer msg to the queue implemented by llist_head queue
References list.
Referenced by osmo_wqueue_enqueue().
| void msgb_free | ( | struct msgb * | m | ) |
Release given message buffer.
| [in] | m | Message buffer to be free'd |
Referenced by gsmtap_sendmsg(), osmo_wqueue_bfd_cb(), and osmo_wqueue_clear().
| static unsigned char* msgb_get | ( | struct msgb * | msgb, |
| unsigned int | len | ||
| ) | [inline, static] |
remove data from end of message
| [in] | msgb | message buffer |
| [in] | len | number of bytes to remove from end |
Referenced by msgb_get_u16(), msgb_get_u32(), and msgb_get_u8().
| static uint16_t msgb_get_u16 | ( | struct msgb * | msgb | ) | [inline, static] |
remove uint16 from end of message
| [in] | msgb | message buffer |
References msgb_get().
| static uint32_t msgb_get_u32 | ( | struct msgb * | msgb | ) | [inline, static] |
remove uint32 from end of message
| [in] | msgb | message buffer |
References msgb_get().
| static uint8_t msgb_get_u8 | ( | struct msgb * | msgb | ) | [inline, static] |
remove uint8 from end of message
| [in] | msgb | message buffer |
References msgb_get().
| static unsigned int msgb_headlen | ( | const struct msgb * | msgb | ) | [inline, static] |
| static int msgb_headroom | ( | const struct msgb * | msgb | ) | [inline, static] |
determine the amount of headroom in msgb
| [in] | msgb | message buffer |
This function computes the amount of bytes left in the underlying data buffer before the start of the actual message.
Referenced by msgb_push().
| static unsigned int msgb_l1len | ( | const struct msgb * | msgb | ) | [inline, static] |
determine length of L1 message
| [in] | msgb | message buffer |
This function computes the number of bytes between the tail of the message and the layer 1 header.
References tail.
| static unsigned int msgb_l2len | ( | const struct msgb * | msgb | ) | [inline, static] |
determine length of L2 message
| [in] | msgb | message buffer |
This function computes the number of bytes between the tail of the message and the layer 2 header.
References tail.
| static unsigned int msgb_l3len | ( | const struct msgb * | msgb | ) | [inline, static] |
determine length of L3 message
| [in] | msgb | message buffer |
This function computes the number of bytes between the tail of the message and the layer 3 header.
References tail.
| uint16_t msgb_length | ( | const struct msgb * | msg | ) |
get length of message buffer
| [in] | msg | message buffer |
References len.
| static unsigned char* msgb_pull | ( | struct msgb * | msgb, |
| unsigned int | len | ||
| ) | [inline, static] |
remove (pull) a header from the front of the message buffer
| [in] | msgb | message buffer |
| [in] | len | number of octets to be pulled |
This function moves the data pointer of the Message buffers further back in the message, thereby shrinking the size of the message by len bytes.
| static unsigned char* msgb_push | ( | struct msgb * | msgb, |
| unsigned int | len | ||
| ) | [inline, static] |
prepend (push) some data to start of message
| [in] | msgb | message buffer |
| [in] | len | number of bytes to pre-pend |
This function moves the data pointer of the Message buffers further to the front (by len bytes), thereby enlarging the message by len bytes.
The return value is a pointer to the newly added section in the beginning of the message. It can be used to fill/copy data into it.
References data, len, and msgb_headroom().
| static unsigned char* msgb_put | ( | struct msgb * | msgb, |
| unsigned int | len | ||
| ) | [inline, static] |
append data to end of message buffer
| [in] | msgb | message buffer |
| [in] | len | number of bytes to append to message |
This function will move the tail pointer of the message buffer len bytes further, thus enlarging the message by len bytes.
The return value is a pointer to start of the newly added section at the end of the message and can be used for actually filling/copying data into it.
References len, msgb_tailroom(), and tail.
Referenced by gsmtap_makemsg(), msgb_put_u16(), msgb_put_u32(), and msgb_put_u8().
| static void msgb_put_u16 | ( | struct msgb * | msgb, |
| uint16_t | word | ||
| ) | [inline, static] |
append a uint16 value to the end of the message
| [in] | msgb | message buffer |
| [in] | word | unsigned 16bit byte to be appended |
References msgb_put().
| static void msgb_put_u32 | ( | struct msgb * | msgb, |
| uint32_t | word | ||
| ) | [inline, static] |
append a uint32 value to the end of the message
| [in] | msgb | message buffer |
| [in] | word | unsigned 32bit byte to be appended |
References msgb_put().
| static void msgb_put_u8 | ( | struct msgb * | msgb, |
| uint8_t | word | ||
| ) | [inline, static] |
append a uint8 value to the end of the message
| [in] | msgb | message buffer |
| [in] | word | unsigned 8bit byte to be appended |
References msgb_put().
| static void msgb_reserve | ( | struct msgb * | msg, |
| int | len | ||
| ) | [inline, static] |
Increase headroom of empty msgb, reducing the tailroom.
| [in] | msg | message buffer |
| [in] | len | amount of extra octets to be reserved as headroom |
This function reserves some memory at the beginning of the underlying data buffer. The idea is to reserve space in case further headers have to be pushed to the Message buffers during further processing.
Calling this function leads to undefined reusults if it is called on a non-empty Message buffers.
References data, len, and tail.
Referenced by msgb_alloc_headroom().
| void msgb_reset | ( | struct msgb * | msg | ) |
Re-set all message buffer pointers.
| [in] | m | message buffer that is to be resetted |
This will re-set the various internal pointers into the underlying message buffer, i.e. remvoe all headroom and treat the msgb as completely empty. It also initializes the control buffer to zero.
References _data, cb, data, head, l2h, l3h, l4h, lchan, len, and tail.
| void msgb_set_talloc_ctx | ( | void * | ctx | ) |
Set the talloc context for msgb_alloc.
| [in] | ctx | talloc context to be used as root for msgb allocations |
| static int msgb_tailroom | ( | const struct msgb * | msgb | ) | [inline, static] |
determine how much tail room is left in msgb
| [in] | msgb | message buffer |
This function computes the amount of octets left in the underlying data buffer after the end of the message.
References data_len, head, and tail.
Referenced by msgb_put().