Re: Example network protocol implementation



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: <eb7c8e2e0612091218r61bb72b4q49faee99d85c509d@xxxxxxxxxxxxxx>
"Vishal Patil" <bsd.devil@xxxxxxxxx> 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@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"

_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: REMINDER: Re: HEADS UP: network stack and socket hackery over the next few weeks (fwd)
    ... committed an extensive set of socket and netinet changes which will likely render the network stack broken. ... Protocols can now explicitly request that a socket not be freed on last ... consumer reference, using the SS_PROTOREF flag, in order that they can ...
    (freebsd-net)
  • Re: Protocols to exchange messages via a socket
    ... protocols are best suitable: ... socket in case of a decoding error? ... You cannot be sure how many messages were lost on the wire behind any ... assuming TCP the atomicity of writes isn't guaranteed. ...
    (comp.unix.programmer)
  • Re: LSP bypass method - pls help
    ... > What I do now, if I detect there are calls in that socket after WSPSocket, I ... same lower provider is called, indepently of which protocol is the socket for. ... MS Recomends installing the LSP over all protocols of the same family, ...
    (microsoft.public.win32.programmer.networks)
  • Re: small tun(4) improvement
    ... And libmchain does not support Big Endians, ... >>don't want to make tun and tap depend on libmchain. ... While the netgraph equivalents may have the same functionality ... >P.S. I'm working on making protocols within protocols domains loadable at ...
    (freebsd-net)
  • Re: small tun(4) improvement
    ... And libmchain does not support Big Endians, ... While the netgraph equivalents may have the same functionality ... P.S. I'm working on making protocols within protocols domains loadable at ... I'm using this to make DIVERT a loadable module. ...
    (freebsd-net)