sending arbitrary UDP packets from kernel module

Robert Watson rwatson at FreeBSD.org
Mon Dec 22 05:37:25 PST 2008


On Mon, 22 Dec 2008, Bruce Simpson wrote:

> Ferner Cilloniz wrote:
>
>> So i have done some research and reading and found that i need to call 
>> either udp_send or udp_output. Can anyone help me out with providing the 
>> proper arguments to these functions so i may call them and send arbitrary 
>> UDP packets from a kernel module?
>
> The NFS and BOOTP code would be the first place to look, it has a rather 
> shonky way of creating a socket in-kernel so that an INPCB will be created, 
> allowing you to send and receive UDP datagrams. Fire up KScope or similar 
> and look at how it does it.

I would encourage this approach, if the application model works with it, as it 
allows using the existing socket infrastruture to reserve the port/ip tuple 
and avoid conflicts with userspace, use existing buffering on the receive 
side, etc.

Robert N M Watson
Computer Laboratory
University of Cambridge


More information about the freebsd-net mailing list