From owner-freebsd-hackers@FreeBSD.ORG  Sat Mar  8 17:19:42 2008
Return-Path: <owner-freebsd-hackers@FreeBSD.ORG>
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 22D74106566B
	for <freebsd-hackers@freebsd.org>; Sat,  8 Mar 2008 17:19:42 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42])
	by mx1.freebsd.org (Postfix) with ESMTP id F05DC8FC1B
	for <freebsd-hackers@freebsd.org>; Sat,  8 Mar 2008 17:19:41 +0000 (UTC)
	(envelope-from rwatson@FreeBSD.org)
Received: from fledge.watson.org (fledge.watson.org [209.31.154.41])
	by cyrus.watson.org (Postfix) with ESMTP id 9167246C21;
	Sat,  8 Mar 2008 12:19:41 -0500 (EST)
Date: Sat, 8 Mar 2008 17:19:41 +0000 (GMT)
From: Robert Watson <rwatson@FreeBSD.org>
X-X-Sender: robert@fledge.watson.org
To: Hans Petter Selasky <hselasky@c2i.net>
In-Reply-To: <200803081133.02575.hselasky@c2i.net>
Message-ID: <20080308171435.J88526@fledge.watson.org>
References: <200803081133.02575.hselasky@c2i.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: freebsd-hackers@freebsd.org
Subject: Re: Documentation on writing a custom socket
X-BeenThere: freebsd-hackers@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Technical Discussions relating to FreeBSD
	<freebsd-hackers.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-hackers>, 
	<mailto:freebsd-hackers-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-hackers>
List-Post: <mailto:freebsd-hackers@freebsd.org>
List-Help: <mailto:freebsd-hackers-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-hackers>,
	<mailto:freebsd-hackers-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 08 Mar 2008 17:19:42 -0000


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 ?

I'd start with a copy of the Design and Implementation of FreeBSD, which 
contains a structural overview of how the protocol parts fit together.  The 
Stevens TCP/IP implementation book is extremely out-of-date, but useful 
reading nontheless.

The first thing to think about, BTW, is whether or not a new protocol is in 
fact what you want to do.  Protocol families bring a lot of useful 
infrastructure to the table: an IPC model, a routing infrastructure, 
abstractions for "interfaces", etc.  However, they may or may not be what 
you're looking for -- before going down this path I'd want to think very 
carefully about whether the requirements you have are best met in this way, or 
possibly better met by creating a new device abstraction 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 example, do you anticipate using or 
even needing the routing facilities, and how might you map ISDN telephony 
parts into the normal network stack infrastructure of addresses, routing, 
interfaces, etc?

Robert N M Watson
Computer Laboratory
University of Cambridge