1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Support IPv6 UDP traceroute.

This commit is contained in:
david
2012-10-06 21:26:31 +00:00
parent cf0b55788f
commit 7830eb4db6

View File

@@ -559,7 +559,7 @@ struct probespec HostState::get_probe(const Target *target) {
(probe.type == PS_TCP || probe.type == PS_UDP || probe.type == PS_SCTP || probe.type == PS_ICMP)) { (probe.type == PS_TCP || probe.type == PS_UDP || probe.type == PS_SCTP || probe.type == PS_ICMP)) {
/* Nothing needed. */ /* Nothing needed. */
} else if (target->af() == AF_INET6 && } else if (target->af() == AF_INET6 &&
(probe.type == PS_TCP || probe.type == PS_ICMPV6)) { (probe.type == PS_TCP || probe.type == PS_UDP || probe.type == PS_ICMPV6)) {
/* Nothing needed. */ /* Nothing needed. */
} else if (target->af() == AF_INET && probe.type == PS_PROTO) { } else if (target->af() == AF_INET && probe.type == PS_PROTO) {
/* If this is an IP protocol probe, fill in some fields for some common /* If this is an IP protocol probe, fill in some fields for some common
@@ -744,18 +744,25 @@ public:
unsigned char *build_packet(const struct sockaddr_storage *source, u32 *len) const { unsigned char *build_packet(const struct sockaddr_storage *source, u32 *len) const {
const char *payload; const char *payload;
size_t payload_length; size_t payload_length;
const struct sockaddr_in *sin;
assert(source->ss_family == AF_INET);
sin = (struct sockaddr_in *) source;
payload = get_udp_payload(pspec.pd.udp.dport, &payload_length); payload = get_udp_payload(pspec.pd.udp.dport, &payload_length);
/* For UDP we encode the token in the source port. */ /* For UDP we encode the token in the source port. */
return build_udp_raw(&sin->sin_addr, host->target->v4hostip(), ttl, if (source->ss_family == AF_INET) {
get_random_u16(), get_random_u8(), false, NULL, 0, const struct sockaddr_in *sin = (struct sockaddr_in *) source;
token ^ global_id, pspec.pd.udp.dport, return build_udp_raw(&sin->sin_addr, host->target->v4hostip(), ttl,
payload, payload_length, len); get_random_u16(), get_random_u8(), false, NULL, 0,
token ^ global_id, pspec.pd.udp.dport,
payload, payload_length, len);
} else if (source->ss_family == AF_INET6) {
const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) source;
return build_udp_raw_ipv6(&sin6->sin6_addr, host->target->v6hostip(),
0, 0, ttl,
token ^ global_id, pspec.pd.udp.dport,
payload, payload_length, len);
} else {
fatal("Unknown address family %u in %s.", source->ss_family, __func__);
}
} }
}; };