Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Mar 2012 08:23:10 -0800
From:      hiren panchasara <hiren.panchasara@gmail.com>
To:        Sergey Kandaurov <pluknet@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Difference between "struct addr" and "struct addrs"
Message-ID:  <CALCpEUGHp-HmPuhiT7SK0qM=1Y6XrHdmMkXQUcnUpWUrCSW=GQ@mail.gmail.com>
In-Reply-To: <CAE-mSOJvK6iXA31GvBKQ=jX=iS=PJcKQvSGS1ZPVsD9s95U7DQ@mail.gmail.com>
References:  <CALCpEUFED9-ZNwLCVFKfx1_Vyh9tNVXauhwSdPqmtCQa8DcJ2w@mail.gmail.com> <CAE-mSOKrY7-p2mt_0tp2OqcTzjBuzj9g4Kjnx6ZHTQb=XxRduA@mail.gmail.com> <CALCpEUFzGdPGXPAu8tH5A9tJcwnLM0RtzPrQXW4QuSXbbyRFxw@mail.gmail.com> <CAE-mSOJvK6iXA31GvBKQ=jX=iS=PJcKQvSGS1ZPVsD9s95U7DQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 6, 2012 at 12:03 AM, Sergey Kandaurov <pluknet@gmail.com> wrote:

> On 6 March 2012 11:08, hiren panchasara <hiren.panchasara@gmail.com>
> wrote:
> >
> >
> > On Mon, Mar 5, 2012 at 10:57 PM, Sergey Kandaurov <pluknet@gmail.com>
> wrote:
> >>
> >> struct ifaddr is the in-kernel representation of the interface address.
> >> In kernel each network interface consists of a linked list of interface
> >> addresses, described by ifaddr structures.
> >> See man ifnet(9): http://man.freebsd.org/ifnet
> >>
> >> struct ifaddrs is used in the userland BSD API getifaddrs(3). This
> >> interface
> >> is used to get interface addresses in userland programs. See how it is
> >> used in e.g. ifconfig(8) sources: /usr/src/sbin/ifconfig/ifconfig.c
> >> See man getifaddrs(3): http://man.freebsd.org/getifaddrs
> >
> > Thanks Sergey, appreciate your help.
> >
> > Are they connected in any way? Can I get one if I have another?
>
> Well, not strictly.
> getifaddrs() collects addresses on all network interfaces using
> sysctl interface to the routine table with NET_RT_IFLIST[L] argument.
> NET_RT_IFLIST[L] does what you would expect: it runs through the linked
> list of network interfaces and gathers all struct ifaddr on each of them.
> You can see how that works in /usr/src/sys/net/rtsock.c:sysctl_iflist().
> See also man sysctl(3) w.r.t. NET_RT_IFLIST / NET_RT_IFLISTL.
>

Thanks a bunch, Sergey!

This is *exactly* what I was looking for. :-)

Hiren



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALCpEUGHp-HmPuhiT7SK0qM=1Y6XrHdmMkXQUcnUpWUrCSW=GQ>