mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
Use the dnet.h defiens for ICMP types and codes instead of having ad-hoc
defines in traceroute.h.
This commit is contained in:
@@ -151,8 +151,8 @@
|
|||||||
* Hops 1-10 are the same as for X.X.X.X
|
* Hops 1-10 are the same as for X.X.X.X
|
||||||
*
|
*
|
||||||
* Traceroute does not work with connect scans or idle scans and has trouble
|
* Traceroute does not work with connect scans or idle scans and has trouble
|
||||||
* with ICMP_TIMESTAMP and ICMP_ADDRESSMASK scans because so many host filter
|
* with ICMP_TSTAMP and ICMP_MASK scans because so many host filter them out.
|
||||||
* them out. The quickest seems to be SYN scan.
|
* The quickest seems to be SYN scan.
|
||||||
*
|
*
|
||||||
* Bugs
|
* Bugs
|
||||||
* ----
|
* ----
|
||||||
@@ -171,6 +171,7 @@
|
|||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <dnet.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -305,7 +306,7 @@ Traceroute::readTraceResponses() {
|
|||||||
sport = ntohs(icmp->icmp_id);
|
sport = ntohs(icmp->icmp_id);
|
||||||
|
|
||||||
/* Process ICMP replies that encapsulate our original probe */
|
/* Process ICMP replies that encapsulate our original probe */
|
||||||
if (icmp->icmp_type == ICMP_DEST_UNREACH || icmp->icmp_type == ICMP_TIME_EXCEEDED) {
|
if (icmp->icmp_type == ICMP_UNREACH || icmp->icmp_type == ICMP_TIMEXCEED) {
|
||||||
if ((unsigned) ip->ip_hl * 4 + 28 > bytes)
|
if ((unsigned) ip->ip_hl * 4 + 28 > bytes)
|
||||||
break;
|
break;
|
||||||
ip2 = (struct ip *) (((char *) ip) + 4 * ip->ip_hl + 8);
|
ip2 = (struct ip *) (((char *) ip) + 4 * ip->ip_hl + 8);
|
||||||
@@ -349,16 +350,16 @@ Traceroute::readTraceResponses() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if ((tg->probe.proto == IPPROTO_UDP && (ip2 && ip2->ip_p == IPPROTO_UDP)) ||
|
if ((tg->probe.proto == IPPROTO_UDP && (ip2 && ip2->ip_p == IPPROTO_UDP)) ||
|
||||||
(icmp->icmp_type == ICMP_DEST_UNREACH)) {
|
(icmp->icmp_type == ICMP_UNREACH)) {
|
||||||
switch (icmp->icmp_code) {
|
switch (icmp->icmp_code) {
|
||||||
/* reply from a closed port */
|
/* reply from a closed port */
|
||||||
case ICMP_PORT_UNREACH:
|
case ICMP_UNREACH_PORT:
|
||||||
/* replies from a filtered port */
|
/* replies from a filtered port */
|
||||||
case ICMP_HOST_UNREACH:
|
case ICMP_UNREACH_HOST:
|
||||||
case ICMP_PROT_UNREACH:
|
case ICMP_UNREACH_PROTO:
|
||||||
case ICMP_NET_ANO:
|
case ICMP_UNREACH_NET_PROHIB:
|
||||||
case ICMP_HOST_ANO:
|
case ICMP_UNREACH_HOST_PROHIB:
|
||||||
case ICMP_PKT_FILTERED:
|
case ICMP_UNREACH_FILTER_PROHIB:
|
||||||
if (tp->probeType() == PROBE_TTL) {
|
if (tp->probeType() == PROBE_TTL) {
|
||||||
tg->setHopDistance(o.ttl - ip2->ip_ttl, 0);
|
tg->setHopDistance(o.ttl - ip2->ip_ttl, 0);
|
||||||
tg->start_ttl = tg->ttl = tg->hopDistance;
|
tg->start_ttl = tg->ttl = tg->hopDistance;
|
||||||
@@ -371,7 +372,7 @@ Traceroute::readTraceResponses() {
|
|||||||
}
|
}
|
||||||
/* icmp ping scan replies */
|
/* icmp ping scan replies */
|
||||||
else if (tg->probe.proto == IPPROTO_ICMP && (icmp->icmp_type == ICMP_ECHOREPLY ||
|
else if (tg->probe.proto == IPPROTO_ICMP && (icmp->icmp_type == ICMP_ECHOREPLY ||
|
||||||
icmp->icmp_type == ICMP_ADDRESSREPLY || icmp->icmp_type == ICMP_TIMESTAMPREPLY)) {
|
icmp->icmp_type == ICMP_MASKREPLY || icmp->icmp_type == ICMP_TSTAMPREPLY)) {
|
||||||
if (tp->probeType() == PROBE_TTL) {
|
if (tp->probeType() == PROBE_TTL) {
|
||||||
tg->setHopDistance(get_initial_ttl_guess(ip->ip_ttl), ip->ip_ttl);
|
tg->setHopDistance(get_initial_ttl_guess(ip->ip_ttl), ip->ip_ttl);
|
||||||
tg->start_ttl = tg->ttl = tg->hopDistance;
|
tg->start_ttl = tg->ttl = tg->hopDistance;
|
||||||
|
|||||||
43
traceroute.h
43
traceroute.h
@@ -118,49 +118,6 @@
|
|||||||
|
|
||||||
#define NAMEIPLEN MAXHOSTNAMELEN+INET6_ADDRSTRLEN
|
#define NAMEIPLEN MAXHOSTNAMELEN+INET6_ADDRSTRLEN
|
||||||
|
|
||||||
#ifndef ICMP_ECHOREPLY
|
|
||||||
#define ICMP_ECHOREPLY 0
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_DEST_UNREACH
|
|
||||||
#define ICMP_DEST_UNREACH 3
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_ECHO
|
|
||||||
#define ICMP_ECHO 8
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_TIME_EXCEEDED
|
|
||||||
#define ICMP_TIME_EXCEEDED 11
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_TIMESTAMP
|
|
||||||
#define ICMP_TIMESTAMP 13
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_TIMESTAMPREPLY
|
|
||||||
#define ICMP_TIMESTAMPREPLY 14
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_ADDRESS
|
|
||||||
#define ICMP_ADDRESS 17
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_ADDRESSREPLY
|
|
||||||
#define ICMP_ADDRESSREPLY 18
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_HOST_UNREACH
|
|
||||||
#define ICMP_HOST_UNREACH 1
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_PROT_UNREACH
|
|
||||||
#define ICMP_PROT_UNREACH 2
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_PORT_UNREACH
|
|
||||||
#define ICMP_PORT_UNREACH 3
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_NET_ANO
|
|
||||||
#define ICMP_NET_ANO 9
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_HOST_ANO
|
|
||||||
#define ICMP_HOST_ANO 10
|
|
||||||
#endif
|
|
||||||
#ifndef ICMP_PKT_FILTERED
|
|
||||||
#define ICMP_PKT_FILTERED 13
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class NmapOutputTable;
|
class NmapOutputTable;
|
||||||
|
|
||||||
/* Keeps track of each probes timing state */
|
/* Keeps track of each probes timing state */
|
||||||
|
|||||||
Reference in New Issue
Block a user