*/
int fpEvalPacket(Packet *p)
{
- int ip_proto = p->ptrs.ip_api.proto();
OTNX_MATCH_DATA *omd = &t_omd;
/* Run UDP rules against the UDP header of Teredo packets */
do_detect_content = tmp_do_detect_content;
}
- switch(ip_proto)
+ switch(p->type())
{
- case IPPROTO_TCP:
- DEBUG_WRAP(DebugMessage(DEBUG_DETECT,
- "Detecting on TcpList\n"););
-
- if(p->ptrs.tcph == NULL)
- {
- ip_proto = -1;
- break;
- }
-
+ case PktType::TCP:
return fpEvalHeaderTcp(p, omd);
- case IPPROTO_UDP:
- DEBUG_WRAP(DebugMessage(DEBUG_DETECT,
- "Detecting on UdpList\n"););
-
- if(p->ptrs.udph == NULL)
- {
- ip_proto = -1;
- break;
- }
-
+ case PktType::UDP:
return fpEvalHeaderUdp(p, omd);
- case IPPROTO_ICMPV6:
- case IPPROTO_ICMP:
+ case PktType::ICMP:
DEBUG_WRAP(DebugMessage(DEBUG_DETECT,
"Detecting on IcmpList\n"););
-
- if(p->ptrs.icmph == NULL)
- {
- ip_proto = -1;
- break;
- }
-
return fpEvalHeaderIcmp(p, omd);
+ /*
+ ** No Match on TCP/UDP, Do IP
+ */
default:
+ return fpEvalHeaderIp(p, -1, omd);
break;
}
- /*
- ** No Match on TCP/UDP, Do IP
- */
- return fpEvalHeaderIp(p, ip_proto, omd);
}
void fpEvalIpProtoOnlyRules(Packet *p, uint8_t proto_id)
MODULE_PROFILE_START(ipProtoPerfStats);
- const uint8_t ip_proto = p->ip_next_proto();
+ const uint8_t ip_proto = p->ip_proto_next();
switch (ipd->comparison_flag)
{
{
case PROTO_BIT__TCP_EMBED_ICMP:
{
- const tcp::TCPHdr* tcph = layer::get_tcp_embed_icmp(op.ptrs.ip_api);
+ const tcp::TCPHdr* const tcph = layer::get_tcp_embed_icmp(op.ptrs.ip_api);
if (tcph)
{
orig_p->ptrs.sp = tcph->src_port();
case PROTO_BIT__UDP_EMBED_ICMP:
{
- const udp::UDPHdr* udph = layer::get_udp_embed_icmp(op.ptrs.ip_api);
+ const udp::UDPHdr* const udph = layer::get_udp_embed_icmp(op.ptrs.ip_api);
if (udph)
{
orig_p->ptrs.sp = udph->src_port();
LogIPHeader(log, orig_p);
TextLog_Print(log, "Len: %d Csum: %d\n",
- ntohs(orig_p->ptrs.udph->uh_len) - udp::UDP_HEADER_LEN,
- ntohs(orig_p->ptrs.udph->uh_chk));
+ udph->len() - udp::UDP_HEADER_LEN,
+ udph->cksum());
+ }
break;
}
}
/* print the packet header to the alert file */
- if (p->ptrs.ip_api.is_valid())
+ if (p->has_ip())
{
LogPriorityData(fast_log, event, 0);
- TextLog_Print(fast_log, "{%s} ", protocol_names[p->ptrs.ip_api.proto()]);
+ TextLog_Print(fast_log, "{%s} ", protocol_names[p->ip_proto_next()]);
LogIpAddrs(fast_log, p);
}
// and only 1st 8 used for ip4
sar.src_ip = ntohl(packet->ptrs.ip_api.get_src()->ip32[0]);
sar.dest_ip = ntohl(packet->ptrs.ip_api.get_dst()->ip32[0]);
- sar.protocol = packet->ptrs.ip_api.proto();
+ sar.protocol = packet->ip_proto_next();
if(packet->is_tcp() || packet->is_udp())
{
"<%s> ", PRINT_INTERFACE(DAQ_GetInterfaceSpec()));
}
- uint16_t proto = p->ptrs.ip_api.proto();
+ uint16_t proto = p->ip_proto_next();
if (protocol_names[proto] != NULL)
{
SnortSnprintfAppend(event_string, sizeof(event_string),
}
else
{
- alertdata.protocol = p->ptrs.ip_api.proto();;
+ alertdata.protocol = p->ip_proto_next();
if ( p->type() == PktType::ICMP)
{
}
else
{
- alertdata.protocol = p->ptrs.ip_api.proto();;
+ alertdata.protocol = p->ip_proto_next();
if ( p->type() == PktType::ICMP)
{
OrderRuleLists(snort_conf, "drop sdrop reject alert pass log");
}
- // Must be after CodecManagers
+ // Must be after CodecManager::instantiate()
if ( !InspectorManager::configure(snort_conf) )
FatalError("can't initialize inspectors\n");
* eth::ip6::hop_opts::ipv6_routing::UDP
* this function return 17 == IPPROTO_UDP == IPPROTO_ID_UDP
*/
- uint8_t ip_next_proto() const;
+ uint8_t ip_proto_next() const;
inline void reset()
{
* a rebuilt packet later. So don't process it further.
*/
if ((frag_offset != 0) ||
- ((p->ptrs.ip_api.proto() != IPPROTO_UDP) && (p->ptrs.decode_flags & DECODE_MF)))
+ ((p->ip_proto_next() != IPPROTO_UDP) && (p->ptrs.decode_flags & DECODE_MF)))
{
DisableDetect(p);
}
FragRebuild(ft, p);
if (frag_offset != 0 ||
- (p->ptrs.ip_api.proto() != IPPROTO_UDP && ft->frag_flags & FRAG_REBUILT))
+ (p->ip_proto_next() != IPPROTO_UDP && ft->frag_flags & FRAG_REBUILT))
{
/* Need to reset some things here because the
* rebuilt packet will have reset the do_detect
if (p->ptrs.ip_api.is_ip4())
{
- ft->protocol = p->ptrs.ip_api.proto();
+ ft->protocol = p->ptrs.ip_api.get_ip4h()->get_proto();
const ip::IP4Hdr *ip4h = reinterpret_cast<const ip::IP4Hdr*>(lyr.start);
frag_off = ntohs(ip4h->get_off());