diff --git a/src/ConnCompressor.cc b/src/ConnCompressor.cc index 29e24457f5..16dd394c8c 100644 --- a/src/ConnCompressor.cc +++ b/src/ConnCompressor.cc @@ -641,7 +641,7 @@ const IP_Hdr* ConnCompressor::PendingConnToPacket(const PendingConn* c) int packet_length = sizeof(*ip) + sizeof(*tp); ip = (struct ip*) new char[packet_length]; tp = (struct tcphdr*) (((char*) ip) + sizeof(*ip)); - ip_hdr = new IP_Hdr(ip); + ip_hdr = new IP_Hdr(ip, true); // Constant fields. ip->ip_v = 4; diff --git a/src/Frag.cc b/src/Frag.cc index b72fac4b16..21abc324f8 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -125,7 +125,7 @@ void FragReassembler::AddFragment(double t, const IP_Hdr* ip, const u_char* pkt, void FragReassembler::Overlap(const u_char* b1, const u_char* b2, int n) { - IP_Hdr proto_h((const struct ip*) proto_hdr); + IP_Hdr proto_h(proto_hdr, false); if ( memcmp((const void*) b1, (const void*) b2, n) ) s->Weird("fragment_inconsistency", &proto_h); @@ -157,7 +157,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */) // can happen for benign reasons when we're // intermingling parts of two fragmented packets. - IP_Hdr proto_h((const struct ip*) proto_hdr); + IP_Hdr proto_h(proto_hdr, false); s->Weird("fragment_size_inconsistency", &proto_h); // We decide to analyze the contiguous portion now. @@ -171,7 +171,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */) else if ( last_block->upper > frag_size ) { - IP_Hdr proto_h((const struct ip*) proto_hdr); + IP_Hdr proto_h(proto_hdr, false); s->Weird("fragment_size_inconsistency", &proto_h); frag_size = last_block->upper; } @@ -214,7 +214,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */) } delete reassembled_pkt; - reassembled_pkt = new IP_Hdr(reassem4); + reassembled_pkt = new IP_Hdr(reassem4, true); DeleteTimer(); } diff --git a/src/IP.h b/src/IP.h index ba37fb4c69..36e8634912 100644 --- a/src/IP.h +++ b/src/IP.h @@ -9,23 +9,13 @@ class IP_Hdr { public: - IP_Hdr(struct ip* arg_ip4) - : ip4(arg_ip4), ip6(0), del(1) + IP_Hdr(const struct ip* arg_ip4, bool arg_del) + : ip4(arg_ip4), ip6(0), del(arg_del) { } - IP_Hdr(const struct ip* arg_ip4) - : ip4(arg_ip4), ip6(0), del(0) - { - } - - IP_Hdr(struct ip6_hdr* arg_ip6) - : ip4(0), ip6(arg_ip6), del(1) - { - } - - IP_Hdr(const struct ip6_hdr* arg_ip6) - : ip4(0), ip6(arg_ip6), del(0) + IP_Hdr(const struct ip6_hdr* arg_ip6, bool arg_del) + : ip4(0), ip6(arg_ip6), del(arg_del) { } @@ -90,7 +80,7 @@ public: private: const struct ip* ip4; const struct ip6_hdr* ip6; - int del; + bool del; }; #endif diff --git a/src/PIA.cc b/src/PIA.cc index 7417615566..9adb4ccab3 100644 --- a/src/PIA.cc +++ b/src/PIA.cc @@ -196,7 +196,7 @@ void PIA_TCP::FirstPacket(bool is_orig, const IP_Hdr* ip) ip4->ip_p = IPPROTO_TCP; // Cast to const so that it doesn't delete it. - ip4_hdr = new IP_Hdr((const struct ip*) ip4); + ip4_hdr = new IP_Hdr(ip4, false); } if ( is_orig ) diff --git a/src/PacketSort.cc b/src/PacketSort.cc index 67a0cf861f..d0e04a37ea 100644 --- a/src/PacketSort.cc +++ b/src/PacketSort.cc @@ -27,9 +27,9 @@ PacketSortElement::PacketSortElement(PktSrc* arg_src, { const struct ip* ip = (const struct ip*) (pkt + hdr_size); if ( ip->ip_v == 4 ) - ip_hdr = new IP_Hdr(ip); + ip_hdr = new IP_Hdr(ip, false); else - ip_hdr = new IP_Hdr((const struct ip6_hdr*) ip); + ip_hdr = new IP_Hdr((const struct ip6_hdr*) ip, false); if ( ip_hdr->NextProto() == IPPROTO_TCP && // Note: can't sort fragmented packets diff --git a/src/Serializer.h b/src/Serializer.h index 45575f7fa0..cd1199a340 100644 --- a/src/Serializer.h +++ b/src/Serializer.h @@ -415,7 +415,7 @@ public: } const IP_Hdr IP() const - { return IP_Hdr((struct ip *) (pkt + hdr_size)); } + { return IP_Hdr((struct ip *) (pkt + hdr_size), true); } void Describe(ODesc* d) const; diff --git a/src/Sessions.cc b/src/Sessions.cc index 908d091ace..3ab673d165 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -275,13 +275,13 @@ void NetSessions::NextPacket(double t, const struct pcap_pkthdr* hdr, const struct ip* ip = (const struct ip*) (pkt + hdr_size); if ( ip->ip_v == 4 ) { - IP_Hdr ip_hdr(ip); + IP_Hdr ip_hdr(ip, false); DoNextPacket(t, hdr, &ip_hdr, pkt, hdr_size); } else if ( ip->ip_v == 6 ) { - IP_Hdr ip_hdr((const struct ip6_hdr*) (pkt + hdr_size)); + IP_Hdr ip_hdr((const struct ip6_hdr*) (pkt + hdr_size), false); DoNextPacket(t, hdr, &ip_hdr, pkt, hdr_size); }