From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 8 19:22:50 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38F3F1065679 for ; Sat, 8 Mar 2008 19:22:50 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.freebsd.org (Postfix) with ESMTP id C35BB8FC2C for ; Sat, 8 Mar 2008 19:22:49 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from [192.168.2.100] ([172.21.151.1]) by smtp-1.dlr.de with Microsoft SMTPSVC(6.0.3790.1830); Sat, 8 Mar 2008 20:09:31 +0100 Message-ID: <47D2E469.9030507@dlr.de> Date: Sat, 08 Mar 2008 20:09:29 +0100 From: Hartmut Brandt Organization: German Aerospace Center User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Robert Watson References: <200803081133.02575.hselasky@c2i.net> <20080308171435.J88526@fledge.watson.org> In-Reply-To: <20080308171435.J88526@fledge.watson.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 08 Mar 2008 19:09:31.0137 (UTC) FILETIME=[F0244F10:01C8814F] Cc: freebsd-hackers@freebsd.org, Hans Petter Selasky Subject: Re: Documentation on writing a custom socket X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "harti@freebsd.org >> Hartmut Brandt" List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Mar 2008 19:22:50 -0000 Robert Watson wrote: > > On Sat, 8 Mar 2008, Hans Petter Selasky wrote: > >> I'm planning to create a new socket type in FreeBSD called AF_Q921, >> which is to be used for ISDN telephony. Where do I find documentation >> on how to implement a new socket in the kernel ? > [SNIP] > that isn't connected to the protocol stack, or by using a device stack > tied to Netgraph nodes. Could you tell us a bit more about what you're > trying to do, and perhaps we can provide some useful pointers? For I want to jump in here about the netgraph stuff (this was the second time a response talked about using netgraph). While developing the ATM signaling stack (this is Q.2931) it turned out, that the netgraph notion of sending message around very rapidly became a nightmare if you want correct error handling. The number of states in Q.2931 (12 states) and the API node exploded to something like 30 or 40 because of the asynchronuous nature of the communication between stack layers and error handling. One example: To setup a connection you invoke a SETUP request. Then you wait for something like CALL_PROCEEDING, RELEASE_ACK or CONNECT_ACK. Unfortunately you also want to return an error in the case something is wrong with the request itself (no memory, bad parameters). So you add an extra message that just ACKs that the SETUP is going to be handled by the stack or rejected because of some error in it. With a normal function call based interface you would just make the setup-request function return an error code. With netgraph however you need to invent a new message, have additional states in the consumer and the protocol. Not to talk about error handling when you want to correctly handle errors like not beeing able to allocate that same response message. Netgraph is very nice for data-flow oriented stuff. It is not so useful to stack complicated protocol layers. If I'd write the signaling stack from scratch, I'd probably collaps all the signalling into a single netgraph node with a socket interface on the upper end. But then one may as well just implement that as a 'normal' protocol, probably... harti