Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Nov 2015 11:25:53 +0100
From:      ulric@siag.nu
To:        Hao Wu <wuhao.thu@gmail.com>
Cc:        net@freebsd.org, owner-freebsd-net@freebsd.org
Subject:   Re: Can I send the Ethernet frames with particular payload via Netmap?
Message-ID:  <9b7b2eb25fd42295d3f2f8a46d2a3c1e@siag.nu>
In-Reply-To: <CAHmvmjGQzAUGf=UGQHXx0C8TPLAOa8G6ySD60BjbxhjGRgZM7Q@mail.gmail.com>
References:  <CAHmvmjGQzAUGf=UGQHXx0C8TPLAOa8G6ySD60BjbxhjGRgZM7Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


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?9b7b2eb25fd42295d3f2f8a46d2a3c1e>