From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id CCA5E18F for ; Fri, 14 Mar 2014 10:57:02 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 14 Mar 2014 02:54:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,653,1389772800"; d="scan'208";a="499760995" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by orsmga002.jf.intel.com with ESMTP; 14 Mar 2014 02:58:28 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.27]) by IRSMSX101.ger.corp.intel.com ([163.33.3.153]) with mapi id 14.03.0123.003; Fri, 14 Mar 2014 09:57:10 +0000 From: "Richardson, Bruce" To: sabu kurian , "dev@dpdk.org" Thread-Topic: [dpdk-dev] Packet crafting.... Thread-Index: AQHPP2hUbAIFcBny4k6YxtDmOL10iJrgVz8w Date: Fri, 14 Mar 2014 09:57:09 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B01A9C4436@IRSMSX103.ger.corp.intel.com> References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 09:57:04 -0000 > Hello friends, >=20 > 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 cou= ld > 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. >=20 You probably want to do something like this to craft a full packet. First a= llocate 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 e= xample, assuming mempool variable p: struct rte_mbuf *buf =3D rte_pktmbuf_alloc(p); struct ether_hdr *ehdr =3D rte_pktmbuf_mtod(buf, struct ether_hdr *); /* set ether_hdr fields here e.g. */ ehdr->ether_type =3D rte_bswap16(ETHER_TYPE_IPv4); struct ipv4_hdr *iphdr =3D (struct ipv4_hdr *)(&ehdr[1]); /* set ipv4 header fields here */ struct udp_hdr *uhdr =3D (struct udp_hdr *)(&iphdr[1]); /* set udp header fields here, e.g. */ uhdr->src_port =3D rte_bswap16(0x5000);