mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +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:
parent
a4c92f83e7
commit
7eb63c1c2d
1 changed files with 9 additions and 2 deletions
11
tcpip.cc
11
tcpip.cc
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue