Go to the documentation of this file.
98 .valid_settings_ips = {
126 .valid_settings_ips = {
154 if (pa_array == NULL)
157 for (
int i = 0; i <
cnt; i++) {
159 while (current_json) {
163 current_json = next_json;
171 if (pa_array == NULL)
175 while (allocated_json) {
179 allocated_json = next_json;
214 SCLogDebug(
"FIXME: DecodeTunnel: protocol %" PRIu32
" not supported.",
proto);
246 for (uint8_t i = 0; i < p->
events.
cnt; i++) {
271 SCLogDebug(
"allocated a new packet only using alloc...");
349 uint32_t newsize =
offset + datalen;
427 if (parent->
root != NULL) {
451 if (parent->
root == NULL) {
454 TUNNEL_INCR_PKT_TPR(p);
459 DecodeSetNoPayloadInspectionFlag(parent);
488 if (parent->
root != NULL) {
523 TUNNEL_INCR_PKT_TPR(parent);
528 DecodeSetNoPayloadInspectionFlag(parent);
539 #ifdef CAPTURE_OFFLOAD
545 (state == FLOW_STATE_CAPTURE_BYPASSED)) {
603 static HashTable *g_counter_table = NULL;
609 if (g_counter_table) {
611 g_counter_table = NULL;
616 static bool IsDefragMemcapExceptionPolicyStatsValid(
enum ExceptionPolicy policy)
624 static bool IsFlowMemcapExceptionPolicyStatsValid(
enum ExceptionPolicy policy)
688 IsFlowMemcapExceptionPolicyStatsValid);
732 IsDefragMemcapExceptionPolicyStatsValid);
743 strncmp(
DEvents[i].event_name,
"decoder.", 8) == 0)
746 if (g_counter_table == NULL) {
750 if (g_counter_table == NULL) {
752 "table init failed");
757 char *dot = strchr(
DEvents[i].event_name,
'.');
759 snprintf(
name,
sizeof(
name),
"%s.%s",
767 "table name init failed");
771 "table name add failed");
808 PrintInet(AF_INET, (
const void *)&a->addr_data32[0], s,
sizeof(s));
826 SCLogError(
"initializing flow log API for thread failed");
861 p->
ext_pkt = (uint8_t *) pktdata;
869 const char *pkt_src_str = NULL;
872 pkt_src_str =
"wire/pcap";
875 pkt_src_str =
"gre tunnel";
878 pkt_src_str =
"ipv4 tunnel";
881 pkt_src_str =
"ipv6 tunnel";
884 pkt_src_str =
"teredo tunnel";
887 pkt_src_str =
"defrag";
890 pkt_src_str =
"stream (detect/log)";
893 pkt_src_str =
"stream (flow timeout)";
896 pkt_src_str =
"geneve encapsulation";
899 pkt_src_str =
"vxlan encapsulation";
902 pkt_src_str =
"detect reload flush";
905 pkt_src_str =
"capture timeout flush";
908 pkt_src_str =
"shutdown flush";
919 return "decode error";
921 return "defrag error";
923 return "defrag memcap";
925 return "flow memcap";
929 return "stream error";
931 return "stream memcap";
933 return "stream midstream";
935 return "stream urgent";
937 return "stream reassembly";
939 return "applayer error";
941 return "applayer memcap";
945 return "threshold detection_filter";
949 return "tunnel packet drop";
951 return "default packet policy";
953 return "default app policy";
955 return "pre stream hook";
957 return "pre flow hook";
969 return "ips.drop_reason.decode_error";
971 return "ips.drop_reason.defrag_error";
973 return "ips.drop_reason.defrag_memcap";
975 return "ips.drop_reason.flow_memcap";
977 return "ips.drop_reason.flow_drop";
979 return "ips.drop_reason.stream_error";
981 return "ips.drop_reason.stream_memcap";
983 return "ips.drop_reason.stream_midstream";
985 return "ips.drop_reason.stream_urgent";
987 return "ips.drop_reason.stream_reassembly";
989 return "ips.drop_reason.applayer_error";
991 return "ips.drop_reason.applayer_memcap";
993 return "ips.drop_reason.rules";
995 return "ips.drop_reason.threshold_detection_filter";
997 return "ips.drop_reason.nfq_error";
999 return "ips.drop_reason.tunnel_packet_drop";
1001 return "ips.drop_reason.default_packet_policy";
1003 return "ips.drop_reason.default_app_policy";
1005 return "ips.drop_reason.pre_stream_hook";
1007 return "ips.drop_reason.pre_flow_hook";
1055 const char *
name = PacketDropReasonToJsonString(i);
1070 if (value < 0 || value > UINT8_MAX) {
1083 if (max <= 0 || max > UINT8_MAX) {
1084 SCLogWarning(
"Invalid value for packet-alert-max, default value set instead");
bool PacketCheckAction(const Packet *p, const uint8_t a)
@ PKT_DROP_REASON_DEFRAG_MEMCAP
StatsCounterId counter_flow_icmp6
@ PKT_DROP_REASON_DEFRAG_ERROR
@ PKT_DROP_REASON_STREAM_PRE_HOOK
@ PKT_DROP_REASON_RULES_THRESHOLD
void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId id, int64_t x)
update the value of the localmax counter
StatsCounterId counter_icmpv4
StatsCounterId counter_defrag_ipv6_fragments
StatsCounterId counter_esp
StatsCounterId counter_ethertype_unknown
TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data)
thread init for the flow logger This will run the thread init functions for the individual registered...
int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
ERSPAN Type II.
StatsCounterId counter_ipv6
StatsCounterId counter_raw
void PacketFreeOrRelease(Packet *p)
Return a packet to where it was allocated.
StatsCounterId counter_vlan_qinqinq
StatsCounterId counter_flow_get_used_eval_busy
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Copy data to Packet payload and set packet length.
void PacketBypassCallback(Packet *p)
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
void DecodeERSPANConfig(void)
Functions to decode ERSPAN Type I and II packets.
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
FlowStorageId GetFlowBypassInfoID(void)
@ PKT_DROP_REASON_STREAM_MEMCAP
int DecodeNSH(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Function to decode NSH packets.
@ PKT_DROP_REASON_FLOW_MEMCAP
void DecodeTeredoConfig(void)
void CaptureStatsSetup(ThreadVars *tv)
const char * PacketDropReasonToString(enum PacketDropReason r)
uint8_t events[PACKET_ENGINE_EVENT_MAX]
#define PKT_STREAM_MODIFIED
StatsCounterId counter_ips_replaced
@ DECODE_TUNNEL_IPV6_TEREDO
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
StatsCounterId counter_defrag_no_frags
void AddressDebugPrint(Address *a)
Debug print function for printing addresses.
Packet * PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto)
Setup a pseudo packet (reassembled frags)
StatsCounterId counter_vxlan
StatsCounterId counter_flow_spare_sync_empty
StatsCounterId counter_nsh
StatsCounterId counter_gre
StatsCounterId counter_flow_get_used_failed
@ PKT_SRC_CAPTURE_TIMEOUT
PacketAlert * PacketAlertCreate(void)
Initialize PacketAlerts with dynamic alerts array size.
struct CaptureStats_ CaptureStats
@ DECODE_EVENT_PACKET_MAX
@ PKT_DROP_REASON_FLOW_PRE_HOOK
@ PKT_DROP_REASON_STREAM_REASSEMBLY
StatsCounterId counter_bytes
int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data, uint32_t datalen)
Copy data to Packet payload at given offset.
StatsCounterId counter_flow_get_used
StatsCounterId counter_pppoe
#define FLOW_PKT_TOSERVER
StatsCounterId counter_tcp_syn
#define ACTION_REJECT_ANY
ExceptionPolicyStatsSetts flow_memcap_eps_stats
int DecodeARP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
#define SCMUTEX_INITIALIZER
StatsCounterId counter_icmpv6
void PacketDecodeFinalize(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Finalize decoding of a packet.
StatsCounterId counter_invalid
void PacketAlertGetMaxConfig(void)
uint8_t decoder_max_layers
char StringHashCompareFunc(void *data1, uint16_t datalen1, void *data2, uint16_t datalen2)
int(* BypassPacketsFlow)(struct Packet_ *)
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
void DecodeVXLANConfig(void)
StatsCounterId counter_flow_spare_sync
StatsCounterId counter_defrag_ipv4_reassembled
void DecodeUnregisterCounters(void)
StatsCounterId counter_chdlc
StatsCounterId counter_sctp
#define GET_PKT_DIRECT_MAX_SIZE(p)
StatsCounterAvgId StatsRegisterAvgCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the average of all the values assigned to it.
uint32_t StringHashFunc(HashTable *ht, void *data, uint16_t datalen)
PacketEngineEvents events
void PacketAlertFree(PacketAlert *pa_array)
StatsCounterId counter_tcp
void HashTableFree(HashTable *ht)
Free a HashTable and all its contents.
@ PKT_DROP_REASON_STREAM_URG
StatsCounterId counter_defrag_tracker_hard_reuse
#define PKT_DEFAULT_MAX_DECODED_LAYERS
const char * stats_decoder_events_prefix
void StatsCounterAvgAddI64(StatsThreadContext *stats, StatsCounterAvgId id, int64_t x)
StatsCounterId counter_flow_memcap
StatsCounterId counter_defrag_max_hit
StatsCounterId counter_ips_accepted
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
StatsCounterId counter_flow_elephant
#define SET_PKT_LEN(p, len)
@ FLOW_STATE_LOCAL_BYPASSED
struct PacketContextData * json_info
@ PKT_DROP_REASON_DEFAULT_APP_POLICY
#define PKT_IS_TOSERVER(p)
StatsCounterId counter_udp
int DecodeERSPANTypeI(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
ERSPAN Type I.
const struct DecodeEvents_ DEvents[]
@ PKT_DROP_REASON_APPLAYER_ERROR
#define SCMutexUnlock(mut)
void PacketSwap(Packet *p)
switch direction of a packet
@ PKT_DROP_REASON_NOT_SET
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
void PacketDestructor(Packet *p)
Cleanup a packet so that we can free it. No memset needed..
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
StatsCounterId counter_vntag
void ExceptionPolicySetStatsCounters(ThreadVars *tv, ExceptionPolicyCounters *counter, ExceptionPolicyStatsSetts *setting, enum ExceptionPolicy conf_policy, const char *default_str, bool(*isExceptionPolicyValid)(enum ExceptionPolicy))
void * HashTableLookup(HashTable *ht, void *data, uint16_t datalen)
StatsCounterAvgId counter_avg_pkt_size
Per thread variable structure.
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
StatsCounterId counter_flow_active
StatsCounterId counter_ipv6inipv4
#define FLOW_PKT_TOCLIENT_FIRST
int FlowSetStorageById(Flow *f, FlowStorageId id, void *ptr)
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
void PacketFree(Packet *p)
Return a malloced packet.
const char * PktSrcToString(enum PktSrcEnum pkt_src)
bool valid_settings_ids[EXCEPTION_POLICY_MAX]
StatsCounterId counter_tcp_urg
StatsCounterId counter_pkts
StatsCounterId counter_eth
#define SCLogWarning(...)
Macro used to log WARNING messages.
int HashTableAdd(HashTable *ht, void *data, uint16_t datalen)
void StringHashFreeFunc(void *data)
StatsCounterAvgId counter_flow_spare_sync_avg
int PacketCallocExtPkt(Packet *p, int datalen)
StatsCounterId counter_flow_icmp4
@ PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH
StatsCounterId counter_ieee8021ah
StatsCounterId counter_defrag_tracker_timeout
StatsCounterId counter_drop_reason[PKT_DROP_REASON_MAX]
int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
AppLayerThreadCtx * app_tctx
StatsCounterId counter_ips_blocked
@ PKT_DROP_REASON_STREAM_ERROR
struct LiveDevice_ * livedev
StatsCounterId counter_geneve
#define SCReturnPtr(x, type)
AppLayerThreadCtx * AppLayerGetCtxThread(void)
Creates a new app layer thread context.
StatsCounterId counter_tcp_rst
#define FLOW_PKT_TOCLIENT
StatsCounterId counter_ipv4inipv6
void * FlowGetStorageById(const Flow *f, FlowStorageId id)
void FlowUpdateState(Flow *f, const enum FlowState s)
StatsCounterMaxId counter_max_mac_addrs_dst
@ PKT_DROP_REASON_DEFAULT_PACKET_POLICY
ExceptionPolicyCounters counter_defrag_memcap_eps
StatsCounterMaxId counter_max_mac_addrs_src
uint32_t default_packet_size
uint8_t nb_decoded_layers
void(* ReleasePacket)(struct Packet_ *)
StatsCounterId counter_ipv4inipv4
@ PKT_DROP_REASON_INNER_PACKET
enum ExceptionPolicy FlowGetMemcapExceptionPolicy(void)
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
StatsCounterId counter_sll
StatsCounterId counter_ppp
@ PKT_DROP_REASON_APPLAYER_MEMCAP
void DecodeGlobalConfig(void)
StatsCounterId counter_flow_udp
StatsCounterId counter_tcp_synack
@ PKT_DROP_REASON_NFQ_ERROR
@ GENERIC_TOO_MANY_LAYERS
StatsCounterId counter_null
enum PacketTunnelType ttype
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
ExceptionPolicyCounters counter_flow_memcap_eps
struct PacketContextData * next
StatsCounterId counter_vlan_qinq
StatsCounterId counter_teredo
#define PACKET_PROFILING_START(p)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
ExceptionPolicyStatsSetts defrag_memcap_eps_stats
StatsCounterId counter_ips_rejected
#define SCLogError(...)
Macro used to log ERROR messages.
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
@ PKT_SRC_DETECT_RELOAD_FLUSH
StatsCounterMaxId counter_max_pkt_size
StatsCounterId counter_flow_spare_sync_incomplete
StatsCounterId counter_sll2
Structure to hold thread specific data for all decode modules.
bool valid_settings_ips[EXCEPTION_POLICY_MAX]
void AppLayerDestroyCtxThread(AppLayerThreadCtx *app_tctx)
Destroys the context created by AppLayerGetCtxThread().
StatsCounterId counter_defrag_ipv4_fragments
StatsCounterId counter_etag
StatsCounterMaxId StatsRegisterMaxCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the maximum of all the values assigned to it.
StatsCounterId counter_tcp_active_sessions
void * output_flow_thread_data
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
HashTable * HashTableInit(uint32_t size, uint32_t(*Hash)(struct HashTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *))
int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
Set data for Packet and set length when zero copy is used.
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
#define GET_PKT_DIRECT_DATA(p)
thread_local CaptureStats t_capture_stats
StatsCounterId counter_defrag_ipv6_reassembled
int EngineModeIsIPS(void)
StatsCounterId counter_mpls
#define ENGINE_SET_INVALID_EVENT(p, e)
void DecodeGeneveConfig(void)
void PacketAlertRecycle(PacketAlert *pa_array, uint16_t cnt)
uint16_t packet_alert_max
uint16_t vlan_id[VLAN_MAX_LAYERS]
StatsCounterId counter_ipv4
StatsCounterId counter_flow_total
StatsCounterId counter_arp
StatsCounterId counter_vlan
void PacketDefragPktSetupParent(Packet *parent)
inform defrag "parent" that a pseudo packet is now associated to it.
StatsCounterId counter_defrag_tracker_soft_reuse
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
bool stats_decoder_events
@ PKT_DROP_REASON_STREAM_MIDSTREAM
int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
void PacketInit(Packet *p)
Initialize a packet structure for use.
StatsCounterId counter_erspan
int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
StatsCounterId counter_ipv6inipv6
#define FLOW_PKT_TOSERVER_FIRST
enum ExceptionPolicy DefragGetMemcapExceptionPolicy(void)
StatsCounterId counter_engine_events[DECODE_EVENT_MAX]
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
#define DEBUG_VALIDATE_BUG_ON(exp)
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
@ PKT_DROP_REASON_FLOW_DROP
void DecodeUpdatePacketCounters(ThreadVars *tv, const DecodeThreadVars *dtv, const Packet *p)
StatsCounterId counter_flow_get_used_eval_reject
StatsCounterId counter_flow_get_used_eval
StatsCounterId counter_flow_tcp_reuse
@ PKT_DROP_REASON_DECODE_ERROR
StatsCounterId counter_flow_tcp