From owner-freebsd-hackers Wed Jul 18 0:53:52 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from hotmail.com (f197.law11.hotmail.com [64.4.17.197]) by hub.freebsd.org (Postfix) with ESMTP id 54B9037B401; Wed, 18 Jul 2001 00:53:46 -0700 (PDT) (envelope-from anandfranklin@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 18 Jul 2001 00:53:46 -0700 Received: from 203.200.20.3 by lw11fd.law11.hotmail.msn.com with HTTP; Wed, 18 Jul 2001 07:53:45 GMT X-Originating-IP: [203.200.20.3] From: "Anand Franklin J" To: freebsd-net@freebsd.org, freebsd-hackers@freebsd.org Subject: Hi(some clarifcation about sysctl usage in ifconfig) Date: Wed, 18 Jul 2001 07:53:45 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 18 Jul 2001 07:53:46.0062 (UTC) FILETIME=[C5A916E0:01C10F5E] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, The below code is part of ifconfig which use sysctl: 1:mib[0] = CTL_NET; 2:mib[1] = PF_ROUTE; 3:mib[2] = 0; 4:mib[3] = 0; /* address family */ 5:mib[4] = NET_RT_IFLIST; 6:mib[5] = 0; /* if particular family specified, only ask about it */ 7:if (afp) 8: mib[3] = afp->af_af; 9:if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) 10: errx(1, "iflist-sysctl-estimate"); 11:if ((buf = malloc(needed)) == NULL) errx(1, "malloc"); 12:if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) errx(1, "actual retrieval of interface table"); the doubts are: 1) what is the purpose of the above c statements. 2)how are the mib values stored before finding its value line from 1->8 3)line from 9->11 is clear, that is it finds the length of the buffer to be allocated. 4)what is the significance of line 12 and what will the buf variable will contain. with regard's franklin. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message