From 50368778655eb90fa834413a4152367e2f8eb929 Mon Sep 17 00:00:00 2001 From: kris Date: Fri, 2 Feb 2007 02:33:20 +0000 Subject: [PATCH] Remove some duplication in get_pcap_result() in scan_engine.cc. probe->protocol() is all ready checked against ip2->ip_p earlier (the two I'm removing indirectly check against ip2->ip_p: look at the removed part and what ip2->ip_p is tested against in the surrounding if()s). Then a little lower in the function, that whole if() block can be removed because it's the same as what's done in that switch() block. The same error() and hdump() are used in the default case. I could've kept the if(), but this keeps is simple. --- scan_engine.cc | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index 796e881db..4e49ec81d 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3034,16 +3034,14 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) { if (ip2->ip_p == IPPROTO_TCP && !USI->prot_scan) { tcp = (struct tcp_hdr *) ((u8 *) ip2 + ip2->ip_hl * 4); - if (probe->protocol() != IPPROTO_TCP || - ntohs(tcp->th_sport) != probe->sport() || + if (ntohs(tcp->th_sport) != probe->sport() || ntohs(tcp->th_dport) != probe->dport() || ntohl(tcp->th_seq) != probe->tcpseq()) continue; } else if (ip2->ip_p == IPPROTO_UDP && !USI->prot_scan) { /* TODO: IPID verification */ udp = (struct udp_hdr *) ((u8 *) ip2 + ip->ip_hl * 4); - if (probe->protocol() != IPPROTO_UDP || - ntohs(udp->uh_sport) != probe->sport() || + if (ntohs(udp->uh_sport) != probe->sport() || ntohs(udp->uh_dport) != probe->dport()) continue; } else if (!USI->prot_scan) { @@ -3051,16 +3049,6 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) { } if (icmp->icmp_type == 3) { - if (icmp->icmp_code != 0 && icmp->icmp_code != 1 && - icmp->icmp_code != 2 && - icmp->icmp_code != 3 && icmp->icmp_code != 9 && - icmp->icmp_code != 10 && icmp->icmp_code != 13) { - error("Unexpected ICMP type/code 3/%d unreachable packet:", - icmp->icmp_code); - hdump((unsigned char *)icmp, ntohs(ip->ip_len) - - sizeof(struct ip)); - break; - } switch(icmp->icmp_code) { case 0: /* Network unreachable */ newstate = PORT_FILTERED;