From owner-freebsd-net@FreeBSD.ORG Tue Dec 30 18:46:46 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 DBFBA1065717 for ; Tue, 30 Dec 2008 18:46:46 +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 B2FA98FC36 for ; Tue, 30 Dec 2008 18:46:46 +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 2A57A46B29; Tue, 30 Dec 2008 13:46:46 -0500 (EST) Date: Tue, 30 Dec 2008 18:46:46 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Max Laier In-Reply-To: <200812301905.57164.max@love2party.net> Message-ID: References: <1230637795.4966.20.camel@mobiliare.Belkin> <200812301905.57164.max@love2party.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org, Ferner Cilloniz Subject: Re: kernel network 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: Tue, 30 Dec 2008 18:46:47 -0000 On Tue, 30 Dec 2008, Max Laier wrote: > On Tuesday 30 December 2008 12:49:55 Ferner Cilloniz wrote: > >> I do not think I could ever be more tired of this topic but I cannot seem >> to understand what to do. I have tried more about a month now to send >> arbitrary UDP packets from a kernel module but cannot achieve it. I have >> looked at udp_send but found that building a socket* was much to tedious. >> Later i looked at in-kernel webservers (http://openketa.sourceforge.net/) >> but could not find anything useful. >> >> Netgraph is a possibility, but there isn't any documentation on accessing >> the network from kernel space. >> >> What do you all suggest? > > $ man 9 socket Definitely the preferred solution, if it meets the application model. Call socreate(9) to allocate the socket, sobind(9) if required, calls to sosend(9) to generate packets, and soclose(9) when done. Direct calls to the udp_output() and udp_send() functions won't work without a socket context, and doing sosend(9) will isolate in-kernel consumers from future changes in UDP internals. ip_output() could be invoked directly to generate IP packets, but won't allow you to easily receive replies, etc. Robert N M Watson Computer Laboratory University of Cambridge