Guys,

Dave Hart wrote:
> I also note ports/winnt/include/config.h has this bit:
> 
> /*
>  * VS.NET's version of wspiapi.h has a bug in it
>  * where it assigns a value to a variable inside
>  * an if statement. It should be comparing them.
>  * We prevent inclusion since we are not using this
>  * code so we don't have to see the warning messages
>  */
> #ifndef _WSPIAPI_H_
> #define _WSPIAPI_H_
> #endif
> 
> Given that ISC already has its own preferred implementation of
> getaddrinfo and friends and the issues with the wspiapi.h
> implementation, using the ISC stuff makes sense.  It would be nice to
> look for the functions in whsip6.dll after checking ws2_32.dll for
> them, so that any lingering Windows 2000 IPv6 users are equally
> served.
> 
> Cheers,
> Dave Hart

Here are a few thoughts:

1.) The NTP code tries to use getaddrinfo() and friends if possible, and
provides basic versions of those functions for target environments which
don't provide those functions.

2.) For Unix versions NTP is normally distributed as source code and
compiled for a specific target OS and target OS version, so the ./configure
script determines whether getaddrinfo() etc. are available on that target
platform and uses either the target functions or the built-in functions as
appropriate.

3.) The Windows version of NTP is mostly distributed as precompiled
binaries, so the program (e.g. ntpd) has to determine at runtime whether
the specific version it is currently running on provides that functions, or
not. This can be handled using late binding of DLL functions, i.e. call
getaddrinfo() and friends via function pointers. If a binary starts on a
specific Windows version it can test whether the target OS supports those
functions. If it does it can let the function pointers point to the
exported functions. If it does not then the pointers can be set to the
built-in function. As already mentione earlier I had implemented this
already for the xmas version back in 2005, but this was never accepted for
the public source code base.

4.) One more thing is the build environment. Depending on the compiler
version and installed header files (SDK available or not) the definitions
required to use getaddrinfo() etc. may be available or not at compile time.
If they are not then the NTP source code also provides the required
definitions. For example, if we build with VC6 without SDK then we have to
use the definitions coming with NTP.

5.) Finally, in order to be able to distribute a single binary which can be
run on Windows with or without support for IPv6 the program fully needs to
check at runtime whether IPv6 support is available, or not. I.e. it first
has to try to import getaddrinfo() and friends from the OS, then call those
functions in order to check whether IPv6 is supported. The current code
already does the check but makes many assumptions just depending on the
compiler version instead of checking whether some declarations are
available after the header files have been imported.


Martin
-- 
Martin Burnicki

Meinberg Funkuhren
Bad Pyrmont
Germany

_______________________________________________
questions mailing list
questions@lists.ntp.org
https://lists.ntp.org/mailman/listinfo/questions

Reply via email to