Thread (1 message) 1 message, 1 author, 2014-03-14

Re: Packet crafting....

From: sabu kurian <hidden>
Date: 2014-03-14 10:09:09

Thank you very much Richardson for your valuable reply. But is there
another way of doing it using the rte_pktmbuf_append / rte_pktmbuf_prepend ?
Can you please tell me on how to do that ?

Regards


On Fri, Mar 14, 2014 at 3:27 PM, Richardson, Bruce <
bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
quoted
Hello friends,

As of now... I know on how to create an ipv4 header using the 'struct
ipv4_hdr'.
My requirement is to craft a packet and sent it via 'rte_eth_tx_burst'.
I know that there should be an 'ether_hdr' created before, the packet
could
quoted
be sent.
Could someone help me on how to set the address fields and type in
'ether_hdr' and how to put the ipv4 header as the payload for ether_hdr.
You probably want to do something like this to craft a full packet. First
allocate an mbuf, then get it's data pointer as a ether_hdr structure, then
an ip_hdr beyond that and then any L4 headers, e.g. udp, beyond that. For
example, assuming mempool variable p:

    struct rte_mbuf *buf = rte_pktmbuf_alloc(p);
    struct ether_hdr *ehdr = rte_pktmbuf_mtod(buf, struct ether_hdr *);
/* set ether_hdr fields here e.g. */
    ehdr->ether_type = rte_bswap16(ETHER_TYPE_IPv4);
    struct ipv4_hdr *iphdr = (struct ipv4_hdr *)(&ehdr[1]);
/* set ipv4 header fields here */
    struct udp_hdr *uhdr = (struct udp_hdr *)(&iphdr[1]);
/* set udp header fields here, e.g. */
    uhdr->src_port = rte_bswap16(0x5000);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help