mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 17:59:04 +00:00
Consider an address directly connected if the gateway of its matching routing
table is exactly the same as the address. This is how it appears to work on Mac OS X. Now there are three ways for an address to be directly connected: 1. Gateway address is 0.0.0.0 (Linux). 2. Gateway address is the same as local interface address (Windows). 3. Gateway address is the same as the destination address (Mac OS X).
This commit is contained in:
6
tcpip.cc
6
tcpip.cc
@@ -3668,9 +3668,11 @@ bool route_dst(const struct sockaddr_storage * const dst,
|
||||
rnfo->ii = *routes[i].device;
|
||||
/* At this point we don't whether this route is direct or indirect ("G" flag
|
||||
in netstat). We guess that a route is direct when the gateway address is
|
||||
0.0.0.0 or it exactly matches the interface address. */
|
||||
0.0.0.0, when it exactly matches the interface address, or when it
|
||||
exactly matches the destination address. */
|
||||
rnfo->direct_connect = (routes[i].gw.s_addr == 0) ||
|
||||
(routes[i].gw.s_addr == ((struct sockaddr_in *) &routes[i].device->addr)->sin_addr.s_addr);
|
||||
(routes[i].gw.s_addr == ((struct sockaddr_in *) &routes[i].device->addr)->sin_addr.s_addr) ||
|
||||
(routes[i].gw.s_addr == dstsin->sin_addr.s_addr);
|
||||
if (!o.spoofsource)
|
||||
rnfo->srcaddr = routes[i].device->addr;
|
||||
ifsin = (struct sockaddr_in *) &rnfo->nexthop;
|
||||
|
||||
Reference in New Issue
Block a user