]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
additional more ntohs and htons to protocol header files
authorJosh <jrosenba@cisco.com>
Thu, 23 Oct 2014 23:56:45 +0000 (18:56 -0500)
committerJosh <jrosenba@cisco.com>
Thu, 23 Oct 2014 23:56:45 +0000 (18:56 -0500)
24 files changed:
CMakeLists.txt
src/codecs/ip/cd_ipv4.cc
src/codecs/ip/cd_ipv6.cc
src/codecs/ip/cd_tcp.cc
src/codecs/ip/cd_udp.cc
src/codecs/misc/cd_icmp4_ip.cc
src/codecs/misc/cd_icmp6_ip.cc
src/log/log_text.cc
src/loggers/alert_csv.cc
src/managers/codec_manager.h
src/network_inspectors/normalize/norm.cc
src/network_inspectors/port_scan/port_scan.cc
src/protocols/ip.cc
src/protocols/ip.h
src/protocols/ipv4.h
src/protocols/ipv6.h
src/protocols/layer.cc
src/protocols/layer.h
src/protocols/packet_manager.cc
src/protocols/tcp.h
src/stream/ip/ip_defrag.cc
src/stream/tcp/tcp_session.cc
tools/snort2lua/config_states/config_binding.cc
tools/snort2lua/preprocessor_states/pps_normalizers.cc

index 4b12495c297914914c9ddb446c9a0a22f4d2a7e7..dc44b4852423f3d81e0a73e5b07d76ed201d9067 100644 (file)
@@ -1,5 +1,5 @@
 
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 2.9)
 project (snort CXX C)
 
 set (SNORT_VERSION_MAJOR 2)
index d78d5e333f0485b4b45b4bfa1d8509cd544e7e54..4a86ee68a929f07b42ed0cac9f2b91acc5d2b462 100644 (file)
@@ -182,7 +182,7 @@ bool Ipv4Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
      * with datalink DLT_RAW it's impossible to differ ARP datagrams from IP.
      * So we are just ignoring non IP datagrams
      */
-    if (iph->get_ver() != 4)
+    if (iph->ver() != 4)
     {
         if ((codec.codec_flags & CODEC_UNSURE_ENCAP) == 0)
             codec_events::decoder_event(codec, DECODE_NOT_IPV4_DGRAM);
@@ -190,8 +190,8 @@ bool Ipv4Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
     }
 
     /* get the IP datagram length */
-    ip_len = ntohs(iph->ip_len);
-    hlen = iph->get_hlen() << 2;
+    ip_len = iph->len();
+    hlen = iph->hlen();
 
     /* header length sanity check */
     if(hlen < ip::IP4_HEADER_LEN)
