diff --git a/virtualsmartcard/configure.ac b/virtualsmartcard/configure.ac index fbf7d55..204d0b3 100644 --- a/virtualsmartcard/configure.ac +++ b/virtualsmartcard/configure.ac @@ -203,6 +203,15 @@ AC_TYPE_SIZE_T AC_TYPE_UINT16_T AC_CHECK_DECLS([SO_NOSIGPIPE], [], [], [#include ]) AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [#include ]) +if test "${WIN32}" = "yes" +then + saved_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600" + AC_CHECK_DECLS([inet_ntop], [], [], [#include ]) + CPPFLAGS="$saved_CPPFLAGS" +else + AC_CHECK_DECLS([inet_ntop], [], [], [#include ]) +fi # Checks for library functions. AC_FUNC_MALLOC diff --git a/virtualsmartcard/src/vpcd-config/Makefile.am b/virtualsmartcard/src/vpcd-config/Makefile.am index 6a16c0f..7a19d45 100644 --- a/virtualsmartcard/src/vpcd-config/Makefile.am +++ b/virtualsmartcard/src/vpcd-config/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = qransi.c +EXTRA_DIST = qransi.c inet_ntop.c bin_PROGRAMS = vpcd-config diff --git a/virtualsmartcard/src/vpcd-config/inet_ntop.c b/virtualsmartcard/src/vpcd-config/inet_ntop.c new file mode 100644 index 0000000..9d701e3 --- /dev/null +++ b/virtualsmartcard/src/vpcd-config/inet_ntop.c @@ -0,0 +1,15 @@ +/* Taken from https://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/ */ + +const char* inet_ntop(int af, const void* src, char* dst, int cnt){ + + struct sockaddr_in srcaddr; + + memset(&srcaddr, 0, sizeof(struct sockaddr_in)); + memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); + + srcaddr.sin_family = af; + if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) { + return NULL; + } + return dst; +} diff --git a/virtualsmartcard/src/vpcd-config/local-ip.c b/virtualsmartcard/src/vpcd-config/local-ip.c index 1fcd89f..3a71849 100644 --- a/virtualsmartcard/src/vpcd-config/local-ip.c +++ b/virtualsmartcard/src/vpcd-config/local-ip.c @@ -5,6 +5,9 @@ * Use getsockname and a udp connection */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include //printf #include //memset #include //errno @@ -12,6 +15,9 @@ #ifdef _WIN32 #include #include +#if defined(HAVE_DECL_INET_NTOP) && ! HAVE_DECL_INET_NTOP +#include"inet_ntop.c" +#endif #define close(s) closesocket(s) #else #include //socket