lyr->length = ip::IP4_HEADER_LEN;
ch->set_ip_len(ip::IP4_HEADER_LEN);
ch->set_hlen(ip::IP4_HEADER_LEN >> 2);
-
-#if 0
- // FIXIT-L - J why did Snort check for this?
- int i = lyr - c->layers;
- if ( i + 1 == p->num_layers )
- {
- lyr->length = ip::IP4_HEADER_LEN;
- ch->set_ip_len(ip::IP4_HEADER_LEN);
- ch->set_hlen(ip::IP4_HEADER_LEN >> 2);
- }
-#endif
}
c->ptrs.ip_api.set(ch);
static const RuleMap udp_rules[] =
{
- { DECODE_UDP_DGRAM_LT_UDPHDR, "truncated UDP Header" },
+ { DECODE_UDP_DGRAM_LT_UDPHDR, "truncated UDP header" },
{ DECODE_UDP_DGRAM_INVALID_LENGTH, "invalid UDP header, length field < 8" },
{ DECODE_UDP_DGRAM_SHORT_PACKET, "short UDP packet, length field > payload length" },
{ DECODE_UDP_DGRAM_LONG_PACKET, "long UDP packet, length field < payload length" },
ip::IpOptionIterator iter(p->ptrs.ip_api.get_ip4h(), p);
- for (ip::IpOptions opt : iter)
+ for (const ip::IpOptions& opt : iter)
{
/* Is the high bit set? If not, weird anomaly. */
- if (!(static_cast<uint8_t>(opt.code) & 0x80))
+ if ( !(static_cast<uint8_t>(opt.code) & 0x80) &&
+ (opt.code != ip::IPOptionCodes::EOL) )
+ {
EventAnomIpOpts(ft->engine);
+
+ }
}
}
}
uint16_t frag_end;
uint16_t frag_off;
- // if we're here, then the last layer was a fragment.
- const Layer& lyr = p->layers[p->num_layers-1];
- fragStart = lyr.start + lyr.length;
/* Use the actual length here because packet may have been
* truncated. Don't want to try to copy more than we actually
* between the last sucesfully decoded layer (which is ip6_frag
* or ipv4) and the end of packet, */
fragLength = p->dsize;
+ fragStart = p->data;
/* Just to double check */
if (fragLength > pkt_snaplen)
memset(ft, 0, sizeof(*ft));
- if (p->ptrs.ip_api.is_ip4())
+ if ( p->is_ip4() )
{
- ft->protocol = p->ptrs.ip_api.get_ip4h()->proto();
-
- const ip::IP4Hdr *ip4h = reinterpret_cast<const ip::IP4Hdr*>(lyr.start);
+ const ip::IP4Hdr* const ip4h = p->ptrs.ip_api.get_ip4h();
+ ft->protocol = ip4h->proto();
frag_off = ip4h->off();
}
else /* IPv6 */
{
+ const Layer& lyr = p->layers[p->num_layers-1];
const ip::IP6Frag* const fragHdr = reinterpret_cast<const ip::IP6Frag*>(lyr.start);
frag_off = fragHdr->off();