discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unpcomming FreeBSD 4.5 release and gdomap


From: Pete French
Subject: Re: Unpcomming FreeBSD 4.5 release and gdomap
Date: Mon, 21 Jan 2002 21:25:56 +0000

> Does that particular machine participate in a network, ie. is your
> networking up and running, except for 'gdomap' ?

Yes, its got two interfaces (fxp0 amd fxp1) which are 100 base T connections
to the outside world via cable modem and the local net respectively. natd
is running between them, lo0 exists too of course, plus a smattering
of other interfaces, IP4 and Ip6 ones, which are not configred.

> Anyway, FreeBSD4.5 is a pre-release. If this is a bug, let them know so a
> possible fix can make it into the kernel in time.

I did, though os far no response. Ironicly the prerelease worked
fine, it was the first release candidate that borke. A later one seems
to work., thoguh it gives the same errors.

I spent a bit of time trying to tarck this down. I came donw to
some very odd behaviour from SIOCGIFCONF. This is supposed to
return a block of ifreq structures, plsu the lecght of that block
so you knwo how many you have.  Now sizeof one of these structures is 32
bytes, but the length of my retruned buffer is 776 - not a multiple of 32 !
A lot of the blocks are full of garbage characters. So the errors in gdomap
come from passing these garbage requests back to SIOCGIFFLAGS.

Which is interesting - and I notice that SIOCGIFCONF is not the way you get
a list of interafces under BSD anymore. I dont mind writing an update
to gdomap to so it the new ay, as long as it can be ifdefd in (and I am not
sure quite which ifdefs to use).

I went and took the SIOCGIFCONF code and tried it on OS4.2 - that works
fine, but duplicates the main ether card interface, so I get lo0, ed0, ed0.
On Mac OS X it gives the same behaviour as FreeBSD - garbage blocks in the
return.

If anyone has any access to other BSD systems then could they try the following
code, just for the sake of curiosity ? It just lists the iterfaces
present on the machine (supposedly). Or if anyone spots a humungous
bug then feel free to tell me where I ent wrong. This is based on the code
in gdomap.

-bat.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/route.h>


int
main(int argc, char **argv)
{
        int s, i, nif;
        char buf[32768];
        struct ifconf cs;

        printf("Each ifreq structure is %ld bytes\n", sizeof(struct ifreq));

        /* make the socket */
        s = socket(AF_INET, SOCK_DGRAM, 0);
        if(s < 0) {
                perror("Failed to make socket");
                return 0;
        }

        /* get the interface list */
        cs.ifc_len = sizeof(buf);
        cs.ifc_buf = buf;
        printf("Start buf size is %d bytes\n", cs.ifc_len);
        if (ioctl(s, SIOCGIFCONF, &cs) < 0) {
                perror("Failed to perform SIOCGIFCONF");
                return 0;
        }
        printf("New buf size is %d bytes\n", cs.ifc_len);

        nif = cs.ifc_len / sizeof(struct ifreq);
        printf("%d interfaces found\n", nif);
        for(i=0;i<nif;i++)
                printf("Interface %d = %s\n", i, (cs.ifc_req)[i].ifr_name);

        return 0;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]