From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qc0-x236.google.com (mail-qc0-x236.google.com [IPv6:2607:f8b0:400d:c01::236]) by dpdk.org (Postfix) with ESMTP id 9381718F for ; Fri, 14 Mar 2014 11:07:39 +0100 (CET) Received: by mail-qc0-f182.google.com with SMTP id e16so2527829qcx.41 for ; Fri, 14 Mar 2014 03:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TaY+/YYh60nGM6gWCoZxaXvimkuL6C7K64nHs5I3Flc=; b=vjsmd7ujn8KQY7S09ZDvoi+E1zBmBkk/29hdcguPAmcamN6AfA28CfSAYmHxLMOWAH 3neUQhH+3H3Rts5t9TnDLWUOlV8QJ4vWE22f3279tBXRwR0ISS1uu+0SQNAoqtgdjh/O x1BxrkV1+b4olaNd3SoozkOhdi+FRKZvpXo+wiRd1OdQ7fLZdplusUhbG3ezjO116+r1 aUPKptAykK4KMgjwO/pecdhWkZujjcbqngFfU84hEGEegrO7+VAK7q9MM+y4axFrvE0j heyk7Qrav6v3gVr9R5qASN1QSeDaldPw76ZvnQjjTcGsNFLI3AKqch4Of4t4h7hQGD2F LyVw== MIME-Version: 1.0 X-Received: by 10.224.11.136 with SMTP id t8mr8671595qat.26.1394791749819; Fri, 14 Mar 2014 03:09:09 -0700 (PDT) Received: by 10.96.69.97 with HTTP; Fri, 14 Mar 2014 03:09:09 -0700 (PDT) In-Reply-To: <59AF69C657FD0841A61C55336867B5B01A9C4436@IRSMSX103.ger.corp.intel.com> References: <59AF69C657FD0841A61C55336867B5B01A9C4436@IRSMSX103.ger.corp.intel.com> Date: Fri, 14 Mar 2014 15:39:09 +0530 Message-ID: From: sabu kurian To: "Richardson, Bruce" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Packet crafting.... X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2014 10:07:40 -0000 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@intel.com> 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); >