[openbeosnetteam] Re: Network overview

Hi Andrew,

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...

On 2006-07-23 at 01:09:24 [+0200], Andrew Galante <haiku.galante@xxxxxxxxx> 
wrote:
> 
> Why are interfaces tied to a single domain?  

As far as I can see, net_interfaces are bound to a single domain because each 
net_interface represents a specific configuration of a device (the address 
which will be bound to the net_device by the stack and the protols that are 
running on the interface). As addresses and protocols are domain specific, it 
is necessary to bind net_interface to a domain.

> Is this a high level domain (internet) or low level (ethernet)?  

This is a high level domain (e.g. AF_INET).

> Are there low level domains?

No, I don't think so. There are device types like IFT_ETHER, but I think 
that's it.

> What is the difference between a chain and a route - the layers they operate 
> in?

A route is used by to determine the interface that an outgoing datagram should 
be passed to (finding the route from the source to the destination). 
A chain (as found in stack.cpp) is used by the stack to "stack" (or "chain") 
protocols on top of each other (UDP on top of IP). Each protocol module 
registers the protocol chains it needs on load.
While routes are a central component of the network layer of *any* network 
stack, chains are just an implementation detail of *our* stack.

> 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.

> 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?

cheers,
        Oliver

Other related posts: