decode: implement IP_GET_IPPROTO as inline func

For better readability and type checking.

Ticket: #5517.
pull/10971/head
Victor Julien 2 years ago committed by Victor Julien
parent 14e2c579f6
commit 61df76a57d

@ -254,11 +254,6 @@ typedef uint16_t Port;
#define IPH_IS_VALID(p) (PKT_IS_IPV4((p)) || PKT_IS_IPV6((p)))
/* Retrieve proto regardless of IP version */
#define IP_GET_IPPROTO(p) \
(p->proto ? p->proto : \
(PKT_IS_IPV4((p))? IPV4_GET_IPPROTO((p)) : (PKT_IS_IPV6((p))? IPV6_GET_L4PROTO((p)) : 0)))
/* structure to store the sids/gids/etc the detection engine
* found in this packet */
typedef struct PacketAlert_ {
@ -680,6 +675,21 @@ typedef struct Packet_
extern uint32_t default_packet_size;
#define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
/* Retrieve proto regardless of IP version */
static inline uint8_t IP_GET_IPPROTO(const Packet *p)
{
if (p->proto != 0) {
return p->proto;
}
if (PKT_IS_IPV4(p)) {
return IPV4_GET_IPPROTO(p);
} else if (PKT_IS_IPV6(p)) {
return IPV6_GET_L4PROTO(p);
} else {
return 0;
}
}
/** \brief Structure to hold thread specific data for all decode modules */
typedef struct DecodeThreadVars_
{

Loading…
Cancel
Save