mirror of
https://github.com/nmap/nmap.git
synced 2025-12-12 02:39:03 +00:00
Allow use of Windows' own inet_pton and inet_ntop functions
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "nbase.h"
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@@ -249,3 +251,5 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
|
||||
return (dst);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef HAVE_INET_NTOP */
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "nbase.h"
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@@ -243,3 +245,5 @@ inet_pton6(const char *src, unsigned char *dst)
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef HAVE_INET_PTON */
|
||||
|
||||
@@ -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
|
||||
/* <wspiapi.h> only comes with Visual Studio. */
|
||||
#define HAVE_WSPIAPI_H 1
|
||||
|
||||
6
tcpip.cc
6
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],
|
||||
|
||||
Reference in New Issue
Block a user