From 9ab82ecedf26742a60793df4e0a3af960803aa9f Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 6 Aug 2015 21:10:36 +0000 Subject: [PATCH] Fix raw packet sending on FreeBSD 10.0 and later. See https://svnweb.freebsd.org/base?view=revision&revision=241913 for the change. Closes #196. Fixes #50. --- CHANGELOG | 4 ++++ libnetutil/netutil.cc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ba244deab..dede1fa80 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o [GH#196] Fix raw packet sending on FreeBSD 10.0 and later. FreeBSD changed + byte order of the IPv4 stack, so SYN scan and other raw packet functions were + broken. [Edward NapieraƂa] Also reported in [GH#50] by Olli Hauer. + o [NSE] Added script http-svn-enum. Enumerates users of a Subversion repostory by examinning commit logs. [Gyanendra Mishra] diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index f4c31184b..e7dca1913 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -3604,7 +3604,7 @@ int send_ip_packet_sd(int sd, const struct sockaddr_in *dst, must deal with it here rather than when building the packet, because they should be in NBO when I'm sending over raw ethernet */ -#if FREEBSD || BSDI || NETBSD || DEC || MACOSX +#if (defined(FREEBSD) && (__FreeBSD_version < 1000022)) || BSDI || NETBSD || DEC || MACOSX ip->ip_len = ntohs(ip->ip_len); ip->ip_off = ntohs(ip->ip_off); #endif @@ -3614,7 +3614,7 @@ int send_ip_packet_sd(int sd, const struct sockaddr_in *dst, (int) sizeof(struct sockaddr_in)); /* Undo the byte order switching. */ -#if FREEBSD || BSDI || NETBSD || DEC || MACOSX +#if (defined(FREEBSD) && (__FreeBSD_version < 1000022)) || BSDI || NETBSD || DEC || MACOSX ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); #endif