From: hwajin@iphasew.com
Newsgroups: comp.os.vxworks
Subject: raw socket e-mail for mike anderson
Date: Mon, 05 Oct 92 11:01:06 -0700
Organization: Lawrence Berkeley Laboratory, Berkeley CA
NNTP-Posting-Host: 128.3.112.16
Originator: daemon@vxw.ee.lbl.gov


mike this message bounced back... 

sorry for the wasted bandwidth but this may be of general interest.


------- Forwarded Message

>From uunet.UU.NET!iphasew!hwajin  Thu Oct  1 22:53:41 1992 remote from durin.laguna.sparta.com
Received: from relay1.UU.NET by laguna.sparta.com (4.1/fjh-lh-MX-1.1(durin))
	id AA24307; Thu, 1 Oct 92 22:53:41 PDT
Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay1.UU.NET with SMTP 
	(5.61/UUNET-internet-primary) id AA15929; Fri, 2 Oct 92 01:53:10 -0400
Received: from iphasew.UUCP by uunet.uu.net with UUCP/RMAIL
	(queueing-rmail) id 015221.10324; Fri, 2 Oct 1992 01:52:21 EDT
Received: by iphasew.iphasew.com (/\=-/\ Smail3.1.18.1 #19.16)
	id <m0mafbw-000EsSC@iphasew.iphasew.com>; Thu, 1 Oct 92 22:31 PDT
Received: by pogo.iphasew.com (/\=-/\ Smail3.1.18.1 #19.16)
	id <m0mafgG-0001crC@pogo.iphasew.com>; Thu, 1 Oct 92 22:36 PDT
Message-Id: <m0mafgG-0001crC@pogo.iphasew.com>
To: sparta.com!mea
Reply-To: durin.laguna.sparta.com!iphasew.com!hwajin
Subject: Re: RAW IP sockets 
Date: Thu, 01 Oct 92 22:35:57 -0700
From: durin.laguna.sparta.com!iphasew.com!hwajin


hi there...

>1) is this a reasonable approach or is there something better?

i assume you don't want to use the backplane net between A and B? (or
maybe they're not on the same bus... 

i also assume that you don't want to use etherLib routines... since
you will have to filter non-ip frames if you do...

so raw socket is probably a right thing to use...

>2) information on raw sockets is almost non-existent.  Do you have any code
>   or pointers that would tell me both how to read a raw socket and how
>   to "forward" the uncompressed packet on to the destination?  

i wrote some sample code to show people how to use raw sockets
when i was and wind river.  they should have it somewhere but
they may not know where it is (if they saved my old directory
they should be able to dig something up from there)...

>3) Do I bind an address to the raw socket and is there information in the
>   raw packet that would tell me the ultimate destination?  

yes.  raw sockets pretty much work like anything else -- you can bind()
and connect().  when you bind() an address the only meaningful thing
is ip address (port is transport layer concept) -- binding is a way
to specify local address -- if you do this only those ip datagrams
that have destination ip address field of ip header equal to your
locally bound address will be received on that socket.  when you
connect(), you're specifying the equivalent filter address for the
source ip address -- only those ip datagrams that have the same ip
source address field will be received on the socket.  if you do neither
bind() or connect(), you'll receive all ip packets.  as you can see
you can use this kind of filtering to implement a pretty efficient
special purpose router for a group of sources and destinations...

similarly you can use recvfrom() to find the source address.
of course, you could also use recv() or read() as well, in which
case you won't get the address. 

>4) What is the structure of the raw packet resulting from a socket call that
>   uses the IPPROTO_RAW?   

you get the ip datagram starting at the header assembled for you.
this is how you'll get the ultimate destination ip address -- by
looking inside the ip header -- unless if you have done a bind()
and set up a filter for the target ip address.


good luck...

	~hwajin


------- End of Forwarded Message