*BSD News Article 94059


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!news-peer.gsl.net!EU.net!Norway.EU.net!sn.no!usenet
From: Terje Eggestad <terje.eggestad@novit.no>
Newsgroups: comp.unix.bsd.freebsd.misc,comp.protocols.tcp-ip
Subject: Re: Q: Raw sockets to buypass tcp/udp?
Date: Mon, 21 Apr 1997 20:00:45 +0200
Organization: Telenor Novit AS
Lines: 55
Message-ID: <335BAB4D.F11@novit.no>
References: <33551811.6113@snads.lkg.dec.com>
NNTP-Posting-Host: fw.novit.no
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (WinNT; I)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:39451 comp.protocols.tcp-ip:53185


Michael C. Cambria wrote:
> 
> Hi,
> 
> First, I need to be able to send and receive my own "layer 3" packets
> but continue to use the FreeBSD IP.  Put simply, I want to replace
> TCP and UDP with my own.  What is the proper way to do this?  Is it
> even possible?
> 
Well if you want to do this from scratch..
In the IP header there is a flied that say protocol number. If I not
mistaken TCP is 6 UDP is 17, OSPF is 89. What you seems to want to do is
to use your own number here. You need to open a socket, and in teh
listen og connect call use SOCK_RAW as type. I have never attemptet this
myself, but seen this is the code. I do belive you must directly set all
the header fields (IP) directly. :-) 
 
> Second, I need to put my own 802.2 packets (ie. no IP layer) for my
> own "layer 2" on the LAN.  What is the proper way to do this?
> 
As in the IP header, there are a field in the 802 frames that says
protocal type. IP, IPX, netbeui, DECnet, etc. In theory SNA and X25. 
I do not recall the numbers here, not do I know exactly how you do the
interface in the code. I have a hunch that that is very dialect
specific.

> 
> For my own "layer 3":
> I've looked at: socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) a bit, since
> "ping" lets one build their own ICMP header and the OS will prefix
> what I send with the IP header.  Should this be used?  It doesn't
> "feel right" as the protocol I'm using is not ICMP.
> 
NO,  ICMP is IP protocol 1. You will be respassing if you do that.

> I've also considered: socket(PF_INET, SOCK_RAW, IPPROTO_RAW)
> but I'm _guessing_ that this would be the way to send/rcv directly
> on the wire myself (ie. build my own "layer 2").
this should be that way to do directly layer 3. Since you will use a
protocol number not used before there will not be a IPPROTO_XXX defined
for you. on my HP IPPROTO_XX <netinet/in.h> are defined directly to the
protocol numbers. You may use your protocol number directly. 
The reason you are still on layer 3 even with IPPROTO_RAW is that in 
the 802 frame there will still be a number saying that this is IP. 

> 
> Thanks for any help, pointers etc.
> 
> MikeC
> 
> --
> Michael C. Cambria                          Voice: 617 643 6250
> Systems & Communications Sciences, Inc.       Fax: 617 643 6251
> 138 Wright Street                        Internet: cambria@world.std.com
> Arlington, Ma. 02174                   CompuServe: 71552,2531