33 static bool g_eps_have_exception_policy =
false;
47 return is_json ?
"drop_flow" :
"drop-flow";
49 return is_json ?
"drop_packet" :
"drop-packet";
51 return is_json ?
"pass_packet" :
"pass-packet";
53 return is_json ?
"pass_flow" :
"pass-flow";
88 FlowSetNoPayloadInspectionFlag(p->
flow);
89 FlowSetNoPacketInspectionFlag(p->
flow);
95 DecodeSetNoPayloadInspectionFlag(p);
96 DecodeSetNoPacketInspectionFlag(p);
106 FlowSetNoPacketInspectionFlag(p->
flow);
111 DecodeSetNoPayloadInspectionFlag(p);
112 DecodeSetNoPacketInspectionFlag(p);
123 "flow actions not supported for %s, defaulting to \"drop-packet\"", option);
127 "flow actions not supported for %s, defaulting to \"pass-packet\"", option);
130 SCLogWarning(
"flow actions not supported for %s, defaulting to \"ignore\"", option);
149 const char *option,
const char *value_str)
152 if (strcmp(value_str,
"drop-flow") == 0) {
154 }
else if (strcmp(value_str,
"pass-flow") == 0) {
156 }
else if (strcmp(value_str,
"bypass") == 0) {
158 }
else if (strcmp(value_str,
"drop-packet") == 0) {
160 }
else if (strcmp(value_str,
"pass-packet") == 0) {
162 }
else if (strcmp(value_str,
"reject") == 0) {
164 }
else if (strcmp(value_str,
"ignore") == 0) {
166 }
else if (strcmp(value_str,
"auto") == 0) {
170 "\"%s\" is not a valid exception policy value. Valid options are drop-flow, "
171 "pass-flow, bypass, reject, drop-packet, pass-packet, ignore or auto.",
179 static enum ExceptionPolicy ExceptionPolicyPickAuto(
bool midstream_enabled,
bool support_flow)
192 static enum ExceptionPolicy ExceptionPolicyMasterParse(
const char *value)
194 enum ExceptionPolicy policy = ExceptionPolicyConfigValueParse(
"exception-policy", value);
199 g_eps_have_exception_policy =
true;
207 const char *option,
bool support_flow,
bool midstream)
210 if (g_eps_have_exception_policy) {
211 p = GetMasterExceptionPolicy();
214 p = ExceptionPolicyPickAuto(midstream, support_flow);
218 p = PickPacketAction(option, p);
220 SCLogConfig(
"%s: %s (defined via 'exception-policy' master switch)", option,
226 SCLogConfig(
"%s: %s (defined via 'built-in default' for %s-mode)", option,
235 const char *value_str = NULL;
237 if ((
ConfGet(option, &value_str) == 1) && value_str != NULL) {
238 if (strcmp(option,
"exception-policy") == 0) {
239 policy = ExceptionPolicyMasterParse(value_str);
241 policy = ExceptionPolicyConfigValueParse(option, value_str);
243 policy = ExceptionPolicyPickAuto(
false, support_flow);
246 policy = PickPacketAction(option, policy);
251 policy = ExceptionPolicyGetDefault(option, support_flow,
false);
260 const char *value_str = NULL;
262 if ((
ConfGet(
"stream.midstream-policy", &value_str)) == 1 && value_str != NULL) {
263 policy = ExceptionPolicyConfigValueParse(
"midstream-policy", value_str);
265 policy = ExceptionPolicyPickAuto(midstream_enabled,
true);
266 }
else if (midstream_enabled) {
269 "Error parsing stream.midstream-policy from config file. \"%s\" is "
270 "not a valid exception policy when midstream is enabled. Valid options "
271 "are pass-flow and ignore.",
278 "Error parsing stream.midstream-policy from config file. \"%s\" is "
279 "not a valid exception policy in IDS mode. See our documentation for a "
280 "list of all possible values.",
285 policy = ExceptionPolicyGetDefault(
"stream.midstream-policy",
true, midstream_enabled);
289 FatalErrorOnInit(
"Error parsing stream.midstream-policy from config file. \"%s\" is "
290 "not valid for this exception policy. See our documentation for a list of "
291 "all possible values.",
300 const char *default_str,
bool (*isExceptionPolicyValid)(
enum ExceptionPolicy))
305 if (isExceptionPolicyValid(i)) {
306 snprintf(setting->
eps_name[i],
sizeof(setting->
eps_name[i]),
"%s%s", default_str,
325 uint64_t g_eps_applayer_error_offset_ts = UINT64_MAX;
326 uint64_t g_eps_applayer_error_offset_tc = UINT64_MAX;
327 uint64_t g_eps_pcap_packet_loss = UINT64_MAX;
328 uint64_t g_eps_stream_ssn_memcap = UINT64_MAX;
329 uint64_t g_eps_stream_reassembly_memcap = UINT64_MAX;
330 uint64_t g_eps_flow_memcap = UINT64_MAX;
331 uint64_t g_eps_defrag_memcap = UINT64_MAX;
332 bool g_eps_is_alert_queue_fail_mode =
false;
337 if (strcmp(name,
"simulate-applayer-error-at-offset-ts") == 0) {
343 g_eps_applayer_error_offset_ts =
offset;
344 }
else if (strcmp(name,
"simulate-applayer-error-at-offset-tc") == 0) {
350 g_eps_applayer_error_offset_tc =
offset;
351 }
else if (strcmp(name,
"simulate-packet-loss") == 0) {
353 uint64_t pkt_num = 0;
357 g_eps_pcap_packet_loss = pkt_num;
358 }
else if (strcmp(name,
"simulate-packet-tcp-reassembly-memcap") == 0) {
360 uint64_t pkt_num = 0;
364 g_eps_stream_reassembly_memcap = pkt_num;
365 }
else if (strcmp(name,
"simulate-packet-tcp-ssn-memcap") == 0) {
367 uint64_t pkt_num = 0;
371 g_eps_stream_ssn_memcap = pkt_num;
372 }
else if (strcmp(name,
"simulate-packet-flow-memcap") == 0) {
374 uint64_t pkt_num = 0;
378 g_eps_flow_memcap = pkt_num;
379 }
else if (strcmp(name,
"simulate-packet-defrag-memcap") == 0) {
381 uint64_t pkt_num = 0;
385 g_eps_defrag_memcap = pkt_num;
386 }
else if (strcmp(name,
"simulate-alert-queue-realloc-failure") == 0) {
387 g_eps_is_alert_queue_fail_mode =
true;