1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 00:19:01 +00:00

Make -e assign IPv6 scope ids for everything, not only route_dst.

You could use "-e en0" to automatically add scope ids to your IPv6
addresses, so you didn't need the write "fe80::1234%en0". But this only
happened for the route_dst calculation, and could lead to later failures
in sendmsg when the address didn't have a scope id.
This commit is contained in:
david
2012-03-27 21:48:53 +00:00
parent e362a434f3
commit 652fb94405
2 changed files with 23 additions and 22 deletions

View File

@@ -2013,34 +2013,16 @@ pcap_if_t *getpcapinterfaces() {
/* Assign the sin6_scope_id member of a sockaddr_in6, based on a device name.
This is used to assign scope to all addresses with the -e option is used. */
static void assign_scope_id(struct sockaddr_in6 *sin6, const char *devname) {
struct interface_info *ii;
if (devname == NULL || devname[0] == '\0')
return;
ii = getInterfaceByName(devname, sin6->sin6_family);
if (ii != NULL)
sin6->sin6_scope_id = ii->ifindex;
}
int nmap_route_dst(const struct sockaddr_storage *dst, struct route_nfo *rnfo) {
struct sockaddr_storage dst_mod, spoofss;
struct sockaddr_storage spoofss;
size_t spoofsslen;
/* Make a copy that we may modify (only to possibly add a sin6_scope_id). */
dst_mod = *dst;
if (dst_mod.ss_family == AF_INET6)
assign_scope_id((struct sockaddr_in6 *) &dst_mod, o.device);
if (o.spoofsource) {
o.SourceSockAddr(&spoofss, &spoofsslen);
return route_dst(&dst_mod, rnfo, o.device, &spoofss);
return route_dst(dst, rnfo, o.device, &spoofss);
} else {
return route_dst(&dst_mod, rnfo, o.device, NULL);
return route_dst(dst, rnfo, o.device, NULL);
}
}