mbuf

package
v0.1.1-r1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNullData = errors.New("NULL response returned")

ErrNullData is returned if NULL is returned by Cgo call.

Functions

func PktMbufAllocBulk

func PktMbufAllocBulk(p *mempool.Mempool, ms []*Mbuf) error

PktMbufAllocBulk allocate a bulk of mbufs.

func PktMbufFreeBulk

func PktMbufFreeBulk(ms []*Mbuf)

PktMbufReset frees a bulk of packet mbufs back into their original mempools.

func PktMbufPrivSize

func PktMbufPrivSize(p *mempool.Mempool) int

PktMbufPrivSize get the application private size of mbufs stored in a pktmbuf_pool. The private size of mbuf is a zone located between the rte_mbuf structure and the data buffer where an application can store data associated to a packet.

Types

type Mbuf

type Mbuf C.struct_rte_mbuf

Mbuf contains a packet.

func AllocResetAndAppend

func AllocResetAndAppend(p *mempool.Mempool, data *common.CStruct) *Mbuf

AllocResetAndAppend allocates an uninitialized mbuf from mempool p, resets the fields of the mbuf to default values and appends the given data to an mbuf.

Note that NULL may be returned if allocation failed or if there is not enough tailroom space in the last segment of mbuf. p is the mempool from which the mbuf is allocated. Data is C array representation of data to add.

func PktMbufAlloc

func PktMbufAlloc(p *mempool.Mempool) *Mbuf

PktMbufAlloc allocate an uninitialized mbuf from mempool p. Note that NULL may be returned if allocation failed.

func (*Mbuf) BufLen

func (m *Mbuf) BufLen() uint16

BufLen represents DataRoomSize that was initialized in mempool.CreateMbufPool.

NOTE: Max available data length that mbuf can hold is BufLen - HeadRoomSize.

func (*Mbuf) Data

func (m *Mbuf) Data() []byte

Data returns contained packet.

func (*Mbuf) HashRss

func (m *Mbuf) HashRss() uint32

HashRss returns hash.rss field of an mbuf.

func (*Mbuf) HeadRoomSize

func (m *Mbuf) HeadRoomSize() uint16

HeadRoomSize returns the value of the data_off field, which must be equal to the size of the headroom in concrete mbuf.

func (*Mbuf) Mempool

func (m *Mbuf) Mempool() *mempool.Mempool

Mempool return a pool from which mbuf was allocated.

func (*Mbuf) Next

func (m *Mbuf) Next() *Mbuf

Next returns next segment of scattered packet.

func (*Mbuf) PktLen

func (m *Mbuf) PktLen() uint32

PktLen returns total packet length: sum of all segments.

func (*Mbuf) PktMbufAppend

func (m *Mbuf) PktMbufAppend(data []byte) error

PktMbufAppend append the given data to an mbuf. Error may be returned if there is not enough tailroom space in the last segment of mbuf.

func (*Mbuf) PktMbufClone

func (m *Mbuf) PktMbufClone(p *mempool.Mempool) *Mbuf

PktMbufClone clones the mbuf using supplied mempool as the buffer source. NOTE: NULL may return if allocation fails.

func (*Mbuf) PktMbufFree

func (m *Mbuf) PktMbufFree()

PktMbufFree returns this mbuf into its originating mempool along with all its segments.

func (*Mbuf) PktMbufHeadRoomSize

func (m *Mbuf) PktMbufHeadRoomSize() uint16

PktMbufHeadRoomSize represents RTE_PKTMBUF_HEADROOM size in concrete mbuf.

NOTE: This implies Cgo call and is used for testing purposes only. Use HeadRoomSize instead.

func (*Mbuf) PktMbufReset

func (m *Mbuf) PktMbufReset()

PktMbufReset reset the fields of a packet mbuf to their default values.

func (*Mbuf) PktMbufTailRoomSize

func (m *Mbuf) PktMbufTailRoomSize() uint16

PktMbufTailRoomSize represents RTE_PKTMBUF_TAILROOM which is available length that can be appended to mbuf.

NOTE: This implies Cgo call and is used for testing purposes only. Use TailRoomSize instead.

func (*Mbuf) PrivData

func (m *Mbuf) PrivData(ptr *common.CStruct)

PrivData sets ptr to point to mbuf's private area. Private data length is set to the priv_size field of an mbuf itself. Although this length may be 0 the private area may still be usable as HeadRoomSize is not 0.

Feel free to edit the contents. A pointer to the headroom will be returned if the length of the private zone is 0.

func (*Mbuf) PrivSize

func (m *Mbuf) PrivSize() uint16

PrivSize return a size of private data area.

func (*Mbuf) RawFree

func (m *Mbuf) RawFree()

RawFree returns this mbuf into its originating mempool.

func (*Mbuf) RefCntRead

func (m *Mbuf) RefCntRead() uint16

RefCntRead reads the value of an mbuf's refcnt.

func (*Mbuf) RefCntSet

func (m *Mbuf) RefCntSet(v uint16)

RefCntSet sets an mbuf's refcnt to the defined value.

func (*Mbuf) RefCntUpdate

func (m *Mbuf) RefCntUpdate(v int16) uint16

RefCntUpdate adds given value to an mbuf's refcnt and returns its new value.

func (*Mbuf) ResetAndAppend

func (m *Mbuf) ResetAndAppend(data *common.CStruct) error

ResetAndAppend reset the fields of a mbuf to their default values and append the given data to an mbuf. Error may be returned if there is not enough tailroom space in the last segment of mbuf. Len is the amount of data to append (in bytes).

func (*Mbuf) TailRoomSize

func (m *Mbuf) TailRoomSize() uint16

TailRoomSize returns available length that can be appended to mbuf.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL