[Xorp-users] HAVE_IPV6

Pavlin Radoslavov pavlin@icir.org
Wed, 18 Jun 2003 11:34:34 -0700


> Some quick help please?
> 
> At various places in the code there is this check:
> 
> #ifdef HAVE_IPV6
> ...
> #endif // HAVE_IPV6
> 
> For some reason it doesn't work for me (RH 9.0 with 2.4.20-8)
> although I do have IPv6 enabled.
> Is there some starting point where this check is initially made?
> May I circumvent it?

The check for IPv6 existence is performed when ./configure is run.
The check itself is in config/acipv6.m4 : the configure script
tries to compile and run the following C program:

#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
main()
{
 /* XXX: check if the IPv6 implementation is not missing various pieces. */
 int dummy = IP6OPT_MINLEN;
 dummy = dummy;
 
 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
   return (1);
 else
   return (0);
}

If the compilation succeeds and the return value from running the
program is 0, then it assumes that you have working IPv6, and
HAVE_IPV6 is defined in config.h .
It could be that the above program is not the apppropriate IPv6
check in case of RedHat 9.0 (e.g, you could have IPv6 without
IP6OPT_MINLEN defined). As a quick and less-restricting test, you
can compile and run the following program:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
main()
{
  if (socket(AF_INET6, SOCK_STREAM, 0) < 0) {
    perror("Failed");
    return (1);
  } else {
    printf("OK\n");
    return (0);
  }
}

If it fails, then you indeed do not have IPv6 enabled.
If it succeeds, then please let me know and I will fix the original
IPv6 test.

Thanks,
Pavlin