1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 11:29:01 +00:00

On some BSD systems, we have to byte-swap the ip_len and ip_off fields before

sending. In send_ip_packet, unswap them after sending so that the buffer is
returned unmodified. Do the packet trace after unswapping the values so that
the correct length and fragmentation offset are reported. On Mac OS X, an
ip_len of 60 (0x003c) was being reported as 15360 (0x3c00) and when ip_off had
the DF flag set (0x4000), it looked like a fragmentation offset of 512
(0x0040 * 8).
This commit is contained in:
david
2009-07-03 18:27:31 +00:00
parent a4c92f83e7
commit 7eb63c1c2d

View File

@@ -1370,8 +1370,6 @@ do {
retries++;
} while( res == -1);
PacketTrace::trace(PacketTrace::SENT, packet, len);
return res;
}
@@ -1442,6 +1440,15 @@ int send_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, unsigned int packetl
res = Sendto("send_ip_packet", sd, packet, packetlen, 0,
(struct sockaddr *)&sock, (int)sizeof(struct sockaddr_in));
/* Undo the byte order switching. */
#if FREEBSD || BSDI || NETBSD || DEC || MACOSX
ip->ip_len = htons(ip->ip_len);
ip->ip_off = htons(ip->ip_off);
#endif
PacketTrace::trace(PacketTrace::SENT, packet, packetlen);
return res;
}