Date: Thu, 26 Nov 2015 20:14:08 +0800 From: Hao Wu <wuhao.thu@gmail.com> To: ulric@siag.nu Cc: net@freebsd.org, owner-freebsd-net@freebsd.org Subject: Re: Can I send the Ethernet frames with particular payload via Netmap? Message-ID: <CAHmvmjHyOKiTt6Q60tqt7gbDnDuBPa27wGHCPtOSV_gr_OtuHA@mail.gmail.com> In-Reply-To: <9b7b2eb25fd42295d3f2f8a46d2a3c1e@siag.nu> References: <CAHmvmjGQzAUGf=UGQHXx0C8TPLAOa8G6ySD60BjbxhjGRgZM7Q@mail.gmail.com> <9b7b2eb25fd42295d3f2f8a46d2a3c1e@siag.nu>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Ulric, Got it! Many thanks :) +++++++++++++++++ Best, Hao On Thu, Nov 26, 2015 at 6:25 PM, <ulric@siag.nu> wrote: > > > 2015-11-25 15:30 skrev Hao Wu: > >> Hi all, >> >> I just start using Netmap. I want to know can I build the Ethernet >> frames and send out via Netmap? I used to build the Ethernet frames via >> Libnet, but it is too slow. So I turn to Netmap now. But I have no idea on >> how to write the code using Netmap or what functions should I call? >> >> Any replay is highly appreciated! >> > > > It's crazy simple. To open a netmap descriptor: > > d = nm_open(ifname, NULL, 0, 0); > > To receive a frame: > > uint8_t *b = nm_nextpkt(d, &h); > > To send a frame: > > int n = nm_inject(d, b, len); > > Working example from Pen: > > https://github.com/UlricE/pen/blob/master/dsr.c > > Ulric >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHmvmjHyOKiTt6Q60tqt7gbDnDuBPa27wGHCPtOSV_gr_OtuHA>