hercules-390 / hyperion

Hercules 390
Other
246 stars 69 forks source link

IPV6 headers are never included when building Hercules #223

Open srorso opened 7 years ago

srorso commented 7 years ago

Either of two possible IPV6 headers are listed for inclusion in hifr.h. However, neither ever is, and hifr.h uses its own in6_ifreq structure definition instead.

Based on tests performed by configure.ac, linux/ipv6.h is the appropriate IPV6 header for On Linux systems, and the header is netinet6/in6_var.h on BSD systems, presumably including Apple.

In hifr.h line 50, ENABLE_IPV6 is first tested. If not defined, all IPV6 stuff is skipped. So far so good. Then we get to preprocessor code starting at line 51:

  #if defined(HAVE_IN6_IFREQ_IFR6_ADDR)
    #if defined(HAVE_LINUX_IPV6_H)
      #include <linux/ipv6.h>
    #elif defined(HAVE_NETINET6_IN6_VAR_H)
      #include <netinet6/in6_var.h>
    #else
      #error HAVE_IN6_IFREQ_IFR6_ADDR is defined but which header to include is undefined!
    #endif
  #else /*!defined(HAVE_IN6_IFREQ_IFR6_ADDR)*/
    struct in6_ifreq {
        struct in6_addr  ifr6_addr;
        U32              ifr6_prefixlen;
        int              ifr6_ifindex;
    };

Unfortunately, HAVE_IN6_IFREQ_IFR6_ADDR is never defined. The result of the structure member test in configure.ac is HAVE_STRUCT_IN6_IFREQ_IFR6_ADDR, and that macro is only defined on Linux systems.

On BSD systems, a different structure is tested and the result stored in HAVE_STRUCT_IN6_IFREQ_IFR_IFRU_IFRU_FLAGS. Though that macro is never referenced in the Hercules source. Nor is the correspondingly incorrect HAVE_IN6_IFREQ_IFR_IFRU_IFRU_FLAGS.

So for Windows, Linux, and BSD, Hercules uses its own structure.

I lack the testing expertise and infrastructure to correct this. The diagnosis above is based solely on inferences drawn from code and comments in configure.ac, which spends quite a bit of time (~95 lines) figuring out which IPV6 header to include.

Because Hercules seems to work using its own structure, I plan to remove the tests from the CMake build. This issue is for the benefit of those with IPV6 skills and stuff that uses IPV6 connections. I will take a look at the other headers that are tested on the way to deciding which IPV6 headers to include.

And should some intrepid IPV6'er make and test the needed corrections for BSD and Linux to hifr.h, I can code what turns out to be needed in CMake.