packet: move action functions to packet files

pull/8042/head
Victor Julien 3 years ago
parent 0977f40d1c
commit cd2a5ec84f

@ -769,46 +769,6 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
} \
} while(0)
/** \brief issue drop action
*
* Set drop (+reject) flags in both current and root packet.
*
* \param action action bit flags. Must be limited to ACTION_DROP_REJECT
*/
static inline void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
{
BUG_ON((action & ~ACTION_DROP_REJECT) != 0);
if (p->drop_reason == PKT_DROP_REASON_NOT_SET)
p->drop_reason = (uint8_t)r;
if (p->root) {
p->root->action |= action;
if (p->root->drop_reason == PKT_DROP_REASON_NOT_SET) {
p->root->drop_reason = PKT_DROP_REASON_INNER_PACKET;
}
}
p->action |= action;
}
static inline uint8_t PacketCheckAction(const Packet *p, const uint8_t a)
{
if (likely(p->root == NULL)) {
return (p->action & a) != 0;
} else {
/* check against both */
const uint8_t actions = p->action | p->root->action;
return (actions & a) != 0;
}
}
#ifdef UNITTESTS
static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
{
return PacketCheckAction(p, a);
}
#endif
#define TUNNEL_INCR_PKT_RTV_NOLOCK(p) do { \
((p)->root ? (p)->root->tunnel_rtv_cnt++ : (p)->tunnel_rtv_cnt++); \
} while (0)

@ -23,6 +23,7 @@
#include "detect-engine-tag.h"
#include "decode.h"
#include "packet.h"
#include "flow.h"
#include "flow-private.h"

@ -28,6 +28,7 @@
#include "conf.h"
#include "decode.h"
#include "packet.h"
#include "flow.h"
#include "stream-tcp.h"
#include "app-layer.h"

@ -25,6 +25,7 @@
*/
#include "suricata-common.h"
#include "packet.h"
#include "detect.h"
#include "flow.h"
#include "conf.h"

@ -25,6 +25,7 @@
*/
#include "suricata-common.h"
#include "packet.h"
#include "detect.h"
#include "flow.h"
#include "conf.h"

@ -20,6 +20,40 @@
#include "flow.h"
#include "host.h"
#include "util-profiling.h"
#include "util-validate.h"
/** \brief issue drop action
*
* Set drop (+reject) flags in both current and root packet.
*
* \param action action bit flags. Must be limited to ACTION_DROP_REJECT
*/
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
{
DEBUG_VALIDATE_BUG_ON((action & ~ACTION_DROP_REJECT) != 0);
if (p->drop_reason == PKT_DROP_REASON_NOT_SET)
p->drop_reason = (uint8_t)r;
if (p->root) {
p->root->action |= action;
if (p->root->drop_reason == PKT_DROP_REASON_NOT_SET) {
p->root->drop_reason = PKT_DROP_REASON_INNER_PACKET;
}
}
p->action |= action;
}
bool PacketCheckAction(const Packet *p, const uint8_t a)
{
if (likely(p->root == NULL)) {
return (p->action & a) != 0;
} else {
/* check against both */
const uint8_t actions = p->action | p->root->action;
return (actions & a) != 0;
}
}
/**
* \brief Initialize a packet structure for use.

@ -20,6 +20,16 @@
#include "decode.h"
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r);
bool PacketCheckAction(const Packet *p, const uint8_t a);
#ifdef UNITTESTS
static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
{
return PacketCheckAction(p, a);
}
#endif
void PacketInit(Packet *p);
void PacketReleaseRefs(Packet *p);
void PacketReinit(Packet *p);

@ -25,6 +25,7 @@
*/
#include "suricata-common.h"
#include "packet.h"
#include "decode.h"
#include "packet-queue.h"
#include "threads.h"

@ -34,6 +34,7 @@
#define SC_PCAP_DONT_INCLUDE_PCAP_H 1
#include "suricata-common.h"
#include "suricata.h"
#include "packet.h"
#include "decode.h"
#include "packet-queue.h"
#include "threads.h"

@ -33,6 +33,7 @@
#include "suricata-common.h"
#include "runmodes.h"
#include "decode.h"
#include "packet.h"
#include "source-dpdk.h"
#include "suricata.h"
#include "threads.h"

@ -27,6 +27,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "decode.h"
#include "packet.h"
#include "packet-queue.h"
#include "threads.h"
#include "threadvars.h"

@ -27,6 +27,7 @@
*/
#include "suricata-common.h"
#include "decode.h"
#include "packet.h"
#include "suricata.h"
#include "threadvars.h"
#include "util-datalink.h"

@ -37,6 +37,7 @@
#include "suricata.h"
#include "suricata-common.h"
#include "tm-threads.h"
#include "packet.h"
#include "util-bpf.h"
#include "util-privs.h"
#include "util-validate.h"

@ -27,6 +27,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "packet.h"
#include "decode.h"
#include "packet-queue.h"

@ -28,7 +28,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "tm-threads.h"
#include "packet.h"
#include "util-byte.h"
#include "util-debug.h"
#include "util-device.h"

@ -28,7 +28,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "packet.h"
#include "decode.h"
#include "detect.h"

@ -21,6 +21,7 @@
#include "suricata-common.h"
#include "suricata.h"
#include "packet.h"
#include "util-exception-policy.h"
#include "util-misc.h"
#include "stream-tcp-reassemble.h"

Loading…
Cancel
Save