@@ -592,7 +592,7 @@ void Ipv4Codec::log(TextLog* const text_log, const uint8_t* raw_pkt,
     TextLog_Putc(text_log, '\t');
 
 
-    const uint16_t hlen = ip4h->get_hlen() << 2;
+    const uint16_t hlen = ip4h->hlen();
     const uint16_t len = ip4h->len();
     const uint16_t frag_off = ip4h->off();
 
@@ -702,7 +702,7 @@ bool Ipv4Codec::update(Packet* p, Layer* lyr, uint32_t* len)
 {
     IP4Hdr* h = (IP4Hdr*)(lyr->start);
     int i = lyr - p->layers;
-    uint16_t hlen = h->get_hlen() << 2;
+    uint16_t hlen = h->hlen();
 
     *len += hlen;
 
@@ -710,7 +710,7 @@ bool Ipv4Codec::update(Packet* p, Layer* lyr, uint32_t* len)
         *len += p->dsize;
 
 
-    h->set_ip_len(htons((uint16_t)*len));
+    h->set_ip_len((uint16_t)*len);
 
 
     if ( !PacketWasCooked(p) || (p->packet_flags & PKT_REBUILT_FRAG) )
@@ -738,7 +738,7 @@ void Ipv4Codec::format(EncodeFlags f, const Packet* p, Packet* c, Layer* lyr)
     if ( f & ENC_FLAG_DEF )
     {
         lyr->length = ip::IP4_HEADER_LEN;
-        ch->set_ip_len(htons(ip::IP4_HEADER_LEN));
+        ch->set_ip_len(ip::IP4_HEADER_LEN);
         ch->set_hlen(ip::IP4_HEADER_LEN >> 2);
 
 #if 0
@@ -747,7 +747,7 @@ void Ipv4Codec::format(EncodeFlags f, const Packet* p, Packet* c, Layer* lyr)
         if ( i + 1 == p->num_layers )
         {
             lyr->length = ip::IP4_HEADER_LEN;
-            ch->set_ip_len(htons(ip::IP4_HEADER_LEN));
+            ch->set_ip_len(ip::IP4_HEADER_LEN);
             ch->set_hlen(ip::IP4_HEADER_LEN >> 2);
         }
 #endif
index 0cc96b85fb831d02d1100de6c789d1cf8c797a7c..3dc9fcc1febd6c80697e179a0a001a84fa33d489 100644 (file)
@@ -144,7 +144,7 @@ bool Ipv6Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
 
 
         /* Verify version in IP6 Header agrees */
-        if(ip6h->get_ver() != 6)
+        if(ip6h->ver() != 6)
         {
             if ((codec.codec_flags & CODEC_UNSURE_ENCAP) == 0)
                 codec_events::decoder_event(codec, DECODE_IPV6_IS_NOT);
@@ -199,11 +199,11 @@ bool Ipv6Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
         CheckIPV6Multicast(ip6h, codec);
 
         snort.set_pkt_type(PktType::IP);
-        codec.next_prot_id = ip6h->get_next();
+        codec.next_prot_id = ip6h->next();
         codec.lyr_len = ip::IP6_HEADER_LEN;
         codec.curr_ip6_extension = 0;
         codec.ip6_extension_count = 0;
-        codec.ip6_csum_proto = ip6h->get_next();
+        codec.ip6_csum_proto = ip6h->next();
         codec.codec_flags &= ~CODEC_ROUTING_SEEN;
 
         // FIXIT-M J  tunnel-byppas is NOT checked!!
@@ -583,7 +583,7 @@ void Ipv6Codec::log(TextLog* const text_log, const uint8_t* raw_pkt,
 
 
     TextLog_Print(text_log, "Next:0x%02X TTL:%u TOS:0x%X DgmLen:%u",
-            ip6h->get_next(), ip6h->get_hop_lim(), ip6h->tos(),
+            ip6h->next(), ip6h->hop_lim(), ip6h->tos(),
             ip6h->len());
 }
 
index e238209cc4eb3ceede7416e97fba9755a6eb36f5..51747e9a301dbbb84c65af73631d4623a5d304b4 100644 (file)
@@ -294,7 +294,7 @@ bool TcpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
         dsize = 0;
 
     if ( (tcph->th_flags & TH_URG) &&
-        ((dsize == 0) || ntohs(tcph->th_urp) > dsize) )
+        ((dsize == 0) || tcph->urp() > dsize) )
         codec_events::decoder_event(codec, DECODE_TCP_BAD_URP);
 
     // Now that we are returning true, set the tcp header
@@ -583,7 +583,7 @@ void TcpCodec::log(TextLog* const text_log, const uint8_t* raw_pkt,
             ntohs(tcph->th_win), tcph->off() << 2);
 
     if((tcph->th_flags & TH_URG) != 0)
-        TextLog_Print(text_log, "UrgPtr: 0x%X", (uint16_t) ntohs(tcph->th_urp));
+        TextLog_Print(text_log, "UrgPtr: 0x%X", tcph->urp());
 
 
     /* dump the TCP options */
index c3a93a5539852bb98137f3d0a20342f2c708f187..eb4c20bb1d07120f850f4e2eee59573f81c7c4b6 100644 (file)
@@ -193,7 +193,7 @@ bool UdpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
     }
     else if(snort.ip_api.is_ip6())
     {
-        const uint16_t ip_len = snort.ip_api.len();
+        const uint16_t ip_len = snort.ip_api.get_ip6h()->len();
         /* subtract the distance from udp header to 1st ip6 extension */
         /* This gives the length of the UDP "payload", when fragmented */
         uhlen = ip_len - ((uint8_t *)udph - snort.ip_api.ip_data());
@@ -201,9 +201,8 @@ bool UdpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
     }
     else
     {
-        const uint16_t ip_len = snort.ip_api.len();
-        /* Don't forget, IP_HLEN is a word - multiply x 4 */
-        uhlen = ip_len - (snort.ip_api.hlen() * 4 );
+        const ip::IP4Hdr* const ip4h = snort.ip_api.get_ip4h();
+        uhlen = ip4h->len() - ip4h->hlen();
         fragmented_udp_flag = true;
     }
 
index 509e841445d79ff8be4a5dc5054061b62c62feeb..e09a6d0150a09e2b0b00b589cb3162e88fa37701 100644 (file)
@@ -83,13 +83,13 @@ bool Icmp4IpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snor
      * with datalink DLT_RAW it's impossible to differ ARP datagrams from IP.
      * So we are just ignoring non IP datagrams
      */
-    if((ip4h->get_ver() != 4) && !snort.ip_api.is_ip6())
+    if((ip4h->ver() != 4) && !snort.ip_api.is_ip6())
     {
         codec_events::decoder_event(codec, DECODE_ICMP_ORIG_IP_VER_MISMATCH);
         return false;
     }
 
-    const uint32_t hlen = ip4h->get_hlen() << 2;    /* set the IP header length */
+    const uint32_t hlen = ip4h->hlen();    /* set the IP header length */
 
     if(raw.len < hlen)
     {
@@ -191,7 +191,7 @@ void Icmp4IpCodec::log(TextLog* const text_log, const uint8_t* raw_pkt,
     TextLog_NewLine(text_log);
     TextLog_Puts(text_log, "\t\t");
 
-    const uint16_t hlen = ip4h->get_hlen() << 2;
+    const uint16_t hlen = ip4h->hlen();
     const uint16_t len = ip4h->len();
     const uint16_t frag_off = ip4h->off();
 
index 7c5fe78b83df296227a44b1b86c522cf1afadbd8..e5f4c06f39a61423343d5ec544a0f0ecba81bfb2 100644 (file)
@@ -83,7 +83,7 @@ bool Icmp6IpCodec::decode(const RawData& raw, CodecData& codec, DecodeData&)
      * with datalink DLT_RAW it's impossible to differ ARP datagrams from IP.
      * So we are just ignoring non IP datagrams
      */
-    if(ip6h->get_ver() != 6)
+    if(ip6h->ver() != 6)
     {
         codec_events::decoder_event(codec, DECODE_ICMP_ORIG_IP_VER_MISMATCH);
         return false;
@@ -109,7 +109,7 @@ bool Icmp6IpCodec::decode(const RawData& raw, CodecData& codec, DecodeData&)
     // ICMP codec. Therefore, doing a minor decode here.
 
     // FIXIT-J L   Will fail to decode Ipv6 options
-    switch(ip6h->get_next())
+    switch(ip6h->next())
     {
         case IPPROTO_TCP: /* decode the interesting part of the header */
             codec.proto_bits |= PROTO_BIT__TCP_EMBED_ICMP;
index 4d0ec0580c2a983eeff0a64334fafd0d96515317..af8dd322d680ce3fecad907befcad627f50706de 100644 (file)
@@ -626,8 +626,8 @@ void LogIPHeader(TextLog*  log, Packet * p)
             (is_ip6 ? layer::get_inner_ip6_frag() : nullptr);
 
         TextLog_Print(log, "%s TTL:%u TOS:0x%X ID:%u IpLen:%u DgmLen:%u",
-                protocol_names[ip6h->get_next()],
-                ip6h->get_hop_lim(),
+                protocol_names[ip6h->next()],
+                ip6h->hop_lim(),
                 ip6h->tos(),
                 (ip6_frag ? ip6_frag->id() : 0),
                 ip::IP6_HEADER_LEN,
@@ -657,7 +657,7 @@ void LogIPHeader(TextLog*  log, Packet * p)
                 ip4h->ttl(),
                 ip4h->tos(),
                 ip4h->id(),
-                ip4h->get_hlen() << 2,
+                ip4h->hlen(),
                 ip4h->len());
 
         frag_off = ip4h->off();
@@ -886,7 +886,7 @@ void LogTCPHeader(TextLog*  log, Packet * p)
 
     if((tcph->th_flags & TH_URG) != 0)
     {
-        TextLog_Print(log, "  UrgPtr: 0x%X\n", (uint16_t) ntohs(tcph->th_urp));
+        TextLog_Print(log, "  UrgPtr: 0x%X\n", tcph->urp());
     }
     else
     {
index 8593f16447b5ce26847c50e0b44745131afb6b9d..63d75dd76fcf7f7e827a87676665c584cfa1e664 100644 (file)
@@ -355,7 +355,7 @@ void CsvLogger::alert(Packet *p, const char *msg, Event *event)
         else if (!strcasecmp("ip_len", type))
         {
             if (p->has_ip())
-                TextLog_Print(csv_log, "%d", p->ptrs.ip_api.len() << 2);
+                TextLog_Print(csv_log, "%d", p->ptrs.ip_api.pay_len());
         }
         else if (!strcasecmp("dgm_len", type))
         {
index 0c0fedaee019f65e17dd0e38b4459a4854524eed..746bcf63922b85697256b2923b33bf8474cd28a6 100644 (file)
@@ -17,7 +17,7 @@
 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
-// packet_manager.h author Josh Rosenbaum <jrosenba@cisco.com>
+// codec_manager.h author Josh Rosenbaum <jrosenba@cisco.com>
 
 #ifndef MANAGERS_CODEC_MANAGER_H
 #define MANAGERS_CODEC_MANAGER_H
index 82dabb73ea5b725af0bf4d3e4f0305c8eacd8286..00bd01785be51058e3a7a3e18910d7a9e954d80c 100644 (file)
@@ -485,9 +485,9 @@ static int Norm_TCP (
             changes++;
         }
         else if ( Norm_IsEnabled(c, NORM_TCP_URP) &&
-            (ntohs(h->th_urp) > p->dsize) )
+            (h->urp() > p->dsize) )
         {
-            h->th_urp = ntohs(p->dsize);
+            h->set_urp(p->dsize);
             normStats[PC_TCP_URP]++;
             sfBase.iPegs[PERF_COUNT_TCP_URP]++;
             changes++;
index 46d18243bf913da2cd4a1e0a15580b799bc0f80b..2dbd471e30e61a2ffdc0d1e6af24a463303b9a2d 100644 (file)
@@ -422,7 +422,7 @@ static int MakePortscanPkt(PS_PKT *ps_pkt, PS_PROTO *proto, int proto_type,
     // FIXIT-L: IP4 is gauranteed to have been set in update().  Is IP6()
     //        also gauranteed?
     if(g_tmp_pkt->ptrs.ip_api.is_ip6())
-        ((ip::IP6Hdr*)g_tmp_pkt->ptrs.ip_api.get_ip6h())->set_len(htons((uint16_t)ip_size));
+        ((ip::IP6Hdr*)g_tmp_pkt->ptrs.ip_api.get_ip6h())->set_len((uint16_t)ip_size);
 
     return 0;
 }
index 26434f5755a19d0b282ee2dec79c8972088ae617..dcc58dab313fe2e5d38e7fc716d2b84e752391fe 100644 (file)
@@ -71,7 +71,7 @@ void IpApi::set(const ip::IP6Hdr* h6)
 bool IpApi::set(const uint8_t* raw_ip_data)
 {
     const IP4Hdr* h4 = reinterpret_cast<const IP4Hdr*>(raw_ip_data);
-    if (h4->get_ver() == 4)
+    if (h4->ver() == 4)
     {
         set(h4);
         return true;
@@ -79,7 +79,7 @@ bool IpApi::set(const uint8_t* raw_ip_data)
 
     const IP6Hdr* h6 = reinterpret_cast<const IP6Hdr*>(raw_ip_data);
 
-    if (h6->get_ver() == 6)
+    if (h6->ver() == 6)
     {
         set(h6);
         return true;
@@ -116,10 +116,10 @@ uint16_t IpApi::off() const
 const uint8_t* IpApi::ip_data() const
 {
     if (ip4h)
-        return reinterpret_cast<const uint8_t*>(ip4h) + (ip4h->get_hlen() << 2);
+        return reinterpret_cast<const uint8_t*>(ip4h) + (ip4h->hlen());
 
     if (ip6h)
-        return reinterpret_cast<const uint8_t*>(ip6h) + IP6_HEADER_LEN;
+        return reinterpret_cast<const uint8_t*>(ip6h) + ip6h->hlen();
 
     return nullptr;
 }
@@ -149,7 +149,7 @@ uint16_t IpApi::dgram_len() const
 uint16_t IpApi::pay_len() const
 {
     if (ip4h)
-        return ip4h->len() - IP4_HEADER_LEN;
+        return ip4h->len() - ip4h->hlen();
 
     if (ip6h)
         return ip6h->len();
index 1d098b63014db904be845aa84492144aa6f7e603..61ca7846a94c3747e3a42181c29661a339d68a37 100644 (file)
@@ -107,28 +107,28 @@ public:
     { return ip4h ? ip4h->tos() : ip6h ? ip6h->tos() : 0; }
 
     inline uint8_t ttl() const
-    { return ip4h ? ip4h->ttl() : ip6h ? ip6h->get_hop_lim() : 0; }
+    { return ip4h ? ip4h->ttl() : ip6h ? ip6h->hop_lim() : 0; }
 
     /* This is different than the Packet's ip_proto_next field - this
      * variable hold the first non-ip and non-ipv6 extension protocols,
      * while proto() returns the next or proto() field of the raw IP
      * header */
     inline uint8_t proto() const
-    { return ip4h ? ip4h->proto() : ip6h ? ip6h->get_next() : 0xFF; }
+    { return ip4h ? ip4h->proto() : ip6h ? ip6h->next() : 0xFF; }
 
     // NOTE:  ipv4 len contains header, ipv6 header does not. If you
     //        want a standard, use dgram_len() or pay_len() instead.
-    inline uint16_t len() const
-    { return ip4h ? ip4h->len() : ip6h ? ip6h->len() : 0; }
+//    inline uint16_t len() const
+//    { return ip4h ? ip4h->len() : ip6h ? ip6h->len() : 0; }
 
     inline uint16_t raw_len() const
     { return ip4h ? ip4h->raw_len() : ip6h ? ip6h->raw_len() : 0; }
 
     inline uint8_t hlen() const
-    { return ip4h ? ip4h->get_hlen() : ip6h ? ip6h->get_hlen() : 0; }
+    { return ip4h ? ip4h->hlen() : ip6h ? ip6h->hlen() : 0; }
 
     inline uint8_t ver() const
-    { return ip4h ? ip4h->get_ver() : ip6h ? ip6h->get_ver() : 0; }
+    { return ip4h ? ip4h->ver() : ip6h ? ip6h->ver() : 0; }
 
 
     // only relevent to IP4.
index 9e7bdf2bd65e975a394c474ef414da3c22e08122..f74938daa48008b8322445625b4cc6ca28421abf 100644 (file)
@@ -74,12 +74,11 @@ struct IP4Hdr
     uint32_t ip_dst;  /* dest IP */
 
     /* getters */
-    inline uint8_t get_hlen() const
-    { return ip_verhl & 0x0f; }
-//    { return (ip_verhl & 0x0f) << 2; } //FIXIT-M J return the actual length
+    inline uint8_t hlen() const
+    { return (ip_verhl & 0x0f) << 2; }
 
-    inline uint8_t get_ver() const
-    { return ((ip_verhl & 0xf0) >> 4); }
+    inline uint8_t ver() const
+    { return (ip_verhl >> 4); }
 
     inline uint8_t tos() const
     { return ip_tos; };
@@ -100,7 +99,10 @@ struct IP4Hdr
     { return ntohs(ip_id); }
 
     inline uint8_t get_opt_len() const
-    { return (get_hlen() << 2) - IP4_HEADER_LEN; }
+    { return hlen() - IP4_HEADER_LEN; }
+
+    inline uint16_t csum() const
+    { return ntohs(ip_csum); }
 
 
     /* booleans */
@@ -111,20 +113,10 @@ struct IP4Hdr
     { return ip_dst == IP4_BROADCAST; }
 
     inline bool has_options() const
-    { return get_hlen() > 5; }
-
-    /*  setters  */
-    inline void set_hlen(uint8_t value)
-    { ip_verhl = (ip_verhl & 0xf0) | (value & 0x0f); }
+    { return hlen() > 20; }
 
-    inline void set_ip_len(uint16_t value)
-    { ip_len = value; }
-
-    inline void set_proto(uint8_t prot)
-    { ip_proto = prot; }
 
     /* Access raw data */
-
     inline uint16_t raw_len() const
     { return ip_len; }
 
@@ -134,7 +126,7 @@ struct IP4Hdr
     inline uint16_t raw_off() const
     { return ip_off; }
 
-    inline uint16_t get_csum() const
+    inline uint16_t raw_csum() const
     { return ip_csum; }
 
     inline uint32_t get_src() const
@@ -142,6 +134,19 @@ struct IP4Hdr
 
     inline uint32_t get_dst() const
     { return ip_dst; }
+
+
+
+    /*  setters  */
+    inline void set_hlen(uint8_t value)
+    { ip_verhl = (ip_verhl & 0xf0) | (value & 0x0f); }
+
+    inline void set_proto(uint8_t prot)
+    { ip_proto = prot; }
+
+    inline void set_ip_len(uint16_t new_len)
+    { ip_len = htons(new_len); }
+
 } ;
 
 
index bdc224e341de6a514195bd7ea13ade08c779dd32..869f755bd20b8b223703b424b249f20a99e5e990 100644 (file)
@@ -106,7 +106,7 @@ struct IP6Frag
     inline uint32_t id() const
     { return ntohl(ip6f_ident); }
 
-    inline uint8_t get_res() const
+    inline uint8_t res() const
     { return ip6f_reserved; }
 
 
@@ -145,24 +145,30 @@ struct IP6Hdr
     inline uint16_t len() const
     { return ntohs(ip6_payload_len); }
 
+    /* Same function as ipv4 */
+    inline uint8_t proto() const
+    { return ip6_next; }
 
-    inline uint8_t get_ver() const
-    { return (uint8_t)(ntohl(ip6_vtf) >> 28); }
-
-    inline uint8_t get_next() const
+    inline uint8_t next() const
     { return ip6_next; }
 
-    inline uint8_t get_hop_lim() const
+    inline uint8_t hop_lim() const
     { return ip6_hoplim; }
 
+    inline uint8_t ver() const
+    { return (uint8_t)(ntohl(ip6_vtf) >> 28); }
+
     inline uint16_t tos() const
     { return (uint16_t)((ntohl(ip6_vtf) & 0x0FF00000) >> 20); }
 
+    inline uint32_t flow() const
+    { return (uint16_t)((ntohl(ip6_vtf) & 0x000FFFFF) >> 20); }
+
 
 
     // becaise Snort expects this in terms of 32 bit words.
-    inline uint8_t get_hlen() const
-    { return IP6_HEADER_LEN / 4; }
+    inline uint8_t hlen() const
+    { return IP6_HEADER_LEN; }
 
     inline const snort_in6_addr* get_src() const
     { return &ip6_src; }
@@ -199,12 +205,16 @@ struct IP6Hdr
 
     /*  setters  */
     inline void set_len(uint16_t new_len)
-    { ip6_payload_len = new_len; }
+    { ip6_payload_len = htons(new_len); }
 
     inline void set_proto(uint8_t prot)
     { ip6_next = prot; }
 
 
+    inline void set_raw_len(uint16_t new_len)
+    { ip6_payload_len = new_len; }
+
+
     /* Access raw data */
 
     inline uint16_t raw_len() const
index bd21119ae8ac44fbf9c014db59081f0ba778823c..e8dcab76e796d3453b66bb37d1cf904913cd1783 100644 (file)
@@ -209,7 +209,7 @@ uint8_t get_outer_ip_next_pro(const Packet* const p)
                 return reinterpret_cast<const ip::IP4Hdr*>(layers[i].start)->proto();
             case ETHERTYPE_IPV6:
             case IPPROTO_ID_IPV6:
-                return reinterpret_cast<const ip::IP6Hdr*>(layers[i].start)->get_next();
+                return reinterpret_cast<const ip::IP6Hdr*>(layers[i].start)->next();
             default:
                 break;
         }
index 7f37e0f8c1766377d1aa3b17a902a918320941c4..a0df7c550df5bb302abbf53873fe85d1a95144f6 100644 (file)
@@ -40,7 +40,7 @@ struct Layer {
                                *
                                * Generally calculated by
                                *    (layers_entire_length) - length;
-                               *     (ip::IP4Hdr*) ip4h->get_hlen() * 4 - length;
+                               *     (ip::IP4Hdr*) ip4h->hlen()- length;
                                */
 };
 
index 1472c7b47653589b430f6a3b813709e71b7991f5..48b0c03ba64440d5b2ed8a968528cc4bc14bfe5b 100644 (file)
@@ -485,7 +485,7 @@ const uint8_t* PacketManager::encode_reject( UnreachResponse type,
 
         const ip::IP4Hdr* const ip4h =
                 reinterpret_cast<const ip::IP4Hdr*>(p->layers[inner_ip_index].start);
-        const uint8_t ip_len = ip4h->get_hlen() << 2;
+        const uint8_t ip_len = ip4h->hlen();
 
         if (!buf.allocate(ip_len))
             return nullptr;
index 14ee82b42df782d5d6554cade58b41cda424190c..c672a267c812ce5e8f56f5d78083b1ed80cb7c80 100644 (file)
@@ -98,6 +98,15 @@ struct TCPHdr
     inline uint16_t dst_port() const
     { return ntohs(th_dport); }
 
+    inline uint16_t win() const
+    { return ntohs(th_win); }
+
+    inline uint16_t cksum() const
+    { return ntohs(th_sum); }
+
+    inline uint16_t urp() const
+    { return ntohs(th_urp); }
+
     inline uint32_t seq() const
     { return ntohl(th_seq); }
 
@@ -122,6 +131,7 @@ struct TCPHdr
     inline bool is_rst() const
     { return (th_flags & TH_RST); }
 
+
     /*  raw data access */
     inline uint8_t raw_src_port() const
     { return th_sport; }
@@ -135,9 +145,25 @@ struct TCPHdr
     inline uint8_t raw_hdr_len() const
     { return th_offx2 >> 4; }
 
+    inline uint16_t raw_win() const
+    { return th_win; }
+
+    inline uint16_t raw_cksum() const
+    { return th_sum; }
+
+    inline uint16_t raw_urp() const
+    { return th_urp; }
+
+
     // setters
     inline void set_offset(uint8_t val)
     { th_offx2 = (uint8_t)((th_offx2 & 0x0f) | (val << 4)); }
+
+    inline void set_urp(uint16_t new_urp)
+    { th_urp = htons(new_urp); }
+
+    inline void set_raw_urp(uint16_t new_urp)
+    { th_urp = new_urp; }
 };
 
 }  // namespace tcp
index ca7b98137d88751e505c9f1b313a60e60d4b59d3..7c8a00c5d9ecb9679d2295bf10444543e267a1d5 100644 (file)
@@ -1918,7 +1918,7 @@ left_overlap_last:
     {
         DEBUG_WRAP(DebugMessage(DEBUG_FRAG,
                     "Overly large fragment %d 0x%x 0x%x %d\n",
-                    fragLength, p->ptrs.ip_api.len(), p->ptrs.ip_api.off(),
+                    fragLength, p->ptrs.ip_api.dgram_len(), p->ptrs.ip_api.off(),
                     net_frag_offset << 3););
         MODULE_PROFILE_END(fragInsertPerfStats);
         return FRAG_INSERT_FAILED;
@@ -2302,7 +2302,7 @@ int Defrag::new_tracker(Packet *p, FragTracker* ft)
     {
         DEBUG_WRAP(DebugMessage(DEBUG_FRAG,
             "Overly large fragment length:%d(0x%x) off:0x%x(%d)\n",
-            fragLength, p->ptrs.ip_api.len(), p->ptrs.ip_api.off() << 3,
+            fragLength, p->ptrs.ip_api.dgram_len(), p->ptrs.ip_api.off() << 3,
             p->ptrs.ip_api.off() << 3););
 
         /* Ah, crap.  Return that tracker. */
index 0305434b135552747249a4d444af83e370a2afc7..c8bd7bd069cc22027b03679464355535d684ab19 100644 (file)
@@ -3106,7 +3106,7 @@ static int AddStreamNode(
     /* handle the urg ptr */
     if(p->ptrs.tcph->th_flags & TH_URG)
     {
-        if(ntohs(p->ptrs.tcph->th_urp) < p->dsize)
+        if(p->ptrs.tcph->urp() < p->dsize)
         {
             switch(st->os_policy)
             {
@@ -3114,7 +3114,7 @@ static int AddStreamNode(
             case STREAM_POLICY_OLD_LINUX:
                 /* Linux, Old linux discard data from urgent pointer */
                 /* If urg pointer is 0, it's treated as a 1 */
-                ss->urg_offset = ntohs(p->ptrs.tcph->th_urp);
+                ss->urg_offset = p->ptrs.tcph->urp();
                 if (ss->urg_offset == 0)
                 {
                     ss->urg_offset = 1;
@@ -3133,7 +3133,7 @@ static int AddStreamNode(
             case STREAM_POLICY_IRIX:
                 /* Others discard data from urgent pointer */
                 /* If urg pointer is beyond this packet, it's treated as a 0 */
-                ss->urg_offset = ntohs(p->ptrs.tcph->th_urp);
+                ss->urg_offset = p->ptrs.tcph->urp();
                 if (ss->urg_offset > p->dsize)
                 {
                     ss->urg_offset = 0;
index 223675dc0a13098248cfb7eefd87b359578a0a84..b6e4eb67ce0c85a685a6bef9ac8b81c94eb11837 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <sstream>
 #include <vector>
+#include <stdexcept>
 
 #include "conversion_state.h"
 #include "utils/converter.h"
index 989c287a17e74a60852a201fac684f06aa465704..15b817d6975ee3b84c765e6f8f426310c94895f3 100644 (file)
@@ -33,7 +33,7 @@ namespace preprocessors
 template<const std::string *norm_option>
 static ConversionState* norm_sans_options_ctor(Converter& c)
 {
-    c.get_table_api().open_table("normalize");
+    c.get_table_api().open_table("normalizer");
     c.get_table_api().add_diff_option_comment("preprocessor normalize_" + *norm_option, *norm_option + " = <bool>");
     c.get_table_api().add_option(*norm_option, true);
     c.get_table_api().close_table();
@@ -103,7 +103,7 @@ bool Ip4Normalizer::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
 
-    table_api.open_table("normalize");
+    table_api.open_table("normalizer");
     table_api.open_table("ip4");
     table_api.add_option("base", true);
 
@@ -173,7 +173,7 @@ bool TcpNormalizer::convert(std::istringstream& data_stream)
     std::string value;
     bool retval = true;
 
-    table_api.open_table("normalize");
+    table_api.open_table("normalizer");
     table_api.open_table("tcp");
     table_api.add_option("base", true);