diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index b706885b7..5460a16e2 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -2294,9 +2294,9 @@ const char *ippackethdrinfo(const u8 *packet, u32 len, int detail) { /* Obtain IP source and destination info */ sin = (struct sockaddr_in *) &hdr.src; - inet_ntop(AF_INET, &sin->sin_addr.s_addr, srchost, sizeof(srchost)); + inet_ntop(AF_INET, (void *)&sin->sin_addr.s_addr, srchost, sizeof(srchost)); sin = (struct sockaddr_in *) &hdr.dst; - inet_ntop(AF_INET, &sin->sin_addr.s_addr, dsthost, sizeof(dsthost)); + inet_ntop(AF_INET, (void *)&sin->sin_addr.s_addr, dsthost, sizeof(dsthost)); /* Compute fragment offset and check if flags are set */ frag_off = 8 * (ntohs(ip->ip_off) & 8191) /* 2^13 - 1 */; @@ -2348,9 +2348,9 @@ const char *ippackethdrinfo(const u8 *packet, u32 len, int detail) { /* Obtain IP source and destination info */ sin6 = (struct sockaddr_in6 *) &hdr.src; - inet_ntop(AF_INET6, sin6->sin6_addr.s6_addr, srchost, sizeof(srchost)); + inet_ntop(AF_INET6, (void *)sin6->sin6_addr.s6_addr, srchost, sizeof(srchost)); sin6 = (struct sockaddr_in6 *) &hdr.dst; - inet_ntop(AF_INET6, sin6->sin6_addr.s6_addr, dsthost, sizeof(dsthost)); + inet_ntop(AF_INET6, (void *)sin6->sin6_addr.s6_addr, dsthost, sizeof(dsthost)); /* Obtain flow label and traffic class */ u32 flow = ntohl(ip6->ip6_flow); diff --git a/nbase/inet_ntop.c b/nbase/inet_ntop.c index 3f608cdfe..da2562345 100644 --- a/nbase/inet_ntop.c +++ b/nbase/inet_ntop.c @@ -22,6 +22,8 @@ #include "nbase.h" +#ifndef HAVE_INET_NTOP + #if HAVE_SYS_TYPES_H #include #endif @@ -249,3 +251,5 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size) return (dst); } #endif + +#endif /* ifndef HAVE_INET_NTOP */ diff --git a/nbase/inet_pton.c b/nbase/inet_pton.c index 2f47e5559..cef18cf04 100644 --- a/nbase/inet_pton.c +++ b/nbase/inet_pton.c @@ -22,6 +22,8 @@ #include "nbase.h" +#ifndef HAVE_INET_PTON + #if HAVE_SYS_TYPES_H #include #endif @@ -243,3 +245,5 @@ inet_pton6(const char *src, unsigned char *dst) return (1); } #endif + +#endif /* ifndef HAVE_INET_PTON */ diff --git a/nbase/nbase_winconfig.h b/nbase/nbase_winconfig.h index 425b9b5e7..3dd26638f 100644 --- a/nbase/nbase_winconfig.h +++ b/nbase/nbase_winconfig.h @@ -152,6 +152,12 @@ #define HAVE_SYS_STAT_H 1 /* #define HAVE_INTTYPES_H */ +/* These functions are available on Vista and later */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN6 +#define HAVE_INET_PTON 1 +#define HAVE_INET_NTOP 1 +#endif + #ifdef _MSC_VER /* only comes with Visual Studio. */ #define HAVE_WSPIAPI_H 1 diff --git a/tcpip.cc b/tcpip.cc index d6618d49c..ec774eafa 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -235,11 +235,11 @@ void PacketTrace::traceArp(pdirection pdir, const u8 *frame, u32 len, } if (frame[7] == 1) { /* arp REQUEST */ - inet_ntop(AF_INET, frame + 24, who_has, sizeof(who_has)); - inet_ntop(AF_INET, frame + 14, tell, sizeof(tell)); + inet_ntop(AF_INET, (void *)(frame + 24), who_has, sizeof(who_has)); + inet_ntop(AF_INET, (void *)(frame + 14), tell, sizeof(tell)); Snprintf(arpdesc, sizeof(arpdesc), "who-has %s tell %s", who_has, tell); } else { /* ARP REPLY */ - inet_ntop(AF_INET, frame + 14, who_has, sizeof(who_has)); + inet_ntop(AF_INET, (void *)(frame + 14), who_has, sizeof(who_has)); Snprintf(arpdesc, sizeof(arpdesc), "reply %s is-at %02X:%02X:%02X:%02X:%02X:%02X", who_has, frame[8], frame[9], frame[10], frame[11], frame[12],