Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Aug 1997 17:52:39 -0700
From:      Julian Elischer <julian@whistle.com>
To:        snayak <snayak@ricochet.net>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: help me out !!
Message-ID:  <34037A57.64880EEB@whistle.com>
References:  <303FB26B.1D25@ricochet.net>

next in thread | previous in thread | raw e-mail | index | archive | help
snayak wrote:
> 
> hello hackers
> 
>  I got some probelsm in understanding the code related to the ARP
>  and DRIVER interfaces in FREE BSD. Actually i am in a process of
> customising the code to my application  ( ARP code ).
> 
>  The  code says
> 
>    struct arpcom {
> 
>                   }
> 
>  is the structure shared between driver and ARP module. I would like
> know there are any structure which are common between these two modules
??
yes the arpcom struct is known to both the driver and the arp code.
each interface has one of these. It's part if the interface's 
private stuff. It's made available tothe arp code whenever the
interface calls the arp code.

> 
> secondly. when ARP request comes in to a host, ARP module will check
> the address ( sanity checking ) and then calls the a function "
> arplookup".  this interms calls  "rtalloc1"  which calls rn_match().
> 
>  the structure involved during the processing of above functions are
>    struct rtentry
>    struct radix_node
>    struct radix_node_head.
> 
>  i am not really understanding what are these radix structures.

these are fully explained in the books by Richard Stevens.
see www.freebsd.org for a bibliography..

a radix tree is used to store routes.
basically each branch in the  tree depends on the state of 1 bit
in the addres being searched. It's basically a dynamic decision tree.
when you reach a leaf you have a route.
if you don't have a match at the leaf, you back up, using
the netmask till you have a route for the net you are trying to get
to. if you back up all the way to the root of the decision tree, 
you get the default route.

each rtentry struct contains two radix nodes. as well as the specific
route information. it turns out that two add a route, you always need to
add 2 nodes to the tree.
one as an extra decision, and one as a leaf node to hold the route.
so each rtentry (short for ROUTE ENTRY) comes with 2 pre-packaged 
to save on the malloc overhead.
the radix_node_head is the head of the radix tree, and contains
special info such as the top node, and two other special nodes
(from memory)

each node specifies which byte of the sockaddr (address) is going
to be tested, and which bit in that byte. (in the form fo a mask).
if that bit of that byte is 1 you take the branch, otherwise take
the right. When backing up, you also use the supplied netmask
to check is your bit should match or not..

as I said..
read the STEVENS book..


> 
>  can i replace this structure with my own struct which contains the
>  arp route information.
each protocol has teh ability to specify different
routines to do routing lookups.

> 
>  pls help me out
This is really tricky stuff you  really need to know what you
are doing to fiddle with it..
BSD4.3 used a much simpler routing table, and a separate
arp table. bsd4.4 has them merged (arp entries being only a special
case of a routing table entry, but it complexifies the situation
in some ways. I believe that garret is thinking about re-implementing
a separate arp table again. The appletalk code still uses a separate 
arp system (It came from BSD4.3) so you migh thlook at how that does
it.

> 
>  hope i am not troubling you too much
> 
> mail me at   " snayak@ricochet.net" or " nayaksan@hotmail.com"
> 
> bye
> sanjay

julian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34037A57.64880EEB>