[openbeosnetteam] Re: Network overview

Oliver Tappe <openbeos@xxxxxxxxxxxxxxx> wrote:
> I'll try to answer your questions, more or less as an exercise for 
> myself (and 
> to check my interpretation of the stack against the views of others). 
> I'm sure 
> Axel will correct me wherever I'm wrong...

Will do, even though there is only one point I slightly disagree with :
-)

[...]
> > Are there low level domains?
> No, I don't think so. There are device types like IFT_ETHER, but I 
> think 
> that's it.

There is AF_LINK which you could consider as a low level domain, as it 
gives you more or less direct access to a certain device.

[...]
> > I'm trying to get ping to work.  The ping program makes a call to
> > socket(AF_INET, SOCK_RAW, icmp->p_proto).  This should cause a new
> > ICMP object to be created, that is attached to the socket 
> > right?(this
> > currently causes an EAFNOSUPPORT error)  I assume ICMP would have 
> > to
> > be registered in the chain to handle these kinds of sockets.
> Yes, I think you're right and I suppose the current registration of 
> ICMP as 
> SOCK_DGRAM might just be a copy & paste bug and should be replaced by 
> SOCK_RAW.

It's not actually, as I just taken it from bone.conf: AFAICT if you 
want to send (and receive) ICMP messages, you'd use (AF_INET, 
SOCK_DGRAM, IPPROTO_ICMP) - but if you'll be using raw sockets (ie. 
AF_INET, SOCK_RAW, IPPROTO_ICMP), you'll get the IP header as well when 
receiving a packet and you get all incoming packets (that aren't 
targeted to UDP or TCP).
At least that's what I think :-)

> > Actually, the ping program makes a call to getprotobyname("ICMP")
> > before the socket call. - This just reads /etc/protocols and 
> > returns
> > the number associated with ICMP (in my case, 1).  Should this be
> > #defined somewhere in the ICMP module?
> Well, IPPROTO_ICMP is defined in in.h and having .../etc/protocols 
> probably 
> isn't such a good idea anyway, as it pretends to give support for 
> changing the 
> assocations between protocols and numbers, when in fact these are 
> hardcoded in 
> the net-stack.
> So maybe we should reimplement getprotoent() to fetch the neccessary 
> info from 
> the stack and not from a plain file?

Sounds reasonable.

Bye,
   Axel.


Other related posts: