41 memset(_probe, 0,
sizeof (_probe));
43 _has_response =
false;
65 void ProbeReply::_dissect()
67 _ip_buf = (
struct iphdr *) &_probe;
69 _src_addr_raw = _ip_buf->saddr;
70 _dst_addr_raw = _ip_buf->daddr;
93 void ProbeReply::_dissect_icmp(
int offset)
95 _icmp_buf = (
struct icmp*) &_probe[offset];
97 _code = _icmp_buf->icmp_type;
98 _subcode = _icmp_buf->icmp_code;
101 if (_code == ICMP_ECHOREPLY && _subcode == ICMP_ECHOREPLY)
103 _scan_result = ICMP_ECHOREPLY;
107 else if (_code == ICMP_DEST_UNREACH && _subcode == ICMP_PORT_UNREACH)
109 _scan_result = ICMP_PORT_UNREACH;
113 else if (_code == ICMP_TIME_EXCEEDED)
115 _scan_result = ICMP_TIME_EXCEEDED;
119 else if (_subcode == ICMP_UNREACH_HOST_PROHIB)
121 _scan_result = ICMP_UNREACH_HOST_PROHIB;
125 else if (_subcode == ICMP_PKT_FILTERED)
127 _scan_result = ICMP_PKT_FILTERED;
131 else if (_subcode == ICMP_PROT_UNREACH)
133 _scan_result = ICMP_PROT_UNREACH;
139 _scan_result = ICMP_DEST_UNREACH;
148 void ProbeReply::_dissect_iperror(
int offset)
150 _iperror_buf = (
struct iphdr *) &_probe[offset];
151 _dst_addr_raw = _iperror_buf->saddr;
154 void ProbeReply::_dissect_tcp(
int offset)
156 _tcp_buf = (
struct tcphdr *) &_probe[offset];
158 if (_tcp_buf->rst == 1)
163 else if (_tcp_buf->ack == 1 && _tcp_buf->syn == 1)
186 memcpy(_probe,
probe,MAX_PACKET);
208 return _src_addr_raw;
228 return _dst_addr_raw;
248 return _iperror_buf->daddr;
259 return _tcp_buf->dest;
279 _scan_result = result_scan;
289 return (
int)_ip_buf->protocol;
299 return (
int)_iperror_buf->protocol;
309 return ((uint16_t)_ip_buf->ihl)*32/8;
339 if (_scan_result < 0)
373 return &_probe[offset];
384 return &_probe[offset];
429 std::cout <<
"Printing details..." << std::endl;
431 std::cout <<
"\t Source address " <<
src_addr() << std::endl;
432 std::cout <<
"\t Destination address " <<
dst_addr() << std::endl;
433 std::cout <<
"\t IP protocol " <<
ip_protocol() << std::endl;
436 std::cout <<
"\t IPError Destination address " <<
iperror_dst_addr() << std::endl;
437 std::cout <<
"\t ICMP type " <<
code() << std::endl;
438 std::cout <<
"\t ICMP code " <<
subcode() << std::endl;
441 std::cout <<
"\t Code " <<
code() << std::endl;
446 std::cout <<
"\t Outer Options:" << std::endl;
454 std::cout <<
"\t Inner Options:" << std::endl;
462 std::cout <<
"No response obtained" << std::endl;
471 memset(_probe, 0,
sizeof (_probe));
473 _has_response =
false;