From owner-freebsd-net@FreeBSD.ORG Tue Mar 6 16:23:12 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A11AF106564A for ; Tue, 6 Mar 2012 16:23:12 +0000 (UTC) (envelope-from hiren.panchasara@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2377B8FC14 for ; Tue, 6 Mar 2012 16:23:11 +0000 (UTC) Received: by bkcjc3 with SMTP id jc3so5857182bkc.13 for ; Tue, 06 Mar 2012 08:23:11 -0800 (PST) Received-SPF: pass (google.com: domain of hiren.panchasara@gmail.com designates 10.205.127.130 as permitted sender) client-ip=10.205.127.130; Authentication-Results: mr.google.com; spf=pass (google.com: domain of hiren.panchasara@gmail.com designates 10.205.127.130 as permitted sender) smtp.mail=hiren.panchasara@gmail.com; dkim=pass header.i=hiren.panchasara@gmail.com Received: from mr.google.com ([10.205.127.130]) by 10.205.127.130 with SMTP id ha2mr13718281bkc.28.1331050991144 (num_hops = 1); Tue, 06 Mar 2012 08:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=zIYgPO+URz2zOz5Pif+pgSVQYP8I7O7NgP+sDycXEyY=; b=tplkjekjR5+OmO7kcWmxhtHsYyARtW2zOe+hFS19+NXHU+sHiPSogZBe1cMLsoyC2a AZOewhNFp1Aky4GM6Z8PTWSv5hKXd+ngSSYUoVWxfnJJyG3e/junk4K/qtOXrF0XOwX3 TBousIgTBTQyS8fBz+lTYLlRgBdYbHfVgd0VhCu+x4kwQ+brgMTUrawK7vDEGmwg6BHm GrxAfC7wRDeNtTyRk168KnQzG2wZFu/kznpL4+KlmgD1POhOTqMXlkbyULbCP2O///4n nnUur6g1JvsBHJsRaZAq/9Nf5LTL58TOtb2CyWJTYmcyqMxQO85/fOebn/CzzA24tLlL 0MOA== MIME-Version: 1.0 Received: by 10.205.127.130 with SMTP id ha2mr10755225bkc.28.1331050991046; Tue, 06 Mar 2012 08:23:11 -0800 (PST) Received: by 10.204.230.5 with HTTP; Tue, 6 Mar 2012 08:23:10 -0800 (PST) In-Reply-To: References: Date: Tue, 6 Mar 2012 08:23:10 -0800 Message-ID: From: hiren panchasara To: Sergey Kandaurov Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-net@freebsd.org Subject: Re: Difference between "struct addr" and "struct addrs" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2012 16:23:12 -0000 On Tue, Mar 6, 2012 at 12:03 AM, Sergey Kandaurov wrote: > On 6 March 2012 11:08, hiren panchasara > wrote: > > > > > > On Mon, Mar 5, 2012 at 10:57 PM, Sergey Kandaurov > 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