From owner-freebsd-net@FreeBSD.ORG Mon Dec 22 13:37:25 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2CC131065673 for ; Mon, 22 Dec 2008 13:37:25 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 08C638FC17 for ; Mon, 22 Dec 2008 13:37:25 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTP id 85D6346B46; Mon, 22 Dec 2008 08:37:24 -0500 (EST) Date: Mon, 22 Dec 2008 13:37:24 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Bruce Simpson In-Reply-To: <494EE7D9.5060000@incunabulum.net> Message-ID: References: <1229738406.5614.17.camel@mobiliare.Belkin> <494EE7D9.5060000@incunabulum.net> User-Agent: Alpine 1.10 (BSF 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org, Ferner Cilloniz Subject: Re: sending arbitrary UDP packets from kernel module X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Dec 2008 13:37:25 -0000 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