Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jul 2001 07:53:45 -0000
From:      "Anand Franklin J" <anandfranklin@hotmail.com>
To:        freebsd-net@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Hi(some clarifcation about sysctl usage in ifconfig)
Message-ID:  <F197ZDgC81TbdkSmLAz000000d2@hotmail.com>

next in thread | raw e-mail | index | archive | help
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




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