From owner-freebsd-bugs Thu Jul 9 16:10:14 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA12602 for freebsd-bugs-outgoing; Thu, 9 Jul 1998 16:10:14 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA12592 for ; Thu, 9 Jul 1998 16:10:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id QAA09722; Thu, 9 Jul 1998 16:10:01 -0700 (PDT) Received: from www.RCousins.com ([209.31.225.65]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA11893 for ; Thu, 9 Jul 1998 16:04:18 -0700 (PDT) (envelope-from rec@rcousins.com) Received: (from rec@localhost) by www.RCousins.com (8.8.8/8.8.8) id QAA03280; Thu, 9 Jul 1998 16:04:11 -0700 (PDT) Message-Id: <199807092304.QAA03280@www.RCousins.com> Date: Thu, 9 Jul 1998 16:04:11 -0700 (PDT) From: rec@rcousins.com Reply-To: rec@rcousins.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/7230: problem with SIOCGIFCONF Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 7230 >Category: kern >Synopsis: problem with SIOCGIFCONF >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jul 9 16:10:01 PDT 1998 >Last-Modified: >Originator: Robert Cousus >Organization: >Release: FreeBSD 2.2.6-RELEASE i386 >Environment: K6 cpu, 128 megs RAM, 15 gigs Disk, 2 LAN ifces. >Description: SIOCGIFCONF does not return an array of struct ifreq with one entry per network interface. >How-To-Repeat: Compile and run the attached program to demonstrate the problem. (Note: program runs correctly under Solaris 2.5.1.) ----------------- #include #include #include #include #include #include char buffer[1<<12]; int main(int argc, char *argv[]) { int res; /* result from call */ int sock; /* socket file descriptor */ int i; /* loop variable */ struct ifconf ifconf; /* used in test below */ struct ifreq *ptr; /* pointer to walk buffer */ sock = socket(PF_INET, SOCK_DGRAM, 0); if (sock < 0) { perror("socket(PF_INET, SOCK_DGRAM, 0)"); exit(1); } ifconf.ifc_len = sizeof(buffer); /* establish size of buffer */ ifconf.ifc_buf = buffer; /* point to buffer */ res = ioctl(sock, SIOCGIFCONF, &ifconf); if (res < 0) { perror("ioctl(sock, SIOCGIFCONF, &ifconf)"); exit(1); } /* * At this point, the ifconf.ifc_len should tell how many bytes consumed * in the buffer and ifconf.ifc_req should point to an array of ifreq * structures. * /* * Test 1: The return value should be a multiple of sizeof(ifreq). */ if (ifconf.ifc_len % sizeof(struct ifreq)) { printf("Failed test1: %d %% %d = %d\n", ifconf.ifc_len, sizeof(struct ifreq), ifconf.ifc_len % sizeof(struct ifreq)); } /* * Test 2: We should be able to print out the names of all * interfaces by looping through the array. */ ptr = ifconf.ifc_req; /* point to beginning of array */ for (i = 0; i < (ifconf.ifc_len/sizeof(struct ifreq)); i++, ptr++) printf("Interface %d: %s\n", i, ptr->ifr_name); exit(0); } ----------------- >Fix: Unknown. >Audit-Trail: >Unformatted: Robert Cousins To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message