[Xorp-users] Build difficulties

Weaver John-JWEAVER1 John.Weaver@motorola.com
Tue, 26 Jul 2005 17:27:17 -0500


I am looking into my build options again.  We are using ClearCase on Sun
machines so I am not sure that we are picking up the right include files.
Problem is compiling on SunOS for Linux on a PowerPC.  If I need to have
HAVE_IOCTL_SIOCGIFCONF defined then it must not be looking into the correct
directories.  I will have to do some looking and get back to you.

Thanks,
John

-----Original Message-----
From: Pavlin Radoslavov [mailto:pavlin@icir.org] 
Sent: Tuesday, July 26, 2005 2:36 PM
To: Weaver John-JWEAVER1
Cc: Pavlin Radoslavov; xorp-users@xorp.org
Subject: Re: [Xorp-users] Build difficulties 

> It is not defined but it is not undefined either. I am pretty much 
> building the code as it is from the packaged download.

I just committed a fix to xorp/fea/ifconfig_set_ioctl.cc (rev. 1.37) so
please get the lastest XORP code from CVS and try to compile it.
I don't have a box like yours to test it, but hopefully it will take care of
the problem.

The usual disclamer applies that you may have to wait up to one hour until
the anon. CVS repository is updated.

Alternatively, you can apply the following patch:
http://xorpc.icir.org/cgi-bin/cvsweb.cgi/xorp/fea/ifconfig_set_ioctl.cc.diff
?r1=1.36&r2=1.37

This patch should apply cleanly for XORP-1.1.

Though, if you are running Linux I am wondering why HAVE_IOCTL_SIOCGIFCONF
wasn't defined. I would expect that all Linux distributions would support
ioctl(SIOCGIFCONF).

Could you compile and run the small program at the end of this email. If
ioctl(SIOCGIFCONF) is available, the program should compile cleanly and
should return (0).
FYI, this is the same program used by configure (see
config/acifconf.m4) to determine whether the system supports
ioctl(SIOCGIFCONF).

Thanks,
Pavlin

/****** BEGIN ******/

#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
main()
{
    int sock, lastlen;
    struct ifconf ifconf;
    int ifnum = 1024;

    ifconf.ifc_buf = NULL;
    lastlen = 0;

    if ( (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
	return (1);

    /* Loop until SIOCGIFCONF success. */
    for ( ; ; ) {
        ifconf.ifc_len = ifnum*sizeof(struct ifreq);
        ifconf.ifc_buf = (caddr_t)realloc(ifconf.ifc_buf, ifconf.ifc_len);
        if (ioctl(sock, SIOCGIFCONF, &ifconf) < 0) {
            /* Check UNPv1, 2e, pp 435 for an explanation why we need this
*/
            if ((errno != EINVAL) || (lastlen != 0))
		return (1);
        } else {
            if (ifconf.ifc_len == lastlen)
                break;          /* success, len has not changed */
            lastlen = ifconf.ifc_len;
        }
        ifnum += 10;
    }

    return (0);
}

/****** END ******/