[net.unix-wizards] 4.2 networking question

clt@wdl1.UUCP (01/16/85)

<>
Problem overview: using raw sockets in 4.2bsd

What I want to do: Write a network application which uses IP.  I am
	implementing an XNET User program (Internet protocol #15).
	This would require sending (and receiving!) packets with the
	IP protocol field set to 15.  Note that I don't care whether
	the user process actually receives the entire IP packet.  If
	the header is stripped off, that is fine.

What I am doing: trying to establish a raw socket, with protocol number 15:

	#define XNETPROTO	15
	...
	socknbr = socket(AF_INET,SOCK_RAW,XNETPROTO);

	This call is returning the "Protocol not supported" error.
	By the way, I have SETUIDed, so it is running in supervisor mode,
	as it should, for using raw sockets.

If anyone has any sample code where a process is running on top of IP
directly, I would greatly appreciate a message telling me what I am
doing wrong (either the idea or the specific code, preferably the latter,
but I'm not picky).			Thank you in advance,

					Chris Tucci

Bob Walsh <walsh@bbn-labs-b.ARPA> (01/21/85)

At a minimum, to support new IP protocols in 4.2BSD, you need to update
in_proto.c

bob walsh

chris@umcp-cs.UUCP (Chris Torek) (01/21/85)

> Path: umcp-cs!seismo!harvard!talcott!panda!teddy!genrad!decvax!
> bellcore!allegra!ulysses!mhuxr!mhuxj!houxm!ihnp4!zehntel!dual!amdcad!
> fortune!wdl1!clt

Great galloping horney todes!  [Tryinta get inta the spirit for Dallas...)

> What I am doing: trying to establish a raw socket,
> with protocol number 15:

>	#define XNETPROTO	15
>	...
>	socknbr = socket(AF_INET,SOCK_RAW,XNETPROTO);

>	This call is returning the "Protocol not supported" error.
>	By the way, I have SETUIDed, so it is running in supervisor mode,
>	as it should, for using raw sockets.

Waaall, a couple of things: first, AF_INET SOCK_RAW will get you a raw
connection.  But you don't need (or want) a protocol field.  Instead,
you get to read and write headers yourself.  Lessee, to get to the IMP
(or whatever), you want to bind() in AF_INET to the interface address,
I think.

I'm sure y'all 'r gonna jump on me if I missed anything, so I'll
jest mosey on outta here now ...
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland

ben@cernvax.UUCP (ben) (01/23/85)

   Here is the answer to your question about raw IP. I suppose several people
have answered as it is quite simple. All you have to do is add an entry to the
protocol switch table in the file /sys/netinet/in_proto.c; this should be an
exact duplicate (and can directly follow) the entry for normal raw IP, but the
value IPPROTO_RAW should be changed to your own value IPPROTO_XNET (= 15).
To be tidy, define this latter thing in /sys/netinet/in.h by the way.
   If you are serious about wanting to remove the IP headers completely, then
your task is much harder (I know 'cos I've done it...). Good hacking!

          Ben M. Segal  (CERN-DD, 1211 Geneva 23, Switzerland).