dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: sabu kurian <sabu2kurian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Richardson,
	Bruce" <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: "dev-VfR2kkLFssw@public.gmane.org" <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: Packet crafting....
Date: Fri, 14 Mar 2014 15:39:09 +0530	[thread overview]
Message-ID: <CAJ2bnfA8a3_uwiQD5ZxFT9pU-0cv0RB4qRdTfY3xZt_TbcgAfA@mail.gmail.com> (raw)
In-Reply-To: <59AF69C657FD0841A61C55336867B5B01A9C4436-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>

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:

> > 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
> > 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);
>

  parent reply	other threads:[~2014-03-14 10:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14  9:31 Packet crafting sabu kurian
     [not found] ` <CAJ2bnfDNNGkWW01TmHeWY370diEhCTPJb8aP+EKB5xB71tL3aA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-14  9:57   ` Richardson, Bruce
     [not found]     ` <59AF69C657FD0841A61C55336867B5B01A9C4436-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-03-14 10:09       ` sabu kurian [this message]
     [not found]         ` <CAJ2bnfA8a3_uwiQD5ZxFT9pU-0cv0RB4qRdTfY3xZt_TbcgAfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-14 11:08           ` Richardson, Bruce
     [not found]             ` <59AF69C657FD0841A61C55336867B5B01A9C452F-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-03-14 11:38               ` sabu kurian
     [not found]                 ` <CAJ2bnfBgJiGQ+VumJY6f6R8ecmvEnQ4D24TyiXWmBwQxR6jZJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-14 11:49                   ` Richardson, Bruce
     [not found]                     ` <59AF69C657FD0841A61C55336867B5B01A9C4588-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-03-14 12:04                       ` sabu kurian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ2bnfA8a3_uwiQD5ZxFT9pU-0cv0RB4qRdTfY3xZt_TbcgAfA@mail.gmail.com \
    --to=sabu2kurian-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).