More code cleanup

This commit is contained in:
Daniel Thayer 2012-03-02 13:52:45 -06:00
parent 6eb9f63e17
commit 9d1e51a91e
3 changed files with 12 additions and 11 deletions

View file

@ -67,6 +67,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
default: default:
reporter->InternalError("unexpected IP proto in ICMP analyzer"); reporter->InternalError("unexpected IP proto in ICMP analyzer");
break;
} }
if ( chksum != 0xffff ) if ( chksum != 0xffff )
@ -108,7 +109,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
void ICMP_Analyzer::NextICMP4(double t, const struct icmp* icmpp, int len, int caplen, void ICMP_Analyzer::NextICMP4(double t, const struct icmp* icmpp, int len, int caplen,
const u_char*& data, const IP_Hdr* ip_hdr ) const u_char*& data, const IP_Hdr* ip_hdr )
{ {
switch ( icmpp->icmp_type ) switch ( icmpp->icmp_type )
{ {
case ICMP_ECHO: case ICMP_ECHO:
@ -119,10 +120,11 @@ void ICMP_Analyzer::NextICMP4(double t, const struct icmp* icmpp, int len, int c
case ICMP_UNREACH: case ICMP_UNREACH:
case ICMP_TIMXCEED: case ICMP_TIMXCEED:
Context4(t, icmpp, len, caplen, data, ip_hdr); Context4(t, icmpp, len, caplen, data, ip_hdr);
break; break;
default: default:
ICMPEvent(icmp_sent, icmpp, len, 0); break; ICMPEvent(icmp_sent, icmpp, len, 0);
break;
} }
} }
@ -257,6 +259,7 @@ TransportProto ICMP_Analyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32* s
default: default:
*src_port = *dst_port = ntohs(0); *src_port = *dst_port = ntohs(0);
break;
} }
return proto; return proto;
@ -350,7 +353,6 @@ RecordVal* ICMP_Analyzer::ExtractICMP6Context(int len, const u_char*& data)
src_addr = dst_addr = 0; src_addr = dst_addr = 0;
src_port = dst_port = 0; src_port = dst_port = 0;
} }
else else
{ {
ip_len = ip_hdr->TotalLen(); ip_len = ip_hdr->TotalLen();
@ -394,7 +396,6 @@ RecordVal* ICMP_Analyzer::ExtractICMP6Context(int len, const u_char*& data)
return iprec; return iprec;
} }
bool ICMP_Analyzer::IsReuse(double /* t */, const u_char* /* pkt */) bool ICMP_Analyzer::IsReuse(double /* t */, const u_char* /* pkt */)
{ {
return 0; return 0;
@ -534,11 +535,11 @@ void ICMP_Analyzer::Context4(double t, const struct icmp* icmpp,
{ {
case ICMP_UNREACH: case ICMP_UNREACH:
f = icmp_unreachable; f = icmp_unreachable;
break; break;
case ICMP_TIMXCEED: case ICMP_TIMXCEED:
f = icmp_error_message; f = icmp_error_message;
break; break;
} }
if ( f ) if ( f )

View file

@ -509,9 +509,9 @@ protected:
#define NUM_PORT_SPACES 4 #define NUM_PORT_SPACES 4
#define PORT_SPACE_MASK 0x30000 #define PORT_SPACE_MASK 0x30000
#define TCP_PORT_MASK 0x10000 #define TCP_PORT_MASK 0x10000
#define UDP_PORT_MASK 0x20000 #define UDP_PORT_MASK 0x20000
#define ICMP_PORT_MASK 0x30000 #define ICMP_PORT_MASK 0x30000
typedef enum { typedef enum {

View file

@ -122,7 +122,7 @@ int icmp6_checksum(const struct icmp* icmpp, const struct ip6_hdr* ip6, int len)
if ( len % 2 == 1 ) if ( len % 2 == 1 )
// Add in pad byte. // Add in pad byte.
sum += htons(((const u_char*) icmpp)[len - 1] << 8); sum = htons(((const u_char*) icmpp)[len - 1] << 8);
else else
sum = 0; sum = 0;