|
|
|
@ -404,6 +404,21 @@ typedef struct PktProfiling_ {
|
|
|
|
|
|
|
|
|
|
#endif /* PROFILING */
|
|
|
|
|
|
|
|
|
|
enum PacketDropReason {
|
|
|
|
|
PKT_DROP_REASON_NOT_SET = 0,
|
|
|
|
|
PKT_DROP_REASON_DECODE_ERROR,
|
|
|
|
|
PKT_DROP_REASON_DEFRAG_ERROR,
|
|
|
|
|
PKT_DROP_REASON_DEFRAG_MEMCAP,
|
|
|
|
|
PKT_DROP_REASON_FLOW_MEMCAP,
|
|
|
|
|
PKT_DROP_REASON_FLOW_DROP,
|
|
|
|
|
PKT_DROP_REASON_STREAM_ERROR,
|
|
|
|
|
PKT_DROP_REASON_STREAM_MEMCAP,
|
|
|
|
|
PKT_DROP_REASON_APPLAYER_ERROR,
|
|
|
|
|
PKT_DROP_REASON_APPLAYER_MEMCAP,
|
|
|
|
|
PKT_DROP_REASON_RULES,
|
|
|
|
|
PKT_DROP_REASON_RULES_THRESHOLD, /**< detection_filter in action */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* forward declaration since Packet struct definition requires this */
|
|
|
|
|
struct PacketQueue_;
|
|
|
|
|
|
|
|
|
@ -600,6 +615,14 @@ typedef struct Packet_
|
|
|
|
|
/** data linktype in host order */
|
|
|
|
|
int datalink;
|
|
|
|
|
|
|
|
|
|
/* count decoded layers of packet : too many layers
|
|
|
|
|
* cause issues with performance and stability (stack exhaustion)
|
|
|
|
|
*/
|
|
|
|
|
uint8_t nb_decoded_layers;
|
|
|
|
|
|
|
|
|
|
/* enum PacketDropReason::PKT_DROP_REASON_* as uint8_t for compactness */
|
|
|
|
|
uint8_t drop_reason;
|
|
|
|
|
|
|
|
|
|
/* tunnel/encapsulation handling */
|
|
|
|
|
struct Packet_ *root; /* in case of tunnel this is a ptr
|
|
|
|
|
* to the 'real' packet, the one we
|
|
|
|
@ -625,11 +648,6 @@ typedef struct Packet_
|
|
|
|
|
*/
|
|
|
|
|
struct PktPool_ *pool;
|
|
|
|
|
|
|
|
|
|
/* count decoded layers of packet : too many layers
|
|
|
|
|
* cause issues with performance and stability (stack exhaustion)
|
|
|
|
|
*/
|
|
|
|
|
uint8_t nb_decoded_layers;
|
|
|
|
|
|
|
|
|
|
#ifdef PROFILING
|
|
|
|
|
PktProfiling *profile;
|
|
|
|
|
#endif
|
|
|
|
@ -802,6 +820,7 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
|
|
|
|
|
(p)->ts.tv_sec = 0; \
|
|
|
|
|
(p)->ts.tv_usec = 0; \
|
|
|
|
|
(p)->datalink = 0; \
|
|
|
|
|
(p)->drop_reason = 0; \
|
|
|
|
|
(p)->action = 0; \
|
|
|
|
|
if ((p)->pktvar != NULL) { \
|
|
|
|
|
PktVarFree((p)->pktvar); \
|
|
|
|
@ -899,8 +918,6 @@ static inline void PacketSetAction(Packet *p, const uint8_t a)
|
|
|
|
|
|
|
|
|
|
#define PACKET_ACCEPT(p) PACKET_SET_ACTION(p, ACTION_ACCEPT)
|
|
|
|
|
|
|
|
|
|
#define PACKET_DROP(p) PACKET_SET_ACTION(p, ACTION_DROP)
|
|
|
|
|
|
|
|
|
|
#define PACKET_REJECT(p) PACKET_SET_ACTION(p, (ACTION_REJECT|ACTION_DROP))
|
|
|
|
|
|
|
|
|
|
#define PACKET_REJECT_DST(p) PACKET_SET_ACTION(p, (ACTION_REJECT_DST|ACTION_DROP))
|
|
|
|
@ -911,6 +928,14 @@ static inline void PacketSetAction(Packet *p, const uint8_t a)
|
|
|
|
|
|
|
|
|
|
#define PACKET_TEST_ACTION(p, a) (p)->action &(a)
|
|
|
|
|
|
|
|
|
|
static inline void PacketDrop(Packet *p, enum PacketDropReason r)
|
|
|
|
|
{
|
|
|
|
|
if (p->drop_reason == PKT_DROP_REASON_NOT_SET)
|
|
|
|
|
p->drop_reason = (uint8_t)r;
|
|
|
|
|
|
|
|
|
|
PACKET_SET_ACTION(p, ACTION_DROP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint8_t PacketTestAction(const Packet *p, const uint8_t a)
|
|
|
|
|
{
|
|
|
|
|
if (likely(p->root == NULL)) {
|
|
|
|
@ -988,6 +1013,7 @@ DecodeThreadVars *DecodeThreadVarsAlloc(ThreadVars *);
|
|
|
|
|
void DecodeThreadVarsFree(ThreadVars *, DecodeThreadVars *);
|
|
|
|
|
void DecodeUpdatePacketCounters(ThreadVars *tv,
|
|
|
|
|
const DecodeThreadVars *dtv, const Packet *p);
|
|
|
|
|
const char *PacketDropReasonToString(enum PacketDropReason r);
|
|
|
|
|
|
|
|
|
|
/* decoder functions */
|
|
|
|
|
int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
|
|
|
|
|