Hi,

I have a situation where one of my plugins needs to construct an l2
packet (containing an ip datagram inside).
So I have a local buffer which contains the following bytes laid out --
dst mac
src mac
ethertype
ip header + payload

Assume for the sake of generality that the above buffer is 4K bytes
(because I have an ip payload of that much size)
Assume further that I magically already know the sw if indices of the RX and TX.
It is also ensured that the l2 paylod size is lesser than or equal to
the MTU of the TX interface

Now once I have all of the above information, I need to create a
vlib_buffer_t (possibly a chained set)
So I need some guidelines/best practices of how to go about it
flawlessly so that once the vlib_buffer_t is constructed, I can simply
send it to the "interface-output" and accomplish the act of
transmission.

The high level set of things that I can think of is --

1. Allocate a vlib_buffer_t (or a chained flavour of those)
2. Start appending data to those buffers
3. What about the various control fields to be set in the above buffers ?
. I suppose I will have to do the following --
  vnet_buffer (b0)->sw_if_index[VLIB_RX] = <My known index>;
                vnet_buffer (b0)->sw_if_index[VLIB_TX] = <My known index>;
Do I need to do anything with b0->buffer_pool_index ?
What to do with b0->current_data ?
What to do with b0->flags ?
What to do with b->current_length ?
And if it is a chained set, what is to be done on individual
vlib_buffer_t of the chain and what on the first one of the chain ?

I suppose I need a convenience function like the following

vlib_buffer_t* foo(char* myl2packet, int lengthOfMyL2Packet, u32
mySwIfRxIndex, u32 mySwIfTxIndex)

The above should return to me a nice little vlib_buffer_t (possibly
chained) which I can then ship to interface output.
I am willing to write such a function by all means but want to find
out if anything like this (or closer) already exists.
If it doesn't exist, what idioms can I follow from the functions which
already exist and what I have to be careful about.

Regards
-Prashant
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11011): https://lists.fd.io/g/vpp-dev/message/11011
Mute This Topic: https://lists.fd.io/mt/27770677/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to