From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 10 07:52:18 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B885616A40F for ; Sun, 10 Dec 2006 07:52:18 +0000 (UTC) (envelope-from ozkan@mersin.edu.tr) Received: from mail.mersin.edu.tr (mail.mersin.edu.tr [193.255.128.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A3AF43C9E for ; Sun, 10 Dec 2006 07:51:09 +0000 (GMT) (envelope-from ozkan@mersin.edu.tr) Received: from localhost (localhost.mersin.edu.tr [127.0.0.1]) by mail.mersin.edu.tr (Postfix) with ESMTP id 9A4DC45403 for ; Sun, 10 Dec 2006 09:59:00 +0200 (EET) X-Virus-Scanned: by amavisd-new at mersin.edu.tr Received: from mail.mersin.edu.tr ([127.0.0.1]) by localhost (mail.mersin.edu.tr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vOKhLFN+CUGu for ; Sun, 10 Dec 2006 09:58:47 +0200 (EET) Received: from [10.0.50.20] (unknown [88.247.50.50]) by mail.mersin.edu.tr (Postfix) with ESMTP id 1B8A1452BD for ; Sun, 10 Dec 2006 09:58:46 +0200 (EET) Message-ID: <457BBCC3.9040605@mersin.edu.tr> Date: Sun, 10 Dec 2006 09:52:35 +0200 From: =?ISO-8859-9?Q?=D6zkan_KIRIK?= User-Agent: Mozilla Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.ORG References: <20061209.222526.-816359937.imp@bsdimp.com> In-Reply-To: <20061209.222526.-816359937.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-9; format=flowed Content-Transfer-Encoding: 8bit Cc: Subject: Re: Example network protocol implementation X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Dec 2006 07:52:18 -0000 I think netgraph subsystem provides this infrastructure for implementing new protocols. according to netgraph (4) man page: The aim of *netgraph* is to supplement rather than replace the existing kernel networking infrastructure. It provides: *·* A flexible way of combining protocol and link level drivers. *·* A modular way to implement new protocols. *·* A common framework for kernel entities to inter-communicate. *·* A reasonably fast, kernel-based implementation. There are many examples and applications at this address: http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netgraph/ you implementation may be "ng_iscsi" :) I hope this helps, Özkan KIRIK EnderUNIX SDT @ Turkey Software Developer M. Warner Losh yazmış: > In message: > "Vishal Patil" writes: > : Could someone point me to an example that shows a SIMPLE network protocol > : implemented over TCP/IP inside the FreeBSD kernel. I think I could look at > : the NFS client driver but is there an example simpler than that. Also is > : there a guide explaining how to go about developing TCP/IP based network > : protocols for FreeBSD. > > [ to implement iSCSI in the kernel ] > > I'm unsure which side you wish to be on. > > There's accept filters that you can write, but I doubt that's what you > want to do. This would be good if you are implementing an iSCSI > target on FreeBSD, maybe (then again, maybe not). > > If you want to be an iSCSI initiator (I think that's the right term), > then you'll need to do things similar to what > sys/nfsclient/nfs_socket.c does. I could do a quick code walkthrough, > but you'd likely be better off studying the nfs code since it will > give you a better understanding than I can in a few lines. In > addition, because locking has changed over time, the exact version > matters. Careful study will show differences in what locks are > needed, if any. > > But in a nutshell, you call socreate to get a socket. You setup the > various fields in the socket data structures. You call sosetopt to do > the latter. sobind will set this host's endpoint, and soconnect will > connect the socket to the remote side. You'll need to setup send and > receive buffers and manage them with soreceive and sosend. there's > some callbacks that also need to be established as well. And some > socket layer locking that may be exposed to your code because there > are so few in-kernel protocol implementations that aren't peers to > TCP, UDP or IP. > > I hope this helps. > > Warner > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > >