filename: *const std::os::raw::c_char,
line: std::os::raw::c_uint,
function: *const std::os::raw::c_char,
- code: std::os::raw::c_int,
message: *const std::os::raw::c_char) -> std::os::raw::c_int;
pub type DetectEngineStateFreeFunc =
}
pub fn sclog(level: Level, file: &str, line: u32, function: &str,
- code: i32, message: &str)
+ message: &str)
{
let filename = basename(file);
sc_log_message(level,
filename,
line,
function,
- code,
message);
}
#[macro_export]
macro_rules!do_log {
- ($level:expr, $code:expr, $($arg:tt)*) => {
+ ($level:expr, $($arg:tt)*) => {
if $crate::log::get_log_level() >= $level as i32 {
- $crate::log::sclog($level, file!(), line!(), $crate::function!(), $code,
+ $crate::log::sclog($level, file!(), line!(), $crate::function!(),
&(format!($($arg)*)));
}
}
#[macro_export]
macro_rules!SCLogError {
($($arg:tt)*) => {
- $crate::do_log!($crate::log::Level::Error, 0, $($arg)*);
+ $crate::do_log!($crate::log::Level::Error, $($arg)*);
};
}
#[macro_export]
macro_rules!SCLogNotice {
($($arg:tt)*) => {
- $crate::do_log!($crate::log::Level::Notice, 0, $($arg)*);
+ $crate::do_log!($crate::log::Level::Notice, $($arg)*);
}
}
#[macro_export]
macro_rules!SCLogInfo {
($($arg:tt)*) => {
- $crate::do_log!($crate::log::Level::Info, 0, $($arg)*);
+ $crate::do_log!($crate::log::Level::Info, $($arg)*);
}
}
#[macro_export]
macro_rules!SCLogPerf {
($($arg:tt)*) => {
- $crate::do_log!($crate::log::Level::Perf, 0, $($arg)*);
+ $crate::do_log!($crate::log::Level::Perf, $($arg)*);
}
}
#[macro_export]
macro_rules!SCLogConfig {
($($arg:tt)*) => {
- $crate::do_log!($crate::log::Level::Config, 0, $($arg)*);
+ $crate::do_log!($crate::log::Level::Config, $($arg)*);
}
}
#[macro_export]
macro_rules!SCLogDebug {
($($arg:tt)*) => {
- do_log!($crate::log::Level::Debug, 0, $($arg)*);
+ do_log!($crate::log::Level::Debug, $($arg)*);
}
}
filename: &str,
line: std::os::raw::c_uint,
function: &str,
- code: std::os::raw::c_int,
message: &str) -> std::os::raw::c_int
{
unsafe {
to_safe_cstring(filename).as_ptr(),
line,
to_safe_cstring(function).as_ptr(),
- code,
to_safe_cstring(message).as_ptr());
}
}
int facility = SCMapEnumNameToValue(facility_s, SCSyslogGetFacilityMap());
if (facility == -1) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid syslog facility: \"%s\","
- " now using \"%s\" as syslog facility", facility_s,
- DEFAULT_ALERT_SYSLOG_FACILITY_STR);
+ SCLogWarning("Invalid syslog facility: \"%s\","
+ " now using \"%s\" as syslog facility",
+ facility_s, DEFAULT_ALERT_SYSLOG_FACILITY_STR);
facility = DEFAULT_ALERT_SYSLOG_FACILITY;
}
SCEnter();
if (!(alproto > ALPROTO_UNKNOWN && alproto < ALPROTO_FAILED)) {
- FatalError(SC_ERR_ALPARSER, "Unknown protocol detected - %u", alproto);
+ FatalError("Unknown protocol detected - %u", alproto);
}
SCReturnUInt(1UL << (uint32_t)alproto);
pe->next = NULL;
if (max_depth != 0 && min_depth >= max_depth) {
- SCLogError(SC_ERR_ALPARSER, "Invalid arguments sent to "
+ SCLogError("Invalid arguments sent to "
"register the probing parser. min_depth >= max_depth");
goto error;
}
if (alproto <= ALPROTO_UNKNOWN || alproto >= ALPROTO_MAX) {
- SCLogError(SC_ERR_ALPARSER, "Invalid arguments sent to register "
- "the probing parser. Invalid alproto - %d", alproto);
+ SCLogError("Invalid arguments sent to register "
+ "the probing parser. Invalid alproto - %d",
+ alproto);
goto error;
}
curr_pe = curr_port->sp;
while (curr_pe != NULL) {
if (curr_pe->alproto == alproto) {
- SCLogError(SC_ERR_ALPARSER, "Duplicate pp registered - "
- "ipproto - %"PRIu8" Port - %"PRIu16" "
+ SCLogError("Duplicate pp registered - "
+ "ipproto - %" PRIu8 " Port - %" PRIu16 " "
"App Protocol - NULL, App Protocol(ID) - "
- "%"PRIu16" min_depth - %"PRIu16" "
- "max_dept - %"PRIu16".",
- ipproto, port, alproto,
- min_depth, max_depth);
+ "%" PRIu16 " min_depth - %" PRIu16 " "
+ "max_dept - %" PRIu16 ".",
+ ipproto, port, alproto, min_depth, max_depth);
goto error;
}
curr_pe = curr_pe->next;
r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
alproto_name, ".detection-ports");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
if (node == NULL) {
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
alproto_name, ".", ipproto_name, ".detection-ports");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
if (node == NULL)
alpd_ctx.spm_global_thread_ctx = SpmInitGlobalThreadCtx(spm_matcher);
if (alpd_ctx.spm_global_thread_ctx == NULL) {
- FatalError(SC_ERR_FATAL, "Unable to alloc SpmGlobalThreadCtx.");
+ FatalError("Unable to alloc SpmGlobalThreadCtx.");
}
for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
alproto, ".enabled");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
alproto, ".", ipproto, ".enabled");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
}
/* Invalid or null value. */
- SCLogError(SC_ERR_FATAL, "Invalid value found for %s.", param);
+ SCLogError("Invalid value found for %s.", param);
exit(EXIT_FAILURE);
disabled:
{
if (expectation_proto[alproto]) {
if (proto != expectation_proto[alproto]) {
- SCLogError(SC_ERR_NOT_SUPPORTED,
- "Expectation on 2 IP protocols are not supported");
+ SCLogError("Expectation on 2 IP protocols are not supported");
}
}
expectation_proto[alproto] = proto;
dnp3->events++;
}
else {
- SCLogWarning(SC_ERR_ALPARSER, "Failed to set event, state or tx pointer was NULL.");
+ SCLogWarning("Failed to set event, state or tx pointer was NULL.");
}
}
{
*event_id = SCMapEnumNameToValue(event_name, dnp3_decoder_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "Event \"%s\" not present in "
- "the DNP3 enum event map table.", event_name);
+ SCLogError("Event \"%s\" not present in "
+ "the DNP3 enum event map table.",
+ event_name);
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, dnp3_decoder_event_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "Event \"%d\" not present in "
- "the DNP3 enum event map table.", event_id);
+ SCLogError("Event \"%d\" not present in "
+ "the DNP3 enum event map table.",
+ event_id);
return -1;
}
*event_id = SCMapEnumNameToValue(event_name, enip_decoder_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "enip's enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "enip's enum map table.",
+ event_name);
/* yes this is fatal */
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, enip_decoder_event_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
- "enip's enum map table.", event_id);
+ SCLogError("event \"%d\" not present in "
+ "enip's enum map table.",
+ event_id);
/* yes this is fatal */
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, app_layer_event_pkt_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
- "app-layer-event's enum map table.", event_id);
+ SCLogError("event \"%d\" not present in "
+ "app-layer-event's enum map table.",
+ event_id);
/* yes this is fatal */
return -1;
}
{
*event_id = SCMapEnumNameToValue(event_name, app_layer_event_pkt_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "app-layer-event's packet event table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "app-layer-event's packet event table.",
+ event_name);
/* this should be treated as fatal */
return -1;
}
if ((ConfGet("app-layer.protocols.ftp.memcap", &conf_val)) == 1)
{
if (ParseSizeStringU64(conf_val, &ftp_config_memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing ftp.memcap "
+ SCLogError("Error parsing ftp.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
}
SCLogInfo("FTP memcap: %"PRIu64, ftp_config_memcap);
if ((ConfGet("app-layer.protocols.ftp.max-tx", &conf_val)) == 1) {
if (ParseSizeStringU32(conf_val, &ftp_config_maxtx) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE,
- "Error parsing ftp.max-tx "
- "from conf file - %s.",
+ SCLogError("Error parsing ftp.max-tx "
+ "from conf file - %s.",
conf_val);
}
SCLogInfo("FTP max tx: %" PRIu32, ftp_config_maxtx);
if ((ConfGet("app-layer.protocols.ftp.max-line-length", &conf_val)) == 1) {
if (ParseSizeStringU32(conf_val, &ftp_max_line_len) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing ftp.max-line-length from conf file - %s.",
- conf_val);
+ SCLogError("Error parsing ftp.max-line-length from conf file - %s.", conf_val);
}
SCLogConfig("FTP max line length: %" PRIu32, ftp_max_line_len);
}
if ((ConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1)
{
if (ParseSizeStringU64(conf_val, &memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing http.memcap "
+ SCLogError("Error parsing http.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(htp_config_memcap, memcap);
uint32_t timeout = HTTP_RANGE_DEFAULT_TIMEOUT;
if (ConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) {
if (ParseSizeStringU64(str, &memcap) < 0) {
- SCLogWarning(SC_EINVAL,
- "memcap value cannot be deduced: %s,"
- " resetting to default",
+ SCLogWarning("memcap value cannot be deduced: %s,"
+ " resetting to default",
str);
memcap = 0;
}
if (ConfGet("app-layer.protocols.http.byterange.timeout", &str) == 1) {
size_t slen = strlen(str);
if (slen > UINT16_MAX || StringParseUint32(&timeout, 10, (uint16_t)slen, str) <= 0) {
- SCLogWarning(SC_EINVAL,
- "timeout value cannot be deduced: %s,"
- " resetting to default",
+ SCLogWarning("timeout value cannot be deduced: %s,"
+ " resetting to default",
str);
timeout = 0;
}
result->flags |= XFF_OVERWRITE;
} else {
if (xff_mode == NULL) {
- SCLogWarning(SC_WARN_XFF_INVALID_MODE, "The XFF mode hasn't been defined, falling back to extra-data mode");
+ SCLogWarning("The XFF mode hasn't been defined, falling back to extra-data mode");
}
else if (strcasecmp(xff_mode, "extra-data") != 0) {
- SCLogWarning(SC_WARN_XFF_INVALID_MODE, "The XFF mode %s is invalid, falling back to extra-data mode",
- xff_mode);
+ SCLogWarning(
+ "The XFF mode %s is invalid, falling back to extra-data mode", xff_mode);
}
result->flags |= XFF_EXTRADATA;
}
result->flags |= XFF_FORWARD;
} else {
if (xff_deployment == NULL) {
- SCLogWarning(SC_WARN_XFF_INVALID_DEPLOYMENT, "The XFF deployment hasn't been defined, falling back to reverse proxy deployment");
+ SCLogWarning("The XFF deployment hasn't been defined, falling back to reverse "
+ "proxy deployment");
}
else if (strcasecmp(xff_deployment, "reverse") != 0) {
- SCLogWarning(SC_WARN_XFF_INVALID_DEPLOYMENT, "The XFF mode %s is invalid, falling back to reverse proxy deployment",
+ SCLogWarning("The XFF mode %s is invalid, falling back to reverse proxy deployment",
xff_deployment);
}
result->flags |= XFF_REVERSE;
if (xff_header != NULL) {
result->header = (char *) xff_header;
} else {
- SCLogWarning(SC_WARN_XFF_INVALID_HEADER, "The XFF header hasn't been defined, using the default %s",
- XFF_DEFAULT);
+ SCLogWarning("The XFF header hasn't been defined, using the default %s", XFF_DEFAULT);
result->header = XFF_DEFAULT;
}
}
IF_HTP_PERSONALITY_NUM(IIS_7_5);
IF_HTP_PERSONALITY_NUM(APACHE_2);
if (strcasecmp("TOMCAT_6_0", str) == 0) {
- SCLogError(SC_WARN_OPTION_OBSOLETE, "Personality %s no "
- "longer supported by libhtp.", str);
+ SCLogError("Personality %s no "
+ "longer supported by libhtp.",
+ str);
return -1;
} else if ((strcasecmp("APACHE", str) == 0) ||
(strcasecmp("APACHE_2_2", str) == 0))
{
- SCLogWarning(SC_WARN_OPTION_OBSOLETE, "Personality %s no "
- "longer supported by libhtp, failing back to "
- "Apache2 personality.", str);
+ SCLogWarning("Personality %s no "
+ "longer supported by libhtp, failing back to "
+ "Apache2 personality.",
+ str);
return HTP_SERVER_APACHE_2;
}
(void)SCRadixFindKeyIPV6BestMatch((uint8_t *)GET_IPV6_DST_ADDR(f), cfgtree, &user_data);
}
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown address family, bug!");
+ SCLogError("unknown address family, bug!");
goto error;
}
SCLogDebug("LIBHTP adding ipv6 server %s at %s: %p",
s->name, pval->val, cfg_prec->cfg);
if (SCRadixAddKeyIPV6String(pval->val, tree, cfg_prec) == NULL) {
- SCLogWarning(SC_EINVAL,
- "LIBHTP failed to "
- "add ipv6 server %s, ignoring",
+ SCLogWarning("LIBHTP failed to "
+ "add ipv6 server %s, ignoring",
pval->val);
}
} else {
SCLogDebug("LIBHTP adding ipv4 server %s at %s: %p",
s->name, pval->val, cfg_prec->cfg);
if (SCRadixAddKeyIPV4String(pval->val, tree, cfg_prec) == NULL) {
- SCLogWarning(SC_EINVAL,
- "LIBHTP failed "
- "to add ipv4 server %s, ignoring",
+ SCLogWarning("LIBHTP failed "
+ "to add ipv4 server %s, ignoring",
pval->val);
}
} /* else - if (strchr(pval->val, ':') != NULL) */
SCLogDebug("LIBHTP default: %s=%s (%d)", p->name, p->val,
personality);
if (htp_config_set_server_personality(cfg_prec->cfg, personality) == HTP_ERROR){
- SCLogWarning(SC_EINVAL,
- "LIBHTP Failed adding "
- "personality \"%s\", ignoring",
+ SCLogWarning("LIBHTP Failed adding "
+ "personality \"%s\", ignoring",
p->val);
} else {
SCLogDebug("LIBHTP personality set to %s",
* Signatures do not expect this, so override it. */
htp_config_set_convert_lowercase(cfg_prec->cfg, HTP_DECODER_URL_PATH, 0);
} else {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "LIBHTP Unknown personality "
- "\"%s\", ignoring", p->val);
+ SCLogWarning("LIBHTP Unknown personality "
+ "\"%s\", ignoring",
+ p->val);
continue;
}
} else if (strcasecmp("request-body-limit", p->name) == 0 ||
strcasecmp("request_body_limit", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->request.body_limit) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing request-body-limit "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing request-body-limit "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("response-body-limit", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->response.body_limit) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing response-body-limit "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing response-body-limit "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("request-body-minimal-inspect-size", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->request.inspect_min_size) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing request-body-minimal-inspect-size "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing request-body-minimal-inspect-size "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("request-body-inspect-window", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->request.inspect_window) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing request-body-inspect-window "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing request-body-inspect-window "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("response-body-minimal-inspect-size", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->response.inspect_min_size) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing response-body-minimal-inspect-size "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing response-body-minimal-inspect-size "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("response-body-inspect-window", p->name) == 0) {
if (ParseSizeStringU32(p->val, &cfg_prec->response.inspect_window) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing response-body-inspect-window "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing response-body-inspect-window "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("response-body-decompress-layer-limit", p->name) == 0) {
uint32_t value = 2;
if (ParseSizeStringU32(p->val, &value) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing response-body-inspect-window "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing response-body-inspect-window "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
#ifdef HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT
htp_config_set_response_decompression_layer_limit(cfg_prec->cfg, value);
#else
- SCLogWarning(SC_WARN_OUTDATED_LIBHTP, "can't set response-body-decompress-layer-limit "
- "to %u, libhtp version too old", value);
+ SCLogWarning("can't set response-body-decompress-layer-limit "
+ "to %u, libhtp version too old",
+ value);
#endif
} else if (strcasecmp("path-convert-backslash-separators", p->name) == 0) {
htp_config_set_backslash_convert_slashes(cfg_prec->cfg,
HTP_DECODER_URL_PATH,
p->val[0]);
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry "
+ SCLogError("Invalid entry "
"for libhtp param path-bestfit-replacement-char");
}
} else if (strcasecmp("path-convert-lowercase", p->name) == 0) {
} else if (strcasecmp(p->val, "decode_invalid") == 0) {
handling = HTP_URL_DECODE_PROCESS_INVALID;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry "
+ SCLogError("Invalid entry "
"for libhtp param path-url-encoding-invalid-handling");
return;
}
} else if (strcasecmp("meta-field-limit", p->name) == 0) {
uint32_t limit = 0;
if (ParseSizeStringU32(p->val, &limit) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error meta-field-limit "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error meta-field-limit "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
if (limit == 0) {
- FatalError(SC_ERR_FATAL, "Error meta-field-limit "
+ FatalError("Error meta-field-limit "
"from conf file cannot be 0. Killing engine");
}
/* set default soft-limit with our new hard limit */
} else if (strcasecmp("lzma-memlimit", p->name) == 0) {
uint32_t limit = 0;
if (ParseSizeStringU32(p->val, &limit) < 0) {
- FatalError(SC_ERR_SIZE_PARSE, "failed to parse 'lzma-memlimit' "
- "from conf file - %s.", p->val);
+ FatalError("failed to parse 'lzma-memlimit' "
+ "from conf file - %s.",
+ p->val);
}
if (limit == 0) {
- FatalError(SC_ERR_SIZE_PARSE, "'lzma-memlimit' "
+ FatalError("'lzma-memlimit' "
"from conf file cannot be 0.");
}
/* set default soft-limit with our new hard limit */
} else if (!ConfValIsFalse(p->val)) {
int8_t limit;
if (StringParseInt8(&limit, 10, 0, (const char *)p->val) < 0) {
- FatalError(SC_ERR_SIZE_PARSE,
- "failed to parse 'lzma-enabled' "
- "from conf file - %s.",
+ FatalError("failed to parse 'lzma-enabled' "
+ "from conf file - %s.",
p->val);
}
SCLogConfig("Setting HTTP LZMA decompression layers to %" PRIu32 "", (int)limit);
} else if (strcasecmp("compression-bomb-limit", p->name) == 0) {
uint32_t limit = 0;
if (ParseSizeStringU32(p->val, &limit) < 0) {
- FatalError(SC_ERR_SIZE_PARSE, "failed to parse 'compression-bomb-limit' "
- "from conf file - %s.", p->val);
+ FatalError("failed to parse 'compression-bomb-limit' "
+ "from conf file - %s.",
+ p->val);
}
if (limit == 0) {
- FatalError(SC_ERR_SIZE_PARSE, "'compression-bomb-limit' "
+ FatalError("'compression-bomb-limit' "
"from conf file cannot be 0.");
}
/* set default soft-limit with our new hard limit */
uint32_t limit = 0;
// between 1 usec and 1 second
if (StringParseU32RangeCheck(&limit, 10, 0, p->val, 1, 1000000) < 0) {
- FatalError(SC_ERR_SIZE_PARSE,
- "failed to parse 'decompression-time-limit' "
- "from conf file - %s.",
+ FatalError("failed to parse 'decompression-time-limit' "
+ "from conf file - %s.",
p->val);
}
SCLogConfig("Setting HTTP decompression time limit to %" PRIu32 " usec", limit);
uint32_t range;
if (StringParseU32RangeCheck(&range, 10, 0,
(const char *)p->val, 0, 100) < 0) {
- SCLogError(SC_EINVAL,
- "Invalid value for randomize"
- "-inspection-range setting from conf file - \"%s\"."
- " It should be a valid integer less than or equal to 100."
- " Killing engine",
+ SCLogError("Invalid value for randomize"
+ "-inspection-range setting from conf file - \"%s\"."
+ " It should be a valid integer less than or equal to 100."
+ " Killing engine",
p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("both", pval->val) == 0) {
cfg_prec->swf_compression_type = HTTP_SWF_COMPRESSION_BOTH;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Invalid entry for "
+ SCLogError("Invalid entry for "
"swf-decompression.type: %s - "
- "Killing engine", pval->val);
+ "Killing engine",
+ pval->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("compress-depth", pval->name) == 0) {
if (ParseSizeStringU32(pval->val, &cfg_prec->swf_compress_depth) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE,
- "Error parsing swf-decompression.compression-depth "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing swf-decompression.compression-depth "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else if (strcasecmp("decompress-depth", pval->name) == 0) {
if (ParseSizeStringU32(pval->val, &cfg_prec->swf_decompress_depth) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE,
- "Error parsing swf-decompression.decompression-depth "
- "from conf file - %s. Killing engine", p->val);
+ SCLogError("Error parsing swf-decompression.decompression-depth "
+ "from conf file - %s. Killing engine",
+ p->val);
exit(EXIT_FAILURE);
}
} else {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "Ignoring unknown param %s", pval->name);
+ SCLogWarning("Ignoring unknown param %s", pval->name);
}
}
} else {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "LIBHTP Ignoring unknown "
- "default config: %s", p->name);
+ SCLogWarning("LIBHTP Ignoring unknown "
+ "default config: %s",
+ p->name);
}
} /* TAILQ_FOREACH(p, &default_config->head, next) */
/* Default Config */
cfglist.cfg = htp_config_create();
if (NULL == cfglist.cfg) {
- FatalError(SC_ERR_FATAL, "Failed to create HTP default config");
+ FatalError("Failed to create HTP default config");
}
SCLogDebug("LIBHTP default config: %p", cfglist.cfg);
HTPConfigSetDefaultsPhase1(&cfglist);
cfglist.next->next = nextrec;
cfglist.next->cfg = htp_config_create();
if (NULL == cfglist.next->cfg) {
- FatalError(SC_ERR_FATAL, "Failed to create HTP server config");
+ FatalError("Failed to create HTP server config");
}
HTPConfigSetDefaultsPhase1(htprec);
{
*event_id = SCMapEnumNameToValue(event_name, http_decoder_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "http's enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "http's enum map table.",
+ event_name);
/* this should be treated as fatal */
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, http_decoder_event_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
- "http's enum map table.", event_id);
+ SCLogError("event \"%d\" not present in "
+ "http's enum map table.",
+ event_id);
/* this should be treated as fatal */
return -1;
}
if (p != NULL) {
uint32_t value;
if (ParseSizeStringU32(p->val, &value) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "invalid value for max-msg-length: %s", p->val);
+ SCLogError("invalid value for max-msg-length: %s", p->val);
} else {
max_msg_len = value;
}
r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
alproto_name, ".enabled");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
alproto_name, ".", ipproto, ".enabled");
if (r < 0) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
} else if (r > (int)sizeof(param)) {
- FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
+ FatalError("buffer not big enough to write param.");
}
node = ConfGetNode(param);
} else if (strcasecmp(node->val, "detection-only") == 0) {
goto disabled;
} else {
- SCLogError(SC_ERR_FATAL, "Invalid value found for %s.", param);
+ SCLogError("Invalid value found for %s.", param);
exit(EXIT_FAILURE);
}
const char *ip_proto_str = NULL;
if (p == NULL)
- FatalError(SC_ERR_FATAL, "Call to %s with NULL pointer.", __FUNCTION__);
+ FatalError("Call to %s with NULL pointer.", __FUNCTION__);
alproto = StringToAppProto(p->name);
if (alproto == ALPROTO_UNKNOWN || alproto == ALPROTO_FAILED)
- FatalError(SC_ERR_FATAL, "Unknown or invalid AppProto '%s'.", p->name);
+ FatalError("Unknown or invalid AppProto '%s'.", p->name);
ip_proto_str = IpProtoToString(p->ip_proto);
if (ip_proto_str == NULL)
- FatalError(SC_ERR_FATAL, "Unknown or unsupported ip_proto field in parser '%s'", p->name);
+ FatalError("Unknown or unsupported ip_proto field in parser '%s'", p->name);
SCLogDebug("%s %s protocol detection enabled.", ip_proto_str, p->name);
const char *ip_proto_str = NULL;
if (p == NULL)
- FatalError(SC_ERR_FATAL, "Call to %s with NULL pointer.", __FUNCTION__);
+ FatalError("Call to %s with NULL pointer.", __FUNCTION__);
if (alproto == ALPROTO_UNKNOWN || alproto >= ALPROTO_FAILED)
- FatalError(SC_ERR_FATAL, "Unknown or invalid AppProto '%s'.", p->name);
+ FatalError("Unknown or invalid AppProto '%s'.", p->name);
ip_proto_str = IpProtoToString(p->ip_proto);
if (ip_proto_str == NULL)
- FatalError(SC_ERR_FATAL, "Unknown or unsupported ip_proto field in parser '%s'", p->name);
+ FatalError("Unknown or unsupported ip_proto field in parser '%s'", p->name);
SCLogDebug("Registering %s protocol parser.", p->name);
/* new_val_len: scheme value from config e.g. 'http' + '://' + null terminator */
size_t new_val_len = strlen(scheme->val) + 3 + 1;
if (new_val_len > UINT16_MAX) {
- FatalError(SC_ERR_FATAL, "Too long value for extract-urls-schemes");
+ FatalError("Too long value for extract-urls-schemes");
}
char *new_val = SCMalloc(new_val_len);
if (unlikely(new_val == NULL)) {
- FatalError(SC_ERR_FATAL, "SCMalloc failure.");
+ FatalError("SCMalloc failure.");
}
int r = snprintf(new_val, new_val_len, "%s://", scheme->val);
if (r < 0 || r >= (int)new_val_len) {
- FatalError(SC_ERR_FATAL, "snprintf failure.");
+ FatalError("snprintf failure.");
}
/* replace existing scheme value stored on the linked list with new value including
* extract-urls-schemes wasn't found in the config */
ConfNode *seq_node = ConfNodeNew();
if (unlikely(seq_node == NULL)) {
- FatalError(SC_ERR_FATAL, "ConfNodeNew failure.");
+ FatalError("ConfNodeNew failure.");
}
ConfNode *scheme = ConfNodeNew();
if (unlikely(scheme == NULL)) {
- FatalError(SC_ERR_FATAL, "ConfNodeNew failure.");
+ FatalError("ConfNodeNew failure.");
}
seq_node->name = SCStrdup("extract-urls-schemes");
if (unlikely(seq_node->name == NULL)) {
- FatalError(SC_ERR_FATAL, "SCStrdup failure.");
+ FatalError("SCStrdup failure.");
}
scheme->val = SCStrdup("http://");
if (unlikely(scheme->val == NULL)) {
- FatalError(SC_ERR_FATAL, "SCStrdup failure.");
+ FatalError("SCStrdup failure.");
}
seq_node->is_seq = 1;
TAILQ_FOREACH(p, &t->head, next) {
if (strcasecmp("content-limit", p->name) == 0) {
if (ParseSizeStringU32(p->val, &content_limit) < 0) {
- SCLogWarning(SC_ERR_SIZE_PARSE,
- "parsing content-limit %s failed", p->val);
+ SCLogWarning("parsing content-limit %s failed", p->val);
content_limit = FILEDATA_CONTENT_LIMIT;
}
smtp_config.content_limit = content_limit;
if (strcasecmp("content-inspect-min-size", p->name) == 0) {
if (ParseSizeStringU32(p->val, &content_inspect_min_size) < 0) {
- SCLogWarning(SC_ERR_SIZE_PARSE,
- "parsing content-inspect-min-size %s failed", p->val);
+ SCLogWarning("parsing content-inspect-min-size %s failed", p->val);
content_inspect_min_size = FILEDATA_CONTENT_INSPECT_MIN_SIZE;
}
smtp_config.content_inspect_min_size = content_inspect_min_size;
if (strcasecmp("content-inspect-window", p->name) == 0) {
if (ParseSizeStringU32(p->val, &content_inspect_window) < 0) {
- SCLogWarning(SC_ERR_SIZE_PARSE,
- "parsing content-inspect-window %s failed", p->val);
+ SCLogWarning("parsing content-inspect-window %s failed", p->val);
content_inspect_window = FILEDATA_CONTENT_INSPECT_WINDOW;
}
smtp_config.content_inspect_window = content_inspect_window;
smtp_config.raw_extraction = SMTP_RAW_EXTRACTION_DEFAULT_VALUE;
}
if (smtp_config.raw_extraction && smtp_config.decode_mime) {
- SCLogError(SC_ERR_CONF_YAML_ERROR,
- "\"decode-mime\" and \"raw-extraction\" "
- "options can't be enabled at the same time, "
- "disabling raw extraction");
+ SCLogError("\"decode-mime\" and \"raw-extraction\" "
+ "options can't be enabled at the same time, "
+ "disabling raw extraction");
smtp_config.raw_extraction = 0;
}
{
*event_id = SCMapEnumNameToValue(event_name, smtp_decoder_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "smtp's enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "smtp's enum map table.",
+ event_name);
/* yes this is fatal */
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, smtp_decoder_event_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
- "smtp's enum map table.", event_id);
+ SCLogError("event \"%d\" not present in "
+ "smtp's enum map table.",
+ event_id);
/* yes this is fatal */
return -1;
}
{
*event_id = SCMapEnumNameToValue(event_name, tls_decoder_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "ssl's enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "ssl's enum map table.",
+ event_name);
/* yes this is fatal */
return -1;
}
{
*event_name = SCMapEnumValueToName(event_id, tls_decoder_event_table);
if (*event_name == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%d\" not present in "
- "ssl's enum map table.", event_id);
+ SCLogError("event \"%d\" not present in "
+ "ssl's enum map table.",
+ event_id);
/* yes this is fatal */
return -1;
}
if (g_disable_hashing) {
if (SC_ATOMIC_GET(ssl_config.enable_ja3)) {
- SCLogWarning(
- SC_WARN_NO_JA3_SUPPORT, "MD5 calculation has been disabled, disabling JA3");
+ SCLogWarning("MD5 calculation has been disabled, disabling JA3");
SC_ATOMIC_SET(ssl_config.enable_ja3, 0);
}
} else {
if (ep == NULL) {
conf_dirname = SCStrdup(".");
if (conf_dirname == NULL) {
- FatalError(SC_ERR_FATAL,
- "ERROR: Failed to allocate memory while loading configuration.");
+ FatalError("ERROR: Failed to allocate memory while loading configuration.");
}
}
else {
conf_dirname = SCStrdup(filename);
if (conf_dirname == NULL) {
- FatalError(SC_ERR_FATAL,
- "ERROR: Failed to allocate memory while loading configuration.");
+ FatalError("ERROR: Failed to allocate memory while loading configuration.");
}
conf_dirname[ep - filename] = '\0';
}
int ret = -1;
if (yaml_parser_initialize(&parser) != 1) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Failed to initialize YAML parser");
+ SCLogError("Failed to initialize YAML parser");
return -1;
}
file = fopen(include_filename, "r");
if (file == NULL) {
- SCLogError(SC_ERR_FOPEN,
- "Failed to open configuration include file %s: %s",
- include_filename, strerror(errno));
+ SCLogError("Failed to open configuration include file %s: %s", include_filename,
+ strerror(errno));
goto done;
}
yaml_parser_set_input_file(&parser, file);
if (ConfYamlParse(&parser, parent, 0, 0) != 0) {
- SCLogError(SC_ERR_CONF_YAML_ERROR,
- "Failed to include configuration file %s", filename);
+ SCLogError("Failed to include configuration file %s", filename);
goto done;
}
int was_empty = -1;
if (rlevel++ > RECURSION_LIMIT) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Recursion limit reached while parsing "
- "configuration file, aborting.");
+ SCLogError("Recursion limit reached while parsing "
+ "configuration file, aborting.");
return -1;
}
while (!done) {
if (!yaml_parser_parse(parser, &event)) {
- SCLogError(SC_ERR_CONF_YAML_ERROR,
- "Failed to parse configuration file at line %" PRIuMAX ": %s\n",
- (uintmax_t)parser->problem_mark.line, parser->problem);
+ SCLogError("Failed to parse configuration file at line %" PRIuMAX ": %s\n",
+ (uintmax_t)parser->problem_mark.line, parser->problem);
retval = -1;
break;
}
yaml_version_directive_t *ver =
event.data.document_start.version_directive;
if (ver == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "ERROR: Invalid configuration file.");
- SCLogError(SC_ERR_CONF_YAML_ERROR,
- "The configuration file must begin with the following two lines: %%YAML 1.1 and ---");
+ SCLogError("ERROR: Invalid configuration file.");
+ SCLogError("The configuration file must begin with the following two lines: %%YAML "
+ "1.1 and ---");
goto fail;
}
int major = ver->major;
int minor = ver->minor;
if (!(major == YAML_VERSION_MAJOR && minor == YAML_VERSION_MINOR)) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "ERROR: Invalid YAML version. Must be 1.1");
+ SCLogError("ERROR: Invalid YAML version. Must be 1.1");
goto fail;
}
}
(strcmp(parent->name, "port-groups") == 0)))) {
Mangle(node->name);
if (mangle_errors < MANGLE_ERRORS_MAX) {
- SCLogWarning(SC_WARN_DEPRECATED,
- "%s is deprecated. Please use %s on line %"PRIuMAX".",
- value, node->name, (uintmax_t)parser->mark.line+1);
+ SCLogWarning("%s is deprecated. Please use %s on line %" PRIuMAX
+ ".",
+ value, node->name, (uintmax_t)parser->mark.line + 1);
mangle_errors++;
if (mangle_errors >= MANGLE_ERRORS_MAX)
- SCLogWarning(SC_WARN_DEPRECATED, "not showing more "
- "parameter name warnings.");
+ SCLogWarning("not showing more "
+ "parameter name warnings.");
}
}
}
ConfNode *root = ConfGetRootNode();
if (yaml_parser_initialize(&parser) != 1) {
- SCLogError(SC_ERR_FATAL, "failed to initialize yaml parser.");
+ SCLogError("failed to initialize yaml parser.");
return -1;
}
struct stat stat_buf;
if (stat(filename, &stat_buf) == 0) {
if (stat_buf.st_mode & S_IFDIR) {
- SCLogError(SC_ERR_FATAL, "yaml argument is not a file but a directory: %s. "
- "Please specify the yaml file in your -c option.", filename);
+ SCLogError("yaml argument is not a file but a directory: %s. "
+ "Please specify the yaml file in your -c option.",
+ filename);
yaml_parser_delete(&parser);
return -1;
}
// coverity[toctou : FALSE]
infile = fopen(filename, "r");
if (infile == NULL) {
- SCLogError(SC_ERR_FATAL, "failed to open file: %s: %s", filename,
- strerror(errno));
+ SCLogError("failed to open file: %s: %s", filename, strerror(errno));
yaml_parser_delete(&parser);
return -1;
}
ConfNode *root = ConfGetNode(prefix);
if (yaml_parser_initialize(&parser) != 1) {
- SCLogError(SC_ERR_FATAL, "failed to initialize yaml parser.");
+ SCLogError("failed to initialize yaml parser.");
return -1;
}
/* coverity[toctou] */
if (stat(filename, &stat_buf) == 0) {
if (stat_buf.st_mode & S_IFDIR) {
- SCLogError(SC_ERR_FATAL, "yaml argument is not a file but a directory: %s. "
- "Please specify the yaml file in your -c option.", filename);
+ SCLogError("yaml argument is not a file but a directory: %s. "
+ "Please specify the yaml file in your -c option.",
+ filename);
return -1;
}
}
/* coverity[toctou] */
infile = fopen(filename, "r");
if (infile == NULL) {
- SCLogError(SC_ERR_FATAL, "failed to open file: %s: %s", filename,
- strerror(errno));
+ SCLogError("failed to open file: %s: %s", filename, strerror(errno));
yaml_parser_delete(&parser);
return -1;
}
char *next;
if (strlcpy(node_name, name, sizeof(node_name)) >= sizeof(node_name)) {
- SCLogError(SC_ERR_CONF_NAME_TOO_LONG,
- "Configuration name too long: %s", name);
+ SCLogError("Configuration name too long: %s", name);
return NULL;
}
if ((node = ConfNodeLookupChild(parent, key)) == NULL) {
node = ConfNodeNew();
if (unlikely(node == NULL)) {
- SCLogWarning(SC_ENOMEM, "Failed to allocate memory for configuration.");
+ SCLogWarning("Failed to allocate memory for configuration.");
goto end;
}
node->name = SCStrdup(key);
if (unlikely(node->name == NULL)) {
ConfNodeFree(node);
node = NULL;
- SCLogWarning(SC_ENOMEM, "Failed to allocate memory for configuration.");
+ SCLogWarning("Failed to allocate memory for configuration.");
goto end;
}
node->parent = parent;
}
root = ConfNodeNew();
if (root == NULL) {
- FatalError(SC_ERR_FATAL,
- "ERROR: Failed to allocate memory for root configuration node, "
- "aborting.");
+ FatalError("ERROR: Failed to allocate memory for root configuration node, "
+ "aborting.");
}
SCLogDebug("configuration module initialized");
}
char *next;
if (strlcpy(node_name, name, sizeof(node_name)) >= sizeof(node_name)) {
- SCLogError(SC_ERR_CONF_NAME_TOO_LONG,
- "Configuration name too long: %s", name);
+ SCLogError("Configuration name too long: %s", name);
return NULL;
}
return 0;
if (strval == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed integer value "
- "for %s: NULL", name);
+ SCLogError("malformed integer value "
+ "for %s: NULL",
+ name);
return 0;
}
errno = 0;
tmpint = strtoimax(strval, &endptr, 0);
if (strval[0] == '\0' || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed integer value "
- "for %s: '%s'", name, strval);
+ SCLogError("malformed integer value "
+ "for %s: '%s'",
+ name, strval);
return 0;
}
if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN)) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "integer value for %s out "
- "of range: '%s'", name, strval);
+ SCLogError("integer value for %s out "
+ "of range: '%s'",
+ name, strval);
return 0;
}
errno = 0;
tmpint = strtoimax(strval, &endptr, 0);
if (strval[0] == '\0' || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed integer value "
- "for %s with base %s: '%s'", name, base->name, strval);
+ SCLogError("malformed integer value "
+ "for %s with base %s: '%s'",
+ name, base->name, strval);
return 0;
}
if (errno == ERANGE && (tmpint == INTMAX_MAX || tmpint == INTMAX_MIN)) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "integer value for %s with "
- " base %s out of range: '%s'", name, base->name, strval);
+ SCLogError("integer value for %s with "
+ " base %s out of range: '%s'",
+ name, base->name, strval);
return 0;
}
/* Find initial node which holds all interfaces */
ifaces_list_node = ConfGetNode(ifaces_node_name);
if (ifaces_list_node == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "unable to find %s config", ifaces_node_name);
+ SCLogError("unable to find %s config", ifaces_node_name);
return NULL;
}
*if_default = ConfSetIfaceNode(ifaces_node_name, default_iface);
if (*if_root == NULL && *if_default == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR,
- "unable to find configuration for the interface \"%s\" or the default "
- "configuration (\"%s\")",
+ SCLogError("unable to find configuration for the interface \"%s\" or the default "
+ "configuration (\"%s\")",
iface, default_iface);
return (-ENODEV);
}
/* warn if we are using legacy config to enable stats */
ConfNode *gstats = ConfGetNode("stats");
if (gstats == NULL) {
- SCLogWarning(SC_ERR_STATS_LOG_GENERIC, "global stats config is missing. "
- "Stats enabled through legacy stats.log. "
- "See %s/configuration/suricata-yaml.html#stats", GetDocURL());
+ SCLogWarning("global stats config is missing. "
+ "Stats enabled through legacy stats.log. "
+ "See %s/configuration/suricata-yaml.html#stats",
+ GetDocURL());
}
const char *interval = ConfNodeLookupChildValue(stats, "interval");
if (interval != NULL)
if (StringParseUint32(&stats_tts, 10, 0, interval) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "interval: \"%s\". Resetting to %d.",
+ SCLogWarning("Invalid value for "
+ "interval: \"%s\". Resetting to %d.",
interval, STATS_MGMTT_TTS);
stats_tts = STATS_MGMTT_TTS;
}
/* init the lock used by StatsThreadStore */
if (SCMutexInit(&stats_ctx->sts_lock, NULL) != 0) {
- FatalError(SC_ERR_FATAL, "error initializing sts mutex");
+ FatalError("error initializing sts mutex");
}
if (stats_enabled && !OutputStatsLoggersRegistered()) {
/* if the unix command socket is enabled we do the background
* stats sync just in case someone runs 'dump-counters' */
if (!ConfUnixSocketIsEnable()) {
- SCLogWarning(SC_WARN_NO_STATS_LOGGERS, "stats are enabled but no loggers are active");
+ SCLogWarning("stats are enabled but no loggers are active");
stats_enabled = false;
SCReturn;
}
SCDropCaps(tv_local);
if (stats_ctx == NULL) {
- SCLogError(SC_ERR_STATS_NOT_INIT, "Stats API not init"
+ SCLogError("Stats API not init"
"StatsInitCounterApi() has to be called first");
TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE);
return NULL;
BUG_ON(tm->ThreadInit == NULL);
int r = tm->ThreadInit(tv_local, NULL, &stats_thread_data);
if (r != 0 || stats_thread_data == NULL) {
- SCLogError(SC_ERR_THREAD_INIT, "Stats API "
+ SCLogError("Stats API "
"ThreadInit failed");
TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE);
return NULL;
r = tm->ThreadDeinit(tv_local, stats_thread_data);
if (r != TM_ECODE_OK) {
- SCLogError(SC_ERR_THREAD_DEINIT, "Stats Counter API "
+ SCLogError("Stats Counter API "
"ThreadDeinit failed");
}
SCDropCaps(tv_local);
if (stats_ctx == NULL) {
- SCLogError(SC_ERR_STATS_NOT_INIT, "Stats API not init"
+ SCLogError("Stats API not init"
"StatsInitCounterApi() has to be called first");
TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE);
return NULL;
stats_table.stats = SCCalloc(stats_table.nstats, sizeof(StatsRecord));
if (stats_table.stats == NULL) {
stats_table.nstats = 0;
- SCLogError(SC_ENOMEM, "could not alloc memory for stats");
+ SCLogError("could not alloc memory for stats");
return -1;
}
stats_table.tstats = SCCalloc(stats_table.ntstats, array_size);
if (stats_table.tstats == NULL) {
stats_table.ntstats = 0;
- SCLogError(SC_ENOMEM, "could not alloc memory for stats");
+ SCLogError("could not alloc memory for stats");
return -1;
}
{
BUG_ON(stats_ctx != NULL);
if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in StatsInitCtx. Exiting...");
+ FatalError("Fatal error encountered in StatsInitCtx. Exiting...");
}
memset(stats_ctx, 0, sizeof(StatsGlobalContext));
tv_wakeup = TmThreadCreateMgmtThread(thread_name_counter_wakeup,
StatsWakeupThread, 1);
if (tv_wakeup == NULL) {
- FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread "
+ FatalError("TmThreadCreateMgmtThread "
"failed");
}
if (TmThreadSpawn(tv_wakeup) != 0) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
+ FatalError("TmThreadSpawn failed for "
"StatsWakeupThread");
}
tv_mgmt = TmThreadCreateMgmtThread(thread_name_counter_stats,
StatsMgmtThread, 1);
if (tv_mgmt == NULL) {
- FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread failed");
+ FatalError("TmThreadCreateMgmtThread failed");
}
if (TmThreadSpawn(tv_mgmt) != 0) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
+ FatalError("TmThreadSpawn failed for "
"StatsWakeupThread");
}
if (value >= 0 && value <= 255)
hash[x] = (uint8_t)value;
else {
- SCLogError(SC_ERR_INVALID_HASH, "hash byte out of range %ld", value);
+ SCLogError("hash byte out of range %ld", value);
return -1;
}
}
uint16_t v = 0;
int r = StringParseU16RangeCheck(&v, 10, strlen(ptrs[0]), ptrs[0], 0, USHRT_MAX);
if (r != (int)strlen(ptrs[0])) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE,
- "'%s' is not a valid reputation value (0-65535)", ptrs[0]);
+ SCLogError("'%s' is not a valid reputation value (0-65535)", ptrs[0]);
return -1;
}
SCLogDebug("v %"PRIu16" raw %s", v, ptrs[0]);
FILE *fp = fopen(set->load, fopen_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_DATASET, "fopen '%s' failed: %s", set->load, strerror(errno));
+ SCLogError("fopen '%s' failed: %s", set->load, strerror(errno));
return -1;
}
struct in_addr in;
if (inet_pton(AF_INET, line, &in) != 1) {
- FatalErrorOnInit(SC_ERR_DATASET, "dataset data parse failed %s/%s: %s", set->name,
- set->load, line);
+ FatalErrorOnInit("dataset data parse failed %s/%s: %s", set->name, set->load, line);
continue;
}
if (DatasetAdd(set, (const uint8_t *)&in.s_addr, 4) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
struct in_addr in;
if (inet_pton(AF_INET, line, &in) != 1) {
- FatalErrorOnInit(SC_ERR_DATASET, "dataset data parse failed %s/%s: %s", set->name,
- set->load, line);
+ FatalErrorOnInit("dataset data parse failed %s/%s: %s", set->name, set->load, line);
continue;
}
DataRepType rep = { .value = 0 };
if (ParseRepLine(r, strlen(r), &rep) < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad rep for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad rep for dataset %s/%s", set->name, set->load);
continue;
}
SCLogDebug("rep v:%u", rep.value);
if (DatasetAddwRep(set, (const uint8_t *)&in.s_addr, 4, &rep) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
if (got_colon) {
uint32_t ip6addr[4];
if (inet_pton(AF_INET6, line, in6) != 1) {
- FatalErrorOnInit(SC_ERR_DATASET, "dataset data parse failed %s/%s: %s", set->name,
- set->load, line);
+ FatalErrorOnInit("dataset data parse failed %s/%s: %s", set->name, set->load, line);
return -1;
}
memcpy(&ip6addr, in6->s6_addr, sizeof(ip6addr));
/* IPv4 case */
struct in_addr in;
if (inet_pton(AF_INET, line, &in) != 1) {
- FatalErrorOnInit(SC_ERR_DATASET, "dataset data parse failed %s/%s: %s", set->name,
- set->load, line);
+ FatalErrorOnInit("dataset data parse failed %s/%s: %s", set->name, set->load, line);
return -1;
}
memset(in6, 0, sizeof(struct in6_addr));
FILE *fp = fopen(set->load, fopen_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_DATASET, "fopen '%s' failed: %s", set->load, strerror(errno));
+ SCLogError("fopen '%s' failed: %s", set->load, strerror(errno));
return -1;
}
struct in6_addr in6;
int ret = ParseIpv6String(set, line, &in6);
if (ret < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "unable to parse IP address");
+ FatalErrorOnInit("unable to parse IP address");
continue;
}
if (DatasetAdd(set, (const uint8_t *)&in6.s6_addr, 16) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
struct in6_addr in6;
int ret = ParseIpv6String(set, line, &in6);
if (ret < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "unable to parse IP address");
+ FatalErrorOnInit("unable to parse IP address");
continue;
}
DataRepType rep = { .value = 0 };
if (ParseRepLine(r, strlen(r), &rep) < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad rep for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad rep for dataset %s/%s", set->name, set->load);
continue;
}
SCLogDebug("rep v:%u", rep.value);
if (DatasetAddwRep(set, (const uint8_t *)&in6.s6_addr, 16, &rep) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
FILE *fp = fopen(set->load, fopen_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_DATASET, "fopen '%s' failed: %s",
- set->load, strerror(errno));
+ SCLogError("fopen '%s' failed: %s", set->load, strerror(errno));
return -1;
}
uint8_t hash[16];
if (HexToRaw((const uint8_t *)line, 32, hash, sizeof(hash)) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "bad hash for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad hash for dataset %s/%s", set->name, set->load);
continue;
}
if (DatasetAdd(set, (const uint8_t *)hash, 16) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
uint8_t hash[16];
if (HexToRaw((const uint8_t *)line, 32, hash, sizeof(hash)) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "bad hash for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad hash for dataset %s/%s", set->name, set->load);
continue;
}
DataRepType rep = { .value = 0};
if (ParseRepLine(line + 33, strlen(line) - 33, &rep) < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad rep for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad rep for dataset %s/%s", set->name, set->load);
continue;
}
SCLogDebug("rep v:%u", rep.value);
if (DatasetAddwRep(set, hash, 16, &rep) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
}
else {
- FatalErrorOnInit(
- SC_ERR_DATASET, "MD5 bad line len %u: '%s'", (uint32_t)strlen(line), line);
+ FatalErrorOnInit("MD5 bad line len %u: '%s'", (uint32_t)strlen(line), line);
continue;
}
}
FILE *fp = fopen(set->load, fopen_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_DATASET, "fopen '%s' failed: %s",
- set->load, strerror(errno));
+ SCLogError("fopen '%s' failed: %s", set->load, strerror(errno));
return -1;
}
uint8_t hash[32];
if (HexToRaw((const uint8_t *)line, 64, hash, sizeof(hash)) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "bad hash for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad hash for dataset %s/%s", set->name, set->load);
continue;
}
if (DatasetAdd(set, (const uint8_t *)hash, (uint32_t)32) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
uint8_t hash[32];
if (HexToRaw((const uint8_t *)line, 64, hash, sizeof(hash)) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "bad hash for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad hash for dataset %s/%s", set->name, set->load);
continue;
}
DataRepType rep = { .value = 0 };
if (ParseRepLine(line + 65, strlen(line) - 65, &rep) < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad rep for dataset %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad rep for dataset %s/%s", set->name, set->load);
continue;
}
SCLogDebug("rep %u", rep.value);
if (DatasetAddwRep(set, hash, 32, &rep) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
FILE *fp = fopen(set->load, fopen_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_DATASET, "fopen '%s' failed: %s",
- set->load, strerror(errno));
+ SCLogError("fopen '%s' failed: %s", set->load, strerror(errno));
return -1;
}
Base64Ecode code = DecodeBase64(decoded, strlen(line), (const uint8_t *)line,
strlen(line), &consumed, &num_decoded, BASE64_MODE_STRICT);
if (code == BASE64_ECODE_ERR) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad base64 encoding %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad base64 encoding %s/%s", set->name, set->load);
continue;
}
if (DatasetAdd(set, (const uint8_t *)decoded, num_decoded) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
Base64Ecode code = DecodeBase64(decoded, strlen(line), (const uint8_t *)line,
strlen(line), &consumed, &num_decoded, BASE64_MODE_STRICT);
if (code == BASE64_ECODE_ERR) {
- FatalErrorOnInit(SC_ERR_DATASET, "bad base64 encoding %s/%s", set->name, set->load);
+ FatalErrorOnInit("bad base64 encoding %s/%s", set->name, set->load);
continue;
}
DataRepType rep = { .value = 0 };
if (ParseRepLine(r, strlen(r), &rep) < 0) {
- FatalErrorOnInit(SC_ERR_DATASET, "die: bad rep");
+ FatalErrorOnInit("die: bad rep");
continue;
}
SCLogDebug("rep %u", rep.value);
if (DatasetAddwRep(set, (const uint8_t *)decoded, num_decoded, &rep) < 0) {
- FatalErrorOnInit(
- SC_ERR_DATASET, "dataset data add failed %s/%s", set->name, set->load);
+ FatalErrorOnInit("dataset data add failed %s/%s", set->name, set->load);
continue;
}
cnt++;
Dataset *set = DatasetSearchByName(name);
if (set) {
if (type != DATASET_TYPE_NOTSET && set->type != type) {
- SCLogError(SC_ERR_DATASET, "dataset %s already "
- "exists and is of type %u",
- set->name, set->type);
+ SCLogError("dataset %s already "
+ "exists and is of type %u",
+ set->name, set->type);
SCMutexUnlock(&sets_lock);
return NULL;
}
} else {
if ((save == NULL && strlen(set->save) > 0) ||
(save != NULL && strcmp(set->save, save) != 0)) {
- SCLogError(SC_ERR_DATASET, "dataset %s save mismatch: %s != %s",
- set->name, set->save, save);
+ SCLogError("dataset %s save mismatch: %s != %s", set->name, set->save, save);
SCMutexUnlock(&sets_lock);
return NULL;
}
if ((load == NULL && strlen(set->load) > 0) ||
(load != NULL && strcmp(set->load, load) != 0)) {
- SCLogError(SC_ERR_DATASET, "dataset %s load mismatch: %s != %s",
- set->name, set->load, load);
+ SCLogError("dataset %s load mismatch: %s != %s", set->name, set->load, load);
SCMutexUnlock(&sets_lock);
return NULL;
}
return set;
} else {
if (type == DATASET_TYPE_NOTSET) {
- SCLogError(SC_ERR_DATASET, "dataset %s not defined", name);
+ SCLogError("dataset %s not defined", name);
goto out_err;
}
}
const char *str = NULL;
if (ConfGet("datasets.defaults.memcap", &str) == 1) {
if (ParseSizeStringU64(str, memcap) < 0) {
- SCLogWarning(SC_EINVAL,
- "memcap value cannot be deduced: %s,"
- " resetting to default",
+ SCLogWarning("memcap value cannot be deduced: %s,"
+ " resetting to default",
str);
*memcap = 0;
}
}
if (ConfGet("datasets.defaults.hashsize", &str) == 1) {
if (ParseSizeStringU32(str, hashsize) < 0) {
- SCLogWarning(SC_EINVAL,
- "hashsize value cannot be deduced: %s,"
- " resetting to default",
+ SCLogWarning("hashsize value cannot be deduced: %s,"
+ " resetting to default",
str);
*hashsize = 0;
}
const char *set_name = iter->name;
if (strlen(set_name) > DATASET_NAME_MAX_LEN) {
- FatalErrorOnInit(SC_ERR_CONF_NAME_TOO_LONG, "set name '%s' too long, max %d chars",
- set_name, DATASET_NAME_MAX_LEN);
+ FatalErrorOnInit(
+ "set name '%s' too long, max %d chars", set_name, DATASET_NAME_MAX_LEN);
continue;
}
ConfNode *set_memcap = ConfNodeLookupChild(iter, "memcap");
if (set_memcap) {
if (ParseSizeStringU64(set_memcap->val, &memcap) < 0) {
- SCLogWarning(SC_EINVAL,
- "memcap value cannot be"
- " deduced: %s, resetting to default",
+ SCLogWarning("memcap value cannot be"
+ " deduced: %s, resetting to default",
set_memcap->val);
memcap = 0;
}
ConfNode *set_hashsize = ConfNodeLookupChild(iter, "hashsize");
if (set_hashsize) {
if (ParseSizeStringU32(set_hashsize->val, &hashsize) < 0) {
- SCLogWarning(SC_EINVAL,
- "hashsize value cannot be"
- " deduced: %s, resetting to default",
+ SCLogWarning("hashsize value cannot be"
+ " deduced: %s, resetting to default",
set_hashsize->val);
hashsize = 0;
}
memcap > 0 ? memcap : default_memcap,
hashsize > 0 ? hashsize : default_hashsize);
if (dset == NULL) {
- FatalErrorOnInit(SC_ERR_DATASET, "failed to setup dataset for %s", set_name);
+ FatalErrorOnInit("failed to setup dataset for %s", set_name);
continue;
}
SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val);
memcap > 0 ? memcap : default_memcap,
hashsize > 0 ? hashsize : default_hashsize);
if (dset == NULL) {
- FatalErrorOnInit(SC_ERR_DATASET, "failed to setup dataset for %s", set_name);
+ FatalErrorOnInit("failed to setup dataset for %s", set_name);
continue;
}
SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val);
memcap > 0 ? memcap : default_memcap,
hashsize > 0 ? hashsize : default_hashsize);
if (dset == NULL) {
- FatalErrorOnInit(SC_ERR_DATASET, "failed to setup dataset for %s", set_name);
+ FatalErrorOnInit("failed to setup dataset for %s", set_name);
continue;
}
SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val);
{
int enabled = 0;
if (ConfGetBool("decoder.erspan.typeI.enabled", &enabled) == 1) {
- SCLogWarning(SC_WARN_ERSPAN_CONFIG,
- "ERSPAN Type I is no longer configurable and it is always"
+ SCLogWarning("ERSPAN Type I is no longer configurable and it is always"
" enabled; ignoring configuration setting.");
}
}
g_geneve_ports_idx = 0;
for (DetectPort *p = head; p != NULL; p = p->next) {
if (g_geneve_ports_idx >= GENEVE_MAX_PORTS) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "more than %d Geneve ports defined",
- GENEVE_MAX_PORTS);
+ SCLogWarning("more than %d Geneve ports defined", GENEVE_MAX_PORTS);
break;
}
g_geneve_ports[g_geneve_ports_idx++] = (int)p->port;
g_teredo_ports_cnt = 0;
for (DetectPort *p = head; p != NULL; p = p->next) {
if (g_teredo_ports_cnt >= TEREDO_MAX_PORTS) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "only %d Teredo ports can be defined",
- TEREDO_MAX_PORTS);
+ SCLogWarning("only %d Teredo ports can be defined", TEREDO_MAX_PORTS);
break;
}
g_teredo_ports[g_teredo_ports_cnt++] = (int)p->port;
g_vxlan_ports_idx = 0;
for (DetectPort *p = head; p != NULL; p = p->next) {
if (g_vxlan_ports_idx >= VXLAN_MAX_PORTS) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "more than %d VXLAN ports defined",
- VXLAN_MAX_PORTS);
+ SCLogWarning("more than %d VXLAN ports defined", VXLAN_MAX_PORTS);
break;
}
g_vxlan_ports[g_vxlan_ports_idx++] = (int)p->port;
StringHashCompareFunc,
StringHashFreeFunc);
if (g_counter_table == NULL) {
- FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
- "table init failed");
+ FatalError("decoder counter hash "
+ "table init failed");
}
}
if (!found) {
char *add = SCStrdup(name);
if (add == NULL)
- FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
- "table name init failed");
+ FatalError("decoder counter hash "
+ "table name init failed");
int r = HashTableAdd(g_counter_table, add, 0);
if (r != 0)
- FatalError(SC_ERR_INITIALIZATION, "decoder counter hash "
- "table name add failed");
+ FatalError("decoder counter hash "
+ "table name add failed");
found = add;
}
dtv->counter_engine_events[i] = StatsRegisterCounter(
dtv->app_tctx = AppLayerGetCtxThread(tv);
if (OutputFlowLogThreadInit(tv, NULL, &dtv->output_flow_thread_data) != TM_ECODE_OK) {
- SCLogError(SC_ERR_THREAD_INIT, "initializing flow log API for thread failed");
+ SCLogError("initializing flow log API for thread failed");
DecodeThreadVarsFree(tv, dtv);
return NULL;
}
intmax_t value = 0;
if (ConfGetInt("decoder.max-layers", &value) == 1) {
if (value < 0 || value > UINT8_MAX) {
- SCLogWarning(SC_EINVAL, "Invalid value for decoder.max-layers");
+ SCLogWarning("Invalid value for decoder.max-layers");
} else {
decoder_max_layers = (uint8_t)value;
}
intmax_t max = 0;
if (ConfGetInt("packet-alert-max", &max) == 1) {
if (max <= 0 || max > UINT8_MAX) {
- SCLogWarning(
- SC_EINVAL, "Invalid value for packet-alert-max, default value set instead");
+ SCLogWarning("Invalid value for packet-alert-max, default value set instead");
} else {
packet_alert_max = (uint16_t)max;
}
DecodeCHDLC(tv, dtv, p, data, len);
break;
default:
- SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED, "datalink type "
- "%"PRId32" not yet supported", datalink);
+ SCLogError("datalink type "
+ "%" PRId32 " not yet supported",
+ datalink);
break;
}
}
uint64_t *user_data = NULL;
if ( (user_data = SCMalloc(sizeof(uint64_t))) == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
+ FatalError("Error allocating memory. Exiting");
}
*user_data = timeout;
if (strchr(host_ip_range, ':') != NULL) {
SCLogDebug("adding ipv6 host %s", host_ip_range);
if (SCRadixAddKeyIPV6String(host_ip_range, defrag_tree, (void *)user_data) == NULL) {
- SCLogWarning(SC_EINVAL, "failed to add ipv6 host %s", host_ip_range);
+ SCLogWarning("failed to add ipv6 host %s", host_ip_range);
}
} else {
SCLogDebug("adding ipv4 host %s", host_ip_range);
if (SCRadixAddKeyIPV4String(host_ip_range, defrag_tree, (void *)user_data) == NULL) {
- SCLogWarning(SC_EINVAL, "failed to add ipv4 host %s", host_ip_range);
+ SCLogWarning("failed to add ipv4 host %s", host_ip_range);
}
}
}
if (strcasecmp("timeout", si->name) == 0) {
SCLogDebug("timeout value %s", si->val);
if (ParseSizeStringU64(si->val, &timeout) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing timeout "
- "from conf file");
+ SCLogError("Error parsing timeout "
+ "from conf file");
}
}
if (strcasecmp("address", si->name) == 0) {
defrag_tree = SCRadixCreateRadixTree(DefragPolicyFreeUserData, NULL);
if (defrag_tree == NULL) {
- FatalError(SC_ERR_FATAL,
- "Can't alloc memory for the defrag config tree.");
+ FatalError("Can't alloc memory for the defrag config tree.");
}
ConfNode *server_config = ConfGetNode("defrag.host-config");
if ((ConfGet("defrag.memcap", &conf_val)) == 1)
{
if (ParseSizeStringU64(conf_val, &defrag_memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing defrag.memcap "
+ SCLogError("Error parsing defrag.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(defrag_config.memcap, defrag_memcap);
/* alloc hash memory */
uint64_t hash_size = defrag_config.hash_size * sizeof(DefragTrackerHashRow);
if (!(DEFRAG_CHECK_MEMCAP(hash_size))) {
- SCLogError(SC_ERR_DEFRAG_INIT, "allocating defrag hash failed: "
- "max defrag memcap is smaller than projected hash size. "
- "Memcap: %"PRIu64", Hash table size %"PRIu64". Calculate "
- "total hash size by multiplying \"defrag.hash-size\" with %"PRIuMAX", "
- "which is the hash bucket size.", SC_ATOMIC_GET(defrag_config.memcap), hash_size,
+ SCLogError("allocating defrag hash failed: "
+ "max defrag memcap is smaller than projected hash size. "
+ "Memcap: %" PRIu64 ", Hash table size %" PRIu64 ". Calculate "
+ "total hash size by multiplying \"defrag.hash-size\" with %" PRIuMAX ", "
+ "which is the hash bucket size.",
+ SC_ATOMIC_GET(defrag_config.memcap), hash_size,
(uintmax_t)sizeof(DefragTrackerHashRow));
exit(EXIT_FAILURE);
}
defragtracker_hash = SCCalloc(defrag_config.hash_size, sizeof(DefragTrackerHashRow));
if (unlikely(defragtracker_hash == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
+ FatalError("Fatal error encountered in DefragTrackerInitConfig. Exiting...");
}
memset(defragtracker_hash, 0, defrag_config.hash_size * sizeof(DefragTrackerHashRow));
/* pre allocate defrag trackers */
for (i = 0; i < defrag_config.prealloc; i++) {
if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) {
- SCLogError(SC_ERR_DEFRAG_INIT, "preallocating defrag trackers failed: "
- "max defrag memcap reached. Memcap %"PRIu64", "
- "Memuse %"PRIu64".", SC_ATOMIC_GET(defrag_config.memcap),
- ((uint64_t)SC_ATOMIC_GET(defrag_memuse) + (uint64_t)sizeof(DefragTracker)));
+ SCLogError("preallocating defrag trackers failed: "
+ "max defrag memcap reached. Memcap %" PRIu64 ", "
+ "Memuse %" PRIu64 ".",
+ SC_ATOMIC_GET(defrag_config.memcap),
+ ((uint64_t)SC_ATOMIC_GET(defrag_memuse) +
+ (uint64_t)sizeof(DefragTracker)));
exit(EXIT_FAILURE);
}
DefragTracker *h = DefragTrackerAlloc();
if (h == NULL) {
- SCLogError(SC_ERR_DEFRAG_INIT, "preallocating defrag failed: %s", strerror(errno));
+ SCLogError("preallocating defrag failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
DefragTrackerEnqueue(&defragtracker_spare_q,h);
{
DefragTrackerQueue *q = (DefragTrackerQueue *)SCMalloc(sizeof(DefragTrackerQueue));
if (q == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerQueueNew. Exiting...");
+ SCLogError("Fatal error encountered in DefragTrackerQueueNew. Exiting...");
exit(EXIT_SUCCESS);
}
q = DefragTrackerQueueInit(q);
sizeof(Frag),
NULL, DefragFragInit, dc, NULL, NULL);
if (dc->frag_pool == NULL) {
- FatalError(SC_ERR_FATAL,
- "Defrag: Failed to initialize fragment pool.");
+ FatalError("Defrag: Failed to initialize fragment pool.");
}
if (SCMutexInit(&dc->frag_pool_lock, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Defrag: Failed to initialize frag pool mutex.");
+ FatalError("Defrag: Failed to initialize frag pool mutex.");
}
/* Set the default timeout. */
}
else {
if (timeout < TIMEOUT_MIN) {
- FatalError(SC_ERR_FATAL,
- "defrag: Timeout less than minimum allowed value.");
+ FatalError("defrag: Timeout less than minimum allowed value.");
}
else if (timeout > TIMEOUT_MAX) {
- FatalError(SC_ERR_FATAL,
- "defrag: Tiemout greater than maximum allowed value.");
+ FatalError("defrag: Tiemout greater than maximum allowed value.");
}
dc->timeout = timeout;
}
/* Allocate the DefragContext. */
defrag_context = DefragContextNew();
if (defrag_context == NULL) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for the Defrag module.");
+ FatalError("Failed to allocate memory for the Defrag module.");
}
DefragSetDefaultTimeout(defrag_context->timeout);
int event_id = 0;
int r = AppLayerGetPktEventInfo(arg, &event_id);
if (r < 0 || r > UINT8_MAX) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword "
+ SCLogError("app-layer-event keyword "
"supplied with packet based event - \"%s\" that isn't "
- "supported yet.", arg);
+ "supported yet.",
+ arg);
return NULL;
}
if (OutdatedEvent(data->arg)) {
if (SigMatchStrictEnabled(DETECT_AL_APP_LAYER_EVENT)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "app-layer-event keyword no longer supports event \"%s\"", data->arg);
+ SCLogError("app-layer-event keyword no longer supports event \"%s\"", data->arg);
return -1;
} else {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE,
- "app-layer-event keyword no longer supports event \"%s\"", data->arg);
+ SCLogWarning("app-layer-event keyword no longer supports event \"%s\"", data->arg);
return -3;
}
}
const char *p_idx = strchr(data->arg, '.');
if (strlen(data->arg) > MAX_ALPROTO_NAME) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword is too long or malformed");
+ SCLogError("app-layer-event keyword is too long or malformed");
return -1;
}
strlcpy(alproto_name, data->arg, p_idx - data->arg + 1);
} else if (ipproto_bitarray[IPPROTO_UDP / 8] & 1 << (IPPROTO_UDP % 8)) {
ipproto = IPPROTO_UDP;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "protocol %s is disabled", alproto_name);
+ SCLogError("protocol %s is disabled", alproto_name);
return -1;
}
}
if (r < 0) {
if (SigMatchStrictEnabled(DETECT_AL_APP_LAYER_EVENT)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword's "
- "protocol \"%s\" doesn't have event \"%s\" registered",
+ SCLogError("app-layer-event keyword's "
+ "protocol \"%s\" doesn't have event \"%s\" registered",
alproto_name, p_idx + 1);
return -1;
} else {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword's "
- "protocol \"%s\" doesn't have event \"%s\" registered",
+ SCLogWarning("app-layer-event keyword's "
+ "protocol \"%s\" doesn't have event \"%s\" registered",
alproto_name, p_idx + 1);
return -3;
}
}
if (event_id > UINT8_MAX) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword's id has invalid value");
+ SCLogWarning("app-layer-event keyword's id has invalid value");
return -4;
}
data->event_id = (uint8_t)event_id;
const char *p_idx = strchr(arg, '.');
if (strlen(arg) > MAX_ALPROTO_NAME) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword is too long or malformed");
+ SCLogError("app-layer-event keyword is too long or malformed");
return NULL;
}
/* + 1 for trailing \0 */
if (!strcmp(alproto_name, "file")) {
needs_detctx = true;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword "
+ SCLogError("app-layer-event keyword "
"supplied with unknown protocol \"%s\"",
- alproto_name);
+ alproto_name);
return NULL;
}
}
*event_type = 0;
if (arg == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword supplied "
+ SCLogError("app-layer-event keyword supplied "
"with no arguments. This keyword needs an argument.");
return NULL;
}
{
*event_id = SCMapEnumNameToValue(event_name, app_layer_event_test_map);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "app-layer-event's test enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "app-layer-event's test enum map table.",
+ event_name);
/* this should be treated as fatal */
return -1;
}
} else {
alproto = AppLayerGetProtoByName((char *)arg);
if (alproto == ALPROTO_UNKNOWN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-protocol "
- "keyword supplied with unknown protocol \"%s\"", arg);
+ SCLogError("app-layer-protocol "
+ "keyword supplied with unknown protocol \"%s\"",
+ arg);
return NULL;
}
}
SigMatch *sm = NULL;
if (s->alproto != ALPROTO_UNKNOWN) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "Either we already "
+ SCLogError("Either we already "
"have the rule match on an app layer protocol set through "
"other keywords that match on this protocol, or have "
"already seen a non-negated app-layer-protocol.");
const DetectAppLayerProtocolData *them = (const DetectAppLayerProtocolData *)tsm->ctx;
if (HasConflicts(data, them)) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "can't mix "
- "positive app-layer-protocol match with negated "
- "match or match for 'failed'.");
+ SCLogError("can't mix "
+ "positive app-layer-protocol match with negated "
+ "match or match for 'failed'.");
goto error;
}
}
DetectAsn1Data *ad = rs_detect_asn1_parse(asn1str);
if (ad == NULL) {
- SCLogError(SC_EINVAL, "Malformed asn1 argument: %s", asn1str);
+ SCLogError("Malformed asn1 argument: %s", asn1str);
}
return ad;
/* Check for a preceding base64_decode. */
pm = DetectGetLastSMFromLists(s, DETECT_BASE64_DECODE, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "\"base64_data\" keyword seen without preceding base64_decode.");
+ SCLogError("\"base64_data\" keyword seen without preceding base64_decode.");
return -1;
}
if (pcre2_substring_get_bynumber(
decode_pcre.match, 2, (PCRE2_UCHAR8 **)&bytes_str, &pcre2_len) == 0) {
if (StringParseUint32(bytes, 10, 0, bytes_str) <= 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "Bad value for bytes: \"%s\"", bytes_str);
+ SCLogError("Bad value for bytes: \"%s\"", bytes_str);
goto error;
}
}
if (pcre2_substring_get_bynumber(
decode_pcre.match, 4, (PCRE2_UCHAR8 **)&offset_str, &pcre2_len) == 0) {
if (StringParseUint32(offset, 10, 0, offset_str) <= 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "Bad value for offset: \"%s\"", offset_str);
+ SCLogError("Bad value for offset: \"%s\"", offset_str);
goto error;
}
}
*relative = 1;
}
else {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "Invalid argument: \"%s\"", relative_str);
+ SCLogError("Invalid argument: \"%s\"", relative_str);
goto error;
}
}
return true;
value_error:
if (bsz->mode == DETECT_UINT_RA) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "signature can't match as required content length %" PRIu64
- " exceeds bsize range: %" PRIu64 "-%" PRIu64,
+ SCLogError("signature can't match as required content length %" PRIu64
+ " exceeds bsize range: %" PRIu64 "-%" PRIu64,
needed, bsz->arg1, bsz->arg2);
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "signature can't match as required content length %" PRIu64 " exceeds bsize value: "
- "%" PRIu64,
+ SCLogError("signature can't match as required content length %" PRIu64
+ " exceeds bsize value: "
+ "%" PRIu64,
needed, bsz->arg1);
}
return false;
SigMatch *sm = NULL;
if (s->flags & SIG_FLAG_FILESTORE) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "bypass can't work with filestore keyword");
+ SCLogError("bypass can't work with filestore keyword");
return -1;
}
s->flags |= SIG_FLAG_BYPASS;
ret = DetectParsePcreExec(&parse_regex, arg, 0, 0);
if (ret < 3 || ret > 19) {
- SCLogError(SC_ERR_PCRE_PARSE, "parse error, ret %" PRId32
- ", string \"%s\"", ret, arg);
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid arg to byte_extract : %s "
- "for byte_extract", arg);
+ SCLogError("parse error, ret %" PRId32 ", string \"%s\"", ret, arg);
+ SCLogError("Invalid arg to byte_extract : %s "
+ "for byte_extract",
+ arg);
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 *)nbytes_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for arg 1 for byte_extract");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg 1 for byte_extract");
goto error;
}
if (StringParseUint8(&bed->nbytes, 10, 0,
(const char *)nbytes_str) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid value for number of bytes"
- " to be extracted: \"%s\".", nbytes_str);
+ SCLogError("Invalid value for number of bytes"
+ " to be extracted: \"%s\".",
+ nbytes_str);
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)offset_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for arg 2 for byte_extract");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg 2 for byte_extract");
goto error;
}
int32_t offset;
if (StringParseI32RangeCheck(&offset, 10, 0, (const char *)offset_str, -65535, 65535) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid value for offset: \"%s\".", offset_str);
+ SCLogError("Invalid value for offset: \"%s\".", offset_str);
goto error;
}
bed->offset = offset;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)varname_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for arg 3 for byte_extract");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg 3 for byte_extract");
goto error;
}
bed->name = SCStrdup(varname_str);
pcre2len = sizeof(opt_str);
res = SC_Pcre2SubstringCopy(parse_regex.match, i, (PCRE2_UCHAR8 *)opt_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING,
- "pcre2_substring_copy_bynumber failed "
- "for arg %d for byte_extract with %d",
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg %d for byte_extract with %d",
i, res);
goto error;
}
if (strcmp("relative", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_RELATIVE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "relative specified more "
+ SCLogError("relative specified more "
"than once for byte_extract");
goto error;
}
bed->flags |= DETECT_BYTE_EXTRACT_FLAG_RELATIVE;
} else if (strcmp("multiplier", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_MULTIPLIER) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "multiplier specified more "
+ SCLogError("multiplier specified more "
"than once for byte_extract");
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, i, (PCRE2_UCHAR8 *)multiplier_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING,
- "pcre2_substring_copy_bynumber failed "
- "for arg %d for byte_extract",
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg %d for byte_extract",
i);
goto error;
}
if (StringParseU16RangeCheck(&multiplier, 10, 0, (const char *)multiplier_str,
DETECT_BYTE_EXTRACT_MULTIPLIER_MIN_LIMIT,
DETECT_BYTE_EXTRACT_MULTIPLIER_MAX_LIMIT) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid value for"
- "multiplier: \"%s\".", multiplier_str);
+ SCLogError("Invalid value for"
+ "multiplier: \"%s\".",
+ multiplier_str);
goto error;
}
bed->multiplier_value = multiplier;
} else if (strcmp("big", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_ENDIAN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "endian option specified "
+ SCLogError("endian option specified "
"more than once for byte_extract");
goto error;
}
bed->endian = DETECT_BYTE_EXTRACT_ENDIAN_BIG;
} else if (strcmp("little", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_ENDIAN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "endian option specified "
+ SCLogError("endian option specified "
"more than once for byte_extract");
goto error;
}
bed->endian = DETECT_BYTE_EXTRACT_ENDIAN_LITTLE;
} else if (strcmp("dce", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_ENDIAN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "endian option specified "
+ SCLogError("endian option specified "
"more than once for byte_extract");
goto error;
}
bed->endian = DETECT_BYTE_EXTRACT_ENDIAN_DCE;
} else if (strcmp("string", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_STRING) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "string specified more "
+ SCLogError("string specified more "
"than once for byte_extract");
goto error;
}
if (bed->base != DETECT_BYTE_EXTRACT_BASE_NONE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "The right way to specify "
+ SCLogError("The right way to specify "
"base is (string, base) and not (base, string) "
"for byte_extract");
goto error;
bed->flags |= DETECT_BYTE_EXTRACT_FLAG_STRING;
} else if (strcmp("hex", opt_str) == 0) {
if (!(bed->flags & DETECT_BYTE_EXTRACT_FLAG_STRING)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Base(hex) specified "
+ SCLogError("Base(hex) specified "
"without specifying string. The right way is "
"(string, base) and not (base, string)");
goto error;
}
if (bed->base != DETECT_BYTE_EXTRACT_BASE_NONE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "More than one base "
+ SCLogError("More than one base "
"specified for byte_extract");
goto error;
}
bed->base = DETECT_BYTE_EXTRACT_BASE_HEX;
} else if (strcmp("oct", opt_str) == 0) {
if (!(bed->flags & DETECT_BYTE_EXTRACT_FLAG_STRING)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Base(oct) specified "
+ SCLogError("Base(oct) specified "
"without specifying string. The right way is "
"(string, base) and not (base, string)");
goto error;
}
if (bed->base != DETECT_BYTE_EXTRACT_BASE_NONE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "More than one base "
+ SCLogError("More than one base "
"specified for byte_extract");
goto error;
}
bed->base = DETECT_BYTE_EXTRACT_BASE_OCT;
} else if (strcmp("dec", opt_str) == 0) {
if (!(bed->flags & DETECT_BYTE_EXTRACT_FLAG_STRING)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Base(dec) specified "
+ SCLogError("Base(dec) specified "
"without specifying string. The right way is "
"(string, base) and not (base, string)");
goto error;
}
if (bed->base != DETECT_BYTE_EXTRACT_BASE_NONE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "More than one base "
+ SCLogError("More than one base "
"specified for byte_extract");
goto error;
}
bed->base = DETECT_BYTE_EXTRACT_BASE_DEC;
} else if (strcmp("align", opt_str) == 0) {
if (bed->flags & DETECT_BYTE_EXTRACT_FLAG_ALIGN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Align specified more "
+ SCLogError("Align specified more "
"than once for byte_extract");
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, i, (PCRE2_UCHAR8 *)align_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING,
- "pcre2_substring_copy_bynumber failed "
- "for arg %d in byte_extract",
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg %d in byte_extract",
i);
goto error;
}
if (StringParseUint8(&bed->align_value, 10, 0,
(const char *)align_str) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid align_value: "
- "\"%s\".", align_str);
+ SCLogError("Invalid align_value: "
+ "\"%s\".",
+ align_str);
goto error;
}
if (!(bed->align_value == 2 || bed->align_value == 4)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid align_value for "
- "byte_extract - \"%d\"", bed->align_value);
+ SCLogError("Invalid align_value for "
+ "byte_extract - \"%d\"",
+ bed->align_value);
goto error;
}
} else if (strcmp("", opt_str) == 0) {
;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid option - \"%s\" "
- "specified in byte_extract", opt_str);
+ SCLogError("Invalid option - \"%s\" "
+ "specified in byte_extract",
+ opt_str);
goto error;
}
} /* for (i = 4; i < ret; i++) */
bed->base = DETECT_BYTE_EXTRACT_BASE_DEC;
}
if (bed->endian != DETECT_BYTE_EXTRACT_ENDIAN_NONE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_extract can't have "
+ SCLogError("byte_extract can't have "
"endian \"big\" or \"little\" specified along with "
"\"string\"");
goto error;
/* if are dealing with octal nos, the max no that can fit in a 8
* byte value is 01777777777777777777777 */
if (bed->nbytes > STRING_MAX_BYTES_TO_EXTRACT_FOR_OCT) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_extract can't process "
+ SCLogError("byte_extract can't process "
"more than %d bytes in \"string\" extraction",
- STRING_MAX_BYTES_TO_EXTRACT_FOR_OCT);
+ STRING_MAX_BYTES_TO_EXTRACT_FOR_OCT);
goto error;
}
} else if (bed->base == DETECT_BYTE_EXTRACT_BASE_DEC) {
/* if are dealing with decimal nos, the max no that can fit in a 8
* byte value is 18446744073709551615 */
if (bed->nbytes > STRING_MAX_BYTES_TO_EXTRACT_FOR_DEC) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_extract can't process "
+ SCLogError("byte_extract can't process "
"more than %d bytes in \"string\" extraction",
- STRING_MAX_BYTES_TO_EXTRACT_FOR_DEC);
+ STRING_MAX_BYTES_TO_EXTRACT_FOR_DEC);
goto error;
}
} else if (bed->base == DETECT_BYTE_EXTRACT_BASE_HEX) {
/* if are dealing with hex nos, the max no that can fit in a 8
* byte value is 0xFFFFFFFFFFFFFFFF */
if (bed->nbytes > STRING_MAX_BYTES_TO_EXTRACT_FOR_HEX) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_extract can't process "
+ SCLogError("byte_extract can't process "
"more than %d bytes in \"string\" extraction",
- STRING_MAX_BYTES_TO_EXTRACT_FOR_HEX);
+ STRING_MAX_BYTES_TO_EXTRACT_FOR_HEX);
goto error;
}
} else {
}
} else {
if (bed->nbytes > NO_STRING_MAX_BYTES_TO_EXTRACT) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_extract can't process "
+ SCLogError("byte_extract can't process "
"more than %d bytes in \"non-string\" extraction",
- NO_STRING_MAX_BYTES_TO_EXTRACT);
+ NO_STRING_MAX_BYTES_TO_EXTRACT);
goto error;
}
/* if string has not been specified and no endian option has been
(data->base == DETECT_BYTE_EXTRACT_BASE_DEC) ||
(data->base == DETECT_BYTE_EXTRACT_BASE_HEX) ||
(data->base == DETECT_BYTE_EXTRACT_BASE_OCT) ) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "Invalid option. "
+ SCLogError("Invalid option. "
"A byte_jump keyword with dce holds other invalid modifiers.");
goto error;
}
/* Execute the regex and populate args with captures. */
ret = DetectParsePcreExec(&parse_regex, optstr, 0, 0);
if (ret < 2 || ret > 10) {
- SCLogError(SC_ERR_PCRE_PARSE,"parse error, ret %" PRId32
- ", string \"%s\"", ret, optstr);
+ SCLogError("parse error, ret %" PRId32 ", string \"%s\"", ret, optstr);
goto error;
}
pcre2len = sizeof(str);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for arg 1");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for arg 1");
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, i + 1, (PCRE2_UCHAR8 *)args[i + 1], &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed for arg %d",
- i + 1);
+ SCLogError("pcre2_substring_copy_bynumber failed for arg %d", i + 1);
goto error;
}
numargs++;
/* Number of bytes */
if (StringParseUint32(&nbytes, 10, (uint16_t)strlen(args[0]), args[0]) <= 0) {
- SCLogError(SC_EINVAL, "Malformed number of bytes: %s", optstr);
+ SCLogError("Malformed number of bytes: %s", optstr);
goto error;
}
/* Offset */
if (args[1][0] != '-' && isalpha((unsigned char)args[1][0])) {
if (offset == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "byte_jump supplied with "
+ SCLogError("byte_jump supplied with "
"var name for offset. \"value\" argument supplied to "
"this function has to be non-NULL");
goto error;
goto error;
} else {
if (StringParseInt32(&data->offset, 0, (uint16_t)strlen(args[1]), args[1]) <= 0) {
- SCLogError(SC_EINVAL, "Malformed offset: %s", optstr);
+ SCLogError("Malformed offset: %s", optstr);
goto error;
}
}
} else if (strncasecmp("multiplier ", args[i], 11) == 0) {
if (StringParseUint32(
&data->multiplier, 10, (uint16_t)strlen(args[i]) - 11, args[i] + 11) <= 0) {
- SCLogError(SC_EINVAL, "Malformed multiplier: %s", optstr);
+ SCLogError("Malformed multiplier: %s", optstr);
goto error;
}
} else if (strncasecmp("post_offset ", args[i], 12) == 0) {
if (StringParseInt32(&data->post_offset, 10, (uint16_t)strlen(args[i]) - 12,
args[i] + 12) <= 0) {
- SCLogError(SC_EINVAL, "Malformed post_offset: %s", optstr);
+ SCLogError("Malformed post_offset: %s", optstr);
goto error;
}
} else if (strcasecmp("dce", args[i]) == 0) {
data->flags |= DETECT_BYTEJUMP_DCE;
} else {
- SCLogError(SC_EINVAL, "Unknown option: \"%s\"", args[i]);
+ SCLogError("Unknown option: \"%s\"", args[i]);
goto error;
}
}
if ((data->flags & DETECT_BYTEJUMP_END) && (data->flags & DETECT_BYTEJUMP_BEGIN)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "'from_end' and 'from_beginning' "
- "cannot be used in the same byte_jump statement");
+ SCLogError("'from_end' and 'from_beginning' "
+ "cannot be used in the same byte_jump statement");
goto error;
}
* "01777777777777777777777" = 0xffffffffffffffff
*/
if (nbytes > 23) {
- SCLogError(SC_EINVAL,
- "Cannot test more than 23 bytes "
- "with \"string\": %s",
+ SCLogError("Cannot test more than 23 bytes "
+ "with \"string\": %s",
optstr);
goto error;
}
} else {
if (nbytes > 8) {
- SCLogError(SC_EINVAL,
- "Cannot test more than 8 bytes "
- "without \"string\": %s\n",
+ SCLogError("Cannot test more than 8 bytes "
+ "without \"string\": %s\n",
optstr);
goto error;
}
if (data->base != DETECT_BYTEJUMP_BASE_UNSET) {
- SCLogError(SC_EINVAL,
- "Cannot use a base "
- "without \"string\": %s",
+ SCLogError("Cannot use a base "
+ "without \"string\": %s",
optstr);
goto error;
}
(data->base == DETECT_BYTEJUMP_BASE_DEC) ||
(data->base == DETECT_BYTEJUMP_BASE_HEX) ||
(data->base == DETECT_BYTEJUMP_BASE_OCT) ) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "Invalid option. "
+ SCLogError("Invalid option. "
"A byte_jump keyword with dce holds other invalid modifiers.");
goto error;
}
if (offset != NULL) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(offset, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown byte_extract var "
- "seen in byte_jump - %s", offset);
+ SCLogError("Unknown byte_extract var "
+ "seen in byte_jump - %s",
+ offset);
goto error;
}
data->offset = index;
{
DetectByteMathData *bmd;
if ((bmd = ScByteMathParse(arg)) == NULL) {
- SCLogError(SC_ERR_PCRE_PARSE, "invalid bytemath values");
+ SCLogError("invalid bytemath values");
return NULL;
}
if (bmd->rvalue_str) {
if (rvalue == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "byte_math supplied with "
+ SCLogError("byte_math supplied with "
"var name for rvalue. \"rvalue\" argument supplied to "
"this function must be non-NULL");
goto error;
if (data->flags & DETECT_BYTEMATH_FLAG_RELATIVE) {
prev_pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, DETECT_PCRE, -1);
if (!prev_pm) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "relative specified without "
+ SCLogError("relative specified without "
"previous pattern match");
goto error;
}
if ((data->flags & DETECT_BYTEMATH_FLAG_STRING) || (data->base == BaseDec) ||
(data->base == BaseHex) || (data->base == BaseOct)) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "Invalid option. "
+ SCLogError("Invalid option. "
"A bytemath keyword with dce holds other invalid modifiers.");
goto error;
}
if (rvalue != NULL) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(rvalue, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unknown byte_ keyword var "
- "seen in byte_math - %s\n", rvalue);
+ SCLogError("unknown byte_ keyword var "
+ "seen in byte_math - %s\n",
+ rvalue);
goto error;
}
data->rvalue = index;
/* Execute the regex and populate args with captures. */
ret = DetectParsePcreExec(&parse_regex, optstr, 0, 0);
if (ret < 4 || ret > 9) {
- SCLogError(SC_ERR_PCRE_PARSE, "parse error, ret %" PRId32
- ", string %s", ret, optstr);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, optstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING,
- "pcre2_substring_get_bynumber failed "
- "for arg %d",
+ SCLogError("pcre2_substring_get_bynumber failed "
+ "for arg %d",
i + 1);
goto error;
}
/* Number of bytes */
if (StringParseUint32(&nbytes, 10, 0, args[0]) <= 0) {
- SCLogError(SC_EINVAL, "Malformed number of bytes: %s", str_ptr);
+ SCLogError("Malformed number of bytes: %s", str_ptr);
goto error;
}
} else if (strcmp("<=", op_ptr) == 0) {
data->op |= DETECT_BYTETEST_OP_LE;
} else {
- SCLogError(SC_ERR_INVALID_OPERATOR, "Invalid operator");
+ SCLogError("Invalid operator");
goto error;
}
}
if (test_value[0] != '-' && isalpha((unsigned char)test_value[0])) {
if (value == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "byte_test supplied with "
+ SCLogError("byte_test supplied with "
"var name for value. \"value\" argument supplied to "
"this function has to be non-NULL");
goto error;
goto error;
} else {
if (ByteExtractStringUint64(&data->value, 0, 0, test_value) <= 0) {
- SCLogError(SC_EINVAL, "Malformed value: %s", test_value);
+ SCLogError("Malformed value: %s", test_value);
goto error;
}
}
data_offset[end_ptr-str_ptr] = '\0';
if (data_offset[0] != '-' && isalpha((unsigned char)data_offset[0])) {
if (data_offset == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "byte_test supplied with "
+ SCLogError("byte_test supplied with "
"var name for offset. \"offset\" argument supplied to "
"this function has to be non-NULL");
goto error;
goto error;
} else {
if (StringParseInt32(&data->offset, 0, 0, data_offset) <= 0) {
- SCLogError(SC_EINVAL, "Malformed offset: %s", data_offset);
+ SCLogError("Malformed offset: %s", data_offset);
goto error;
}
}
data->flags |= DETECT_BYTETEST_BITMASK;
bitmask_index = i;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "Unknown value: \"%s\"",
- args[i]);
+ SCLogError("Unknown value: \"%s\"", args[i]);
goto error;
}
}
* "01777777777777777777777" = 0xffffffffffffffff
*/
if (nbytes > 23) {
- SCLogError(SC_EINVAL, "Cannot test more than 23 bytes with \"string\": %s", optstr);
+ SCLogError("Cannot test more than 23 bytes with \"string\": %s", optstr);
goto error;
}
} else {
if (nbytes > 8) {
- SCLogError(SC_EINVAL, "Cannot test more than 8 bytes without \"string\": %s", optstr);
+ SCLogError("Cannot test more than 8 bytes without \"string\": %s", optstr);
goto error;
}
if (data->base != DETECT_BYTETEST_BASE_UNSET) {
- SCLogError(SC_EINVAL, "Cannot use a base without \"string\": %s", optstr);
+ SCLogError("Cannot use a base without \"string\": %s", optstr);
goto error;
}
}
if (bitmask_index != -1 && data->flags & DETECT_BYTETEST_BITMASK) {
if (ByteExtractStringUint32(&data->bitmask, 0, 0, args[bitmask_index]+strlen("bitmask")) <= 0) {
- SCLogError(SC_EINVAL, "Malformed bitmask value: %s",
- args[bitmask_index] + strlen("bitmask"));
+ SCLogError("Malformed bitmask value: %s", args[bitmask_index] + strlen("bitmask"));
goto error;
}
/* determine how many trailing 0's are in the bitmask. This will be used
(data->base == DETECT_BYTETEST_BASE_DEC) ||
(data->base == DETECT_BYTETEST_BASE_HEX) ||
(data->base == DETECT_BYTETEST_BASE_OCT) ) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "Invalid option. "
+ SCLogError("Invalid option. "
"A byte_test keyword with dce holds other invalid modifiers.");
goto error;
}
if (value != NULL) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(value, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown byte_extract var "
- "seen in byte_test - %s\n", value);
+ SCLogError("Unknown byte_extract var "
+ "seen in byte_test - %s\n",
+ value);
goto error;
}
data->value = index;
if (offset != NULL) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(offset, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown byte_extract var "
- "seen in byte_test - %s\n", offset);
+ SCLogError("Unknown byte_extract var "
+ "seen in byte_test - %s\n",
+ offset);
goto error;
}
data->offset = index;
{
if (i > 2) //for now only need 3 parameters
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "too many parameters");
+ SCLogError("too many parameters");
goto error;
}
{
if (!isdigit((int) *token))
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "parameter error %s", token);
+ SCLogError("parameter error %s", token);
goto error;
}
} else //if on attribute
if (!isdigit((int) *token))
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "attribute error %s", token);
+ SCLogError("attribute error %s", token);
goto error;
}
unsigned long num = atol(token);
if ((num > MAX_CIP_SERVICE) && (i == 0))//if service greater than 7 bit
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid CIP service %lu", num);
+ SCLogError("invalid CIP service %lu", num);
goto error;
} else if ((num > MAX_CIP_CLASS) && (i == 1))//if service greater than 16 bit
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid CIP class %lu", num);
+ SCLogError("invalid CIP class %lu", num);
goto error;
} else if ((num > MAX_CIP_ATTRIBUTE) && (i == 2))//if service greater than 16 bit
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid CIP attribute %lu", num);
+ SCLogError("invalid CIP attribute %lu", num);
goto error;
}
}
if (i == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "no tokens found");
+ SCLogError("no tokens found");
goto error;
}
goto error;
if (!(isdigit((int) *rulestr))) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid ENIP command %s", rulestr);
+ SCLogError("invalid ENIP command %s", rulestr);
goto error;
}
uint16_t cmd;
if (StringParseUint16(&cmd, 10, 0, rulestr) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid ENIP command"
- ": \"%s\"", rulestr);
+ SCLogError("invalid ENIP command"
+ ": \"%s\"",
+ rulestr);
goto error;
}
int ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_MATCH, "Invalid Classtype in Signature");
+ SCLogError("Invalid Classtype in Signature");
return -1;
}
pcre2len = esize;
ret = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)e, &pcre2len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
if (strlen(e) >= CLASSTYPE_NAME_MAX_LEN) {
- SCLogError(
- SC_EINVAL, "classtype '%s' is too big: max %d", rawstr, CLASSTYPE_NAME_MAX_LEN - 1);
+ SCLogError("classtype '%s' is too big: max %d", rawstr, CLASSTYPE_NAME_MAX_LEN - 1);
return -1;
}
(void)strlcpy(out, e, outsize);
if ((s->class_id > 0) || (s->class_msg != NULL)) {
if (SigMatchStrictEnabled(DETECT_CLASSTYPE)) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "duplicated 'classtype' "
- "keyword detected.");
+ SCLogError("duplicated 'classtype' "
+ "keyword detected.");
return -1;
} else {
- SCLogWarning(SC_ERR_CONFLICTING_RULE_KEYWORDS, "duplicated 'classtype' "
- "keyword detected. Using instance with highest priority");
+ SCLogWarning("duplicated 'classtype' "
+ "keyword detected. Using instance with highest priority");
}
}
if (DetectClasstypeParseRawString(rawstr, parsed_ct_name, sizeof(parsed_ct_name)) < 0) {
- SCLogError(SC_ERR_PCRE_PARSE, "invalid value for classtype keyword: "
- "\"%s\"", rawstr);
+ SCLogError("invalid value for classtype keyword: "
+ "\"%s\"",
+ rawstr);
return -1;
}
SCClassConfClasstype *ct = SCClassConfGetClasstype(parsed_ct_name, de_ctx);
if (ct == NULL) {
if (SigMatchStrictEnabled(DETECT_CLASSTYPE)) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown classtype '%s'",
- parsed_ct_name);
+ SCLogError("unknown classtype '%s'", parsed_ct_name);
return -1;
}
if (s->id > 0) {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "signature sid:%u uses "
- "unknown classtype: \"%s\", using default priority %d. "
- "This message won't be shown again for this classtype",
+ SCLogWarning("signature sid:%u uses "
+ "unknown classtype: \"%s\", using default priority %d. "
+ "This message won't be shown again for this classtype",
s->id, parsed_ct_name, DETECT_DEFAULT_PRIO);
} else if (de_ctx->rule_file != NULL) {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "signature at %s:%u uses "
- "unknown classtype: \"%s\", using default priority %d. "
- "This message won't be shown again for this classtype",
- de_ctx->rule_file, de_ctx->rule_line,
- parsed_ct_name, DETECT_DEFAULT_PRIO);
+ SCLogWarning("signature at %s:%u uses "
+ "unknown classtype: \"%s\", using default priority %d. "
+ "This message won't be shown again for this classtype",
+ de_ctx->rule_file, de_ctx->rule_line, parsed_ct_name, DETECT_DEFAULT_PRIO);
} else {
- SCLogWarning(SC_ERR_UNKNOWN_VALUE, "unknown classtype: \"%s\", "
- "using default priority %d. "
- "This message won't be shown again for this classtype",
+ SCLogWarning("unknown classtype: \"%s\", "
+ "using default priority %d. "
+ "This message won't be shown again for this classtype",
parsed_ct_name, DETECT_DEFAULT_PRIO);
}
#if 0
/* filestore and bypass keywords can't work together */
if (s->flags & SIG_FLAG_BYPASS) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
+ SCLogError(
"filestore can't work with bypass keyword");
return -1;
}
sm->type = DETECT_CONFIG;
if (str == NULL || strlen(str) == 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "config keywords need arguments");
+ SCLogError("config keywords need arguments");
goto error;
}
char subsys[32];
ret = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (ret != 7) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "config is rather picky at this time");
+ SCLogError("config is rather picky at this time");
goto error;
}
pcre2len = sizeof(subsys);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)subsys, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcmp(subsys, "logging") != 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'logging' supported at this time");
+ SCLogError("only 'logging' supported at this time");
goto error;
}
SCLogDebug("subsys %s", subsys);
pcre2len = sizeof(state);
res = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)state, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcmp(state, "disable") != 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'disable' supported at this time");
+ SCLogError("only 'disable' supported at this time");
goto error;
}
SCLogDebug("state %s", state);
pcre2len = sizeof(type);
res = pcre2_substring_copy_bynumber(parse_regex.match, 3, (PCRE2_UCHAR8 *)type, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcmp(type, "type") != 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'type' supported at this time");
+ SCLogError("only 'type' supported at this time");
goto error;
}
SCLogDebug("type %s", type);
pcre2len = sizeof(typeval);
res = pcre2_substring_copy_bynumber(parse_regex.match, 4, (PCRE2_UCHAR8 *)typeval, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (!(strcmp(typeval, "tx") == 0 ||strcmp(typeval, "flow") == 0)) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'tx' and 'flow' supported at this time");
+ SCLogError("only 'tx' and 'flow' supported at this time");
goto error;
}
SCLogDebug("typeval %s", typeval);
pcre2len = sizeof(scope);
res = pcre2_substring_copy_bynumber(parse_regex.match, 5, (PCRE2_UCHAR8 *)scope, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcmp(scope, "scope") != 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'scope' supported at this time");
+ SCLogError("only 'scope' supported at this time");
goto error;
}
SCLogDebug("scope %s", scope);
pcre2len = sizeof(scopeval);
res = pcre2_substring_copy_bynumber(parse_regex.match, 6, (PCRE2_UCHAR8 *)scopeval, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (!(strcmp(scopeval, "tx") == 0 ||strcmp(scopeval, "flow") == 0)) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "only 'tx' and 'flow' supported at this time");
+ SCLogError("only 'tx' and 'flow' supported at this time");
goto error;
}
SCLogDebug("scopeval %s", scopeval);
bin_count++;
if (bin) {
if (binpos > 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Incomplete hex code in content - %s. Invalidating signature.",
+ SCLogError("Incomplete hex code in content - %s. Invalidating signature.",
contentstr);
goto error;
}
// SCLogDebug("space as part of binary string");
}
else if (str[i] != ',') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid hex code in "
- "content - %s, hex %c. Invalidating signature.", str, str[i]);
+ SCLogError("Invalid hex code in "
+ "content - %s, hex %c. Invalidating signature.",
+ str, str[i]);
goto error;
}
} else if (escape) {
str[x] = str[i];
x++;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "'%c' has to be escaped", str[i-1]);
+ SCLogError("'%c' has to be escaped", str[i - 1]);
goto error;
}
escape = 0;
converted = 1;
} else if (str[i] == '"') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid unescaped double quote within content section.");
+ SCLogError("Invalid unescaped double quote within content section.");
goto error;
} else {
str[x] = str[i];
}
if (bin_count % 2 != 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid hex code assembly in "
- "%s - %s. Invalidating signature.", keyword, contentstr);
+ SCLogError("Invalid hex code assembly in "
+ "%s - %s. Invalidating signature.",
+ keyword, contentstr);
goto error;
}
const char *tstr;
if (!DetectEngineBufferTypeValidateTransform(
de_ctx, sm_list, cd->content, cd->content_len, &tstr)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "content string \"%s\" incompatible with %s transform",
- contentstr, tstr);
+ SCLogError("content string \"%s\" incompatible with %s transform", contentstr, tstr);
goto error;
}
}
if (min_dsize_required >= 0) {
SCLogDebug("min_dsize %d; max_right_edge %d", min_dsize_required, max_right_edge);
if ((uint32_t)min_dsize_required > max_right_edge) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "signature can't match as required content length %d exceeds dsize value %d",
+ SCLogError("signature can't match as required content length %d exceeds dsize value %d",
min_dsize_required, max_right_edge);
return false;
}
}
if (strcmp(key, "memcap") == 0) {
if (ParseSizeStringU64(val, memcap) < 0) {
- SCLogWarning(SC_EINVAL,
- "invalid value for memcap: %s,"
- " resetting to default",
+ SCLogWarning("invalid value for memcap: %s,"
+ " resetting to default",
val);
*memcap = 0;
}
}
if (strcmp(key, "hashsize") == 0) {
if (ParseSizeStringU32(val, hashsize) < 0) {
- SCLogWarning(SC_EINVAL,
- "invalid value for hashsize: %s,"
- " resetting to default",
+ SCLogWarning("invalid value for hashsize: %s,"
+ " resetting to default",
val);
*hashsize = 0;
}
}
if (strlen(load) > 0 && *type == DATASET_TYPE_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "if load is used type must be set as well");
+ SCLogError("if load is used type must be set as well");
return 0;
}
if (!name_set || !cmd_set || !value_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "missing values");
+ SCLogError("missing values");
return 0;
}
/* Validate name, spaces are not allowed. */
for (size_t i = 0; i < strlen(name); i++) {
if (isblank(name[i])) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "spaces not allowed in dataset names");
+ SCLogError("spaces not allowed in dataset names");
return 0;
}
}
uint32_t hashsize = 0;
if (DetectBufferGetActiveList(de_ctx, s) == -1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "datarep is only supported for sticky buffers");
+ SCLogError("datarep is only supported for sticky buffers");
SCReturnInt(-1);
}
int list = s->init_data->list;
if (list == DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "datarep is only supported for sticky buffers");
+ SCLogError("datarep is only supported for sticky buffers");
SCReturnInt(-1);
}
} else if (strcmp(cmd_str,"==") == 0) {
op = DATAREP_OP_EQ;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE,
- "datarep operation \"%s\" is not supported.", cmd_str);
+ SCLogError("datarep operation \"%s\" is not supported.", cmd_str);
return -1;
}
Dataset *set = DatasetGet(name, type, /* no save */ NULL, load, memcap, hashsize);
if (set == NULL) {
- SCLogError(SC_ERR_UNKNOWN_VALUE,
- "failed to set up datarep set '%s'.", name);
+ SCLogError("failed to set up datarep set '%s'.", name);
return -1;
}
} else if (strcmp(val, "ip") == 0) {
*type = DATASET_TYPE_IPV6;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "bad type %s", val);
+ SCLogError("bad type %s", val);
return -1;
}
} else if (strcmp(key, "save") == 0) {
if (save_set) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE,
- "'save' can only appear once");
+ SCLogWarning("'save' can only appear once");
return -1;
}
SCLogDebug("save %s", val);
save_set = true;
} else if (strcmp(key, "load") == 0) {
if (load_set) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE,
- "'load' can only appear once");
+ SCLogWarning("'load' can only appear once");
return -1;
}
SCLogDebug("load %s", val);
load_set = true;
} else if (strcmp(key, "state") == 0) {
if (state_set) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE,
- "'state' can only appear once");
+ SCLogWarning("'state' can only appear once");
return -1;
}
SCLogDebug("state %s", val);
}
if (strcmp(key, "memcap") == 0) {
if (ParseSizeStringU64(val, memcap) < 0) {
- SCLogWarning(SC_EINVAL,
- "invalid value for memcap: %s,"
- " resetting to default",
+ SCLogWarning("invalid value for memcap: %s,"
+ " resetting to default",
val);
*memcap = 0;
}
}
if (strcmp(key, "hashsize") == 0) {
if (ParseSizeStringU32(val, hashsize) < 0) {
- SCLogWarning(SC_EINVAL,
- "invalid value for hashsize: %s,"
- " resetting to default",
+ SCLogWarning("invalid value for hashsize: %s,"
+ " resetting to default",
val);
*hashsize = 0;
}
}
if ((load_set || save_set) && state_set) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE,
- "'state' can not be mixed with 'load' and 'save'");
+ SCLogWarning("'state' can not be mixed with 'load' and 'save'");
return -1;
}
/* Validate name, spaces are not allowed. */
for (size_t i = 0; i < strlen(name); i++) {
if (isblank(name[i])) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "spaces not allowed in dataset names");
+ SCLogError("spaces not allowed in dataset names");
return 0;
}
}
char save[PATH_MAX] = "";
if (DetectBufferGetActiveList(de_ctx, s) == -1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "datasets are only supported for sticky buffers");
+ SCLogError("datasets are only supported for sticky buffers");
SCReturnInt(-1);
}
int list = s->init_data->list;
if (list == DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "datasets are only supported for sticky buffers");
+ SCLogError("datasets are only supported for sticky buffers");
SCReturnInt(-1);
}
} else if (strcmp(cmd_str,"unset") == 0) {
cmd = DETECT_DATASET_CMD_UNSET;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE,
- "dataset action \"%s\" is not supported.", cmd_str);
+ SCLogError("dataset action \"%s\" is not supported.", cmd_str);
return -1;
}
SCLogDebug("name '%s' load '%s' save '%s'", name, load, save);
Dataset *set = DatasetGet(name, type, save, load, memcap, hashsize);
if (set == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "failed to set up dataset '%s'.", name);
+ SCLogError("failed to set up dataset '%s'.", name);
return -1;
}
if (set->hash && SC_ATOMIC_GET(set->hash->memcap_reached)) {
- SCLogError(SC_ERR_THASH_INIT, "dataset too large for set memcap");
+ SCLogError("dataset too large for set memcap");
return -1;
}
void *did = rs_dcerpc_iface_parse(arg);
if (did == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Error parsing dce_iface option in "
+ SCLogError("Error parsing dce_iface option in "
"signature");
return -1;
}
static int DetectDceOpnumSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
{
if (arg == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Error parsing dce_opnum option in "
+ SCLogError("Error parsing dce_opnum option in "
"signature, option needs a value");
return -1;
}
void *dod = rs_dcerpc_opnum_parse(arg);
if (dod == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Error parsing dce_opnum option in "
+ SCLogError("Error parsing dce_opnum option in "
"signature");
return -1;
}
/* retrive the sm to apply the depth against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_DEPTH_MISSING_CONTENT, "depth needs "
+ SCLogError("depth needs "
"preceding content, uricontent option, http_client_body, "
"http_server_body, http_header option, http_raw_header option, "
"http_method option, http_cookie, http_raw_uri, "
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_DEPTH) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple depths for the same content.");
+ SCLogError("can't use multiple depths for the same content.");
goto end;
}
if ((cd->flags & DETECT_CONTENT_WITHIN) || (cd->flags & DETECT_CONTENT_DISTANCE)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a relative "
+ SCLogError("can't use a relative "
"keyword like within/distance with a absolute "
"relative keyword like depth/offset for the same "
- "content." );
+ "content.");
goto end;
}
if (cd->flags & DETECT_CONTENT_NEGATED && cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"negated keyword set along with 'fast_pattern'.");
goto end;
}
if (cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"keyword set along with 'fast_pattern:only;'.");
goto end;
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(str, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unknown byte_ keyword var "
- "seen in depth - %s.", str);
+ SCLogError("unknown byte_ keyword var "
+ "seen in depth - %s.",
+ str);
goto end;
}
cd->depth = index;
} else {
if (StringParseUint16(&cd->depth, 0, 0, str) < 0)
{
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "invalid value for depth: %s.", str);
+ SCLogError("invalid value for depth: %s.", str);
goto end;
}
if (cd->depth < cd->content_len) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "depth:%u smaller than "
- "content of len %u.", cd->depth, cd->content_len);
+ SCLogError("depth:%u smaller than "
+ "content of len %u.",
+ cd->depth, cd->content_len);
return -1;
}
/* Now update the real limit, as depth is relative to the offset */
/* retrieve the sm to apply the depth against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_DEPTH_MISSING_CONTENT, "startswith needs a "
+ SCLogError("startswith needs a "
"preceding content option.");
goto end;
}
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_DEPTH) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple "
- "depth/startswith settings for the same content.");
+ SCLogError("can't use multiple "
+ "depth/startswith settings for the same content.");
goto end;
}
if ((cd->flags & DETECT_CONTENT_WITHIN) || (cd->flags & DETECT_CONTENT_DISTANCE)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a relative "
+ SCLogError("can't use a relative "
"keyword like within/distance with a absolute "
"relative keyword like depth/offset for the same "
"content.");
goto end;
}
if (cd->flags & DETECT_CONTENT_NEGATED && cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"negated keyword set along with a 'fast_pattern'.");
goto end;
}
if (cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"keyword set along with 'fast_pattern:only;'.");
goto end;
}
if (cd->flags & DETECT_CONTENT_OFFSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't mix offset "
+ SCLogError("can't mix offset "
"with startswith.");
goto end;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 5) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret,
- rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
}
if (df->count == 0 || df->seconds == 0) {
- SCLogError(SC_EINVAL, "found an invalid value");
+ SCLogError("found an invalid value");
goto error;
}
/* checks if there's a previous instance of threshold */
tmpm = DetectGetLastSMFromLists(s, DETECT_THRESHOLD, -1);
if (tmpm != NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "\"detection_filter\" and \"threshold\" are not allowed in the same rule");
+ SCLogError("\"detection_filter\" and \"threshold\" are not allowed in the same rule");
SCReturnInt(-1);
}
/* checks there's no previous instance of detection_filter */
tmpm = DetectGetLastSMFromLists(s, DETECT_DETECTION_FILTER, -1);
if (tmpm != NULL) {
- SCLogError(
- SC_ERR_INVALID_SIGNATURE, "At most one \"detection_filter\" is allowed per rule");
+ SCLogError("At most one \"detection_filter\" is allowed per rule");
SCReturnInt(-1);
}
UtRegisterTest("DetectDetectionFilterTestSig2", DetectDetectionFilterTestSig2);
UtRegisterTest("DetectDetectionFilterTestSig3", DetectDetectionFilterTestSig3);
}
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */
DetectU64Data *dd = DetectU64Parse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Parsing \'%s\' failed for %s", rawstr,
+ SCLogError("Parsing \'%s\' failed for %s", rawstr,
sigmatch_table[DETECT_AL_DHCP_LEASETIME].name);
return -1;
}
DetectU64Data *dd = DetectU64Parse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Parsing \'%s\' failed for %s", rawstr,
+ SCLogError("Parsing \'%s\' failed for %s", rawstr,
sigmatch_table[DETECT_AL_DHCP_REBINDING_TIME].name);
return -1;
}
DetectU64Data *dd = DetectU64Parse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Parsing \'%s\' failed for %s", rawstr,
+ SCLogError("Parsing \'%s\' failed for %s", rawstr,
sigmatch_table[DETECT_AL_DHCP_RENEWAL_TIME].name);
return -1;
}
/* retrieve the sm to apply the distance against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_OFFSET_MISSING_CONTENT, "distance needs "
+ SCLogError("distance needs "
"preceding content, uricontent option, http_client_body, "
"http_server_body, http_header option, http_raw_header option, "
"http_method option, http_cookie, http_raw_uri, "
/* verify other conditions */
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_DISTANCE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple distances for the same content.");
+ SCLogError("can't use multiple distances for the same content.");
goto end;
}
if ((cd->flags & DETECT_CONTENT_DEPTH) || (cd->flags & DETECT_CONTENT_OFFSET)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a relative "
+ SCLogError("can't use a relative "
"keyword like within/distance with a absolute "
"relative keyword like depth/offset for the same "
- "content." );
+ "content.");
goto end;
}
if (cd->flags & DETECT_CONTENT_NEGATED && cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"negated keyword set along with a fast_pattern");
goto end;
}
if (cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"keyword set along with a fast_pattern:only;");
goto end;
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(str, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unknown byte_ keyword var "
- "seen in distance - %s\n", str);
+ SCLogError("unknown byte_ keyword var "
+ "seen in distance - %s\n",
+ str);
goto end;
}
cd->distance = index;
cd->flags |= DETECT_CONTENT_DISTANCE_VAR;
} else {
if (StringParseInt32(&cd->distance, 0, 0, str) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "invalid value for distance: %s", str);
+ SCLogError("invalid value for distance: %s", str);
goto end;
}
}
if (prev_pm->type == DETECT_CONTENT) {
DetectContentData *prev_cd = (DetectContentData *)prev_pm->ctx;
if (prev_cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "previous keyword "
+ SCLogError("previous keyword "
"has a fast_pattern:only; set. Can't "
"have relative keywords around a fast_pattern "
"only content");
return -1;
if (!DetectDNP3FuncParseFunctionCode(str, &function_code)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Invalid argument \"%s\" supplied to dnp3_func keyword.", str);
+ SCLogError("Invalid argument \"%s\" supplied to dnp3_func keyword.", str);
return -1;
}
}
if (!found) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Bad argument \"%s\" supplied to dnp3.ind keyword.", p);
+ SCLogError("Bad argument \"%s\" supplied to dnp3.ind keyword.", p);
return 0;
}
}
return -1;
if (!DetectDNP3IndParse(str, &flags)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Invalid argument \"%s\" supplied to dnp3.ind keyword.", str);
+ SCLogError("Invalid argument \"%s\" supplied to dnp3.ind keyword.", str);
return -1;
}
void *detect = rs_detect_dns_opcode_parse(str);
if (detect == NULL) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "failed to parse dns.opcode: %s", str);
+ SCLogError("failed to parse dns.opcode: %s", str);
return -1;
}
SigMatch *sm = NULL;
if (DetectGetLastSMFromLists(s, DETECT_DSIZE, -1)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Can't use 2 or more dsizes in "
+ SCLogError("Can't use 2 or more dsizes in "
"the same sig. Invalidating signature.");
goto error;
}
dd = DetectU16Parse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
* and put it in the Signature. */
sm = SigMatchAlloc();
if (sm == NULL){
- SCLogError(SC_ENOMEM, "Failed to allocate memory for SigMatch");
+ SCLogError("Failed to allocate memory for SigMatch");
rs_detect_u16_free(dd);
goto error;
}
/* validate netmask */
int cidr = CIDRFromMask(netmask);
if (cidr < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
+ SCLogError(
"netmask \"%s\" is not usable. Only netmasks that are compatible with "
"CIDR notation are supported. See ticket #5168.",
mask);
/* parse the address */
DetectAddress *ad = DetectAddressParseSingle(s);
if (ad == NULL) {
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC,
- "failed to parse address \"%s\"", s);
+ SCLogError("failed to parse address \"%s\"", s);
return -1;
}
char *temp_rule_var_address = NULL;
if (++recur > 64) {
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC, "address block recursion "
- "limit reached (max 64)");
+ SCLogError("address block recursion "
+ "limit reached (max 64)");
goto error;
}
size_t size = strlen(s);
for (u = 0, x = 0; u < size && x < address_length; u++) {
if (x == (address_length - 1)) {
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC,
- "Hit the address buffer"
- " limit for the supplied address. Invalidating sig. "
- "Please file a bug report on this.");
+ SCLogError("Hit the address buffer"
+ " limit for the supplied address. Invalidating sig. "
+ "Please file a bug report on this.");
goto error;
}
address[x] = s[u];
goto error;
if (strlen(rule_var_address) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "variable %s resolved "
- "to nothing. This is likely a misconfiguration. "
- "Note that a negated address needs to be quoted, "
- "\"!$HOME_NET\" instead of !$HOME_NET. See issue #295.", s);
+ SCLogError("variable %s resolved "
+ "to nothing. This is likely a misconfiguration. "
+ "Note that a negated address needs to be quoted, "
+ "\"!$HOME_NET\" instead of !$HOME_NET. See issue #295.",
+ s);
goto error;
}
x = 0;
if (AddVariableToResolveList(var_list, address) == -1) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Found a loop in a address "
- "groups declaration. This is likely a misconfiguration.");
+ SCLogError("Found a loop in a address "
+ "groups declaration. This is likely a misconfiguration.");
goto error;
}
goto error;
if (strlen(rule_var_address) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "variable %s resolved "
- "to nothing. This is likely a misconfiguration. "
- "Note that a negated address needs to be quoted, "
- "\"!$HOME_NET\" instead of !$HOME_NET. See issue #295.", s);
+ SCLogError("variable %s resolved "
+ "to nothing. This is likely a misconfiguration. "
+ "Note that a negated address needs to be quoted, "
+ "\"!$HOME_NET\" instead of !$HOME_NET. See issue #295.",
+ s);
goto error;
}
}
}
if (depth > 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not every address block was "
- "properly closed in \"%s\", %d missing closing brackets (]). "
- "Note: problem might be in a variable.", s, depth);
+ SCLogError("not every address block was "
+ "properly closed in \"%s\", %d missing closing brackets (]). "
+ "Note: problem might be in a variable.",
+ s, depth);
goto error;
} else if (depth < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not every address block was "
- "properly opened in \"%s\", %d missing opening brackets ([). "
- "Note: problem might be in a variable.", s, depth*-1);
+ SCLogError("not every address block was "
+ "properly opened in \"%s\", %d missing opening brackets ([). "
+ "Note: problem might be in a variable.",
+ s, depth * -1);
goto error;
}
if (address_length > (MAX_ADDRESS_LENGTH - 1)) {
char *address = SCCalloc(1, address_length);
if (address == NULL) {
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC, "Unable to allocate"
- " memory for address parsing.");
+ SCLogError("Unable to allocate"
+ " memory for address parsing.");
return -1;
}
rc = DetectAddressParseInternal(
/* check if the negated list covers the entire ip space. If so
* the user screwed up the rules/vars. */
if (DetectAddressIsCompleteIPSpace(ghn) == 1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Complete IP space negated. "
+ SCLogError("Complete IP space negated. "
"Rule address range is NIL. Probably have a !any or "
"an address range that supplies a NULL address range");
goto error;
cnt++;
if (ipv4_applied != cnt) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not all IPv4 negations "
- "could be applied: %d != %d", cnt, ipv4_applied);
+ SCLogError("not all IPv4 negations "
+ "could be applied: %d != %d",
+ cnt, ipv4_applied);
goto error;
}
cnt++;
if (ipv6_applied != cnt) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not all IPv6 negations "
- "could be applied: %d != %d", cnt, ipv6_applied);
+ SCLogError("not all IPv6 negations "
+ "could be applied: %d != %d",
+ cnt, ipv6_applied);
goto error;
}
}
/* if the result is that we have no addresses we return error */
if (gh->ipv4_head == NULL && gh->ipv6_head == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "no addresses left after "
- "merging addresses and negated addresses");
+ SCLogError("no addresses left after "
+ "merging addresses and negated addresses");
goto error;
}
}
if (seq_node->val == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Address var \"%s\" probably has a sequence(something "
+ SCLogError("Address var \"%s\" probably has a sequence(something "
"in brackets) value set without any quotes. Please "
- "quote it using \"..\".", seq_node->name);
+ "quote it using \"..\".",
+ seq_node->name);
goto error;
}
CleanVariableResolveList(&var_list);
if (r < 0) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "failed to parse address var \"%s\" with value \"%s\". "
- "Please check its syntax",
+ SCLogError("failed to parse address var \"%s\" with value \"%s\". "
+ "Please check its syntax",
seq_node->name, seq_node->val);
goto error;
}
if (DetectAddressIsCompleteIPSpace(ghn)) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "address var - \"%s\" has the complete IP space negated "
- "with its value \"%s\". Rule address range is NIL. "
- "Probably have a !any or an address range that supplies "
- "a NULL address range",
+ SCLogError("address var - \"%s\" has the complete IP space negated "
+ "with its value \"%s\". Rule address range is NIL. "
+ "Probably have a !any or an address range that supplies "
+ "a NULL address range",
seq_node->name, seq_node->val);
goto error;
}
det_ctx->alert_queue_size = 0;
det_ctx->alert_queue = SCCalloc(packet_alert_max, sizeof(PacketAlert));
if (det_ctx->alert_queue == NULL) {
- FatalError(SC_ENOMEM, "failed to allocate %" PRIu64 " bytes for the alert queue",
+ FatalError("failed to allocate %" PRIu64 " bytes for the alert queue",
(uint64_t)(packet_alert_max * sizeof(PacketAlert)));
}
det_ctx->alert_queue_capacity = packet_alert_max;
uint16_t patlen = fp_cd->content_len;
uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
if (unlikely(pat == NULL)) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memcpy(pat, fp_cd->content, fp_cd->content_len);
pat[fp_cd->content_len] = '\0';
fp_engine_analysis_FD = fopen(log_path, "w");
if (fp_engine_analysis_FD == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", log_path,
- strerror(errno));
+ SCLogError("failed to open %s: %s", log_path, strerror(errno));
return 0;
}
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, "rules_analysis.txt");
rule_engine_analysis_FD = fopen(log_path, "w");
if (rule_engine_analysis_FD == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", log_path, strerror(errno));
+ SCLogError("failed to open %s: %s", log_path, strerror(errno));
return 0;
}
if (percent_re == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE, "Compile of \"%s\" failed at offset %d: %s",
- DETECT_PERCENT_ENCODING_REGEX, (int)eo, errbuffer);
+ SCLogError("Compile of \"%s\" failed at offset %d: %s", DETECT_PERCENT_ENCODING_REGEX,
+ (int)eo, errbuffer);
return 0;
}
return 0;
}
else if (ret < -1) {
- SCLogError(SC_ERR_PCRE_MATCH, "Error parsing content - %s; error code is %d", content, ret);
+ SCLogError("Error parsing content - %s; error code is %d", content, ret);
return -1;
}
return ret;
uint16_t patlen = fp_cd->content_len;
uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
if (unlikely(pat == NULL)) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memcpy(pat, fp_cd->content, fp_cd->content_len);
pat[fp_cd->content_len] = '\0';
analyzer_item->item_id = (uint16_t)item_id;
if (analyzer_item->item_id == -1) {
/* Mismatch between the analyzer_items array and what's supported */
- FatalError(SC_ERR_INITIALIZATION,
- "unable to initialize engine-analysis table: detect buffer \"%s\" not recognized.",
- analyzer_item->item_name);
+ FatalError("unable to initialize engine-analysis table: detect buffer \"%s\" not "
+ "recognized.",
+ analyzer_item->item_name);
}
analyzer_item->item_seen = false;
((s->flags & (SIG_FLAG_TOSERVER|SIG_FLAG_TOCLIENT)) == (SIG_FLAG_TOSERVER|SIG_FLAG_TOCLIENT)) &&
(!(s->dp->port == 0 && s->dp->port2 == 65535)))
{
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: SYN-only to port(s) %u:%u "
- "w/o direction specified, disabling for toclient direction",
+ SCLogWarning("rule %u: SYN-only to port(s) %u:%u "
+ "w/o direction specified, disabling for toclient direction",
s->id, s->dp->port, s->dp->port2);
goto next;
}
SigInitStandardMpmFactoryContexts(de_ctx);
if (SigAddressPrepareStage1(de_ctx) != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
if (SigAddressPrepareStage2(de_ctx) != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
if (SigAddressPrepareStage3(de_ctx) != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
if (SigAddressPrepareStage4(de_ctx) != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
int r = DetectMpmPrepareBuiltinMpms(de_ctx);
r |= DetectMpmPreparePktMpms(de_ctx);
r |= DetectMpmPrepareFrameMpms(de_ctx);
if (r != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
if (SigMatchPrepare(de_ctx) != 0) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
#ifdef PROFILING
* cast to non-const as replace writes to it. */
det_ctx->replist = DetectReplaceAddToList(det_ctx->replist, (uint8_t *)found, cd);
} else {
- SCLogWarning(SC_EINVAL, "Can't modify payload without packet");
+ SCLogWarning("Can't modify payload without packet");
}
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32
- ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
res = pcre2_substring_copy_bynumber(parse_regex.match, 0, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
}
if (found == 0) {
- SCLogError(SC_ERR_UNKNOWN_DECODE_EVENT, "unknown decode event \"%s\"",
- copy_str);
+ SCLogError("unknown decode event \"%s\"", copy_str);
goto error;
}
/* parse the address */
if (IPOnlyCIDRItemParseSingle(gh, s) == -1) {
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC,
- "address parsing error \"%s\"", s);
+ SCLogError("address parsing error \"%s\"", s);
goto error;
}
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
if (unlikely(new == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SigNumArrayNew. Exiting...");
+ FatalError("Fatal error encountered in SigNumArrayNew. Exiting...");
}
memset(new, 0, sizeof(SigNumArray));
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
if (unlikely(new == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SigNumArrayCopy. Exiting...");
+ FatalError("Fatal error encountered in SigNumArrayCopy. Exiting...");
}
memset(new, 0, sizeof(SigNumArray));
return head;
error:
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC,"Error parsing addresses");
+ SCLogError("Error parsing addresses");
return head;
}
return 0;
error:
- SCLogError(SC_ERR_ADDRESS_ENGINE_GENERIC, "failed to parse addresses");
+ SCLogError("failed to parse addresses");
return -1;
}
sna, src->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the "
- "src ipv4 radix tree");
+ SCLogError("Error inserting in the "
+ "src ipv4 radix tree");
} else {
SCLogDebug("Best match found");
if (node == NULL) {
char tmpstr[64];
PrintInet(src->family, &src->ip[0], tmpstr, sizeof(tmpstr));
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the"
- " src ipv4 radix tree ip %s netmask %"PRIu8, tmpstr, src->netmask);
+ SCLogError("Error inserting in the"
+ " src ipv4 radix tree ip %s netmask %" PRIu8,
+ tmpstr, src->netmask);
//SCRadixPrintTree((de_ctx->io_ctx).tree_ipv4src);
exit(-1);
}
(de_ctx->io_ctx).tree_ipv6src,
sna, src->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the src "
+ SCLogError("Error inserting in the src "
"ipv6 radix tree");
} else {
/* Found, copy the sig num table, add this signum and insert */
(de_ctx->io_ctx).tree_ipv6src,
sna, src->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the src "
+ SCLogError("Error inserting in the src "
"ipv6 radix tree");
}
} else {
sna, dst->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the dst "
+ SCLogError("Error inserting in the dst "
"ipv4 radix tree");
} else {
SCLogDebug("Best match found");
sna, dst->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the dst "
+ SCLogError("Error inserting in the dst "
"ipv4 radix tree");
}
} else {
sna, dst->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the dst "
+ SCLogError("Error inserting in the dst "
"ipv6 radix tree");
} else {
/* Found, copy the sig num table, add this signum and insert */
sna, dst->netmask);
if (node == NULL)
- SCLogError(SC_ERR_IPONLY_RADIX, "Error inserting in the dst "
+ SCLogError("Error inserting in the dst "
"ipv6 radix tree");
}
} else {
char varname[128];
if (sig_file == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS,"invalid sig_file argument - NULL");
+ SCLogError("invalid sig_file argument - NULL");
return NULL;
}
FILE *fp = fopen(sig_file, "r");
if (fp == NULL) {
- SCLogError(SC_ERR_OPENING_RULE_FILE, "opening rule file %s:"
- " %s.", sig_file, strerror(errno));
+ SCLogError("opening rule file %s:"
+ " %s.",
+ sig_file, strerror(errno));
return -1;
}
good++;
} else {
if (!de_ctx->sigerror_silent) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "error parsing signature \"%s\" from "
- "file %s at line %"PRId32"", line, sig_file, lineno - multiline);
+ SCLogError("error parsing signature \"%s\" from "
+ "file %s at line %" PRId32 "",
+ line, sig_file, lineno - multiline);
if (!SigStringAppend(&de_ctx->sig_stat, sig_file, line, de_ctx->sigerror, (lineno - multiline))) {
- SCLogError(SC_ENOMEM,
- "Error adding sig \"%s\" from "
- "file %s at line %" PRId32 "",
+ SCLogError("Error adding sig \"%s\" from "
+ "file %s at line %" PRId32 "",
line, sig_file, lineno - multiline);
}
if (de_ctx->sigerror) {
int r = 0;
if (pattern == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "opening rule file null");
+ SCLogError("opening rule file null");
return -1;
}
r = glob(pattern, 0, NULL, &files);
if (r == GLOB_NOMATCH) {
- SCLogWarning(SC_ERR_NO_RULES, "No rule files match the pattern %s", pattern);
+ SCLogWarning("No rule files match the pattern %s", pattern);
++(st->bad_files);
++(st->total_files);
return -1;
} else if (r != 0) {
- SCLogError(SC_ERR_OPENING_RULE_FILE, "error expanding template %s: %s",
- pattern, strerror(errno));
+ SCLogError("error expanding template %s: %s", pattern, strerror(errno));
return -1;
}
rule_files = ConfGetNode(varname);
if (rule_files != NULL) {
if (!ConfNodeIsSequence(rule_files)) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Invalid rule-files configuration section: "
- "expected a list of filenames.");
+ SCLogWarning("Invalid rule-files configuration section: "
+ "expected a list of filenames.");
}
else {
TAILQ_FOREACH(file, &rule_files->head, next) {
/* now we should have signatures to work with */
if (sig_stat->good_sigs_total <= 0) {
if (sig_stat->total_files > 0) {
- SCLogWarning(SC_ERR_NO_RULES_LOADED, "%d rule files specified, but no rules were loaded!", sig_stat->total_files);
+ SCLogWarning(
+ "%d rule files specified, but no rules were loaded!", sig_stat->total_files);
} else {
SCLogInfo("No signatures supplied.");
goto end;
}
if (errors) {
- SCLogError(SC_ERR_INITIALIZATION, "%d loaders reported errors", errors);
+ SCLogError("%d loaders reported errors", errors);
return -1;
}
SCLogDebug("done");
(void)ConfGetInt("multi-detect.loaders", &setting);
if (setting < 1 || setting > 1024) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS,
- "invalid multi-detect.loaders setting %"PRIdMAX, setting);
+ SCLogError("invalid multi-detect.loaders setting %" PRIdMAX, setting);
exit(EXIT_FAILURE);
}
num_loaders = (int32_t)setting;
DetectBufferTypeSupportsTransformations(name);
int sm_list = DetectBufferTypeGetByName(name);
if (sm_list == -1) {
- FatalError(SC_ERR_INITIALIZATION,
- "MPM engine registration for %s failed", name);
+ FatalError("MPM engine registration for %s failed", name);
}
DetectBufferMpmRegistery *am = SCCalloc(1, sizeof(*am));
DetectBufferTypeSupportsTransformations(name);
int sm_list = DetectBufferTypeGetByName(name);
if (sm_list < 0 || sm_list > UINT16_MAX) {
- FatalError(SC_ERR_INITIALIZATION, "MPM engine registration for %s failed", name);
+ FatalError("MPM engine registration for %s failed", name);
}
DetectBufferMpmRegistery *am = SCCalloc(1, sizeof(*am));
const int sm_list = DetectEngineBufferTypeRegister(de_ctx, name);
if (sm_list < 0 || sm_list > UINT16_MAX) {
- FatalError(SC_ERR_INITIALIZATION, "MPM engine registration for %s failed", name);
+ FatalError("MPM engine registration for %s failed", name);
}
DetectEngineBufferTypeSupportsMpm(de_ctx, name);
DetectBufferTypeSupportsTransformations(name);
int sm_list = DetectBufferTypeGetByName(name);
if (sm_list == -1) {
- FatalError(SC_ERR_INITIALIZATION,
- "MPM engine registration for %s failed", name);
+ FatalError("MPM engine registration for %s failed", name);
}
DetectBufferMpmRegistery *am = SCCalloc(1, sizeof(*am));
if (mpm_algo != NULL) {
#if __BYTE_ORDER == __BIG_ENDIAN
if (strcmp(mpm_algo, "ac-ks") == 0) {
- FatalError(SC_ERR_FATAL, "ac-ks does "
+ FatalError("ac-ks does "
"not work on big endian systems at this time.");
}
#endif
#ifndef BUILD_HYPERSCAN
if ((strcmp(mpm_algo, "hs") == 0)) {
- FatalError(SC_EINVAL, "Hyperscan (hs) support for mpm-algo is "
- "not compiled into Suricata.");
+ FatalError("Hyperscan (hs) support for mpm-algo is "
+ "not compiled into Suricata.");
}
#endif
}
- FatalError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid mpm algo supplied "
- "in the yaml conf file: \"%s\"", mpm_algo);
+ FatalError("Invalid mpm algo supplied "
+ "in the yaml conf file: \"%s\"",
+ mpm_algo);
}
done:
/** parse the address */
ad = PortParse(s);
if (ad == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT," failed to parse port \"%s\"",s);
+ SCLogError(" failed to parse port \"%s\"", s);
return -1;
}
return 0;
error:
- SCLogError(SC_ERR_PORT_PARSE_INSERT_STRING,"DetectPortParseInsertString error");
+ SCLogError("DetectPortParseInsertString error");
if (ad != NULL)
DetectPortCleanupList(de_ctx, ad);
if (ad_any != NULL)
int r = 0;
if (recur++ > 64) {
- SCLogError(SC_ERR_PORT_ENGINE_GENERIC, "port block recursion "
- "limit reached (max 64)");
+ SCLogError("port block recursion "
+ "limit reached (max 64)");
goto error;
}
range = 1;
if (range == 1 && s[u] == '!') {
- SCLogError(SC_ERR_NEGATED_VALUE_IN_PORT_RANGE,"Can't have a negated value in a range.");
+ SCLogError("Can't have a negated value in a range.");
return -1;
} else if (!o_set && s[u] == '!') {
SCLogDebug("negation encountered");
if (rule_var_port == NULL)
goto error;
if (strlen(rule_var_port) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "variable %s resolved "
- "to nothing. This is likely a misconfiguration. "
- "Note that a negated port needs to be quoted, "
- "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s);
+ SCLogError("variable %s resolved "
+ "to nothing. This is likely a misconfiguration. "
+ "Note that a negated port needs to be quoted, "
+ "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.",
+ s);
goto error;
}
if (negate == 1 || n_set == 1) {
SCLogDebug("%s", address);
if (AddVariableToResolveList(var_list, address) == -1) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Found a loop in a port "
- "groups declaration. This is likely a misconfiguration.");
+ SCLogError("Found a loop in a port "
+ "groups declaration. This is likely a misconfiguration.");
goto error;
}
if (rule_var_port == NULL)
goto error;
if (strlen(rule_var_port) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "variable %s resolved "
- "to nothing. This is likely a misconfiguration. "
- "Note that a negated port needs to be quoted, "
- "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.", s);
+ SCLogError("variable %s resolved "
+ "to nothing. This is likely a misconfiguration. "
+ "Note that a negated port needs to be quoted, "
+ "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.",
+ s);
goto error;
}
if ((negate + n_set) % 2) {
}
if (depth > 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not every port block was "
- "properly closed in \"%s\", %d missing closing brackets (]). "
- "Note: problem might be in a variable.", s, depth);
+ SCLogError("not every port block was "
+ "properly closed in \"%s\", %d missing closing brackets (]). "
+ "Note: problem might be in a variable.",
+ s, depth);
goto error;
} else if (depth < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "not every port block was "
- "properly opened in \"%s\", %d missing opening brackets ([). "
- "Note: problem might be in a variable.", s, depth*-1);
+ SCLogError("not every port block was "
+ "properly opened in \"%s\", %d missing opening brackets ([). "
+ "Note: problem might be in a variable.",
+ s, depth * -1);
goto error;
}
/** check if the full port space is negated */
if (DetectPortIsCompletePortSpace(*nhead) == 1) {
- SCLogError(SC_ERR_COMPLETE_PORT_SPACE_NEGATED,"Complete port space is negated");
+ SCLogError("Complete port space is negated");
goto error;
}
}
if (*head == NULL) {
- SCLogError(SC_ERR_NO_PORTS_LEFT_AFTER_MERGE,"no ports left after merging ports with negated ports");
+ SCLogError("no ports left after merging ports with negated ports");
goto error;
}
DetectPort *ghn = NULL;
if (seq_node->val == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Port var \"%s\" probably has a sequence(something "
+ SCLogError("Port var \"%s\" probably has a sequence(something "
"in brackets) value set without any quotes. Please "
- "quote it using \"..\".", seq_node->name);
+ "quote it using \"..\".",
+ seq_node->name);
DetectPortCleanupList(NULL, gh);
goto error;
}
if (r < 0) {
DetectPortCleanupList(NULL, gh);
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "failed to parse port var \"%s\" with value \"%s\". "
- "Please check its syntax",
+ SCLogError("failed to parse port var \"%s\" with value \"%s\". "
+ "Please check its syntax",
seq_node->name, seq_node->val);
goto error;
}
if (DetectPortIsCompletePortSpace(ghn)) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Port var - \"%s\" has the complete Port range negated "
- "with its value \"%s\". Port space range is NIL. "
- "Probably have a !any or a port range that supplies "
- "a NULL address range",
+ SCLogError("Port var - \"%s\" has the complete Port range negated "
+ "with its value \"%s\". Port space range is NIL. "
+ "Probably have a !any or a port range that supplies "
+ "a NULL address range",
seq_node->name, seq_node->val);
DetectPortCleanupList(NULL, gh);
DetectPortCleanupList(NULL, ghn);
{
int r = PatternMatchPrepareGroup(de_ctx, sgh);
if (r != 0) {
- FatalError(SC_ERR_INITIALIZATION, "failed to set up pattern matching");
+ FatalError("failed to set up pattern matching");
}
/* set up engines if needed - when prefilter is set to auto we run
"registration function.", sigmatch_table[i].name);
if (coverage_unittests)
- SCLogWarning(SC_WARN_NO_UNITTESTS, "detection plugin %s has no unittest "
- "registration function.", sigmatch_table[i].name);
+ SCLogWarning("detection plugin %s has no unittest "
+ "registration function.",
+ sigmatch_table[i].name);
}
}
}
}
if ( (temp = SCMalloc(sizeof(SCSigOrderFunc))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
+ FatalError("Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
}
memset(temp, 0, sizeof(SCSigOrderFunc));
host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
if (host_tag_id.id == -1) {
- FatalError(SC_ERR_FATAL, "Can't initiate host storage for tag");
+ FatalError("Can't initiate host storage for tag");
}
flow_tag_id = FlowStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
if (flow_tag_id.id == -1) {
- FatalError(SC_ERR_FATAL, "Can't initiate flow storage for tag");
+ FatalError("Can't initiate flow storage for tag");
}
}
{
host_threshold_id = HostStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
if (host_threshold_id.id == -1) {
- FatalError(SC_ERR_FATAL,
- "Can't initiate host storage for thresholding");
+ FatalError("Can't initiate host storage for thresholding");
}
ippair_threshold_id = IPPairStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
if (ippair_threshold_id.id == -1) {
- FatalError(SC_ERR_FATAL,
- "Can't initiate IP pair storage for thresholding");
+ FatalError("Can't initiate IP pair storage for thresholding");
}
}
break;
case TRACK_RULE:
default:
- SCLogError(SC_EINVAL, "track mode %d is not supported", td->track);
+ SCLogError("track mode %d is not supported", td->track);
break;
}
if (m == NULL)
}
/* case TYPE_SUPPRESS: is not handled here */
default:
- SCLogError(SC_EINVAL, "type %d is not supported", td->type);
+ SCLogError("type %d is not supported", td->type);
}
return ret;
}
void ThresholdHashInit(DetectEngineCtx *de_ctx)
{
if (SCMutexInit(&de_ctx->ths_ctx.threshold_table_lock, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Threshold: Failed to initialize hash table mutex.");
+ FatalError("Threshold: Failed to initialize hash table mutex.");
}
}
de_ctx->ths_ctx.th_size = highest_signum + 1;
de_ctx->ths_ctx.th_entry = SCCalloc(de_ctx->ths_ctx.th_size, sizeof(DetectThresholdEntry *));
if (de_ctx->ths_ctx.th_entry == NULL) {
- FatalError(SC_ENOMEM,
- "Error allocating memory for rule "
- "thresholds (tried to allocate %" PRIu32 " th_entrys for "
- "rule tracking)",
+ FatalError("Error allocating memory for rule "
+ "thresholds (tried to allocate %" PRIu32 " th_entrys for "
+ "rule tracking)",
de_ctx->ths_ctx.th_size);
}
}
DetectBufferTypeRegister(name);
const int sm_list = DetectBufferTypeGetByName(name);
if (sm_list == -1) {
- FatalError(SC_ERR_INITIALIZATION,
- "failed to register inspect engine %s", name);
+ FatalError("failed to register inspect engine %s", name);
}
if ((sm_list < DETECT_SM_LIST_MATCH) || (sm_list >= SHRT_MAX) ||
(Callback == NULL))
{
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments");
+ SCLogError("Invalid arguments");
BUG_ON(1);
}
DetectEnginePktInspectionEngine *new_engine = SCCalloc(1, sizeof(*new_engine));
if (unlikely(new_engine == NULL)) {
- FatalError(SC_ERR_INITIALIZATION,
- "failed to register inspect engine %s: %s", name, strerror(errno));
+ FatalError("failed to register inspect engine %s: %s", name, strerror(errno));
}
new_engine->sm_list = (uint16_t)sm_list;
new_engine->sm_list_base = (uint16_t)sm_list;
DetectBufferTypeRegister(name);
const int sm_list = DetectBufferTypeGetByName(name);
if (sm_list == -1) {
- FatalError(SC_ERR_INITIALIZATION, "failed to register inspect engine %s", name);
+ FatalError("failed to register inspect engine %s", name);
}
if ((sm_list < DETECT_SM_LIST_MATCH) || (sm_list >= SHRT_MAX) || (Callback == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments");
+ SCLogError("Invalid arguments");
BUG_ON(1);
}
DetectEngineFrameInspectionEngine *new_engine = SCCalloc(1, sizeof(*new_engine));
if (unlikely(new_engine == NULL)) {
- FatalError(SC_ERR_INITIALIZATION, "failed to register inspect engine %s: %s", name,
- strerror(errno));
+ FatalError("failed to register inspect engine %s: %s", name, strerror(errno));
}
new_engine->sm_list = (uint16_t)sm_list;
new_engine->sm_list_base = (uint16_t)sm_list;
DetectBufferTypeRegister(name);
const int sm_list = DetectBufferTypeGetByName(name);
if (sm_list == -1) {
- FatalError(SC_ERR_INITIALIZATION,
- "failed to register inspect engine %s", name);
+ FatalError("failed to register inspect engine %s", name);
}
if ((alproto >= ALPROTO_FAILED) ||
(progress < 0 || progress >= SHRT_MAX) ||
(Callback2 == NULL))
{
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments");
+ SCLogError("Invalid arguments");
BUG_ON(1);
} else if (Callback2 == DetectEngineInspectBufferGeneric && GetData == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments: must register "
- "GetData with DetectEngineInspectBufferGeneric");
+ SCLogError("Invalid arguments: must register "
+ "GetData with DetectEngineInspectBufferGeneric");
BUG_ON(1);
}
{
const int sm_list = DetectEngineBufferTypeRegister(de_ctx, name);
if (sm_list < 0) {
- FatalError(SC_ERR_INITIALIZATION, "failed to register inspect engine %s", name);
+ FatalError("failed to register inspect engine %s", name);
}
if ((sm_list < DETECT_SM_LIST_MATCH) || (sm_list >= SHRT_MAX) || (Callback == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments");
+ SCLogError("Invalid arguments");
BUG_ON(1);
}
DetectEngineFrameInspectionEngine *new_engine = SCCalloc(1, sizeof(*new_engine));
if (unlikely(new_engine == NULL)) {
- FatalError(SC_ERR_INITIALIZATION, "failed to register inspect engine %s: %s", name,
- strerror(errno));
+ FatalError("failed to register inspect engine %s: %s", name, strerror(errno));
}
new_engine->sm_list = (uint16_t)sm_list;
new_engine->sm_list_base = (uint16_t)sm_list;
if (map->transforms.transforms[i].options == NULL)
continue;
if (sigmatch_table[map->transforms.transforms[i].transform].Free == NULL) {
- SCLogError(SC_ERR_UNIMPLEMENTED,
- "%s allocates transform option memory but has no free routine",
- sigmatch_table[map->transforms.transforms[i].transform].name);
+ SCLogError("%s allocates transform option memory but has no free routine",
+ sigmatch_table[map->transforms.transforms[i].transform].name);
continue;
}
sigmatch_table[map->transforms.transforms[i].transform].Free(NULL, map->transforms.transforms[i].options);
if (s->init_data->list && s->init_data->transforms.cnt) {
if (s->init_data->list == DETECT_SM_LIST_NOTSET ||
s->init_data->list < DETECT_SM_LIST_DYNAMIC_START) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "previous transforms not consumed "
- "(list: %u, transform_cnt %u)", s->init_data->list,
- s->init_data->transforms.cnt);
+ SCLogError("previous transforms not consumed "
+ "(list: %u, transform_cnt %u)",
+ s->init_data->list, s->init_data->transforms.cnt);
SCReturnInt(-1);
}
return -1;
}
if (!base_map->supports_transforms) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "buffer '%s' does not support transformations",
- base_map->name);
+ SCLogError("buffer '%s' does not support transformations", base_map->name);
return -1;
}
new_det_ctx[i] = DetectEngineThreadCtxInitForReload(tv, new_de_ctx, 1);
if (new_det_ctx[i] == NULL) {
- SCLogError(SC_ERR_LIVE_RULE_SWAP, "Detect engine thread init "
+ SCLogError("Detect engine thread init "
"failure in live rule swap. Let's get out of here");
SCMutexUnlock(&tv_root_lock);
goto error;
} else if (strcmp(de_ctx_profile, "custom") == 0) {
profile = ENGINE_PROFILE_CUSTOM;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "invalid value for detect.profile: '%s'. "
- "Valid options: low, medium, high and custom.",
+ SCLogError("invalid value for detect.profile: '%s'. "
+ "Valid options: low, medium, high and custom.",
de_ctx_profile);
return -1;
}
} else if (strcmp(sgh_mpm_context, "full") == 0) {
de_ctx->sgh_mpm_ctx_cnf = ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "You have supplied an "
- "invalid conf value for detect-engine.sgh-mpm-context-"
- "%s", sgh_mpm_context);
- exit(EXIT_FAILURE);
+ SCLogError("You have supplied an "
+ "invalid conf value for detect-engine.sgh-mpm-context-"
+ "%s",
+ sgh_mpm_context);
+ exit(EXIT_FAILURE);
}
}
(const char *)max_uniq_toclient_groups_str) <= 0) {
de_ctx->max_uniq_toclient_groups = 20;
- SCLogWarning(SC_ERR_SIZE_PARSE, "parsing '%s' for "
- "toclient-groups failed, using %u",
- max_uniq_toclient_groups_str,
- de_ctx->max_uniq_toclient_groups);
+ SCLogWarning("parsing '%s' for "
+ "toclient-groups failed, using %u",
+ max_uniq_toclient_groups_str, de_ctx->max_uniq_toclient_groups);
}
} else {
de_ctx->max_uniq_toclient_groups = 20;
(const char *)max_uniq_toserver_groups_str) <= 0) {
de_ctx->max_uniq_toserver_groups = 40;
- SCLogWarning(SC_ERR_SIZE_PARSE, "parsing '%s' for "
- "toserver-groups failed, using %u",
- max_uniq_toserver_groups_str,
- de_ctx->max_uniq_toserver_groups);
+ SCLogWarning("parsing '%s' for "
+ "toserver-groups failed, using %u",
+ max_uniq_toserver_groups_str, de_ctx->max_uniq_toserver_groups);
}
} else {
de_ctx->max_uniq_toserver_groups = 40;
insp_recursion_limit_node = ConfNodeLookupChild(opt, opt->val);
if (insp_recursion_limit_node == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Error retrieving conf "
- "entry for detect-engine:inspection-recursion-limit");
+ SCLogError("Error retrieving conf "
+ "entry for detect-engine:inspection-recursion-limit");
break;
}
insp_recursion_limit = insp_recursion_limit_node->val;
if (insp_recursion_limit != NULL) {
if (StringParseInt32(&de_ctx->inspection_recursion_limit, 10,
0, (const char *)insp_recursion_limit) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "detect-engine.inspection-recursion-limit: %s "
- "resetting to %d",
+ SCLogWarning("Invalid value for "
+ "detect-engine.inspection-recursion-limit: %s "
+ "resetting to %d",
insp_recursion_limit, DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT);
de_ctx->inspection_recursion_limit =
DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT;
}
if (DetectPortParse(de_ctx, &de_ctx->tcp_whitelist, ports) != 0) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "'%s' is not a valid value "
- "for detect.grouping.tcp-whitelist", ports);
+ SCLogWarning("'%s' is not a valid value "
+ "for detect.grouping.tcp-whitelist",
+ ports);
}
DetectPort *x = de_ctx->tcp_whitelist;
for ( ; x != NULL; x = x->next) {
if (x->port != x->port2) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "'%s' is not a valid value "
- "for detect.grouping.tcp-whitelist: only single ports allowed", ports);
+ SCLogWarning("'%s' is not a valid value "
+ "for detect.grouping.tcp-whitelist: only single ports allowed",
+ ports);
DetectPortCleanupList(de_ctx, de_ctx->tcp_whitelist);
de_ctx->tcp_whitelist = NULL;
break;
}
if (DetectPortParse(de_ctx, &de_ctx->udp_whitelist, ports) != 0) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "'%s' is not a valid value "
- "for detect.grouping.udp-whitelist",
+ SCLogWarning("'%s' is not a valid value "
+ "for detect.grouping.udp-whitelist",
ports);
}
for (x = de_ctx->udp_whitelist; x != NULL; x = x->next) {
if (x->port != x->port2) {
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, "'%s' is not a valid value "
- "for detect.grouping.udp-whitelist: only single ports allowed", ports);
+ SCLogWarning("'%s' is not a valid value "
+ "for detect.grouping.udp-whitelist: only single ports allowed",
+ ports);
DetectPortCleanupList(de_ctx, de_ctx->udp_whitelist);
de_ctx->udp_whitelist = NULL;
break;
// coverity[suspicious_sizeof : FALSE]
det_ctx->global_keyword_ctxs_array = (void **)SCCalloc(master->keyword_id, sizeof(void *));
if (det_ctx->global_keyword_ctxs_array == NULL) {
- SCLogError(SC_ERR_DETECT_PREPARE, "setting up thread local detect ctx");
+ SCLogError("setting up thread local detect ctx");
return TM_ECODE_FAILED;
}
det_ctx->global_keyword_ctxs_size = master->keyword_id;
while (item) {
det_ctx->global_keyword_ctxs_array[item->id] = item->InitFunc(item->data);
if (det_ctx->global_keyword_ctxs_array[item->id] == NULL) {
- SCLogError(SC_ERR_DETECT_PREPARE, "setting up thread local detect ctx "
- "for keyword \"%s\" failed", item->name);
+ SCLogError("setting up thread local detect ctx "
+ "for keyword \"%s\" failed",
+ item->name);
return TM_ECODE_FAILED;
}
item = item->next;
// coverity[suspicious_sizeof : FALSE]
det_ctx->keyword_ctxs_array = SCMalloc(de_ctx->keyword_id * sizeof(void *));
if (det_ctx->keyword_ctxs_array == NULL) {
- SCLogError(SC_ERR_DETECT_PREPARE, "setting up thread local detect ctx");
+ SCLogError("setting up thread local detect ctx");
return TM_ECODE_FAILED;
}
det_ctx->keyword_ctxs_array[item->id] = item->InitFunc(item->data);
if (det_ctx->keyword_ctxs_array[item->id] == NULL) {
- SCLogError(SC_ERR_DETECT_PREPARE, "setting up thread local detect ctx "
- "for keyword \"%s\" failed", item->name);
+ SCLogError("setting up thread local detect ctx "
+ "for keyword \"%s\" failed",
+ item->name);
return TM_ECODE_FAILED;
}
}
HashTable *mt_det_ctxs_hash = NULL;
if (master->tenant_selector == TENANT_SELECTOR_UNKNOWN) {
- SCLogError(SC_ERR_MT_NO_SELECTOR, "no tenant selector set: "
- "set using multi-detect.selector");
+ SCLogError("no tenant selector set: "
+ "set using multi-detect.selector");
return TM_ECODE_FAILED;
}
DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data;
if (det_ctx == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "argument \"data\" NULL");
+ SCLogWarning("argument \"data\" NULL");
return TM_ECODE_OK;
}
struct stat st;
if(stat(filename, &st) != 0) {
#endif /* OS_WIN32 */
- SCLogError(SC_ERR_FOPEN, "failed to stat file %s", filename);
+ SCLogError("failed to stat file %s", filename);
goto error;
}
de_ctx = DetectEngineGetByTenantId(tenant_id);
if (de_ctx != NULL) {
- SCLogError(SC_ERR_MT_DUPLICATE_TENANT, "tenant %u already registered",
- tenant_id);
+ SCLogError("tenant %u already registered", tenant_id);
DetectEngineDeReference(&de_ctx);
goto error;
}
ConfNode *node = ConfGetNode(prefix);
if (node == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to properly setup yaml %s", filename);
+ SCLogError("failed to properly setup yaml %s", filename);
goto error;
}
de_ctx = DetectEngineCtxInitWithPrefix(prefix);
if (de_ctx == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
- "context failed.");
+ SCLogError("initializing detection engine "
+ "context failed.");
goto error;
}
SCLogDebug("de_ctx %p with prefix %s", de_ctx, de_ctx->config_prefix);
de_ctx->loader_id = loader_id;
if (SigLoadSignatures(de_ctx, NULL, 0) < 0) {
- SCLogError(SC_ERR_NO_RULES_LOADED, "Loading signatures failed.");
+ SCLogError("Loading signatures failed.");
goto error;
}
{
DetectEngineCtx *old_de_ctx = DetectEngineGetByTenantId(tenant_id);
if (old_de_ctx == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "tenant detect engine not found");
+ SCLogError("tenant detect engine not found");
return -1;
}
SCLogDebug("prefix %s", prefix);
if (ConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
- SCLogError(SC_ERR_INITIALIZATION,"failed to load yaml");
+ SCLogError("failed to load yaml");
goto error;
}
ConfNode *node = ConfGetNode(prefix);
if (node == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to properly setup yaml %s", filename);
+ SCLogError("failed to properly setup yaml %s", filename);
goto error;
}
DetectEngineCtx *new_de_ctx = DetectEngineCtxInitWithPrefix(prefix);
if (new_de_ctx == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
- "context failed.");
+ SCLogError("initializing detection engine "
+ "context failed.");
goto error;
}
SCLogDebug("de_ctx %p with prefix %s", new_de_ctx, new_de_ctx->config_prefix);
new_de_ctx->loader_id = old_de_ctx->loader_id;
if (SigLoadSignatures(new_de_ctx, NULL, 0) < 0) {
- SCLogError(SC_ERR_NO_RULES_LOADED, "Loading signatures failed.");
+ SCLogError("Loading signatures failed.");
goto error;
}
uint32_t tenant_id = 0;
if (StringParseUint32(&tenant_id, 10, (uint16_t)strlen(tenant_id_node->val),
tenant_id_node->val) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant-id "
- "of %s is invalid", tenant_id_node->val);
+ SCLogError("tenant-id "
+ "of %s is invalid",
+ tenant_id_node->val);
goto bad_mapping;
}
const char *dev = device_node->val;
LiveDevice *ld = LiveGetDevice(dev);
if (ld == NULL) {
- SCLogWarning(SC_ERR_MT_NO_MAPPING, "device %s not found", dev);
+ SCLogWarning("device %s not found", dev);
goto bad_mapping;
}
if (ld->tenant_id_set) {
- SCLogWarning(SC_ERR_MT_NO_MAPPING, "device %s already mapped to tenant-id %u",
- dev, ld->tenant_id);
+ SCLogWarning("device %s already mapped to tenant-id %u", dev, ld->tenant_id);
goto bad_mapping;
}
uint32_t tenant_id = 0;
if (StringParseUint32(&tenant_id, 10, (uint16_t)strlen(tenant_id_node->val),
tenant_id_node->val) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant-id "
- "of %s is invalid", tenant_id_node->val);
+ SCLogError("tenant-id "
+ "of %s is invalid",
+ tenant_id_node->val);
goto bad_mapping;
}
uint16_t vlan_id = 0;
if (StringParseUint16(
&vlan_id, 10, (uint16_t)strlen(vlan_id_node->val), vlan_id_node->val) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "vlan-id "
- "of %s is invalid", vlan_id_node->val);
+ SCLogError("vlan-id "
+ "of %s is invalid",
+ vlan_id_node->val);
goto bad_mapping;
}
if (vlan_id == 0 || vlan_id >= 4095) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "vlan-id "
- "of %s is invalid. Valid range 1-4094.", vlan_id_node->val);
+ SCLogError("vlan-id "
+ "of %s is invalid. Valid range 1-4094.",
+ vlan_id_node->val);
goto bad_mapping;
}
int vlanbool = 0;
if ((ConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) {
- SCLogError(SC_EINVAL, "vlan tracking is disabled, "
- "can't use multi-detect selector 'vlan'");
+ SCLogError("vlan tracking is disabled, "
+ "can't use multi-detect selector 'vlan'");
SCMutexUnlock(&master->lock);
goto error;
}
} else if (strcmp(handler, "device") == 0) {
tenant_selector = master->tenant_selector = TENANT_SELECTOR_LIVEDEV;
if (EngineModeIsIPS()) {
- SCLogWarning(SC_ERR_MT_NO_MAPPING,
- "multi-tenant 'device' mode not supported for IPS");
+ SCLogWarning("multi-tenant 'device' mode not supported for IPS");
SCMutexUnlock(&master->lock);
goto error;
}
} else {
- SCLogError(SC_EINVAL,
- "unknown value %s "
- "multi-detect.selector",
+ SCLogError("unknown value %s "
+ "multi-detect.selector",
handler);
SCMutexUnlock(&master->lock);
goto error;
"tenants won't be used until mappings are added");
} else {
if (failure_fatal) {
- SCLogError(SC_ERR_MT_NO_MAPPING, "no multi-detect mappings defined");
+ SCLogError("no multi-detect mappings defined");
goto error;
} else {
- SCLogWarning(SC_ERR_MT_NO_MAPPING, "no multi-detect mappings defined");
+ SCLogWarning("no multi-detect mappings defined");
}
}
}
failure_fatal);
if (mapping_cnt == 0) {
if (failure_fatal) {
- SCLogError(SC_ERR_MT_NO_MAPPING, "no multi-detect mappings defined");
+ SCLogError("no multi-detect mappings defined");
goto error;
} else {
- SCLogWarning(SC_ERR_MT_NO_MAPPING, "no multi-detect mappings defined");
+ SCLogWarning("no multi-detect mappings defined");
}
}
}
uint32_t tenant_id = 0;
if (StringParseUint32(
&tenant_id, 10, (uint16_t)strlen(id_node->val), id_node->val) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant_id "
- "of %s is invalid", id_node->val);
+ SCLogError("tenant_id "
+ "of %s is invalid",
+ id_node->val);
goto bad_tenant;
}
SCLogDebug("tenant id: %u, %s", tenant_id, yaml_node->val);
char prefix[64];
snprintf(prefix, sizeof(prefix), "multi-detect.%u", tenant_id);
if (ConfYamlLoadFileWithPrefix(yaml_node->val, prefix) != 0) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to load yaml %s", yaml_node->val);
+ SCLogError("failed to load yaml %s", yaml_node->val);
goto bad_tenant;
}
if (suri->conf_filename != NULL) {
snprintf(prefix, sizeof(prefix), "detect-engine-reloads.%d", reloads++);
if (ConfYamlLoadFileWithPrefix(suri->conf_filename, prefix) != 0) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to load yaml %s",
- suri->conf_filename);
+ SCLogError("failed to load yaml %s", suri->conf_filename);
return -1;
}
ConfNode *node = ConfGetNode(prefix);
if (node == NULL) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to properly setup yaml %s",
- suri->conf_filename);
+ SCLogError("failed to properly setup yaml %s", suri->conf_filename);
return -1;
}
#if 0
/* get new detection engine */
new_de_ctx = DetectEngineCtxInitWithPrefix(prefix);
if (new_de_ctx == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
- "context failed.");
+ SCLogError("initializing detection engine "
+ "context failed.");
DetectEngineDeReference(&old_de_ctx);
return -1;
}
{
*event_id = SCMapEnumNameToValue(event_name, det_ctx_event_table);
if (*event_id == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "event \"%s\" not present in "
- "det_ctx's enum map table.", event_name);
+ SCLogError("event \"%s\" not present in "
+ "det_ctx's enum map table.",
+ event_name);
/* this should be treated as fatal */
return -1;
}
for (SCFPSupportSMList *tmp = g_fp_support_smlist_list; tmp != NULL; tmp = tmp->next) {
SCFPSupportSMList *n = SCCalloc(1, sizeof(*n));
if (n == NULL) {
- FatalError(SC_ERR_FATAL, "out of memory: %s", strerror(errno));
+ FatalError("out of memory: %s", strerror(errno));
}
n->list_id = tmp->list_id;
n->priority = tmp->priority;
SigMatch *pm1 = DetectGetLastSMFromMpmLists(de_ctx, s);
SigMatch *pm2 = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm1 == NULL && pm2 == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "fast_pattern found inside "
- "the rule, without a content context. Please use a "
- "content based keyword before using fast_pattern");
+ SCLogError("fast_pattern found inside "
+ "the rule, without a content context. Please use a "
+ "content based keyword before using fast_pattern");
return -1;
}
(cd->flags & DETECT_CONTENT_DEPTH))) {
/* we can't have any of these if we are having "only" */
- SCLogError(SC_ERR_INVALID_SIGNATURE, "fast_pattern; cannot be "
+ SCLogError("fast_pattern; cannot be "
"used with negated content, along with relative modifiers");
goto error;
}
if (arg == NULL|| strcmp(arg, "") == 0) {
if (cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple fast_pattern "
- "options for the same content");
+ SCLogError("can't use multiple fast_pattern "
+ "options for the same content");
goto error;
}
else { /*allow only one content to have fast_pattern modifier*/
if (sm->type == DETECT_CONTENT) {
DetectContentData *tmp_cd = (DetectContentData *)sm->ctx;
if (tmp_cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "fast_pattern "
- "can be used on only one content in a rule");
+ SCLogError("fast_pattern "
+ "can be used on only one content in a rule");
goto error;
}
}
(cd->flags & DETECT_CONTENT_DEPTH)) {
/* we can't have any of these if we are having "only" */
- SCLogError(SC_ERR_INVALID_SIGNATURE, "fast_pattern: only; cannot be "
+ SCLogError("fast_pattern: only; cannot be "
"used with negated content or with any of the relative "
"modifiers like distance, within, offset, depth");
goto error;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)arg_substr, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for fast_pattern offset");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for fast_pattern offset");
goto error;
}
uint16_t offset;
if (StringParseUint16(&offset, 10, 0,
(const char *)arg_substr) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid fast pattern offset:"
- " \"%s\"", arg_substr);
+ SCLogError("Invalid fast pattern offset:"
+ " \"%s\"",
+ arg_substr);
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)arg_substr, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed "
- "for fast_pattern offset");
+ SCLogError("pcre2_substring_copy_bynumber failed "
+ "for fast_pattern offset");
goto error;
}
uint16_t length;
if (StringParseUint16(&length, 10, 0,
(const char *)arg_substr) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid value for fast "
- "pattern: \"%s\"", arg_substr);
+ SCLogError("Invalid value for fast "
+ "pattern: \"%s\"",
+ arg_substr);
goto error;
}
// Avoiding integer overflow
if (offset > (65535 - length)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Fast pattern (length + offset) "
+ SCLogError("Fast pattern (length + offset) "
"exceeds limit pattern length limit");
goto error;
}
if (offset + length > cd->content_len) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Fast pattern (length + "
+ SCLogError("Fast pattern (length + "
"offset (%u)) exceeds pattern length (%u)",
- offset + length, cd->content_len);
+ offset + length, cd->content_len);
goto error;
}
cd->flags |= DETECT_CONTENT_FAST_PATTERN_CHOP;
} else {
- SCLogError(SC_ERR_PCRE_PARSE, "parse error, ret %" PRId32
- ", string %s", ret, arg);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, arg);
goto error;
}
s->alproto != ALPROTO_HTTP2 && s->alproto != ALPROTO_FTP &&
s->alproto != ALPROTO_FTPDATA && s->alproto != ALPROTO_HTTP &&
s->alproto != ALPROTO_NFS)) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting keywords.");
+ SCLogError("rule contains conflicting keywords.");
return -1;
}
if (s->alproto == ALPROTO_SMTP && (s->init_data->init_flags & SIG_FLAG_INIT_FLOW) &&
!(s->flags & SIG_FLAG_TOSERVER) && (s->flags & SIG_FLAG_TOCLIENT)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Can't use file_data with "
- "flow:to_client or flow:from_server with smtp.");
+ SCLogError("Can't use file_data with "
+ "flow:to_client or flow:from_server with smtp.");
return -1;
}
uint16_t expected_len)
{
if (strlen(string) != expected_len) {
- SCLogError(SC_ERR_INVALID_HASH, "%s:%d hash string not %d characters",
- filename, line_no, expected_len);
+ SCLogError("%s:%d hash string not %d characters", filename, line_no, expected_len);
return -1;
}
if (value >= 0 && value <= 255)
hash[x] = (uint8_t)value;
else {
- SCLogError(SC_ERR_INVALID_HASH, "%s:%d hash byte out of range %ld",
- filename, line_no, value);
+ SCLogError("%s:%d hash byte out of range %ld", filename, line_no, value);
return -1;
}
}
snprintf(path, sizeof(path), "%s/%s", dir, str);
fp = fopen(path, "r");
if (fp == NULL) {
- SCLogError(SC_ERR_OPENING_RULE_FILE,
- "opening hash file %s: %s", path, strerror(errno));
+ SCLogError("opening hash file %s: %s", path, strerror(errno));
goto error;
}
}
}
if (fp == NULL) {
#endif
- SCLogError(SC_ERR_OPENING_RULE_FILE, "opening hash file %s: %s", filename, strerror(errno));
+ SCLogError("opening hash file %s: %s", filename, strerror(errno));
goto error;
#ifdef HAVE_LIBGEN_H
}
static int DetectFilemagicSetupNoSupport (DetectEngineCtx *de_ctx, Signature *s, const char *str)
{
- SCLogError(SC_ERR_NO_MAGIC_SUPPORT, "no libmagic support built in, needed for filemagic keyword");
+ SCLogError("no libmagic support built in, needed for filemagic keyword");
return -1;
}
{
DetectFilemagicThreadData *t = SCCalloc(1, sizeof(DetectFilemagicThreadData));
if (unlikely(t == NULL)) {
- SCLogError(SC_ENOMEM, "couldn't alloc ctx memory");
+ SCLogError("couldn't alloc ctx memory");
return NULL;
}
de_ctx->version);
}
if (!RequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
- SCLogWarning(SC_WARN_ALERT_CONFIG, "One or more rule(s) depends on the "
+ SCLogWarning("One or more rule(s) depends on the "
"file-store output log which is not enabled. "
"Enable the output \"file-store\".");
}
/* filestore and bypass keywords can't work together */
if (s->flags & SIG_FLAG_BYPASS) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "filestore can't work with bypass keyword");
+ SCLogError("filestore can't work with bypass keyword");
return -1;
}
ret = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 ", string %s", ret, str);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, str);
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 *)str_0, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[0] = (char *)str_0;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)str_1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[1] = (char *)str_1;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)str_2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[2] = (char *)str_2;
ret = DetectParsePcreExec(&parse_regex, flowstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 ", string %s", ret, flowstr);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, flowstr);
goto error;
}
pcre2len = sizeof(str1);
res = SC_Pcre2SubstringCopy(parse_regex.match, 1, (PCRE2_UCHAR8 *)str1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[0] = (char *)str1;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)str2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[1] = (char *)str2;
res = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)str3, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
args[2] = (char *)str3;
/* inspect our options and set the flags */
if (strcasecmp(args[i], "established") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_ESTABLISHED) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "DETECT_FLOW_FLAG_ESTABLISHED flag is already set");
+ SCLogError("DETECT_FLOW_FLAG_ESTABLISHED flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_STATELESS) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "DETECT_FLOW_FLAG_STATELESS already set");
+ SCLogError("DETECT_FLOW_FLAG_STATELESS already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_ESTABLISHED;
} else if (strcasecmp(args[i], "not_established") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_NOT_ESTABLISHED) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "DETECT_FLOW_FLAG_NOT_ESTABLISHED flag is already set");
+ SCLogError("DETECT_FLOW_FLAG_NOT_ESTABLISHED flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_NOT_ESTABLISHED) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set DETECT_FLOW_FLAG_NOT_ESTABLISHED, DETECT_FLOW_FLAG_ESTABLISHED already set");
+ SCLogError("cannot set DETECT_FLOW_FLAG_NOT_ESTABLISHED, "
+ "DETECT_FLOW_FLAG_ESTABLISHED already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_NOT_ESTABLISHED;
} else if (strcasecmp(args[i], "stateless") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_STATELESS) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "DETECT_FLOW_FLAG_STATELESS flag is already set");
+ SCLogError("DETECT_FLOW_FLAG_STATELESS flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_ESTABLISHED) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set DETECT_FLOW_FLAG_STATELESS, DETECT_FLOW_FLAG_ESTABLISHED already set");
+ SCLogError("cannot set DETECT_FLOW_FLAG_STATELESS, "
+ "DETECT_FLOW_FLAG_ESTABLISHED already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_STATELESS;
} else if (strcasecmp(args[i], "to_client") == 0 || strcasecmp(args[i], "from_server") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_TOCLIENT) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set DETECT_FLOW_FLAG_TOCLIENT flag is already set");
+ SCLogError("cannot set DETECT_FLOW_FLAG_TOCLIENT flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_TOSERVER) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set to_client, DETECT_FLOW_FLAG_TOSERVER already set");
+ SCLogError("cannot set to_client, DETECT_FLOW_FLAG_TOSERVER already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_TOCLIENT;
} else if (strcasecmp(args[i], "to_server") == 0 || strcasecmp(args[i], "from_client") == 0){
if (fd->flags & DETECT_FLOW_FLAG_TOSERVER) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set DETECT_FLOW_FLAG_TOSERVER flag is already set");
+ SCLogError("cannot set DETECT_FLOW_FLAG_TOSERVER flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_TOCLIENT) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set to_server, DETECT_FLOW_FLAG_TO_CLIENT flag already set");
+ SCLogError("cannot set to_server, DETECT_FLOW_FLAG_TO_CLIENT flag already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_TOSERVER;
} else if (strcasecmp(args[i], "only_stream") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_ONLYSTREAM) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set only_stream flag is already set");
+ SCLogError("cannot set only_stream flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_NOSTREAM) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set only_stream flag, DETECT_FLOW_FLAG_NOSTREAM already set");
+ SCLogError(
+ "cannot set only_stream flag, DETECT_FLOW_FLAG_NOSTREAM already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_ONLYSTREAM;
} else if (strcasecmp(args[i], "no_stream") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_NOSTREAM) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set no_stream flag is already set");
+ SCLogError("cannot set no_stream flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_ONLYSTREAM) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set no_stream flag, DETECT_FLOW_FLAG_ONLYSTREAM already set");
+ SCLogError(
+ "cannot set no_stream flag, DETECT_FLOW_FLAG_ONLYSTREAM already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_NOSTREAM;
} else if (strcasecmp(args[i], "no_frag") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_NO_FRAG) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set no_frag flag is already set");
+ SCLogError("cannot set no_frag flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_ONLY_FRAG) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set no_frag flag, only_frag already set");
+ SCLogError("cannot set no_frag flag, only_frag already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_NO_FRAG;
} else if (strcasecmp(args[i], "only_frag") == 0) {
if (fd->flags & DETECT_FLOW_FLAG_ONLY_FRAG) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set only_frag flag is already set");
+ SCLogError("cannot set only_frag flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_NO_FRAG) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "cannot set only_frag flag, no_frag already set");
+ SCLogError("cannot set only_frag flag, no_frag already set");
goto error;
}
fd->flags |= DETECT_FLOW_FLAG_ONLY_FRAG;
} else {
- SCLogError(SC_EINVAL, "invalid flow option \"%s\"", args[i]);
+ SCLogError("invalid flow option \"%s\"", args[i]);
goto error;
}
{
/* ensure only one flow option */
if (s->init_data->init_flags & SIG_FLAG_INIT_FLOW) {
- SCLogError (SC_ERR_INVALID_SIGNATURE, "A signature may have only one flow option.");
+ SCLogError("A signature may have only one flow option.");
return -1;
}
// Check for spaces in between the flowbit names
if (strchr(token, ' ') != NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Spaces are not allowed in flowbit names.");
+ SCLogError("Spaces are not allowed in flowbit names.");
return -1;
}
if (i == MAX_TOKENS) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Number of flowbits exceeds "
- "maximum allowed: %d.", MAX_TOKENS);
+ SCLogError("Number of flowbits exceeds "
+ "maximum allowed: %d.",
+ MAX_TOKENS);
return -1;
}
strarr[i++] = token;
case DETECT_FLOWBITS_CMD_TOGGLE:
return DetectFlowbitMatchToggle(p,fd);
default:
- SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown cmd %" PRIu32 "", fd->cmd);
+ SCLogError("unknown cmd %" PRIu32 "", fd->cmd);
return 0;
}
count = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (count != 2 && count != 3) {
- SCLogError(SC_ERR_PCRE_MATCH,
- "\"%s\" is not a valid setting for flowbits.", str);
+ SCLogError("\"%s\" is not a valid setting for flowbits.", str);
return 0;
}
pcre2len = cmd_len;
rc = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)cmd, &pcre2len);
if (rc < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return 0;
}
pcre2len = name_len;
rc = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)name, &pcre2len);
if (rc < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return 0;
}
/* Validate name, spaces are not allowed. */
for (size_t i = 0; i < strlen(name); i++) {
if (isblank(name[i])) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "spaces not allowed in flowbit names");
+ SCLogError("spaces not allowed in flowbit names");
return 0;
}
}
} else if (strcmp(fb_cmd_str,"toggle") == 0) {
fb_cmd = DETECT_FLOWBITS_CMD_TOGGLE;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
+ SCLogError("ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
goto error;
}
struct FBAnalyze *array = SCCalloc(array_size, sizeof(struct FBAnalyze));
if (array == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate flowbit analyze array");
+ SCLogError("Unable to allocate flowbit analyze array");
return -1;
}
array[i].cnts[DETECT_FLOWBITS_CMD_SET] == 0) {
const Signature *s = de_ctx->sig_array[array[i].isset_sids[0]];
- SCLogWarning(SC_WARN_FLOWBIT, "flowbit '%s' is checked but not "
- "set. Checked in %u and %u other sigs",
+ SCLogWarning("flowbit '%s' is checked but not "
+ "set. Checked in %u and %u other sigs",
varname, s->id, array[i].isset_sids_idx - 1);
}
if (array[i].state_cnts[DETECT_FLOWBITS_CMD_ISSET] &&
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 3 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "\"%s\" is not a valid setting for flowint(ret = %d).", rawstr, ret);
+ SCLogError("\"%s\" is not a valid setting for flowint(ret = %d).", rawstr, ret);
return NULL;
}
/* Get our flowint varname */
res = pcre2_substring_get_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
varname = (char *)str_ptr;
res = pcre2_substring_get_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
modstr = (char *)str_ptr;
modifier = FLOWINT_MODIFIER_NOTSET;
if (modifier == FLOWINT_MODIFIER_UNKNOWN) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "Unknown modifier");
+ SCLogError("Unknown modifier");
goto error;
}
parse_regex.match, 3, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
varval = (char *)str_ptr;
if (res < 0 || varval == NULL || strcmp(varval, "") == 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
sfd->targettype = FLOWINT_TARGET_VAR;
sfd->target.tvar.name = SCStrdup(varval);
if (unlikely(sfd->target.tvar.name == NULL)) {
- SCLogError(SC_ENOMEM, "malloc from strdup failed");
+ SCLogError("malloc from strdup failed");
goto error;
}
}
/* Set the name of the origin var to modify/compared with the target */
sfd->name = SCStrdup(varname);
if (unlikely(sfd->name == NULL)) {
- SCLogError(SC_ENOMEM, "malloc from strdup failed");
+ SCLogError("malloc from strdup failed");
goto error;
}
sfd->idx = VarNameStoreSetupAdd(varname, VAR_TYPE_FLOW_INT);
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret != 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "\"%s\" is not a valid setting for flowvar.", rawstr);
+ SCLogError("\"%s\" is not a valid setting for flowvar.", rawstr);
return -1;
}
pcre2len = sizeof(varname);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)varname, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)varcontent, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
for (i = 0; i < (ret - 1); i++) {
res = SC_Pcre2SubstringGet(parse_regex.match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed %d", res);
+ SCLogError("pcre2_substring_get_bynumber failed %d", res);
goto error;
}
}
if (args[1] == NULL) {
- SCLogError(SC_EINVAL, "invalid value");
+ SCLogError("invalid value");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, fragoffsetstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH,"Parse error %s", fragoffsetstr);
+ SCLogError("Parse error %s", fragoffsetstr);
goto error;
}
for (i = 1; i < ret; i++) {
res = SC_Pcre2SubstringGet(parse_regex.match, i, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
substr[i-1] = (char *)str_ptr;
}
if (StringParseUint16(&fragoff->frag_off, 10, 0, substr[1]) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "specified frag offset %s is not "
- "valid", substr[1]);
+ SCLogError("specified frag offset %s is not "
+ "valid",
+ substr[1]);
goto error;
}
const bool is_tcp = DetectProtoContainsProto(&s->proto, IPPROTO_TCP);
const bool is_udp = DetectProtoContainsProto(&s->proto, IPPROTO_UDP);
if (!(is_tcp || is_udp)) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "'frame' keyword only supported for TCP and UDP");
+ SCLogError("'frame' keyword only supported for TCP and UDP");
return -1;
}
}
if (is_short && rule_alproto == ALPROTO_UNKNOWN) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "rule protocol unknown, can't use shorthand notation for frame '%s'", str);
+ SCLogError("rule protocol unknown, can't use shorthand notation for frame '%s'", str);
return -1;
} else if (rule_alproto == ALPROTO_UNKNOWN) {
if (DetectSignatureSetAppProto(s, keyword_alproto) < 0)
return -1;
} else if (!AppProtoEquals(rule_alproto, keyword_alproto)) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
- "frame '%s' protocol '%s' mismatch with rule protocol '%s'", str,
+ SCLogError("frame '%s' protocol '%s' mismatch with rule protocol '%s'", str,
AppProtoToString(keyword_alproto), AppProtoToString(s->alproto));
return -1;
}
if (is_udp && raw_frame_type < 0)
raw_frame_type = AppLayerParserGetFrameIdByName(IPPROTO_UDP, keyword_alproto, frame_str);
if (raw_frame_type < 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "unknown frame '%s' for protocol '%s'", frame_str,
- proto);
+ SCLogError("unknown frame '%s' for protocol '%s'", frame_str, proto);
return -1;
}
BUG_ON(raw_frame_type >= UINT8_MAX);
int ret = DetectParsePcreExec(&parse_regex, ftpcommandstr, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 "", ret);
+ SCLogError("parse error, ret %" PRId32 "", ret);
goto error;
}
pcre2len = sizeof(arg1);
int res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)arg1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
SCLogDebug("Arg1 \"%s\"", arg1);
} else if (!strcmp(arg1, "retr")) {
ftpcommandd->command = FTP_COMMAND_RETR;
} else {
- SCLogError(SC_ERR_NOT_SUPPORTED, "Invalid command value");
+ SCLogError("Invalid command value");
goto error;
}
static int DetectGeoipSetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c)
{
- SCLogError(SC_ERR_NO_GEOIP_SUPPORT, "no GeoIP support built in, needed for geoip keyword");
+ SCLogError("no GeoIP support built in, needed for geoip keyword");
return -1;
}
(void)ConfGet("geoip-database", &filename);
if (filename == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Unable to locate a GeoIP2"
+ SCLogWarning("Unable to locate a GeoIP2"
"database filename in YAML conf. GeoIP rule matching "
"is disabled.");
geoipdata->mmdb_status = MMDB_FILE_OPEN_ERROR;
return true;
}
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Failed to open GeoIP2 database: %s. "
- "Error was: %s. GeoIP rule matching is disabled.", filename,
- MMDB_strerror(status));
+ SCLogWarning("Failed to open GeoIP2 database: %s. "
+ "Error was: %s. GeoIP rule matching is disabled.",
+ filename, MMDB_strerror(status));
geoipdata->mmdb_status = status;
return false;
}
}
if (geoipdata->nlocations >= GEOOPTION_MAXLOCATIONS) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "too many arguements for geoip keyword");
+ SCLogError("too many arguements for geoip keyword");
goto error;
}
char *endptr = NULL;
gid = strtoul(rawstr, &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid character as arg "
+ SCLogError("invalid character as arg "
"to gid keyword");
goto error;
}
if (gid >= UINT_MAX) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "gid value to high, max %u", UINT_MAX);
+ SCLogError("gid value to high, max %u", UINT_MAX);
goto error;
}
case DETECT_XBITS_CMD_TOGGLE:
return DetectHostbitMatchToggle(p,xd);
default:
- SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown cmd %" PRIu32 "", xd->cmd);
+ SCLogError("unknown cmd %" PRIu32 "", xd->cmd);
return 0;
}
count = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (count != 2 && count != 3 && count != 4) {
- SCLogError(SC_ERR_PCRE_MATCH,
- "\"%s\" is not a valid setting for hostbits.", str);
+ SCLogError("\"%s\" is not a valid setting for hostbits.", str);
return 0;
}
pcre2len = cmd_len;
rc = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)cmd, &pcre2len);
if (rc < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return 0;
}
pcre2len = name_len;
rc = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)name, &pcre2len);
if (rc < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return 0;
}
if (count >= 4) {
rc = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)dir, &pcre2len);
if (rc < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return 0;
}
}
hb_dir = DETECT_XBITS_TRACK_IPDST;
else if (strcmp(hb_dir_str, "both") == 0) {
//hb_dir = DETECT_XBITS_TRACK_IPBOTH;
- SCLogError(SC_ERR_UNIMPLEMENTED, "'both' not implemented");
+ SCLogError("'both' not implemented");
goto error;
} else {
// TODO
} else if (strcmp(fb_cmd_str,"toggle") == 0) {
fb_cmd = DETECT_XBITS_CMD_TOGGLE;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
+ SCLogError("ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
goto error;
}
"The hostname buffer is normalized "
"to lowercase, specifying "
"nocase is redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
} else {
uint32_t u;
"uppercase characters detected for http.host. "
"The hostname buffer is normalized to lowercase, "
"please specify a lowercase pattern.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
}
if (cd->content && cd->content_len) {
if (cd->content[cd->content_len-1] == 0x20) {
*sigerror = "http_method pattern with trailing space";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return false;
} else if (cd->content[0] == 0x20) {
*sigerror = "http_method pattern with leading space";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return false;
} else if (cd->content[cd->content_len-1] == 0x09) {
*sigerror = "http_method pattern with trailing tab";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return false;
} else if (cd->content[0] == 0x09) {
*sigerror = "http_method pattern with leading tab";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return false;
}
}
"inspecting request headers or flow:to_client for "
"inspecting response headers.";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
SCReturnInt(false);
}
return true;
return -1;
if (!DetectHTTP2FuncParseFrameType(str, &frame_type)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Invalid argument \"%s\" supplied to http2.frametype keyword.", str);
+ SCLogError("Invalid argument \"%s\" supplied to http2.frametype keyword.", str);
return -1;
}
return -1;
if (!DetectHTTP2FuncParseErrorCode(str, &error_code)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Invalid argument \"%s\" supplied to http2.errorcode keyword.", str);
+ SCLogError("Invalid argument \"%s\" supplied to http2.errorcode keyword.", str);
return -1;
}
*sigerror = "Invalid http2.header string : "
"': ' is a special sequence for separation between name and value "
" and thus can only be present once";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
namevaluesep = true;
*sigerror = "Invalid http2.header string : "
"':' is an escaping character for itself, "
"or space for the separation between name and value";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
escaped = false;
*sigerror = "Invalid http2.header string : "
"':' is an escaping character for itself, "
"or space for the separation between name and value";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
}
ret = DetectParsePcreExec(&parse_regex, icmpidstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "Parse error %s", icmpidstr);
+ SCLogError("Parse error %s", icmpidstr);
goto error;
}
for (i = 1; i < ret; i++) {
res = SC_Pcre2SubstringGet(parse_regex.match, i, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
substr[i-1] = (char *)str_ptr;
if (substr[0]!= NULL && strlen(substr[0]) != 0) {
if (substr[2] == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing close quote in input");
+ SCLogError("Missing close quote in input");
goto error;
}
} else {
if (substr[2] != NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing open quote in input");
+ SCLogError("Missing open quote in input");
goto error;
}
}
uint16_t id = 0;
if (StringParseUint16(&id, 10, 0, substr[1]) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp id %s is not "
- "valid", substr[1]);
+ SCLogError("specified icmp id %s is not "
+ "valid",
+ substr[1]);
goto error;
}
iid->id = htons(id);
ret = DetectParsePcreExec(&parse_regex, icmpseqstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH,"Parse error %s", icmpseqstr);
+ SCLogError("Parse error %s", icmpseqstr);
goto error;
}
for (i = 1; i < ret; i++) {
res = SC_Pcre2SubstringGet(parse_regex.match, i, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
substr[i-1] = (char *)str_ptr;
if (substr[0] != NULL && strlen(substr[0]) != 0) {
if (substr[2] == NULL) {
- SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
+ SCLogError("Missing quote in input");
goto error;
}
} else {
if (substr[2] != NULL) {
- SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
+ SCLogError("Missing quote in input");
goto error;
}
}
uint16_t seq = 0;
if (StringParseUint16(&seq, 10, 0, substr[1]) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp seq %s is not "
- "valid", substr[1]);
+ SCLogError("specified icmp seq %s is not "
+ "valid",
+ substr[1]);
goto error;
}
iseq->seq = htons(seq);
ret = DetectParsePcreExec(&parse_regex, idstr, 0, 0);
if (ret < 1 || ret > 3) {
- SCLogError(SC_EINVAL,
- "invalid id option '%s'. The id option "
- "value must be in the range %u - %u",
+ SCLogError("invalid id option '%s'. The id option "
+ "value must be in the range %u - %u",
idstr, DETECT_IPID_MIN, DETECT_IPID_MAX);
return NULL;
}
pcre2len = sizeof(copy_str);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return NULL;
}
tmp_str = copy_str;
/* ok, fill the id data */
if (StringParseUint16(&temp, 10, 0, (const char *)tmp_str) < 0) {
- SCLogError(SC_EINVAL, "invalid id option '%s'", tmp_str);
+ SCLogError("invalid id option '%s'", tmp_str);
return NULL;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 3 || ret > 5) {
- SCLogError(SC_ERR_PCRE_MATCH,
+ SCLogError(
"pcre match for ike.chosen_sa_attribute failed, should be: <sa_attribute>=<type>, "
"but was: %s; error code %d",
rawstr, ret);
pcre2len = sizeof(attribute);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)attribute, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
pcre2len = sizeof(value);
res = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)value, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
goto error;
if (ByteExtractStringUint32(&dd->sa_value, 10, strlen(value), value) <= 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid input as arg "
- "to ike.chosen_sa_attribute keyword");
+ SCLogError("invalid input as arg "
+ "to ike.chosen_sa_attribute keyword");
goto error;
}
DetectIkeChosenSaData *dd = DetectIkeChosenSaParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
/* Execute the regex and populate args with captures. */
ret = DetectParsePcreExec(&parse_regex, optstr, 0, 0);
if (ret != 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret"
- "%" PRId32 ", string %s", ret, optstr);
+ SCLogError("pcre_exec parse error, ret"
+ "%" PRId32 ", string %s",
+ ret, optstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[i] = (char *)str_ptr;
if (!isdigit((unsigned char)*(args[1]))) {
uint8_t proto;
if (!SCGetProtoByName(args[1], &proto)) {
- SCLogError(SC_EINVAL, "Unknown protocol name: \"%s\"", str_ptr);
+ SCLogError("Unknown protocol name: \"%s\"", str_ptr);
goto error;
}
data->proto = proto;
}
else {
if (StringParseUint8(&data->proto, 10, 0, args[1]) <= 0) {
- SCLogError(SC_EINVAL, "Malformed protocol number: %s", str_ptr);
+ SCLogError("Malformed protocol number: %s", str_ptr);
goto error;
}
}
* not true we error out on the sig. And hence the init_flag to
* indicate this. */
if (!(s->init_data->init_flags & SIG_FLAG_INIT_FIRST_IPPROTO_SEEN)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Signature can use "
+ SCLogError("Signature can use "
"ip_proto keyword only when we use alert ip, "
"in which case the _ANY flag is set on the sig "
"and the if condition should match.");
switch (data->op) {
case DETECT_IPPROTO_OP_EQ:
if (eq_set || gt_set || lt_set || not_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a eq "
+ SCLogError("can't use a eq "
"ipproto without any operators attached to "
"them in the same sig");
goto error;
case DETECT_IPPROTO_OP_GT:
if (eq_set || gt_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a eq or gt "
+ SCLogError("can't use a eq or gt "
"ipproto along with a greater than ipproto in the "
"same sig ");
goto error;
if (temp_sm != NULL) {
DetectIPProtoData *data_temp = (DetectIPProtoData *)temp_sm->ctx;
if (data_temp->proto <= data->proto) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have "
- "both gt and lt ipprotos, with the lt being "
- "lower than gt value");
+ SCLogError("can't have "
+ "both gt and lt ipprotos, with the lt being "
+ "lower than gt value");
goto error;
} else {
for (i = 0; i < (data->proto / 8); i++) {
if (temp_sm != NULL) {
data_temp = (DetectIPProtoData *)temp_sm->ctx;
if (data_temp->proto <= data->proto) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have "
- "both gt and lt ipprotos, with the lt being "
- "lower than gt value");
+ SCLogError("can't have "
+ "both gt and lt ipprotos, with the lt being "
+ "lower than gt value");
goto error;
} else {
for (i = 0; i < (data->proto / 8); i++) {
case DETECT_IPPROTO_OP_LT:
if (eq_set || lt_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a eq or lt "
+ SCLogError("can't use a eq or lt "
"ipproto along with a less than ipproto in the "
"same sig ");
goto error;
if (temp_sm != NULL) {
DetectIPProtoData *data_temp = (DetectIPProtoData *)temp_sm->ctx;
if (data_temp->proto >= data->proto) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a have "
- "both gt and lt ipprotos, with the lt being "
- "lower than gt value");
+ SCLogError("can't use a have "
+ "both gt and lt ipprotos, with the lt being "
+ "lower than gt value");
goto error;
} else {
for (i = 0; i < (data->proto / 8); i++) {
if (temp_sm != NULL) {
data_temp = (DetectIPProtoData *)temp_sm->ctx;
if (data_temp->proto >= data->proto) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have "
- "both gt and lt ipprotos, with the lt being "
- "lower than gt value");
+ SCLogError("can't have "
+ "both gt and lt ipprotos, with the lt being "
+ "lower than gt value");
goto error;
} else {
for (i = 0; i < (data->proto / 8); i++) {
case DETECT_IPPROTO_OP_NOT:
if (eq_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a eq "
+ SCLogError("can't use a eq "
"ipproto along with a not ipproto in the "
"same sig ");
goto error;
DetectIPRepData *cd = rs_detect_iprep_parse(rawstr);
if (cd == NULL) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "\"%s\" is not a valid setting for iprep", rawstr);
+ SCLogError("\"%s\" is not a valid setting for iprep", rawstr);
goto error;
}
ret = DetectParsePcreExec(&parse_regex, isdataatstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, isdataatstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, isdataatstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[0] = (char *)str_ptr;
res = pcre2_substring_get_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[1] = (char *)str_ptr;
res = pcre2_substring_get_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[2] = (char *)str_ptr;
if (args[0][0] != '-' && isalpha((unsigned char)args[0][0])) {
if (offset == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "isdataat supplied with "
+ SCLogError("isdataat supplied with "
"var name for offset. \"offset\" argument supplied to "
"this function has to be non-NULL");
goto error;
} else {
if (StringParseUint16(&idad->dataat, 10,
strlen(args[0]), args[0]) < 0 ) {
- SCLogError(SC_EINVAL, "isdataat out of range");
+ SCLogError("isdataat out of range");
SCFree(idad);
idad = NULL;
goto error;
if (offset != NULL) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(offset, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown byte_extract var "
- "seen in isdataat - %s\n", offset);
+ SCLogError("Unknown byte_extract var "
+ "seen in isdataat - %s\n",
+ offset);
goto end;
}
idad->dataat = index;
/* retrieve the sm to apply the depth against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_DEPTH_MISSING_CONTENT, "endswith needs a "
+ SCLogError("endswith needs a "
"preceding content option");
goto end;
}
ret = DetectParsePcreExec(&parse_regex, krb5str, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 "", ret);
+ SCLogError("parse error, ret %" PRId32 "", ret);
goto error;
}
pcre2len = sizeof(arg1);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)arg1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, krb5str, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 "", ret);
+ SCLogError("parse error, ret %" PRId32 "", ret);
goto error;
}
pcre2len = sizeof(arg1);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)arg1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcasecmp(str,"ipv4") == 0 ||
strcasecmp(str,"ip4") == 0 ) {
if (s->proto.flags & DETECT_PROTO_IPV6) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Conflicting l3 proto specified");
+ SCLogError("Conflicting l3 proto specified");
goto error;
}
s->proto.flags |= DETECT_PROTO_IPV4;
} else if (strcasecmp(str,"ipv6") == 0 ||
strcasecmp(str,"ip6") == 0 ) {
if (s->proto.flags & DETECT_PROTO_IPV6) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Conflicting l3 proto specified");
+ SCLogError("Conflicting l3 proto specified");
goto error;
}
s->proto.flags |= DETECT_PROTO_IPV6;
SCLogDebug("IPv6 protocol detected");
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid l3 proto: \"%s\"", str);
+ SCLogError("Invalid l3 proto: \"%s\"", str);
goto error;
}
static int DetectLuaSetupNoSupport (DetectEngineCtx *a, Signature *b, const char *c)
{
- SCLogError(SC_ERR_NO_LUA_SUPPORT, "no Lua support built in, needed for lua/luajit keyword");
+ SCLogError("no Lua support built in, needed for lua/luajit keyword");
return -1;
}
if (strcmp(k, "retval") == 0) {
int val;
if (StringParseInt32(&val, 10, 0, (const char *)v) < 0) {
- SCLogError(SC_EINVAL,
- "Invalid value "
- "for \"retval\" from LUA return table: '%s'",
+ SCLogError("Invalid value "
+ "for \"retval\" from LUA return table: '%s'",
v);
ret = 0;
}
int val;
if (StringParseInt32(&val, 10, 0,
(const char *)v) < 0) {
- SCLogError(SC_EINVAL,
- "Invalid value "
- "for \"retval\" from LUA return table: '%s'",
+ SCLogError("Invalid value "
+ "for \"retval\" from LUA return table: '%s'",
v);
ret = 0;
}
int val;
if (StringParseInt32(&val, 10, 0,
(const char *)v) < 0) {
- SCLogError(SC_EINVAL,
- "Invalid value "
- "for \"retval\" from LUA return table: '%s'",
+ SCLogError("Invalid value "
+ "for \"retval\" from LUA return table: '%s'",
v);
ret = 0;
}
DetectLuaThreadData *t = SCMalloc(sizeof(DetectLuaThreadData));
if (unlikely(t == NULL)) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't alloc ctx memory");
+ SCLogError("couldn't alloc ctx memory");
return NULL;
}
memset(t, 0x00, sizeof(DetectLuaThreadData));
t->luastate = LuaGetState();
if (t->luastate == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "luastate pool depleted");
+ SCLogError("luastate pool depleted");
goto error;
}
if (ut_script != NULL) {
status = luaL_loadbuffer(t->luastate, ut_script, strlen(ut_script), "unittest");
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(t->luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(t->luastate, -1));
goto error;
}
} else {
#endif
status = luaL_loadfile(t->luastate, lua->filename);
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(t->luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(t->luastate, -1));
goto error;
}
#ifdef UNITTESTS
/* prime the script (or something) */
if (lua_pcall(t->luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't prime file: %s", lua_tostring(t->luastate, -1));
+ SCLogError("couldn't prime file: %s", lua_tostring(t->luastate, -1));
goto error;
}
if (ut_script != NULL) {
status = luaL_loadbuffer(luastate, ut_script, strlen(ut_script), "unittest");
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(luastate, -1));
goto error;
}
} else {
#endif
status = luaL_loadfile(luastate, ld->filename);
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(luastate, -1));
goto error;
}
#ifdef UNITTESTS
/* prime the script (or something) */
if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't prime file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't prime file: %s", lua_tostring(luastate, -1));
goto error;
}
lua_getglobal(luastate, "init");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no init function in script");
+ SCLogError("no init function in script");
goto error;
}
lua_newtable(luastate); /* stack at -1 */
if (lua_gettop(luastate) == 0 || lua_type(luastate, 2) != LUA_TTABLE) {
- SCLogError(SC_ERR_LUA_ERROR, "no table setup");
+ SCLogError("no table setup");
goto error;
}
lua_settable(luastate, -3);
if (lua_pcall(luastate, 1, 1, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't run script 'init' function: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't run script 'init' function: %s", lua_tostring(luastate, -1));
goto error;
}
/* process returns from script */
if (lua_gettop(luastate) == 0) {
- SCLogError(SC_ERR_LUA_ERROR, "init function in script should return table, nothing returned");
+ SCLogError("init function in script should return table, nothing returned");
goto error;
}
if (lua_type(luastate, 1) != LUA_TTABLE) {
- SCLogError(SC_ERR_LUA_ERROR, "init function in script should return table, returned is not table");
+ SCLogError("init function in script should return table, returned is not table");
goto error;
}
lua_pop(luastate, 1);
if (ld->flowvars == DETECT_LUAJIT_MAX_FLOWVARS) {
- SCLogError(SC_ERR_LUA_ERROR, "too many flowvars registered");
+ SCLogError("too many flowvars registered");
goto error;
}
lua_pop(luastate, 1);
if (ld->flowints == DETECT_LUAJIT_MAX_FLOWINTS) {
- SCLogError(SC_ERR_LUA_ERROR, "too many flowints registered");
+ SCLogError("too many flowints registered");
goto error;
}
lua_pop(luastate, 1);
if (ld->bytevars == DETECT_LUAJIT_MAX_BYTEVARS) {
- SCLogError(SC_ERR_LUA_ERROR, "too many bytevars registered");
+ SCLogError("too many bytevars registered");
goto error;
}
DetectByteIndexType idx;
if (!DetectByteRetrieveSMVar(value, s, &idx)) {
- SCLogError(SC_ERR_LUA_ERROR,
- "Unknown byte_extract or byte_math var "
- "requested by lua script - %s",
+ SCLogError("Unknown byte_extract or byte_math var "
+ "requested by lua script - %s",
value);
goto error;
}
ld->buffername = SCStrdup("buffer");
if (ld->buffername == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "alloc error");
+ SCLogError("alloc error");
goto error;
}
} else if (strcmp(k, "stream") == 0 && strcmp(v, "true") == 0) {
ld->buffername = SCStrdup("stream");
if (ld->buffername == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "alloc error");
+ SCLogError("alloc error");
goto error;
}
} else if (strncmp(k, "http", 4) == 0 && strcmp(v, "true") == 0) {
if (ld->alproto != ALPROTO_UNKNOWN && ld->alproto != ALPROTO_HTTP1) {
- SCLogError(SC_ERR_LUA_ERROR, "can just inspect script against one app layer proto like HTTP at a time");
+ SCLogError(
+ "can just inspect script against one app layer proto like HTTP at a time");
goto error;
}
if (ld->flags != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "when inspecting HTTP buffers only a single buffer can be inspected");
+ SCLogError("when inspecting HTTP buffers only a single buffer can be inspected");
goto error;
}
ld->flags |= DATATYPE_HTTP_RESPONSE_HEADERS_RAW;
else {
- SCLogError(SC_ERR_LUA_ERROR, "unsupported http data type %s", k);
+ SCLogError("unsupported http data type %s", k);
goto error;
}
ld->buffername = SCStrdup(k);
if (ld->buffername == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "alloc error");
+ SCLogError("alloc error");
goto error;
}
} else if (strncmp(k, "dns", 3) == 0 && strcmp(v, "true") == 0) {
ld->flags |= DATATYPE_DNS_RESPONSE;
else {
- SCLogError(SC_ERR_LUA_ERROR, "unsupported dns data type %s", k);
+ SCLogError("unsupported dns data type %s", k);
goto error;
}
ld->buffername = SCStrdup(k);
if (ld->buffername == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "alloc error");
+ SCLogError("alloc error");
goto error;
}
} else if (strncmp(k, "tls", 3) == 0 && strcmp(v, "true") == 0) {
ld->flags |= DATATYPE_DNP3;
} else {
- SCLogError(SC_ERR_LUA_ERROR, "unsupported data type %s", k);
+ SCLogError("unsupported data type %s", k);
goto error;
}
}
if (DetectBufferGetActiveList(de_ctx, s) != -1) {
list = s->init_data->list;
} else {
- SCLogError(SC_ERR_LUA_ERROR, "Lua and sticky buffer failure");
+ SCLogError("Lua and sticky buffer failure");
goto error;
}
} else
} else if (lua->alproto == ALPROTO_DNP3) {
list = DetectBufferTypeGetByName("dnp3");
} else {
- SCLogError(SC_ERR_LUA_ERROR, "lua can't be used with protocol %s",
- AppLayerGetProtoName(lua->alproto));
+ SCLogError("lua can't be used with protocol %s", AppLayerGetProtoName(lua->alproto));
goto error;
}
if (list == -1) {
- SCLogError(SC_ERR_LUA_ERROR, "lua can't be used with protocol %s",
- AppLayerGetProtoName(lua->alproto));
+ SCLogError("lua can't be used with protocol %s", AppLayerGetProtoName(lua->alproto));
goto error;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
return NULL;
}
res = pcre2_substring_get_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
return NULL;
}
errno = 0;
mark = strtoul(ptr, &endptr, 0);
if (errno == ERANGE) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
+ SCLogError("Numeric value out of range");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
} /* If there is no numeric value in the given string then strtoull(), makes
endptr equals to ptr and return 0 as result */
else if (endptr == ptr && mark == 0) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "No numeric value");
+ SCLogError("No numeric value");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
} else if (endptr == ptr) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
+ SCLogError("Invalid numeric value");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
}
res = pcre2_substring_get_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
return NULL;
}
errno = 0;
mask = strtoul(ptr, &endptr, 0);
if (errno == ERANGE) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
+ SCLogError("Numeric value out of range");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
} /* If there is no numeric value in the given string then strtoull(), makes
endptr equals to ptr and return 0 as result */
else if (endptr == ptr && mask == 0) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "No numeric value");
+ SCLogError("No numeric value");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
}
else if (endptr == ptr) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
+ SCLogError("Invalid numeric value");
pcre2_substring_free((PCRE2_UCHAR8 *)ptr);
return NULL;
}
const char *hkey = DetectMedatataHashAdd(de_ctx, key);
if (hkey == NULL) {
- SCLogError(SC_ENOMEM, "can't create metadata key");
+ SCLogError("can't create metadata key");
continue;
}
const char *hval = DetectMedatataHashAdd(de_ctx, val);
if (hval == NULL) {
- SCLogError(SC_ENOMEM, "can't create metadata value");
+ SCLogError("can't create metadata value");
goto next;
}
return -1;
if ((modbus = rs_modbus_parse(str)) == NULL) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid modbus option");
+ SCLogError("invalid modbus option");
goto error;
}
} else if (strcmp(rawstr, "false") == 0) {
*de = false;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "invalid session_present flag definition: %s", rawstr);
+ SCLogError("invalid session_present flag definition: %s", rawstr);
goto error;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid flag definition: %s", rawstr);
+ SCLogError("invalid flag definition: %s", rawstr);
return NULL;
}
flagv++;
}
if (strlen(flagv) < 2) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "malformed flag value: %s", flagv);
+ SCLogError("malformed flag value: %s", flagv);
goto error;
} else {
int offset = 0;
}
if (strcmp(flagv+offset, "username") == 0) {
if (de->username != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->username = fs_to_set;
} else if (strcmp(flagv+offset, "password") == 0) {
if (de->password != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->password = fs_to_set;
} else if (strcmp(flagv+offset, "will") == 0) {
if (de->will != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->will = fs_to_set;
} else if (strcmp(flagv+offset, "will_retain") == 0) {
if (de->will_retain != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->will_retain = fs_to_set;
} else if (strcmp(flagv+offset, "clean_session") == 0) {
if (de->clean_session != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->clean_session = fs_to_set;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "invalid flag definition: %s", flagv);
+ SCLogError("invalid flag definition: %s", flagv);
goto error;
}
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid flag definition: %s", rawstr);
+ SCLogError("invalid flag definition: %s", rawstr);
return NULL;
}
}
if (strlen(flagv) < 2) {
/* flags have a minimum length */
- SCLogError(SC_ERR_UNKNOWN_VALUE, "malformed flag value: %s", flagv);
+ SCLogError("malformed flag value: %s", flagv);
goto error;
} else {
int offset = 0;
}
if (strcmp(flagv+offset, "dup") == 0) {
if (de->dup != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->dup = fs_to_set;
} else if (strcmp(flagv+offset, "retain") == 0) {
if (de->retain != MQTT_DONT_CARE) {
- SCLogError(SC_EINVAL, "duplicate flag definition: %s", flagv);
+ SCLogError("duplicate flag definition: %s", flagv);
goto error;
}
de->retain = fs_to_set;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "invalid flag definition: %s", flagv);
+ SCLogError("invalid flag definition: %s", flagv);
goto error;
}
}
ret = StringParseU8RangeCheck(&val, 10, 0, rawstr, 0, 2);
if (ret < 0) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "invalid MQTT QOS level: %s", rawstr);
+ SCLogError("invalid MQTT QOS level: %s", rawstr);
return NULL;
}
ret = StringParseUint8(&val, 10, 0, rawstr);
if (ret < 0) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "invalid MQTT reason code: %s", rawstr);
+ SCLogError("invalid MQTT reason code: %s", rawstr);
return NULL;
}
ret = rs_mqtt_cstr_message_code(rawstr);
// negative value denotes invalid input
if(ret < 0) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown mqtt.type value %s", rawstr);
+ SCLogError("unknown mqtt.type value %s", rawstr);
goto error;
}
}
if (s->msg != NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "duplicated 'msg' keyword detected");
+ SCLogError("duplicated 'msg' keyword detected");
goto error;
}
s->msg = SCStrdup(str);
dd = DetectNfsProcedureParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
DetectU32Data *dd = DetectNfsVersionParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
return -1;
}
static int DetectNoalertSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr)
{
if (nullstr != NULL) {
- SCLogError(SC_EINVAL, "nocase has no value");
+ SCLogError("nocase has no value");
return -1;
}
int ret = -1;
if (nullstr != NULL) {
- SCLogError(SC_EINVAL, "nocase has value");
+ SCLogError("nocase has value");
goto end;
}
/* retrive the sm to apply the nocase against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_NOCASE_MISSING_PATTERN, "nocase needs "
+ SCLogError("nocase needs "
"preceding content option");
goto end;
}
DetectContentData *cd = (DetectContentData *)pm->ctx;;
if (cd->flags & DETECT_CONTENT_NOCASE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple nocase modifiers with the same content");
+ SCLogError("can't use multiple nocase modifiers with the same content");
goto end;
}
/* retrive the sm to apply the offset against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_OFFSET_MISSING_CONTENT, "offset needs "
+ SCLogError("offset needs "
"preceding content option.");
goto end;
}
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_STARTS_WITH) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use offset with startswith.");
+ SCLogError("can't use offset with startswith.");
goto end;
}
if (cd->flags & DETECT_CONTENT_OFFSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple offsets for the same content.");
+ SCLogError("can't use multiple offsets for the same content.");
goto end;
}
if ((cd->flags & DETECT_CONTENT_WITHIN) || (cd->flags & DETECT_CONTENT_DISTANCE)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a relative "
+ SCLogError("can't use a relative "
"keyword like within/distance with a absolute "
"relative keyword like depth/offset for the same "
- "content." );
+ "content.");
goto end;
}
if (cd->flags & DETECT_CONTENT_NEGATED && cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"negated keyword set along with 'fast_pattern'.");
goto end;
}
if (cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"keyword set along with 'fast_pattern:only;'.");
goto end;
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(str, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unknown byte_ keyword var "
- "seen in offset - %s.", str);
+ SCLogError("unknown byte_ keyword var "
+ "seen in offset - %s.",
+ str);
goto end;
}
cd->offset = index;
} else {
if (StringParseUint16(&cd->offset, 0, 0, str) < 0)
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid value for offset: %s.", str);
+ SCLogError("invalid value for offset: %s.", str);
goto end;
}
if (cd->depth != 0) {
int ret = -1;
if (arg != NULL && strcmp(arg, "") != 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "%s shouldn't be supplied "
- "with an argument", sigmatch_table[sm_type].name);
+ SCLogError("%s shouldn't be supplied "
+ "with an argument",
+ sigmatch_table[sm_type].name);
goto end;
}
if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "\"%s\" keyword seen "
+ SCLogError("\"%s\" keyword seen "
"with a sticky buffer still set. Reset sticky buffer "
"with pkt_data before using the modifier.",
- sigmatch_table[sm_type].name);
+ sigmatch_table[sm_type].name);
goto end;
}
if (s->alproto != ALPROTO_UNKNOWN && !AppProtoEquals(s->alproto, alproto)) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting "
+ SCLogError("rule contains conflicting "
"alprotos set");
goto end;
}
sm = DetectGetLastSMByListId(s,
DETECT_SM_LIST_PMATCH, DETECT_CONTENT, -1);
if (sm == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "\"%s\" keyword "
+ SCLogError("\"%s\" keyword "
"found inside the rule without a content context. "
"Please use a \"content\" keyword before using the "
- "\"%s\" keyword", sigmatch_table[sm_type].name,
- sigmatch_table[sm_type].name);
+ "\"%s\" keyword",
+ sigmatch_table[sm_type].name, sigmatch_table[sm_type].name);
goto end;
}
DetectContentData *cd = (DetectContentData *)sm->ctx;
if (cd->flags & DETECT_CONTENT_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s rule can not "
+ SCLogError("%s rule can not "
"be used with the rawbytes rule keyword",
- sigmatch_table[sm_type].name);
+ sigmatch_table[sm_type].name);
goto end;
}
if (cd->flags & DETECT_CONTENT_REPLACE) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s rule can not "
+ SCLogError("%s rule can not "
"be used with the replace rule keyword",
- sigmatch_table[sm_type].name);
+ sigmatch_table[sm_type].name);
goto end;
}
if (cd->flags & (DETECT_CONTENT_WITHIN | DETECT_CONTENT_DISTANCE)) {
char *copy = SCStrdup(str);
if (copy == NULL)
- FatalError(SC_ENOMEM, "could not duplicate opt string");
+ FatalError("could not duplicate opt string");
char *xsaveptr = NULL;
char *key = strtok_r(copy, ",", &xsaveptr);
if (st != NULL) {
st->flags |= SIGMATCH_STRICT_PARSING;
} else {
- SCLogWarning(SC_ERR_CMD_LINE, "'strict' command line "
- "argument '%s' not found", key);
+ SCLogWarning("'strict' command line "
+ "argument '%s' not found",
+ key);
}
key = strtok_r(NULL, ",", &xsaveptr);
}
}
}
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unable to find the sm in any of the "
+ SCLogError("Unable to find the sm in any of the "
"sm lists");
return -1;
}
for (;;) {
optend = strchr(optend, ';');
if (optend == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "no terminating \";\" found");
+ SCLogError("no terminating \";\" found");
goto error;
}
else if (optend > optstr && *(optend -1 ) == '\\') {
/* Call option parsing */
st = SigTableGet(optname);
if (st == NULL || st->Setup == NULL) {
- SCLogError(SC_ERR_RULE_KEYWORD_UNKNOWN, "unknown rule keyword '%s'.", optname);
+ SCLogError("unknown rule keyword '%s'.", optname);
goto error;
}
if (!(st->flags & (SIGMATCH_NOOPT|SIGMATCH_OPTIONAL_OPT))) {
if (optvalue == NULL || strlen(optvalue) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
+ SCLogError(
"invalid formatting or malformed option to %s keyword: '%s'", optname, optstr);
goto error;
}
} else if (st->flags & SIGMATCH_NOOPT) {
if (optvalue && strlen(optvalue)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unexpected option to %s keyword: '%s'", optname,
- optstr);
+ SCLogError("unexpected option to %s keyword: '%s'", optname, optstr);
goto error;
}
}
if (st->flags & SIGMATCH_INFO_DEPRECATED) {
#define URL "https://suricata.io/our-story/deprecation-policy/"
if (st->alternative == 0)
- SCLogWarning(SC_WARN_DEPRECATED, "keyword '%s' is deprecated "
- "and will be removed soon. See %s", st->name, URL);
+ SCLogWarning("keyword '%s' is deprecated "
+ "and will be removed soon. See %s",
+ st->name, URL);
else
- SCLogWarning(SC_WARN_DEPRECATED, "keyword '%s' is deprecated "
- "and will be removed soon. Use '%s' instead. "
- "See %s", st->name, sigmatch_table[st->alternative].name, URL);
+ SCLogWarning("keyword '%s' is deprecated "
+ "and will be removed soon. Use '%s' instead. "
+ "See %s",
+ st->name, sigmatch_table[st->alternative].name, URL);
#undef URL
}
ovlen--;
}
if (ovlen == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid formatting or malformed option to %s keyword: \'%s\'",
- optname, optstr);
+ SCLogError("invalid formatting or malformed option to %s keyword: \'%s\'", optname,
+ optstr);
goto error;
}
ovlen--;
}
if (ovlen == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid formatting or malformed option to %s keyword: \'%s\'",
- optname, optstr);
+ SCLogError("invalid formatting or malformed option to %s keyword: \'%s\'", optname,
+ optstr);
goto error;
}
/* if quoting is mandatory, enforce it */
if (st->flags & SIGMATCH_QUOTES_MANDATORY && ovlen && *ptr != '"') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid formatting to %s keyword: "
- "value must be double quoted \'%s\'", optname, optstr);
+ SCLogError("invalid formatting to %s keyword: "
+ "value must be double quoted \'%s\'",
+ optname, optstr);
goto error;
}
}
}
if (ovlen && ptr[ovlen - 1] != '"') {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "bad option value formatting (possible missing semicolon) "
- "for keyword %s: \'%s\'", optname, optvalue);
+ SCLogError("bad option value formatting (possible missing semicolon) "
+ "for keyword %s: \'%s\'",
+ optname, optvalue);
goto error;
}
if (ovlen > 1) {
ovlen--;
}
if (ovlen == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "bad input "
- "for keyword %s: \'%s\'", optname, optvalue);
+ SCLogError("bad input "
+ "for keyword %s: \'%s\'",
+ optname, optvalue);
goto error;
}
} else {
if (*ptr == '"') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "quotes on %s keyword that doesn't support them: \'%s\'",
- optname, optstr);
+ SCLogError(
+ "quotes on %s keyword that doesn't support them: \'%s\'", optname, optstr);
goto error;
}
}
AppLayerProtoDetectSupportedIpprotos(s->alproto, s->proto.proto);
}
else {
- SCLogError(SC_ERR_UNKNOWN_PROTOCOL, "protocol \"%s\" cannot be used "
+ SCLogError("protocol \"%s\" cannot be used "
"in a signature. Either detection for this protocol "
"is not yet supported OR detection has been disabled for "
"protocol through the yaml option "
- "app-layer.protocols.%s.detection-enabled", protostr,
- protostr);
+ "app-layer.protocols.%s.detection-enabled",
+ protostr, protostr);
SCReturnInt(-1);
}
}
#ifdef HAVE_LIBNET11
#if defined HAVE_LIBCAP_NG && !defined HAVE_LIBNET_CAPABILITIES
if (sc_set_caps == TRUE) {
- SCLogError(SC_ERR_LIBNET11_INCOMPATIBLE_WITH_LIBCAP_NG, "Libnet 1.1 is "
- "incompatible with POSIX based capabilities with privs dropping. "
- "For rejects to work, run as root/super user.");
+ SCLogError("Libnet 1.1 is "
+ "incompatible with POSIX based capabilities with privs dropping. "
+ "For rejects to work, run as root/super user.");
return 0;
}
#endif
#else /* no libnet 1.1 */
- SCLogError(SC_ERR_LIBNET_REQUIRED_FOR_ACTION, "Libnet 1.1.x is "
- "required for action \"%s\" but is not compiled into Suricata",
+ SCLogError("Libnet 1.1.x is "
+ "required for action \"%s\" but is not compiled into Suricata",
action);
return 0;
#endif
s->action = ACTION_CONFIG;
s->flags |= SIG_FLAG_NOALERT;
} else {
- SCLogError(SC_ERR_INVALID_ACTION,"An invalid action \"%s\" was given",action);
+ SCLogError("An invalid action \"%s\" was given", action);
return -1;
}
return 0;
/* Options. */
if (index == NULL) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "no rule options.");
+ SCLogError("no rule options.");
goto error;
}
while (isspace(*index) || *index == '(') {
if (strcmp(parser->direction, "<>") == 0) {
s->init_data->init_flags |= SIG_FLAG_INIT_BIDIREC;
} else if (strcmp(parser->direction, "->") != 0) {
- SCLogError(SC_ERR_INVALID_DIRECTION,
- "\"%s\" is not a valid direction modifier, "
- "\"->\" and \"<>\" are supported.", parser->direction);
+ SCLogError("\"%s\" is not a valid direction modifier, "
+ "\"->\" and \"<>\" are supported.",
+ parser->direction);
goto error;
}
SCEnter();
if (!rs_check_utf8(sigstr)) {
- SCLogError(SC_ERR_RULE_INVALID_UTF8, "rule is not valid UTF-8");
+ SCLogError("rule is not valid UTF-8");
SCReturnInt(-1);
}
SCReturnInt(-1);
}
if (!s->init_data->list_set) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "transforms must directly follow stickybuffers");
+ SCLogError("transforms must directly follow stickybuffers");
SCReturnInt(-1);
}
if (s->init_data->transforms.cnt >= DETECT_TRANSFORMS_MAX) {
{
if (alproto == ALPROTO_UNKNOWN ||
alproto >= ALPROTO_FAILED) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid alproto %u", alproto);
+ SCLogError("invalid alproto %u", alproto);
return -1;
}
/* since AppProtoEquals is quite permissive wrt dcerpc and smb, make sure
* we refuse `alert dcerpc ... smb.share; content...` explicitly. */
if (alproto == ALPROTO_SMB && s->alproto == ALPROTO_DCERPC) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "can't set rule app proto to %s: already set to %s", AppProtoToString(alproto),
+ SCLogError("can't set rule app proto to %s: already set to %s", AppProtoToString(alproto),
AppProtoToString(s->alproto));
return -1;
}
// in this case, we must keep the most restrictive HTTP1
alproto = s->alproto;
} else {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "can't set rule app proto to %s: already set to %s", AppProtoToString(alproto),
- AppProtoToString(s->alproto));
+ SCLogError("can't set rule app proto to %s: already set to %s",
+ AppProtoToString(alproto), AppProtoToString(s->alproto));
return -1;
}
}
if (AppLayerProtoDetectGetProtoName(alproto) == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "disabled alproto %s, rule can never match",
- AppProtoToString(alproto));
+ SCLogError("disabled alproto %s, rule can never match", AppProtoToString(alproto));
return -1;
}
s->alproto = alproto;
SigMatchData *smd = (SigMatchData *)SCCalloc(len, sizeof(SigMatchData));
if (smd == NULL) {
- FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
+ FatalError("initializing the detection engine failed");
}
SigMatchData *out = smd;
if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
if (s->init_data->list >= (int)s->init_data->smlists_array_size ||
s->init_data->smlists[s->init_data->list] == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "rule %u setup buffer %s but didn't add matches to it", s->id,
+ SCLogError("rule %u setup buffer %s but didn't add matches to it", s->id,
DetectEngineBufferTypeGetNameById(de_ctx, s->init_data->list));
SCReturnInt(0);
}
bufdir[x].tc);
}
if (ts_excl && tc_excl) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "rule %u mixes keywords with conflicting directions", s->id);
+ SCLogError("rule %u mixes keywords with conflicting directions", s->id);
SCReturnInt(0);
} else if (ts_excl) {
SCLogDebug("%u: implied rule direction is toserver", s->id);
if (DetectFlowSetupImplicit(s, SIG_FLAG_TOSERVER) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "rule %u mixes keywords with conflicting directions", s->id);
+ SCLogError("rule %u mixes keywords with conflicting directions", s->id);
SCReturnInt(0);
}
} else if (tc_excl) {
SCLogDebug("%u: implied rule direction is toclient", s->id);
if (DetectFlowSetupImplicit(s, SIG_FLAG_TOCLIENT) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "rule %u mixes keywords with conflicting directions", s->id);
+ SCLogError("rule %u mixes keywords with conflicting directions", s->id);
SCReturnInt(0);
}
} else if (dir_amb) {
if ((s->flags & SIG_FLAG_REQUIRE_PACKET) &&
(s->flags & SIG_FLAG_REQUIRE_STREAM)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't mix packet keywords with "
+ SCLogError("can't mix packet keywords with "
"tcp-stream or flow:only_stream. Invalidating signature.");
SCReturnInt(0);
}
}
#endif
if ((sig_flags & (SIG_FLAG_TOCLIENT | SIG_FLAG_TOSERVER)) == (SIG_FLAG_TOCLIENT | SIG_FLAG_TOSERVER)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,"You seem to have mixed keywords "
+ SCLogError("You seem to have mixed keywords "
"that require inspection in both directions. Atm we only "
"support keywords in one direction within a rule.");
SCReturnInt(0);
has_pkt |= b->packet;
}
if (has_pmatch && has_frame) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't mix pure content and frame inspection");
+ SCLogError("can't mix pure content and frame inspection");
SCReturnInt(0);
}
if (has_app && has_frame) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't mix app-layer buffer and frame inspection");
+ SCLogError("can't mix app-layer buffer and frame inspection");
SCReturnInt(0);
}
if (has_pkt && has_frame) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't mix pkt buffer and frame inspection");
+ SCLogError("can't mix pkt buffer and frame inspection");
SCReturnInt(0);
}
continue;
if (!(DetectEngineBufferTypeSupportsPacketGetById(de_ctx, i))) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Signature combines packet "
- "specific matches (like dsize, flags, ttl) with stream / "
- "state matching by matching on app layer proto (like using "
- "http_* keywords).");
+ SCLogError("Signature combines packet "
+ "specific matches (like dsize, flags, ttl) with stream / "
+ "state matching by matching on app layer proto (like using "
+ "http_* keywords).");
SCReturnInt(0);
}
}
if (list != DETECT_SM_LIST_BASE64_DATA &&
s->init_data->smlists[list] != NULL) {
if (s->init_data->smlists[list]->idx > idx) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Rule buffer "
- "cannot be reset after base64_data.");
+ SCLogError("Rule buffer "
+ "cannot be reset after base64_data.");
SCReturnInt(0);
}
}
if (s->init_data->init_flags & SIG_FLAG_INIT_JA3 && s->alproto != ALPROTO_UNKNOWN &&
s->alproto != ALPROTO_TLS && s->alproto != ALPROTO_QUIC) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Cannot have ja3 with protocol %s.",
- AppProtoToString(s->alproto));
+ SCLogError("Cannot have ja3 with protocol %s.", AppProtoToString(s->alproto));
SCReturnInt(0);
}
if ((s->flags & SIG_FLAG_FILESTORE) || s->file_flags != 0 ||
if (s->alproto != ALPROTO_UNKNOWN &&
!AppLayerParserSupportsFiles(IPPROTO_TCP, s->alproto))
{
- SCLogError(SC_ERR_NO_FILES_FOR_PROTOCOL, "protocol %s doesn't "
- "support file matching", AppProtoToString(s->alproto));
+ SCLogError("protocol %s doesn't "
+ "support file matching",
+ AppProtoToString(s->alproto));
SCReturnInt(0);
}
if (s->alproto == ALPROTO_HTTP2 && (s->file_flags & FILE_SIG_NEED_FILENAME)) {
- SCLogError(SC_ERR_NO_FILES_FOR_PROTOCOL,
- "protocol HTTP2 doesn't support file name matching");
+ SCLogError("protocol HTTP2 doesn't support file name matching");
SCReturnInt(0);
}
}
}
if (s->id == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Signature missing required value \"sid\".");
+ SCLogError("Signature missing required value \"sid\".");
SCReturnInt(0);
}
SCReturnInt(1);
/* a duplicate signature that should be chucked out. Check the previously
* called function details to understand the different return values */
if (dup_sig == 1) {
- SCLogError(SC_ERR_DUPLICATE_SIG, "Duplicate signature \"%s\"", sigstr);
+ SCLogError("Duplicate signature \"%s\"", sigstr);
goto error;
} else if (dup_sig == 2) {
- SCLogWarning(SC_ERR_DUPLICATE_SIG, "Signature with newer revision,"
- " so the older sig replaced by this new signature \"%s\"",
+ SCLogWarning("Signature with newer revision,"
+ " so the older sig replaced by this new signature \"%s\"",
sigstr);
}
{
DetectParseRegex *r = SCCalloc(1, sizeof(*r));
if (r == NULL) {
- FatalError(SC_ENOMEM, "failed to alloc memory for pcre free list");
+ FatalError("failed to alloc memory for pcre free list");
}
r->regex = detect_parse->regex;
r->match = detect_parse->match;
if (detect_parse->regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre compile of \"%s\" failed at "
+ "offset %d: %s",
parse_str, en, errbuffer);
return false;
}
if (detect_parse->regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
parse_str, (int)eo, errbuffer);
SCFree(detect_parse);
return NULL;
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
{
if (!DetectSetupParseRegexesOpts(parse_str, detect_parse, 0)) {
- FatalError(SC_ERR_PCRE_COMPILE, "pcre compile and study failed");
+ FatalError("pcre compile and study failed");
}
}
parse_regex = DetectSetupPCRE2(PARSE_REGEX, 0);
if (parse_regex == NULL) {
- FatalError(SC_ERR_PCRE_COMPILE, "pcre2 compile failed for parse_regex");
+ FatalError("pcre2 compile failed for parse_regex");
}
/* setup the capture regex, as it needs PCRE2_UNGREEDY we do it manually */
/* pkt_http_ua should be pkt, http_ua, for this reason the UNGREEDY */
parse_capture_regex = DetectSetupPCRE2(PARSE_CAPTURE_REGEX, PCRE2_UNGREEDY);
if (parse_capture_regex == NULL) {
- FatalError(SC_ERR_PCRE_COMPILE, "pcre2 compile failed for parse_capture_regex");
+ FatalError("pcre2 compile failed for parse_capture_regex");
}
#ifdef PCRE2_HAVE_JIT
static int DetectPcreSetList(int list, int set)
{
if (list != DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "only one pcre option to specify a buffer type is allowed");
+ SCLogError("only one pcre option to specify a buffer type is allowed");
return -1;
}
return set;
ret = pcre2_match(
parse_regex->regex, (PCRE2_SPTR8)regexstr, slen, 0, 0, parse_regex->match, NULL);
if (ret <= 0) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre parse error: %s", regexstr);
+ SCLogError("pcre parse error: %s", regexstr);
goto error;
}
res = pcre2_substring_copy_bynumber(parse_regex->match, 1, (PCRE2_UCHAR8 *)re, &slen);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return NULL;
}
res = pcre2_substring_copy_bynumber(
parse_regex->match, 2, (PCRE2_UCHAR8 *)op_str, ©len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return NULL;
}
op = op_str;
case 'B': /* snort's option */
if (*sm_list != DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'B' inconsistent with chosen buffer");
+ SCLogError("regex modifier 'B' inconsistent with chosen buffer");
goto error;
}
pd->flags |= DETECT_PCRE_RAWBYTES;
case 'U': { /* snort's option */
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'U' inconsistent with 'B'");
+ SCLogError("regex modifier 'U' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_uri");
}
case 'V': {
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'V' inconsistent with 'B'");
+ SCLogError("regex modifier 'V' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_user_agent");
}
case 'W': {
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'W' inconsistent with 'B'");
+ SCLogError("regex modifier 'W' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_host");
}
case 'Z': {
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'Z' inconsistent with 'B'");
+ SCLogError("regex modifier 'Z' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_raw_host");
}
case 'H': { /* snort's option */
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'H' inconsistent with 'B'");
+ SCLogError("regex modifier 'H' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_header");
break;
} case 'I': { /* snort's option */
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'I' inconsistent with 'B'");
+ SCLogError("regex modifier 'I' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_raw_uri");
}
case 'M': { /* snort's option */
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'M' inconsistent with 'B'");
+ SCLogError("regex modifier 'M' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_method");
}
case 'C': { /* snort's option */
if (pd->flags & DETECT_PCRE_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "regex modifier 'C' inconsistent with 'B'");
+ SCLogError("regex modifier 'C' inconsistent with 'B'");
goto error;
}
int list = DetectBufferTypeGetByName("http_cookie");
break;
}
default:
- SCLogError(SC_ERR_UNKNOWN_REGEX_MOD, "unknown regex modifier '%c'", *op);
+ SCLogError("unknown regex modifier '%c'", *op);
goto error;
}
op++;
/* host header */
if (check_host_header) {
if (pd->flags & DETECT_PCRE_CASELESS) {
- SCLogWarning(SC_ERR_INVALID_SIGNATURE, "http host pcre(\"W\") "
+ SCLogWarning("http host pcre(\"W\") "
"specified along with \"i(caseless)\" modifier. "
"Since the hostname buffer we match against "
"is actually lowercase, having a "
"nocase is redundant.");
}
else if (DetectPcreHasUpperCase(re)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "pcre host(\"W\") "
- "specified has an uppercase char. "
- "Since the hostname buffer we match against "
- "is actually lowercase, please specify an "
- "all lowercase based pcre.");
+ SCLogError("pcre host(\"W\") "
+ "specified has an uppercase char. "
+ "Since the hostname buffer we match against "
+ "is actually lowercase, please specify an "
+ "all lowercase based pcre.");
goto error;
}
}
if (pd->parse_regex.regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
regexstr, (int)eo2, errbuffer);
goto error;
}
pd->parse_regex.context = pcre2_match_context_create(NULL);
if (pd->parse_regex.context == NULL) {
- SCLogError(SC_ERR_PCRE_COMPILE, "pcre2 could not create match context");
+ SCLogError("pcre2 could not create match context");
goto error;
}
pd->parse_regex.match = pcre2_match_data_create_from_pattern(pd->parse_regex.regex, NULL);
char *ptr = NULL;
while ((name_array[name_idx] = strtok_r(name_idx == 0 ? capture_names : NULL, " ,", &ptr))){
if (name_idx > (capture_cnt - 1)) {
- SCLogError(SC_ERR_VAR_LIMIT, "more pkt/flow "
- "var capture names than capturing substrings");
+ SCLogError("more pkt/flow "
+ "var capture names than capturing substrings");
return -1;
}
SCLogDebug("name '%s'", name_array[name_idx]);
pd->idx++;
} else {
- SCLogError(SC_ERR_VAR_LIMIT, " pkt/flow "
- "var capture names must start with 'pkt:' or 'flow:'");
+ SCLogError(" pkt/flow "
+ "var capture names must start with 'pkt:' or 'flow:'");
return -1;
}
res = pcre2_substring_copy_bynumber(
parse_capture_regex->match, 1, (PCRE2_UCHAR8 *)type_str, ©len);
if (res != 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
cap_buffer_len = strlen(regexstr) + 1;
res = pcre2_substring_copy_bynumber(
parse_capture_regex->match, 2, (PCRE2_UCHAR8 *)capture_str, &cap_buffer_len);
if (res != 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strlen(capture_str) == 0 || strlen(type_str) == 0) {
SCLogDebug("capture \'%s\'", capture_str);
if (pd->idx >= DETECT_PCRE_CAPTURE_MAX) {
- SCLogError(SC_ERR_VAR_LIMIT, "rule can have maximally %d pkt/flow "
- "var captures", DETECT_PCRE_CAPTURE_MAX);
+ SCLogError("rule can have maximally %d pkt/flow "
+ "var captures",
+ DETECT_PCRE_CAPTURE_MAX);
return -1;
}
int sm_list = -1;
if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
if (parsed_sm_list != DETECT_SM_LIST_NOTSET && parsed_sm_list != s->init_data->list) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Expression seen with a sticky buffer still set; either (1) reset sticky "
- "buffer with pkt_data or (2) use a sticky buffer providing \"%s\".",
+ SCLogError("Expression seen with a sticky buffer still set; either (1) reset sticky "
+ "buffer with pkt_data or (2) use a sticky buffer providing \"%s\".",
DetectEngineBufferTypeGetDescriptionById(de_ctx, parsed_sm_list));
goto error;
}
SigMatch *prev_pm = DetectGetLastSMByListPtr(s, sm->prev,
DETECT_CONTENT, DETECT_PCRE, -1);
if (s->init_data->list == DETECT_SM_LIST_NOTSET && prev_pm == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "pcre with /R (relative) needs "
- "preceding match in the same buffer");
+ SCLogError("pcre with /R (relative) needs "
+ "preceding match in the same buffer");
goto error_nofree;
/* null is allowed when we use a sticky buffer */
} else if (prev_pm == NULL) {
{
SCEnter();
if (s->init_data->transforms.cnt) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "previous transforms not consumed before 'pkt_data'");
+ SCLogError("previous transforms not consumed before 'pkt_data'");
SCReturnInt(-1);
}
s->init_data->list = DETECT_SM_LIST_NOTSET;
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret != 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "\"%s\" is not a valid setting for pktvar.", rawstr);
+ SCLogError("\"%s\" is not a valid setting for pktvar.", rawstr);
return -1;
}
const char *str_ptr;
res = pcre2_substring_get_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
return -1;
}
varname = (char *)str_ptr;
res = pcre2_substring_get_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
pcre2_substring_free((PCRE2_UCHAR8 *)varname);
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
return -1;
}
varcontent = (char *)str_ptr;
SCEnter();
if (nullstr != NULL) {
- SCLogError(SC_EINVAL, "prefilter has value");
+ SCLogError("prefilter has value");
SCReturnInt(-1);
}
if (s->flags & SIG_FLAG_PREFILTER) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "prefilter already set");
+ SCLogError("prefilter already set");
SCReturnInt(-1);
}
SigMatch *sm = DetectGetLastSM(s);
if (sm == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "prefilter needs preceding match");
+ SCLogError("prefilter needs preceding match");
SCReturnInt(-1);
}
(cd->flags & DETECT_CONTENT_OFFSET) ||
(cd->flags & DETECT_CONTENT_DEPTH)))
{
- SCLogError(SC_ERR_INVALID_SIGNATURE, "prefilter; cannot be "
- "used with negated content, along with relative modifiers");
+ SCLogError("prefilter; cannot be "
+ "used with negated content, along with relative modifiers");
SCReturnInt(-1);
}
cd->flags |= DETECT_CONTENT_FAST_PATTERN;
} else {
if (sigmatch_table[sm->type].SupportsPrefilter == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "prefilter is not supported for %s",
- sigmatch_table[sm->type].name);
+ SCLogError("prefilter is not supported for %s", sigmatch_table[sm->type].name);
SCReturnInt(-1);
}
s->flags |= SIG_FLAG_PREFILTER;
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_MATCH, "Invalid Priority in Signature "
- "- %s", rawstr);
+ SCLogError("Invalid Priority in Signature "
+ "- %s",
+ rawstr);
return -1;
}
pcre2len = sizeof(copy_str);
ret = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
char *endptr = NULL;
prio = strtol(copy_str, &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Saw an invalid character as arg "
+ SCLogError("Saw an invalid character as arg "
"to priority keyword");
return -1;
}
if (s->init_data->init_flags & SIG_FLAG_INIT_PRIO_EXPLICT) {
- SCLogWarning(SC_ERR_CONFLICTING_RULE_KEYWORDS, "duplicate priority "
- "keyword. Using highest priority in the rule");
+ SCLogWarning("duplicate priority "
+ "keyword. Using highest priority in the rule");
s->prio = MIN(s->prio, prio);
} else {
s->prio = prio;
*sigerror = BUFFER_NAME " should not be used together with "
"nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
if (cd->content_len != 32) {
*sigerror = "Invalid length of the specified" BUFFER_NAME " (should "
"be 32 characters long). This rule will therefore "
"never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return FALSE;
}
for (size_t i = 0; i < cd->content_len; ++i) {
*sigerror = "Invalid " BUFFER_NAME
" string (should be string of hexadecimal characters)."
"This rule will therefore never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return FALSE;
}
}
SCEnter();
if (nullstr != NULL) {
- SCLogError(SC_EINVAL, "rawbytes has no value");
+ SCLogError("rawbytes has no value");
SCReturnInt(-1);
}
if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
- SCLogError(SC_ERR_RAWBYTES_BUFFER,
- "\"rawbytes\" cannot be combined "
- "with the \"%s\" sticky buffer",
+ SCLogError("\"rawbytes\" cannot be combined "
+ "with the \"%s\" sticky buffer",
DetectEngineBufferTypeGetNameById(de_ctx, s->init_data->list));
SCReturnInt(-1);
}
SigMatch *pm = DetectGetLastSMByListId(s, DETECT_SM_LIST_PMATCH, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(
- SC_ERR_RAWBYTES_MISSING_CONTENT, "\"rawbytes\" needs a preceding content option");
+ SCLogError("\"rawbytes\" needs a preceding content option");
SCReturnInt(-1);
}
case DETECT_CONTENT: {
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_RAWBYTES) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "can't use multiple rawbytes modifiers for the same content. ");
+ SCLogError("can't use multiple rawbytes modifiers for the same content. ");
SCReturnInt(-1);
}
cd->flags |= DETECT_CONTENT_RAWBYTES;
break;
}
default:
- SCLogError(SC_ERR_RAWBYTES_MISSING_CONTENT,
- "\"rawbytes\" needs a preceding content option");
+ SCLogError("\"rawbytes\" needs a preceding content option");
SCReturnInt(-1);
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 2) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Unable to parse \"reference\" "
- "keyword argument - \"%s\". Invalid argument.", rawstr);
+ SCLogError("Unable to parse \"reference\" "
+ "keyword argument - \"%s\". Invalid argument.",
+ rawstr);
return NULL;
}
pcre2len = sizeof(key);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)key, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
pcre2len = sizeof(content);
res = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)content, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ref->key = lookup_ref_conf->url;
} else {
if (SigMatchStrictEnabled(DETECT_REFERENCE)) {
- SCLogError(SC_ERR_REFERENCE_UNKNOWN,
- "unknown reference key \"%s\"", key);
+ SCLogError("unknown reference key \"%s\"", key);
goto error;
}
- SCLogWarning(SC_ERR_REFERENCE_UNKNOWN,
- "unknown reference key \"%s\"", key);
+ SCLogWarning("unknown reference key \"%s\"", key);
char str[2048];
snprintf(str, sizeof(str), "config reference: %s undefined\n", key);
/* make a copy so we can free pcre's substring */
ref->reference = SCStrdup(content);
if (ref->reference == NULL) {
- SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
+ SCLogError("strdup failed: %s", strerror(errno));
goto error;
}
uint16_t len = 0;
if (s->init_data->negated) {
- SCLogError(SC_EINVAL, "Can't negate replacement string: %s", replacestr);
+ SCLogError("Can't negate replacement string: %s", replacestr);
return -1;
}
case RUNMODE_IPFW:
break;
default:
- SCLogWarning(SC_ERR_RUNMODE,
- "Can't use 'replace' keyword in non IPS mode: %s",
- s->sig_str);
+ SCLogWarning("Can't use 'replace' keyword in non IPS mode: %s", s->sig_str);
/* this is a success, having the alert is interesting */
return 0;
}
const SigMatch *pm = DetectGetLastSMByListId(s, DETECT_SM_LIST_PMATCH,
DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_WITHIN_MISSING_CONTENT, "replace needs"
- "preceding content option for raw sig");
+ SCLogError("replace needs"
+ "preceding content option for raw sig");
SCFree(content);
return -1;
}
/* we can remove this switch now with the unified structure */
DetectContentData *ud = (DetectContentData *)pm->ctx;
if (ud == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid argument");
+ SCLogError("invalid argument");
SCFree(content);
return -1;
}
if (ud->flags & DETECT_CONTENT_NEGATED) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
- "negated keyword set along with a replacement");
+ SCLogError("can't have a relative "
+ "negated keyword set along with a replacement");
goto error;
}
if (ud->content_len != len) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a content "
- "length different from replace length");
+ SCLogError("can't have a content "
+ "length different from replace length");
goto error;
}
char *endptr = NULL;
rev = strtoul(rawstr, &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid character as arg "
+ SCLogError("invalid character as arg "
"to rev keyword");
goto error;
}
if (rev >= UINT_MAX) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "rev value to high, max %u", UINT_MAX);
+ SCLogError("rev value to high, max %u", UINT_MAX);
goto error;
}
if (rev == 0) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "rev value 0 is invalid");
+ SCLogError("rev value 0 is invalid");
goto error;
}
if (s->rev > 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "duplicated 'rev' keyword detected");
+ SCLogError("duplicated 'rev' keyword detected");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
}
if(found == 0) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "unknown secresult value %s", rawstr);
+ SCLogError("unknown secresult value %s", rawstr);
goto error;
}
DetectU32Data *dd = DetectRfbSectypeParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
ret = DetectParsePcreExec(&parse_regex, rpcstr, 0, 0);
if (ret < 1 || ret > 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 ", string %s", ret, rpcstr);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, rpcstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[0] = (char *)str_ptr;
res = pcre2_substring_get_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[1] = (char *)str_ptr;
res = pcre2_substring_get_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
args[2] = (char *)str_ptr;
switch (i) {
case 0:
if (StringParseUint32(&rd->program, 10, strlen(args[i]), args[i]) <= 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc program:\"%s\"", args[i]);
+ SCLogError("Invalid size specified for the rpc program:\"%s\"", args[i]);
goto error;
}
rd->flags |= DETECT_RPC_CHECK_PROGRAM;
case 1:
if (args[i][0] != '*') {
if (StringParseUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc version:\"%s\"", args[i]);
+ SCLogError(
+ "Invalid size specified for the rpc version:\"%s\"", args[i]);
goto error;
}
rd->flags |= DETECT_RPC_CHECK_VERSION;
case 2:
if (args[i][0] != '*') {
if (StringParseUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
+ SCLogError(
+ "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
goto error;
}
rd->flags |= DETECT_RPC_CHECK_PROCEDURE;
break;
}
} else {
- SCLogError(SC_EINVAL, "invalid rpc option %s", rpcstr);
+ SCLogError("invalid rpc option %s", rpcstr);
goto error;
}
}
char *endptr = NULL;
id = strtoul(sidstr, &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid character as arg "
+ SCLogError("invalid character as arg "
"to sid keyword");
goto error;
}
if (id >= UINT_MAX) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "sid value too high, max %u", UINT_MAX);
+ SCLogError("sid value too high, max %u", UINT_MAX);
goto error;
}
if (id == 0) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "sid value 0 is invalid");
+ SCLogError("sid value 0 is invalid");
goto error;
}
if (s->id > 0) {
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "duplicated 'sid' keyword detected");
+ SCLogError("duplicated 'sid' keyword detected");
goto error;
}
if (cd->content && cd->content_len) {
if (cd->content[cd->content_len-1] == 0x20) {
*sigerror = "sip.method pattern with trailing space";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return true;
} else if (cd->content[0] == 0x20) {
*sigerror = "sip.method pattern with leading space";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return true;
} else if (cd->content[cd->content_len-1] == 0x09) {
*sigerror = "sip.method pattern with trailing tab";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return true;
} else if (cd->content[0] == 0x09) {
*sigerror = "sip.method pattern with leading tab";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "%s", *sigerror);
+ SCLogError("%s", *sigerror);
return true;
}
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "Parse error %s", rawstr);
+ SCLogError("Parse error %s", rawstr);
goto error;
}
pcre2len = sizeof(value1);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)value1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
/* set the value */
dd->pdu_type = strtoul(value1, &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid character as arg "
+ SCLogError("invalid character as arg "
"to snmp.pdu_type keyword");
goto error;
}
dd = DetectSNMPPduTypeParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
dd = DetectSNMPVersionParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
/* Check if Hassh is disabled */
if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_SSH_HASSH_SERVER_STRING)) {
- SCLogError(SC_WARN_HASSH_DISABLED, "hassh support is not enabled");
+ SCLogError("hassh support is not enabled");
}
return -2;
}
/* Check if Hassh is disabled */
if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_SSH_HASSH_SERVER)) {
- SCLogError(SC_WARN_HASSH_DISABLED, "hassh support is not enabled");
+ SCLogError("hassh support is not enabled");
}
return -2;
}
*sigerror = "ssh.hassh.server should not be used together with "
"nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
if (cd->content_len != 32)
*sigerror = "Invalid length of the specified ssh.hassh.server (should "
"be 32 characters long). This rule will therefore "
"never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
for (size_t i = 0; i < cd->content_len; ++i)
{
*sigerror = "Invalid ssh.hassh.server string (should be string of hexademical characters)."
"This rule will therefore never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
}
/* Check if Hassh is disabled */
if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_SSH_HASSH_STRING)) {
- SCLogError(SC_WARN_HASSH_DISABLED, "hassh support is not enabled");
+ SCLogError("hassh support is not enabled");
}
return -2;
}
/* Check if Hassh is disabled */
if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_SSH_HASSH)) {
- SCLogError(SC_WARN_HASSH_DISABLED, "hassh support is not enabled");
+ SCLogError("hassh support is not enabled");
}
return -2;
}
*sigerror = "ssh.hassh should not be used together with "
"nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
if (cd->content_len != 32)
*sigerror = "Invalid length of the specified ssh.hassh (should "
"be 32 characters long). This rule will therefore "
"never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
for (size_t i = 0; i < cd->content_len; ++i)
{
*sigerror = "Invalid ssh.hassh string (should be string of hexademical characters)."
"This rule will therefore never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
}
ret = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (ret < 1 || ret > 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid ssh.protoversion option");
+ SCLogError("invalid ssh.protoversion option");
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (ret < 1 || ret > 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid ssh.softwareversion option");
+ SCLogError("invalid ssh.softwareversion option");
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
ret = DetectParsePcreExec(&parse_regex1, arg, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid arg \"%s\" supplied to "
- "ssl_state keyword.", arg);
+ SCLogError("Invalid arg \"%s\" supplied to "
+ "ssl_state keyword.",
+ arg);
goto error;
}
pcre2len = sizeof(str1);
res = pcre2_substring_copy_bynumber(parse_regex1.match, 1, (PCRE2_UCHAR8 *)str1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
negate = !strcmp("!", str1);
pcre2len = sizeof(str1);
res = pcre2_substring_copy_bynumber(parse_regex1.match, 2, (PCRE2_UCHAR8 *)str1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (negate)
mask |= DETECT_SSL_STATE_UNKNOWN;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Found invalid option \"%s\" "
- "in ssl_state keyword.", str1);
+ SCLogError("Found invalid option \"%s\" "
+ "in ssl_state keyword.",
+ str1);
goto error;
}
pcre2len = sizeof(str1);
res = pcre2_substring_copy_bynumber(parse_regex1.match, 3, (PCRE2_UCHAR8 *)str1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
while (res >= 0 && strlen(str1) > 0) {
ret = DetectParsePcreExec(&parse_regex2, str1, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid arg \"%s\" supplied to "
- "ssl_state keyword.", arg);
+ SCLogError("Invalid arg \"%s\" supplied to "
+ "ssl_state keyword.",
+ arg);
goto error;
}
pcre2len = sizeof(str2);
res = pcre2_substring_copy_bynumber(parse_regex2.match, 1, (PCRE2_UCHAR8 *)str2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
negate = !strcmp("!", str2);
pcre2len = sizeof(str2);
res = pcre2_substring_copy_bynumber(parse_regex2.match, 2, (PCRE2_UCHAR8 *)str2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (strcmp("client_hello", str2) == 0) {
if (negate)
mask |= DETECT_SSL_STATE_UNKNOWN;
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Found invalid option \"%s\" "
- "in ssl_state keyword.", str2);
+ SCLogError("Found invalid option \"%s\" "
+ "in ssl_state keyword.",
+ str2);
goto error;
}
pcre2len = sizeof(str2);
res = pcre2_substring_copy_bynumber(parse_regex2.match, 3, (PCRE2_UCHAR8 *)str2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
tmp_str++;
}
if (tmp_str[0] == 0) {
- SCLogError(SC_EINVAL, "Invalid empty value");
+ SCLogError("Invalid empty value");
goto error;
}
// iterate every version separated by comma
if (tmp_len == strlen(ssl_version_keywords[i].word) &&
strncasecmp(ssl_version_keywords[i].word, tmp_str, tmp_len) == 0) {
if (ssl->data[ssl_version_keywords[i].index].ver != 0) {
- SCLogError(SC_EINVAL, "Invalid duplicate value");
+ SCLogError("Invalid duplicate value");
goto error;
}
ssl->data[ssl_version_keywords[i].index].ver = ssl_version_keywords[i].value;
}
}
if (!is_keyword) {
- SCLogError(SC_EINVAL, "Invalid unknown value");
+ SCLogError("Invalid unknown value");
goto error;
}
if (found == 0) {
found |= 1 << neg;
} else if (found != 1 << neg) {
- SCLogError(SC_EINVAL, "Invalid value mixing negative and positive forms");
+ SCLogError("Invalid value mixing negative and positive forms");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, tagstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 ", string %s", ret, tagstr);
+ SCLogError("parse error, ret %" PRId32 ", string %s", ret, tagstr);
goto error;
}
res = pcre2_substring_get_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
} else if (strcasecmp("host", str_ptr) == 0) {
td.type = DETECT_TAG_TYPE_HOST;
} else {
- SCLogError(SC_EINVAL, "Invalid argument type. Must be session or host (%s)", tagstr);
+ SCLogError("Invalid argument type. Must be session or host (%s)", tagstr);
goto error;
}
pcre2_substring_free((PCRE2_UCHAR *)str_ptr);
res = pcre2_substring_get_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
/* count */
if (StringParseUint32(&td.count, 10, strlen(str_ptr),
str_ptr) <= 0) {
- SCLogError(SC_EINVAL,
- "Invalid argument for count. Must be a value in the range of 0 to %" PRIu32
- " (%s)",
+ SCLogError("Invalid argument for count. Must be a value in the range of 0 to %" PRIu32
+ " (%s)",
UINT32_MAX, tagstr);
goto error;
}
res = pcre2_substring_get_bynumber(
parse_regex.match, 4, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
} else if (strcasecmp("bytes", str_ptr) == 0) {
td.metric = DETECT_TAG_METRIC_BYTES;
} else {
- SCLogError(SC_EINVAL,
+ SCLogError(
"Invalid argument metric. Must be one of \"seconds\", \"packets\" or \"bytes\" "
"(%s)",
tagstr);
res = pcre2_substring_get_bynumber(
parse_regex.match, 6, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0 || str_ptr == NULL) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
} else if (strcasecmp("dst", str_ptr) == 0) {
td.direction = DETECT_TAG_DIR_DST;
} else {
- SCLogError(SC_EINVAL,
+ SCLogError(
"Invalid argument direction. Must be one of \"src\" or \"dst\" (only valid "
"for tag host type, not sessions) (%s)",
tagstr);
}
if (td.type != DETECT_TAG_TYPE_HOST) {
- SCLogWarning(SC_EINVAL,
+ SCLogWarning(
"Argument direction doesn't make sense for type \"session\" (%s [%" PRIu8
"])",
tagstr, td.type);
DetectTagData *real_td = SCMalloc(sizeof(DetectTagData));
if (unlikely(real_td == NULL)) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, targetstr, 0, 0);
if (ret < 1) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, targetstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, targetstr);
return -1;
}
pcre2len = sizeof(value);
res = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)value, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
/* now check key value */
if (!strcmp(value, "src_ip")) {
if (s->flags & SIG_FLAG_DEST_IS_TARGET) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "Conflicting values of target keyword");
+ SCLogError("Conflicting values of target keyword");
return -1;
}
s->flags |= SIG_FLAG_SRC_IS_TARGET;
} else if (!strcmp(value, "dest_ip")) {
if (s->flags & SIG_FLAG_SRC_IS_TARGET) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS,
- "Conflicting values of target keyword");
+ SCLogError("Conflicting values of target keyword");
return -1;
}
s->flags |= SIG_FLAG_DEST_IS_TARGET;
} else {
- SCLogError(SC_EINVAL, "only 'src_ip' and 'dest_ip' are supported as target value");
+ SCLogError("only 'src_ip' and 'dest_ip' are supported as target value");
return -1;
}
return 0;
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
SCLogDebug("input '%s', pcre said %d", rawstr, ret);
if (ret < 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre match failed");
+ SCLogError("pcre match failed");
SCReturnPtr(NULL, "DetectFlagsData");
}
pcre2len = sizeof(arg1);
res = SC_Pcre2SubstringCopy(parse_regex.match, 1, (PCRE2_UCHAR8 *)arg1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
SCReturnPtr(NULL, "DetectFlagsData");
}
if (ret >= 2) {
pcre2len = sizeof(arg2);
res = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)arg2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
SCReturnPtr(NULL, "DetectFlagsData");
}
}
pcre2len = sizeof(arg3);
res = SC_Pcre2SubstringCopy(parse_regex.match, 3, (PCRE2_UCHAR8 *)arg3, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
SCReturnPtr(NULL, "DetectFlagsData");
}
}
case '!':
if (de->modifier != 0) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "\"flags\" supports only"
- " one modifier at a time");
+ SCLogError("\"flags\" supports only"
+ " one modifier at a time");
goto error;
}
de->modifier = MODIFIER_NOT;
break;
case '+':
if (de->modifier != 0) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "\"flags\" supports only"
- " one modifier at a time");
+ SCLogError("\"flags\" supports only"
+ " one modifier at a time");
goto error;
}
de->modifier = MODIFIER_PLUS;
break;
case '*':
if (de->modifier != 0) {
- SCLogError(SC_ERR_FLAGS_MODIFIER, "\"flags\" supports only"
- " one modifier at a time");
+ SCLogError("\"flags\" supports only"
+ " one modifier at a time");
goto error;
}
de->modifier = MODIFIER_ANY;
ret = DetectParsePcreExec(&parse_regex, windowstr, 0, 0);
if (ret < 1 || ret > 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, windowstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, windowstr);
goto error;
}
pcre2len = sizeof(copy_str);
res = SC_Pcre2SubstringCopy(parse_regex.match, 1, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
int ret = DetectParsePcreExec(&parse_regex, templatestr, 0, 0);
if (ret != 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "parse error, ret %" PRId32 "", ret);
+ SCLogError("parse error, ret %" PRId32 "", ret);
return NULL;
}
pcre2len = sizeof(arg1);
ret = pcre2_substring_copy_bynumber(parse_regex.match, 1, (PCRE2_UCHAR8 *)arg1, &pcre2len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return NULL;
}
SCLogDebug("Arg1 \"%s\"", arg1);
pcre2len = sizeof(arg2);
ret = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)arg2, &pcre2len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return NULL;
}
SCLogDebug("Arg2 \"%s\"", arg2);
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 5) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
+ SCLogError("pcre_exec parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
parse_regex.match, i + 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
tmpm = DetectGetLastSMFromLists(s, DETECT_THRESHOLD, DETECT_DETECTION_FILTER, -1);
if (tmpm != NULL) {
if (tmpm->type == DETECT_DETECTION_FILTER) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "\"detection_filter\" and "
- "\"threshold\" are not allowed in the same rule");
+ SCLogError("\"detection_filter\" and "
+ "\"threshold\" are not allowed in the same rule");
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "multiple \"threshold\" "
- "options are not allowed in the same rule");
+ SCLogError("multiple \"threshold\" "
+ "options are not allowed in the same rule");
}
SCReturnInt(-1);
}
if (cd->content_len != 59) {
*sigerror = "Invalid length of the specified fingerprint. "
"This rule will therefore never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
*sigerror = "No colon delimiters ':' detected in content after "
"tls.cert_fingerprint. This rule will therefore "
"never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
*sigerror = "tls.cert_fingerprint should not be used together "
"with nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
}
*sigerror = "tls.cert_serial should not be used together "
"with nocase, since the rule is automatically "
"uppercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
/* no need to worry about this if the content is short enough */
*sigerror = "No colon delimiters ':' detected in content after "
"tls.cert_serial. This rule will therefore never "
"match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret < 3 || ret > 5) {
- SCLogError(SC_ERR_PCRE_MATCH, "Parse error %s", rawstr);
+ SCLogError("Parse error %s", rawstr);
goto error;
}
pcre2len = sizeof(mode);
res = SC_Pcre2SubstringCopy(parse_regex.match, 1, (PCRE2_UCHAR8 *)mode, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
SCLogDebug("mode \"%s\"", mode);
pcre2len = sizeof(value1);
res = pcre2_substring_copy_bynumber(parse_regex.match, 2, (PCRE2_UCHAR8 *)value1, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
SCLogDebug("value1 \"%s\"", value1);
pcre2len = sizeof(range);
res = pcre2_substring_copy_bynumber(parse_regex.match, 3, (PCRE2_UCHAR8 *)range, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
SCLogDebug("range \"%s\"", range);
res = pcre2_substring_copy_bynumber(
parse_regex.match, 4, (PCRE2_UCHAR8 *)value2, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
SCLogDebug("value2 \"%s\"", value2);
}
if (strlen(range) != 0 && strlen(mode) != 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Range specified but mode also set");
+ SCLogError("Range specified but mode also set");
goto error;
}
/* set the second value if specified */
if (strlen(value2) > 0) {
if (!(dd->mode & DETECT_TLS_VALIDITY_RA)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Multiple tls validity values specified but mode is not range");
+ SCLogError("Multiple tls validity values specified but mode is not range");
goto error;
}
goto error;
if (dd->epoch2 <= dd->epoch) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Second value in range must not be smaller than the first");
+ SCLogError("Second value in range must not be smaller than the first");
goto error;
}
}
dd = SCCalloc(1, sizeof(DetectTlsValidityData));
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Allocation \'%s\' failed", rawstr);
+ SCLogError("Allocation \'%s\' failed", rawstr);
goto error;
}
dd = SCCalloc(1, sizeof(DetectTlsValidityData));
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Allocation \'%s\' failed", rawstr);
+ SCLogError("Allocation \'%s\' failed", rawstr);
goto error;
}
dd = DetectTlsValidityParse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Parsing \'%s\' failed", rawstr);
+ SCLogError("Parsing \'%s\' failed", rawstr);
goto error;
}
DetectU32Data *dd = DetectU32Parse(rawstr);
if (dd == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Parsing \'%s\' failed for %s", rawstr,
- sigmatch_table[KEYWORD_ID].name);
+ SCLogError("Parsing \'%s\' failed for %s", rawstr, sigmatch_table[KEYWORD_ID].name);
return -1;
}
return -1;
if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_TLS && s->alproto != ALPROTO_QUIC) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting protocols.");
+ SCLogError("rule contains conflicting protocols.");
return -1;
}
/* Check if JA3 is disabled */
if (!RunmodeIsUnittests() && Ja3IsDisabled("rule")) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_TLS_JA3_HASH)) {
- SCLogError(SC_WARN_JA3_DISABLED, "ja3 support is not enabled");
+ SCLogError("ja3 support is not enabled");
}
return -2;
}
*sigerror = "ja3.hash should not be used together with "
"nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
if (cd->content_len == SC_MD5_HEX_LEN)
*sigerror = "Invalid length of the specified JA3 hash (should "
"be 32 characters long). This rule will therefore "
"never match.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
return false;
}
return -1;
if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_TLS && s->alproto != ALPROTO_QUIC) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting protocols.");
+ SCLogError("rule contains conflicting protocols.");
return -1;
}
/* Check if JA3 is disabled */
if (!RunmodeIsUnittests() && Ja3IsDisabled("rule")) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_TLS_JA3_STRING)) {
- SCLogError(SC_WARN_JA3_DISABLED, "ja3(s) support is not enabled");
+ SCLogError("ja3(s) support is not enabled");
}
return -2;
}
return -1;
if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_TLS && s->alproto != ALPROTO_QUIC) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting protocols.");
+ SCLogError("rule contains conflicting protocols.");
return -1;
}
/* Check if JA3 is disabled */
if (!RunmodeIsUnittests() && Ja3IsDisabled("rule")) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_TLS_JA3S_HASH)) {
- SCLogError(SC_WARN_JA3_DISABLED, "ja3(s) support is not enabled");
+ SCLogError("ja3(s) support is not enabled");
}
return -2;
}
*sigerror = "ja3s.hash should not be used together with "
"nocase, since the rule is automatically "
"lowercased anyway which makes nocase redundant.";
- SCLogWarning(SC_WARN_POOR_RULE, "rule %u: %s", s->id, *sigerror);
+ SCLogWarning("rule %u: %s", s->id, *sigerror);
}
if (cd->content_len == SC_MD5_HEX_LEN)
*sigerror = "Invalid length of the specified JA3S hash (should "
"be 32 characters long). This rule will therefore "
"never match.";
- SCLogError(SC_ERR_INVALID_RULE_ARGUMENT, "rule %u: %s", s->id, *sigerror);
+ SCLogError("rule %u: %s", s->id, *sigerror);
return false;
}
return -1;
if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_TLS && s->alproto != ALPROTO_QUIC) {
- SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting protocols.");
+ SCLogError("rule contains conflicting protocols.");
return -1;
}
/* Check if JA3 is disabled */
if (!RunmodeIsUnittests() && Ja3IsDisabled("rule")) {
if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_AL_TLS_JA3S_STRING)) {
- SCLogError(SC_WARN_JA3_DISABLED, "ja3(s) support is not enabled");
+ SCLogError("ja3(s) support is not enabled");
}
return -2;
}
ret = DetectParsePcreExec(&parse_regex, str, 0, 0);
if (ret < 1 || ret > 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid tls.version option");
+ SCLogError("invalid tls.version option");
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 *)ver_ptr, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
temp = (uint16_t)strtol(tmp_str, NULL, 0);
tls->flags |= DETECT_TLS_VERSION_FLAG_RAW;
} else {
- SCLogError(SC_EINVAL, "Invalid value");
+ SCLogError("Invalid value");
goto error;
}
ret = DetectParsePcreExec(&subject_parse_regex, str, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid tls.subject option");
+ SCLogError("invalid tls.subject option");
goto error;
}
res = pcre2_substring_get_bynumber(
subject_parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
ret = DetectParsePcreExec(&issuerdn_parse_regex, str, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid tls.issuerdn option");
+ SCLogError("invalid tls.issuerdn option");
goto error;
}
res = pcre2_substring_get_bynumber(
issuerdn_parse_regex.match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
ret = DetectParsePcreExec(&parse_regex, arg, 0, 0);
if (ret != 2) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid tos option - %s. "
+ SCLogError("invalid tos option - %s. "
"The tos option value must be in the range "
- "%u - %u", arg, DETECT_IPTOS_MIN, DETECT_IPTOS_MAX);
+ "%u - %u",
+ arg, DETECT_IPTOS_MIN, DETECT_IPTOS_MAX);
goto error;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 *)tosbytes_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
}
if (!(tos >= DETECT_IPTOS_MIN && tos <= DETECT_IPTOS_MAX)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid tos argument - "
+ SCLogError("Invalid tos argument - "
"%s. The tos option value must be in the range "
- "%u - %u", tosbytes_str, DETECT_IPTOS_MIN, DETECT_IPTOS_MAX);
+ "%u - %u",
+ tosbytes_str, DETECT_IPTOS_MIN, DETECT_IPTOS_MAX);
goto error;
}
{
SCEnter();
if (g_disable_hashing) {
- SCLogError(SC_ERR_HASHING_DISABLED, "MD5 hashing has been disabled, "
- "needed for to_md5 keyword");
+ SCLogError("MD5 hashing has been disabled, "
+ "needed for to_md5 keyword");
SCReturnInt(-1);
}
int r = DetectSignatureAddTransform(s, DETECT_TRANSFORM_MD5, NULL);
if (pxd->regex == NULL) {
PCRE2_UCHAR buffer[256];
pcre2_get_error_message(en, buffer, sizeof(buffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
regexstr, (int)eo, buffer);
pcre2_match_context_free(pxd->context);
SCFree(pxd);
// check pcd->regex has exactly one capture expression
uint32_t nb;
if (pcre2_pattern_info(pxd->regex, PCRE2_INFO_CAPTURECOUNT, &nb) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "pcrexform failed getting info about capturecount");
+ SCLogError("pcrexform failed getting info about capturecount");
DetectTransformPcrexformFree(de_ctx, pxd);
SCReturnInt(-1);
}
if (nb != 1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "pcrexform needs exactly one substring capture, found %" PRIu32, nb);
+ SCLogError("pcrexform needs exactly one substring capture, found %" PRIu32, nb);
DetectTransformPcrexformFree(de_ctx, pxd);
SCReturnInt(-1);
}
{
SCEnter();
if (g_disable_hashing) {
- SCLogError(SC_ERR_HASHING_DISABLED, "SHA1 hashing has been disabled, "
- "needed for to_sha1 keyword");
+ SCLogError("SHA1 hashing has been disabled, "
+ "needed for to_sha1 keyword");
SCReturnInt(-1);
}
int r = DetectSignatureAddTransform(s, DETECT_TRANSFORM_SHA1, NULL);
{
SCEnter();
if (g_disable_hashing) {
- SCLogError(SC_ERR_HASHING_DISABLED, "SHA256 hashing has been disabled, "
- "needed for to_sha256 keyword");
+ SCLogError("SHA256 hashing has been disabled, "
+ "needed for to_sha256 keyword");
SCReturnInt(-1);
}
int r = DetectSignatureAddTransform(s, DETECT_TRANSFORM_SHA256, NULL);
// Create pxd from optstr
DetectTransformXorData *pxd = SCCalloc(1, sizeof(*pxd));
if (pxd == NULL) {
- SCLogError(SC_ENOMEM, "memory allocation failed");
+ SCLogError("memory allocation failed");
SCReturnInt(-1);
}
size_t keylen = strlen(optstr);
if (keylen % 2 == 1) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "XOR transform key's length must be an even number");
+ SCLogError("XOR transform key's length must be an even number");
DetectTransformXorFree(de_ctx, pxd);
SCReturnInt(-1);
}
if (keylen / 2 > UINT8_MAX) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Key length too big for XOR transform");
+ SCLogError("Key length too big for XOR transform");
DetectTransformXorFree(de_ctx, pxd);
SCReturnInt(-1);
}
pxd->length = (uint8_t)(keylen / 2);
pxd->key = SCMalloc(keylen / 2);
if (pxd->key == NULL) {
- SCLogError(SC_ENOMEM, "memory allocation failed");
+ SCLogError("memory allocation failed");
DetectTransformXorFree(de_ctx, pxd);
SCReturnInt(-1);
}
pxd->key[i] |= (optstr[2 * i + 1] >= 'A' ? ((optstr[2 * i + 1] & 0xdf) - 'A') + 10
: (optstr[2 * i + 1] - '0'));
} else {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "XOR transform key must be hexadecimal characters only");
+ SCLogError("XOR transform key must be hexadecimal characters only");
DetectTransformXorFree(de_ctx, pxd);
SCReturnInt(-1);
}
const char *legacy = NULL;
if (ConfGet("legacy.uricontent", &legacy) == 1) {
if (strcasecmp("disabled", legacy) == 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "uriconent deprecated. To "
+ SCLogError("uriconent deprecated. To "
"use a rule with \"uricontent\", either set the "
"option - \"legacy.uricontent\" in the conf to "
"\"enabled\" OR replace uricontent with "
- "\'content:%s; http_uri;\'.", contentstr);
+ "\'content:%s; http_uri;\'.",
+ contentstr);
goto error;
} else if (strcasecmp("enabled", legacy) == 0) {
;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid value found "
+ SCLogError("Invalid value found "
"for legacy.uriconent - \"%s\". Valid values are "
- "\"enabled\" OR \"disabled\".", legacy);
+ "\"enabled\" OR \"disabled\".",
+ legacy);
goto error;
}
}
if (cd->depth && cd->depth < cd->content_len) {
*sigerror = "depth or urilen smaller than content len";
- SCLogError(SC_ERR_INVALID_SIGNATURE, "depth or urilen %u smaller "
- "than content len %u", cd->depth, cd->content_len);
+ SCLogError("depth or urilen %u smaller "
+ "than content len %u",
+ cd->depth, cd->content_len);
return false;
}
}
/* retrieve the sm to apply the within against */
pm = DetectGetLastSMFromLists(s, DETECT_CONTENT, -1);
if (pm == NULL) {
- SCLogError(SC_ERR_OFFSET_MISSING_CONTENT, "within needs "
+ SCLogError("within needs "
"preceding content option");
goto end;
}
/* verify other conditions */
DetectContentData *cd = (DetectContentData *)pm->ctx;
if (cd->flags & DETECT_CONTENT_WITHIN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use multiple withins for the same content.");
+ SCLogError("can't use multiple withins for the same content.");
goto end;
}
if ((cd->flags & DETECT_CONTENT_DEPTH) || (cd->flags & DETECT_CONTENT_OFFSET)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't use a relative "
+ SCLogError("can't use a relative "
"keyword like within/distance with a absolute "
"relative keyword like depth/offset for the same "
- "content." );
+ "content.");
goto end;
}
if (cd->flags & DETECT_CONTENT_NEGATED && cd->flags & DETECT_CONTENT_FAST_PATTERN) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"negated keyword set along with a fast_pattern");
goto end;
}
if (cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "can't have a relative "
+ SCLogError("can't have a relative "
"keyword set along with a fast_pattern:only;");
goto end;
}
if (str[0] != '-' && isalpha((unsigned char)str[0])) {
DetectByteIndexType index;
if (!DetectByteRetrieveSMVar(str, s, &index)) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "unknown byte_ keyword var "
- "seen in within - %s\n", str);
+ SCLogError("unknown byte_ keyword var "
+ "seen in within - %s\n",
+ str);
goto end;
}
cd->within = index;
cd->flags |= DETECT_CONTENT_WITHIN_VAR;
} else {
if (StringParseInt32(&cd->within, 0, 0, str) < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "invalid value for within: %s", str);
+ SCLogError("invalid value for within: %s", str);
goto end;
}
if (cd->within < (int32_t)cd->content_len) {
- SCLogError(SC_ERR_WITHIN_INVALID, "within argument \"%"PRIi32"\" is "
- "less than the content length \"%"PRIu32"\" which is invalid, since "
- "this will never match. Invalidating signature", cd->within,
- cd->content_len);
+ SCLogError("within argument \"%" PRIi32 "\" is "
+ "less than the content length \"%" PRIu32 "\" which is invalid, since "
+ "this will never match. Invalidating signature",
+ cd->within, cd->content_len);
goto end;
}
}
if (prev_pm->type == DETECT_CONTENT) {
DetectContentData *prev_cd = (DetectContentData *)prev_pm->ctx;
if (prev_cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "previous keyword "
+ SCLogError("previous keyword "
"has a fast_pattern:only; set. Can't "
"have relative keywords around a fast_pattern "
"only content");
ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
if (ret != 2 && ret != 3 && ret != 4 && ret != 5) {
- SCLogError(SC_ERR_PCRE_MATCH, "\"%s\" is not a valid setting for xbits.", rawstr);
+ SCLogError("\"%s\" is not a valid setting for xbits.", rawstr);
return -1;
}
SCLogDebug("ret %d, %s", ret, rawstr);
res = pcre2_substring_copy_bynumber(
parse_regex.match, 1, (PCRE2_UCHAR8 *)fb_cmd_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
res = pcre2_substring_copy_bynumber(
parse_regex.match, 2, (PCRE2_UCHAR8 *)fb_name, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
if (ret >= 4) {
res = pcre2_substring_copy_bynumber(
parse_regex.match, 3, (PCRE2_UCHAR8 *)hb_dir_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
SCLogDebug("hb_dir_str %s", hb_dir_str);
res = pcre2_substring_copy_bynumber(
parse_regex.match, 4, (PCRE2_UCHAR8 *)expire_str, &pcre2len);
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
return -1;
}
SCLogDebug("expire_str %s", expire_str);
if (StringParseUint32(&expire, 10, 0, (const char *)expire_str) < 0) {
- SCLogError(SC_EINVAL,
- "Invalid value for "
- "expire: \"%s\"",
+ SCLogError("Invalid value for "
+ "expire: \"%s\"",
expire_str);
return -1;
}
if (expire == 0) {
- SCLogError(SC_EINVAL, "expire must be bigger than 0");
+ SCLogError("expire must be bigger than 0");
return -1;
}
SCLogDebug("expire %d", expire);
} else if (strcmp(fb_cmd_str,"toggle") == 0) {
fb_cmd = DETECT_XBITS_CMD_TOGGLE;
} else {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "xbits action \"%s\" is not supported.", fb_cmd_str);
+ SCLogError("xbits action \"%s\" is not supported.", fb_cmd_str);
return -1;
}
DEBUG_VALIDATE_BUG_ON(det_ctx->tx_candidates);
det_ctx->tx_candidates = SCCalloc(size, sizeof(RuleMatchCandidateTx));
if (det_ctx->tx_candidates == NULL) {
- FatalError(SC_ENOMEM, "failed to allocate %" PRIu64 " bytes",
+ FatalError("failed to allocate %" PRIu64 " bytes",
(uint64_t)(size * sizeof(RuleMatchCandidateTx)));
}
det_ctx->tx_candidates_size = size;
uint32_t new_size = needed;
void *ptmp = SCRealloc(det_ctx->tx_candidates, (new_size * sizeof(RuleMatchCandidateTx)));
if (ptmp == NULL) {
- FatalError(SC_ENOMEM, "failed to expand to %" PRIu64 " bytes",
+ FatalError("failed to expand to %" PRIu64 " bytes",
(uint64_t)(new_size * sizeof(RuleMatchCandidateTx)));
// TODO can this be handled more gracefully?
}
FeatureHashFreeFunc);
if (!feature_hash_table) {
- FatalError(sc_errno, "Unable to allocate feature hash table.");
+ FatalError("Unable to allocate feature hash table.");
}
}
FeatureEntryType *feature = SCCalloc(1, sizeof(*feature));
if (!feature) {
- FatalError(SC_ENOMEM, "Unable to allocate feature entry memory.");
+ FatalError("Unable to allocate feature entry memory.");
}
feature->feature = SCStrdup(feature_name);
again:
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- FatalError(SC_ERR_SHUTDOWN, "unable to get all flow manager "
- "threads to shutdown in time");
+ FatalError("unable to get all flow manager "
+ "threads to shutdown in time");
}
SCMutexLock(&tv_root_lock);
(void)ConfGetInt("flow.managers", &setting);
if (setting < 1 || setting > 1024) {
- FatalError(SC_ERR_INVALID_ARGUMENTS,
- "invalid flow.managers setting %"PRIdMAX, setting);
+ FatalError("invalid flow.managers setting %" PRIdMAX, setting);
}
flowmgr_number = (uint32_t)setting;
BUG_ON(tv_flowmgr == NULL);
if (tv_flowmgr == NULL) {
- FatalError(SC_ERR_FATAL, "flow manager thread creation failed");
+ FatalError("flow manager thread creation failed");
}
if (TmThreadSpawn(tv_flowmgr) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "flow manager thread spawn failed");
+ FatalError("flow manager thread spawn failed");
}
}
return;
if (ftd == NULL)
return TM_ECODE_FAILED;
if (OutputFlowLogThreadInit(t, NULL, &ftd->output_thread_data) != TM_ECODE_OK) {
- SCLogError(SC_ERR_THREAD_INIT, "initializing flow log API for thread failed");
+ SCLogError("initializing flow log API for thread failed");
SCFree(ftd);
return TM_ECODE_FAILED;
}
(void)ConfGetInt("flow.recyclers", &setting);
if (setting < 1 || setting > 1024) {
- FatalError(SC_ERR_INVALID_ARGUMENTS,
- "invalid flow.recyclers setting %"PRIdMAX, setting);
+ FatalError("invalid flow.recyclers setting %" PRIdMAX, setting);
}
flowrec_number = (uint32_t)setting;
"FlowRecycler", 0);
if (tv_flowrec == NULL) {
- FatalError(SC_ERR_FATAL, "flow recycler thread creation failed");
+ FatalError("flow recycler thread creation failed");
}
if (TmThreadSpawn(tv_flowrec) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "flow recycler thread spawn failed");
+ FatalError("flow recycler thread spawn failed");
}
}
return;
again:
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- FatalError(SC_ERR_SHUTDOWN, "unable to get all flow recycler "
- "threads to shutdown in time");
+ FatalError("unable to get all flow recycler "
+ "threads to shutdown in time");
}
SCMutexLock(&tv_root_lock);
{
FlowQueue *q = (FlowQueue *)SCMalloc(sizeof(FlowQueue));
if (q == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowQueueNew. Exiting...");
+ SCLogError("Fatal error encountered in FlowQueueNew. Exiting...");
exit(EXIT_SUCCESS);
}
q = FlowQueueInit(q);
for (uint32_t cnt = 0; cnt < flow_config.prealloc; ) {
FlowSparePool *p = FlowSpareGetPool();
if (p == NULL) {
- FatalError(SC_ERR_FLOW_INIT, "failed to initialize flow pool");
+ FatalError("failed to initialize flow pool");
}
FlowSparePoolUpdateBlock(p);
cnt += p->queue.len;
return TM_ECODE_FAILED;
}
if (OutputFlowLogThreadInit(tv, NULL, &fw->output_thread_flow) != TM_ECODE_OK) {
- SCLogError(SC_ERR_THREAD_INIT, "initializing flow log API for thread failed");
+ SCLogError("initializing flow log API for thread failed");
FlowWorkerThreadDeinit(tv, fw);
return TM_ECODE_FAILED;
}
if (val <= 100 && val >= 1) {
flow_config.emergency_recovery = (uint8_t)val;
} else {
- SCLogError(SC_EINVAL, "flow.emergency-recovery must be in the range of "
- "1 and 100 (as percentage)");
+ SCLogError("flow.emergency-recovery must be in the range of "
+ "1 and 100 (as percentage)");
flow_config.emergency_recovery = FLOW_DEFAULT_EMERGENCY_RECOVERY;
}
} else {
if ((ConfGet("flow.memcap", &conf_val)) == 1)
{
if (conf_val == NULL) {
- FatalError(SC_ERR_FATAL, "Invalid value for flow.memcap: NULL");
+ FatalError("Invalid value for flow.memcap: NULL");
}
if (ParseSizeStringU64(conf_val, &flow_memcap_copy) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing flow.memcap "
+ SCLogError("Error parsing flow.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(flow_config.memcap, flow_memcap_copy);
if ((ConfGet("flow.hash-size", &conf_val)) == 1)
{
if (conf_val == NULL) {
- FatalError(SC_ERR_FATAL, "Invalid value for flow.hash-size: NULL");
+ FatalError("Invalid value for flow.hash-size: NULL");
}
if (StringParseUint32(&configval, 10, strlen(conf_val),
if ((ConfGet("flow.prealloc", &conf_val)) == 1)
{
if (conf_val == NULL) {
- FatalError(SC_ERR_FATAL, "Invalid value for flow.prealloc: NULL");
+ FatalError("Invalid value for flow.prealloc: NULL");
}
if (StringParseUint32(&configval, 10, strlen(conf_val),
/* alloc hash memory */
uint64_t hash_size = flow_config.hash_size * sizeof(FlowBucket);
if (!(FLOW_CHECK_MEMCAP(hash_size))) {
- SCLogError(SC_ERR_FLOW_INIT, "allocating flow hash failed: "
- "max flow memcap is smaller than projected hash size. "
- "Memcap: %"PRIu64", Hash table size %"PRIu64". Calculate "
- "total hash size by multiplying \"flow.hash-size\" with %"PRIuMAX", "
- "which is the hash bucket size.", SC_ATOMIC_GET(flow_config.memcap), hash_size,
- (uintmax_t)sizeof(FlowBucket));
+ SCLogError("allocating flow hash failed: "
+ "max flow memcap is smaller than projected hash size. "
+ "Memcap: %" PRIu64 ", Hash table size %" PRIu64 ". Calculate "
+ "total hash size by multiplying \"flow.hash-size\" with %" PRIuMAX ", "
+ "which is the hash bucket size.",
+ SC_ATOMIC_GET(flow_config.memcap), hash_size, (uintmax_t)sizeof(FlowBucket));
exit(EXIT_FAILURE);
}
flow_hash = SCMallocAligned(flow_config.hash_size * sizeof(FlowBucket), CLS);
if (unlikely(flow_hash == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in FlowInitConfig. Exiting...");
+ FatalError("Fatal error encountered in FlowInitConfig. Exiting...");
}
memset(flow_hash, 0, flow_config.hash_size * sizeof(FlowBucket));
FlowProtoTimeout *e = &flow_timeouts_emerg[i];
if (e->est_timeout > n->est_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value %u for \'established\' "
- "must be below regular value %u", e->est_timeout, n->est_timeout);
+ SCLogWarning("emergency timeout value %u for \'established\' "
+ "must be below regular value %u",
+ e->est_timeout, n->est_timeout);
e->est_timeout = n->est_timeout / 10;
}
if (e->new_timeout > n->new_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value %u for \'new\' must be "
- "below regular value %u", e->new_timeout, n->new_timeout);
+ SCLogWarning("emergency timeout value %u for \'new\' must be "
+ "below regular value %u",
+ e->new_timeout, n->new_timeout);
e->new_timeout = n->new_timeout / 10;
}
if (e->closed_timeout > n->closed_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value %u for \'closed\' must "
- "be below regular value %u", e->closed_timeout, n->closed_timeout);
+ SCLogWarning("emergency timeout value %u for \'closed\' must "
+ "be below regular value %u",
+ e->closed_timeout, n->closed_timeout);
e->closed_timeout = n->closed_timeout / 10;
}
if (e->bypassed_timeout > n->bypassed_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value %u for \'bypassed\' "
- "must be below regular value %u", e->bypassed_timeout, n->bypassed_timeout);
+ SCLogWarning("emergency timeout value %u for \'bypassed\' "
+ "must be below regular value %u",
+ e->bypassed_timeout, n->bypassed_timeout);
e->bypassed_timeout = n->bypassed_timeout / 10;
}
}
FlowProtoTimeout *d = &flow_timeouts_delta[i];
if (e->est_timeout > n->est_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value for \'established\' must be below normal value");
+ SCLogWarning("emergency timeout value for \'established\' must be below normal value");
e->est_timeout = n->est_timeout / 10;
}
d->est_timeout = n->est_timeout - e->est_timeout;
if (e->new_timeout > n->new_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value for \'new\' must be below normal value");
+ SCLogWarning("emergency timeout value for \'new\' must be below normal value");
e->new_timeout = n->new_timeout / 10;
}
d->new_timeout = n->new_timeout - e->new_timeout;
if (e->closed_timeout > n->closed_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value for \'closed\' must be below normal value");
+ SCLogWarning("emergency timeout value for \'closed\' must be below normal value");
e->closed_timeout = n->closed_timeout / 10;
}
d->closed_timeout = n->closed_timeout - e->closed_timeout;
if (e->bypassed_timeout > n->bypassed_timeout) {
- SCLogWarning(SC_WARN_FLOW_EMERGENCY, "emergency timeout value for \'bypassed\' must be below normal value");
+ SCLogWarning("emergency timeout value for \'bypassed\' must be below normal value");
e->bypassed_timeout = n->bypassed_timeout / 10;
}
d->bypassed_timeout = n->bypassed_timeout - e->bypassed_timeout;
{
host_bit_id = HostStorageRegister("bit", sizeof(void *), NULL, HostBitFreeAll);
if (host_bit_id.id == -1) {
- FatalError(SC_ERR_FATAL, "Can't initiate host storage for bits");
+ FatalError("Can't initiate host storage for bits");
}
}
{
HostQueue *q = (HostQueue *)SCMalloc(sizeof(HostQueue));
if (q == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostQueueNew. Exiting...");
+ SCLogError("Fatal error encountered in HostQueueNew. Exiting...");
exit(EXIT_SUCCESS);
}
q = HostQueueInit(q);
if ((ConfGet("host.memcap", &conf_val)) == 1) {
uint64_t host_memcap = 0;
if (ParseSizeStringU64(conf_val, &host_memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing host.memcap "
+ SCLogError("Error parsing host.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(host_config.memcap, host_memcap);
/* alloc hash memory */
uint64_t hash_size = host_config.hash_size * sizeof(HostHashRow);
if (!(HOST_CHECK_MEMCAP(hash_size))) {
- SCLogError(SC_ERR_HOST_INIT, "allocating host hash failed: "
- "max host memcap is smaller than projected hash size. "
- "Memcap: %"PRIu64", Hash table size %"PRIu64". Calculate "
- "total hash size by multiplying \"host.hash-size\" with %"PRIuMAX", "
- "which is the hash bucket size.", SC_ATOMIC_GET(host_config.memcap), hash_size,
- (uintmax_t)sizeof(HostHashRow));
+ SCLogError("allocating host hash failed: "
+ "max host memcap is smaller than projected hash size. "
+ "Memcap: %" PRIu64 ", Hash table size %" PRIu64 ". Calculate "
+ "total hash size by multiplying \"host.hash-size\" with %" PRIuMAX ", "
+ "which is the hash bucket size.",
+ SC_ATOMIC_GET(host_config.memcap), hash_size, (uintmax_t)sizeof(HostHashRow));
exit(EXIT_FAILURE);
}
host_hash = SCMallocAligned(host_config.hash_size * sizeof(HostHashRow), CLS);
if (unlikely(host_hash == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in HostInitConfig. Exiting...");
+ FatalError("Fatal error encountered in HostInitConfig. Exiting...");
}
memset(host_hash, 0, host_config.hash_size * sizeof(HostHashRow));
/* pre allocate hosts */
for (i = 0; i < host_config.prealloc; i++) {
if (!(HOST_CHECK_MEMCAP(g_host_size))) {
- SCLogError(SC_ERR_HOST_INIT, "preallocating hosts failed: "
- "max host memcap reached. Memcap %"PRIu64", "
- "Memuse %"PRIu64".", SC_ATOMIC_GET(host_config.memcap),
+ SCLogError("preallocating hosts failed: "
+ "max host memcap reached. Memcap %" PRIu64 ", "
+ "Memuse %" PRIu64 ".",
+ SC_ATOMIC_GET(host_config.memcap),
((uint64_t)SC_ATOMIC_GET(host_memuse) + g_host_size));
exit(EXIT_FAILURE);
}
Host *h = HostAlloc();
if (h == NULL) {
- SCLogError(SC_ERR_HOST_INIT, "preallocating host failed: %s", strerror(errno));
+ SCLogError("preallocating host failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
HostEnqueue(&host_spare_q,h);
{
g_ippair_bit_storage_id = IPPairStorageRegister("bit", sizeof(void *), NULL, XBitFreeAll);
if (g_ippair_bit_storage_id.id == -1) {
- FatalError(SC_ERR_FATAL, "Can't initiate ippair storage for bits");
+ FatalError("Can't initiate ippair storage for bits");
}
}
{
IPPairQueue *q = (IPPairQueue *)SCMalloc(sizeof(IPPairQueue));
if (q == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in IPPairQueueNew. Exiting...");
+ SCLogError("Fatal error encountered in IPPairQueueNew. Exiting...");
exit(EXIT_SUCCESS);
}
q = IPPairQueueInit(q);
if ((ConfGet("ippair.memcap", &conf_val)) == 1)
{
if (ParseSizeStringU64(conf_val, &ippair_memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing ippair.memcap "
+ SCLogError("Error parsing ippair.memcap "
"from conf file - %s. Killing engine",
- conf_val);
+ conf_val);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(ippair_config.memcap, ippair_memcap);
/* alloc hash memory */
uint64_t hash_size = ippair_config.hash_size * sizeof(IPPairHashRow);
if (!(IPPAIR_CHECK_MEMCAP(hash_size))) {
- SCLogError(SC_ERR_IPPAIR_INIT, "allocating ippair hash failed: "
- "max ippair memcap is smaller than projected hash size. "
- "Memcap: %"PRIu64", Hash table size %"PRIu64". Calculate "
- "total hash size by multiplying \"ippair.hash-size\" with %"PRIuMAX", "
- "which is the hash bucket size.", SC_ATOMIC_GET(ippair_config.memcap), hash_size,
- (uintmax_t)sizeof(IPPairHashRow));
+ SCLogError("allocating ippair hash failed: "
+ "max ippair memcap is smaller than projected hash size. "
+ "Memcap: %" PRIu64 ", Hash table size %" PRIu64 ". Calculate "
+ "total hash size by multiplying \"ippair.hash-size\" with %" PRIuMAX ", "
+ "which is the hash bucket size.",
+ SC_ATOMIC_GET(ippair_config.memcap), hash_size, (uintmax_t)sizeof(IPPairHashRow));
exit(EXIT_FAILURE);
}
ippair_hash = SCMallocAligned(ippair_config.hash_size * sizeof(IPPairHashRow), CLS);
if (unlikely(ippair_hash == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in IPPairInitConfig. Exiting...");
+ FatalError("Fatal error encountered in IPPairInitConfig. Exiting...");
}
memset(ippair_hash, 0, ippair_config.hash_size * sizeof(IPPairHashRow));
/* pre allocate ippairs */
for (i = 0; i < ippair_config.prealloc; i++) {
if (!(IPPAIR_CHECK_MEMCAP(g_ippair_size))) {
- SCLogError(SC_ERR_IPPAIR_INIT, "preallocating ippairs failed: "
- "max ippair memcap reached. Memcap %"PRIu64", "
- "Memuse %"PRIu64".", SC_ATOMIC_GET(ippair_config.memcap),
+ SCLogError("preallocating ippairs failed: "
+ "max ippair memcap reached. Memcap %" PRIu64 ", "
+ "Memuse %" PRIu64 ".",
+ SC_ATOMIC_GET(ippair_config.memcap),
((uint64_t)SC_ATOMIC_GET(ippair_memuse) + g_ippair_size));
exit(EXIT_FAILURE);
}
IPPair *h = IPPairAlloc();
if (h == NULL) {
- SCLogError(SC_ERR_IPPAIR_INIT, "preallocating ippair failed: %s", strerror(errno));
+ SCLogError("preallocating ippair failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
IPPairEnqueue(&ippair_spare_q,h);
{
LogCustomFormatNode * node = SCCalloc(1, sizeof(LogCustomFormatNode));
if (unlikely(node == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to alloc custom format node");
+ SCLogError("Failed to alloc custom format node");
return NULL;
}
return node;
{
LogCustomFormat * cf = SCCalloc(1, sizeof(LogCustomFormat));
if (unlikely(cf == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to alloc custom format");
+ SCLogError("Failed to alloc custom format");
return NULL;
}
return cf;
return;
if (cf->cf_n == LOG_MAXN_NODES) {
- SCLogWarning(SC_WARN_LOG_CF_TOO_MANY_NODES, "Too many options for custom format");
+ SCLogWarning("Too many options for custom format");
return;
}
OutputInitResult result = { NULL, false };
LogFileCtx* file_ctx = LogFileNewCtx();
if(file_ctx == NULL) {
- SCLogError(SC_ERR_HTTP_LOG_GENERIC, "couldn't create new file_ctx");
+ SCLogError("couldn't create new file_ctx");
return result;
}
return result;
parsererror:
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Syntax error in custom http log format string.");
+ SCLogError("Syntax error in custom http log format string.");
errorfree:
LogCustomFormatFree(httplog_ctx->cf);
LogFileFreeCtx(file_ctx);
comp->pcap_buf_wrapper = SCFmemopen(comp->pcap_buf,
comp->pcap_buf_size, "w");
if (comp->pcap_buf_wrapper == NULL) {
- SCLogError(SC_ERR_FOPEN, "SCFmemopen failed: %s",
- strerror(errno));
+ SCLogError("SCFmemopen failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
}
uint64_t bytes_written = LZ4F_compressEnd(comp->lz4f_context,
comp->buffer, comp->buffer_size, NULL);
if (LZ4F_isError(bytes_written)) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS, "LZ4F_compressEnd: %s",
- LZ4F_getErrorName(bytes_written));
+ SCLogError("LZ4F_compressEnd: %s", LZ4F_getErrorName(bytes_written));
return TM_ECODE_FAILED;
}
if (fwrite(comp->buffer, 1, bytes_written, comp->file) < bytes_written) {
- SCLogError(SC_ERR_FWRITE, "fwrite failed: %s", strerror(errno));
+ SCLogError("fwrite failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
fclose(comp->file);
if (remove(pf->filename) != 0) {
// VJ remove can fail because file is already gone
- //LogWarning(SC_ERR_PCAP_FILE_DELETE_FAILED,
- // "failed to remove log file %s: %s",
+ // SCLogWarning("failed to remove log file %s: %s",
// pf->filename, strerror( errno ));
}
pf->dirname, pfnext->dirname);
if (remove(pf->dirname) != 0) {
- SCLogWarning(SC_ERR_PCAP_FILE_DELETE_FAILED,
- "failed to remove sguil log %s: %s",
- pf->dirname, strerror( errno ));
+ SCLogWarning("failed to remove sguil log %s: %s", pf->dirname, strerror(errno));
}
}
}
}
if (PcapLogOpenFileCtx(pl) < 0) {
- SCLogError(SC_ERR_FOPEN, "opening new pcap log file failed");
+ SCLogError("opening new pcap log file failed");
return -1;
}
pl->file_cnt++;
PcapLogCompressionData *comp = &pl->compression;
if ((pl->pcap_dumper = pcap_dump_fopen(pl->pcap_dead_handle,
comp->pcap_buf_wrapper)) == NULL) {
- SCLogError(SC_ERR_OPENING_FILE, "Error opening dump file %s",
- pcap_geterr(pl->pcap_dead_handle));
+ SCLogError("Error opening dump file %s", pcap_geterr(pl->pcap_dead_handle));
return TM_ECODE_FAILED;
}
comp->file = fopen(pl->filename, "w");
if (comp->file == NULL) {
- SCLogError(SC_ERR_OPENING_FILE,
- "Error opening file for compressed output: %s",
- strerror(errno));
+ SCLogError("Error opening file for compressed output: %s", strerror(errno));
return TM_ECODE_FAILED;
}
uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context,
comp->buffer, comp->buffer_size, NULL);
if (LZ4F_isError(bytes_written)) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS, "LZ4F_compressBegin: %s",
- LZ4F_getErrorName(bytes_written));
+ SCLogError("LZ4F_compressBegin: %s", LZ4F_getErrorName(bytes_written));
return TM_ECODE_FAILED;
}
if (fwrite(comp->buffer, 1, bytes_written, comp->file) < bytes_written) {
- SCLogError(SC_ERR_FWRITE, "fwrite failed: %s", strerror(errno));
+ SCLogError("fwrite failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
}
pcap_dump_flush(pl->pcap_dumper);
long in_size = ftell(comp->pcap_buf_wrapper);
if (in_size < 0) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS, "ftell failed with: %s", strerror(errno));
+ SCLogError("ftell failed with: %s", strerror(errno));
return TM_ECODE_FAILED;
}
uint64_t out_size = LZ4F_compressUpdate(comp->lz4f_context, comp->buffer, comp->buffer_size,
comp->pcap_buf, (uint64_t)in_size, NULL);
if (LZ4F_isError(len)) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS, "LZ4F_compressUpdate: %s", LZ4F_getErrorName(len));
+ SCLogError("LZ4F_compressUpdate: %s", LZ4F_getErrorName(len));
return TM_ECODE_FAILED;
}
if (fseek(pl->compression.pcap_buf_wrapper, 0, SEEK_SET) != 0) {
- SCLogError(SC_ERR_FSEEK, "fseek failed: %s", strerror(errno));
+ SCLogError("fseek failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
if (fwrite(comp->buffer, 1, out_size, comp->file) < out_size) {
- SCLogError(SC_ERR_FWRITE, "fwrite failed: %s", strerror(errno));
+ SCLogError("fwrite failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
if (out_size > 0) {
copy_comp->buffer = SCMalloc(copy_comp->buffer_size);
if (copy_comp->buffer == NULL) {
- SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
+ SCLogError("SCMalloc failed: %s", strerror(errno));
SCFree(copy->h);
SCFree(copy);
return NULL;
}
copy_comp->pcap_buf = SCMalloc(copy_comp->pcap_buf_size);
if (copy_comp->pcap_buf == NULL) {
- SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
+ SCLogError("SCMalloc failed: %s", strerror(errno));
SCFree(copy_comp->buffer);
SCFree(copy->h);
SCFree(copy);
copy_comp->pcap_buf_wrapper = SCFmemopen(copy_comp->pcap_buf,
copy_comp->pcap_buf_size, "w");
if (copy_comp->pcap_buf_wrapper == NULL) {
- SCLogError(SC_ERR_FOPEN, "SCFmemopen failed: %s", strerror(errno));
+ SCLogError("SCFmemopen failed: %s", strerror(errno));
SCFree(copy_comp->buffer);
SCFree(copy_comp->pcap_buf);
SCFree(copy->h);
LZ4F_errorCode_t errcode =
LZ4F_createCompressionContext(©_comp->lz4f_context, 1);
if (LZ4F_isError(errcode)) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS,
- "LZ4F_createCompressionContext failed: %s",
- LZ4F_getErrorName(errcode));
+ SCLogError("LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
fclose(copy_comp->pcap_buf_wrapper);
SCFree(copy_comp->buffer);
SCFree(copy_comp->pcap_buf);
}
switch (part[1]) {
case 'i':
- SCLogError(
- SC_ERR_INVALID_ARGUMENT, "Thread ID not allowed in ring buffer mode.");
+ SCLogError("Thread ID not allowed in ring buffer mode.");
return TM_ECODE_FAILED;
case 'n': {
char tmp[PATH_MAX];
strlcat(pattern, "*", PATH_MAX);
break;
default:
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Unsupported format character: %%%s", part);
+ SCLogError("Unsupported format character: %%%s", part);
return TM_ECODE_FAILED;
}
}
/* Pattern is now just the directory name. */
DIR *dir = opendir(pattern);
if (dir == NULL) {
- SCLogWarning(SC_ERR_DIR_OPEN, "Failed to open directory %s: %s",
- pattern, strerror(errno));
+ SCLogWarning("Failed to open directory %s: %s", pattern, strerror(errno));
return TM_ECODE_FAILED;
}
while (pf != NULL && pl->file_cnt > pl->max_files) {
SCLogDebug("Removing PCAP file %s", pf->filename);
if (remove(pf->filename) != 0) {
- SCLogWarning(SC_WARN_REMOVE_FILE,
- "Failed to remove PCAP file %s: %s", pf->filename,
- strerror(errno));
+ SCLogWarning("Failed to remove PCAP file %s: %s", pf->filename, strerror(errno));
}
TAILQ_REMOVE(&pl->pcap_file_list, pf, next);
PcapFileNameFree(pf);
if (DatalinkHasMultipleValues()) {
if (pl->mode != LOGMODE_MULTI) {
- FatalError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT,
- "Pcap logging with multiple link type is not supported.");
+ FatalError("Pcap logging with multiple link type is not supported.");
} else {
/* In multi mode, only pcap conditional is not supported as a flow timeout
* will trigger packet logging with potentially invalid datalink. In regular
switch (pl->conditional) {
case LOGMODE_COND_ALERTS:
case LOGMODE_COND_TAG:
- FatalError(SC_ERR_PCAP_MULTI_DEV_NO_SUPPORT,
- "Can't have multiple link types in pcap conditional mode.");
+ FatalError("Can't have multiple link types in pcap conditional mode.");
break;
default:
- SCLogWarning(SC_WARN_COMPATIBILITY,
- "Using multiple link types can result in invalid pcap output");
+ SCLogWarning("Using multiple link types can result in invalid pcap output");
}
}
}
LZ4F_errorCode_t errcode =
LZ4F_freeCompressionContext(pl->compression.lz4f_context);
if (LZ4F_isError(errcode)) {
- SCLogWarning(SC_EINVAL, "Error freeing lz4 context.");
+ SCLogWarning("Error freeing lz4 context.");
}
}
#endif /* HAVE_LIBLZ4 */
if (filename) {
filename_len = strlen(filename);
if (filename_len > (MAX_FILENAMELEN-1)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid filename option. Max filename-length: %d",MAX_FILENAMELEN-1);
+ SCLogError("invalid filename option. Max filename-length: %d", MAX_FILENAMELEN - 1);
goto error;
}
for (i = 0; i < (int)strlen(filename); i++) {
if (tok >= MAX_TOKS) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "invalid filename option. Max 2 %%-sign options");
+ SCLogError("invalid filename option. Max 2 %%-sign options");
goto error;
}
if (i+1 < (int)strlen(filename)) {
if (tok >= MAX_TOKS) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "invalid filename option. Max 2 %%-sign options");
+ SCLogError("invalid filename option. Max 2 %%-sign options");
goto error;
}
if (filename[i+1] != 'n' && filename[i+1] != 't' && filename[i+1] != 'i') {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
+ SCLogError(
"invalid filename option. Valid %%-sign options: %%n, %%i and %%t");
goto error;
}
}
if ((tok == 0) && (pl->mode == LOGMODE_MULTI)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Invalid filename for multimode. Need at list one %%-sign option");
+ SCLogError("Invalid filename for multimode. Need at list one %%-sign option");
goto error;
}
if (s) {
if (tok >= MAX_TOKS) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "invalid filename option. Max 3 %%-sign options");
+ SCLogError("invalid filename option. Max 3 %%-sign options");
goto error;
}
PcapLogData *pl = SCMalloc(sizeof(PcapLogData));
if (unlikely(pl == NULL)) {
- FatalError(SC_ERR_FATAL, "Failed to allocate Memory for PcapLogData");
+ FatalError("Failed to allocate Memory for PcapLogData");
}
memset(pl, 0, sizeof(PcapLogData));
pl->h = SCMalloc(sizeof(*pl->h));
if (pl->h == NULL) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate Memory for pcap header struct");
+ FatalError("Failed to allocate Memory for pcap header struct");
}
/* Set the defaults */
if (pcre_timestamp_code == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- FatalError(SC_ERR_PCRE_COMPILE, "Failed to compile \"%s\" at offset %d: %s",
- timestamp_pattern, (int)eo, errbuffer);
+ FatalError(
+ "Failed to compile \"%s\" at offset %d: %s", timestamp_pattern, (int)eo, errbuffer);
}
pcre_timestamp_match = pcre2_match_data_create_from_pattern(pcre_timestamp_code, NULL);
s_limit = ConfNodeLookupChildValue(conf, "limit");
if (s_limit != NULL) {
if (ParseSizeStringU64(s_limit, &pl->size_limit) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to initialize pcap output, invalid limit: %s",
- s_limit);
+ SCLogError("Failed to initialize pcap output, invalid limit: %s", s_limit);
exit(EXIT_FAILURE);
}
if (pl->size_limit < 4096) {
uint64_t size = pl->size_limit * 1024 * 1024;
pl->size_limit = size;
} else if (pl->size_limit < MIN_LIMIT) {
- FatalError(SC_ERR_FATAL,
- "Fail to initialize pcap-log output, limit less than "
- "allowed minimum.");
+ FatalError("Fail to initialize pcap-log output, limit less than "
+ "allowed minimum.");
}
}
}
} else if (strcasecmp(s_mode, "multi") == 0) {
pl->mode = LOGMODE_MULTI;
} else if (strcasecmp(s_mode, "normal") != 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "log-pcap: invalid mode \"%s\". Valid options: \"normal\", "
- "\"sguil\", or \"multi\" mode ", s_mode);
+ SCLogError("log-pcap: invalid mode \"%s\". Valid options: \"normal\", "
+ "\"sguil\", or \"multi\" mode ",
+ s_mode);
exit(EXIT_FAILURE);
}
}
}
if (s_dir == NULL) {
if (pl->mode == LOGMODE_SGUIL) {
- FatalError(SC_ERR_FATAL,
- "log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
- "option to be set.");
+ FatalError("log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
+ "option to be set.");
} else {
const char *log_dir = NULL;
log_dir = ConfigGetLogDirectory();
struct stat stat_buf;
if (stat(pl->dir, &stat_buf) != 0) {
- SCLogError(SC_ERR_LOGDIR_CONFIG, "The sguil-base-dir directory \"%s\" "
- "supplied doesn't exist. Shutting down the engine",
+ SCLogError("The sguil-base-dir directory \"%s\" "
+ "supplied doesn't exist. Shutting down the engine",
pl->dir);
exit(EXIT_FAILURE);
}
} else if (strcmp(compression_str, "lz4") == 0) {
#ifdef HAVE_LIBLZ4
if (pl->mode == LOGMODE_SGUIL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Compressed pcap "
- "logs are not possible in sguil mode");
+ SCLogError("Compressed pcap "
+ "logs are not possible in sguil mode");
SCFree(pl->h);
SCFree(pl);
return result;
sizeof(struct pcap_pkthdr) + PCAP_SNAPLEN;
comp->pcap_buf = SCMalloc(comp->pcap_buf_size);
if (comp->pcap_buf == NULL) {
- SCLogError(SC_ENOMEM, "SCMalloc failed: %s", strerror(errno));
+ SCLogError("SCMalloc failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
comp->pcap_buf_wrapper = SCFmemopen(comp->pcap_buf,
comp->pcap_buf_size, "w");
if (comp->pcap_buf_wrapper == NULL) {
- SCLogError(SC_ERR_FOPEN, "SCFmemopen failed: %s",
- strerror(errno));
+ SCLogError("SCFmemopen failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
LZ4F_createCompressionContext(&pl->compression.lz4f_context, 1);
if (LZ4F_isError(errcode)) {
- SCLogError(SC_ERR_PCAP_LOG_COMPRESS,
- "LZ4F_createCompressionContext failed: %s",
- LZ4F_getErrorName(errcode));
+ SCLogError("LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
exit(EXIT_FAILURE);
}
comp->buffer = SCMalloc(comp->buffer_size);
if (unlikely(comp->buffer == NULL)) {
- FatalError(SC_ERR_FATAL, "Failed to allocate memory for "
+ FatalError("Failed to allocate memory for "
"lz4 output buffer.");
}
pl->suffix = ".lz4";
#else
- SCLogError(SC_ERR_INVALID_ARGUMENT, "lz4 compression was selected "
- "in pcap-log, but suricata was not compiled with lz4 "
- "support.");
+ SCLogError("lz4 compression was selected "
+ "in pcap-log, but suricata was not compiled with lz4 "
+ "support.");
PcapLogDataFree(pl);
return result;
#endif /* HAVE_LIBLZ4 */
}
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Unsupported pcap-log "
- "compression format: %s", compression_str);
+ SCLogError("Unsupported pcap-log "
+ "compression format: %s",
+ compression_str);
PcapLogDataFree(pl);
return result;
}
pl->conditional = LOGMODE_COND_TAG;
EnableTcpSessionDumping();
} else if (strcasecmp(s_conditional, "all") != 0) {
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
- "\"alerts\", or \"tag\" mode ",
+ FatalError("log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
+ "\"alerts\", or \"tag\" mode ",
s_conditional);
}
}
if (max_number_of_files_s != NULL) {
if (StringParseUint32(&max_file_limit, 10, 0,
max_number_of_files_s) == -1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Failed to initialize "
+ SCLogError("Failed to initialize "
"pcap-log output, invalid number of files limit: %s",
- max_number_of_files_s);
+ max_number_of_files_s);
exit(EXIT_FAILURE);
} else if (max_file_limit < 1) {
- FatalError(SC_ERR_FATAL,
- "Failed to initialize pcap-log output, limit less than "
- "allowed minimum.");
+ FatalError("Failed to initialize pcap-log output, limit less than "
+ "allowed minimum.");
} else {
pl->max_files = max_file_limit;
pl->use_ringbuffer = RING_BUFFER_MODE_ENABLED;
if (strcasecmp(ts_format, "usec") == 0) {
pl->timestamp_format = TS_FORMAT_USEC;
} else if (strcasecmp(ts_format, "sec") != 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "log-pcap ts_format specified %s is invalid must be"
- " \"sec\" or \"usec\"", ts_format);
+ SCLogError("log-pcap ts_format specified %s is invalid must be"
+ " \"sec\" or \"usec\"",
+ ts_format);
exit(EXIT_FAILURE);
}
}
} else if (ConfValIsTrue(use_stream_depth)) {
pl->use_stream_depth = USE_STREAM_DEPTH_ENABLED;
} else {
- FatalError(SC_ERR_FATAL,
- "log-pcap use_stream_depth specified is invalid must be");
+ FatalError("log-pcap use_stream_depth specified is invalid must be");
}
}
} else if (ConfValIsTrue(honor_pass_rules)) {
pl->honor_pass_rules = HONOR_PASS_RULES_ENABLED;
} else {
- FatalError(SC_ERR_FATAL,
- "log-pcap honor-pass-rules specified is invalid");
+ FatalError("log-pcap honor-pass-rules specified is invalid");
}
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
if (unlikely(output_ctx == NULL)) {
- FatalError(SC_ERR_FATAL, "Failed to allocate memory for OutputCtx.");
+ FatalError("Failed to allocate memory for OutputCtx.");
}
output_ctx->data = pl;
output_ctx->DeInit = PcapLogFileDeInitCtx;
/* create the filename to use */
int ret = snprintf(dirfull, sizeof(dirfull), "%s/%s", pl->dir, dirname);
if (ret < 0 || (size_t)ret >= sizeof(dirfull)) {
- SCLogError(SC_ERR_SPRINTF,"failed to construct path");
+ SCLogError("failed to construct path");
goto error;
}
(void)SCMkDir(dirfull, 0700);
if ((pf->dirname = SCStrdup(dirfull)) == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory for "
- "directory name");
+ SCLogError("Error allocating memory for "
+ "directory name");
goto error;
}
(uint32_t)ts.tv_usec, pl->suffix);
}
if (written == PATH_MAX) {
- SCLogError(SC_ERR_SPRINTF,"log-pcap path overflow");
+ SCLogError("log-pcap path overflow");
goto error;
}
} else if (pl->mode == LOGMODE_NORMAL) {
(uint32_t)ts.tv_sec, (uint32_t)ts.tv_usec, pl->suffix);
}
if (ret < 0 || (size_t)ret >= PATH_MAX) {
- SCLogError(SC_ERR_SPRINTF,"failed to construct path");
+ SCLogError("failed to construct path");
goto error;
}
} else if (pl->mode == LOGMODE_MULTI) {
(uint32_t)ts.tv_usec, pl->suffix);
}
if (ret < 0 || (size_t)ret >= PATH_MAX) {
- SCLogError(SC_ERR_SPRINTF,"failed to construct path");
+ SCLogError("failed to construct path");
goto error;
}
}
}
if ((pf->filename = SCStrdup(pl->filename)) == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory. For filename");
+ SCLogError("Error allocating memory. For filename");
goto error;
}
SCLogDebug("Opening pcap file log %s", pf->filename);
if (profiling_pcaplog_output_to_file == 1) {
fp = fopen(profiling_pcaplog_file_name, profiling_pcaplog_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s",
- profiling_pcaplog_file_name, strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_pcaplog_file_name, strerror(errno));
return;
}
} else {
profiling_pcaplog_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_pcaplog_file_name == NULL)) {
- FatalError(SC_ERR_FATAL, "can't duplicate file name");
+ FatalError("can't duplicate file name");
}
snprintf(profiling_pcaplog_file_name, PATH_MAX, "%s/%s", log_dir, filename);
OutputInitResult result = { NULL, false };
LogFileCtx *file_ctx = LogFileNewCtx();
if (file_ctx == NULL) {
- SCLogError(SC_ERR_STATS_LOG_GENERIC, "couldn't create new file_ctx");
+ SCLogError("couldn't create new file_ctx");
return result;
}
(threads != NULL && ConfValIsFalse(threads))) {
LogFileFreeCtx(file_ctx);
SCFree(statslog_ctx);
- SCLogError(SC_ERR_STATS_LOG_NEGATED,
- "Cannot disable both totals and threads in stats logging");
+ SCLogError("Cannot disable both totals and threads in stats logging");
return result;
}
LogFileCtx *file_ctx = LogFileNewCtx();
if(file_ctx == NULL) {
- SCLogError(SC_ERR_TCPDATA_LOG_GENERIC, "couldn't create new file_ctx");
+ SCLogError("couldn't create new file_ctx");
return result;
}
parsererror:
LogFileFreeCtx(file_ctx);
SCFree(tcpdatalog_ctx);
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Syntax error in custom http log format string.");
+ SCLogError("Syntax error in custom http log format string.");
return result;
}
LogFileCtx* file_ctx = LogFileNewCtx();
if (file_ctx == NULL) {
- SCLogError(SC_ERR_TLS_LOG_GENERIC, "LogTlsLogInitCtx: Couldn't "
+ SCLogError("LogTlsLogInitCtx: Couldn't "
"create new file_ctx");
return result;
}
return result;
parser_error:
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Syntax error in custom tls log "
+ SCLogError("Syntax error in custom tls log "
"format string.");
tlslog_error:
LogCustomFormatFree(tlslog_ctx->cf);
CreateFileName(p, state, filename, sizeof(filename));
if (strlen(filename) == 0) {
- SCLogWarning(SC_ERR_FOPEN, "Can't create PEM filename");
+ SCLogWarning("Can't create PEM filename");
SCReturn;
}
fp = fopen(filename, "w");
if (fp == NULL) {
if (logging_dir_not_writable < LOGGING_WRITE_ISSUE_LIMIT) {
- SCLogWarning(SC_ERR_FOPEN,
- "Can't create PEM file '%s' in '%s' directory",
- filename, tls_logfile_base_dir);
+ SCLogWarning(
+ "Can't create PEM file '%s' in '%s' directory", filename, tls_logfile_base_dir);
logging_dir_not_writable++;
}
SCReturn;
SCFree(aft->enc_buf);
aft->enc_buf = NULL;
aft->enc_buf_len = 0;
- SCLogWarning(SC_ENOMEM, "Can't allocate data for base64 encoding");
+ SCLogWarning("Can't allocate data for base64 encoding");
goto end_fp;
}
aft->enc_buf = ptmp;
ret = Base64Encode((unsigned char*) cert->cert_data, cert->cert_len, aft->enc_buf, &pemlen);
if (ret != SC_BASE64_OK) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "Invalid return of Base64Encode function");
+ SCLogWarning("Invalid return of Base64Encode function");
goto end_fwrite_fp;
}
fclose(fpmeta);
} else {
if (logging_dir_not_writable < LOGGING_WRITE_ISSUE_LIMIT) {
- SCLogWarning(SC_ERR_FOPEN,
- "Can't create meta file '%s' in '%s' directory",
- filename, tls_logfile_base_dir);
+ SCLogWarning("Can't create meta file '%s' in '%s' directory", filename,
+ tls_logfile_base_dir);
logging_dir_not_writable++;
}
SCReturn;
end_fwrite_fp:
fclose(fp);
if (logging_dir_not_writable < LOGGING_WRITE_ISSUE_LIMIT) {
- SCLogWarning(SC_ERR_FWRITE, "Unable to write certificate");
+ SCLogWarning("Unable to write certificate");
logging_dir_not_writable++;
}
end_fwrite_fpmeta:
if (fpmeta) {
fclose(fpmeta);
if (logging_dir_not_writable < LOGGING_WRITE_ISSUE_LIMIT) {
- SCLogWarning(SC_ERR_FWRITE, "Unable to write certificate metafile");
+ SCLogWarning("Unable to write certificate metafile");
logging_dir_not_writable++;
}
}
if (ret != 0) {
int err = errno;
if (err != EEXIST) {
- SCLogError(SC_ERR_LOGDIR_CONFIG,
- "Cannot create certs drop directory %s: %s",
- tls_logfile_base_dir, strerror(err));
+ SCLogError("Cannot create certs drop directory %s: %s", tls_logfile_base_dir,
+ strerror(err));
exit(EXIT_FAILURE);
}
} else {
{
Context *context = SCCalloc(1, sizeof(Context));
if (context == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate context for %s", OUTPUT_NAME);
+ SCLogError("Unable to allocate context for %s", OUTPUT_NAME);
return -1;
}
const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
int facility = SCMapEnumNameToValue(facility_s, SCSyslogGetFacilityMap());
if (facility == -1) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Invalid syslog facility: \"%s\","
- " now using \"%s\" as syslog facility",
+ SCLogWarning("Invalid syslog facility: \"%s\","
+ " now using \"%s\" as syslog facility",
facility_s, DEFAULT_ALERT_SYSLOG_FACILITY_STR);
facility = DEFAULT_ALERT_SYSLOG_FACILITY;
}
SCEveFileType *file_type = SCCalloc(1, sizeof(SCEveFileType));
if (file_type == NULL) {
- FatalError(SC_ENOMEM, "Unable to allocate memory for eve file type %s", OUTPUT_NAME);
+ FatalError("Unable to allocate memory for eve file type %s", OUTPUT_NAME);
}
file_type->name = OUTPUT_NAME;
file_type->Deinit = SyslogDeInit;
file_type->Write = SyslogWrite;
if (!SCRegisterEveFileType(file_type)) {
- FatalError(SC_ERR_LOG_OUTPUT, "Failed to register EVE file type: %s", OUTPUT_NAME);
+ FatalError("Failed to register EVE file type: %s", OUTPUT_NAME);
}
}
#endif /* !OS_WIN32 */
uint16_t fs_error_counter;
} OutputFilestoreLogThread;
+enum WarnOnceTypes {
+ WOT_OPEN,
+ WOT_WRITE,
+ WOT_UNLINK,
+ WOT_RENAME,
+ WOT_SNPRINTF,
+
+ WOT_MAX,
+};
+
/* For WARN_ONCE, a record of warnings that have already been
* issued. */
-static thread_local bool once_errs[SC_ERR_MAX];
-
-#define WARN_ONCE(err_code, ...) do { \
- if (!once_errs[err_code]) { \
- once_errs[err_code] = true; \
- SCLogWarning(err_code, __VA_ARGS__); \
- } \
+static thread_local bool once_errs[WOT_MAX];
+
+#define WARN_ONCE(wot_type, ...) \
+ do { \
+ if (!once_errs[wot_type]) { \
+ once_errs[wot_type] = true; \
+ SCLogWarning(__VA_ARGS__); \
+ } \
} while (0)
static uint64_t OutputFilestoreOpenFilesCounter(void)
OutputFilestoreUpdateFileTime(tmp_filename, final_filename);
if (unlink(tmp_filename) != 0) {
StatsIncr(tv, oft->fs_error_counter);
- WARN_ONCE(SC_WARN_REMOVE_FILE,
- "Failed to remove temporary file %s: %s", tmp_filename,
+ WARN_ONCE(WOT_UNLINK, "Failed to remove temporary file %s: %s", tmp_filename,
strerror(errno));
}
} else if (rename(tmp_filename, final_filename) != 0) {
StatsIncr(tv, oft->fs_error_counter);
- WARN_ONCE(SC_WARN_RENAMING_FILE, "Failed to rename %s to %s: %s",
- tmp_filename, final_filename, strerror(errno));
+ WARN_ONCE(WOT_RENAME, "Failed to rename %s to %s: %s", tmp_filename, final_filename,
+ strerror(errno));
if (unlink(tmp_filename) != 0) {
/* Just increment, don't log as has_fs_errors would
* already be set above. */
"%s.%"PRIuMAX".%u.json", final_filename,
(uintmax_t)p->ts.tv_sec, ff->file_store_id)
== (int)sizeof(js_metadata_filename)) {
- WARN_ONCE(SC_ERR_SPRINTF,
- "Failed to write file info record. Output filename truncated.");
+ WARN_ONCE(WOT_SNPRINTF, "Failed to write file info record. Output filename truncated.");
} else {
JsonBuilder *js_fileinfo =
JsonBuildFileInfoRecord(p, ff, tx, tx_id, true, dir, ctx->xff_cfg, NULL);
0644);
if (file_fd == -1) {
StatsIncr(tv, aft->fs_error_counter);
- SCLogWarning(SC_ERR_OPENING_FILE,
- "Filestore (v2) failed to create %s: %s", filename,
- strerror(errno));
+ SCLogWarning("Filestore (v2) failed to create %s: %s", filename, strerror(errno));
return -1;
}
file_fd = open(filename, O_APPEND | O_NOFOLLOW | O_WRONLY);
if (file_fd == -1) {
StatsIncr(tv, aft->fs_error_counter);
- WARN_ONCE(SC_ERR_OPENING_FILE,
- "Filestore (v2) failed to open file %s: %s",
- filename, strerror(errno));
+ WARN_ONCE(WOT_OPEN, "Filestore (v2) failed to open file %s: %s", filename,
+ strerror(errno));
return -1;
}
} else {
ssize_t r = write(file_fd, (const void *)data, (size_t)data_len);
if (r == -1) {
StatsIncr(tv, aft->fs_error_counter);
- WARN_ONCE(SC_ERR_FWRITE,
- "Filestore (v2) failed to write to %s: %s",
- filename, strerror(errno));
+ WARN_ONCE(WOT_WRITE, "Filestore (v2) failed to write to %s: %s", filename,
+ strerror(errno));
if (ff->fd != -1) {
SC_ATOMIC_SUB(filestore_open_file_cnt, 1);
}
if (!SCPathExists(dir)) {
SCLogInfo("Filestore (v2) creating directory %s", dir);
if (SCCreateDirectoryTree(dir, true) != 0) {
- SCLogError(SC_ERR_CREATE_DIRECTORY,
- "Filestore (v2) failed to create directory %s: %s", dir,
- strerror(errno));
+ SCLogError("Filestore (v2) failed to create directory %s: %s", dir, strerror(errno));
return false;
}
}
char leaf[PATH_MAX];
int n = snprintf(leaf, sizeof(leaf), "%s/%02x", dir, i);
if (n < 0 || n >= PATH_MAX) {
- SCLogError(SC_ERR_CREATE_DIRECTORY,
- "Filestore (v2) failed to create leaf directory: "
- "path too long");
+ SCLogError("Filestore (v2) failed to create leaf directory: "
+ "path too long");
return false;
}
if (!SCPathExists(leaf)) {
SCLogInfo("Filestore (v2) creating directory %s", leaf);
if (SCDefaultMkDir(leaf) != 0) {
- SCLogError(SC_ERR_CREATE_DIRECTORY,
- "Filestore (v2) failed to create directory %s: %s",
- leaf, strerror(errno));
+ SCLogError(
+ "Filestore (v2) failed to create directory %s: %s", leaf, strerror(errno));
return false;
}
}
char tmpdir[PATH_MAX];
int n = snprintf(tmpdir, sizeof(tmpdir), "%s/tmp", dir);
if (n < 0 || n >= PATH_MAX) {
- SCLogError(SC_ERR_CREATE_DIRECTORY,
- "Filestore (v2) failed to create tmp directory: path too long");
+ SCLogError("Filestore (v2) failed to create tmp directory: path too long");
return false;
}
if (!SCPathExists(tmpdir)) {
SCLogInfo("Filestore (v2) creating directory %s", tmpdir);
if (SCDefaultMkDir(tmpdir) != 0) {
- SCLogError(SC_ERR_CREATE_DIRECTORY,
- "Filestore (v2) failed to create directory %s: %s", tmpdir,
- strerror(errno));
+ SCLogError("Filestore (v2) failed to create directory %s: %s", tmpdir, strerror(errno));
return false;
}
}
intmax_t version = 0;
if (!ConfGetChildValueInt(conf, "version", &version) || version < 2) {
- SCLogWarning(SC_WARN_DEPRECATED,
- "File-store v1 has been removed. Please update to file-store v2.");
+ SCLogWarning("File-store v1 has been removed. Please update to file-store v2.");
return result;
}
if (RunModeOutputFiledataEnabled()) {
- SCLogWarning(SC_ERR_NOT_SUPPORTED,
- "A file data logger is already enabled. Filestore (v2) "
- "will not be enabled.");
+ SCLogWarning("A file data logger is already enabled. Filestore (v2) "
+ "will not be enabled.");
return result;
}
int written = snprintf(ctx->tmpdir, sizeof(ctx->tmpdir) - 1, "%s/tmp",
log_directory);
if (written == sizeof(ctx->tmpdir)) {
- SCLogError(SC_ERR_SPRINTF, "File-store output directory overflow.");
+ SCLogError("File-store output directory overflow.");
SCFree(ctx);
return result;
}
uint32_t stream_depth = 0;
if (ParseSizeStringU32(stream_depth_str,
&stream_depth) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"file-store.stream-depth "
"from conf file - %s. Killing engine",
- stream_depth_str);
+ stream_depth_str);
exit(EXIT_FAILURE);
}
if (stream_depth) {
if (stream_depth <= stream_config.reassembly_depth) {
- SCLogWarning(SC_WARN_FILESTORE_CONFIG,
- "file-store.stream-depth value %" PRIu32 " has "
- "no effect since it's less than stream.reassembly.depth "
- "value.", stream_depth);
+ SCLogWarning("file-store.stream-depth value %" PRIu32 " has "
+ "no effect since it's less than stream.reassembly.depth "
+ "value.",
+ stream_depth);
} else {
FileReassemblyDepthEnable(stream_depth);
}
uint32_t file_count = 0;
if (ParseSizeStringU32(file_count_str,
&file_count) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"file-store.max-open-files "
"from conf file - %s. Killing engine",
- file_count_str);
+ file_count_str);
exit(EXIT_FAILURE);
} else {
if (file_count != 0) {
if (payload_buffer_value != NULL) {
uint32_t value;
if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
- SCLogError(SC_ERR_ALERT_PAYLOAD_BUFFER, "Error parsing "
+ SCLogError("Error parsing "
"payload-buffer-size - %s. Killing engine",
- payload_buffer_value);
+ payload_buffer_value);
exit(EXIT_FAILURE);
} else {
payload_buffer_size = value;
if (!warn_no_meta && flags & JSON_BODY_LOGGING) {
if (((flags & LOG_JSON_APP_LAYER) == 0)) {
- SCLogWarning(SC_WARN_ALERT_CONFIG, "HTTP body logging has been configured, however, "
- "metadata logging has not been enabled. HTTP body logging will be disabled.");
+ SCLogWarning("HTTP body logging has been configured, however, "
+ "metadata logging has not been enabled. HTTP body logging will be "
+ "disabled.");
flags &= ~JSON_BODY_LOGGING;
warn_no_meta = true;
}
SetFlag(conf, "packethdr", LOG_JSON_PACKETHDR, &flags);
}
if (((flags & (LOG_JSON_DECODE_TYPE | LOG_JSON_PACKETHDR)) == LOG_JSON_PACKETHDR) && !warn_no_packet) {
- SCLogWarning(SC_WARN_ANOMALY_CONFIG, "Anomaly logging configured to include packet headers, however decode "
+ SCLogWarning("Anomaly logging configured to include packet headers, however decode "
"type logging has not been selected. Packet headers will not be logged.");
warn_no_packet = true;
flags &= ~LOG_JSON_PACKETHDR;
}
if (flags == 0 && !warn_no_flags) {
- SCLogWarning(SC_WARN_ANOMALY_CONFIG, "Anomaly logging has been configured; however, no logging types "
+ SCLogWarning("Anomaly logging has been configured; however, no logging types "
"have been selected. Select one or more logging types.");
warn_no_flags = true;
}
if (!OutputAnomalyLoggerEnable()) {
OutputInitResult result = { NULL, false };
- SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'anomaly' logger "
- "can be enabled");
+ SCLogError("only one 'anomaly' logger "
+ "can be enabled");
return result;
}
break;
case 1:
if (!v1_deprecation_warned) {
- SCLogError(SC_WARN_DEPRECATED,
- "DNS EVE v1 logging has been removed, will use v2");
+ SCLogError("DNS EVE v1 logging has been removed, will use v2");
v1_deprecation_warned = true;
}
break;
invalid = true;
}
if (invalid) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid EVE DNS version \"%s\", will use v2",
- has_version->val);
+ SCLogWarning("Invalid EVE DNS version \"%s\", will use v2", has_version->val);
}
}
}
{
OutputInitResult result = { NULL, false };
if (OutputDropLoggerEnable() != 0) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
- "can be enabled");
+ SCLogError("only one 'drop' logger "
+ "can be enabled");
return result;
}
} else if (strcasecmp(extended, "all") == 0) {
g_droplog_flows_start = 0;
} else {
- SCLogWarning(SC_ERR_CONF_YAML_ERROR, "valid options for "
- "'flow' are 'start' and 'all'");
+ SCLogWarning("valid options for "
+ "'flow' are 'start' and 'all'");
}
}
}
break;
#endif
default:
- SCLogError(SC_EINVAL, "Invalid flow state: %d, contact developers", flow_state);
+ SCLogError("Invalid flow state: %d, contact developers", flow_state);
}
}
OutputJsonCtx *ajt = parent_ctx->data;
if (!StatsEnabled()) {
- SCLogError(SC_ERR_STATS_LOG_GENERIC,
- "eve.stats: stats are disabled globally: set stats.enabled to true. "
- "See %s/configuration/suricata-yaml.html#stats", GetDocURL());
+ SCLogError("eve.stats: stats are disabled globally: set stats.enabled to true. "
+ "See %s/configuration/suricata-yaml.html#stats",
+ GetDocURL());
return result;
}
if (stats_decoder_events &&
strcmp(stats_decoder_events_prefix, "decoder") == 0) {
- SCLogWarning(SC_WARN_EVE_MISSING_EVENTS,
- "eve.stats will not display "
- "all decoder events correctly. See ticket #2225. Set a prefix in "
- "stats.decoder-events-prefix.");
+ SCLogWarning("eve.stats will not display "
+ "all decoder events correctly. See ticket #2225. Set a prefix in "
+ "stats.decoder-events-prefix.");
}
stats_ctx->flags = JSON_STATS_TOTALS;
if ((totals != NULL && ConfValIsFalse(totals)) &&
(threads != NULL && ConfValIsFalse(threads))) {
SCFree(stats_ctx);
- SCLogError(SC_ERR_JSON_STATS_LOG_NEGATED,
- "Cannot disable both totals and threads in stats logging");
+ SCLogError("Cannot disable both totals and threads in stats logging");
return result;
}
}
}
if (!valid) {
- SCLogWarning(SC_ERR_LOG_OUTPUT, "eve.tls: unknown 'custom' field '%s'", field->val);
+ SCLogWarning("eve.tls: unknown 'custom' field '%s'", field->val);
}
}
}
if ((tls_ctx->fields & LOG_TLS_FIELD_CERTIFICATE) &&
(tls_ctx->fields & LOG_TLS_FIELD_CHAIN)) {
- SCLogWarning(SC_WARN_DUPLICATE_OUTPUT,
- "Both 'certificate' and 'chain' contains the top "
+ SCLogWarning("Both 'certificate' and 'chain' contains the top "
"certificate, so only one of them should be enabled "
"at a time");
}
if ((tls_ctx->fields & LOG_TLS_FIELD_CLIENT_CERT) &&
(tls_ctx->fields & LOG_TLS_FIELD_CLIENT_CHAIN)) {
- SCLogWarning(SC_WARN_DUPLICATE_OUTPUT,
- "Both 'client_certificate' and 'client_chain' contains the top "
- "certificate, so only one of them should be enabled "
- "at a time");
+ SCLogWarning("Both 'client_certificate' and 'client_chain' contains the top "
+ "certificate, so only one of them should be enabled "
+ "at a time");
}
if ((tls_ctx->fields & LOG_TLS_FIELD_CLIENT) == 0) {
if ((tls_ctx->fields & LOG_TLS_FIELD_CERTIFICATE) &&
(tls_ctx->fields & LOG_TLS_FIELD_CHAIN)) {
- SCLogWarning(SC_WARN_DUPLICATE_OUTPUT,
- "Both 'certificate' and 'chain' contains the top "
+ SCLogWarning("Both 'certificate' and 'chain' contains the top "
"certificate, so only one of them should be enabled "
"at a time");
}
#ifdef HAVE_LIBHIREDIS
log_filetype = LOGFILE_TYPE_REDIS;
#else
- FatalError(SC_ERR_FATAL, "redis JSON output option is not compiled");
+ FatalError("redis JSON output option is not compiled");
#endif
}
SCLogDebug("type %s, file type value %d", typestr, log_filetype);
* node (deprecated). If that fails, lookup the global one. */
const char *sensor_name = ConfNodeLookupChildValue(conf, "sensor-name");
if (sensor_name != NULL) {
- SCLogWarning(SC_ERR_DEPRECATED_CONF,
- "Found deprecated eve-log setting \"sensor-name\". "
- "Please set sensor-name globally.");
+ SCLogWarning("Found deprecated eve-log setting \"sensor-name\". "
+ "Please set sensor-name globally.");
}
else {
(void)ConfGet("sensor-name", &sensor_name);
json_ctx->plugin = plugin;
} else
#endif
- FatalError(SC_ERR_INVALID_ARGUMENT, "Invalid JSON output option: %s", output_s);
+ FatalError("Invalid JSON output option: %s", output_s);
}
const char *prefix = ConfNodeLookupChildValue(conf, "prefix");
json_ctx->file_ctx->prefix = SCStrdup(prefix);
if (json_ctx->file_ctx->prefix == NULL)
{
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for eve-log.prefix setting.");
+ FatalError("Failed to allocate memory for eve-log.prefix setting.");
}
json_ctx->file_ctx->prefix_len = strlen(prefix);
}
const char *sensor_id_s = ConfNodeLookupChildValue(conf, "sensor-id");
if (sensor_id_s != NULL) {
if (StringParseUint64((uint64_t *)&sensor_id, 10, 0, sensor_id_s) < 0) {
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "Failed to initialize JSON output, "
- "invalid sensor-id: %s",
+ FatalError("Failed to initialize JSON output, "
+ "invalid sensor-id: %s",
sensor_id_s);
}
}
if (StringParseUint16(&json_ctx->cfg.community_id_seed,
10, 0, cid_seed) < 0)
{
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "Failed to initialize JSON output, "
- "invalid community-id-seed: %s",
+ FatalError("Failed to initialize JSON output, "
+ "invalid community-id-seed: %s",
cid_seed);
}
}
OutputJsonCtx *json_ctx = (OutputJsonCtx *)output_ctx->data;
LogFileCtx *logfile_ctx = json_ctx->file_ctx;
if (logfile_ctx->dropped) {
- SCLogWarning(SC_WARN_EVENT_DROPPED,
- "%"PRIu64" events were dropped due to slow or "
- "disconnected socket", logfile_ctx->dropped);
+ SCLogWarning("%" PRIu64 " events were dropped due to slow or "
+ "disconnected socket",
+ logfile_ctx->dropped);
}
if (json_ctx->xff_cfg != NULL) {
SCFree(json_ctx->xff_cfg);
int status = luaL_loadfile(luastate, filename);
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(luastate, -1));
goto error;
}
/* prime the script (or something) */
if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't prime file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't prime file: %s", lua_tostring(luastate, -1));
goto error;
}
lua_getglobal(luastate, "init");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no init function in script");
+ SCLogError("no init function in script");
goto error;
}
lua_newtable(luastate); /* stack at -1 */
if (lua_gettop(luastate) == 0 || lua_type(luastate, 2) != LUA_TTABLE) {
- SCLogError(SC_ERR_LUA_ERROR, "no table setup");
+ SCLogError("no table setup");
goto error;
}
lua_settable(luastate, -3);
if (lua_pcall(luastate, 1, 1, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't run script 'init' function: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't run script 'init' function: %s", lua_tostring(luastate, -1));
goto error;
}
/* process returns from script */
if (lua_gettop(luastate) == 0) {
- SCLogError(SC_ERR_LUA_ERROR, "init function in script should return table, nothing returned");
+ SCLogError("init function in script should return table, nothing returned");
goto error;
}
if (lua_type(luastate, 1) != LUA_TTABLE) {
- SCLogError(SC_ERR_LUA_ERROR, "init function in script should return table, returned is not table");
+ SCLogError("init function in script should return table, returned is not table");
goto error;
}
}
if (((options->alproto != ALPROTO_UNKNOWN)) + options->packet + options->file > 1) {
- SCLogError(SC_ERR_LUA_ERROR, "invalid combination of 'needs' in the script");
+ SCLogError("invalid combination of 'needs' in the script");
goto error;
}
lua_getglobal(luastate, "setup");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no setup function in script");
+ SCLogError("no setup function in script");
goto error;
}
lua_getglobal(luastate, "log");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no log function in script");
+ SCLogError("no log function in script");
goto error;
}
lua_getglobal(luastate, "deinit");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no deinit function in script");
+ SCLogError("no deinit function in script");
goto error;
}
{
lua_State *luastate = LuaGetState();
if (luastate == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "luaL_newstate failed");
+ SCLogError("luaL_newstate failed");
goto error;
}
int status = luaL_loadfile(luastate, filename);
if (status) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't load file: %s", lua_tostring(luastate, -1));
goto error;
}
/* prime the script */
if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't prime file: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't prime file: %s", lua_tostring(luastate, -1));
goto error;
}
LuaRegisterSmtpFunctions(luastate);
if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't run script 'setup' function: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't run script 'setup' function: %s", lua_tostring(luastate, -1));
goto error;
}
char path[PATH_MAX] = "";
int ret = snprintf(path, sizeof(path),"%s%s%s", dir, strlen(dir) ? "/" : "", conf->val);
if (ret < 0 || ret == sizeof(path)) {
- SCLogError(SC_ERR_SPRINTF,"failed to construct lua script path");
+ SCLogError("failed to construct lua script path");
goto error;
}
SCLogDebug("script full path %s", path);
int r = LuaScriptInit(path, &opts);
if (r != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't initialize script");
+ SCLogError("couldn't initialize script");
goto error;
}
* on it's needs. */
OutputModule *om = SCCalloc(1, sizeof(*om));
if (om == NULL) {
- SCLogError(SC_ENOMEM, "calloc() failed");
+ SCLogError("calloc() failed");
goto error;
}
} else if (opts.stats) {
om->StatsLogFunc = LuaStatsLogger;
} else {
- SCLogError(SC_ERR_LUA_ERROR, "failed to setup thread module");
+ SCLogError("failed to setup thread module");
SCFree(om);
goto error;
}
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
- FatalError(SC_ERR_FATAL,
- "Error during setup of lua output. Details should be "
- "described in previous error messages. Shutting down...");
+ FatalError("Error during setup of lua output. Details should be "
+ "described in previous error messages. Shutting down...");
}
return result;
lua_getglobal(luastate, "deinit");
if (lua_type(luastate, -1) != LUA_TFUNCTION) {
- SCLogError(SC_ERR_LUA_ERROR, "no deinit function in script");
+ SCLogError("no deinit function in script");
return;
}
//LuaPrintStack(luastate);
if (lua_pcall(luastate, 0, 0, 0) != 0) {
- SCLogError(SC_ERR_LUA_ERROR, "couldn't run script 'deinit' function: %s", lua_tostring(luastate, -1));
+ SCLogError("couldn't run script 'deinit' function: %s", lua_tostring(luastate, -1));
return;
}
LuaReturnState(luastate);
while (t->next)
t = t->next;
if (t->id * 2 > UINT32_MAX) {
- FatalError(SC_ERR_FATAL, "Too many loggers registered.");
+ FatalError("Too many loggers registered.");
}
op->id = t->id * 2;
t->next = op;
if (g_file_logger_enabled) {
if (OutputFileLogThreadInit(tv, &td->file) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "failed to set up file thread data");
+ FatalError("failed to set up file thread data");
}
}
if (g_filedata_logger_enabled) {
if (OutputFiledataLogThreadInit(tv, &td->filedata) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "failed to set up filedata thread data");
+ FatalError("failed to set up filedata thread data");
}
}
return;
error:
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in OutputRegisterModule. Exiting...");
+ FatalError("Fatal error encountered in OutputRegisterModule. Exiting...");
}
/**
SCLogDebug("Packet logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Packet logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Tx logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name,
SCLogDebug("Tx logger for alproto %d \"%s\" registered.", alproto, name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("File logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("File logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Filedata logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Filedata logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Flow logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Streaming logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Streaming logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Stats logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Stats logger \"%s\" registered.", name);
return;
error:
- FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
+ FatalError("Fatal error encountered. Exiting...");
}
/**
{
OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
if (unlikely(flag_entry == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate memory to register file rotation flag");
+ SCLogError("Failed to allocate memory to register file rotation flag");
return;
}
flag_entry->flag = flag;
RootLogger *logger = SCCalloc(1, sizeof(*logger));
if (logger == NULL) {
- FatalError(SC_ENOMEM, "failed to alloc root logger");
+ FatalError("failed to alloc root logger");
}
logger->ThreadInit = ThreadInit;
logger->ThreadDeinit = ThreadDeinit;
{
RootLogger *logger = SCCalloc(1, sizeof(*logger));
if (logger == NULL) {
- FatalError(SC_ENOMEM, "failed to alloc root logger");
+ FatalError("failed to alloc root logger");
}
logger->ThreadInit = reg->ThreadInit;
logger->ThreadDeinit = reg->ThreadDeinit;
{
SReputation *user_data = NULL;
if ((user_data = SCMalloc(sizeof(SReputation))) == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
+ FatalError("Error allocating memory. Exiting");
}
memset(user_data, 0x00, sizeof(SReputation));
SCLogDebug("adding ipv6 host %s", ip);
if (SCRadixAddKeyIPV6String(ip, cidr_ctx->srepIPV6_tree[cat], (void *)user_data) == NULL) {
- SCLogWarning(SC_EINVAL, "failed to add ipv6 host %s", ip);
+ SCLogWarning("failed to add ipv6 host %s", ip);
}
} else {
SCLogDebug("adding ipv4 host %s", ip);
if (SCRadixAddKeyIPV4String(ip, cidr_ctx->srepIPV4_tree[cat], (void *)user_data) == NULL) {
- SCLogWarning(SC_EINVAL, "failed to add ipv4 host %s", ip);
+ SCLogWarning("failed to add ipv4 host %s", ip);
}
}
}
FILE *fp = fopen(filename, "r");
if (fp == NULL) {
- SCLogError(SC_ERR_OPENING_RULE_FILE, "opening ip rep file %s: %s", filename, strerror(errno));
+ SCLogError("opening ip rep file %s: %s", filename, strerror(errno));
return -1;
}
if (SRepCatSplitLine(line, &cat, shortname, sizeof(shortname)) == 0) {
strlcpy(srep_cat_table[cat], shortname, SREP_SHORTNAME_LEN);
} else {
- SCLogError(SC_ERR_NO_REPUTATION, "bad line \"%s\"", line);
+ SCLogError("bad line \"%s\"", line);
}
}
FILE *fp = fopen(filename, "r");
if (fp == NULL) {
- SCLogError(SC_ERR_OPENING_RULE_FILE, "opening ip rep file %s: %s", filename, strerror(errno));
+ SCLogError("opening ip rep file %s: %s", filename, strerror(errno));
return -1;
}
uint8_t cat = 0, value = 0;
int r = SRepSplitLine(cidr_ctx, line, &a, &cat, &value);
if (r < 0) {
- SCLogError(SC_ERR_NO_REPUTATION, "bad line \"%s\"", line);
+ SCLogError("bad line \"%s\"", line);
} else if (r == 0) {
if (a.family == AF_INET) {
char ipstr[16];
Host *h = HostGetHostFromHash(&a);
if (h == NULL) {
- SCLogError(SC_ERR_NO_REPUTATION, "failed to get a host, increase host.memcap");
+ SCLogError("failed to get a host, increase host.memcap");
break;
} else {
//SCLogInfo("host %p", h);
}
if (files == NULL) {
- SCLogError(SC_ERR_NO_REPUTATION, "\"reputation-files\" not set");
+ SCLogError("\"reputation-files\" not set");
return -1;
}
if (init) {
if (filename == NULL) {
- SCLogError(SC_ERR_NO_REPUTATION, "\"reputation-categories-file\" not set");
+ SCLogError("\"reputation-categories-file\" not set");
return -1;
}
/* init even if we have reputation files, so that when we
* have a live reload, we have inited the cats */
if (SRepLoadCatFile(filename) < 0) {
- SCLogError(SC_ERR_NO_REPUTATION, "failed to load reputation "
- "categories file %s", filename);
+ SCLogError("failed to load reputation "
+ "categories file %s",
+ filename);
return -1;
}
}
char ebuf[LIBNET_ERRBUF_SIZE];
libnet_t *c = libnet_init(injection_type, LIBNET_INIT_CAST devname, ebuf);
if (c == NULL) {
- SCLogError(SC_ERR_LIBNET_INIT,"libnet_init failed: %s", ebuf);
+ SCLogError("libnet_init failed: %s", ebuf);
}
if (store_ctx) {
t_c = c;
c, /* libnet context */
0)) < 0) /* libnet ptag */
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_tcp %s", libnet_geterror(c));
+ SCLogError("libnet_build_tcp %s", libnet_geterror(c));
return -1;
}
return 0;
c, /* libnet context pointer */
0)) < 0) /* packet id */
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_ipv4 %s", libnet_geterror(c));
+ SCLogError("libnet_build_ipv4 %s", libnet_geterror(c));
return -1;
}
return 0;
c, /* libnet context pointer */
0)) < 0) /* packet id */
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_ipv6 %s", libnet_geterror(c));
+ SCLogError("libnet_build_ipv6 %s", libnet_geterror(c));
return -1;
}
return 0;
static inline int BuildEthernet(libnet_t *c, Libnet11Packet *lpacket, uint16_t proto)
{
if ((libnet_build_ethernet(lpacket->dmac,lpacket->smac, proto , NULL, 0, c, 0)) < 0) {
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_ethernet %s", libnet_geterror(c));
+ SCLogError("libnet_build_ethernet %s", libnet_geterror(c));
return -1;
}
return 0;
c, /* libnet handle */
0) < 0)
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_802_1q %s", libnet_geterror(c));
+ SCLogError("libnet_build_802_1q %s", libnet_geterror(c));
return -1;
}
return 0;
result = libnet_write(c);
if (result == -1) {
- SCLogError(SC_ERR_LIBNET_WRITE_FAILED,"libnet_write failed: %s", libnet_geterror(c));
+ SCLogError("libnet_write failed: %s", libnet_geterror(c));
goto cleanup;
}
c, /* libnet context */
0)) < 0) /* libnet ptag */
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_icmpv4_unreach %s", libnet_geterror(c));
+ SCLogError("libnet_build_icmpv4_unreach %s", libnet_geterror(c));
goto cleanup;
}
result = libnet_write(c);
if (result == -1) {
- SCLogError(SC_ERR_LIBNET_WRITE_FAILED,"libnet_write_raw_ipv4 failed: %s", libnet_geterror(c));
+ SCLogError("libnet_write_raw_ipv4 failed: %s", libnet_geterror(c));
goto cleanup;
}
result = libnet_write(c);
if (result == -1) {
- SCLogError(SC_ERR_LIBNET_WRITE_FAILED,"libnet_write failed: %s", libnet_geterror(c));
+ SCLogError("libnet_write failed: %s", libnet_geterror(c));
goto cleanup;
}
c, /* libnet context */
0)) < 0) /* libnet ptag */
{
- SCLogError(SC_ERR_LIBNET_BUILD_FAILED,"libnet_build_icmpv6_unreach %s", libnet_geterror(c));
+ SCLogError("libnet_build_icmpv6_unreach %s", libnet_geterror(c));
goto cleanup;
}
result = libnet_write(c);
if (result == -1) {
- SCLogError(SC_ERR_LIBNET_WRITE_FAILED,"libnet_write_raw_ipv6 failed: %s", libnet_geterror(c));
+ SCLogError("libnet_write_raw_ipv6 failed: %s", libnet_geterror(c));
goto cleanup;
}
int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
{
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED, "Libnet ICMPv6 based rejects are disabled."
- "Usually this means that you don't have a patched libnet installed,"
- " or configure couldn't find it.");
+ SCLogError("Libnet ICMPv6 based rejects are disabled."
+ "Usually this means that you don't have a patched libnet installed,"
+ " or configure couldn't find it.");
return 0;
}
#endif /* HAVE_LIBNET_ICMPV6_UNREACH */
int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
{
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED, "Libnet based rejects are disabled."
- "Usually this means that you don't have libnet installed,"
- " or configure couldn't find it.");
+ SCLogError("Libnet based rejects are disabled."
+ "Usually this means that you don't have libnet installed,"
+ " or configure couldn't find it.");
return 0;
}
int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
{
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED, "Libnet based rejects are disabled."
- "Usually this means that you don't have libnet installed,"
- " or configure couldn't find it.");
+ SCLogError("Libnet based rejects are disabled."
+ "Usually this means that you don't have libnet installed,"
+ " or configure couldn't find it.");
return 0;
}
int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
{
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED, "Libnet based rejects are disabled."
- "Usually this means that you don't have libnet installed,"
- " or configure couldn't find it.");
+ SCLogError("Libnet based rejects are disabled."
+ "Usually this means that you don't have libnet installed,"
+ " or configure couldn't find it.");
return 0;
}
int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum RejectDirection dir)
{
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED, "Libnet based rejects are disabled."
- "Usually this means that you don't have libnet installed,"
- " or configure couldn't find it.");
+ SCLogError("Libnet based rejects are disabled."
+ "Usually this means that you don't have libnet installed,"
+ " or configure couldn't find it.");
return 0;
}
aconf->threads = 0;
} else {
if (StringParseInt32(&aconf->threads, 10, 0, (const char *)threadsstr) < 0) {
- SCLogWarning(SC_EINVAL, "Invalid number of "
- "threads, resetting to default");
+ SCLogWarning("Invalid number of "
+ "threads, resetting to default");
aconf->threads = 0;
}
}
if (ConfGetChildValueBoolWithDefault(if_root, if_default, "use-mmap", (int *)&boolval) == 1) {
if (!boolval) {
- SCLogWarning(SC_WARN_OPTION_OBSOLETE,
+ SCLogWarning(
"%s: \"use-mmap\" option is obsolete: mmap is always enabled", aconf->iface);
}
}
aconf->flags &= ~AFP_TPACKET_V3;
#endif
} else {
- SCLogWarning(SC_ERR_RUNMODE, "tpacket v3 is only implemented for 'workers' runmode."
- " Switching to tpacket v2.");
+ SCLogWarning("tpacket v3 is only implemented for 'workers' runmode."
+ " Switching to tpacket v2.");
aconf->flags &= ~AFP_TPACKET_V3;
}
} else {
aconf->out_iface);
aconf->copy_mode = AFP_COPY_MODE_IPS;
if (aconf->flags & AFP_TPACKET_V3) {
- SCLogWarning(SC_ERR_RUNMODE, "Using tpacket_v3 in IPS mode will result in high latency");
+ SCLogWarning("Using tpacket_v3 in IPS mode will result in high latency");
}
} else if (strcmp(copymodestr, "tap") == 0) {
SCLogInfo("AF_PACKET TAP mode activated %s->%s",
aconf->out_iface);
aconf->copy_mode = AFP_COPY_MODE_TAP;
if (aconf->flags & AFP_TPACKET_V3) {
- SCLogWarning(SC_ERR_RUNMODE, "Using tpacket_v3 in TAP mode will result in high latency");
+ SCLogWarning("Using tpacket_v3 in TAP mode will result in high latency");
}
} else {
SCLogInfo("Invalid mode (not in tap, ips)");
aconf->cluster_id = (uint16_t)(cluster_id_auto++);
} else {
if (StringParseUint16(&aconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
- SCLogWarning(SC_EINVAL, "Invalid cluster_id, resetting to 0");
+ SCLogWarning("Invalid cluster_id, resetting to 0");
aconf->cluster_id = 0;
}
SCLogDebug("Going to use cluster-id %" PRIu16, aconf->cluster_id);
} else if (strcmp(tmpctype, "cluster_rollover") == 0) {
SCLogConfig("Using rollover based cluster mode for AF_PACKET (iface %s)",
aconf->iface);
- SCLogWarning(SC_WARN_UNCOMMON, "Rollover mode is causing severe flow "
- "tracking issues, use it at your own risk.");
+ SCLogWarning("Rollover mode is causing severe flow "
+ "tracking issues, use it at your own risk.");
aconf->cluster_type = PACKET_FANOUT_ROLLOVER;
cluster_type = PACKET_FANOUT_ROLLOVER;
#ifdef HAVE_PACKET_EBPF
cluster_type = PACKET_FANOUT_EBPF;
#endif
} else {
- SCLogWarning(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype);
+ SCLogWarning("invalid cluster-type %s", tmpctype);
}
int conf_val = 0;
SCLogConfig("Using rollover kernel functionality for AF_PACKET (iface %s)",
aconf->iface);
aconf->cluster_type |= PACKET_FANOUT_FLAG_ROLLOVER;
- SCLogWarning(SC_WARN_UNCOMMON, "Rollover option is causing severe flow "
- "tracking issues, use it at your own risk.");
+ SCLogWarning("Rollover option is causing severe flow "
+ "tracking issues, use it at your own risk.");
}
/*load af_packet bpf filter*/
&aconf->ebpf_lb_fd,
&aconf->ebpf_t_config);
if (ret != 0) {
- SCLogWarning(SC_EINVAL, "Error when loading eBPF lb file");
+ SCLogWarning("Error when loading eBPF lb file");
}
}
#else
if (aconf->ebpf_lb_file) {
- SCLogError(SC_ERR_UNIMPLEMENTED, "eBPF support is not build-in");
+ SCLogError("eBPF support is not build-in");
}
#endif
aconf->flags |= AFP_BYPASS;
BypassedFlowManagerRegisterUpdateFunc(EBPFUpdateFlow, NULL);
#else
- SCLogError(SC_ERR_UNIMPLEMENTED, "Bypass set but eBPF support is not built-in");
+ SCLogError("Bypass set but eBPF support is not built-in");
#endif
}
}
&aconf->ebpf_filter_fd,
&aconf->ebpf_t_config);
if (ret != 0) {
- SCLogWarning(SC_EINVAL, "Error when loading eBPF filter file");
+ SCLogWarning("Error when loading eBPF filter file");
}
#else
- SCLogError(SC_ERR_UNIMPLEMENTED, "eBPF support is not build-in");
+ SCLogError("eBPF support is not build-in");
#endif
}
RunModeEnablesBypassManager();
struct ebpf_timeout_config *ebt = SCCalloc(1, sizeof(struct ebpf_timeout_config));
if (ebt == NULL) {
- SCLogError(SC_ENOMEM, "Flow bypass alloc error");
+ SCLogError("Flow bypass alloc error");
} else {
memcpy(ebt, &(aconf->ebpf_t_config), sizeof(struct ebpf_timeout_config));
BypassedFlowManagerRegisterCheckFunc(NULL,
BypassedFlowManagerRegisterUpdateFunc(EBPFUpdateFlow, NULL);
}
#else
- SCLogWarning(SC_ERR_UNIMPLEMENTED, "XDP filter set but XDP support is not built-in");
+ SCLogWarning("XDP filter set but XDP support is not built-in");
#endif
#ifdef HAVE_PACKET_XDP
const char *xdp_mode;
aconf->xdp_mode = XDP_FLAGS_HW_MODE;
aconf->ebpf_t_config.flags |= EBPF_XDP_HW_MODE;
} else {
- SCLogWarning(SC_EINVAL, "Invalid xdp-mode value: '%s'", xdp_mode);
+ SCLogWarning("Invalid xdp-mode value: '%s'", xdp_mode);
}
}
SCLogInfo("Loaded pinned maps from sysfs");
break;
case -1:
- SCLogWarning(SC_EINVAL, "Error when loading XDP filter file");
+ SCLogWarning("Error when loading XDP filter file");
break;
case 0:
ret = EBPFSetupXDP(aconf->iface, aconf->xdp_filter_fd, aconf->xdp_mode);
if (ret != 0) {
- SCLogWarning(SC_EINVAL, "Error when setting up XDP");
+ SCLogWarning("Error when setting up XDP");
} else {
/* Try to get the xdp-cpu-redirect key */
const char *cpuset;
SCLogConfig("Setting up CPU map XDP");
ConfNode *node = ConfGetChildWithDefault(if_root, if_default, "xdp-cpu-redirect");
if (node == NULL) {
- SCLogError(SC_EINVAL, "Previously found node has disappeared");
+ SCLogError("Previously found node has disappeared");
} else {
EBPFBuildCPUSet(node, aconf->iface);
}
}
}
#else
- SCLogError(SC_ERR_UNIMPLEMENTED, "XDP support is not built-in");
+ SCLogError("XDP support is not built-in");
#endif
}
if ((ConfGetChildValueIntWithDefault(if_root, if_default, "block-size", &value)) == 1) {
if (value % getpagesize()) {
- SCLogError(SC_EINVAL, "Block-size must be a multiple of pagesize.");
+ SCLogError("Block-size must be a multiple of pagesize.");
} else {
aconf->block_size = value;
}
} else if (strcmp(tmpctype, "kernel") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_KERNEL;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid value for checksum-checks for %s", aconf->iface);
+ SCLogError("Invalid value for checksum-checks for %s", aconf->iface);
}
}
if (aconf->ring_size != 0) {
if (aconf->ring_size * aconf->threads < max_pending_packets) {
aconf->ring_size = max_pending_packets / aconf->threads + 1;
- SCLogWarning(SC_ERR_AFP_CREATE, "Inefficient setup: ring-size < max_pending_packets. "
- "Resetting to decent value %d.", aconf->ring_size);
+ SCLogWarning("Inefficient setup: ring-size < max_pending_packets. "
+ "Resetting to decent value %d.",
+ aconf->ring_size);
/* We want at least that max_pending_packets packets can be handled by the
* interface. This is generous if we have multiple interfaces listening. */
}
/* af-packet can handle csum offloading */
if (LiveGetOffload() == 0) {
if (GetIfaceOffloading(iface, 0, 1) == 1) {
- SCLogWarning(SC_ERR_AFP_CREATE,
+ SCLogWarning(
"Using AF_PACKET with offloading activated leads to capture problems");
}
} else {
for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
const char *copymodestr = NULL;
if (if_root == NULL) {
if (if_default == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = if_default;
}
if (has_ids && has_ips) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "AF_PACKET using both IPS and TAP/IDS mode, this will not "
- "be allowed in Suricata 8 due to undefined behavior. See ticket #5588.");
+ SCLogWarning("AF_PACKET using both IPS and TAP/IDS mode, this will not "
+ "be allowed in Suricata 8 due to undefined behavior. See ticket #5588.");
for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = ConfNodeLookupKeyValue(af_packet_node, "interface", live_dev);
if (if_root == NULL) {
if (if_default == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = if_default;
if (! ((ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) &&
(strcmp(copymodestr, "ips") == 0))) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "AF_PACKET IPS mode used and interface '%s' is in IDS or TAP mode. "
- "Sniffing '%s' but expect bad result as stream-inline is activated.",
+ SCLogError("AF_PACKET IPS mode used and interface '%s' is in IDS or TAP mode. "
+ "Sniffing '%s' but expect bad result as stream-inline is activated.",
live_dev, live_dev);
}
}
SCLogDebug("live_dev %s", live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Unable to init peers list.");
+ FatalError("Unable to init peers list.");
}
ret = RunModeSetLiveCaptureAutoFp(ParseAFPConfig,
"DecodeAFP", thread_name_autofp,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
+ FatalError("Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPAutoFp initialised");
(void)ConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Unable to init peers list.");
+ FatalError("Unable to init peers list.");
}
ret = RunModeSetLiveCaptureSingle(ParseAFPConfig,
"DecodeAFP", thread_name_single,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
+ FatalError("Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPSingle initialised");
(void)ConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Unable to init peers list.");
+ FatalError("Unable to init peers list.");
}
ret = RunModeSetLiveCaptureWorkers(ParseAFPConfig,
"DecodeAFP", thread_name_workers,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
+ FatalError("Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPWorkers initialised");
}
if (entry_str == NULL) {
- SCLogError(SC_ERR_INVALID_VALUE, "Number of threads for interface \"%s\" not specified",
- aconf->iface);
+ SCLogError("Number of threads for interface \"%s\" not specified", aconf->iface);
SCReturnInt(TM_ECODE_FAILED);
}
}
if (StringParseInt32(&aconf->threads, 10, 0, entry_str) < 0) {
- SCLogError(SC_ERR_INVALID_VALUE,
- "Threads entry for interface %s contain non-numerical characters - \"%s\"",
+ SCLogError("Threads entry for interface %s contain non-numerical characters - \"%s\"",
aconf->iface, entry_str);
SCReturnInt(TM_ECODE_FAILED);
}
if (aconf->threads < 0) {
- SCLogError(SC_ERR_INVALID_VALUE, "Interface %s has a negative number of threads",
- aconf->iface);
+ SCLogError("Interface %s has a negative number of threads", aconf->iface);
SCReturnInt(TM_ECODE_FAILED);
}
if (aconf->threads > nr_queues) {
- SCLogWarning(SC_WARN_AFXDP_CONF,
+ SCLogWarning(
"Selected threads greater than configured queues, using: %d thread(s)", nr_queues);
aconf->threads = nr_queues;
}
aconf->mode |= XDP_FLAGS_SKB_MODE;
} else if (strncasecmp(confstr, "none", 4) == 0) {
} else {
- SCLogWarning(SC_WARN_AFXDP_CONF,
- "Incorrect af-xdp xdp-mode setting, default (none) shall be applied");
+ SCLogWarning("Incorrect af-xdp xdp-mode setting, default (none) shall be applied");
}
}
aconf->bind_flags |= XDP_COPY;
} else if (strncasecmp(confstr, "none", 4) == 0) {
} else {
- SCLogWarning(SC_WARN_AFXDP_CONF,
- "Incorrect af-xdp copy-mode setting, default (none) shall be applied");
+ SCLogWarning("Incorrect af-xdp copy-mode setting, default (none) shall be applied");
}
}
finalize:
if (LiveGetOffload() == 0) {
if (GetIfaceOffloading(iface, 0, 1) == 1) {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "Using AF_XDP with offloading activated leads to capture problems");
+ SCLogWarning("Using AF_XDP with offloading activated leads to capture problems");
}
} else {
DisableIfaceOffloading(LiveGetDevice(iface), 0, 1);
static int AFXDPConfigGetThreadsCount(void *conf)
{
if (conf == NULL)
- FatalError(SC_ERR_AFXDP_CONF, "Configuration file is NULL");
+ FatalError("Configuration file is NULL");
AFXDPIfaceConfig *afxdp_conf = (AFXDPIfaceConfig *)conf;
return afxdp_conf->threads;
(void)ConfGet("af-xdp.live-interface", &live_dev);
if (AFXDPQueueProtectionInit() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Unable to init AF_XDP queue protection.");
+ FatalError("Unable to init AF_XDP queue protection.");
}
ret = RunModeSetLiveCaptureSingle(ParseAFXDPConfig, AFXDPConfigGetThreadsCount, "ReceiveAFXDP",
"DecodeAFXDP", thread_name_single, live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogDebug("RunModeIdsAFXDPSingle initialised");
(void)ConfGet("af-xdp.live-interface", &live_dev);
if (AFXDPQueueProtectionInit() != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "Unable to init AF_XDP queue protection.");
+ FatalError("Unable to init AF_XDP queue protection.");
}
ret = RunModeSetLiveCaptureWorkers(ParseAFXDPConfig, AFXDPConfigGetThreadsCount, "ReceiveAFXDP",
"DecodeAFXDP", thread_name_workers, live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogDebug("RunModeIdsAFXDPWorkers initialised");
arg_len += 1; // null character
ptr = (char *)SCCalloc(arg_len, sizeof(char));
if (ptr == NULL)
- FatalError(SC_ENOMEM, "Could not allocate memory for an argument");
+ FatalError("Could not allocate memory for an argument");
SCReturnPtr(ptr, "char *");
}
{
SCEnter();
if (arg == NULL)
- FatalError(SC_ERR_DPDK_CONF, "Passed argument is NULL in DPDK config initialization");
+ FatalError("Passed argument is NULL in DPDK config initialization");
char *ptr;
size_t arg_len = strlen(arg);
{
SCEnter();
if (arg == NULL)
- FatalError(SC_ERR_DPDK_CONF, "Passed option is NULL in DPDK config initialization");
+ FatalError("Passed option is NULL in DPDK config initialization");
char *ptr = NULL;
size_t arg_len = strlen(arg);
SCEnter();
args->argv = SCCalloc(capacity, sizeof(ptrdiff_t)); // alloc array of pointers
if (args->argv == NULL)
- FatalError(SC_ENOMEM, "Could not allocate memory for Arguments structure");
+ FatalError("Could not allocate memory for Arguments structure");
args->capacity = capacity;
args->argc = 0;
{
SCEnter();
if (args->argc + 1 > args->capacity)
- FatalError(SC_ERR_DPDK_EAL_INIT, "No capacity for more arguments (Max: %" PRIu32 ")",
- EAL_ARGS);
+ FatalError("No capacity for more arguments (Max: %" PRIu32 ")", EAL_ARGS);
args->argv[args->argc++] = value;
SCReturn;
char **eal_argv;
if (eal_params == NULL) {
- FatalError(SC_ERR_DPDK_CONF, "DPDK EAL parameters not found in the config");
+ FatalError("DPDK EAL parameters not found in the config");
}
ArgumentsInit(&args, EAL_ARGS);
// creating a shallow copy for cleanup because rte_eal_init changes array contents
eal_argv = SCMalloc(args.argc * sizeof(args.argv));
if (eal_argv == NULL) {
- FatalError(SC_ENOMEM, "Failed to allocate memory for the array of DPDK EAL arguments");
+ FatalError("Failed to allocate memory for the array of DPDK EAL arguments");
}
memcpy(eal_argv, args.argv, args.argc * sizeof(*args.argv));
SCFree(eal_argv);
if (retval < 0) { // retval binded to the result of rte_eal_init
- FatalError(
- SC_ERR_DPDK_EAL_INIT, "DPDK EAL initialization error: %s", rte_strerror(-retval));
+ FatalError("DPDK EAL initialization error: %s", rte_strerror(-retval));
}
DPDKSetTimevalOfMachineStart();
}
DPDKIfaceConfig *ptr = NULL;
ptr = SCCalloc(1, sizeof(DPDKIfaceConfig));
if (ptr == NULL)
- FatalError(SC_ERR_DPDK_CONF, "Could not allocate memory for DPDKIfaceConfig");
+ FatalError("Could not allocate memory for DPDKIfaceConfig");
ptr->pkt_mempool = NULL;
ptr->out_port_id = -1; // make sure no port is set
int retval;
if (entry_str == NULL || entry_str[0] == '\0')
- FatalError(SC_EINVAL, "Interface name in DPDK config is NULL or empty");
+ FatalError("Interface name in DPDK config is NULL or empty");
retval = rte_eth_dev_get_port_by_name(entry_str, &iconf->port_id);
if (retval < 0)
- FatalError(SC_ERR_DPDK_CONF, "Interface \"%s\": %s", entry_str, rte_strerror(-retval));
+ FatalError("Interface \"%s\": %s", entry_str, rte_strerror(-retval));
strlcpy(iconf->iface, entry_str, sizeof(iconf->iface));
SCReturn;
}
if (entry_str == NULL) {
- SCLogError(SC_EINVAL, "Number of threads for interface \"%s\" not specified", iconf->iface);
+ SCLogError("Number of threads for interface \"%s\" not specified", iconf->iface);
SCReturnInt(-EINVAL);
}
}
if (StringParseInt32(&iconf->threads, 10, 0, entry_str) < 0) {
- SCLogError(SC_EINVAL,
- "Threads entry for interface %s contain non-numerical characters - \"%s\"",
+ SCLogError("Threads entry for interface %s contain non-numerical characters - \"%s\"",
iconf->iface, entry_str);
SCReturnInt(-EINVAL);
}
if (iconf->threads < 0) {
- SCLogError(SC_EINVAL, "Interface %s has a negative number of threads", iconf->iface);
+ SCLogError("Interface %s has a negative number of threads", iconf->iface);
SCReturnInt(-ERANGE);
}
SCEnter();
iconf->nb_rx_queues = nb_queues;
if (iconf->nb_rx_queues < 1) {
- SCLogError(SC_EINVAL, "Interface %s requires to have positive number of RX queues",
- iconf->iface);
+ SCLogError("Interface %s requires to have positive number of RX queues", iconf->iface);
SCReturnInt(-ERANGE);
}
SCEnter();
iconf->nb_tx_queues = nb_queues;
if (iconf->nb_tx_queues < 1) {
- SCLogError(SC_EINVAL, "Interface %s requires to have positive number of TX queues",
- iconf->iface);
+ SCLogError("Interface %s requires to have positive number of TX queues", iconf->iface);
SCReturnInt(-ERANGE);
}
{
SCEnter();
if (entry_int <= 0) {
- SCLogError(
- SC_EINVAL, "Interface %s requires to have positive memory pool size", iconf->iface);
+ SCLogError("Interface %s requires to have positive memory pool size", iconf->iface);
SCReturnInt(-ERANGE);
}
// RTE_MEMPOOL_CACHE_MAX_SIZE (by default 512) and "mempool-size / 1.5"
// and at the same time "mempool-size modulo cache_size == 0".
if (iconf->mempool_size == 0) {
- SCLogError(SC_EINVAL, "Cannot calculate mempool cache size of a mempool with size %d",
+ SCLogError("Cannot calculate mempool cache size of a mempool with size %d",
iconf->mempool_size);
SCReturnInt(-EINVAL);
}
}
if (StringParseUint32(&iconf->mempool_cache_size, 10, 0, entry_str) < 0) {
- SCLogError(SC_EINVAL,
- "Mempool cache size entry for interface %s contain non-numerical "
- "characters - \"%s\"",
+ SCLogError("Mempool cache size entry for interface %s contain non-numerical "
+ "characters - \"%s\"",
iconf->iface, entry_str);
SCReturnInt(-EINVAL);
}
if (iconf->mempool_cache_size <= 0 || iconf->mempool_cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE) {
- SCLogError(SC_EINVAL,
+ SCLogError(
"Interface %s requires to have mempool cache size set to a positive number smaller "
"than %" PRIu32,
iconf->iface, RTE_MEMPOOL_CACHE_MAX_SIZE);
{
SCEnter();
if (entry_int <= 0) {
- SCLogError(SC_EINVAL, "Interface %s requires to have positive number of RX descriptors",
- iconf->iface);
+ SCLogError("Interface %s requires to have positive number of RX descriptors", iconf->iface);
SCReturnInt(-ERANGE);
}
{
SCEnter();
if (entry_int <= 0) {
- SCLogError(SC_EINVAL, "Interface %s requires to have positive number of TX descriptors",
- iconf->iface);
+ SCLogError("Interface %s requires to have positive number of TX descriptors", iconf->iface);
SCReturnInt(-ERANGE);
}
}
if (StringParseUint64(&iconf->rss_hf, 0, 0, entry_str) < 0) {
- SCLogError(SC_EINVAL,
- "RSS hash functions entry for interface %s contain non-numerical "
- "characters - \"%s\"",
+ SCLogError("RSS hash functions entry for interface %s contain non-numerical "
+ "characters - \"%s\"",
iconf->iface, entry_str);
SCReturnInt(-EINVAL);
}
{
SCEnter();
if (entry_int < RTE_ETHER_MIN_MTU || entry_int > RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
- SCLogError(SC_EINVAL,
- "Interface %s requires to have size of MTU between %" PRIu32 " and %" PRIu32,
+ SCLogError("Interface %s requires to have size of MTU between %" PRIu32 " and %" PRIu32,
iconf->iface, RTE_ETHER_MIN_MTU, RTE_ETHER_MAX_JUMBO_FRAME_LEN);
SCReturnInt(-ERANGE);
}
retval = rte_eth_dev_get_port_by_name(entry_str, &iconf->out_port_id);
if (retval < 0) {
- SCLogWarning(SC_ERR_DPDK_CONF,
+ SCLogWarning(
"Name of the copy interface (%s) for the interface %s is not valid, changing to %s",
entry_str, iconf->iface, DPDK_CONFIG_DEFAULT_COPY_INTERFACE);
iconf->out_iface = DPDK_CONFIG_DEFAULT_COPY_INTERFACE;
{
SCEnter();
if (entry_str == NULL) {
- SCLogWarning(SC_EINVAL, "Interface %s has no copy mode specified, changing to %s ",
- iconf->iface, DPDK_CONFIG_DEFAULT_COPY_MODE);
+ SCLogWarning("Interface %s has no copy mode specified, changing to %s ", iconf->iface,
+ DPDK_CONFIG_DEFAULT_COPY_MODE);
entry_str = DPDK_CONFIG_DEFAULT_COPY_MODE;
}
if (strcmp(entry_str, "none") != 0 && strcmp(entry_str, "tap") != 0 &&
strcmp(entry_str, "ips") != 0) {
- SCLogWarning(SC_EINVAL,
+ SCLogWarning(
"Copy mode \"%s\" is not one of the possible values (none|tap|ips) for interface "
"%s. Changing to %s",
entry_str, iconf->iface, DPDK_CONFIG_DEFAULT_COPY_MODE);
}
if (iconf->out_iface == NULL || strlen(iconf->out_iface) <= 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Copy mode enabled but interface not set");
+ SCLogError("Copy mode enabled but interface not set");
SCReturnInt(-EINVAL);
}
retval = ConfSetRootAndDefaultNodes("dpdk.interfaces", iconf->iface, &if_root, &if_default);
if (retval < 0) {
- FatalError(SC_ERR_DPDK_CONF, "failed to find DPDK configuration for the interface %s",
- iconf->iface);
+ FatalError("failed to find DPDK configuration for the interface %s", iconf->iface);
}
retval = ConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.threads, &entry_str) != 1
int retval;
DPDKIfaceConfig *iconf = NULL;
if (iface == NULL)
- FatalError(SC_ERR_DPDK_CONF, "DPDK interface is NULL");
+ FatalError("DPDK interface is NULL");
ConfigInit(&iconf);
retval = ConfigLoad(iconf, iface);
static int DeviceValidateMTU(const DPDKIfaceConfig *iconf, const struct rte_eth_dev_info *dev_info)
{
if (iconf->mtu > dev_info->max_mtu || iconf->mtu < dev_info->min_mtu) {
- SCLogError(SC_ERR_DPDK_INIT,
- "Loaded MTU of \"%s\" is out of bounds. "
- "Min MTU: %" PRIu16 " Max MTU: %" PRIu16,
+ SCLogError("Loaded MTU of \"%s\" is out of bounds. "
+ "Min MTU: %" PRIu16 " Max MTU: %" PRIu16,
iconf->iface, dev_info->min_mtu, dev_info->max_mtu);
SCReturnInt(-ERANGE);
}
// check if jumbo frames are set and are available
if (iconf->mtu > RTE_ETHER_MAX_LEN &&
!(dev_info->rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME)) {
- SCLogError(SC_ERR_DPDK_CONF, "Jumbo frames not supported, set MTU of \"%s\" to 1500B",
- iconf->iface);
+ SCLogError("Jumbo frames not supported, set MTU of \"%s\" to 1500B", iconf->iface);
SCReturnInt(-EINVAL);
}
#endif
if (port_conf->rx_adv_conf.rss_conf.rss_hf != rss_hf_tmp) {
DumpRSSFlags(port_conf->rx_adv_conf.rss_conf.rss_hf, rss_hf_tmp);
- SCLogWarning(SC_WARN_DPDK_CONF,
- "Interface %s modified RSS hash function based on hardware support, "
- "requested:%#" PRIx64 " configured:%#" PRIx64,
+ SCLogWarning("Interface %s modified RSS hash function based on hardware support, "
+ "requested:%#" PRIx64 " configured:%#" PRIx64,
iconf->iface, port_conf->rx_adv_conf.rss_conf.rss_hf, rss_hf_tmp);
port_conf->rx_adv_conf.rss_conf.rss_hf = rss_hf_tmp;
}
iconf->mempool_cache_size, 0, mbuf_size, (int)iconf->socket_id);
if (iconf->pkt_mempool == NULL) {
retval = -rte_errno;
- SCLogError(SC_ERR_DPDK_INIT,
- "Error (err=%d) during rte_pktmbuf_pool_create (mempool: %s) - %s", rte_errno,
+ SCLogError("Error (err=%d) during rte_pktmbuf_pool_create (mempool: %s) - %s", rte_errno,
mempool_name, rte_strerror(rte_errno));
SCReturnInt(retval);
}
iconf->socket_id, &rxq_conf, iconf->pkt_mempool);
if (retval < 0) {
rte_mempool_free(iconf->pkt_mempool);
- SCLogError(SC_ERR_DPDK_INIT,
- "Error (err=%d) during initialization of device queue %u of port %u", retval,
+ SCLogError("Error (err=%d) during initialization of device queue %u of port %u", retval,
queue_id, iconf->port_id);
SCReturnInt(retval);
}
iconf->port_id, queue_id, iconf->nb_tx_desc, iconf->socket_id, &txq_conf);
if (retval < 0) {
rte_mempool_free(iconf->pkt_mempool);
- SCLogError(SC_ERR_DPDK_INIT,
- "Error (err=%d) during initialization of device queue %u of port %u", retval,
+ SCLogError("Error (err=%d) during initialization of device queue %u of port %u", retval,
queue_id, iconf->port_id);
SCReturnInt(retval);
}
DPDKIfaceConfig *out_iconf = NULL;
ConfigInit(&out_iconf);
if (out_iconf == NULL) {
- FatalError(
- SC_ERR_DPDK_CONF, "Copy interface of the interface \"%s\" is NULL", iconf->iface);
+ FatalError("Copy interface of the interface \"%s\" is NULL", iconf->iface);
}
retval = ConfigLoad(out_iconf, iconf->out_iface);
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Fail to load config of interface %s", iconf->out_iface);
+ SCLogError("Fail to load config of interface %s", iconf->out_iface);
out_iconf->DerefFunc(out_iconf);
SCReturnInt(-EINVAL);
}
if (iconf->nb_rx_queues != out_iconf->nb_tx_queues) {
// the other direction is validated when the copy interface is configured
- SCLogError(SC_ERR_DPDK_CONF,
- "Interface %s has configured %d RX queues but copy interface %s has %d TX queues"
- " - number of queues must be equal",
+ SCLogError("Interface %s has configured %d RX queues but copy interface %s has %d TX queues"
+ " - number of queues must be equal",
iconf->iface, iconf->nb_rx_queues, out_iconf->iface, out_iconf->nb_tx_queues);
out_iconf->DerefFunc(out_iconf);
SCReturnInt(-EINVAL);
} else if (iconf->mtu != out_iconf->mtu) {
- SCLogError(SC_ERR_DPDK_CONF,
- "Interface %s has configured MTU of %dB but copy interface %s has MTU set to %dB"
- " - MTU must be equal",
+ SCLogError("Interface %s has configured MTU of %dB but copy interface %s has MTU set to %dB"
+ " - MTU must be equal",
iconf->iface, iconf->mtu, out_iconf->iface, out_iconf->mtu);
out_iconf->DerefFunc(out_iconf);
SCReturnInt(-EINVAL);
} else if (iconf->copy_mode != out_iconf->copy_mode) {
- SCLogError(SC_ERR_DPDK_CONF, "Copy modes of interfaces %s and %s are not equal",
- iconf->iface, out_iconf->iface);
+ SCLogError(
+ "Copy modes of interfaces %s and %s are not equal", iconf->iface, out_iconf->iface);
out_iconf->DerefFunc(out_iconf);
SCReturnInt(-EINVAL);
} else if (strcmp(iconf->iface, out_iconf->out_iface) != 0) {
// check if the other iface has the current iface set as a copy iface
- SCLogError(SC_ERR_DPDK_CONF, "Copy interface of %s is not set to %s", out_iconf->iface,
- iconf->iface);
+ SCLogError("Copy interface of %s is not set to %s", out_iconf->iface, iconf->iface);
out_iconf->DerefFunc(out_iconf);
SCReturnInt(-EINVAL);
}
if (iconf->out_iface != NULL) {
retval = rte_eth_dev_get_port_by_name(iconf->out_iface, &iconf->out_port_id);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) during obtaining port id of %s", retval,
- iconf->out_iface);
+ SCLogError("Error (err=%d) during obtaining port id of %s", retval, iconf->out_iface);
SCReturnInt(retval);
}
if (rte_eth_dev_socket_id(iconf->port_id) != rte_eth_dev_socket_id(iconf->out_port_id)) {
- SCLogWarning(SC_WARN_DPDK_CONF, "%s and %s are not on the same NUMA node", iconf->iface,
- iconf->out_iface);
+ SCLogWarning("%s and %s are not on the same NUMA node", iconf->iface, iconf->out_iface);
}
retval = DeviceValidateOutIfaceConfig(iconf);
retval = rte_eth_dev_get_port_by_name(iconf->iface, &(iconf->port_id));
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) when getting port id of %s Is device enabled?",
- retval, iconf->iface);
+ SCLogError("Error (err=%d) when getting port id of %s Is device enabled?", retval,
+ iconf->iface);
SCReturnInt(retval);
}
if (!rte_eth_dev_is_valid_port(iconf->port_id)) {
- SCLogError(SC_ERR_DPDK_INIT, "Specified port %d is invalid", iconf->port_id);
+ SCLogError("Specified port %d is invalid", iconf->port_id);
SCReturnInt(retval);
}
retval = rte_eth_dev_socket_id(iconf->port_id);
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) invalid socket id (port %s)", retval,
- iconf->iface);
+ SCLogError("Error (err=%d) invalid socket id (port %s)", retval, iconf->iface);
SCReturnInt(retval);
} else {
iconf->socket_id = retval;
retval = rte_eth_dev_info_get(iconf->port_id, &dev_info);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) during getting device info (port %s)", retval,
- iconf->iface);
+ SCLogError("Error (err=%d) during getting device info (port %s)", retval, iconf->iface);
SCReturnInt(retval);
}
if (iconf->nb_rx_queues > dev_info.max_rx_queues) {
- SCLogError(SC_ERR_DPDK_INIT,
- "Number of configured RX queues of %s is higher than maximum allowed (%" PRIu16 ")",
+ SCLogError("Number of configured RX queues of %s is higher than maximum allowed (%" PRIu16
+ ")",
iconf->iface, dev_info.max_rx_queues);
SCReturnInt(-ERANGE);
}
if (iconf->nb_tx_queues > dev_info.max_tx_queues) {
- SCLogError(SC_ERR_DPDK_INIT,
- "Number of configured TX queues of %s is higher than maximum allowed (%" PRIu16 ")",
+ SCLogError("Number of configured TX queues of %s is higher than maximum allowed (%" PRIu16
+ ")",
iconf->iface, dev_info.max_tx_queues);
SCReturnInt(-ERANGE);
}
retval = rte_eth_dev_configure(
iconf->port_id, iconf->nb_rx_queues, iconf->nb_tx_queues, &port_conf);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) during configuring the device (port %u)",
- retval, iconf->port_id);
+ SCLogError(
+ "Error (err=%d) during configuring the device (port %u)", retval, iconf->port_id);
SCReturnInt(retval);
}
retval = rte_eth_dev_adjust_nb_rx_tx_desc(
iconf->port_id, &iconf->nb_rx_desc, &iconf->nb_tx_desc);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT,
- "Error (err=%d) during adjustment of device queues descriptors (port %u)", retval,
- iconf->port_id);
+ SCLogError("Error (err=%d) during adjustment of device queues descriptors (port %u)",
+ retval, iconf->port_id);
SCReturnInt(retval);
}
// when multicast is enabled but set to disable or vice versa
if ((retval == 1 && !(iconf->flags & DPDK_MULTICAST)) ||
(retval == 0 && (iconf->flags & DPDK_MULTICAST))) {
- SCLogError(SC_ERR_DPDK_CONF,
- "Allmulticast setting of port (%" PRIu16
- ") can not be configured. Set it to %s",
+ SCLogError("Allmulticast setting of port (%" PRIu16
+ ") can not be configured. Set it to %s",
iconf->port_id, retval == 1 ? "true" : "false");
} else if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) Unable to get multicast mode on port %u",
- retval, iconf->port_id);
+ SCLogError("Error (err=%d) Unable to get multicast mode on port %u", retval,
+ iconf->port_id);
SCReturnInt(retval);
}
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) Unable to get multicast mode on port %u",
- retval, iconf->port_id);
+ SCLogError("Error (err=%d) Unable to get multicast mode on port %u", retval,
+ iconf->port_id);
SCReturnInt(retval);
}
} else if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) when en/disabling multicast on port %u",
- retval, iconf->port_id);
+ SCLogError("Error (err=%d) when en/disabling multicast on port %u", retval, iconf->port_id);
SCReturnInt(retval);
}
retval = rte_eth_promiscuous_get(iconf->port_id);
if ((retval == 1 && !(iconf->flags & DPDK_PROMISC)) ||
(retval == 0 && (iconf->flags & DPDK_PROMISC))) {
- SCLogError(SC_ERR_DPDK_CONF,
- "Promiscuous setting of port (%" PRIu16 ") can not be configured. Set it to %s",
+ SCLogError("Promiscuous setting of port (%" PRIu16
+ ") can not be configured. Set it to %s",
iconf->port_id, retval == 1 ? "true" : "false");
SCReturnInt(TM_ECODE_FAILED);
} else if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) Unable to get promiscuous mode on port %u",
- retval, iconf->port_id);
+ SCLogError("Error (err=%d) Unable to get promiscuous mode on port %u", retval,
+ iconf->port_id);
SCReturnInt(retval);
}
} else if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) when enabling promiscuous mode on port %u",
- retval, iconf->port_id);
+ SCLogError(
+ "Error (err=%d) when enabling promiscuous mode on port %u", retval, iconf->port_id);
SCReturnInt(TM_ECODE_FAILED);
}
SCLogConfig("Setting MTU of %s to %dB", iconf->iface, iconf->mtu);
retval = rte_eth_dev_set_mtu(iconf->port_id, iconf->mtu);
if (retval == -ENOTSUP) {
- SCLogWarning(SC_WARN_DPDK_CONF,
- "Changing MTU on port %u is not supported, ignoring the setting...",
+ SCLogWarning("Changing MTU on port %u is not supported, ignoring the setting...",
iconf->port_id);
// if it is not possible to set the MTU, retrieve it
retval = rte_eth_dev_get_mtu(iconf->port_id, &iconf->mtu);
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) Unable to retrieve MTU from port %u",
- retval, iconf->port_id);
+ SCLogError(
+ "Error (err=%d) Unable to retrieve MTU from port %u", retval, iconf->port_id);
SCReturnInt(retval);
}
} else if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) when setting MTU to %u on port %u", retval,
- iconf->mtu, iconf->port_id);
+ SCLogError("Error (err=%d) when setting MTU to %u on port %u", retval, iconf->mtu,
+ iconf->port_id);
SCReturnInt(retval);
}
int retval;
DPDKIfaceConfig *iconf = ConfigParse(iface);
if (iconf == NULL) {
- FatalError(SC_ERR_DPDK_CONF, "DPDK configuration could not be parsed");
+ FatalError("DPDK configuration could not be parsed");
}
if (DeviceConfigure(iconf) != 0) {
iconf->DerefFunc(iconf);
retval = rte_eal_cleanup();
if (retval != 0)
- FatalError(SC_ERR_DPDK_EAL_INIT, "EAL cleanup failed: %s", strerror(-retval));
+ FatalError("EAL cleanup failed: %s", strerror(-retval));
- FatalError(SC_ERR_DPDK_CONF, "Device %s fails to configure", iface);
+ FatalError("Device %s fails to configure", iface);
}
SC_ATOMIC_RESET(iconf->ref);
static int DPDKConfigGetThreadsCount(void *conf)
{
if (conf == NULL)
- FatalError(SC_ERR_DPDK_CONF, "Configuration file is NULL");
+ FatalError("Configuration file is NULL");
DPDKIfaceConfig *dpdk_conf = (DPDKIfaceConfig *)conf;
return dpdk_conf->threads;
ret = RunModeSetLiveCaptureWorkers(ParseDpdkConfigAndConfigureDevice, DPDKConfigGetThreadsCount,
"ReceiveDPDK", "DecodeDPDK", thread_name_workers, NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogDebug("RunModeIdsDpdkWorkers initialised");
thread_name_single,
NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "DAG single runmode failed to start");
+ FatalError("DAG single runmode failed to start");
}
SCLogInfo("RunModeIdsDagSingle initialised");
thread_name_autofp,
NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "DAG autofp runmode failed to start");
+ FatalError("DAG autofp runmode failed to start");
}
SCLogInfo("RunModeIdsDagAutoFp initialised");
thread_name_workers,
NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "DAG workers runmode failed to start");
+ FatalError("DAG workers runmode failed to start");
}
SCLogInfo("RunModeIdsErfDagWorkers initialised");
SCEnter();
if (ConfGet("erf-file.file", &file) == 0) {
- FatalError(SC_ERR_FATAL, "Failed to get erf-file.file from config.");
+ FatalError("Failed to get erf-file.file from config.");
}
RunModeInitialize();
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
const char *file = NULL;
if (ConfGet("erf-file.file", &file) == 0) {
- FatalError(SC_ERR_FATAL,
- "Failed retrieving erf-file.file from config");
+ FatalError("Failed retrieving erf-file.file from config");
}
TimeModeSetOffline();
queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- FatalError(SC_ERR_FATAL,
- "RunmodeAutoFpCreatePickupQueuesString failed");
+ FatalError("RunmodeAutoFpCreatePickupQueuesString failed");
}
/* create the threads */
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL,
- "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
* automatically creates streams. Therefore, these two options are mutually exclusive.
*/
if (use_all_streams && auto_config) {
- FatalError(SC_ERR_FATAL,
- "napatech.auto-config cannot be used in configuration file at the same time as napatech.use-all-streams.");
+ FatalError("napatech.auto-config cannot be used in configuration file at the same time as "
+ "napatech.use-all-streams.");
}
/* to use hardware_bypass we need to configure the streams to be consistent.
* option.
*/
if (use_hw_bypass && auto_config == 0) {
- FatalError(SC_ERR_FATAL,
- "napatech auto-config must be enabled when using napatech.use_hw_bypass.");
+ FatalError("napatech auto-config must be enabled when using napatech.use_hw_bypass.");
}
/* Get the stream ID's either from the conf or by querying Napatech */
for (uint16_t inst = 0; inst < stream_cnt; ++inst) {
char *plive_dev_buf = SCCalloc(1, 9);
if (unlikely(plive_dev_buf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(plive_dev_buf, 9, "nt%d", stream_config[inst].stream_id);
if (auto_config) {
if (stream_config[inst].is_active) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Registering Napatech device: %s - active stream found.",
- plive_dev_buf);
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
+ SCLogError("Registering Napatech device: %s - active stream found.", plive_dev_buf);
+ SCLogError(
"run /opt/napatech3/bin/ntpl -e \"delete=all\" to delete existing stream");
- FatalError(SC_ERR_FATAL,
- "or disable auto-config in the conf file before running.");
+ FatalError("or disable auto-config in the conf file before running.");
}
} else {
SCLogInfo("Registering Napatech device: %s - active stream%sfound.",
/* Expect device to be of the form nt%d where %d is the stream id to use */
int dev_len = strlen(device);
if (dev_len < 3 || dev_len > 5) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Could not parse config for device: %s - invalid length", device);
+ SCLogError("Could not parse config for device: %s - invalid length", device);
return NULL;
}
struct NapatechStreamDevConf *conf = SCCalloc(1, sizeof (struct NapatechStreamDevConf));
if (unlikely(conf == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate memory for NAPATECH device name.");
+ SCLogError("Failed to allocate memory for NAPATECH device name.");
return NULL;
}
/* device+2 is a pointer to the beginning of the stream id after the constant nt portion */
if (StringParseUint16(&conf->stream_id, 10, 0, device + 2) < 0) {
- SCLogError(SC_EINVAL, "Invalid value for stream_id: %s", device + 2);
+ SCLogError("Invalid value for stream_id: %s", device + 2);
SCFree(conf);
return NULL;
}
if (ConfGetInt("napatech.hba", &conf->hba) == 0) {
conf->hba = -1;
} else {
- SCLogWarning(SC_WARN_COMPATIBILITY,
- "Napatech Host Buffer Allocation (hba) will be deprecated in Suricata v7.0.");
+ SCLogWarning("Napatech Host Buffer Allocation (hba) will be deprecated in Suricata v7.0.");
}
return (void *) conf;
}
/* Initialize the API and check version compatibility */
if ((status = NT_Init(NTAPI_VERSION)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
status = NapatechRegisterDeviceStreams();
if (status < 0 || num_configured_streams <= 0) {
- FatalError(SC_ERR_FATAL,
- "Unable to find existing Napatech Streams");
+ FatalError("Unable to find existing Napatech Streams");
}
struct NapatechStreamDevConf *conf =
SCCalloc(1, sizeof (struct NapatechStreamDevConf));
if (unlikely(conf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH device.");
+ FatalError("Failed to allocate memory for NAPATECH device.");
}
if ((ConfGetInt("napatech.hba", &conf->hba) != 0) && (conf->hba > 0)) {
if (NapatechVerifyBypassSupport()) {
SCLogInfo("Napatech Hardware Bypass is supported and enabled.");
} else {
- FatalError(SC_ERR_FATAL,
- "Napatech Hardware Bypass requested in conf but is not supported by the hardware.");
+ FatalError("Napatech Hardware Bypass requested in conf but is not supported by the "
+ "hardware.");
}
#else
- FatalError(SC_ERR_FATAL,
- "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
+ FatalError(
+ "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
#endif
} else {
SCLogInfo("Hardware Bypass is disabled in the conf file.");
}
if (status != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
return 0;
}
if (ns->iface[0]) {
size_t len = strlen(ns->iface);
if (ns->iface[len-1] == '+') {
- SCLogWarning(SC_WARN_OPTION_OBSOLETE,
- "netmap interface %s uses obsolete '+' notation. "
- "Using '^' instead.", ns->iface);
+ SCLogWarning("netmap interface %s uses obsolete '+' notation. Using '^' instead.",
+ ns->iface);
ns->iface[len-1] = '^';
ns->sw_ring = true;
} else if (ns->iface[len-1] == '^') {
ns->threads_auto = true;
} else {
if (StringParseUint16(&ns->threads, 10, 0, threadsstr) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid config value for "
- "threads: %s, resetting to 0",
- threadsstr);
+ SCLogWarning("Invalid config value for threads: %s, resetting to 0", threadsstr);
ns->threads = 0;
}
}
} else if (ConfValIsFalse(tmpctype)) {
ns->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid value for "
- "checksum-checks for %s", iface);
+ SCLogWarning("Invalid value for checksum-checks for %s", iface);
}
}
} else if (strcmp(copymodestr, "tap") == 0) {
ns->copy_mode = NETMAP_COPY_MODE_TAP;
} else {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid copy-mode "
- "(valid are tap, ips)");
+ SCLogWarning("Invalid copy-mode (valid are tap, ips)");
}
}
for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
const char *copymodestr = NULL;
if (if_root == NULL) {
if (if_default == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = if_default;
}
if (has_ids && has_ips) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Netmap using both IPS and TAP/IDS mode, this will not be "
- "allowed in Suricata 8 due to undefined behavior. See ticket #5588.");
+ SCLogWarning("Netmap using both IPS and TAP/IDS mode, this will not be allowed in Suricata "
+ "8 due to undefined behavior. See ticket #5588.");
for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev);
if (if_root == NULL) {
if (if_default == NULL) {
- SCLogError(SC_EINVAL, "Problem with config file");
+ SCLogError("Problem with config file");
return 0;
}
if_root = if_default;
if (! ((ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) &&
(strcmp(copymodestr, "ips") == 0))) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Netmap IPS mode used and interface '%s' is in IDS or TAP mode. "
- "Sniffing '%s' but expect bad result as stream-inline is activated.",
+ SCLogError("Netmap IPS mode used and interface '%s' is in IDS or TAP mode. "
+ "Sniffing '%s' but expect bad result as stream-inline is activated.",
live_dev, live_dev);
}
}
break;
}
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode %s",
- runmode == NETMAP_AUTOFP ? "autofp"
- : runmode == NETMAP_WORKERS ? "workers" : "single");
+ FatalError("Unable to start runmode %s", runmode == NETMAP_AUTOFP ? "autofp"
+ : runmode == NETMAP_WORKERS ? "workers"
+ : "single");
}
SCLogDebug("%s initialized",
int RunModeIdsNetmapAutoFp(void)
{
SCEnter();
- FatalError(SC_ERR_FATAL, "Netmap not configured");
+ FatalError("Netmap not configured");
SCReturnInt(0);
}
int RunModeIdsNetmapSingle(void)
{
SCEnter();
- FatalError(SC_ERR_FATAL, "Netmap not configured");
+ FatalError("Netmap not configured");
SCReturnInt(0);
}
int RunModeIdsNetmapWorkers(void)
{
SCEnter();
- FatalError(SC_ERR_FATAL, "Netmap not configured");
+ FatalError("Netmap not configured");
SCReturnInt(0);
}
#endif // #ifdef HAVE_NETMAP
strlcpy(nflogconf->numgroup, group, sizeof(nflogconf->numgroup));
if (ParseSizeStringU16(group, &nflogconf->group) < 0) {
- FatalError(SC_ERR_FATAL, "NFLOG's group number invalid.");
+ FatalError("NFLOG's group number invalid.");
}
boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
if (boolval)
nflogconf->nlbufsiz = bufsize;
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid buffer-size value");
+ SCLogError("Invalid buffer-size value");
SCFree(nflogconf);
return NULL;
}
if (boolval)
nflogconf->nlbufsiz_max = bufsize_max;
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid max-size value");
+ SCLogError("Invalid max-size value");
SCFree(nflogconf);
return NULL;
}
if (nflogconf->nlbufsiz > nflogconf->nlbufsiz_max) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "buffer-size value larger "
- "than max-size value, adjusting buffer-size");
+ SCLogWarning("buffer-size value larger "
+ "than max-size value, adjusting buffer-size");
nflogconf->nlbufsiz = nflogconf->nlbufsiz_max;
}
if (boolval)
nflogconf->qthreshold = qthreshold;
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid qthreshold value");
+ SCLogError("Invalid qthreshold value");
SCFree(nflogconf);
return NULL;
}
if (boolval)
nflogconf->qtimeout = qtimeout;
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid qtimeout value");
+ SCLogError("Invalid qtimeout value");
SCFree(nflogconf);
return NULL;
}
int ret = RunModeSetLiveCaptureAutoFp(ParseNflogConfig, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "DecodeNFLOG", thread_name_autofp, NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogAutoFp initialised");
int ret = RunModeSetLiveCaptureSingle(ParseNflogConfig, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "DecodeNFLOG", thread_name_single, NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogSingle initialised");
int ret = RunModeSetLiveCaptureWorkers(ParseNflogConfig, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "DecodeNFLOG", thread_name_workers, NULL);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogWorkers initialised");
char tname[TM_THREAD_NAME_MAX];
if (ConfGet("pcap-file.file", &file) == 0) {
- FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
+ FatalError("Failed retrieving pcap-file from Conf");
}
RunModeInitialize();
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
- FatalError(SC_ERR_FATAL, "threading setup failed");
+ FatalError("threading setup failed");
}
TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
+ FatalError("TmModuleGetByName failed for ReceivePcap");
}
TmSlotSetFuncAppend(tv, tm_module, file);
tm_module = TmModuleGetByName("DecodePcapFile");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
+ FatalError("TmModuleGetByName DecodePcap failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
TmThreadSetCPU(tv, WORKER_CPU_SET);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
return 0;
}
const char *file = NULL;
if (ConfGet("pcap-file.file", &file) == 0) {
- FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
+ FatalError("Failed retrieving pcap-file from Conf");
}
SCLogDebug("file %s", file);
queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- FatalError(SC_ERR_FATAL,
- "RunmodeAutoFpCreatePickupQueuesString failed");
+ FatalError("RunmodeAutoFpCreatePickupQueuesString failed");
}
snprintf(tname, sizeof(tname), "%s#01", thread_name_autofp);
SCFree(queues);
if (tv_receivepcap == NULL) {
- FatalError(SC_ERR_FATAL, "threading setup failed");
+ FatalError("threading setup failed");
}
TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
+ FatalError("TmModuleGetByName failed for ReceivePcap");
}
TmSlotSetFuncAppend(tv_receivepcap, tm_module, file);
tm_module = TmModuleGetByName("DecodePcapFile");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
+ FatalError("TmModuleGetByName DecodePcap failed");
}
TmSlotSetFuncAppend(tv_receivepcap, tm_module, NULL);
TmThreadSetCPU(tv_receivepcap, RECEIVE_CPU_SET);
if (TmThreadSpawn(tv_receivepcap) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
for (thread = 0; thread < (uint16_t)thread_max; thread++) {
"packetpool", "packetpool",
"varslot");
if (tv_detect_ncpu == NULL) {
- FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_FATAL,
- "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
TmThreadSetCPU(tv_detect_ncpu, WORKER_CPU_SET);
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
if ((cpu + 1) == ncpus)
SCLogInfo("Pcap will use %d buffer size", (int)value);
aconf->buffer_size = value;
} else {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "pcap.buffer-size "
- "value of %"PRIiMAX" is invalid. Valid range is "
- "0-2147483647", value);
+ SCLogWarning("pcap.buffer-size "
+ "value of %" PRIiMAX " is invalid. Valid range is "
+ "0-2147483647",
+ value);
}
}
} else {
if (threadsstr != NULL) {
if (StringParseInt32(&aconf->threads, 10, 0, (const char *)threadsstr) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pcap.threads: %s, resetting to 1",
+ SCLogWarning("Invalid value for "
+ "pcap.threads: %s, resetting to 1",
threadsstr);
aconf->threads = 1;
}
uint64_t bsize = 0;
if (ParseSizeStringU64(s_limit, &bsize) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to parse pcap buffer size: %s",
- s_limit);
+ SCLogError("Failed to parse pcap buffer size: %s", s_limit);
} else {
/* the string 2gb returns 2147483648 which is 1 to high
* for a int. */
bsize = (uint64_t)INT_MAX;
if (bsize > INT_MAX) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to set pcap buffer size: 2gb max. %"PRIu64" > %d", bsize, INT_MAX);
+ SCLogError("Failed to set pcap buffer size: 2gb max. %" PRIu64 " > %d", bsize,
+ INT_MAX);
} else {
aconf->buffer_size = (int)bsize;
}
} else if (ConfValIsFalse(tmpctype)) {
aconf->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid value for checksum-checks for %s", aconf->iface);
+ SCLogError("Invalid value for checksum-checks for %s", aconf->iface);
}
}
"DecodePcap", thread_name_single,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
SCLogInfo("RunModeIdsPcapSingle initialised");
"DecodePcap", thread_name_autofp,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
SCLogInfo("RunModeIdsPcapAutoFp initialised");
"DecodePcap", thread_name_workers,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Unable to start runmode");
+ FatalError("Unable to start runmode");
}
SCLogInfo("RunModeIdsPcapWorkers initialised");
} else {
if (threadsstr != NULL) {
if (StringParseInt32(&pfconf->threads, 10, 0, threadsstr) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pfring.threads: '%s'. Resetting to 1.",
+ SCLogWarning("Invalid value for "
+ "pfring.threads: '%s'. Resetting to 1.",
threadsstr);
pfconf->threads = 1;
}
else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster-id");
} else if (ConfGet("pfring.cluster-id", &tmpclusterid) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config");
+ SCLogError("Could not get cluster-id from config");
} else {
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pfring.cluster_id: '%s'. Resetting to 1.",
+ SCLogWarning("Invalid value for "
+ "pfring.cluster_id: '%s'. Resetting to 1.",
tmpclusterid);
pfconf->cluster_id = 1;
}
SCLogInfo("DNA interface detected, not setting cluster type for PF_RING (iface %s)",
pfconf->iface);
} else if (ConfGet("pfring.cluster-type", &tmpctype) != 1) {
- SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get cluster-type from config");
+ SCLogError("Could not get cluster-type from config");
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)",
pfconf->iface);
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype;
} else {
- SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype);
+ SCLogError("invalid cluster-type %s", tmpctype);
SCFree(pfconf);
return NULL;
}
} else {
uint16_t threads = 0;
if (StringParseUint16(&threads, 10, 0, (const char *)threadsstr) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pfring.threads: '%s'. Resetting to 1.",
+ SCLogWarning("Invalid value for "
+ "pfring.threads: '%s'. Resetting to 1.",
threadsstr);
pfconf->threads = 1;
} else {
/* command line value has precedence */
if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pfring.cluster-id: '%s'. Resetting to 1.",
+ SCLogWarning("Invalid value for "
+ "pfring.cluster-id: '%s'. Resetting to 1.",
tmpclusterid);
pfconf->cluster_id = 1;
}
SCLogInfo("DNA interface detected, not setting cluster-id for PF_RING (iface %s)",
pfconf->iface);
} else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Could not get cluster-id from config");
+ SCLogError("Could not get cluster-id from config");
} else {
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for "
- "pfring.cluster-id: '%s'. Resetting to 1.",
+ SCLogWarning("Invalid value for "
+ "pfring.cluster-id: '%s'. Resetting to 1.",
tmpclusterid);
pfconf->cluster_id = 1;
}
if (strlen(bpf_filter) > 0) {
pfconf->bpf_filter = SCStrdup(bpf_filter);
if (unlikely(pfconf->bpf_filter == NULL)) {
- SCLogError(SC_ENOMEM, "Can't allocate BPF filter string");
+ SCLogError("Can't allocate BPF filter string");
} else {
SCLogDebug("Going to use command-line provided bpf filter %s",
pfconf->bpf_filter);
if (strlen(bpf_filter) > 0) {
pfconf->bpf_filter = SCStrdup(bpf_filter);
if (unlikely(pfconf->bpf_filter == NULL)) {
- SCLogError(SC_ENOMEM, "Can't allocate BPF filter string");
+ SCLogError("Can't allocate BPF filter string");
} else {
SCLogDebug("Going to use bpf filter %s",
pfconf->bpf_filter);
SCLogInfo("DNA interface detected, not setting cluster type for PF_RING (iface %s)",
pfconf->iface);
} else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) {
- SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,
- "Could not get cluster-type from config");
+ SCLogError("Could not get cluster-type from config");
} else {
getctype = 1;
}
pfconf->iface);
pfconf->ctype = CLUSTER_FLOW;
} else {
- SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,
- "invalid cluster-type %s",
- tmpctype);
+ SCLogError("invalid cluster-type %s", tmpctype);
SCFree(pfconf);
return NULL;
}
} else if (strcmp(tmpctype, "rx-only") == 0) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_RXONLY;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid value for checksum-checks for %s", pfconf->iface);
+ SCLogError("Invalid value for checksum-checks for %s", pfconf->iface);
}
}
SCLogConfig("Enabling bypass support in PF_RING for iface %s (if supported by underlying hw)", pfconf->iface);
pfconf->flags |= PFRING_CONF_FLAGS_BYPASS;
#else
- SCLogError(SC_ERR_BYPASS_NOT_SUPPORTED, "Bypass is not supported by this Pfring version, please upgrade");
+ SCLogError("Bypass is not supported by this Pfring version, please upgrade");
SCFree(pfconf);
return NULL;
#endif
if (LiveGetOffload() == 0) {
if (GetIfaceOffloading(iface, 0, 1) == 1) {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "Using PF_RING with offloading activated leads to capture problems");
+ SCLogWarning("Using PF_RING with offloading activated leads to capture problems");
}
} else {
DisableIfaceOffloading(LiveGetDevice(iface), 0, 1);
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- FatalError(SC_ERR_FATAL,
- "Unable to get parser and interface params");
+ FatalError("Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureAutoFp(tparser,
"DecodePfring", thread_name_autofp,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
SCLogInfo("RunModeIdsPfringAutoFp initialised");
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- FatalError(SC_ERR_FATAL,
- "Unable to get parser and interface params");
+ FatalError("Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureSingle(tparser,
"DecodePfring", thread_name_single,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
SCLogInfo("RunModeIdsPfringSingle initialised");
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- FatalError(SC_ERR_FATAL,
- "Unable to get parser and interface params");
+ FatalError("Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureWorkers(tparser,
"DecodePfring", thread_name_workers,
live_dev);
if (ret != 0) {
- FatalError(SC_ERR_FATAL, "Runmode start failed");
+ FatalError("Runmode start failed");
}
SCLogInfo("RunModeIdsPfringWorkers initialised");
exit(EXIT_SUCCESS);
#else
- FatalError(SC_ERR_FATAL, "Unittests are not build-in");
+ FatalError("Unittests are not build-in");
#endif /* UNITTESTS */
}
return TM_ECODE_FAILED;
cfile = SCMalloc(sizeof(PcapFiles));
if (unlikely(cfile == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to allocate new file");
+ SCLogError("Unable to allocate new file");
return TM_ECODE_FAILED;
}
memset(cfile, 0, sizeof(PcapFiles));
cfile->filename = SCStrdup(filename);
if (unlikely(cfile->filename == NULL)) {
SCFree(cfile);
- SCLogError(SC_ENOMEM, "Unable to dup filename");
+ SCLogError("Unable to dup filename");
return TM_ECODE_FAILED;
}
if (unlikely(cfile->output_dir == NULL)) {
SCFree(cfile->filename);
SCFree(cfile);
- SCLogError(SC_ENOMEM, "Unable to dup output_dir");
+ SCLogError("Unable to dup output_dir");
return TM_ECODE_FAILED;
}
}
json_t *jarg = json_object_get(cmd, "filename");
if (!json_is_string(jarg)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "filename is not a string");
+ SCLogError("filename is not a string");
json_object_set_new(answer, "message",
json_string("filename is not a string"));
return TM_ECODE_FAILED;
json_t *oarg = json_object_get(cmd, "output-dir");
if (oarg != NULL) {
if (!json_is_string(oarg)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "output-dir is not a string");
+ SCLogError("output-dir is not a string");
json_object_set_new(answer, "message",
json_string("output-dir is not a string"));
}
output_dir = json_string_value(oarg);
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "can't get output-dir");
+ SCLogError("can't get output-dir");
json_object_set_new(answer, "message",
json_string("output-dir param is mandatory"));
json_t *delay_arg = json_object_get(cmd, "delay");
if (delay_arg != NULL) {
if (!json_is_integer(delay_arg)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "delay is not a integer");
+ SCLogError("delay is not a integer");
json_object_set_new(answer, "message",
json_string("delay is not a integer"));
return TM_ECODE_FAILED;
json_t *interval_arg = json_object_get(cmd, "poll-interval");
if (interval_arg != NULL) {
if (!json_is_integer(interval_arg)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "poll-interval is not a integer");
+ SCLogError("poll-interval is not a integer");
json_object_set_new(answer, "message",
json_string("poll-interval is not a integer"));
this->running = 1;
if (ConfSetFinal("pcap-file.file", cfile->filename) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Can not set working file to '%s'",
- cfile->filename);
+ SCLogError("Can not set working file to '%s'", cfile->filename);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
set_res = ConfSetFinal("pcap-file.continuous", "false");
}
if (set_res != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Can not set continuous mode for pcap processing");
+ SCLogError("Can not set continuous mode for pcap processing");
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
set_res = ConfSetFinal("pcap-file.delete-when-done", "false");
}
if (set_res != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Can not set delete mode for pcap processing");
+ SCLogError("Can not set delete mode for pcap processing");
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
char tstr[32];
snprintf(tstr, sizeof(tstr), "%" PRIuMAX, (uintmax_t)cfile->delay);
if (ConfSetFinal("pcap-file.delay", tstr) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Can not set delay to '%s'", tstr);
+ SCLogError("Can not set delay to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
char tstr[32];
snprintf(tstr, sizeof(tstr), "%" PRIuMAX, (uintmax_t)cfile->poll_interval);
if (ConfSetFinal("pcap-file.poll-interval", tstr) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Can not set poll-interval to '%s'", tstr);
+ SCLogError("Can not set poll-interval to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
char tstr[16];
snprintf(tstr, sizeof(tstr), "%d", cfile->tenant_id);
if (ConfSetFinal("pcap-file.tenant-id", tstr) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Can not set working tenant-id to '%s'", tstr);
+ SCLogError("Can not set working tenant-id to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
if (cfile->output_dir) {
if (ConfSetFinal("default-log-dir", cfile->output_dir) != 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Can not set output dir to '%s'", cfile->output_dir);
+ SCLogError("Can not set output dir to '%s'", cfile->output_dir);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
char prefix[64];
snprintf(prefix, sizeof(prefix), "multi-detect.%d", tenant_id);
if (ConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "failed to load yaml %s", filename);
+ SCLogError("failed to load yaml %s", filename);
json_object_set_new(answer, "message", json_string("failed to load yaml"));
return TM_ECODE_FAILED;
}
value_str = (char *)json_string_value(jarg);
if (ParseSizeStringU64(value_str, &value) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
- "memcap from unix socket: %s", value_str);
+ SCLogError("Error parsing "
+ "memcap from unix socket: %s",
+ value_str);
json_object_set_new(answer, "message",
json_string("error parsing memcap specified, "
"value not changed"));
PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand));
if (unlikely(pcapcmd == NULL)) {
- SCLogError(SC_ENOMEM, "Can not allocate pcap command");
+ SCLogError("Can not allocate pcap command");
return 1;
}
TAILQ_INIT(&pcapcmd->files);
#endif
default:
- FatalError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting");
+ FatalError("Unknown runtime mode. Aborting");
}
}
#ifdef HAVE_PLUGINS
SCCapturePlugin *plugin = SCPluginFindCaptureByName(capture_plugin_name);
if (plugin == NULL) {
- FatalError(SC_ERR_PLUGIN, "No capture plugin found with name %s",
- capture_plugin_name);
+ FatalError("No capture plugin found with name %s", capture_plugin_name);
}
custom_mode = (const char *)plugin->GetDefaultMode();
#endif
break;
#endif
default:
- FatalError(SC_ERR_FATAL, "Unknown runtime mode. Aborting");
+ FatalError("Unknown runtime mode. Aborting");
}
} else { /* if (custom_mode == NULL) */
/* Add compability with old 'worker' name */
if (!strcmp("worker", custom_mode)) {
- SCLogWarning(SC_ERR_RUNMODE, "'worker' mode have been renamed "
+ SCLogWarning("'worker' mode have been renamed "
"to 'workers', please modify your setup.");
local_custom_mode = SCStrdup("workers");
if (unlikely(local_custom_mode == NULL)) {
- FatalError(SC_ERR_FATAL, "Unable to dup custom mode");
+ FatalError("Unable to dup custom mode");
}
custom_mode = local_custom_mode;
}
RunMode *mode = RunModeGetCustomMode(runmode, custom_mode);
if (mode == NULL) {
- SCLogError(SC_ERR_RUNMODE, "The custom type \"%s\" doesn't exist "
+ SCLogError("The custom type \"%s\" doesn't exist "
"for this runmode type \"%s\". Please use --list-runmodes to "
"see available custom types for this runmode",
- custom_mode, RunModeTranslateModeToName(runmode));
+ custom_mode, RunModeTranslateModeToName(runmode));
exit(EXIT_FAILURE);
}
}
active_runmode = SCStrdup(custom_mode);
if (unlikely(active_runmode == NULL)) {
- FatalError(SC_ERR_FATAL, "Unable to dup active mode");
+ FatalError("Unable to dup active mode");
}
if (strcasecmp(active_runmode, "autofp") == 0) {
int (*RunModeFunc)(void))
{
if (RunModeGetCustomMode(runmode, name) != NULL) {
- FatalError(SC_ERR_RUNMODE, "runmode '%s' has already "
- "been registered. Please use an unique name.", name);
+ FatalError("runmode '%s' has already "
+ "been registered. Please use an unique name.",
+ name);
}
void *ptmp = SCRealloc(runmodes[runmode].runmodes,
mode->runmode = runmode;
mode->name = SCStrdup(name);
if (unlikely(mode->name == NULL)) {
- FatalError(SC_ENOMEM, "Failed to allocate string");
+ FatalError("Failed to allocate string");
}
mode->description = SCStrdup(description);
if (unlikely(mode->description == NULL)) {
- FatalError(SC_ENOMEM, "Failed to allocate string");
+ FatalError("Failed to allocate string");
}
mode->RunModeFunc = RunModeFunc;
module->ThreadInit, module->ThreadDeinit,
module->ThreadExitPrintStats);
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Unknown logger type: name=%s",
- module->name);
+ SCLogError("Unknown logger type: name=%s", module->name);
}
}
char subname[256];
if (strcmp(type->val, "ikev2") == 0) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "eve module 'ikev2' has been replaced by 'ike'");
+ SCLogWarning("eve module 'ikev2' has been replaced by 'ike'");
strlcpy(subname, "eve-log.ike", sizeof(subname));
} else {
snprintf(subname, sizeof(subname), "eve-log.%s", type->val);
if (sub_module->parent_name == NULL ||
strcmp(sub_module->parent_name, "eve-log") != 0) {
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "bad parent for %s", subname);
+ FatalError("bad parent for %s", subname);
}
if (sub_module->InitSubFunc == NULL) {
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "bad sub-module for %s", subname);
+ FatalError("bad sub-module for %s", subname);
}
/* pass on parent output_ctx */
/* Error is no registered loggers with this name
* were found .*/
if (!sub_count) {
- FatalErrorOnInit(SC_ERR_INVALID_ARGUMENT,
- "No output module named %s", subname);
+ FatalErrorOnInit("No output module named %s", subname);
continue;
}
}
output_config = ConfNodeLookupChild(output, output->val);
if (output_config == NULL) {
/* Shouldn't happen. */
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "Failed to lookup configuration child node: %s", output->val);
+ FatalError("Failed to lookup configuration child node: %s", output->val);
}
if (strcmp(output->val, "tls-store") == 0) {
}
if (strcmp(output->val, "file-log") == 0) {
- SCLogWarning(SC_ERR_NOT_SUPPORTED, "file-log is no longer supported,"
- " use eve.files instead "
- "(see ticket #2376"
- " for an explanation)");
+ SCLogWarning("file-log is no longer supported,"
+ " use eve.files instead "
+ "(see ticket #2376"
+ " for an explanation)");
continue;
} else if (strncmp(output->val, "unified-", sizeof("unified-") - 1) == 0) {
- SCLogWarning(SC_ERR_NOT_SUPPORTED, "Unified1 is no longer supported,"
- " use Unified2 instead "
- "(see ticket #353"
- " for an explanation)");
+ SCLogWarning("Unified1 is no longer supported,"
+ " use Unified2 instead "
+ "(see ticket #353"
+ " for an explanation)");
continue;
} else if (strncmp(output->val, "unified2-", sizeof("unified2-") - 1) == 0) {
- SCLogWarning(SC_ERR_NOT_SUPPORTED,
- "Unified2 is no longer supported.");
+ SCLogWarning("Unified2 is no longer supported.");
continue;
} else if (strcmp(output->val, "lua") == 0) {
#ifndef HAVE_LUA
- SCLogWarning(SC_ERR_NOT_SUPPORTED,
- "lua support not compiled in. Reconfigure/"
- "recompile with lua(jit) and its development "
- "files installed to add lua support.");
+ SCLogWarning("lua support not compiled in. Reconfigure/"
+ "recompile with lua(jit) and its development "
+ "files installed to add lua support.");
continue;
#endif
} else if (strcmp(output->val, "dns-log") == 0) {
- SCLogWarning(SC_ERR_NOT_SUPPORTED,
- "dns-log is not longer available as of Suricata 5.0");
+ SCLogWarning("dns-log is not longer available as of Suricata 5.0");
continue;
} else if (strcmp(output->val, "tls-log") == 0) {
tls_log_enabled = 1;
if (module->InitFunc != NULL) {
OutputInitResult r = module->InitFunc(output_config);
if (!r.ok) {
- FatalErrorOnInit(SC_ERR_INVALID_ARGUMENT,
- "output module \"%s\": setup failed", output->val);
+ FatalErrorOnInit("output module \"%s\": setup failed", output->val);
continue;
} else if (r.ctx == NULL) {
continue;
}
}
if (count == 0) {
- FatalErrorOnInit(SC_ERR_INVALID_ARGUMENT,
- "No output module named %s", output->val);
+ FatalErrorOnInit("No output module named %s", output->val);
continue;
}
}
if (!tls_store_present && tls_log_enabled) {
/* old YAML with no "tls-store" in outputs. "tls-log" value needs
* to be started using 'tls-log' config as own config */
- SCLogWarning(SC_ERR_CONF_YAML_ERROR,
- "Please use 'tls-store' in YAML to configure TLS storage");
+ SCLogWarning("Please use 'tls-store' in YAML to configure TLS storage");
TAILQ_FOREACH(output, &outputs->head, next) {
output_config = ConfNodeLookupChild(output, output->val);
OutputModule *module = OutputGetModuleByConfName("tls-store");
if (module == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "No output module named %s, ignoring", "tls-store");
+ SCLogWarning("No output module named %s, ignoring", "tls-store");
continue;
}
if (module->InitFunc != NULL) {
OutputInitResult r = module->InitFunc(output_config);
if (!r.ok) {
- FatalErrorOnInit(SC_ERR_INVALID_ARGUMENT,
- "output module setup failed");
+ FatalErrorOnInit("output module setup failed");
continue;
} else if (r.ctx == NULL) {
continue;
if ((ConfGet("threading.stack-size", &ss)) == 1) {
if (ss != NULL) {
if (ParseSizeStringU64(ss, &threading_set_stack_size) < 0) {
- FatalError(SC_ERR_INVALID_ARGUMENT,
- "Failed to initialize thread_stack_size output, invalid limit: %s", ss);
+ FatalError("Failed to initialize thread_stack_size output, invalid limit: %s", ss);
}
}
}
struct AppLayerParser;
typedef struct SuricataContext_ {
- SCError (*SCLogMessage)(const SCLogLevel, const char *, const unsigned int,
- const char *, const SCError, const char *message);
+ SCError (*SCLogMessage)(
+ const SCLogLevel, const char *, const unsigned int, const char *, const char *message);
void (*DetectEngineStateFree)(DetectEngineState *);
void (*AppLayerDecoderEventsSetEventRaw)(AppLayerDecoderEvents **,
uint8_t);
*/
TmEcode NoAFPSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_NO_AF_PACKET,"Error creating thread %s: you do not have "
+ SCLogError("Error creating thread %s: you do not have "
"support for AF_PACKET enabled, on Linux host please recompile "
- "with --enable-af-packet", tv->name);
+ "with --enable-af-packet",
+ tv->name);
exit(EXIT_FAILURE);
}
}
try++;
}
- SCLogError(SC_ERR_AFP_CREATE, "Threads number not equals");
+ SCLogError("Threads number not equals");
SCReturnInt(TM_ECODE_FAILED);
}
mtu = GetIfaceMTU(ptv->iface);
out_mtu = GetIfaceMTU(ptv->out_iface);
if (mtu != out_mtu) {
- SCLogError(SC_ERR_AFP_CREATE,
- "MTU on %s (%d) and %s (%d) are not equal, "
- "transmission of packets bigger than %d will fail.",
- ptv->iface, mtu,
- ptv->out_iface, out_mtu,
- (out_mtu > mtu) ? mtu : out_mtu);
+ SCLogError("MTU on %s (%d) and %s (%d) are not equal, "
+ "transmission of packets bigger than %d will fail.",
+ ptv->iface, mtu, ptv->out_iface, out_mtu, (out_mtu > mtu) ? mtu : out_mtu);
}
peerslist.peered += 2;
break;
}
if (p->ethh == NULL) {
- SCLogWarning(SC_EINVAL, "Should have an Ethernet header");
+ SCLogWarning("Should have an Ethernet header");
return;
}
if (sendto(socket, GET_PKT_DATA(p), GET_PKT_LEN(p), 0, (struct sockaddr *)&socket_address,
sizeof(struct sockaddr_ll)) < 0) {
if (SC_ATOMIC_ADD(p->afp_v.peer->send_errors, 1) == 0) {
- SCLogWarning(SC_ERR_SOCKET, "sending packet failed on socket %d: %s", socket,
- strerror(errno));
+ SCLogWarning("sending packet failed on socket %d: %s", socket, strerror(errno));
}
}
if (p->afp_v.peer->flags & AFP_SOCK_PROTECT)
int r = poll(&fds, 1, POLL_TIMEOUT);
if (r > 0 &&
(fds.revents & (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL))) {
- SCLogWarning(SC_ERR_AFP_READ, "poll failed %02x",
- fds.revents & (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL));
+ SCLogWarning(
+ "poll failed %02x", fds.revents & (POLLHUP | POLLRDHUP | POLLERR | POLLNVAL));
return 0;
} else if (r > 0) {
if (AFPPeersListStarted() && synctv.tv_sec == (time_t) 0xffffffff) {
SCLogDebug("Starting to read on %s", ptv->tv->name);
return 1;
} else if (r < 0) { /* only exit on error */
- SCLogWarning(SC_ERR_AFP_READ, "poll failed with retval %d", r);
+ SCLogWarning("poll failed with retval %d", r);
return 0;
}
}
int afp_activate_r = AFPCreateSocket(ptv, ptv->iface, 0);
if (afp_activate_r != 0) {
if (ptv->down_count % AFP_DOWN_COUNTER_INTERVAL == 0) {
- SCLogWarning(SC_ERR_AFP_CREATE, "Can not open iface '%s'",
- ptv->iface);
+ SCLogWarning("Can not open iface '%s'", ptv->iface);
}
return afp_activate_r;
}
if (r < 0) {
switch (-r) {
case AFP_FATAL_ERROR:
- SCLogError(SC_ERR_AFP_CREATE, "Couldn't init AF_PACKET socket, fatal error");
+ SCLogError("Couldn't init AF_PACKET socket, fatal error");
SCReturnInt(TM_ECODE_FAILED);
case AFP_RECOVERABLE_ERROR:
- SCLogWarning(SC_ERR_AFP_CREATE, "Couldn't init AF_PACKET socket, retrying soon");
+ SCLogWarning("Couldn't init AF_PACKET socket, retrying soon");
}
}
AFPPeersListReachedInc();
/* Do a recv to get errno */
if (recv(ptv->socket, &c, sizeof c, MSG_PEEK) != -1)
continue; /* what, no error? */
- SCLogError(SC_ERR_AFP_READ,
- "Error reading data from iface '%s': (%d) %s",
- ptv->iface, errno, strerror(errno));
+ SCLogError("Error reading data from iface '%s': (%d) %s", ptv->iface, errno,
+ strerror(errno));
AFPSwitchState(ptv, AFP_STATE_DOWN);
continue;
} else if (fds.revents & POLLNVAL) {
- SCLogError(SC_ERR_AFP_READ, "Invalid polling request");
+ SCLogError("Invalid polling request");
AFPSwitchState(ptv, AFP_STATE_DOWN);
continue;
}
break;
case AFP_READ_FAILURE:
/* AFPRead in error: best to reset the socket */
- SCLogError(SC_ERR_AFP_READ,
- "AFPRead error reading data from iface '%s': (%d) %s",
- ptv->iface, errno, strerror(errno));
+ SCLogError("AFPRead error reading data from iface '%s': (%d) %s", ptv->iface,
+ errno, strerror(errno));
AFPSwitchState(ptv, AFP_STATE_DOWN);
continue;
case AFP_SURI_FAILURE:
} else if ((r < 0) && (errno != EINTR)) {
StatsIncr(ptv->tv, ptv->capture_afp_poll_err);
- SCLogError(SC_ERR_AFP_READ, "Error reading data from iface '%s': (%d) %s",
- ptv->iface,
- errno, strerror(errno));
+ SCLogError("Error reading data from iface '%s': (%d) %s", ptv->iface, errno,
+ strerror(errno));
AFPSwitchState(ptv, AFP_STATE_DOWN);
continue;
}
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Unable to find type for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to find type for iface \"%s\": %s", ifname, strerror(errno));
return -1;
}
if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) {
if (verbose)
- SCLogError(SC_ERR_AFP_CREATE, "Unable to find iface %s: %s",
- ifname, strerror(errno));
+ SCLogError("Unable to find iface %s: %s", ifname, strerror(errno));
return -1;
}
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Unable to find type for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to find type for iface \"%s\": %s", ifname, strerror(errno));
return -1;
}
int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (fd == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Couldn't create a AF_PACKET socket, error %s", strerror(errno));
+ SCLogError("Couldn't create a AF_PACKET socket, error %s", strerror(errno));
return LINKTYPE_RAW;
}
if (snaplen == 0) {
snaplen = GetIfaceMaxPacketSize(ptv->iface);
if (snaplen <= 0) {
- SCLogWarning(SC_EINVAL, "Unable to get MTU, setting snaplen to sane default of 1514");
+ SCLogWarning("Unable to get MTU, setting snaplen to sane default of 1514");
snaplen = 1514;
}
}
ptv->req.v2.tp_block_size = getpagesize() << order;
int frames_per_block = ptv->req.v2.tp_block_size / ptv->req.v2.tp_frame_size;
if (frames_per_block == 0) {
- SCLogError(SC_EINVAL, "Frame size bigger than block size");
+ SCLogError("Frame size bigger than block size");
return -1;
}
ptv->req.v2.tp_frame_nr = ptv->ring_size;
if (snaplen == 0) {
snaplen = GetIfaceMaxPacketSize(ptv->iface);
if (snaplen <= 0) {
- SCLogWarning(SC_EINVAL, "Unable to get MTU, setting snaplen to sane default of 1514");
+ SCLogWarning("Unable to get MTU, setting snaplen to sane default of 1514");
snaplen = 1514;
}
}
frames_per_block = ptv->req.v3.tp_block_size / ptv->req.v3.tp_frame_size;
if (frames_per_block == 0) {
- SCLogError(SC_EINVAL, "Block size is too small, it should be at least %d",
- ptv->req.v3.tp_frame_size);
+ SCLogError("Block size is too small, it should be at least %d", ptv->req.v3.tp_frame_size);
return -1;
}
ptv->req.v3.tp_block_nr = ptv->ring_size / frames_per_block + 1;
if (getsockopt(ptv->socket, SOL_PACKET, PACKET_HDRLEN, &val, &len) < 0) {
if (errno == ENOPROTOOPT) {
if (ptv->flags & AFP_TPACKET_V3) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Too old kernel giving up (need 3.2 for TPACKET_V3)");
+ SCLogError("Too old kernel giving up (need 3.2 for TPACKET_V3)");
} else {
- SCLogError(SC_ERR_AFP_CREATE,
- "Too old kernel giving up (need 2.6.27 at least)");
+ SCLogError("Too old kernel giving up (need 2.6.27 at least)");
}
}
- SCLogError(SC_ERR_AFP_CREATE, "Error when retrieving packet header len");
+ SCLogError("Error when retrieving packet header len");
return AFP_FATAL_ERROR;
}
#endif
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_VERSION, &val,
sizeof(val)) < 0) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Can't activate TPACKET_V2/TPACKET_V3 on packet socket: %s",
- strerror(errno));
+ SCLogError("Can't activate TPACKET_V2/TPACKET_V3 on packet socket: %s", strerror(errno));
return AFP_FATAL_ERROR;
}
int req = SOF_TIMESTAMPING_RAW_HARDWARE;
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req,
sizeof(req)) < 0) {
- SCLogWarning(SC_ERR_AFP_CREATE,
- "Can't activate hardware timestamping on packet socket: %s",
- strerror(errno));
+ SCLogWarning("Can't activate hardware timestamping on packet socket: %s", strerror(errno));
}
#endif
int reserve = VLAN_HEADER_LEN;
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_RESERVE, (void *)&reserve, sizeof(reserve)) <
0) {
- SCLogError(
- SC_ERR_AFP_CREATE, "Can't activate reserve on packet socket: %s", strerror(errno));
+ SCLogError("Can't activate reserve on packet socket: %s", strerror(errno));
return AFP_FATAL_ERROR;
}
r = setsockopt(ptv->socket, SOL_PACKET, PACKET_RX_RING,
(void *) &ptv->req.v3, sizeof(ptv->req.v3));
if (r < 0) {
- SCLogError(SC_ENOMEM, "Unable to allocate RX Ring for iface %s: (%d) %s", devname,
- errno, strerror(errno));
+ SCLogError("Unable to allocate RX Ring for iface %s: (%d) %s", devname, errno,
+ strerror(errno));
return AFP_FATAL_ERROR;
}
} else {
SCLogInfo("Memory issue with ring parameters. Retrying.");
continue;
}
- SCLogError(SC_EINVAL, "Unable to setup RX Ring for iface %s: (%d) %s", devname,
- errno, strerror(errno));
+ SCLogError("Unable to setup RX Ring for iface %s: (%d) %s", devname, errno,
+ strerror(errno));
return AFP_FATAL_ERROR;
} else {
break;
}
}
if (order < 0) {
- SCLogError(SC_EINVAL, "Unable to setup RX Ring for iface %s (order 0 failed)", devname);
+ SCLogError("Unable to setup RX Ring for iface %s (order 0 failed)", devname);
return AFP_FATAL_ERROR;
}
#ifdef HAVE_TPACKET_V3
ptv->ring_buf = mmap(0, ptv->ring_buflen, PROT_READ|PROT_WRITE,
mmap_flag, ptv->socket, 0);
if (ptv->ring_buf == MAP_FAILED) {
- SCLogError(SC_ENOMEM, "Unable to mmap, error %s", strerror(errno));
+ SCLogError("Unable to mmap, error %s", strerror(errno));
goto mmap_err;
}
#ifdef HAVE_TPACKET_V3
if (ptv->flags & AFP_TPACKET_V3) {
ptv->ring.v3 = SCMalloc(ptv->req.v3.tp_block_nr * sizeof(*ptv->ring.v3));
if (!ptv->ring.v3) {
- SCLogError(SC_ENOMEM, "Unable to malloc ptv ring.v3");
+ SCLogError("Unable to malloc ptv ring.v3");
goto postmmap_err;
}
for (i = 0; i < ptv->req.v3.tp_block_nr; ++i) {
/* allocate a ring for each frame header pointer*/
ptv->ring.v2 = SCCalloc(ptv->req.v2.tp_frame_nr, sizeof(union thdr *));
if (ptv->ring.v2 == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate frame buf");
+ SCLogError("Unable to allocate frame buf");
goto postmmap_err;
}
/* fill the header ring with proper frame ptr*/
close(fd);
if (r < 0) {
- SCLogError(SC_EINVAL,
- "fanout not supported by kernel: "
- "Kernel too old or cluster-id %d already in use.",
+ SCLogError("fanout not supported by kernel: "
+ "Kernel too old or cluster-id %d already in use.",
cluster_id);
return 0;
}
{
int pfd = ptv->ebpf_lb_fd;
if (pfd == -1) {
- SCLogError(SC_EINVAL, "Fanout file descriptor is invalid");
+ SCLogError("Fanout file descriptor is invalid");
return -1;
}
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_FANOUT_DATA, &pfd, sizeof(pfd))) {
- SCLogError(SC_EINVAL, "Error setting ebpf");
+ SCLogError("Error setting ebpf");
return -1;
}
SCLogInfo("Activated eBPF on socket");
{
int pfd = ptv->ebpf_filter_fd;
if (pfd == -1) {
- SCLogError(SC_EINVAL, "Filter file descriptor is invalid");
+ SCLogError("Filter file descriptor is invalid");
return -1;
}
if (setsockopt(ptv->socket, SOL_SOCKET, SO_ATTACH_BPF, &pfd, sizeof(pfd))) {
- SCLogError(SC_EINVAL, "Error setting ebpf: %s", strerror(errno));
+ SCLogError("Error setting ebpf: %s", strerror(errno));
return -1;
}
SCLogInfo("Activated eBPF filter on socket");
/* open socket */
ptv->socket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (ptv->socket == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Couldn't create a AF_PACKET socket, error %s", strerror(errno));
+ SCLogError("Couldn't create a AF_PACKET socket, error %s", strerror(errno));
goto error;
}
bind_address.sll_ifindex = if_idx;
if (bind_address.sll_ifindex == -1) {
if (verbose)
- SCLogError(SC_ERR_AFP_CREATE, "Couldn't find iface %s", devname);
+ SCLogError("Couldn't find iface %s", devname);
ret = AFP_RECOVERABLE_ERROR;
goto socket_err;
}
int if_flags = AFPGetDevFlags(ptv->socket, ptv->iface);
if (if_flags == -1) {
if (verbose) {
- SCLogError(SC_ERR_AFP_READ,
- "Couldn't get flags for interface '%s'",
- ptv->iface);
+ SCLogError("Couldn't get flags for interface '%s'", ptv->iface);
}
ret = AFP_RECOVERABLE_ERROR;
goto socket_err;
} else if ((if_flags & (IFF_UP | IFF_RUNNING)) == 0) {
if (verbose) {
- SCLogError(SC_ERR_AFP_READ,
- "Interface '%s' is down",
- ptv->iface);
+ SCLogError("Interface '%s' is down", ptv->iface);
}
ret = AFP_RECOVERABLE_ERROR;
goto socket_err;
sock_params.mr_ifindex = bind_address.sll_ifindex;
r = setsockopt(ptv->socket, SOL_PACKET, PACKET_ADD_MEMBERSHIP,(void *)&sock_params, sizeof(sock_params));
if (r < 0) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Couldn't switch iface %s to promiscuous, error %s",
- devname, strerror(errno));
+ SCLogError(
+ "Couldn't switch iface %s to promiscuous, error %s", devname, strerror(errno));
goto socket_err;
}
}
int val = 1;
if (setsockopt(ptv->socket, SOL_PACKET, PACKET_AUXDATA, &val,
sizeof(val)) == -1 && errno != ENOPROTOOPT) {
- SCLogWarning(SC_ERR_NO_AF_PACKET,
- "'kernel' checksum mode not supported, falling back to full mode.");
+ SCLogWarning("'kernel' checksum mode not supported, falling back to full mode.");
ptv->checksum_mode = CHECKSUM_VALIDATION_ENABLE;
}
}
if (setsockopt(ptv->socket, SOL_SOCKET, SO_RCVBUF,
&ptv->buffer_size,
sizeof(ptv->buffer_size)) == -1) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Couldn't set buffer size to %d on iface %s, error %s",
- ptv->buffer_size, devname, strerror(errno));
+ SCLogError("Couldn't set buffer size to %d on iface %s, error %s", ptv->buffer_size,
+ devname, strerror(errno));
goto socket_err;
}
}
if (r < 0) {
if (verbose) {
if (errno == ENETDOWN) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Couldn't bind AF_PACKET socket, iface %s is down",
- devname);
+ SCLogError("Couldn't bind AF_PACKET socket, iface %s is down", devname);
} else {
- SCLogError(SC_ERR_AFP_CREATE,
- "Couldn't bind AF_PACKET socket to iface %s, error %s",
- devname, strerror(errno));
+ SCLogError("Couldn't bind AF_PACKET socket to iface %s, error %s", devname,
+ strerror(errno));
}
}
ret = AFP_RECOVERABLE_ERROR;
uint32_t option = (mode << 16) | (id & 0xffff);
r = setsockopt(ptv->socket, SOL_PACKET, PACKET_FANOUT,(void *)&option, sizeof(option));
if (r < 0) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Couldn't set fanout mode, error %s",
- strerror(errno));
+ SCLogError("Couldn't set fanout mode, error %s", strerror(errno));
goto socket_err;
}
}
if (ptv->cluster_type == PACKET_FANOUT_EBPF) {
r = SockFanoutSeteBPF(ptv);
if (r < 0) {
- SCLogError(SC_ERR_AFP_CREATE,
- "Coudn't set EBPF, error %s",
- strerror(errno));
+ SCLogError("Coudn't set EBPF, error %s", strerror(errno));
goto socket_err;
}
}
0, /* mask */
errbuf,
sizeof(errbuf)) == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Failed to compile BPF \"%s\": %s",
- ptv->bpf_filter,
- errbuf);
+ SCLogError("Failed to compile BPF \"%s\": %s", ptv->bpf_filter, errbuf);
return TM_ECODE_FAILED;
}
SCBPFFree(&filter);
if(rc == -1) {
- SCLogError(SC_ERR_AFP_CREATE, "Failed to attach filter: %s", strerror(errno));
+ SCLogError("Failed to attach filter: %s", strerror(errno));
return TM_ECODE_FAILED;
}
return 1;
/* Not supposed to be there so issue a error */
default:
- SCLogError(SC_ERR_BPF, "Can't update eBPF map: %s (%d)",
- strerror(errno),
- errno);
+ SCLogError("Can't update eBPF map: %s (%d)", strerror(errno), errno);
return 0;
}
}
AFPIfaceConfig *afpconfig = (AFPIfaceConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
ptv->livedev = LiveGetDevice(ptv->iface);
if (ptv->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4");
if (ptv->v4_map_fd == -1) {
if (g_flowv4_ok == false) {
- SCLogError(SC_EINVAL, "Can't find eBPF map fd for '%s'", "flow_table_v4");
+ SCLogError("Can't find eBPF map fd for '%s'", "flow_table_v4");
g_flowv4_ok = true;
}
}
ptv->v6_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v6");
if (ptv->v6_map_fd == -1) {
if (g_flowv6_ok) {
- SCLogError(SC_EINVAL, "Can't find eBPF map fd for '%s'", "flow_table_v6");
+ SCLogError("Can't find eBPF map fd for '%s'", "flow_table_v6");
g_flowv6_ok = false;
}
}
ptv->out_iface[AFP_IFACE_NAME_LENGTH - 1]= '\0';
/* Warn about BPF filter consequence */
if (ptv->bpf_filter) {
- SCLogWarning(SC_WARN_UNCOMMON, "Enabling a BPF filter in IPS mode result"
- " in dropping all non matching packets.");
+ SCLogWarning("Enabling a BPF filter in IPS mode result"
+ " in dropping all non matching packets.");
}
}
*/
TmEcode NoAFXDPSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_NO_AF_XDP,
- "Error creating thread %s: you do not have "
- "support for AF_XDP enabled, on Linux host please recompile "
- "with --enable-af-xdp",
+ SCLogError("Error creating thread %s: you do not have "
+ "support for AF_XDP enabled, on Linux host please recompile "
+ "with --enable-af-xdp",
tv->name);
exit(EXIT_FAILURE);
}
ptv->umem.buf = mmap(NULL, MEM_BYTES, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
if (ptv->umem.buf == MAP_FAILED) {
- SCLogError(SC_ERR_MEM_ALLOC, "mmap: failed to acquire memory");
+ SCLogError("mmap: failed to acquire memory");
SCReturnInt(TM_ECODE_FAILED);
}
{
if (xsk_umem__create(&ptv->umem.umem, ptv->umem.buf, MEM_BYTES, &ptv->umem.fq, &ptv->umem.cq,
&ptv->umem.cfg)) {
- SCLogError(SC_ERR_AFXDP_CREATE, "failed to create umem: %s", strerror(errno));
+ SCLogError("failed to create umem: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
uint32_t ret = xsk_ring_prod__reserve(&ptv->umem.fq, cnt, &idx_fq);
if (ret != cnt) {
- SCLogError(SC_ERR_AFXDP_INIT, "Failed to initialise the fill ring.");
+ SCLogError("Failed to initialise the fill ring.");
SCReturnInt(TM_ECODE_FAILED);
}
* see linux commit: 7fd3253a7de6a317a0683f83739479fb880bffc8
*/
if (!SCKernelVersionIsAtLeast(5, 11)) {
- SCLogWarning(SC_WARN_AFXDP_CONF,
- "Kernel version older than required: v5.11,"
- " upgrade kernel version to use 'enable-busy-poll' option.");
+ SCLogWarning("Kernel version older than required: v5.11,"
+ " upgrade kernel version to use 'enable-busy-poll' option.");
SCReturnInt(TM_ECODE_FAILED);
}
SCMutexLock(&xsk_protect.queue_protect);
if (AFXDPAssignQueueID(ptv) != TM_ECODE_OK) {
- SCLogError(SC_ERR_SOCKET, "Failed to assign queue ID");
+ SCLogError("Failed to assign queue ID");
SCReturnInt(TM_ECODE_FAILED);
}
if ((ret = xsk_socket__create(&ptv->xsk.xsk, ptv->livedev->dev, ptv->xsk.queue.queue_num,
ptv->umem.umem, &ptv->xsk.rx, &ptv->xsk.tx, &ptv->xsk.cfg))) {
- SCLogError(SC_ERR_SOCKET, "Failed to create socket: %s", strerror(-ret));
+ SCLogError("Failed to create socket: %s", strerror(-ret));
SCReturnInt(TM_ECODE_FAILED);
}
SCLogDebug("bind to %s on queue %u", ptv->iface, ptv->xsk.queue.queue_num);
}
if (ConfigureBusyPolling(ptv) != TM_ECODE_OK) {
- SCLogWarning(SC_WARN_AFXDP_CONF, "Failed to configure busy polling"
- " performance may be reduced.");
+ SCLogWarning("Failed to configure busy polling"
+ " performance may be reduced.");
}
/* Has the eBPF program successfully bound? */
if (bpf_get_link_xdp_id(ptv->ifindex, &ptv->prog_id, ptv->xsk.cfg.xdp_flags)) {
- SCLogError(SC_ERR_BPF, "Failed to attach eBPF program to interface: %s", ptv->livedev->dev);
+ SCLogError("Failed to attach eBPF program to interface: %s", ptv->livedev->dev);
SCReturnInt(TM_ECODE_FAILED);
}
AFXDPIfaceConfig *afxdpconfig = (AFXDPIfaceConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
ptv->livedev = LiveGetDevice(ptv->iface);
if (ptv->livedev == NULL) {
- SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
if (ptv->promisc != 0) {
/* Force promiscuous mode */
if (SetIfaceFlags(ptv->iface, IFF_PROMISC | IFF_UP) != 0) {
- SCLogError(SC_ERR_AFXDP_CREATE,
- "Failed to switch interface (%s) to promiscuous, error %s", ptv->iface,
+ SCLogError("Failed to switch interface (%s) to promiscuous, error %s", ptv->iface,
strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
StatsIncr(ptv->tv, ptv->capture_afxdp_poll_timeout);
} else if (r < 0) {
StatsIncr(ptv->tv, ptv->capture_afxdp_poll_failed);
- SCLogWarning(SC_ERR_AFXDP_READ, "poll failed with retval %d", r);
+ SCLogWarning("poll failed with retval %d", r);
AFXDPSwitchState(ptv, AFXDP_STATE_DOWN);
}
StatsIncr(ptv->tv, ptv->capture_afxdp_empty_reads);
ssize_t ret = WakeupSocket(ptv);
if (ret < 0) {
- SCLogWarning(SC_ERR_AFXDP_READ, "recv failed with retval %ld", ret);
+ SCLogWarning("recv failed with retval %ld", ret);
AFXDPSwitchState(ptv, AFXDP_STATE_DOWN);
}
DumpStatsEverySecond(ptv, &last_dump);
StatsIncr(ptv->tv, ptv->capture_afxdp_failed_reads);
ssize_t ret = WakeupSocket(ptv);
if (ret < 0) {
- SCLogWarning(SC_ERR_AFXDP_READ, "recv failed with retval %ld", ret);
+ SCLogWarning("recv failed with retval %ld", ret);
AFXDPSwitchState(ptv, AFXDP_STATE_DOWN);
continue;
}
*/
TmEcode NoDPDKSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- FatalError(SC_ERR_NO_DPDK,
- "Error creating thread %s: you do not have "
- "support for DPDK enabled, on Linux host please recompile "
- "with --enable-dpdk",
+ FatalError("Error creating thread %s: you do not have "
+ "support for DPDK enabled, on Linux host please recompile "
+ "with --enable-dpdk",
tv->name);
}
struct rte_flow_error flush_error = { 0 };
retval = rte_flow_flush(ptv->port_id, &flush_error);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Unable to flush rte_flow rules: %s Flush error msg: %s",
+ SCLogError("Unable to flush rte_flow rules: %s Flush error msg: %s",
rte_strerror(-retval), flush_error.message);
}
}
cpu = sched_getcpu();
node = numa_node_of_cpu(cpu);
#else
- SCLogWarning(SC_ERR_TM_THREADS_ERROR, "NUMA node retrieval is not supported on this OS.");
+ SCLogWarning("NUMA node retrieval is not supported on this OS.");
#endif
return node;
struct rte_eth_stats eth_stats;
int retval = rte_eth_stats_get(ptv->port_id, ð_stats);
if (unlikely(retval != 0)) {
- SCLogError(SC_ERR_STAT, "Failed to get stats for port id %d: %s", ptv->port_id,
- rte_strerror(-retval));
+ SCLogError("Failed to get stats for port id %d: %s", ptv->port_id, rte_strerror(-retval));
return;
}
DPDKIfaceConfig *dpdk_config = (DPDKIfaceConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "DPDK configuration is NULL in thread initialization");
+ SCLogError("DPDK configuration is NULL in thread initialization");
goto fail;
}
ptv = SCCalloc(1, sizeof(DPDKThreadVars));
if (unlikely(ptv == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to allocate memory");
+ SCLogError("Unable to allocate memory");
goto fail;
}
if (queue_id == dpdk_config->threads - 1) {
retval = rte_eth_dev_start(ptv->port_id);
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (%s) during device startup of %s",
- rte_strerror(-retval), dpdk_config->iface);
+ SCLogError("Error (%s) during device startup of %s", rte_strerror(-retval),
+ dpdk_config->iface);
goto fail;
}
struct rte_eth_dev_info dev_info;
retval = rte_eth_dev_info_get(ptv->port_id, &dev_info);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (%s) when getting device info of %s",
- rte_strerror(-retval), dpdk_config->iface);
+ SCLogError("Error (%s) when getting device info of %s", rte_strerror(-retval),
+ dpdk_config->iface);
goto fail;
}
uint16_t inconsist_numa_cnt = SC_ATOMIC_GET(dpdk_config->inconsitent_numa_cnt);
if (inconsist_numa_cnt > 0) {
- SCLogWarning(SC_WARN_DPDK_CONF,
- "%s: NIC is on NUMA %d, %u threads on different NUMA node(s)",
+ SCLogWarning("%s: NIC is on NUMA %d, %u threads on different NUMA node(s)",
dpdk_config->iface, rte_eth_dev_socket_id(ptv->port_id), inconsist_numa_cnt);
}
}
retval = rte_eth_dev_get_name_by_port(ptv->port_id, port_name);
if (unlikely(retval != 0)) {
- SCLogError(SC_ERR_STAT, "Failed to convert port id %d to the interface name: %s",
- ptv->port_id, strerror(-retval));
+ SCLogError("Failed to convert port id %d to the interface name: %s", ptv->port_id,
+ strerror(-retval));
SCReturn;
}
retval = rte_eth_stats_get(ptv->port_id, ð_stats);
if (unlikely(retval != 0)) {
- SCLogError(SC_ERR_STAT, "Failed to get stats for interface %s: %s", port_name,
- strerror(-retval));
+ SCLogError("Failed to get stats for interface %s: %s", port_name, strerror(-retval));
SCReturn;
}
SCLogPerf("Total RX stats of %s: packets %" PRIu64 " bytes: %" PRIu64 " missed: %" PRIu64
char iface[RTE_ETH_NAME_MAX_LEN];
retval = rte_eth_dev_get_name_by_port(ptv->port_id, iface);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) when getting device name (port %d)",
- retval, ptv->port_id);
+ SCLogError("Error (err=%d) when getting device name (port %d)", retval, ptv->port_id);
SCReturnInt(TM_ECODE_FAILED);
}
retval = rte_eth_dev_info_get(ptv->port_id, &dev_info);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_INIT, "Error (err=%d) during getting device info (port %s)",
- retval, iface);
+ SCLogError("Error (err=%d) during getting device info (port %s)", retval, iface);
SCReturnInt(TM_ECODE_FAILED);
}
TmEcode
NoErfDagSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_DAG_NOSUPPORT,
- "Error creating thread %s: you do not have support for DAG cards "
- "enabled please recompile with --enable-dag", tv->name);
+ SCLogError("Error creating thread %s: you do not have support for DAG cards "
+ "enabled please recompile with --enable-dag",
+ tv->name);
exit(EXIT_FAILURE);
}
int stream_count = 0;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Error: No DAG interface provided.");
+ SCLogError("Error: No DAG interface provided.");
SCReturnInt(TM_ECODE_FAILED);
}
ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
if (unlikely(ewtn == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for ERF DAG thread vars.");
+ FatalError("Failed to allocate memory for ERF DAG thread vars.");
}
memset(ewtn, 0, sizeof(*ewtn));
*/
if (dag_parse_name(initdata, ewtn->dagname, DAGNAME_BUFSIZE,
&ewtn->dagstream) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to parse DAG interface: %s",
- (char*)initdata);
+ SCLogError("Failed to parse DAG interface: %s", (char *)initdata);
SCFree(ewtn);
exit(EXIT_FAILURE);
}
ewtn->livedev = LiveGetDevice(initdata);
if (ewtn->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to get %s live device", (char *)initdata);
+ SCLogError("Unable to get %s live device", (char *)initdata);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
ewtn->dagname, ewtn->dagstream);
if ((ewtn->dagfd = dag_open(ewtn->dagname)) < 0) {
- SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED, "Failed to open DAG: %s",
- ewtn->dagname);
+ SCLogError("Failed to open DAG: %s", ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
* support reading from the one specified.
*/
if ((stream_count = dag_rx_get_stream_count(ewtn->dagfd)) < 0) {
- SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED,
- "Failed to open stream: %d, DAG: %s, could not query stream count",
- ewtn->dagstream, ewtn->dagname);
+ SCLogError("Failed to open stream: %d, DAG: %s, could not query stream count",
+ ewtn->dagstream, ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
* the user is asking for.
*/
if (ewtn->dagstream > stream_count * 2) {
- SCLogError(SC_ERR_ERF_DAG_OPEN_FAILED,
- "Failed to open stream: %d, DAG: %s, insufficient streams: %d",
- ewtn->dagstream, ewtn->dagname, stream_count);
+ SCLogError("Failed to open stream: %d, DAG: %s, insufficient streams: %d", ewtn->dagstream,
+ ewtn->dagname, stream_count);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
if (0 != (ewtn->dagstream & 0x01)) {
/* Setting reverse mode for using with soft dag from daemon side */
if (dag_set_mode(ewtn->dagfd, ewtn->dagstream, DAG_REVERSE_MODE)) {
- SCLogError(SC_ERR_ERF_DAG_STREAM_OPEN_FAILED,
- "Failed to set mode to DAG_REVERSE_MODE on stream: %d, DAG: %s",
- ewtn->dagstream, ewtn->dagname);
+ SCLogError("Failed to set mode to DAG_REVERSE_MODE on stream: %d, DAG: %s",
+ ewtn->dagstream, ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
}
if (dag_attach_stream(ewtn->dagfd, ewtn->dagstream, 0, 0) < 0) {
- SCLogError(SC_ERR_ERF_DAG_STREAM_OPEN_FAILED,
- "Failed to open DAG stream: %d, DAG: %s",
- ewtn->dagstream, ewtn->dagname);
+ SCLogError("Failed to open DAG stream: %d, DAG: %s", ewtn->dagstream, ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
if (dag_start_stream(ewtn->dagfd, ewtn->dagstream) < 0) {
- SCLogError(SC_ERR_ERF_DAG_STREAM_START_FAILED,
- "Failed to start DAG stream: %d, DAG: %s",
- ewtn->dagstream, ewtn->dagname);
+ SCLogError("Failed to start DAG stream: %d, DAG: %s", ewtn->dagstream, ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
*/
if (dag_set_stream_poll(ewtn->dagfd, ewtn->dagstream, MINDATA,
&(ewtn->maxwait), &(ewtn->poll)) < 0) {
- SCLogError(SC_ERR_ERF_DAG_STREAM_SET_FAILED,
- "Failed to set poll parameters for stream: %d, DAG: %s",
- ewtn->dagstream, ewtn->dagname);
+ SCLogError("Failed to set poll parameters for stream: %d, DAG: %s", ewtn->dagstream,
+ ewtn->dagname);
SCFree(ewtn);
SCReturnInt(TM_ECODE_FAILED);
}
}
continue;
} else {
- SCLogError(SC_ERR_ERF_DAG_STREAM_READ_FAILED,
- "Failed to read from stream: %d, DAG: %s when "
- "using dag_advance_stream",
- dtv->dagstream, dtv->dagname);
+ SCLogError("Failed to read from stream: %d, DAG: %s when "
+ "using dag_advance_stream",
+ dtv->dagstream, dtv->dagname);
SCReturnInt(TM_ECODE_FAILED);
}
}
err = ProcessErfDagRecords(dtv, top, &pkts_read);
if (err == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_ERF_DAG_STREAM_READ_FAILED,
- "Failed to read from stream: %d, DAG: %s",
- dtv->dagstream, dtv->dagname);
+ SCLogError("Failed to read from stream: %d, DAG: %s", dtv->dagstream, dtv->dagname);
ReceiveErfDagCloseStream(dtv->dagfd, dtv->dagstream);
SCReturnInt(TM_ECODE_FAILED);
}
}
break;
default:
- SCLogError(SC_ERR_UNIMPLEMENTED,
- "Processing of DAG record type: %d not implemented.", dr->type);
+ SCLogError("Processing of DAG record type: %d not implemented.", dr->type);
SCReturnInt(TM_ECODE_FAILED);
}
/* count extension headers */
while (hdr_type & 0x80) {
if (rlen < (dag_record_size + (hdr_num * 8))) {
- SCLogError(SC_ERR_UNIMPLEMENTED,
- "Insufficient captured packet length.");
+ SCLogError("Insufficient captured packet length.");
SCReturnInt(TM_ECODE_FAILED);
}
hdr_type = prec[(dag_record_size + (hdr_num * 8))];
p = PacketGetFromQueueOrAlloc();
if (p == NULL) {
- SCLogError(SC_ENOMEM, "Failed to allocate a Packet on stream: %d, DAG: %s", ewtn->dagstream,
+ SCLogError("Failed to allocate a Packet on stream: %d, DAG: %s", ewtn->dagstream,
ewtn->dagname);
SCReturnInt(TM_ECODE_FAILED);
}
DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
break;
default:
- SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED,
- "Error: datalink type %" PRId32
- " not yet supported in module DecodeErfDag",
- p->datalink);
+ SCLogError("Error: datalink type %" PRId32 " not yet supported in module DecodeErfDag",
+ p->datalink);
break;
}
p = PacketGetFromQueueOrAlloc();
if (unlikely(p == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate a packet.");
+ SCLogError("Failed to allocate a packet.");
EngineStop();
SCReturnInt(TM_ECODE_FAILED);
}
uint16_t rlen = SCNtohs(dr.rlen);
uint16_t wlen = SCNtohs(dr.wlen);
if (rlen < sizeof(DagRecord)) {
- SCLogError(SC_ERR_ERF_BAD_RLEN, "Bad ERF record, "
- "record length less than size of header");
+ SCLogError("Bad ERF record, "
+ "record length less than size of header");
SCReturnInt(TM_ECODE_FAILED);
}
r = fread(GET_PKT_DATA(p), rlen - sizeof(DagRecord), 1, etv->erf);
/* Only support ethernet at this time. */
if (dr.type != DAG_TYPE_ETH) {
- SCLogError(SC_ERR_UNIMPLEMENTED,
- "DAG record type %d not implemented.", dr.type);
+ SCLogError("DAG record type %d not implemented.", dr.type);
SCReturnInt(TM_ECODE_FAILED);
}
SCEnter();
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Error: No filename provided.");
+ SCLogError("Error: No filename provided.");
SCReturnInt(TM_ECODE_FAILED);
}
FILE *erf = fopen((const char *)initdata, "r");
if (erf == NULL) {
- SCLogError(SC_ERR_FOPEN, "Failed to open %s: %s", (char *)initdata,
- strerror(errno));
+ SCLogError("Failed to open %s: %s", (char *)initdata, strerror(errno));
exit(EXIT_FAILURE);
}
ErfFileThreadVars *etv = SCMalloc(sizeof(ErfFileThreadVars));
if (unlikely(etv == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate memory for ERF file thread vars.");
+ SCLogError("Failed to allocate memory for ERF file thread vars.");
fclose(erf);
SCReturnInt(TM_ECODE_FAILED);
}
TmEcode NoIPFWSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_IPFW_NOSUPPORT,"Error creating thread %s: you do not have support for ipfw "
- "enabled please recompile with --enable-ipfw", tv->name);
+ SCLogError("Error creating thread %s: you do not have support for ipfw "
+ "enabled please recompile with --enable-ipfw",
+ tv->name);
exit(EXIT_FAILURE);
}
nq = IPFWGetQueue(ptv->ipfw_index);
if (nq == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Can't get thread variable");
+ SCLogWarning("Can't get thread variable");
SCReturnInt(TM_ECODE_FAILED);
}
/* Nothing for us to process */
continue;
} else {
- SCLogWarning(SC_WARN_IPFW_RECV,
- "Read from IPFW divert socket failed: %s",
- strerror(errno));
+ SCLogWarning("Read from IPFW divert socket failed: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
}
#else
if ((nq->fd = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)) == -1) {
#endif
- SCLogError(SC_ERR_IPFW_SOCK,"Can't create divert socket: %s", strerror(errno));
+ SCLogError("Can't create divert socket: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
timev.tv_usec = 0;
if (setsockopt(nq->fd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev)) == -1) {
- SCLogError(SC_ERR_IPFW_SETSOCKOPT,"Can't set IPFW divert socket timeout: %s", strerror(errno));
+ SCLogError("Can't set IPFW divert socket timeout: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
/* Bind that SOB */
if (bind(nq->fd, (struct sockaddr *)&nq->ipfw_sin, nq->ipfw_sinlen) == -1) {
- SCLogError(SC_ERR_IPFW_BIND,"Can't bind divert socket on port %d: %s",nq->port_num,strerror(errno));
+ SCLogError("Can't bind divert socket on port %d: %s", nq->port_num, strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
/* Attempt to shut the socket down...close instead? */
if (shutdown(nq->fd, SHUT_RD) < 0) {
- SCLogWarning(SC_WARN_IPFW_UNBIND,"Unable to disable ipfw socket: %s",strerror(errno));
+ SCLogWarning("Unable to disable ipfw socket: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
SCEnter();
if (p == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Packet is NULL");
+ SCLogWarning("Packet is NULL");
SCReturnInt(TM_ECODE_FAILED);
}
nq = IPFWGetQueue(p->ipfw_v.ipfw_index);
if (nq == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "No thread found");
+ SCLogWarning("No thread found");
SCReturnInt(TM_ECODE_FAILED);
}
int r = errno;
switch (r) {
default:
- SCLogWarning(SC_WARN_IPFW_XMIT,"Write to ipfw divert socket failed: %s",strerror(r));
+ SCLogWarning("Write to ipfw divert socket failed: %s", strerror(r));
IPFWMutexUnlock(nq);
SCReturnInt(TM_ECODE_FAILED);
case EHOSTDOWN:
uint16_t port_num = 0;
if ((StringParseUint16(&port_num, 10, strlen(queue), queue)) < 0)
{
- SCLogError(SC_ERR_INVALID_ARGUMENT, "specified queue number %s is not "
- "valid", queue);
+ SCLogError("specified queue number %s is not "
+ "valid",
+ queue);
return -1;
}
SCMutexLock(&ipfw_init_lock);
if (receive_port_num >= IPFW_MAX_QUEUE) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "too much IPFW divert port registered (%d)",
- receive_port_num);
+ SCLogError("too much IPFW divert port registered (%d)", receive_port_num);
SCMutexUnlock(&ipfw_init_lock);
return -1;
}
TmEcode NoNapatechSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_NAPATECH_NOSUPPORT,
- "Error creating thread %s: you do not have support for Napatech adapter "
- "enabled please recompile with --enable-napatech",
+ SCLogError("Error creating thread %s: you do not have support for Napatech adapter "
+ "enabled please recompile with --enable-napatech",
tv->name);
exit(EXIT_FAILURE);
}
inline_port_map[port] = peer;
inline_port_map[peer] = port;
} else {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Port pairing is already configured.");
+ SCLogError("Port pairing is already configured.");
return 0;
}
return 1;
if (unlikely(port_adapter_map[port] == -1)) {
if ((status = NT_InfoOpen(&h_info_stream, "ExampleInfo")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
/* Read the system info */
h_info.u.port_v9.portNo = (uint8_t) port;
if ((status = NT_InfoRead(h_info_stream, &h_info)) != NT_SUCCESS) {
/* Get the status code as text */
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
NT_InfoClose(h_info_stream);
return -1;
}
snprintf(flow_name, sizeof(flow_name), "Flow_stream_%d", stream_id );
SCLogDebug("Opening flow programming stream: %s", flow_name);
if ((status = NT_FlowOpen_Attr(&hFlowStream, flow_name, &attr)) != NT_SUCCESS) {
- SCLogWarning(SC_WARN_COMPATIBILITY,
- "Napatech bypass functionality not supported by the FPGA version on adapter %d - disabling support.",
+ SCLogWarning("Napatech bypass functionality not supported by the FPGA version on adapter "
+ "%d - disabling support.",
adapter);
return NULL;
}
if (NT_FlowWrite(ntpv->flow_stream, &flow_match, -1) != NT_SUCCESS) {
if (!(suricata_ctl_flags & SURICATA_STOP)) {
- SCLogError(SC_ERR_NAPATECH_OPEN_FAILED,"NT_FlowWrite failed!.");
+ SCLogError("NT_FlowWrite failed!.");
exit(EXIT_FAILURE);
}
}
NapatechThreadVars *ntv = SCCalloc(1, sizeof (NapatechThreadVars));
if (unlikely(ntv == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH thread vars.");
+ FatalError("Failed to allocate memory for NAPATECH thread vars.");
}
memset(ntv, 0, sizeof (NapatechThreadVars));
cpu = sched_getcpu();
node = numa_node_of_cpu(cpu);
#else
- SCLogWarning(SC_ERR_NAPATECH_NOSUPPORT,
- "Auto configuration of NUMA node is not supported on this OS.");
+ SCLogWarning("Auto configuration of NUMA node is not supported on this OS.");
#endif
return node;
"E.g.: HostBuffersRx=%s%s%s%s", string0, string1, string2,
string3);
} else if (log_level == SC_LOG_ERROR) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Or, try running /opt/napatech3/bin/ntpl -e \"delete=all\" to clean-up stream NUMA config.");
+ SCLogError("Or, try running /opt/napatech3/bin/ntpl -e \"delete=all\" to clean-up stream "
+ "NUMA config.");
}
}
closer = 1;
if (status == 0x20002061) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Check host buffer configuration in ntservice.ini.");
+ SCLogError("Check host buffer configuration in ntservice.ini.");
RecommendNUMAConfig(SC_LOG_ERROR);
exit(EXIT_FAILURE);
} else if (status == 0x20000008) {
- FatalError(SC_ERR_FATAL,
- "Check napatech.ports in the suricata config file.");
+ FatalError("Check napatech.ports in the suricata config file.");
}
RecommendNUMAConfig(SC_LOG_PERF);
SCLogNotice("Napatech packet input engine started.");
if (ntv->hba > 0) {
char *s_hbad_pkt = SCCalloc(1, 32);
if (unlikely(s_hbad_pkt == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(s_hbad_pkt, 32, "nt%d.hba_drop", ntv->stream_id);
hba_pkt = StatsRegisterCounter(s_hbad_pkt, tv);
if ((status = NT_NetRxOpen(&(ntv->rx_stream), "SuricataStream",
NT_NET_INTERFACE_PACKET, ntv->stream_id, ntv->hba)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
SCFree(ntv);
SCReturnInt(TM_ECODE_FAILED);
}
}
continue;
} else if (unlikely(status != NT_SUCCESS)) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
SCLogInfo("Failed to read from Napatech Stream %d: %s",
ntv->stream_id, error_buffer);
break;
p->ts.tv_usec = ((pkt_ts % 100000000) / 100) + ((pkt_ts % 100) > 50 ? 1 : 0);
break;
default:
- SCLogError(SC_ERR_NAPATECH_TIMESTAMP_TYPE_NOT_SUPPORTED,
- "Packet from Napatech Stream: %u does not have a supported timestamp format",
+ SCLogError("Packet from Napatech Stream: %u does not have a supported timestamp "
+ "format",
ntv->stream_id);
NT_NetRxRelease(ntv->rx_stream, packet_buffer);
SCReturnInt(TM_ECODE_FAILED);
stat_cmd.cmd = NT_NETRX_READ_CMD_STREAM_DROP;
/* Update drop counter */
if (unlikely((status = NT_NetRxRead(ntv->rx_stream, &stat_cmd)) != NT_SUCCESS)) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
SCLogInfo("Couldn't retrieve drop statistics from the RX stream: %u",
ntv->stream_id);
} else {
DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
break;
default:
- SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED,
- "Datalink type %" PRId32 " not yet supported in module NapatechDecode",
+ SCLogError("Datalink type %" PRId32 " not yet supported in module NapatechDecode",
p->datalink);
break;
}
*/
static TmEcode NoNetmapSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- FatalError(SC_ERR_NO_NETMAP,
- "Error creating thread %s: Netmap is not enabled. "
- "Make sure to pass --enable-netmap to configure when building.",
+ FatalError("Error creating thread %s: Netmap is not enabled. "
+ "Make sure to pass --enable-netmap to configure when building.",
tv->name);
}
/* open netmap device */
int fd = open("/dev/netmap", O_RDWR);
if (fd == -1) {
- SCLogError(SC_ERR_NETMAP_CREATE,
- "Couldn't open netmap device, error %s",
- strerror(errno));
+ SCLogError("Couldn't open netmap device, error %s", strerror(errno));
goto error_open;
}
strlcpy(hdr.nr_name, base_name, sizeof(hdr.nr_name));
if (ioctl(fd, NIOCCTRL, &hdr) != 0) {
- SCLogError(SC_ERR_NETMAP_CREATE, "Couldn't query netmap for info about %s, error %s",
- ifname, strerror(errno));
+ SCLogError("Couldn't query netmap for info about %s, error %s", ifname, strerror(errno));
goto error_fd;
};
int if_flags = GetIfaceFlags(base_name);
if (if_flags == -1) {
if (verbose) {
- SCLogError(SC_ERR_NETMAP_CREATE, "Cannot access network interface '%s' (%s)",
- base_name, ns->iface);
+ SCLogError("Cannot access network interface '%s' (%s)", base_name, ns->iface);
}
goto error;
}
/* bring iface up if it is down */
if ((if_flags & IFF_UP) == 0) {
- SCLogError(SC_ERR_NETMAP_CREATE, "interface '%s' (%s) is down", base_name, ns->iface);
+ SCLogError("interface '%s' (%s) is down", base_name, ns->iface);
goto error;
}
/* if needed, try to set iface in promisc mode */
NetmapDevice *pdev = NULL, *spdev = NULL;
pdev = SCCalloc(1, sizeof(*pdev));
if (unlikely(pdev == NULL)) {
- SCLogError(SC_ENOMEM, "Memory allocation failed");
+ SCLogError("Memory allocation failed");
goto error;
}
SC_ATOMIC_INIT(pdev->threads_run);
}
NetmapCloseAll();
- FatalError(SC_ERR_FATAL, "opening devname %s failed: %s", devname, strerror(errno));
+ FatalError("opening devname %s failed: %s", devname, strerror(errno));
}
/* Work around bug in libnetmap library where "cur_{r,t}x_ring" values not initialized */
NetmapIfaceConfig *aconf = (NetmapIfaceConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
NetmapThreadVars *ntv = SCCalloc(1, sizeof(*ntv));
if (unlikely(ntv == NULL)) {
- SCLogError(SC_ENOMEM, "Memory allocation failed");
+ SCLogError("Memory allocation failed");
goto error;
}
ntv->livedev = LiveGetDevice(aconf->iface_name);
if (ntv->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
goto error_ntv;
}
errbuf,
sizeof(errbuf)) == -1)
{
- SCLogError(SC_ERR_NETMAP_CREATE, "Failed to compile BPF \"%s\": %s",
- aconf->in.bpf_filter,
- errbuf);
+ SCLogError("Failed to compile BPF \"%s\": %s", aconf->in.bpf_filter, errbuf);
goto error_dst;
}
}
if (r < 0) {
/* error */
if (errno != EINTR)
- SCLogError(SC_ERR_NETMAP_READ,
- "Error polling netmap from iface '%s': (%d" PRIu32 ") %s",
+ SCLogError("Error polling netmap from iface '%s': (%d" PRIu32 ") %s",
ntv->ifsrc->ifname, errno, strerror(errno));
continue;
if (unlikely(fds.revents & POLL_EVENTS)) {
if (fds.revents & POLLERR) {
- SCLogError(SC_ERR_NETMAP_READ,
- "Error reading netmap data via polling from iface '%s': (%d" PRIu32 ") %s",
+ SCLogError("Error reading netmap data via polling from iface '%s': (%d" PRIu32
+ ") %s",
ntv->ifsrc->ifname, errno, strerror(errno));
} else if (fds.revents & POLLNVAL) {
- SCLogError(SC_ERR_NETMAP_READ, "Invalid polling request");
+ SCLogError("Invalid polling request");
}
continue;
}
TmEcode NoNFLOGSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_NFLOG_NOSUPPORT,"Error creating thread %s: you do not have support for nflog "
- "enabled please recompile with --enable-nflog", tv->name);
+ SCLogError("Error creating thread %s: you do not have support for nflog "
+ "enabled please recompile with --enable-nflog",
+ tv->name);
exit(EXIT_FAILURE);
}
if (ret > 0) {
if (ret > 65536) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "NFLOG sent too big packet");
+ SCLogWarning("NFLOG sent too big packet");
SET_PKT_LEN(p, 0);
} else if (runmode_workers)
PacketSetData(p, (uint8_t *)payload, ret);
NflogGroupConfig *nflconfig = (NflogGroupConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
ntv->h = nflog_open();
if (ntv->h == NULL) {
- SCLogError(SC_ERR_NFLOG_OPEN, "nflog_open() failed");
+ SCLogError("nflog_open() failed");
SCFree(ntv);
return TM_ECODE_FAILED;
}
SCLogDebug("binding netfilter_log as nflog handler for AF_INET and AF_INET6");
if (nflog_bind_pf(ntv->h, AF_INET) < 0) {
- FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET failed");
+ FatalError("nflog_bind_pf() for AF_INET failed");
}
if (nflog_bind_pf(ntv->h, AF_INET6) < 0) {
- FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET6 failed");
+ FatalError("nflog_bind_pf() for AF_INET6 failed");
}
ntv->gh = nflog_bind_group(ntv->h, ntv->group);
if (!ntv->gh) {
- SCLogError(SC_ERR_NFLOG_OPEN, "nflog_bind_group() failed");
+ SCLogError("nflog_bind_group() failed");
SCFree(ntv);
return TM_ECODE_FAILED;
}
if (nflog_set_mode(ntv->gh, NFULNL_COPY_PACKET, 0xFFFF) < 0) {
- SCLogError(SC_ERR_NFLOG_SET_MODE, "can't set packet_copy mode");
+ SCLogError("can't set packet_copy mode");
SCFree(ntv);
return TM_ECODE_FAILED;
}
if (ntv->nlbufsiz < ntv->nlbufsiz_max)
ntv->nlbufsiz = nfnl_rcvbufsiz(nflog_nfnlh(ntv->h), ntv->nlbufsiz);
else {
- SCLogError(SC_ERR_NFLOG_MAX_BUFSIZ, "Maximum buffer size (%d) in NFLOG "
- "has been reached", ntv->nlbufsiz);
+ SCLogError("Maximum buffer size (%d) in NFLOG "
+ "has been reached",
+ ntv->nlbufsiz);
return TM_ECODE_FAILED;
}
ntv->livedev = LiveGetDevice(nflconfig->numgroup);
if (ntv->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
SCFree(ntv);
SCReturnInt(TM_ECODE_FAILED);
}
int fd = nflog_fd(ntv->h);
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev)) == -1) {
- SCLogWarning(SC_WARN_NFLOG_SETSOCKOPT, "can't set socket "
- "timeout: %s", strerror(errno));
+ SCLogWarning("can't set socket "
+ "timeout: %s",
+ strerror(errno));
}
#ifdef PACKET_STATISTICS
SCLogDebug("closing nflog group %d", ntv->group);
if (nflog_unbind_pf(ntv->h, AF_INET) < 0) {
- FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET failed");
+ FatalError("nflog_unbind_pf() for AF_INET failed");
}
if (nflog_unbind_pf(ntv->h, AF_INET6) < 0) {
- FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET6 failed");
+ FatalError("nflog_unbind_pf() for AF_INET6 failed");
}
if (ntv->gh) {
return 1;
}
- SCLogWarning(SC_WARN_NFLOG_MAXBUFSIZ_REACHED,
- "Maximum buffer size (%d) in NFLOG has been "
+ SCLogWarning("Maximum buffer size (%d) in NFLOG has been "
"reached. Please, consider raising "
"`buffer-size` and `max-size` in nflog configuration",
- ntv->nlbufsiz);
+ ntv->nlbufsiz);
return 0;
}
fd = nflog_fd(ntv->h);
if (fd < 0) {
- SCLogError(SC_ERR_NFLOG_FD, "Can't obtain a file descriptor");
+ SCLogError("Can't obtain a file descriptor");
SCReturnInt(TM_ECODE_FAILED);
}
if (!ntv->nful_overrun_warned) {
int s = ntv->nlbufsiz * 2;
if (NFLOGSetnlbufsiz((void *)ntv, s)) {
- SCLogWarning(SC_WARN_NFLOG_LOSING_EVENTS,
- "We are losing events, "
- "increasing buffer size "
- "to %d", ntv->nlbufsiz);
+ SCLogWarning("We are losing events, "
+ "increasing buffer size "
+ "to %d",
+ ntv->nlbufsiz);
} else {
ntv->nful_overrun_warned = 1;
}
}
continue;
} else {
- SCLogWarning(SC_WARN_NFLOG_RECV,
- "Read from NFLOG fd failed: %s",
- strerror(errno));
+ SCLogWarning("Read from NFLOG fd failed: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
}
ret = nflog_handle_packet(ntv->h, ntv->data, rv);
if (ret != 0)
- SCLogWarning(SC_ERR_NFLOG_HANDLE_PKT,
- "nflog_handle_packet error %" PRId32 "", ret);
+ SCLogWarning("nflog_handle_packet error %" PRId32 "", ret);
StatsSyncCountersIfSignalled(tv);
}
static TmEcode NoNFQSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- FatalError(SC_ERR_NFQ_NOSUPPORT,"Error creating thread %s: you do not "
- "have support for nfqueue enabled please recompile with "
- "--enable-nfqueue", tv->name);
+ FatalError("Error creating thread %s: you do not "
+ "have support for nfqueue enabled please recompile with "
+ "--enable-nfqueue",
+ tv->name);
}
#else /* we do have NFQ support */
} else if (!strcmp("route", nfq_mode)) {
nfq_config.mode = NFQ_ROUTE_MODE;
} else {
- FatalError(SC_ERR_FATAL, "Unknown nfq.mode");
+ FatalError("Unknown nfq.mode");
}
}
SCLogInfo("Enabling fail-open on queue");
nfq_config.flags |= NFQ_FLAG_FAIL_OPEN;
#else
- SCLogError(SC_ERR_NFQ_NOSUPPORT,
- "nfq.%s set but NFQ library has no support for it.", "fail-open");
+ SCLogError("nfq.%s set but NFQ library has no support for it.", "fail-open");
#endif
}
if ((ConfGetInt("nfq.batchcount", &value)) == 1) {
#ifdef HAVE_NFQ_SET_VERDICT_BATCH
if (value > 255) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "nfq.batchcount cannot exceed 255.");
+ SCLogWarning("nfq.batchcount cannot exceed 255.");
value = 255;
}
if (value > 1)
nfq_config.batchcount = (uint8_t) (value - 1);
#else
- SCLogWarning(SC_ERR_NFQ_NOSUPPORT,
- "nfq.%s set but NFQ library has no support for it.", "batchcount");
+ SCLogWarning("nfq.%s set but NFQ library has no support for it.", "batchcount");
#endif
}
} while ((ret < 0) && (iter++ < NFQ_VERDICT_RETRY_TIME));
if (ret < 0) {
- SCLogWarning(SC_ERR_NFQ_SET_VERDICT, "nfq_set_verdict_batch failed: %s",
- strerror(errno));
+ SCLogWarning("nfq_set_verdict_batch failed: %s", strerror(errno));
} else {
t->verdict_cache.len = 0;
t->verdict_cache.mark_valid = 0;
ret = nfq_set_verdict(qh, p->nfq_v.id, NF_ACCEPT, 0, NULL);
} while ((ret < 0) && (iter++ < NFQ_VERDICT_RETRY_TIME));
if (ret < 0) {
- SCLogWarning(SC_ERR_NFQ_SET_VERDICT,
- "nfq_set_verdict of %p failed %" PRId32 ": %s",
- p, ret, strerror(errno));
+ SCLogWarning(
+ "nfq_set_verdict of %p failed %" PRId32 ": %s", p, ret, strerror(errno));
}
return -1 ;
}
/* Will not be able to copy data ! Set length to 0
* to trigger an error in packet decoding.
* This is unlikely to happen */
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "NFQ sent too big packet");
+ SCLogWarning("NFQ sent too big packet");
SET_PKT_LEN(p, 0);
} else if (runmode_workers) {
PacketSetData(p, (uint8_t *)pktdata, ret);
int opt;
NFQQueueVars *q = NFQGetQueue(t->nfq_index);
if (q == NULL) {
- SCLogError(SC_ERR_NFQ_OPEN, "no queue for given index");
+ SCLogError("no queue for given index");
return TM_ECODE_FAILED;
}
SCLogDebug("opening library handle");
q->h = nfq_open();
if (q->h == NULL) {
- SCLogError(SC_ERR_NFQ_OPEN, "nfq_open() failed");
+ SCLogError("nfq_open() failed");
return TM_ECODE_FAILED;
}
* run. Ignoring the error seems to have no bad effects. */
SCLogDebug("unbinding existing nf_queue handler for AF_INET (if any)");
if (nfq_unbind_pf(q->h, AF_INET) < 0) {
- FatalError(SC_ERR_FATAL, "nfq_unbind_pf() for AF_INET failed");
+ FatalError("nfq_unbind_pf() for AF_INET failed");
}
if (nfq_unbind_pf(q->h, AF_INET6) < 0) {
- FatalError(SC_ERR_FATAL, "nfq_unbind_pf() for AF_INET6 failed");
+ FatalError("nfq_unbind_pf() for AF_INET6 failed");
}
nfq_g.unbind = 1;
SCLogDebug("binding nfnetlink_queue as nf_queue handler for AF_INET and AF_INET6");
if (nfq_bind_pf(q->h, AF_INET) < 0) {
- FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET failed");
+ FatalError("nfq_bind_pf() for AF_INET failed");
}
if (nfq_bind_pf(q->h, AF_INET6) < 0) {
- FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET6 failed");
+ FatalError("nfq_bind_pf() for AF_INET6 failed");
}
}
* callback function has access to it. */
q->qh = nfq_create_queue(q->h, q->queue_num, &NFQCallBack, (void *)t);
if (q->qh == NULL) {
- SCLogError(SC_ERR_NFQ_CREATE_QUEUE, "nfq_create_queue failed");
+ SCLogError("nfq_create_queue failed");
return TM_ECODE_FAILED;
}
/* 05DC = 1500 */
//if (nfq_set_mode(nfq_t->qh, NFQNL_COPY_PACKET, 0x05DC) < 0) {
if (nfq_set_mode(q->qh, NFQNL_COPY_PACKET, 0xFFFF) < 0) {
- SCLogError(SC_ERR_NFQ_SET_MODE, "can't set packet_copy mode");
+ SCLogError("can't set packet_copy mode");
return TM_ECODE_FAILED;
}
/* non-fatal if it fails */
if (nfq_set_queue_maxlen(q->qh, queue_maxlen) < 0) {
- SCLogWarning(SC_ERR_NFQ_MAXLEN, "can't set queue maxlen: your kernel probably "
- "doesn't support setting the queue length");
+ SCLogWarning("can't set queue maxlen: your kernel probably "
+ "doesn't support setting the queue length");
}
}
#endif /* HAVE_NFQ_MAXLEN */
#ifdef NETLINK_BROADCAST_SEND_ERROR
if (setsockopt(q->fd, SOL_NETLINK,
NETLINK_BROADCAST_SEND_ERROR, &opt, sizeof(int)) == -1) {
- SCLogWarning(SC_ERR_NFQ_SETSOCKOPT,
- "can't set netlink broadcast error: %s",
- strerror(errno));
+ SCLogWarning("can't set netlink broadcast error: %s", strerror(errno));
}
#endif
/* Don't send error about no buffer space available but drop the
#ifdef NETLINK_NO_ENOBUFS
if (setsockopt(q->fd, SOL_NETLINK,
NETLINK_NO_ENOBUFS, &opt, sizeof(int)) == -1) {
- SCLogWarning(SC_ERR_NFQ_SETSOCKOPT,
- "can't set netlink enobufs: %s",
- strerror(errno));
+ SCLogWarning("can't set netlink enobufs: %s", strerror(errno));
}
#endif
int r = nfq_set_queue_flags(q->qh, mask, flags);
if (r == -1) {
- SCLogWarning(SC_ERR_NFQ_SET_MODE, "can't set fail-open mode: %s",
- strerror(errno));
+ SCLogWarning("can't set fail-open mode: %s", strerror(errno));
} else {
SCLogInfo("fail-open mode should be set on queue");
}
if (runmode_workers) {
q->verdict_cache.maxlen = nfq_config.batchcount;
} else if (nfq_config.batchcount) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "nfq.batchcount is only valid in workers runmode.");
+ SCLogError("nfq.batchcount is only valid in workers runmode.");
}
#endif
tv.tv_usec = 0;
if(setsockopt(q->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
- SCLogWarning(SC_ERR_NFQ_SETSOCKOPT, "can't set socket timeout: %s", strerror(errno));
+ SCLogWarning("can't set socket timeout: %s", strerror(errno));
}
SCLogDebug("nfq_q->h %p, nfq_q->nh %p, nfq_q->qh %p, nfq_q->fd %" PRId32 "",
int r = NFQInitThread(ntv, (max_pending_packets * NFQ_BURST_FACTOR));
if (r != TM_ECODE_OK) {
- SCLogError(SC_ERR_NFQ_THREAD_INIT, "nfq thread failed to initialize");
+ SCLogError("nfq thread failed to initialize");
SCMutexUnlock(&nfq_init_lock);
exit(EXIT_FAILURE);
uint16_t num_cpus = UtilCpuGetNumProcessorsOnline();
if (g_nfq_t == NULL || g_nfq_q == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "NFQ context is not initialized");
+ SCLogError("NFQ context is not initialized");
return -1;
}
SCMutexLock(&nfq_init_lock);
if (!many_queues_warned && (receive_queue_num >= num_cpus)) {
- SCLogWarning(SC_WARN_UNCOMMON,
- "using more Netfilter queues than %hu available CPU core(s) "
+ SCLogWarning("using more Netfilter queues than %hu available CPU core(s) "
"may degrade performance",
- num_cpus);
+ num_cpus);
many_queues_warned = true;
}
if (receive_queue_num >= NFQ_MAX_QUEUE) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "can not register more than %d Netfilter queues",
- NFQ_MAX_QUEUE);
+ SCLogError("can not register more than %d Netfilter queues", NFQ_MAX_QUEUE);
SCMutexUnlock(&nfq_init_lock);
return -1;
}
ntv->livedev = LiveGetDevice(queue);
if (ntv->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
return -1;
}
int count = sscanf(queues, "%hu:%hu", &queue_start, &queue_end);
if (count < 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "specified queue(s) argument '%s' is not "
- "valid (allowed queue numbers are 0-65535)", queues);
+ SCLogError("specified queue(s) argument '%s' is not "
+ "valid (allowed queue numbers are 0-65535)",
+ queues);
return -1;
}
if (count == 2) {
// Sanity check
if (queue_start > queue_end) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "start queue's number %d is greater than "
- "ending number %d", queue_start, queue_end);
+ SCLogError("start queue's number %d is greater than "
+ "ending number %d",
+ queue_start, queue_end);
return -1;
}
// We do realloc() to preserve previously registered queues
void *ptmp = SCRealloc(g_nfq_t, (receive_queue_num + num_queues) * sizeof(NFQThreadVars));
if (ptmp == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate NFQThreadVars");
+ SCLogError("Unable to allocate NFQThreadVars");
NFQContextsClean();
exit(EXIT_FAILURE);
}
ptmp = SCRealloc(g_nfq_q, (receive_queue_num + num_queues) * sizeof(NFQQueueVars));
if (ptmp == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate NFQQueueVars");
+ SCLogError("Unable to allocate NFQQueueVars");
NFQContextsClean();
exit(EXIT_FAILURE);
}
#endif /* COUNTERS */
}
} else if(rv == 0) {
- SCLogWarning(SC_ERR_NFQ_RECV, "recv got returncode 0");
+ SCLogWarning("recv got returncode 0");
} else {
#ifdef DBG_PERF
if (rv > t->dbg_maxreadsize)
if (t->qh != NULL) {
ret = nfq_handle_packet(t->h, tv->data, rv);
} else {
- SCLogWarning(SC_ERR_NFQ_HANDLE_PKT, "NFQ handle has been destroyed");
+ SCLogWarning("NFQ handle has been destroyed");
ret = -1;
}
NFQMutexUnlock(t);
NFQMutexUnlock(t);
if (ret < 0) {
- SCLogWarning(SC_ERR_NFQ_SET_VERDICT,
- "nfq_set_verdict of %p failed %" PRId32 ": %s",
- p, ret, strerror(errno));
+ SCLogWarning("nfq_set_verdict of %p failed %" PRId32 ": %s", p, ret, strerror(errno));
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
TmEcode status = TM_ECODE_FAILED;
if (unlikely(ptv == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Directory vars was null");
+ SCLogError("Directory vars was null");
SCReturnInt(TM_ECODE_FAILED);
}
if (unlikely(ptv->shared == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Directory shared vars was null");
+ SCLogError("Directory shared vars was null");
SCReturnInt(TM_ECODE_FAILED);
}
TmEcode status = TM_ECODE_DONE;
if (unlikely(ptv == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Directory vars was null");
+ SCLogError("Directory vars was null");
SCReturnInt(TM_ECODE_FAILED);
}
if (unlikely(ptv->shared == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Directory shared vars was null");
+ SCLogError("Directory shared vars was null");
SCReturnInt(TM_ECODE_FAILED);
}
if (temp_dir == NULL) {//if null, our filename may just be a normal file
switch (errno) {
case EACCES:
- SCLogError(SC_ERR_FOPEN, "%s: Permission denied", filename);
+ SCLogError("%s: Permission denied", filename);
break;
case EBADF:
- SCLogError(SC_ERR_FOPEN,
- "%s: Not a valid file descriptor opened for reading",
- filename);
+ SCLogError("%s: Not a valid file descriptor opened for reading", filename);
break;
case EMFILE:
- SCLogError(SC_ERR_FOPEN,
- "%s: Per process open file descriptor limit reached",
- filename);
+ SCLogError("%s: Per process open file descriptor limit reached", filename);
break;
case ENFILE:
- SCLogError(SC_ERR_FOPEN,
- "%s: System wide open file descriptor limit reached",
- filename);
+ SCLogError("%s: System wide open file descriptor limit reached", filename);
break;
case ENOENT:
- SCLogError(SC_ERR_FOPEN,
- "%s: Does not exist, or name is an empty string",
- filename);
+ SCLogError("%s: Does not exist, or name is an empty string", filename);
break;
case ENOMEM:
- SCLogError(SC_ERR_FOPEN,
- "%s: Insufficient memory to complete the operation",
- filename);
+ SCLogError("%s: Insufficient memory to complete the operation", filename);
break;
case ENOTDIR: //no error checking the directory, just is a plain file
break;
default:
- SCLogError(SC_ERR_FOPEN, "%s: %" PRId32, filename, errno);
+ SCLogError("%s: %" PRId32, filename, errno);
}
} else {
//no error, filename references a directory
PendingFile *next_file_to_compare = NULL;
if (unlikely(pv == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "No directory vars passed");
+ SCLogError("No directory vars passed");
SCReturnInt(TM_ECODE_FAILED);
}
if (unlikely(file_to_add == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "File passed was null");
+ SCLogError("File passed was null");
SCReturnInt(TM_ECODE_FAILED);
}
if (unlikely(file_to_add->filename == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "File was passed with null filename");
+ SCLogError("File was passed with null filename");
SCReturnInt(TM_ECODE_FAILED);
}
struct timespec *older_than
) {
if (unlikely(pv == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "No directory vars passed");
+ SCLogError("No directory vars passed");
SCReturnInt(TM_ECODE_FAILED);
}
if (unlikely(pv->filename == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "No directory filename was passed");
+ SCLogError("No directory filename was passed");
SCReturnInt(TM_ECODE_FAILED);
}
struct dirent * dir = NULL;
written = snprintf(pathbuff, PATH_MAX, "%s/%s", pv->filename, dir->d_name);
if (written <= 0 || written >= PATH_MAX) {
- SCLogError(SC_ERR_SPRINTF, "Could not write path");
+ SCLogError("Could not write path");
SCReturnInt(TM_ECODE_FAILED);
} else {
file_to_add = SCCalloc(1, sizeof(PendingFile));
if (unlikely(file_to_add == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate pending file");
+ SCLogError("Failed to allocate pending file");
SCReturnInt(TM_ECODE_FAILED);
}
file_to_add->filename = SCStrdup(pathbuff);
if (unlikely(file_to_add->filename == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to copy filename");
+ SCLogError("Failed to copy filename");
CleanupPendingFile(file_to_add);
SCReturnInt(TM_ECODE_FAILED);
(uintmax_t)SCTimespecAsEpochMillis(&file_to_add->modified_time));
if (PcapDirectoryInsertFile(pv, file_to_add) == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Failed to add file");
+ SCLogError("Failed to add file");
CleanupPendingFile(file_to_add);
SCReturnInt(TM_ECODE_FAILED);
struct timespec *older_than)
{
if (PcapDirectoryPopulateBuffer(pv, older_than) == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Failed to populate directory buffer");
+ SCLogError("Failed to populate directory buffer");
SCReturnInt(TM_ECODE_FAILED);
}
TAILQ_REMOVE(&pv->directory_content, current_file, next);
if (unlikely(current_file == NULL)) {
- SCLogWarning(SC_ERR_PCAP_DISPATCH, "Current file was null");
+ SCLogWarning("Current file was null");
} else if (unlikely(current_file->filename == NULL)) {
- SCLogWarning(SC_ERR_PCAP_DISPATCH, "Current file filename was null");
+ SCLogWarning("Current file filename was null");
} else {
SCLogDebug("Processing file %s", current_file->filename);
PcapFileFileVars *pftv = SCMalloc(sizeof(PcapFileFileVars));
if (unlikely(pftv == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate PcapFileFileVars");
+ SCLogError("Failed to allocate PcapFileFileVars");
SCReturnInt(TM_ECODE_FAILED);
}
memset(pftv, 0, sizeof(PcapFileFileVars));
pftv->filename = SCStrdup(current_file->filename);
if (unlikely(pftv->filename == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate filename");
+ SCLogError("Failed to allocate filename");
CleanupPcapFileFileVars(pftv);
SCReturnInt(TM_ECODE_FAILED);
}
pftv->shared = pv->shared;
if (InitPcapFile(pftv) == TM_ECODE_FAILED) {
- SCLogWarning(SC_ERR_PCAP_DISPATCH,
- "Failed to init pcap file %s, skipping",
- current_file->filename);
+ SCLogWarning("Failed to init pcap file %s, skipping", current_file->filename);
CleanupPendingFile(current_file);
CleanupPcapFileFileVars(pftv);
status = TM_ECODE_OK;
StatsSyncCountersIfSignalled(ptv->shared->tv);
if (status == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_PCAP_DISPATCH, "Directory %s run mode failed", ptv->filename);
+ SCLogError("Directory %s run mode failed", ptv->filename);
status = PcapDirectoryFailure(ptv);
} else {
SCLogInfo("Directory run mode complete");
if (pfv->shared != NULL && pfv->shared->should_delete) {
SCLogDebug("Deleting pcap file %s", pfv->filename);
if (unlink(pfv->filename) != 0) {
- SCLogWarning(SC_ERR_PCAP_FILE_DELETE_FAILED,
- "Failed to delete %s", pfv->filename);
+ SCLogWarning("Failed to delete %s", pfv->filename);
}
}
SCFree(pfv->filename);
int r = pcap_dispatch(ptv->pcap_handle, packet_q_len,
(pcap_handler)PcapFileCallbackLoop, (u_char *)ptv);
if (unlikely(r == -1)) {
- SCLogError(SC_ERR_PCAP_DISPATCH, "error code %" PRId32 " %s for %s",
- r, pcap_geterr(ptv->pcap_handle), ptv->filename);
+ SCLogError("error code %" PRId32 " %s for %s", r, pcap_geterr(ptv->pcap_handle),
+ ptv->filename);
if (ptv->shared->cb_result == TM_ECODE_FAILED) {
SCReturnInt(TM_ECODE_FAILED);
}
ptv->shared->files++;
loop_result = TM_ECODE_DONE;
} else if (ptv->shared->cb_result == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_PCAP_DISPATCH,
- "Pcap callback PcapFileCallbackLoop failed for %s", ptv->filename);
+ SCLogError("Pcap callback PcapFileCallbackLoop failed for %s", ptv->filename);
loop_result = TM_ECODE_FAILED;
}
StatsSyncCountersIfSignalled(ptv->shared->tv);
{
int r = pcap_next_ex(pfv->pcap_handle, &pfv->first_pkt_hdr, &pfv->first_pkt_data);
if (r <= 0 || pfv->first_pkt_hdr == NULL) {
- SCLogError(SC_ERR_PCAP_OPEN_OFFLINE,
- "failed to get first packet timestamp. pcap_next_ex(): %d", r);
+ SCLogError("failed to get first packet timestamp. pcap_next_ex(): %d", r);
return false;
}
/* timestamp in pfv->first_pkt_hdr may not be 'struct timeval' so
char errbuf[PCAP_ERRBUF_SIZE] = "";
if(unlikely(pfv->filename == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Filename was null");
+ SCLogError("Filename was null");
SCReturnInt(TM_ECODE_FAILED);
}
pfv->pcap_handle = pcap_open_offline(pfv->filename, errbuf);
if (pfv->pcap_handle == NULL) {
- SCLogError(SC_ERR_FOPEN, "%s", errbuf);
+ SCLogError("%s", errbuf);
SCReturnInt(TM_ECODE_FAILED);
}
SCLogInfo("using bpf-filter \"%s\"", pfv->shared->bpf_string);
if (pcap_compile(pfv->pcap_handle, &pfv->filter, pfv->shared->bpf_string, 1, 0) < 0) {
- SCLogError(SC_ERR_BPF, "bpf compilation error %s for %s",
- pcap_geterr(pfv->pcap_handle), pfv->filename);
+ SCLogError("bpf compilation error %s for %s", pcap_geterr(pfv->pcap_handle),
+ pfv->filename);
SCReturnInt(TM_ECODE_FAILED);
}
if (pcap_setfilter(pfv->pcap_handle, &pfv->filter) < 0) {
- SCLogError(SC_ERR_BPF,"could not set bpf filter %s for %s",
- pcap_geterr(pfv->pcap_handle), pfv->filename);
+ SCLogError("could not set bpf filter %s for %s", pcap_geterr(pfv->pcap_handle),
+ pfv->filename);
pcap_freecode(&pfv->filter);
SCReturnInt(TM_ECODE_FAILED);
}
break;
default:
- SCLogError(SC_ERR_UNIMPLEMENTED,
- "datalink type %"PRId32" not (yet) supported in module PcapFile.",
- datalink);
+ SCLogError(
+ "datalink type %" PRId32 " not (yet) supported in module PcapFile.", datalink);
SCReturnInt(TM_ECODE_FAILED);
}
SCEnter();
if(unlikely(data == NULL)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "pcap file reader thread failed to initialize");
+ SCLogError("pcap file reader thread failed to initialize");
PcapFileExit(TM_ECODE_FAILED, NULL);
const char *tmp_bpf_string = NULL;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "error: initdata == NULL");
+ SCLogError("error: initdata == NULL");
SCReturnInt(TM_ECODE_OK);
}
ptv->shared.tenant_id = (uint32_t)tenant;
SCLogInfo("tenant %u", ptv->shared.tenant_id);
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant out of range");
+ SCLogError("tenant out of range");
}
}
} else {
ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
if (unlikely(ptv->shared.bpf_string == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate bpf_string");
+ SCLogError("Failed to allocate bpf_string");
CleanupPcapFileThreadVars(ptv);
SCLogDebug("argument %s was a file", (char *)initdata);
PcapFileFileVars *pv = SCMalloc(sizeof(PcapFileFileVars));
if (unlikely(pv == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate file vars");
+ SCLogError("Failed to allocate file vars");
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_OK);
}
pv->filename = SCStrdup((char *)initdata);
if (unlikely(pv->filename == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate filename");
+ SCLogError("Failed to allocate filename");
CleanupPcapFileFileVars(pv);
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_OK);
ptv->is_directory = 0;
ptv->behavior.file = pv;
} else {
- SCLogWarning(SC_ERR_PCAP_DISPATCH,
- "Failed to init pcap file %s, skipping", pv->filename);
+ SCLogWarning("Failed to init pcap file %s, skipping", pv->filename);
CleanupPcapFileFileVars(pv);
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_OK);
SCLogInfo("Argument %s was a directory", (char *)initdata);
PcapFileDirectoryVars *pv = SCMalloc(sizeof(PcapFileDirectoryVars));
if (unlikely(pv == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate directory vars");
+ SCLogError("Failed to allocate directory vars");
closedir(directory);
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_OK);
pv->filename = SCStrdup((char*)initdata);
if (unlikely(pv->filename == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate filename");
+ SCLogError("Failed to allocate filename");
CleanupPcapFileDirectoryVars(pv);
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_OK);
}
if (pv->should_recurse == true && pv->should_loop == true) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Error, --pcap-file-continuous and --pcap-file-recursive "
- "cannot be used together.");
+ SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
+ "cannot be used together.");
CleanupPcapFileDirectoryVars(pv);
CleanupPcapFileThreadVars(ptv);
SCReturnInt(TM_ECODE_FAILED);
pv->delay = (time_t)delay;
SCLogDebug("delay %lu", pv->delay);
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "delay out of range");
+ SCLogError("delay out of range");
}
}
pv->poll_interval = (time_t)poll_interval;
SCLogDebug("poll-interval %lu", pv->delay);
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "poll-interval out of range");
+ SCLogError("poll-interval out of range");
}
}
SC_ATOMIC_GET(pcap_g.invalid_checksums)) {
uint64_t chrate = pcap_g.cnt / SC_ATOMIC_GET(pcap_g.invalid_checksums);
if (chrate < CHECKSUM_INVALID_RATIO)
- SCLogWarning(SC_ERR_INVALID_CHECKSUM,
- "1/%" PRIu64 "th of packets have an invalid checksum,"
- " consider setting pcap-file.checksum-checks variable to no"
- " or use '-k none' option on command line.",
- chrate);
+ SCLogWarning("1/%" PRIu64 "th of packets have an invalid checksum,"
+ " consider setting pcap-file.checksum-checks variable to no"
+ " or use '-k none' option on command line.",
+ chrate);
else
SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
chrate);
if (pcap_compile(ptv->pcap_handle, &ptv->filter,
(char *)ptv->bpf_filter, 1, 0) < 0)
{
- SCLogError(SC_ERR_BPF, "bpf compilation error %s",
- pcap_geterr(ptv->pcap_handle));
+ SCLogError("bpf compilation error %s", pcap_geterr(ptv->pcap_handle));
return -1;
}
if (pcap_setfilter(ptv->pcap_handle, &ptv->filter) < 0) {
- SCLogError(SC_ERR_BPF, "could not set bpf filter %s",
- pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set bpf filter %s", pcap_geterr(ptv->pcap_handle));
return -1;
}
}
TmThreadsCaptureHandleTimeout(tv, NULL);
} else if (unlikely(r < 0)) {
int dbreak = 0;
- SCLogError(SC_ERR_PCAP_DISPATCH, "error code %" PRId32 " %s",
- r, pcap_geterr(ptv->pcap_handle));
+ SCLogError("error code %" PRId32 " %s", r, pcap_geterr(ptv->pcap_handle));
do {
usleep(PCAP_RECONNECT_TIMEOUT);
if (suricata_ctl_flags != 0) {
break;
}
} else if (ptv->cb_result == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_PCAP_DISPATCH, "Pcap callback PcapCallbackLoop failed");
+ SCLogError("Pcap callback PcapCallbackLoop failed");
SCReturnInt(TM_ECODE_FAILED);
}
PcapIfaceConfig *pcapconfig = (PcapIfaceConfig *)initdata;
if (initdata == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
ptv->livedev = LiveGetDevice(pcapconfig->iface);
if (ptv->livedev == NULL) {
- SCLogError(SC_EINVAL, "unable to find Live device");
+ SCLogError("unable to find Live device");
SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
ptv->pcap_handle = pcap_create((char *)pcapconfig->iface, errbuf);
if (ptv->pcap_handle == NULL) {
if (strlen(errbuf)) {
- SCLogError(SC_ERR_PCAP_CREATE, "could not create a new "
- "pcap handler for %s, error %s",
+ SCLogError("could not create a new "
+ "pcap handler for %s, error %s",
(char *)pcapconfig->iface, errbuf);
} else {
- SCLogError(SC_ERR_PCAP_CREATE, "could not create a new "
- "pcap handler for %s",
+ SCLogError("could not create a new "
+ "pcap handler for %s",
(char *)pcapconfig->iface);
}
SCFree(ptv);
/* set Snaplen. Must be called before pcap_activate */
int pcap_set_snaplen_r = pcap_set_snaplen(ptv->pcap_handle, ptv->pcap_snaplen);
if (pcap_set_snaplen_r != 0) {
- SCLogError(SC_ERR_PCAP_SET_SNAPLEN, "could not set snaplen, "
- "error: %s", pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set snaplen, "
+ "error: %s",
+ pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
/* set Promisc, and Timeout. Must be called before pcap_activate */
int pcap_set_promisc_r = pcap_set_promisc(ptv->pcap_handle, pcapconfig->promisc);
if (pcap_set_promisc_r != 0) {
- SCLogError(SC_ERR_PCAP_SET_PROMISC, "could not set promisc mode, "
- "error %s", pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set promisc mode, "
+ "error %s",
+ pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
int pcap_set_timeout_r = pcap_set_timeout(ptv->pcap_handle, LIBPCAP_COPYWAIT);
if (pcap_set_timeout_r != 0) {
- SCLogError(SC_ERR_PCAP_SET_TIMEOUT, "could not set timeout, "
- "error %s", pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set timeout, "
+ "error %s",
+ pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
int pcap_set_buffer_size_r = pcap_set_buffer_size(ptv->pcap_handle,
ptv->pcap_buffer_size);
if (pcap_set_buffer_size_r != 0) {
- SCLogError(SC_ERR_PCAP_SET_BUFF_SIZE, "could not set "
- "pcap buffer size, error %s", pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set "
+ "pcap buffer size, error %s",
+ pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
/* activate the handle */
int pcap_activate_r = pcap_activate(ptv->pcap_handle);
if (pcap_activate_r != 0) {
- SCLogError(SC_ERR_PCAP_ACTIVATE_HANDLE, "could not activate the "
- "pcap handler, error %s", pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not activate the "
+ "pcap handler, error %s",
+ pcap_geterr(ptv->pcap_handle));
SCFree(ptv);
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
if (pcap_compile(ptv->pcap_handle, &ptv->filter,
(char *)ptv->bpf_filter, 1, 0) < 0)
{
- SCLogError(SC_ERR_BPF, "bpf compilation error %s",
- pcap_geterr(ptv->pcap_handle));
+ SCLogError("bpf compilation error %s", pcap_geterr(ptv->pcap_handle));
SCMutexUnlock(&pcap_bpf_compile_lock);
SCFree(ptv);
}
if (pcap_setfilter(ptv->pcap_handle, &ptv->filter) < 0) {
- SCLogError(SC_ERR_BPF, "could not set bpf filter %s",
- pcap_geterr(ptv->pcap_handle));
+ SCLogError("could not set bpf filter %s", pcap_geterr(ptv->pcap_handle));
SCMutexUnlock(&pcap_bpf_compile_lock);
SCFree(ptv);
struct pcap_stat pcap_s;
if (pcap_stats(ptv->pcap_handle, &pcap_s) < 0) {
- SCLogError(SC_ERR_STAT,"(%s) Failed to get pcap_stats: %s",
- tv->name, pcap_geterr(ptv->pcap_handle));
+ SCLogError("(%s) Failed to get pcap_stats: %s", tv->name, pcap_geterr(ptv->pcap_handle));
SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name,
ptv->pkts, ptv->bytes);
} else {
*/
TmEcode NoPfringSupportExit(ThreadVars *tv, const void *initdata, void **data)
{
- SCLogError(SC_ERR_NO_PF_RING,"Error creating thread %s: you do not have support for pfring "
- "enabled please recompile with --enable-pfring", tv->name);
+ SCLogError("Error creating thread %s: you do not have support for pfring "
+ "enabled please recompile with --enable-pfring",
+ tv->name);
exit(EXIT_FAILURE);
}
p->vlan_idx = 1;
if (!ptv->vlan_hdr_warned) {
- SCLogWarning(SC_ERR_PF_RING_VLAN, "no VLAN header in the raw "
- "packet. See ticket #2355.");
+ SCLogWarning("no VLAN header in the raw "
+ "packet. See ticket #2355.");
ptv->vlan_hdr_warned = true;
}
}
* the threads have called pfring_set_cluster(). */
int rc = pfring_enable_ring(ptv->pd);
if (rc != 0) {
- SCLogError(SC_ERR_PF_RING_OPEN, "pfring_enable_ring failed returned %d ", rc);
+ SCLogError("pfring_enable_ring failed returned %d ", rc);
SCReturnInt(TM_ECODE_FAILED);
}
TmThreadsCaptureHandleTimeout(tv, p);
} else {
- SCLogError(SC_ERR_PF_RING_RECV,"pfring_recv error %" PRId32 "", r);
+ SCLogError("pfring_recv error %" PRId32 "", r);
TmqhOutputPacketpool(ptv->tv, p);
SCReturnInt(TM_ECODE_FAILED);
}
ptv->interface = SCStrdup(pfconf->iface);
if (unlikely(ptv->interface == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to allocate device string");
+ SCLogError("Unable to allocate device string");
SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
ptv->livedev = LiveGetDevice(pfconf->iface);
if (ptv->livedev == NULL) {
- SCLogError(SC_EINVAL, "Unable to find Live device");
+ SCLogError("Unable to find Live device");
SCFree(ptv);
SCReturnInt(TM_ECODE_FAILED);
}
if (ptv->checksum_mode == CHECKSUM_VALIDATION_RXONLY) {
if (strncmp(ptv->interface, "dna", 3) == 0) {
- SCLogWarning(SC_EINVAL, "Can't use rxonly checksum-checks on DNA interface,"
- " resetting to auto");
+ SCLogWarning("Can't use rxonly checksum-checks on DNA interface,"
+ " resetting to auto");
ptv->checksum_mode = CHECKSUM_VALIDATION_AUTO;
} else {
opflag |= PF_RING_LONG_HEADER;
ptv->pd = pfring_open(ptv->interface, (uint32_t)default_packet_size, opflag);
if (ptv->pd == NULL) {
- SCLogError(SC_ERR_PF_RING_OPEN,"Failed to open %s: pfring_open error."
- " Check if %s exists and pf_ring module is loaded.",
- ptv->interface,
- ptv->interface);
+ SCLogError("Failed to open %s: pfring_open error."
+ " Check if %s exists and pf_ring module is loaded.",
+ ptv->interface, ptv->interface);
pfconf->DerefFunc(pfconf);
SCFree(ptv);
return TM_ECODE_FAILED;
rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, ptv->ctype);
if (rc != 0) {
- SCLogError(SC_ERR_PF_RING_SET_CLUSTER_FAILED, "pfring_set_cluster "
- "returned %d for cluster-id: %d", rc, ptv->cluster_id);
+ SCLogError("pfring_set_cluster "
+ "returned %d for cluster-id: %d",
+ rc, ptv->cluster_id);
if (rc != PF_RING_ERROR_NOT_SUPPORTED || (pfconf->flags & PFRING_CONF_FLAGS_CLUSTER)) {
/* cluster is mandatory as explicitly specified in the configuration */
pfconf->DerefFunc(pfconf);
if (pfconf->bpf_filter) {
ptv->bpf_filter = SCStrdup(pfconf->bpf_filter);
if (unlikely(ptv->bpf_filter == NULL)) {
- SCLogError(SC_ENOMEM, "Set PF_RING bpf filter failed.");
+ SCLogError("Set PF_RING bpf filter failed.");
} else {
SCMutexLock(&pfring_bpf_set_filter_lock);
rc = pfring_set_bpf_filter(ptv->pd, ptv->bpf_filter);
SCMutexUnlock(&pfring_bpf_set_filter_lock);
if (rc < 0) {
- SCLogError(SC_EINVAL, "Failed to compile BPF \"%s\"", ptv->bpf_filter);
+ SCLogError("Failed to compile BPF \"%s\"", ptv->bpf_filter);
return TM_ECODE_FAILED;
}
}
rc = pfring_set_cluster(ptv->pd, ptv->cluster_id, CLUSTER_FLOW_5_TUPLE);
if (rc != 0) {
- SCLogError(SC_ERR_PF_RING_SET_CLUSTER_FAILED, "pfring_set_cluster "
- "returned %d for cluster-id: %d", rc, ptv->cluster_id);
+ SCLogError("pfring_set_cluster "
+ "returned %d for cluster-id: %d",
+ rc, ptv->cluster_id);
pfconf->DerefFunc(pfconf);
return TM_ECODE_FAILED;
}
TmEcode NoWinDivertSupportExit(ThreadVars *tv, const void *initdata,
void **data)
{
- SCLogError(
- SC_ERR_WINDIVERT_NOSUPPORT,
- "Error creating thread %s: you do not have support for WinDivert "
- "enabled; please recompile with --enable-windivert",
+ SCLogError("Error creating thread %s: you do not have support for WinDivert "
+ "enabled; please recompile with --enable-windivert",
tv->name);
exit(EXIT_FAILURE);
}
/**
* \brief logs a WinDivert error at Error level.
*/
-#define WinDivertLogError(err_code) \
- do { \
- const char *win_err_str = Win32GetErrorString((err_code), NULL); \
- SCLogError(SC_ERR_WINDIVERT_GENERIC, \
- "WinDivertOpen failed, error %" PRId32 " (0x%08" PRIx32 \
- "): %s %s", \
- (uint32_t)(err_code), (uint32_t)(err_code), win_err_str, \
- WinDivertGetErrorString(err_code)); \
- LocalFree((LPVOID)win_err_str); \
+#define WinDivertLogError(err_code) \
+ do { \
+ const char *win_err_str = Win32GetErrorString((err_code), NULL); \
+ SCLogError("WinDivertOpen failed, error %" PRId32 " (0x%08" PRIx32 "): %s %s", \
+ (uint32_t)(err_code), (uint32_t)(err_code), win_err_str, \
+ WinDivertGetErrorString(err_code)); \
+ LocalFree((LPVOID)win_err_str); \
} while (0);
/**
bool valid = WinDivertHelperCheckFilter(filter_str, layer, &error_str,
&error_pos);
if (!valid) {
- SCLogWarning(
- SC_ERR_WINDIVERT_INVALID_FILTER,
- "Invalid filter \"%s\" supplied to WinDivert: %s at position "
- "%" PRId32 "",
+ SCLogWarning("Invalid filter \"%s\" supplied to WinDivert: %s at position "
+ "%" PRId32 "",
filter_str, error_str, error_pos);
- SCReturnInt(SC_ERR_WINDIVERT_INVALID_FILTER);
+ SCReturnInt(-1);
}
/* initialize the queue */
SCMutexLock(&g_wd_init_lock);
if (g_wd_num >= WINDIVERT_MAX_QUEUE) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Too many WinDivert queues specified %" PRId32 "", g_wd_num);
+ SCLogError("Too many WinDivert queues specified %" PRId32 "", g_wd_num);
ret = -1;
goto unlock;
}
size_t copy_len =
strlcpy(wd_qv->filter_str, filter_str, sizeof(wd_qv->filter_str));
if (filter_len > copy_len) {
- SCLogWarning(SC_ERR_WINDIVERT_TOOLONG_FILTER,
- "Queue length exceeds storage by %" PRId32 " bytes",
- (int32_t)(filter_len - copy_len));
+ SCLogWarning("Queue length exceeds storage by %" PRId32 " bytes",
+ (int32_t)(filter_len - copy_len));
ret = -1;
goto unlock;
}
WinDivertThreadVars *wd_tv = (WinDivertThreadVars *)initdata;
if (wd_tv == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "initdata == NULL");
+ SCLogError("initdata == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
WinDivertQueueVars *wd_qv = WinDivertGetQueue(wd_tv->thread_num);
if (wd_qv == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "queue == NULL");
+ SCLogError("queue == NULL");
SCReturnInt(TM_ECODE_FAILED);
}
if (WinDivertCollectFilterDevices(wd_tv, wd_qv) == TM_ECODE_OK) {
WinDivertDisableOffloading(wd_tv);
} else {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to obtain network devices for WinDivert filter");
+ SCLogWarning("Failed to obtain network devices for WinDivert filter");
}
/* we open now so that we can immediately start handling packets,
if (!match) {
int err = GetLastError();
if (err != 0) {
- SCLogWarning(SC_ERR_WINDIVERT_GENERIC,
- "Failed to evaluate filter: 0x%" PRIx32, err);
+ SCLogWarning("Failed to evaluate filter: 0x%" PRIx32, err);
}
}
WinDivertThreadVars *wd_tv = (WinDivertThreadVars *)data;
WinDivertQueueVars *wd_qv = WinDivertGetQueue(wd_tv->thread_num);
if (wd_qv == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "queue == NULL");
+ SCLogError("queue == NULL");
SCReturn;
}
}
if (!WinDivertClose(wd_qv->filter_handle)) {
- SCLogError(SC_ERR_FATAL, "WinDivertClose failed: error %" PRIu32 "",
- (uint32_t)(GetLastError()));
+ SCLogError("WinDivertClose failed: error %" PRIu32 "", (uint32_t)(GetLastError()));
ret = TM_ECODE_FAILED;
goto unlock;
}
seg->pcap_hdr_storage = SCCalloc(1, sizeof(TcpSegmentPcapHdrStorage));
if (seg->pcap_hdr_storage == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate memory for "
- "TcpSegmentPcapHdrStorage");
+ SCLogError("Unable to allocate memory for "
+ "TcpSegmentPcapHdrStorage");
SCFree(seg);
return NULL;
} else {
seg->pcap_hdr_storage->pkt_hdr =
SCCalloc(1, sizeof(uint8_t) * TCPSEG_PKT_HDR_DEFAULT_SIZE);
if (seg->pcap_hdr_storage->pkt_hdr == NULL) {
- SCLogError(SC_ENOMEM, "Unable to allocate memory for "
- "packet header data within "
- "TcpSegmentPcapHdrStorage");
+ SCLogError("Unable to allocate memory for "
+ "packet header data within "
+ "TcpSegmentPcapHdrStorage");
SCFree(seg->pcap_hdr_storage);
SCFree(seg);
return NULL;
if (seg) {
uint32_t prealloc = 0;
if (StringParseUint32(&prealloc, 10, (uint16_t)strlen(seg->val), seg->val) < 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "segment-prealloc of "
- "%s is invalid", seg->val);
+ SCLogError("segment-prealloc of "
+ "%s is invalid",
+ seg->val);
return -1;
}
segment_prealloc = prealloc;
}
SCMutexUnlock(&segment_thread_pool_mutex);
if (ra_ctx->segment_thread_pool_id < 0 || segment_thread_pool == NULL) {
- SCLogError(sc_errno,
- "failed to setup/expand stream segment pool. Expand stream.reassembly.memcap?");
+ SCLogError("failed to setup/expand stream segment pool. Expand stream.reassembly.memcap?");
StreamTcpReassembleFreeThreadCtx(ra_ctx);
SCReturnPtr(NULL, "TcpReassemblyThreadCtx");
}
SC_ATOMIC_INIT(stream_config.reassembly_memcap);
if ((ConfGetInt("stream.max-sessions", &value)) == 1) {
- SCLogWarning(SC_WARN_OPTION_OBSOLETE, "max-sessions is obsolete. "
- "Number of concurrent sessions is now only limited by Flow and "
- "TCP stream engine memcaps.");
+ SCLogWarning("max-sessions is obsolete. "
+ "Number of concurrent sessions is now only limited by Flow and "
+ "TCP stream engine memcaps.");
}
if ((ConfGetInt("stream.prealloc-sessions", &value)) == 1) {
if (ConfGet("stream.memcap", &temp_stream_memcap_str) == 1) {
uint64_t stream_memcap_copy;
if (ParseSizeStringU64(temp_stream_memcap_str, &stream_memcap_copy) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing stream.memcap "
+ SCLogError("Error parsing stream.memcap "
"from conf file - %s. Killing engine",
- temp_stream_memcap_str);
+ temp_stream_memcap_str);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(stream_config.memcap, stream_memcap_copy);
uint64_t stream_reassembly_memcap_copy;
if (ParseSizeStringU64(temp_stream_reassembly_memcap_str,
&stream_reassembly_memcap_copy) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"stream.reassembly.memcap "
"from conf file - %s. Killing engine",
- temp_stream_reassembly_memcap_str);
+ temp_stream_reassembly_memcap_str);
exit(EXIT_FAILURE);
} else {
SC_ATOMIC_SET(stream_config.reassembly_memcap, stream_reassembly_memcap_copy);
if (ConfGet("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) {
if (ParseSizeStringU32(temp_stream_reassembly_depth_str,
&stream_config.reassembly_depth) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"stream.reassembly.depth "
"from conf file - %s. Killing engine",
- temp_stream_reassembly_depth_str);
+ temp_stream_reassembly_depth_str);
exit(EXIT_FAILURE);
}
} else {
const char *temp_rdrange;
if (ConfGet("stream.reassembly.randomize-chunk-range", &temp_rdrange) == 1) {
if (ParseSizeStringU16(temp_rdrange, &rdrange) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
- "stream.reassembly.randomize-chunk-range "
- "from conf file - %s. Killing engine",
+ SCLogError("Error parsing "
+ "stream.reassembly.randomize-chunk-range "
+ "from conf file - %s. Killing engine",
temp_rdrange);
exit(EXIT_FAILURE);
} else if (rdrange >= 100) {
- FatalError(SC_ERR_FATAL,
- "stream.reassembly.randomize-chunk-range "
- "must be lower than 100");
+ FatalError("stream.reassembly.randomize-chunk-range "
+ "must be lower than 100");
}
}
}
&temp_stream_reassembly_toserver_chunk_size_str) == 1) {
if (ParseSizeStringU16(temp_stream_reassembly_toserver_chunk_size_str,
&stream_config.reassembly_toserver_chunk_size) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"stream.reassembly.toserver-chunk-size "
"from conf file - %s. Killing engine",
- temp_stream_reassembly_toserver_chunk_size_str);
+ temp_stream_reassembly_toserver_chunk_size_str);
exit(EXIT_FAILURE);
}
} else {
&temp_stream_reassembly_toclient_chunk_size_str) == 1) {
if (ParseSizeStringU16(temp_stream_reassembly_toclient_chunk_size_str,
&stream_config.reassembly_toclient_chunk_size) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing "
+ SCLogError("Error parsing "
"stream.reassembly.toclient-chunk-size "
"from conf file - %s. Killing engine",
- temp_stream_reassembly_toclient_chunk_size_str);
+ temp_stream_reassembly_toclient_chunk_size_str);
exit(EXIT_FAILURE);
}
} else {
}
SCMutexUnlock(&ssn_pool_mutex);
if (stt->ssn_pool_id < 0 || ssn_pool == NULL) {
- SCLogError(sc_errno, "failed to setup/expand stream session pool. Expand stream.memcap?");
+ SCLogError("failed to setup/expand stream session pool. Expand stream.memcap?");
SCReturnInt(TM_ECODE_FAILED);
}
break;
#ifdef DEBUG
case IPPROTO_UDP:
- SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "UDP is currently unsupported");
+ SCLogWarning("UDP is currently unsupported");
break;
default:
- SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "This protocol is currently unsupported");
+ SCLogWarning("This protocol is currently unsupported");
break;
#endif
}
break;
#ifdef DEBUG
case IPPROTO_UDP:
- SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "UDP is currently unsupported");
+ SCLogWarning("UDP is currently unsupported");
break;
default:
- SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "This protocol is currently unsupported");
+ SCLogWarning("This protocol is currently unsupported");
break;
#endif
}
temp += cw;
}
}
- SCLogError(SC_ERR_SIGNAL, "%s", msg);
+ SCLogError("%s", msg);
terminate:
// Propagate signal to watchers, if any
{
#if HAVE_LIBSYSTEMD
if (sd_notify(0, "READY=1") < 0) {
- SCLogWarning(SC_ERR_SYSCALL, "failed to notify systemd");
+ SCLogWarning("failed to notify systemd");
/* Please refer to:
* https://www.freedesktop.org/software/systemd/man/sd_notify.html#Return%20Value
* for discussion on why failure should not be considered an error */
return TM_ECODE_OK;
if (EngineModeIsIPS()) {
- SCLogError(SC_ERR_NOT_SUPPORTED,
- "BPF filter not available in IPS mode."
+ SCLogError("BPF filter not available in IPS mode."
" Use firewall filtering if possible.");
return TM_ECODE_FAILED;
}
if(strlen(bpf_filter) > 0) {
if (ConfSetFinal("bpf-filter", bpf_filter) != 1) {
- SCLogError(SC_ERR_FATAL, "Failed to set bpf filter.");
+ SCLogError("Failed to set bpf filter.");
SCFree(bpf_filter);
return TM_ECODE_FAILED;
}
size_t nm = 0;
if (EngineModeIsIPS()) {
- FatalError(SC_ERR_FATAL,
- "BPF filter not available in IPS mode."
- " Use firewall filtering if possible.");
+ FatalError("BPF filter not available in IPS mode."
+ " Use firewall filtering if possible.");
}
fp = fopen(filename, "r");
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "Failed to open file %s", filename);
+ SCLogError("Failed to open file %s", filename);
exit(EXIT_FAILURE);
}
#else
if (fstat(fileno(fp), &st) != 0) {
#endif /* OS_WIN32 */
- SCLogError(SC_ERR_FOPEN, "Failed to stat file %s", filename);
+ SCLogError("Failed to stat file %s", filename);
exit(EXIT_FAILURE);
}
bpf_len = st.st_size + 1;
bpf_filter = SCMalloc(bpf_len);
if (unlikely(bpf_filter == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate buffer for bpf filter in file %s", filename);
+ SCLogError("Failed to allocate buffer for bpf filter in file %s", filename);
exit(EXIT_FAILURE);
}
memset(bpf_filter, 0x00, bpf_len);
nm = fread(bpf_filter, 1, bpf_len - 1, fp);
if ((ferror(fp) != 0) || (nm != (bpf_len - 1))) {
- SCLogError(SC_ERR_BPF, "Failed to read complete BPF file %s", filename);
+ SCLogError("Failed to read complete BPF file %s", filename);
SCFree(bpf_filter);
fclose(fp);
exit(EXIT_FAILURE);
}
if (strlen(bpf_filter) > 0) {
if(ConfSetFinal("bpf-filter", bpf_filter) != 1) {
- SCLogError(SC_ERR_FOPEN, "ERROR: Failed to set bpf filter!");
+ SCLogError("ERROR: Failed to set bpf filter!");
SCFree(bpf_filter);
exit(EXIT_FAILURE);
}
if (strlen(pcap_dev) == 0) {
int ret = LiveBuildDeviceList("pcap");
if (ret == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "No interface found in config for pcap");
+ SCLogError("No interface found in config for pcap");
SCReturnInt(TM_ECODE_FAILED);
}
}
/* iface has been set on command line */
if (strlen(pcap_dev)) {
if (ConfSetFinal("pfring.live-interface", pcap_dev) != 1) {
- SCLogError(SC_ERR_INITIALIZATION, "Failed to set pfring.live-interface");
+ SCLogError("Failed to set pfring.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else {
char iface_selector[] = "dpdk.interfaces";
int ret = LiveBuildDeviceList(iface_selector);
if (ret == 0) {
- SCLogError(
- SC_ERR_INITIALIZATION, "No interface found in config for %s", iface_selector);
+ SCLogError("No interface found in config for %s", iface_selector);
SCReturnInt(TM_ECODE_FAILED);
}
#endif
/* iface has been set on command line */
if (strlen(pcap_dev)) {
if (ConfSetFinal("af-packet.live-interface", pcap_dev) != 1) {
- SCLogError(SC_ERR_INITIALIZATION, "Failed to set af-packet.live-interface");
+ SCLogError("Failed to set af-packet.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else {
int ret = LiveBuildDeviceList("af-packet");
if (ret == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "No interface found in config for af-packet");
+ SCLogError("No interface found in config for af-packet");
SCReturnInt(TM_ECODE_FAILED);
}
}
/* iface has been set on command line */
if (strlen(pcap_dev)) {
if (ConfSetFinal("af-xdp.live-interface", pcap_dev) != 1) {
- SCLogError(SC_ERR_INITIALIZATION, "Failed to set af-xdp.live-interface");
+ SCLogError("Failed to set af-xdp.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else {
int ret = LiveBuildDeviceList("af-xdp");
if (ret == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "No interface found in config for af-xdp");
+ SCLogError("No interface found in config for af-xdp");
SCReturnInt(TM_ECODE_FAILED);
}
}
/* iface has been set on command line */
if (strlen(pcap_dev)) {
if (ConfSetFinal("netmap.live-interface", pcap_dev) != 1) {
- SCLogError(SC_ERR_INITIALIZATION, "Failed to set netmap.live-interface");
+ SCLogError("Failed to set netmap.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else {
int ret = LiveBuildDeviceList("netmap");
if (ret == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "No interface found in config for netmap");
+ SCLogError("No interface found in config for netmap");
SCReturnInt(TM_ECODE_FAILED);
}
}
} else if (runmode == RUNMODE_NFLOG) {
int ret = LiveBuildDeviceListCustom("nflog", "group");
if (ret == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "No group found in config for nflog");
+ SCLogError("No group found in config for nflog");
SCReturnInt(TM_ECODE_FAILED);
}
#endif
SCLogInfo("Multiple af-packet option without interface on each is useless");
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(suri->progname);
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
#else
- SCLogError(SC_ERR_NO_AF_PACKET,"AF_PACKET not enabled. On Linux "
- "host, make sure to pass --enable-af-packet to "
- "configure when building.");
+ SCLogError("AF_PACKET not enabled. On Linux "
+ "host, make sure to pass --enable-af-packet to "
+ "configure when building.");
return TM_ECODE_FAILED;
#endif
}
SCLogInfo("Multiple af-xdp options without interface on each is useless");
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(suri->progname);
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
#else
- SCLogError(SC_ERR_NO_AF_XDP, "AF_XDP not enabled. On Linux "
- "host, make sure correct libraries are installed,"
- " see documentation for information.");
+ SCLogError("AF_XDP not enabled. On Linux "
+ "host, make sure correct libraries are installed,"
+ " see documentation for information.");
return TM_ECODE_FAILED;
#endif
}
} else if (suri->run_mode == RUNMODE_DPDK) {
SCLogInfo("Multiple dpdk options have no effect on Suricata");
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(suri->progname);
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
#else
- SCLogError(SC_ERR_NO_DPDK, "DPDK not enabled. On Linux "
- "host, make sure to pass --enable-dpdk to "
- "configure when building.");
+ SCLogError("DPDK not enabled. On Linux "
+ "host, make sure to pass --enable-dpdk to "
+ "configure when building.");
return TM_ECODE_FAILED;
#endif
}
{
#if defined(OS_WIN32) && !defined(HAVE_LIBWPCAP)
/* If running on Windows without Npcap, bail early as live capture is not supported. */
- FatalError(SC_ERR_FATAL,
- "Live capture not available. To support live capture compile against Npcap.");
+ FatalError("Live capture not available. To support live capture compile against Npcap.");
#endif
memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev));
if (strcmp(suri->pcap_dev, in_arg) != 0) {
SCLogInfo("translated %s to pcap device %s", in_arg, suri->pcap_dev);
} else if (strlen(suri->pcap_dev) > 0 && isdigit((unsigned char)suri->pcap_dev[0])) {
- SCLogError(SC_ERR_PCAP_TRANSLATE, "failed to find a pcap device for IP %s", in_arg);
+ SCLogError("failed to find a pcap device for IP %s", in_arg);
return TM_ECODE_FAILED;
}
}
} else if (suri->run_mode == RUNMODE_PCAP_DEV) {
LiveRegisterDeviceName(suri->pcap_dev);
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(suri->progname);
return TM_ECODE_FAILED;
}
LiveRegisterDeviceName(optarg);
}
#else
- SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure "
- "to pass --enable-pfring to configure when building.");
+ SCLogError("PF_RING not enabled. Make sure "
+ "to pass --enable-pfring to configure when building.");
return TM_ECODE_FAILED;
#endif /* HAVE_PFRING */
}
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure "
- "to pass --enable-pfring to configure when building.");
+ SCLogError("PF_RING not enabled. Make sure "
+ "to pass --enable-pfring to configure when building.");
return TM_ECODE_FAILED;
#endif /* HAVE_PFRING */
}
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure "
- "to pass --enable-pfring to configure when building.");
+ SCLogError("PF_RING not enabled. Make sure "
+ "to pass --enable-pfring to configure when building.");
return TM_ECODE_FAILED;
#endif /* HAVE_PFRING */
}
break;
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_NO_NETMAP, "NETMAP not enabled.");
- return TM_ECODE_FAILED;
+ SCLogError("NETMAP not enabled.");
+ return TM_ECODE_FAILED;
#endif
} else if (strcmp((long_opts[option_index]).name, "nflog") == 0) {
#ifdef HAVE_NFLOG
LiveBuildDeviceListCustom("nflog", "group");
}
#else
- SCLogError(SC_ERR_NFLOG_NOSUPPORT, "NFLOG not enabled.");
+ SCLogError("NFLOG not enabled.");
return TM_ECODE_FAILED;
#endif /* HAVE_NFLOG */
} else if (strcmp((long_opts[option_index]).name, "pcap") == 0) {
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
else if(strcmp((long_opts[option_index]).name, "pidfile") == 0) {
suri->pid_filename = SCStrdup(optarg);
if (suri->pid_filename == NULL) {
- SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
+ SCLogError("strdup failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
}
#endif /* UNITTESTS */
} else if (strcmp((long_opts[option_index]).name, "user") == 0) {
#ifndef HAVE_LIBCAP_NG
- SCLogError(SC_ERR_LIBCAP_NG_REQUIRED, "libcap-ng is required to"
- " drop privileges, but it was not compiled into Suricata.");
+ SCLogError("libcap-ng is required to"
+ " drop privileges, but it was not compiled into Suricata.");
return TM_ECODE_FAILED;
#else
suri->user_name = optarg;
#endif /* HAVE_LIBCAP_NG */
} else if (strcmp((long_opts[option_index]).name, "group") == 0) {
#ifndef HAVE_LIBCAP_NG
- SCLogError(SC_ERR_LIBCAP_NG_REQUIRED, "libcap-ng is required to"
- " drop privileges, but it was not compiled into Suricata.");
+ SCLogError("libcap-ng is required to"
+ " drop privileges, but it was not compiled into Suricata.");
return TM_ECODE_FAILED;
#else
suri->group_name = optarg;
suri->run_mode = RUNMODE_DAG;
}
else if (suri->run_mode != RUNMODE_DAG) {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE,
- "more than one run mode has been specified");
+ SCLogError("more than one run mode has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
LiveRegisterDeviceName(optarg);
#else
- SCLogError(SC_ERR_DAG_REQUIRED, "libdag and a DAG card are required"
- " to receive packets using --dag.");
+ SCLogError("libdag and a DAG card are required"
+ " to receive packets using --dag.");
return TM_ECODE_FAILED;
#endif /* HAVE_DAG */
} else if (strcmp((long_opts[option_index]).name, "napatech") == 0) {
#ifdef HAVE_NAPATECH
suri->run_mode = RUNMODE_NAPATECH;
#else
- SCLogError(SC_ERR_NAPATECH_REQUIRED, "libntapi and a Napatech adapter are required"
- " to capture packets using --napatech.");
+ SCLogError("libntapi and a Napatech adapter are required"
+ " to capture packets using --napatech.");
return TM_ECODE_FAILED;
#endif /* HAVE_NAPATECH */
} else if (strcmp((long_opts[option_index]).name, "pcap-buffer-size") == 0) {
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_NO_PCAP_SET_BUFFER_SIZE, "The version of libpcap you have"
- " doesn't support setting buffer size.");
+ SCLogError("The version of libpcap you have"
+ " doesn't support setting buffer size.");
#endif /* HAVE_PCAP_SET_BUFF */
} else if (strcmp((long_opts[option_index]).name, "build-info") == 0) {
suri->run_mode = RUNMODE_PRINT_BUILDINFO;
exit(EXIT_FAILURE);
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
exit(EXIT_FAILURE);
}
#else
- SCLogError(SC_ERR_WINDIVERT_NOSUPPORT,"WinDivert not enabled. Make sure to pass --enable-windivert to configure when building.");
+ SCLogError("WinDivert not enabled. Make sure to pass --enable-windivert to "
+ "configure when building.");
return TM_ECODE_FAILED;
#endif /* WINDIVERT */
} else if(strcmp((long_opts[option_index]).name, "reject-dev") == 0) {
g_reject_dev_mtu = (uint16_t)mtu;
}
#else
- SCLogError(SC_ERR_LIBNET_NOT_ENABLED,
- "Libnet 1.1 support not enabled. Compile Suricata with libnet support.");
+ SCLogError("Libnet 1.1 support not enabled. Compile Suricata with libnet support.");
return TM_ECODE_FAILED;
#endif
}
/* Quick validation. */
char *val = strchr(optarg, '=');
if (val == NULL) {
- FatalError(SC_ERR_FATAL,
- "Invalid argument for --set, must be key=val.");
+ FatalError("Invalid argument for --set, must be key=val.");
}
if (!ConfSetFromString(optarg, 1)) {
fprintf(stderr, "Failed to set configuration value %s.",
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-continuous") == 0) {
if (ConfSetFinal("pcap-file.continuous", "true") != 1) {
- SCLogError(SC_ERR_CMD_LINE, "Failed to set pcap-file.continuous");
+ SCLogError("Failed to set pcap-file.continuous");
return TM_ECODE_FAILED;
}
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-delete") == 0) {
if (ConfSetFinal("pcap-file.delete-when-done", "true") != 1) {
- SCLogError(SC_ERR_CMD_LINE, "Failed to set pcap-file.delete-when-done");
+ SCLogError("Failed to set pcap-file.delete-when-done");
return TM_ECODE_FAILED;
}
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-recursive") == 0) {
if (ConfSetFinal("pcap-file.recursive", "true") != 1) {
- SCLogError(SC_ERR_CMD_LINE, "ERROR: Failed to set pcap-file.recursive");
+ SCLogError("ERROR: Failed to set pcap-file.recursive");
return TM_ECODE_FAILED;
}
}
else if (strcmp((long_opts[option_index]).name, "data-dir") == 0) {
if (optarg == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "no option argument (optarg) for -d");
+ SCLogError("no option argument (optarg) for -d");
return TM_ECODE_FAILED;
}
if (ConfigSetDataDirectory(optarg) != TM_ECODE_OK) {
- SCLogError(SC_ERR_FATAL, "Failed to set data directory.");
+ SCLogError("Failed to set data directory.");
return TM_ECODE_FAILED;
}
if (ConfigCheckDataDirectory(optarg) != TM_ECODE_OK) {
- SCLogError(SC_ERR_LOGDIR_CMDLINE, "The data directory \"%s\""
- " supplied at the commandline (-d %s) doesn't "
- "exist. Shutting down the engine.", optarg, optarg);
+ SCLogError("The data directory \"%s\""
+ " supplied at the commandline (-d %s) doesn't "
+ "exist. Shutting down the engine.",
+ optarg, optarg);
return TM_ECODE_FAILED;
}
suri->set_datadir = true;
suri->strict_rule_parsing_string = SCStrdup(optarg);
}
if (suri->strict_rule_parsing_string == NULL) {
- FatalError(SC_ENOMEM, "failed to duplicate 'strict' string");
+ FatalError("failed to duplicate 'strict' string");
}
} else {
int r = ExceptionSimulationCommandlineParser(
return TM_ECODE_OK;
case 'i':
if (optarg == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "no option argument (optarg) for -i");
+ SCLogError("no option argument (optarg) for -i");
return TM_ECODE_FAILED;
}
#ifdef HAVE_AF_PACKET
#ifdef HAVE_NETMAP
i++;
#endif
- SCLogWarning(SC_WARN_FASTER_CAPTURE_AVAILABLE, "faster capture "
- "option%s %s available:"
+ SCLogWarning("faster capture "
+ "option%s %s available:"
#ifdef HAVE_PFRING
- " PF_RING (--pfring-int=%s)"
+ " PF_RING (--pfring-int=%s)"
#endif
#ifdef HAVE_NETMAP
- " NETMAP (--netmap=%s)"
+ " NETMAP (--netmap=%s)"
#endif
- ". Use --pcap=%s to suppress this warning",
+ ". Use --pcap=%s to suppress this warning",
i == 1 ? "" : "s", i == 1 ? "is" : "are"
#ifdef HAVE_PFRING
- , optarg
+ ,
+ optarg
#endif
#ifdef HAVE_NETMAP
- , optarg
+ ,
+ optarg
#endif
- , optarg
- );
+ ,
+ optarg);
#endif /* have faster methods */
if (ParseCommandLinePcapLive(suri, optarg) != TM_ECODE_OK) {
return TM_ECODE_FAILED;
break;
case 'l':
if (optarg == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "no option argument (optarg) for -l");
+ SCLogError("no option argument (optarg) for -l");
return TM_ECODE_FAILED;
}
if (ConfigSetLogDirectory(optarg) != TM_ECODE_OK) {
- SCLogError(SC_ERR_FATAL, "Failed to set log directory.");
+ SCLogError("Failed to set log directory.");
return TM_ECODE_FAILED;
}
if (ConfigCheckLogDirectoryExists(optarg) != TM_ECODE_OK) {
- SCLogError(SC_ERR_LOGDIR_CMDLINE, "The logging directory \"%s\""
- " supplied at the commandline (-l %s) doesn't "
- "exist. Shutting down the engine.", optarg, optarg);
+ SCLogError("The logging directory \"%s\""
+ " supplied at the commandline (-l %s) doesn't "
+ "exist. Shutting down the engine.",
+ optarg, optarg);
return TM_ECODE_FAILED;
}
if (!IsLogDirectoryWritable(optarg)) {
- SCLogError(SC_ERR_LOGDIR_CMDLINE, "The logging directory \"%s\""
- " supplied at the commandline (-l %s) is not "
- "writable. Shutting down the engine.", optarg, optarg);
+ SCLogError("The logging directory \"%s\""
+ " supplied at the commandline (-l %s) is not "
+ "writable. Shutting down the engine.",
+ optarg, optarg);
return TM_ECODE_FAILED;
}
suri->set_logdir = true;
if (NFQParseAndRegisterQueues(optarg) == -1)
return TM_ECODE_FAILED;
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_NFQ_NOSUPPORT,"NFQUEUE not enabled. Make sure to pass --enable-nfqueue to configure when building.");
+ SCLogError("NFQUEUE not enabled. Make sure to pass --enable-nfqueue to configure when "
+ "building.");
return TM_ECODE_FAILED;
#endif /* NFQ */
break;
if (IPFWRegisterQueue(optarg) == -1)
return TM_ECODE_FAILED;
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
#else
- SCLogError(SC_ERR_IPFW_NOSUPPORT,"IPFW not enabled. Make sure to pass --enable-ipfw to configure when building.");
+ SCLogError("IPFW not enabled. Make sure to pass --enable-ipfw to configure when "
+ "building.");
return TM_ECODE_FAILED;
#endif /* IPFW */
break;
if (suri->run_mode == RUNMODE_UNKNOWN) {
suri->run_mode = RUNMODE_PCAP_FILE;
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
- "has been specified");
+ SCLogError("more than one run mode "
+ "has been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
struct stat buf;
if (stat(optarg, &buf) != 0) {
#endif /* OS_WIN32 */
- SCLogError(SC_ERR_INITIALIZATION, "ERROR: Pcap file does not exist\n");
+ SCLogError("ERROR: Pcap file does not exist\n");
return TM_ECODE_FAILED;
}
if (ConfSetFinal("pcap-file.file", optarg) != 1) {
- SCLogError(SC_ERR_INITIALIZATION, "ERROR: Failed to set pcap-file.file\n");
+ SCLogError("ERROR: Failed to set pcap-file.file\n");
return TM_ECODE_FAILED;
}
break;
case 's':
if (suri->sig_file != NULL) {
- SCLogError(SC_ERR_CMD_LINE, "can't have multiple -s options or mix -s and -S.");
+ SCLogError("can't have multiple -s options or mix -s and -S.");
return TM_ECODE_FAILED;
}
suri->sig_file = optarg;
break;
case 'S':
if (suri->sig_file != NULL) {
- SCLogError(SC_ERR_CMD_LINE, "can't have multiple -S options or mix -s and -S.");
+ SCLogError("can't have multiple -S options or mix -s and -S.");
return TM_ECODE_FAILED;
}
suri->sig_file = optarg;
if (suri->run_mode == RUNMODE_UNKNOWN) {
suri->run_mode = RUNMODE_UNITTEST;
} else {
- SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode has"
- " been specified");
+ SCLogError("more than one run mode has"
+ " been specified");
PrintUsage(argv[0]);
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
case 'F':
if (optarg == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "no option argument (optarg) for -F");
+ SCLogError("no option argument (optarg) for -F");
return TM_ECODE_FAILED;
}
break;
case 'k':
if (optarg == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "no option argument (optarg) for -k");
+ SCLogError("no option argument (optarg) for -k");
return TM_ECODE_FAILED;
}
if (!strcmp("all", optarg))
else if (!strcmp("none", optarg))
suri->checksum_validation = 0;
else {
- SCLogError(SC_ERR_INITIALIZATION, "option '%s' invalid for -k", optarg);
+ SCLogError("option '%s' invalid for -k", optarg);
return TM_ECODE_FAILED;
}
break;
}
if (suri->disabled_detect && suri->sig_file != NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "can't use -s/-S when detection is disabled");
+ SCLogError("can't use -s/-S when detection is disabled");
return TM_ECODE_FAILED;
}
*p = '\0';
}
if (!SetCurrentDirectory(path)) {
- SCLogError(SC_ERR_FATAL, "Can't set current directory to: %s", path);
+ SCLogError("Can't set current directory to: %s", path);
return -1;
}
SCLogInfo("Current directory is set to: %s", path);
/* Windows socket subsystem initialization */
WSADATA wsaData;
if (0 != WSAStartup(MAKEWORD(2, 2), &wsaData)) {
- SCLogError(SC_ERR_FATAL, "Can't initialize Windows sockets: %d", WSAGetLastError());
+ SCLogError("Can't initialize Windows sockets: %d", WSAGetLastError());
return -1;
}
/* The pid file name may be in config memory, but is needed later. */
suri->pid_filename = SCStrdup(pid_filename);
if (suri->pid_filename == NULL) {
- SCLogError(SC_ENOMEM, "strdup failed: %s", strerror(errno));
+ SCLogError("strdup failed: %s", strerror(errno));
return TM_ECODE_FAILED;
}
}
if (SCPidfileCreate(suri->pid_filename) != 0) {
SCFree(suri->pid_filename);
suri->pid_filename = NULL;
- SCLogError(SC_ERR_PIDFILE_DAEMON,
- "Unable to create PID file, concurrent run of"
- " Suricata can occur.");
- SCLogError(SC_ERR_PIDFILE_DAEMON,
- "PID file creation WILL be mandatory for daemon mode"
- " in future version");
+ SCLogError("Unable to create PID file, concurrent run of"
+ " Suricata can occur.");
+ SCLogError("PID file creation WILL be mandatory for daemon mode"
+ " in future version");
}
}
if (suri->do_setuid == TRUE) {
if (SCGetUserID(suri->user_name, suri->group_name,
&suri->userid, &suri->groupid) != 0) {
- SCLogError(SC_ERR_UID_FAILED, "failed in getting user ID");
+ SCLogError("failed in getting user ID");
return TM_ECODE_FAILED;
}
/* Get the suricata group ID to given group ID */
} else if (suri->do_setgid == TRUE) {
if (SCGetGroupID(suri->group_name, &suri->groupid) != 0) {
- SCLogError(SC_ERR_GID_FAILED, "failed in getting group ID");
+ SCLogError("failed in getting group ID");
return TM_ECODE_FAILED;
}
static int LoadSignatures(DetectEngineCtx *de_ctx, SCInstance *suri)
{
if (SigLoadSignatures(de_ctx, suri->sig_file, suri->sig_file_exclusive) < 0) {
- SCLogError(SC_ERR_NO_RULES_LOADED, "Loading signatures failed.");
+ SCLogError("Loading signatures failed.");
if (de_ctx->failure_fatal)
return TM_ECODE_FAILED;
}
if (ConfGetInt("max-pending-packets", &max_pending_packets) != 1)
max_pending_packets = DEFAULT_MAX_PENDING_PACKETS;
if (max_pending_packets >= 65535) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Maximum max-pending-packets setting is 65534. "
- "Please check %s for errors", suri->conf_filename);
+ SCLogError("Maximum max-pending-packets setting is 65534. "
+ "Please check %s for errors",
+ suri->conf_filename);
return TM_ECODE_FAILED;
}
}
} else {
if (ParseSizeStringU32(temp_default_packet_size, &default_packet_size) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing max-pending-packets "
+ SCLogError("Error parsing max-pending-packets "
"from conf file - %s. Killing engine",
- temp_default_packet_size);
+ temp_default_packet_size);
return TM_ECODE_FAILED;
}
}
if (mt_enabled)
(void)ConfGetBool("multi-detect.default", &default_tenant);
if (DetectEngineMultiTenantSetup(suri->unix_socket_enabled) == -1) {
- FatalError(SC_ERR_FATAL, "initializing multi-detect "
+ FatalError("initializing multi-detect "
"detection engine contexts failed.");
}
if (suri->delayed_detect && suri->run_mode != RUNMODE_CONF_TEST) {
de_ctx = DetectEngineCtxInit();
}
if (de_ctx == NULL) {
- FatalError(SC_ERR_FATAL, "initializing detection engine "
+ FatalError("initializing detection engine "
"context failed.");
}
if (suri->set_logdir == false) {
/* override log dir to current work dir" */
if (ConfigSetLogDirectory((char *)".") != TM_ECODE_OK) {
- FatalError(SC_ERR_LOGDIR_CONFIG, "could not set USER mode logdir");
+ FatalError("could not set USER mode logdir");
}
}
if (suri->set_datadir == false) {
/* override data dir to current work dir" */
if (ConfigSetDataDirectory((char *)".") != TM_ECODE_OK) {
- FatalError(SC_ERR_LOGDIR_CONFIG, "could not set USER mode datadir");
+ FatalError("could not set USER mode datadir");
}
}
}
IPPairBitInitCtx();
if (DetectAddressTestConfVars() < 0) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "basic address vars test failed. Please check %s for errors",
- suri->conf_filename);
+ SCLogError(
+ "basic address vars test failed. Please check %s for errors", suri->conf_filename);
SCReturnInt(TM_ECODE_FAILED);
}
if (DetectPortTestConfVars() < 0) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "basic port vars test failed. Please check %s for errors",
- suri->conf_filename);
+ SCLogError("basic port vars test failed. Please check %s for errors", suri->conf_filename);
SCReturnInt(TM_ECODE_FAILED);
}
suri->log_dir = ConfigGetLogDirectory();
if (ConfigCheckLogDirectoryExists(suri->log_dir) != TM_ECODE_OK) {
- SCLogError(SC_ERR_LOGDIR_CONFIG, "The logging directory \"%s\" "
- "supplied by %s (default-log-dir) doesn't exist. "
- "Shutting down the engine", suri->log_dir, suri->conf_filename);
+ SCLogError("The logging directory \"%s\" "
+ "supplied by %s (default-log-dir) doesn't exist. "
+ "Shutting down the engine",
+ suri->log_dir, suri->conf_filename);
SCReturnInt(TM_ECODE_FAILED);
}
if (!IsLogDirectoryWritable(suri->log_dir)) {
- SCLogError(SC_ERR_LOGDIR_CONFIG, "The logging directory \"%s\" "
- "supplied by %s (default-log-dir) is not writable. "
- "Shutting down the engine", suri->log_dir, suri->conf_filename);
+ SCLogError("The logging directory \"%s\" "
+ "supplied by %s (default-log-dir) is not writable. "
+ "Shutting down the engine",
+ suri->log_dir, suri->conf_filename);
SCReturnInt(TM_ECODE_FAILED);
}
#ifndef OS_WIN32
UtilSignalHandlerSetup(SIGUSR2, SIG_IGN);
if (UtilSignalBlock(SIGUSR2)) {
- SCLogError(SC_ERR_INITIALIZATION, "SIGUSR2 initialization error");
+ SCLogError("SIGUSR2 initialization error");
return EXIT_FAILURE;
}
#endif
/* Wait till all the threads have been initialized */
if (TmThreadWaitOnThreadInit() == TM_ECODE_FAILED) {
- FatalError(SC_ERR_FATAL, "Engine initialization failed, "
+ FatalError("Engine initialization failed, "
"aborting...");
}
#if defined(SC_ADDRESS_SANITIZER)
if (limit_nproc) {
- SCLogWarning(SC_ERR_SYSCONF,
+ SCLogWarning(
"\"security.limit-noproc\" (setrlimit()) not set when using address sanitizer");
limit_nproc = 0;
}
#if defined(HAVE_SYS_RESOURCE_H)
#ifdef linux
if (geteuid() == 0) {
- SCLogWarning(SC_ERR_SYSCONF, "setrlimit has no effet when running as root.");
+ SCLogWarning("setrlimit has no effet when running as root.");
}
#endif
struct rlimit r = { 0, 0 };
if (setrlimit(RLIMIT_NPROC, &r) != 0) {
- SCLogWarning(SC_ERR_SYSCONF, "setrlimit failed to prevent process creation.");
+ SCLogWarning("setrlimit failed to prevent process creation.");
}
#else
- SCLogWarning(SC_ERR_SYSCONF, "setrlimit unavailable.");
+ SCLogWarning("setrlimit unavailable.");
#endif
}
if (snprintf(conf_var_full_name, strlen(conf_var_type_name) + strlen(conf_var_name) + 2,
"%s.%s", conf_var_type_name, conf_var_name) < 0) {
- SCLogError(SC_EINVAL, "Error in making the conf full name");
+ SCLogError("Error in making the conf full name");
goto end;
}
if (ConfGet(conf_var_full_name, &conf_var_value) != 1) {
- SCLogError(SC_ERR_UNKNOWN_VALUE, "Error in getting conf value for conf name %s",
- conf_var_full_name);
+ SCLogError("Error in getting conf value for conf name %s", conf_var_full_name);
goto end;
}
{
if (id < 0 || id >= TMM_SIZE) {
- SCLogError(SC_ERR_TM_MODULES_ERROR, "Threading module with the id "
- "\"%d\" doesn't exist", id);
+ SCLogError("Threading module with the id "
+ "\"%d\" doesn't exist",
+ id);
return NULL;
}
if (t->RegisterTests == NULL) {
if (coverage_unittests)
- SCLogWarning(SC_WARN_NO_UNITTESTS, "threading module %s has no unittest "
- "registration function.", t->name);
+ SCLogWarning("threading module %s has no unittest "
+ "registration function.",
+ t->name);
} else {
t->RegisterTests();
g_ut_covered++;
{
Tmq *q = SCCalloc(1, sizeof(*q));
if (q == NULL)
- FatalError(SC_ENOMEM, "SCCalloc failed");
+ FatalError("SCCalloc failed");
q->name = SCStrdup(name);
if (q->name == NULL)
- FatalError(SC_ENOMEM, "SCStrdup failed");
+ FatalError("SCStrdup failed");
q->id = tmq_id++;
q->is_packet_pool = (strcmp(q->name, "packetpool") == 0);
if (!q->is_packet_pool) {
q->pq = PacketQueueAlloc();
if (q->pq == NULL)
- FatalError(SC_ENOMEM, "PacketQueueAlloc failed");
+ FatalError("PacketQueueAlloc failed");
}
TAILQ_INSERT_HEAD(&tmq_list, q, next);
TAILQ_FOREACH(tmq, &tmq_list, next) {
SCMutexLock(&tmq->pq->mutex_q);
if (tmq->reader_cnt == 0) {
- SCLogError(SC_ERR_THREAD_QUEUE, "queue \"%s\" doesn't have a reader (id %d max %u)",
- tmq->name, tmq->id, tmq_id);
+ SCLogError("queue \"%s\" doesn't have a reader (id %d max %u)", tmq->name, tmq->id,
+ tmq_id);
err = true;
} else if (tmq->writer_cnt == 0) {
- SCLogError(SC_ERR_THREAD_QUEUE, "queue \"%s\" doesn't have a writer (id %d, max %u)",
- tmq->name, tmq->id, tmq_id);
+ SCLogError("queue \"%s\" doesn't have a writer (id %d, max %u)", tmq->name, tmq->id,
+ tmq_id);
err = true;
}
SCMutexUnlock(&tmq->pq->mutex_q);
return;
error:
- FatalError(SC_ERR_FATAL, "fatal error during threading setup");
+ FatalError("fatal error during threading setup");
}
/* check if we are setup properly */
if (s == NULL || s->PktAcqLoop == NULL || tv->tmqh_in == NULL || tv->tmqh_out == NULL) {
- SCLogError(SC_ERR_FATAL, "TmSlot or ThreadVars badly setup: s=%p,"
- " PktAcqLoop=%p, tmqh_in=%p,"
- " tmqh_out=%p",
- s, s ? s->PktAcqLoop : NULL, tv->tmqh_in, tv->tmqh_out);
+ SCLogError("TmSlot or ThreadVars badly setup: s=%p,"
+ " PktAcqLoop=%p, tmqh_in=%p,"
+ " tmqh_out=%p",
+ s, s ? s->PktAcqLoop : NULL, tv->tmqh_in, tv->tmqh_out);
TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
pthread_exit((void *) -1);
return NULL;
} else if (slot->tm_id == TMM_FLOWWORKER) {
tv->stream_pq_local = SCCalloc(1, sizeof(PacketQueue));
if (tv->stream_pq_local == NULL)
- FatalError(SC_ENOMEM, "failed to alloc PacketQueue");
+ FatalError("failed to alloc PacketQueue");
SCMutexInit(&tv->stream_pq_local->mutex_q, NULL);
tv->stream_pq = tv->stream_pq_local;
tv->tm_flowworker = slot;
} else if (s->tm_id == TMM_FLOWWORKER) {
tv->stream_pq_local = SCCalloc(1, sizeof(PacketQueue));
if (tv->stream_pq_local == NULL)
- FatalError(SC_ENOMEM, "failed to alloc PacketQueue");
+ FatalError("failed to alloc PacketQueue");
SCMutexInit(&tv->stream_pq_local->mutex_q, NULL);
tv->stream_pq = tv->stream_pq_local;
tv->tm_flowworker = s;
#ifndef __CYGWIN__
#ifdef OS_WIN32
if (0 == SetThreadPriority(GetCurrentThread(), tv->thread_priority)) {
- SCLogError(SC_ERR_THREAD_NICE_PRIO, "Error setting priority for "
- "thread %s: %s", tv->name, strerror(errno));
+ SCLogError("Error setting priority for "
+ "thread %s: %s",
+ tv->name, strerror(errno));
} else {
SCLogDebug("Priority set to %"PRId32" for thread %s",
tv->thread_priority, tv->name);
#else
int ret = nice(tv->thread_priority);
if (ret == -1) {
- SCLogError(SC_ERR_THREAD_NICE_PRIO, "Error setting nice value %d "
- "for thread %s: %s", tv->thread_priority, tv->name,
- strerror(errno));
+ SCLogError("Error setting nice value %d "
+ "for thread %s: %s",
+ tv->thread_priority, tv->name, strerror(errno));
} else {
SCLogDebug("Nice value set to %"PRId32" for thread %s",
tv->thread_priority, tv->name);
return TM_ECODE_OK;
if (type > MAX_CPU_SET) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid cpu type family");
+ SCLogError("invalid cpu type family");
return TM_ECODE_FAILED;
}
int TmThreadGetNbThreads(uint8_t type)
{
if (type >= MAX_CPU_SET) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "invalid cpu type family");
+ SCLogError("invalid cpu type family");
return 0;
}
return tv;
error:
- SCLogError(SC_ERR_THREAD_CREATE, "failed to setup a thread");
+ SCLogError("failed to setup a thread");
if (tv != NULL)
SCFree(tv);
again:
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- SCLogWarning(SC_ERR_SHUTDOWN, "unable to get all packet threads "
- "to process their packets in time");
+ SCLogWarning("unable to get all packet threads "
+ "to process their packets in time");
return;
}
again:
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- FatalError(SC_ERR_FATAL, "Engine unable to disable detect "
- "thread - \"%s\". Killing engine", tv->name);
+ FatalError("Engine unable to disable detect "
+ "thread - \"%s\". Killing engine",
+ tv->name);
}
SCMutexLock(&tv_root_lock);
again:
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- FatalError(SC_ERR_FATAL, "Engine unable to disable packet "
- "threads. Killing engine");
+ FatalError("Engine unable to disable packet "
+ "threads. Killing engine");
}
/* loop through the packet threads and kill them */
thread_group_name = SCStrdup(name);
if (unlikely(thread_group_name == NULL)) {
- SCLogError(SC_ERR_RUNMODE, "error allocating memory");
+ SCLogError("error allocating memory");
return;
}
tv->thread_group_name = thread_group_name;
{
pthread_attr_t attr;
if (tv->tm_func == NULL) {
- FatalError(SC_ERR_TM_THREADS_ERROR, "No thread function set");
+ FatalError("No thread function set");
}
/* Initialize and set thread detached attribute */
if (threading_set_stack_size) {
SCLogDebug("Setting per-thread stack size to %" PRIu64, threading_set_stack_size);
if (pthread_attr_setstacksize(&attr, (size_t)threading_set_stack_size)) {
- FatalError(SC_ERR_TM_THREADS_ERROR,
- "Unable to increase stack size to %" PRIu64 " in thread attributes",
+ FatalError("Unable to increase stack size to %" PRIu64 " in thread attributes",
threading_set_stack_size);
}
}
int rc = pthread_create(&tv->t, &attr, tv->tm_func, (void *)tv);
if (rc) {
- FatalError(SC_ERR_THREAD_CREATE,
- "Unable to create thread with pthread_create() is %" PRId32, rc);
+ FatalError("Unable to create thread with pthread_create() is %" PRId32, rc);
}
#if DEBUG && HAVE_PTHREAD_GETATTR_NP
void TmThreadInitMC(ThreadVars *tv)
{
if ( (tv->ctrl_mutex = SCMalloc(sizeof(*tv->ctrl_mutex))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in TmThreadInitMC. "
+ FatalError("Fatal error encountered in TmThreadInitMC. "
"Exiting...");
}
}
if ( (tv->ctrl_cond = SCMalloc(sizeof(*tv->ctrl_cond))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in TmThreadInitMC. "
+ FatalError("Fatal error encountered in TmThreadInitMC. "
"Exiting...");
}
if (SCCtrlCondInit(tv->ctrl_cond, NULL) != 0) {
- FatalError(SC_ERR_FATAL, "Error initializing the tv->cond condition "
+ FatalError("Error initializing the tv->cond condition "
"variable");
}
if (TmThreadsCheckFlag(tv, (THV_FAILED | THV_CLOSED | THV_DEAD))) {
SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT,
- "thread \"%s\" failed to "
- "start: flags %04x",
+ SCLogError("thread \"%s\" failed to "
+ "start: flags %04x",
tv->name, SC_ATOMIC_GET(tv->flags));
return TM_ECODE_FAILED;
}
* THV_INIT_DONE to THV_RUNNING */
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 60) {
- SCLogError(SC_ERR_THREAD_INIT,
- "thread \"%s\" failed to "
- "start in time: flags %04x",
+ SCLogError("thread \"%s\" failed to "
+ "start in time: flags %04x",
tv->name, SC_ATOMIC_GET(tv->flags));
return TM_ECODE_FAILED;
}
ThreadVars *tv = tv_root[i];
while (tv) {
if (TmThreadsCheckFlag(tv, THV_FAILED)) {
- FatalError(SC_ERR_FATAL, "thread %s failed", tv->name);
+ FatalError("thread %s failed", tv->name);
}
tv = tv->next;
}
if (TmThreadsCheckFlag(tv, (THV_CLOSED|THV_DEAD))) {
SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
- "initialize: flags %04x", tv->name,
- SC_ATOMIC_GET(tv->flags));
+ SCLogError("thread \"%s\" failed to "
+ "initialize: flags %04x",
+ tv->name, SC_ATOMIC_GET(tv->flags));
return TM_ECODE_FAILED;
}
gettimeofday(&cur_ts, NULL);
if ((cur_ts.tv_sec - start_ts.tv_sec) > 120) {
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
- "initialize in time: flags %04x", tv->name,
- SC_ATOMIC_GET(tv->flags));
+ SCLogError("thread \"%s\" failed to "
+ "initialize in time: flags %04x",
+ tv->name, SC_ATOMIC_GET(tv->flags));
return TM_ECODE_FAILED;
}
if (TmThreadsCheckFlag(tv, THV_FAILED)) {
SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
- "initialize.", tv->name);
+ SCLogError("thread \"%s\" failed to "
+ "initialize.",
+ tv->name);
return TM_ECODE_FAILED;
}
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
SCMutexUnlock(&tv_root_lock);
- SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" closed on "
- "initialization.", tv->name);
+ SCLogError("thread \"%s\" closed on "
+ "initialization.",
+ tv->name);
return TM_ECODE_FAILED;
}
if (thread_max < 1)
thread_max = 1;
if (thread_max > 1024) {
- SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
+ SCLogWarning("limited number of 'worker' threads to 1024. Wanted %d", thread_max);
thread_max = 1024;
}
return (uint16_t)thread_max;
} else if (strcasecmp(scheduler, "ippair") == 0) {
tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowIPPair;
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry \"%s\" "
+ SCLogError("Invalid entry \"%s\" "
"for autofp-scheduler in conf. Killing engine.",
- scheduler);
+ scheduler);
exit(EXIT_FAILURE);
}
} else {
for (i = 0; i < max_pending_packets; i++) {
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered while allocating a packet. Exiting...");
+ FatalError("Fatal error encountered while allocating a packet. Exiting...");
}
PacketPoolStorePacket(p);
}
extern intmax_t max_pending_packets;
intmax_t pending_packets = max_pending_packets;
if (pending_packets < RESERVED_PACKETS) {
- FatalError(SC_ERR_INVALID_ARGUMENT, "'max-pending-packets' setting "
- "must be at least %d", RESERVED_PACKETS);
+ FatalError("'max-pending-packets' setting "
+ "must be at least %d",
+ RESERVED_PACKETS);
}
uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM);
if (threads == 0)
if (ret != 0) {
int err = errno;
if (err != EEXIST) {
- SCLogError(SC_ERR_INITIALIZATION,
- "Cannot create socket directory %s: %s",
- SOCKET_PATH, strerror(err));
+ SCLogError("Cannot create socket directory %s: %s", SOCKET_PATH, strerror(err));
return 0;
}
} else {
/* create socket */
this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (this->socket == -1) {
- SCLogWarning(SC_ERR_OPENING_FILE,
- "Unix Socket: unable to create UNIX socket %s: %s",
- addr.sun_path, strerror(errno));
+ SCLogWarning(
+ "Unix Socket: unable to create UNIX socket %s: %s", addr.sun_path, strerror(errno));
return 0;
}
this->select_max = this->socket + 1;
ret = setsockopt(this->socket, SOL_SOCKET, SO_REUSEADDR,
(char *) &on, sizeof(on));
if ( ret != 0 ) {
- SCLogWarning(SC_ERR_INITIALIZATION,
- "Cannot set sockets options: %s.", strerror(errno));
+ SCLogWarning("Cannot set sockets options: %s.", strerror(errno));
}
/* bind socket */
ret = bind(this->socket, (struct sockaddr *) &addr, len);
if (ret == -1) {
- SCLogWarning(SC_ERR_INITIALIZATION,
- "Unix socket: UNIX socket bind(%s) error: %s",
- sockettarget, strerror(errno));
+ SCLogWarning("Unix socket: UNIX socket bind(%s) error: %s", sockettarget, strerror(errno));
return 0;
}
ret = chmod(sockettarget, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
if (ret == -1) {
int err = errno;
- SCLogWarning(SC_ERR_INITIALIZATION,
- "Unable to change permission on socket: %s (%d)",
- strerror(err),
- err);
+ SCLogWarning("Unable to change permission on socket: %s (%d)", strerror(err), err);
}
#endif
/* listen */
if (listen(this->socket, 1) == -1) {
- SCLogWarning(SC_ERR_INITIALIZATION,
- "Command server: UNIX socket listen() error: %s",
- strerror(errno));
+ SCLogWarning("Command server: UNIX socket listen() error: %s", strerror(errno));
return 0;
}
return 1;
UnixClient *item;
if (this == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Unix command is NULL, warn devel");
+ SCLogError("Unix command is NULL, warn devel");
return;
}
{
UnixClient *uclient = SCMalloc(sizeof(UnixClient));
if (unlikely(uclient == NULL)) {
- SCLogError(SC_ENOMEM, "Can't allocate new client");
+ SCLogError("Can't allocate new client");
return NULL;
}
uclient->mbuf = MemBufferCreateNew(CLIENT_BUFFER_SIZE);
if (uclient->mbuf == NULL) {
- SCLogError(sc_errno, "Can't allocate new client send buffer");
+ SCLogError("Can't allocate new client send buffer");
SCFree(uclient);
return NULL;
}
}
if (found == 0) {
- SCLogError(SC_EINVAL, "No fd found in client list");
+ SCLogError("No fd found in client list");
return;
}
JSON_PRESERVE_ORDER|JSON_COMPACT|JSON_ENSURE_ASCII|
JSON_ESCAPE_SLASH);
if (r != 0) {
- SCLogWarning(SC_ERR_SOCKET, "unable to serialize JSON object");
+ SCLogWarning("unable to serialize JSON object");
return -1;
}
if (send(client->fd, (const char *)MEMBUFFER_BUFFER(client->mbuf),
MEMBUFFER_OFFSET(client->mbuf), MSG_NOSIGNAL) == -1)
{
- SCLogWarning(SC_ERR_SOCKET, "unable to send block of size "
- "%"PRIuMAX": %s", (uintmax_t)MEMBUFFER_OFFSET(client->mbuf),
- strerror(errno));
+ SCLogWarning("unable to send block of size "
+ "%" PRIuMAX ": %s",
+ (uintmax_t)MEMBUFFER_OFFSET(client->mbuf), strerror(errno));
return -1;
}
uclient->version = client_version;
if (UnixCommandSendJSONToClient(uclient, server_msg) != 0) {
- SCLogWarning(SC_ERR_SOCKET, "Unable to send command");
+ SCLogWarning("Unable to send command");
UnixClientFree(uclient);
json_decref(server_msg);
if (ret == 0) {
SCLogDebug("Unix socket: lost connection with client");
} else {
- SCLogError(SC_ERR_SOCKET, "Unix socket: error on recv() from client: %s",
- strerror(errno));
+ SCLogError("Unix socket: error on recv() from client: %s", strerror(errno));
}
UnixCommandClose(this, client->fd);
return;
}
if (ret >= (int)(sizeof(buffer)-1)) {
- SCLogError(SC_ERR_SOCKET, "Command server: client command is too long, "
- "disconnect him.");
+ SCLogError("Command server: client command is too long, "
+ "disconnect him.");
UnixCommandClose(this, client->fd);
}
buffer[ret] = 0;
if (ret == 0) {
SCLogDebug("Unix socket: lost connection with client");
} else {
- SCLogError(SC_ERR_SOCKET, "Unix socket: error on recv() from client: %s",
- strerror(errno));
+ SCLogError("Unix socket: error on recv() from client: %s", strerror(errno));
}
UnixCommandClose(this, client->fd);
return;
if (errno == EINTR) {
return 1;
}
- SCLogError(SC_ERR_SOCKET, "Command server: select() fatal error: %s", strerror(errno));
+ SCLogError("Command server: select() fatal error: %s", strerror(errno));
return 0;
}
Command *lcmd = NULL;
if (Func == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Null function");
+ SCLogError("Null function");
SCReturnInt(TM_ECODE_FAILED);
}
if (keyword == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Null keyword");
+ SCLogError("Null keyword");
SCReturnInt(TM_ECODE_FAILED);
}
TAILQ_FOREACH(lcmd, &command.commands, next) {
if (!strcmp(keyword, lcmd->name)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "%s already registered", keyword);
+ SCLogError("%s already registered", keyword);
SCReturnInt(TM_ECODE_FAILED);
}
}
cmd = SCMalloc(sizeof(Command));
if (unlikely(cmd == NULL)) {
- SCLogError(SC_ENOMEM, "Can't alloc cmd");
+ SCLogError("Can't alloc cmd");
SCReturnInt(TM_ECODE_FAILED);
}
cmd->name = SCStrdup(keyword);
if (unlikely(cmd->name == NULL)) {
- SCLogError(SC_ENOMEM, "Can't alloc cmd name");
+ SCLogError("Can't alloc cmd name");
SCFree(cmd);
SCReturnInt(TM_ECODE_FAILED);
}
Task *task = NULL;
if (Func == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Null function");
+ SCLogError("Null function");
SCReturnInt(TM_ECODE_FAILED);
}
task = SCMalloc(sizeof(Task));
if (unlikely(task == NULL)) {
- SCLogError(SC_ENOMEM, "Can't alloc task");
+ SCLogError("Can't alloc task");
SCReturnInt(TM_ECODE_FAILED);
}
task->Func = Func;
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
- FatalError(SC_ERR_FATAL,
- "Unable to create unix command socket");
+ FatalError("Unable to create unix command socket");
} else {
- SCLogWarning(SC_ERR_INITIALIZATION,
- "Unable to create unix command socket");
+ SCLogWarning("Unable to create unix command socket");
return -1;
}
}
while (1) {
ret = UnixMain(&command);
if (ret == 0) {
- SCLogError(SC_ERR_FATAL, "Fatal error on unix socket");
+ SCLogError("Fatal error on unix socket");
}
if ((ret == 0) || (TmThreadsCheckFlag(th_v, THV_KILL))) {
"UnixManager", 0);
if (tv_unixmgr == NULL) {
- FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
if (TmThreadSpawn(tv_unixmgr) != TM_ECODE_OK) {
- FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
if (mode == 1) {
if (TmThreadsCheckFlag(tv_unixmgr, THV_RUNNING_DONE)) {
- FatalError(SC_ERR_FATAL, "Unix socket init failed");
+ FatalError("Unix socket init failed");
}
}
return;
void UnixManagerThreadSpawn(int mode)
{
- SCLogError(SC_ERR_UNIMPLEMENTED, "Unix socket is not compiled");
+ SCLogError("Unix socket is not compiled");
return;
}
SCLogDebug("Loading action order : %s", action->val);
action_flag = ActionAsciiToFlag(action->val);
if (action_flag == 0) {
- SCLogError(SC_ERR_ACTION_ORDER, "action-order, invalid action: \"%s\". Please, use"
- " \"pass\",\"drop\",\"alert\",\"reject\". You have"
- " to specify all of them, without quotes and without"
- " capital letters", action->val);
+ SCLogError("action-order, invalid action: \"%s\". Please, use"
+ " \"pass\",\"drop\",\"alert\",\"reject\". You have"
+ " to specify all of them, without quotes and without"
+ " capital letters",
+ action->val);
goto error;
}
if (actions_used & action_flag) {
- SCLogError(SC_ERR_ACTION_ORDER, "action-order, action already set: \"%s\". Please,"
- " use \"pass\",\"drop\",\"alert\",\"reject\". You"
- " have to specify all of them, without quotes and"
- " without capital letters", action->val);
+ SCLogError("action-order, action already set: \"%s\". Please,"
+ " use \"pass\",\"drop\",\"alert\",\"reject\". You"
+ " have to specify all of them, without quotes and"
+ " without capital letters",
+ action->val);
goto error;
}
if (order >= 4) {
- SCLogError(SC_ERR_ACTION_ORDER, "action-order, you have already specified all the "
- "possible actions plus \"%s\". Please, use \"pass\","
- "\"drop\",\"alert\",\"reject\". You have to specify"
- " all of them, without quotes and without capital"
- " letters", action->val);
+ SCLogError("action-order, you have already specified all the "
+ "possible actions plus \"%s\". Please, use \"pass\","
+ "\"drop\",\"alert\",\"reject\". You have to specify"
+ " all of them, without quotes and without capital"
+ " letters",
+ action->val);
goto error;
}
actions_used |= action_flag;
}
}
if (order < 4) {
- SCLogError(SC_ERR_ACTION_ORDER, "action-order, the config didn't specify all of the "
- "actions. Please, use \"pass\",\"drop\",\"alert\","
- "\"reject\". You have to specify all of them, without"
- " quotes and without capital letters");
+ SCLogError("action-order, the config didn't specify all of the "
+ "actions. Please, use \"pass\",\"drop\",\"alert\","
+ "\"reject\". You have to specify all of them, without"
+ " quotes and without capital letters");
goto error;
}
char *end;
a = strtoul(lnode->val, &end, 10);
if (end != sep) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "%s: invalid cpu range (start invalid): \"%s\"",
- name,
- lnode->val);
+ SCLogError("%s: invalid cpu range (start invalid): \"%s\"", name, lnode->val);
exit(EXIT_FAILURE);
}
b = strtol(sep + 1, &end, 10);
if (end != sep + strlen(sep)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "%s: invalid cpu range (end invalid): \"%s\"",
- name,
- lnode->val);
+ SCLogError("%s: invalid cpu range (end invalid): \"%s\"", name, lnode->val);
exit(EXIT_FAILURE);
}
if (a > b) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "%s: invalid cpu range (bad order): \"%s\"",
- name,
- lnode->val);
+ SCLogError("%s: invalid cpu range (bad order): \"%s\"", name, lnode->val);
exit(EXIT_FAILURE);
}
if (b > max) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "%s: upper bound (%ld) of cpu set is too high, only %d cpu(s)",
- name,
- b, max + 1);
+ SCLogError("%s: upper bound (%ld) of cpu set is too high, only %d cpu(s)", name, b,
+ max + 1);
}
} else {
char *end;
a = strtoul(lnode->val, &end, 10);
if (end != lnode->val + strlen(lnode->val)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "%s: invalid cpu range (not an integer): \"%s\"",
- name,
- lnode->val);
+ SCLogError("%s: invalid cpu range (not an integer): \"%s\"", name, lnode->val);
exit(EXIT_FAILURE);
}
b = a;
ConfNode *nprio = NULL;
if (taf == NULL) {
- FatalError(SC_ERR_FATAL, "unknown cpu-affinity type");
+ FatalError("unknown cpu-affinity type");
} else {
SCLogConfig("Found affinity definition for \"%s\"", setname);
}
} else if (!strcmp(node->val, "high")) {
taf->prio = PRIO_HIGH;
} else {
- FatalError(SC_ERR_FATAL, "unknown cpu_affinity prio");
+ FatalError("unknown cpu_affinity prio");
}
SCLogConfig("Using default prio '%s' for set '%s'",
node->val, setname);
} else if (!strcmp(node->val, "balanced")) {
taf->mode_flag = BALANCED_AFFINITY;
} else {
- FatalError(SC_ERR_FATAL, "unknown cpu_affinity node");
+ FatalError("unknown cpu_affinity node");
}
}
node = ConfNodeLookupChild(affinity->head.tqh_first, "threads");
if (node != NULL) {
if (StringParseUint32(&taf->nb_threads, 10, 0, (const char *)node->val) < 0) {
- FatalError(SC_ERR_INVALID_ARGUMENT, "invalid value for threads "
- "count: '%s'", node->val);
+ FatalError("invalid value for threads "
+ "count: '%s'",
+ node->val);
}
if (! taf->nb_threads) {
- FatalError(SC_ERR_FATAL, "bad value for threads count");
+ FatalError("bad value for threads count");
}
}
}
}
}
if (iter == 2) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "cpu_set does not contain "
- "available cpus, cpu affinity conf is invalid");
+ SCLogError("cpu_set does not contain "
+ "available cpus, cpu affinity conf is invalid");
}
taf->lcpu = ncpu + 1;
if (taf->lcpu >= UtilCpuGetNumProcessorsOnline())
{
sc_errno = SC_OK;
if (size > MAX_LIMIT) {
- SCLogWarning(SC_EINVAL,
- "Mem buffer asked to create "
- "buffer with size greater than API limit - %d",
+ SCLogWarning("Mem buffer asked to create "
+ "buffer with size greater than API limit - %d",
MAX_LIMIT);
sc_errno = SC_EINVAL;
return NULL;
*/
int MemBufferExpand(MemBuffer **buffer, uint32_t expand_by) {
if (((*buffer)->size + expand_by) > MAX_LIMIT) {
- SCLogWarning(SC_ERR_MEM_BUFFER_API, "Mem buffer asked to create "
- "buffer with size greater than API limit - %d", MAX_LIMIT);
+ SCLogWarning("Mem buffer asked to create "
+ "buffer with size greater than API limit - %d",
+ MAX_LIMIT);
return -1;
}
return -1;
}
else if (strict && *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Extra characters following numeric value");
+ SCLogError("Extra characters following numeric value");
return -1;
}
*res = (uint32_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UINT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ i64, (uintmax_t)UINT_MAX);
return -1;
}
*res = (uint16_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)USHRT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ i64, (uintmax_t)USHRT_MAX);
return -1;
}
*res = (uint8_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UCHAR_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ i64, (uintmax_t)UCHAR_MAX);
return -1;
}
}
if ((uint64_t)(*res) != u64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", u64, (uintmax_t)UINT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ u64, (uintmax_t)UINT_MAX);
return -1;
}
}
if ((uint64_t)(*res) != u64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", u64, (uintmax_t)USHRT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ u64, (uintmax_t)USHRT_MAX);
return -1;
}
}
if ((uint64_t)(*res) != u64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIu64 " > %" PRIuMAX ")", u64, (uintmax_t)UCHAR_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")",
+ u64, (uintmax_t)UCHAR_MAX);
return -1;
}
char strbuf[24];
if (len > 23) {
- SCLogError(SC_ERR_ARG_LEN_LONG, "len too large (23 max)");
+ SCLogError("len too large (23 max)");
return -1;
}
*res = strtoll(ptr, &endptr, base);
if (errno == ERANGE) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
+ SCLogError("Numeric value out of range");
return -1;
} else if (endptr == str) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
+ SCLogError("Invalid numeric value");
return -1;
}
else if (strict && len && *endptr != '\0') {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Extra characters following numeric value");
+ SCLogError("Extra characters following numeric value");
return -1;
}
*res = (int32_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)INT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)INT_MAX);
return -1;
}
*res = (int16_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)SHRT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)SHRT_MAX);
return -1;
}
*res = (int8_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)CHAR_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)CHAR_MAX);
return -1;
}
*res = (int32_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)INT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)INT_MAX);
return -1;
}
*res = (int16_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)SHRT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)SHRT_MAX);
return -1;
}
*res = (int8_t)i64;
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)CHAR_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)CHAR_MAX);
return -1;
}
}
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)INT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)INT_MAX);
return -1;
}
}
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)SHRT_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)SHRT_MAX);
return -1;
}
}
if ((int64_t)(*res) != i64) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
- "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)CHAR_MAX);
+ SCLogError("Numeric value out of range "
+ "(%" PRIi64 " > %" PRIiMAX ")\n",
+ i64, (intmax_t)CHAR_MAX);
return -1;
}
if (regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogWarning(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogWarning("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
DETECT_CLASSCONFIG_REGEX, (int)eo, errbuffer);
return;
}
SCClassConfClasstypeHashCompareFunc,
SCClassConfClasstypeHashFree);
if (de_ctx->class_conf_ht == NULL) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "Error initializing the hash "
+ SCLogError("Error initializing the hash "
"table");
return NULL;
}
if (RunmodeIsUnittests())
return NULL; // silently fail
#endif
- SCLogWarning(SC_ERR_FOPEN, "could not open: \"%s\": %s",
- filename, strerror(errno));
+ SCLogWarning("could not open: \"%s\": %s", filename, strerror(errno));
return NULL;
}
}
char *temp_str = NULL;
if ( (new_str = SCStrdup(str)) == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
return NULL;
}
ret = pcre2_match(regex, (PCRE2_SPTR8)rawstr, strlen(rawstr), 0, 0, regex_match, NULL);
if (ret < 0) {
- SCLogError(SC_ERR_INVALID_SIGNATURE,
- "Invalid Classtype in "
- "classification.config file %s: \"%s\"",
+ SCLogError("Invalid Classtype in "
+ "classification.config file %s: \"%s\"",
SCClassConfGetConfFilename(de_ctx), rawstr);
goto error;
}
if (classtype_desc != NULL &&
(ct->classtype_desc = SCStrdup(classtype_desc)) == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
SCClassConfDeAllocClasstype(ct);
return NULL;
return false;
}
#endif
- SCLogError(SC_ERR_OPENING_FILE, "please check the \"classification-file\" "
- "option in your suricata.yaml file");
+ SCLogError("please check the \"classification-file\" "
+ "option in your suricata.yaml file");
return false;
}
bool ret = true;
if (!SCClassConfParseFile(de_ctx, fd)) {
- SCLogWarning(SC_WARN_CLASSIFICATION_CONFIG,
- "Error loading classification configuration from %s",
+ SCLogWarning("Error loading classification configuration from %s",
SCClassConfGetConfFilename(de_ctx));
ret = false;
}
}
if (value == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed value for unix-command.enabled: NULL");
+ SCLogError("malformed value for unix-command.enabled: NULL");
return 0;
}
return 1;
}
if (dump_size_config == NULL) {
- SCLogError (SC_ERR_INVALID_YAML_CONF_ENTRY, "malformed value for coredump.max-dump: NULL");
+ SCLogError("malformed value for coredump.max-dump: NULL");
return 0;
}
if (strcasecmp (dump_size_config, "unlimited") == 0) {
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_CONF);
if (nprocs < 1) {
- SCLogError(SC_ERR_SYSCALL, "Couldn't retrieve the number of cpus "
- "configured (%s)", strerror(errno));
+ SCLogError("Couldn't retrieve the number of cpus "
+ "configured (%s)",
+ strerror(errno));
return 0;
}
const char* envvar = getenv("NUMBER_OF_PROCESSORS");
if (envvar != NULL) {
if (StringParseInt64(&nprocs, 10, 0, envvar) < 0) {
- SCLogWarning(SC_EINVAL,
- "Invalid value for number of "
- "processors: %s",
+ SCLogWarning("Invalid value for number of "
+ "processors: %s",
envvar);
return 0;
}
}
if (nprocs < 1) {
- SCLogError(SC_ERR_SYSCALL, "Couldn't retrieve the number of cpus "
+ SCLogError("Couldn't retrieve the number of cpus "
"configured from the NUMBER_OF_PROCESSORS environment variable");
return 0;
}
return (uint16_t)nprocs;
#else
- SCLogError(SC_ERR_SYSCONF, "Couldn't retrieve the number of cpus "
+ SCLogError("Couldn't retrieve the number of cpus "
"configured, sysconf macro unavailable");
return 0;
#endif
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (nprocs < 1) {
- SCLogError(SC_ERR_SYSCALL, "Couldn't retrieve the number of cpus "
- "online (%s)", strerror(errno));
+ SCLogError("Couldn't retrieve the number of cpus "
+ "online (%s)",
+ strerror(errno));
return 0;
}
#elif OS_WIN32
return UtilCpuGetNumProcessorsConfigured();
#else
- SCLogError(SC_ERR_SYSCONF, "Couldn't retrieve the number of cpus online, "
+ SCLogError("Couldn't retrieve the number of cpus online, "
"synconf macro unavailable");
return 0;
#endif
long nprocs = -1;
nprocs = sysconf(_SC_NPROCESSORS_MAX);
if (nprocs < 1) {
- SCLogError(SC_ERR_SYSCALL, "Couldn't retrieve the maximum number of cpus "
- "allowed by the system (%s)", strerror(errno));
+ SCLogError("Couldn't retrieve the maximum number of cpus "
+ "allowed by the system (%s)",
+ strerror(errno));
return 0;
}
return (uint16_t)nprocs;
#else
- SCLogError(SC_ERR_SYSCONF, "Couldn't retrieve the maximum number of cpus allowed by "
+ SCLogError("Couldn't retrieve the maximum number of cpus allowed by "
"the system, synconf macro unavailable");
return 0;
#endif
if (waitpid(pid, &status, WNOHANG)) {
/* Check if the child is still there, otherwise the parent should exit */
if (WIFEXITED(status) || WIFSIGNALED(status)) {
- FatalError(SC_ERR_FATAL, "Child died unexpectedly");
+ FatalError("Child died unexpectedly");
}
}
/* sigsuspend(); */
if (pid < 0) {
/* Fork error */
- FatalError(SC_ERR_FATAL, "Error forking the process");
+ FatalError("Error forking the process");
} else if (pid == 0) {
/* Child continues here */
const char *daemondir;
sid = setsid();
if (sid < 0) {
- FatalError(SC_ERR_FATAL, "Error creating new session");
+ FatalError("Error creating new session");
}
if (ConfGet("daemon-directory", &daemondir) == 1) {
if ((chdir(daemondir)) < 0) {
- FatalError(SC_ERR_FATAL,
- "Error changing to working directory");
+ FatalError("Error changing to working directory");
}
}
#ifndef OS_WIN32
else {
if (chdir("/") < 0) {
- SCLogError(SC_ERR_DAEMON, "Error changing to working directory '/'");
+ SCLogError("Error changing to working directory '/'");
}
}
#endif
if (daemon) {
switch (mode) {
case RUNMODE_PCAP_FILE:
- SCLogError(SC_ERR_INVALID_RUNMODE, "ERROR: pcap offline mode cannot run as daemon");
+ SCLogError("ERROR: pcap offline mode cannot run as daemon");
return 0;
case RUNMODE_UNITTEST:
- SCLogError(SC_ERR_INVALID_RUNMODE, "ERROR: unittests cannot run as daemon");
+ SCLogError("ERROR: unittests cannot run as daemon");
return 0;
default:
SCLogDebug("Allowed mode");
SCLogFGFilterLine *fgf_line_temp = NULL;
if ( (fgf_file_temp = SCMalloc(sizeof(SCLogFGFilterFile))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
}
memset(fgf_file_temp, 0, sizeof(SCLogFGFilterFile));
}
if ( (fgf_func_temp = SCMalloc(sizeof(SCLogFGFilterFunc))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
}
memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
}
if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
}
memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
SCLogFGFilterLine *fgf_line_temp = NULL;
if ( (fgf_func_temp = SCMalloc(sizeof(SCLogFGFilterFunc))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
}
memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
}
if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
}
memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
SCLogFGFilterLine *fgf_line_temp = NULL;
if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
+ FatalError("Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
}
memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
/**
*/
static int SCLogMessageJSON(struct timeval *tval, char *buffer, size_t buffer_size,
- SCLogLevel log_level, const char *file,
- unsigned line, const char *function, SCError error_code,
+ SCLogLevel log_level, const char *file, unsigned line, const char *function,
const char *message)
{
json_t *js = json_object();
json_object_set_new(js, "event_type", json_string("engine"));
- if (error_code > 0) {
- json_object_set_new(ejs, "error_code", json_integer(error_code));
- json_object_set_new(ejs, "error", json_string(SCErrorToString(error_code)));
- }
-
if (message)
json_object_set_new(ejs, "message", json_string(message));
*
* \retval SC_OK on success; else an error code
*/
-static SCError SCLogMessageGetBuffer(
- struct timeval *tval, int color, SCLogOPType type,
- char *buffer, size_t buffer_size,
- const char *log_format,
-
- const SCLogLevel log_level, const char *file,
- const unsigned int line, const char *function,
- const SCError error_code, const char *message)
+static SCError SCLogMessageGetBuffer(struct timeval *tval, int color, SCLogOPType type,
+ char *buffer, size_t buffer_size, const char *log_format,
+
+ const SCLogLevel log_level, const char *file, const unsigned int line, const char *function,
+ const char *message)
{
if (type == SC_LOG_OP_TYPE_JSON)
- return SCLogMessageJSON(tval, buffer, buffer_size, log_level, file, line, function, error_code, message);
+ return SCLogMessageJSON(
+ tval, buffer, buffer_size, log_level, file, line, function, message);
char *temp = buffer;
const char *s = NULL;
return SC_OK;
}
- if (error_code != SC_OK) {
- cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - buffer),
- "[%sERRCODE%s: %s%s%s(%s%d%s)] - ", yellow, reset, red, SCErrorToString(error_code), reset, yellow, error_code, reset);
- if (cw < 0) {
- return SC_ERR_SPRINTF;
- }
- temp += cw;
- if ((temp - buffer) > SC_LOG_MAX_LOG_MSG_LEN) {
- return SC_OK;
- }
- }
-
const char *hi = "";
- if (error_code > SC_OK)
+ if (log_level <= SC_LOG_ERROR)
hi = red;
else if (log_level <= SC_LOG_NOTICE)
hi = yellow;
*
* \retval SC_OK on success; else an error code
*/
-SCError SCLogMessage(const SCLogLevel log_level, const char *file,
- const unsigned int line, const char *function,
- const SCError error_code, const char *message)
+SCError SCLogMessage(const SCLogLevel log_level, const char *file, const unsigned int line,
+ const char *function, const char *message)
{
char buffer[SC_LOG_MAX_LOG_MSG_LEN] = "";
SCLogOPIfaceCtx *op_iface_ctx = NULL;
switch (op_iface_ctx->iface) {
case SC_LOG_OP_IFACE_CONSOLE:
if (SCLogMessageGetBuffer(&tval, op_iface_ctx->use_color, op_iface_ctx->type,
- buffer, sizeof(buffer),
- op_iface_ctx->log_format ?
- op_iface_ctx->log_format : sc_log_config->log_format,
- log_level, file, line, function,
- error_code, message) == 0)
- {
+ buffer, sizeof(buffer),
+ op_iface_ctx->log_format ? op_iface_ctx->log_format
+ : sc_log_config->log_format,
+ log_level, file, line, function, message) == 0) {
SCLogPrintToStream((log_level == SC_LOG_ERROR)? stderr: stdout, buffer);
}
break;
case SC_LOG_OP_IFACE_FILE:
if (SCLogMessageGetBuffer(&tval, 0, op_iface_ctx->type, buffer, sizeof(buffer),
- op_iface_ctx->log_format ?
- op_iface_ctx->log_format : sc_log_config->log_format,
- log_level, file, line, function,
- error_code, message) == 0)
- {
+ op_iface_ctx->log_format ? op_iface_ctx->log_format
+ : sc_log_config->log_format,
+ log_level, file, line, function, message) == 0) {
int r = 0;
SCMutexLock(&op_iface_ctx->fp_mutex);
if (op_iface_ctx->rotation_flag) {
/* report error outside of lock to avoid recursion */
if (r == -1) {
- SCLogError(SC_ERR_FOPEN, "re-opening file \"%s\" failed: %s",
- op_iface_ctx->file, strerror(errno));
+ SCLogError("re-opening file \"%s\" failed: %s", op_iface_ctx->file,
+ strerror(errno));
}
}
break;
case SC_LOG_OP_IFACE_SYSLOG:
if (SCLogMessageGetBuffer(&tval, 0, op_iface_ctx->type, buffer, sizeof(buffer),
- op_iface_ctx->log_format ?
- op_iface_ctx->log_format : sc_log_config->log_format,
- log_level, file, line, function,
- error_code, message) == 0)
- {
+ op_iface_ctx->log_format ? op_iface_ctx->log_format
+ : sc_log_config->log_format,
+ log_level, file, line, function, message) == 0) {
SCLogPrintToSyslog(SCLogMapLogLevelToSyslogLevel(log_level), buffer);
}
break;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
- SCLogMessage(x, file, line, func, SC_OK, msg);
+ SCLogMessage(x, file, line, func, msg);
}
}
-void SCLogErr(int x, const char *file, const char *func, const int line,
- const int err, const char *fmt, ...)
+void SCLogErr(int x, const char *file, const char *func, const int line, const char *fmt, ...)
{
if (sc_log_global_log_level >= x &&
(sc_log_fg_filters_present == 0 ||
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
- SCLogMessage(x, file, line, func, err, msg);
+ SCLogMessage(x, file, line, func, msg);
}
}
if ( (buffer = SCMalloc(sc_log_config->op_ifaces_cnt *
sizeof(SCLogOPBuffer))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
+ FatalError("Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
}
SCLogOPIfaceCtx *op_iface_ctx = sc_log_config->op_ifaces;
SCLogOPIfaceCtx *iface_ctx = NULL;
if ( (iface_ctx = SCMalloc(sizeof(SCLogOPIfaceCtx))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
+ FatalError("Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
}
memset(iface_ctx, 0, sizeof(SCLogOPIfaceCtx));
{
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if (iface_ctx == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogInitFileOPIface. Exiting...");
+ FatalError("Fatal error encountered in SCLogInitFileOPIface. Exiting...");
}
if (file == NULL) {
#ifndef OS_WIN32
if (userid != 0 || groupid != 0) {
if (fchown(fileno(iface_ctx->file_d), userid, groupid) == -1) {
- SCLogWarning(SC_WARN_CHOWN, "Failed to change ownership of file %s: %s", file,
- strerror(errno));
+ SCLogWarning("Failed to change ownership of file %s: %s", file, strerror(errno));
}
}
#endif
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if (iface_ctx == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
+ FatalError("Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
}
iface_ctx->iface = SC_LOG_OP_IFACE_CONSOLE;
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if ( iface_ctx == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogInitSyslogOPIface. Exiting...");
+ FatalError("Fatal error encountered in SCLogInitSyslogOPIface. Exiting...");
}
iface_ctx->iface = SC_LOG_OP_IFACE_SYSLOG;
#if defined (OS_WIN32)
if (SCMutexInit(&sc_log_stream_lock, NULL) != 0) {
- FatalError(SC_ERR_FATAL, "Failed to initialize log mutex.");
+ FatalError("Failed to initialize log mutex.");
}
#endif /* OS_WIN32 */
/* sc_log_config is a global variable */
if ( (sc_log_config = SCMalloc(sizeof(SCLogConfig))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCLogInitLogModule. Exiting...");
+ FatalError("Fatal error encountered in SCLogInitLogModule. Exiting...");
}
memset(sc_log_config, 0, sizeof(SCLogConfig));
SCLogLevel default_log_level =
SCMapEnumNameToValue(default_log_level_s, sc_log_level_map);
if (default_log_level == -1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid default log level: %s",
- default_log_level_s);
+ SCLogError("Invalid default log level: %s", default_log_level_s);
exit(EXIT_FAILURE);
}
sc_lid->global_log_level = MAX(min_level, default_log_level);
if (level_s != NULL) {
level = SCMapEnumNameToValue(level_s, sc_log_level_map);
if (level == -1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid log level: %s",
- level_s);
+ SCLogError("Invalid log level: %s", level_s);
exit(EXIT_FAILURE);
}
max_level = MAX(max_level, level);
else if (strcmp(output->name, "file") == 0) {
const char *filename = ConfNodeLookupChildValue(output, "filename");
if (filename == NULL) {
- FatalError(SC_ERR_FATAL,
- "Logging to file requires a filename");
+ FatalError("Logging to file requires a filename");
}
char *path = NULL;
if (!(PathIsAbsolute(filename))) {
path = SCStrdup(filename);
}
if (path == NULL)
- FatalError(SC_ERR_FATAL, "failed to setup output to file");
+ FatalError("failed to setup output to file");
have_logging = 1;
op_iface_ctx = SCLogInitFileOPIface(path, userid, groupid, format, level, type);
SCFree(path);
if (facility_s != NULL) {
facility = SCMapEnumNameToValue(facility_s, SCSyslogGetFacilityMap());
if (facility == -1) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid syslog "
- "facility: \"%s\", now using \"%s\" as syslog "
- "facility", facility_s, SC_LOG_DEF_SYSLOG_FACILITY_STR);
+ SCLogWarning("Invalid syslog "
+ "facility: \"%s\", now using \"%s\" as syslog "
+ "facility",
+ facility_s, SC_LOG_DEF_SYSLOG_FACILITY_STR);
facility = SC_LOG_DEF_SYSLOG_FACILITY;
}
}
op_iface_ctx = SCLogInitSyslogOPIface(facility, format, level, type);
}
else {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT, "Invalid logging method: %s, "
- "ignoring", output->name);
+ SCLogWarning("Invalid logging method: %s, "
+ "ignoring",
+ output->name);
}
if (op_iface_ctx != NULL) {
SCLogAppendOPIfaceCtx(op_iface_ctx, sc_lid);
}
if (daemon && (have_logging == 0)) {
- SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
- "NO logging compatible with daemon mode selected,"
+ SCLogError("NO logging compatible with daemon mode selected,"
" suricata won't be able to log. Please update "
" 'logging.outputs' in the YAML.");
}
void SCLog(int x, const char *file, const char *func, const int line,
const char *fmt, ...) ATTR_FMT_PRINTF(5,6);
-void SCLogErr(int x, const char *file, const char *func, const int line,
- const int err, const char *fmt, ...) ATTR_FMT_PRINTF(6,7);
+void SCLogErr(int x, const char *file, const char *func, const int line, const char *fmt, ...)
+ ATTR_FMT_PRINTF(5, 6);
/**
* \brief Macro used to log INFORMATIONAL messages.
* warning message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogWarning(err_code, ...) SCLogErr(SC_LOG_WARNING, \
- __FILE__, __FUNCTION__, __LINE__, \
- err_code, __VA_ARGS__)
-#define SCLogWarningRaw(err_code, file, func, line, ...) \
- SCLogErr(SC_LOG_WARNING, (file), (func), (line), err_code, __VA_ARGS__)
+#define SCLogWarning(...) SCLogErr(SC_LOG_WARNING, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define SCLogWarningRaw(file, func, line, ...) \
+ SCLogErr(SC_LOG_WARNING, (file), (func), (line), __VA_ARGS__)
/**
* \brief Macro used to log ERROR messages.
* error message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, \
- __FILE__, __FUNCTION__, __LINE__, \
- err_code, __VA_ARGS__)
-#define SCLogErrorRaw(err_code, file, func, line, ...) SCLogErr(SC_LOG_ERROR, \
- (file), (func), (line), err_code, __VA_ARGS__)
+#define SCLogError(...) SCLogErr(SC_LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
+#define SCLogErrorRaw(file, func, line, ...) \
+ SCLogErr(SC_LOG_ERROR, (file), (func), (line), __VA_ARGS__)
/**
* \brief Macro used to log CRITICAL messages.
* critical message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogCritical(err_code, ...) SCLogErr(SC_LOG_CRITICAL, \
- __FILE__, __FUNCTION__, __LINE__, \
- err_code, __VA_ARGS__)
+#define SCLogCritical(...) SCLogErr(SC_LOG_CRITICAL, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
/**
* \brief Macro used to log ALERT messages.
*
* alert message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogAlert(err_code, ...) SCLogErr(SC_LOG_ALERT, \
- __FILE__, __FUNCTION__, __LINE__, \
- err_code, __VA_ARGS__)
+#define SCLogAlert(...) SCLogErr(SC_LOG_ALERT, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
/**
* \brief Macro used to log EMERGENCY messages.
*
* emergency message
* \retval ... Takes as argument(s), a printf style format message
*/
-#define SCLogEmerg(err_code, ...) SCLogErr(SC_LOG_EMERGENCY, \
- __FILE__, __FUNCTION__, __LINE__, \
- err_code, __VA_ARGS__)
-
+#define SCLogEmerg(...) SCLogErr(SC_LOG_EMERGENCY, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
/* Avoid the overhead of using the debugging subsystem, in production mode */
#ifndef DEBUG
#endif /* DEBUG */
-#define FatalError(x, ...) do { \
- SCLogError(x, __VA_ARGS__); \
- exit(EXIT_FAILURE); \
-} while(0)
+#define FatalError(...) \
+ do { \
+ SCLogError(__VA_ARGS__); \
+ exit(EXIT_FAILURE); \
+ } while (0)
/** \brief Fatal error IF we're starting up, and configured to consider
* errors to be fatal errors */
#if !defined(__clang_analyzer__)
-#define FatalErrorOnInit(x, ...) \
+#define FatalErrorOnInit(...) \
do { \
SC_ATOMIC_EXTERN(unsigned int, engine_stage); \
int init_errors_fatal = 0; \
(void)ConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \
if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT)) { \
- SCLogError(x, __VA_ARGS__); \
+ SCLogError(__VA_ARGS__); \
exit(EXIT_FAILURE); \
} \
- SCLogWarning(x, __VA_ARGS__); \
+ SCLogWarning(__VA_ARGS__); \
} while (0)
/* make it simpler for scan-build */
#else
-#define FatalErrorOnInit(x, ...) FatalError(x, __VA_ARGS__)
+#define FatalErrorOnInit(...) FatalError(__VA_ARGS__)
#endif
#define BOOL2STR(b) (b) ? "true" : "false"
void SCLogDeInitLogModule(void);
-SCError SCLogMessage(const SCLogLevel, const char *, const unsigned int,
- const char *, const SCError, const char *message);
+SCError SCLogMessage(
+ const SCLogLevel, const char *, const unsigned int, const char *, const char *message);
SCLogOPBuffer *SCLogAllocLogOPBuffer(void);
mime_dec_config.header_value_depth = MAX_HEADER_VALUE;
}
} else {
- SCLogWarning(SC_ERR_MISSING_CONFIG_PARAM, "Invalid null configuration parameters");
+ SCLogWarning("Invalid null configuration parameters");
}
}
sig->filename = SCStrdup(sig_file);
if (sig->filename == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
return 0;
}
sig->sig_str = SCStrdup(sig_str);
if (sig->sig_str == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
SCFree(sig->filename);
return 0;
}
if (sig_error) {
sig->sig_error = SCStrdup(sig_error);
if (sig->sig_error == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
SCFree(sig->filename);
SCFree(sig->sig_str);
return 0;
LiveDevice *pd;
if (name == NULL) {
- SCLogWarning(SC_EINVAL, "Name of device should not be null");
+ SCLogWarning("Name of device should not be null");
return NULL;
}
{
BypassInfo *bpinfo = SCCalloc(1, sizeof(*bpinfo));
if (bpinfo == NULL) {
- SCLogError(SC_ENOMEM, "Can't allocate bypass info structure");
+ SCLogError("Can't allocate bypass info structure");
return -1;
}
retval = rte_eth_dev_filter_supported(port_id, RTE_ETH_FILTER_HASH);
#pragma GCC diagnostic pop
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_CONF, "RTE_ETH_FILTER_HASH not supported on port: %s", port_name);
+ SCLogError("RTE_ETH_FILTER_HASH not supported on port: %s", port_name);
return retval;
}
#pragma GCC diagnostic pop
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Cannot set global hash configurations on port %s", port_name);
+ SCLogError("Cannot set global hash configurations on port %s", port_name);
return retval;
}
#pragma GCC diagnostic pop
if (ret < 0) {
- SCLogError(SC_ERR_DPDK_CONF, "RTE_ETH_FILTER_HASH not supported on port: %s", port_name);
+ SCLogError("RTE_ETH_FILTER_HASH not supported on port: %s", port_name);
return ret;
}
#pragma GCC diagnostic pop
if (ret < 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Cannot set symmetric hash enable per port on port %s",
- port_name);
+ SCLogError("Cannot set symmetric hash enable per port on port %s", port_name);
return ret;
}
rss_action_conf.key = NULL;
if (nb_rx_queues < 1) {
- FatalError(SC_ERR_DPDK_CONF, "The number of queues for RSS configuration must be "
- "configured with a positive number");
+ FatalError("The number of queues for RSS configuration must be "
+ "configured with a positive number");
}
rss_action_conf.queue_num = nb_rx_queues;
flow = rte_flow_create(port_id, &attr, pattern, action, &flow_error);
if (flow == NULL) {
- SCLogError(SC_ERR_DPDK_CONF, "Error when creating rte_flow rule on %s: %s", port_name,
- flow_error.message);
+ SCLogError("Error when creating rte_flow rule on %s: %s", port_name, flow_error.message);
int ret = rte_flow_validate(port_id, &attr, pattern, action, &flow_error);
- SCLogError(SC_ERR_DPDK_CONF, "Error on rte_flow validation for port %s: %s errmsg: %s",
- port_name, rte_strerror(-ret), flow_error.message);
+ SCLogError("Error on rte_flow validation for port %s: %s errmsg: %s", port_name,
+ rte_strerror(-ret), flow_error.message);
return ret;
} else {
SCLogInfo("RTE_FLOW queue region created for port %s", port_name);
flow = rte_flow_create(port_id, &attr, pattern, action, &flow_error);
if (flow == NULL) {
- SCLogError(SC_ERR_DPDK_CONF, "Error when creating rte_flow rule on %s: %s", port_name,
- flow_error.message);
+ SCLogError("Error when creating rte_flow rule on %s: %s", port_name, flow_error.message);
int ret = rte_flow_validate(port_id, &attr, pattern, action, &flow_error);
- SCLogError(SC_ERR_DPDK_CONF, "Error on rte_flow validation for port %s: %s errmsg: %s",
- port_name, rte_strerror(-ret), flow_error.message);
+ SCLogError("Error on rte_flow validation for port %s: %s errmsg: %s", port_name,
+ rte_strerror(-ret), flow_error.message);
return ret;
} else {
SCLogInfo("RTE_FLOW flow rule created for port %s", port_name);
retval = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_CONF, "Unable to get RSS hash configuration of port %s", port_name);
+ SCLogError("Unable to get RSS hash configuration of port %s", port_name);
return retval;
}
if (retval != 0) {
retval = rte_flow_flush(port_id, &flush_error);
if (retval != 0) {
- SCLogError(SC_ERR_DPDK_CONF,
- "Unable to flush rte_flow rules of %s: %s Flush error msg: %s", port_name,
+ SCLogError("Unable to flush rte_flow rules of %s: %s Flush error msg: %s", port_name,
rte_strerror(-retval), flush_error.message);
}
return retval;
retval = rte_eth_dev_get_name_by_port(port_id, port_name);
if (unlikely(retval != 0)) {
- SCLogError(SC_ERR_STAT, "Failed to convert port id %d to the interface name: %s", port_id,
+ SCLogError("Failed to convert port id %d to the interface name: %s", port_id,
strerror(-retval));
return retval;
}
if (run_mode == RUNMODE_DPDK) {
int retval = rte_eal_cleanup();
if (retval != 0)
- SCLogError(SC_ERR_DPDK_EAL_DEINIT, "EAL cleanup failed: %s", strerror(-retval));
+ SCLogError("EAL cleanup failed: %s", strerror(-retval));
}
#endif
}
if (run_mode == RUNMODE_DPDK) {
retval = rte_eth_dev_get_port_by_name(ldev->dev, &port_id);
if (retval < 0) {
- SCLogError(SC_ERR_DPDK_EAL_DEINIT, "Unable to get port id of \"%s\", error: %s",
- ldev->dev, rte_strerror(-retval));
+ SCLogError(
+ "Unable to get port id of \"%s\", error: %s", ldev->dev, rte_strerror(-retval));
return;
}
ret = unlink(pinnedpath);
if (ret == -1) {
int error = errno;
- SCLogWarning(SC_ERR_SYSCALL,
- "Unable to remove %s: %s (%d)",
- pinnedpath,
- strerror(error),
- error);
+ SCLogWarning(
+ "Unable to remove %s: %s (%d)", pinnedpath, strerror(error), error);
}
} else {
- SCLogWarning(SC_ERR_SPRINTF, "Unable to remove map %s",
- bpfinfo->array[i].name);
+ SCLogWarning("Unable to remove map %s", bpfinfo->array[i].name);
}
}
SCFree(bpfinfo->array[i].name);
{
int ret = bpf_map_delete_elem(fd, key);
if (ret < 0) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Unable to delete entry: %s (%d)",
- strerror(errno),
- errno);
+ SCLogWarning("Unable to delete entry: %s (%d)", strerror(errno), errno);
}
}
/* Get flow v6 table */
fd_v6 = EBPFLoadPinnedMapsFile(livedev, "flow_table_v6");
if (fd_v6 < 0) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Found a flow_table_v4 map but no flow_table_v6 map");
+ SCLogWarning("Found a flow_table_v4 map but no flow_table_v6 map");
return fd_v6;
}
}
struct bpf_maps_info *bpf_map_data = SCCalloc(1, sizeof(*bpf_map_data));
if (bpf_map_data == NULL) {
- SCLogError(SC_ENOMEM, "Can't allocate bpf map array");
+ SCLogError("Can't allocate bpf map array");
return -1;
}
SCFree(bpf_map_data->array[i].name);
}
bpf_map_data->last = 0;
- SCLogError(SC_ENOMEM, "Can't allocate bpf map name");
+ SCLogError("Can't allocate bpf map name");
return -1;
}
}
if (! path) {
- SCLogError(SC_EINVAL, "No file defined to load eBPF from");
+ SCLogError("No file defined to load eBPF from");
return -1;
}
* locked memory so we set it to unlimited to avoid a ENOPERM error */
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
if (setrlimit(RLIMIT_MEMLOCK, &r) != 0) {
- SCLogError(SC_ENOMEM, "Unable to lock memory: %s (%d)", strerror(errno), errno);
+ SCLogError("Unable to lock memory: %s (%d)", strerror(errno), errno);
return -1;
}
char err_buf[128];
libbpf_strerror(error, err_buf,
sizeof(err_buf));
- SCLogError(SC_EINVAL, "Unable to load eBPF objects in '%s': %s", path, err_buf);
+ SCLogError("Unable to load eBPF objects in '%s': %s", path, err_buf);
return -1;
}
}
if (found == false) {
- SCLogError(SC_EINVAL, "No section '%s' in '%s' file. Will not be able to use the file",
- section, path);
+ SCLogError("No section '%s' in '%s' file. Will not be able to use the file", section, path);
return -1;
}
err = bpf_object__load(bpfobj);
if (err < 0) {
if (err == -EPERM) {
- SCLogError(SC_ERR_SYSCALL,
- "Permission issue when loading eBPF object"
- " (check libbpf error on stdout)");
+ SCLogError("Permission issue when loading eBPF object"
+ " (check libbpf error on stdout)");
} else {
char buf[129];
libbpf_strerror(err, buf, sizeof(buf));
- SCLogError(SC_EINVAL, "Unable to load eBPF object: %s (%d)", buf, err);
+ SCLogError("Unable to load eBPF object: %s (%d)", buf, err);
}
return -1;
}
* that we use bpf_maps_info:: */
struct bpf_maps_info *bpf_map_data = SCCalloc(1, sizeof(*bpf_map_data));
if (bpf_map_data == NULL) {
- SCLogError(SC_ENOMEM, "Can't allocate bpf map array");
+ SCLogError("Can't allocate bpf map array");
return -1;
}
/* Store the maps in bpf_maps_info:: */
bpf_map__for_each(map, bpfobj) {
if (bpf_map_data->last == BPF_MAP_MAX_COUNT) {
- SCLogError(SC_ERR_NOT_SUPPORTED, "Too many BPF maps in eBPF files");
+ SCLogError("Too many BPF maps in eBPF files");
break;
}
SCLogDebug("Got a map '%s' with fd '%d'", bpf_map__name(map), bpf_map__fd(map));
snprintf(bpf_map_data->array[bpf_map_data->last].iface, IFNAMSIZ,
"%s", iface);
if (!bpf_map_data->array[bpf_map_data->last].name) {
- SCLogError(SC_ENOMEM, "Unable to duplicate map name");
+ SCLogError("Unable to duplicate map name");
BpfMapsInfoFree(bpf_map_data);
return -1;
}
bpf_map_data->array[bpf_map_data->last].name);
int ret = bpf_obj_pin(bpf_map_data->array[bpf_map_data->last].fd, buf);
if (ret != 0) {
- SCLogWarning(SC_ERR_AFP_CREATE, "Can not pin: %s", strerror(errno));
+ SCLogWarning("Can not pin: %s", strerror(errno));
}
/* Don't unlink pinned maps in XDP mode to avoid a state reset */
if (config->flags & EBPF_XDP_CODE) {
* (XDP case). */
pfd = bpf_program__fd(bpfprog);
if (pfd == -1) {
- SCLogError(SC_EINVAL, "Unable to find %s section", section);
+ SCLogError("Unable to find %s section", section);
return -1;
}
#ifdef HAVE_PACKET_XDP
unsigned int ifindex = if_nametoindex(iface);
if (ifindex == 0) {
- SCLogError(SC_EINVAL, "Unknown interface '%s'", iface);
+ SCLogError("Unknown interface '%s'", iface);
return -1;
}
#ifdef HAVE_BPF_XDP_ATTACH
if (err != 0) {
char buf[129];
libbpf_strerror(err, buf, sizeof(buf));
- SCLogError(SC_EINVAL, "Unable to set XDP on '%s': %s (%d)", iface, buf, err);
+ SCLogError("Unable to set XDP on '%s': %s (%d)", iface, buf, err);
return -1;
}
#endif
uint64_t hash_cnt = 0;
if (tcfg->cpus_count == 0) {
- SCLogWarning(SC_EINVAL, "CPU count should not be 0");
+ SCLogWarning("CPU count should not be 0");
return 0;
}
int ret;
if (cpumap < 0) {
- SCLogError(SC_ERR_AFP_CREATE, "Can't find cpu_map");
+ SCLogError("Can't find cpu_map");
return -1;
}
ret = bpf_map_update_elem(cpumap, &i, &queue_size, 0);
if (ret) {
- SCLogError(SC_ERR_AFP_CREATE, "Create CPU entry failed (err:%d)", ret);
+ SCLogError("Create CPU entry failed (err:%d)", ret);
return -1;
}
int cpus_available = EBPFGetMapFDByName(iface, "cpus_available");
if (cpus_available < 0) {
- SCLogError(SC_ERR_AFP_CREATE, "Can't find cpus_available map");
+ SCLogError("Can't find cpus_available map");
return -1;
}
ret = bpf_map_update_elem(cpus_available, &g_redirect_iface_cpu_counter, &i, 0);
if (ret) {
- SCLogError(SC_ERR_AFP_CREATE, "Create CPU entry failed (err:%d)", ret);
+ SCLogError("Create CPU entry failed (err:%d)", ret);
return -1;
}
return 0;
static void EBPFRedirectMapAddCPU(int i, void *data)
{
if (EBPFAddCPUToMap(data, i) < 0) {
- SCLogError(SC_EINVAL, "Unable to add CPU %d to set", i);
+ SCLogError("Unable to add CPU %d to set", i);
} else {
g_redirect_iface_cpu_counter++;
}
uint32_t key0 = 0;
int mapfd = EBPFGetMapFDByName(iface, "cpus_count");
if (mapfd < 0) {
- SCLogError(SC_EINVAL, "Unable to find 'cpus_count' map");
+ SCLogError("Unable to find 'cpus_count' map");
return;
}
g_redirect_iface_cpu_counter = 0;
{
int mapfd = EBPFGetMapFDByName(iface, "tx_peer");
if (mapfd < 0) {
- SCLogError(SC_EINVAL, "Unable to find 'tx_peer' map");
+ SCLogError("Unable to find 'tx_peer' map");
return -1;
}
int intmapfd = EBPFGetMapFDByName(iface, "tx_peer_int");
if (intmapfd < 0) {
- SCLogError(SC_EINVAL, "Unable to find 'tx_peer_int' map");
+ SCLogError("Unable to find 'tx_peer_int' map");
return -1;
}
int key0 = 0;
unsigned int peer_index = if_nametoindex(out_iface);
if (peer_index == 0) {
- SCLogError(SC_EINVAL, "No iface '%s'", out_iface);
+ SCLogError("No iface '%s'", out_iface);
return -1;
}
int ret = bpf_map_update_elem(mapfd, &key0, &peer_index, BPF_ANY);
if (ret) {
- SCLogError(SC_ERR_AFP_CREATE, "Create peer entry failed (err:%d)", ret);
+ SCLogError("Create peer entry failed (err:%d)", ret);
return -1;
}
ret = bpf_map_update_elem(intmapfd, &key0, &peer_index, BPF_ANY);
if (ret) {
- SCLogError(SC_ERR_AFP_CREATE, "Create peer entry failed (err:%d)", ret);
+ SCLogError("Create peer entry failed (err:%d)", ret);
return -1;
}
return 0;
policy = EXCEPTION_POLICY_IGNORE;
SCLogConfig("%s: %s", option, value_str);
} else {
- FatalErrorOnInit(SC_ERR_INVALID_ARGUMENT,
+ FatalErrorOnInit(
"\"%s\" is not a valid exception policy value. Valid options are drop-flow, "
"pass-flow, bypass, drop-packet, pass-packet or ignore.",
value_str);
if (!support_flow) {
if (policy == EXCEPTION_POLICY_DROP_FLOW || policy == EXCEPTION_POLICY_PASS_FLOW ||
policy == EXCEPTION_POLICY_BYPASS_FLOW) {
- SCLogWarning(SC_WARN_COMPATIBILITY,
- "flow actions not supported for %s, defaulting to \"ignore\"", option);
+ SCLogWarning("flow actions not supported for %s, defaulting to \"ignore\"", option);
policy = EXCEPTION_POLICY_IGNORE;
}
}
/* legacy option */
const char *force_md5 = ConfNodeLookupChildValue(conf, "force-md5");
if (force_md5 != NULL) {
- SCLogWarning(SC_ERR_DEPRECATED_CONF, "deprecated 'force-md5' option "
- "found. Please use 'force-hash: [md5]' instead");
+ SCLogWarning("deprecated 'force-md5' option "
+ "found. Please use 'force-hash: [md5]' instead");
if (ConfValIsTrue(force_md5)) {
if (g_disable_hashing) {
{
FileContainer *new = SCMalloc(sizeof(FileContainer));
if (unlikely(new == NULL)) {
- SCLogError(SC_ENOMEM, "Error allocating mem");
+ SCLogError("Error allocating mem");
return NULL;
}
memset(new, 0, sizeof(FileContainer));
{
File *new = SCMalloc(sizeof(File));
if (unlikely(new == NULL)) {
- SCLogError(SC_ENOMEM, "Error allocating mem");
+ SCLogError("Error allocating mem");
return NULL;
}
memset(new, 0, sizeof(File));
hb->next = NULL;
if (hash >= ht->array_size) {
- SCLogWarning(SC_EINVAL, "attempt to insert element out of hash array\n");
+ SCLogWarning("attempt to insert element out of hash array\n");
goto error;
}
hash = ht->Hash(ht, data, datalen);
if (hash >= ht->array_size) {
- SCLogWarning(SC_EINVAL, "attempt to access element out of hash array\n");
+ SCLogWarning("attempt to access element out of hash array\n");
return NULL;
}
/* get local version */
if (uname(&kuname) != 0) {
- SCLogError(SC_EINVAL, "Invalid uname return: %s", strerror(errno));
+ SCLogError("Invalid uname return: %s", strerror(errno));
return 0;
}
if (version_regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
VERSION_REGEX, (int)eo, errbuffer);
goto error;
}
version_regex_match, NULL);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_MATCH, "Version did not cut");
+ SCLogError("Version did not cut");
goto error;
}
if (ret < 3) {
- SCLogError(SC_ERR_PCRE_MATCH, "Version major and minor not found (ret %d)", ret);
+ SCLogError("Version major and minor not found (ret %d)", ret);
goto error;
}
bool err = false;
if (StringParseInt32(&kmajor, 10, 0, (const char *)list[1]) < 0) {
- SCLogError(SC_EINVAL, "Invalid value for kmajor: '%s'", list[1]);
+ SCLogError("Invalid value for kmajor: '%s'", list[1]);
err = true;
}
if (StringParseInt32(&kminor, 10, 0, (const char *)list[2]) < 0) {
- SCLogError(SC_EINVAL, "Invalid value for kminor: '%s'", list[2]);
+ SCLogError("Invalid value for kminor: '%s'", list[2]);
err = true;
}
int SCKernelVersionIsAtLeast(int major, int minor)
{
- SCLogError(SC_ERR_NOT_SUPPORTED, "OS compare is not supported on Windows");
+ SCLogError("OS compare is not supported on Windows");
return 0;
}
int *user_data = NULL;
if ( (user_data = SCMalloc(sizeof(int))) == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
+ FatalError("Error allocating memory. Exiting");
}
/* the host os flavour that has to be sent as user data */
if ( (*user_data = SCMapEnumNameToValue(host_os, sc_hinfo_os_policy_map)) == -1) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "Invalid enum map inside "
+ SCLogError("Invalid enum map inside "
"SCHInfoAddHostOSInfo()");
SCFree(user_data);
return NULL;
if (host_os == NULL || host_os_ip_range == NULL ||
strlen(host_os_ip_range) == 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid arguments");
+ SCLogError("Invalid arguments");
return -1;
}
/* the host os flavour that has to be sent as user data */
if ( (user_data = SCHInfoAllocUserDataOSPolicy(host_os)) == NULL) {
- SCLogError(SC_ERR_INVALID_ENUM_MAP, "Invalid enum map inside");
+ SCLogError("Invalid enum map inside");
return -1;
}
}
if ( (ip_str = SCStrdup(host_os_ip_range)) == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
/* check if we have more addresses in the host_os_ip_range */
if (strchr(ip_str, ':') == NULL) {
/* if we are here, we have an IPV4 address */
if ( (ipv4_addr = ValidateIPV4Address(ip_str)) == NULL) {
- SCLogError(SC_ERR_INVALID_IPV4_ADDR, "Invalid IPV4 address");
+ SCLogError("Invalid IPV4 address");
SCHInfoFreeUserDataOSPolicy(user_data);
SCFree(ip_str);
return -1;
} else {
if (StringParseU8RangeCheck(&netmask_value, 10, 0, (const char *)netmask_str, 0, 32) <
0) {
- SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV4 Netblock");
+ SCLogError("Invalid IPV4 Netblock");
SCHInfoFreeUserDataOSPolicy(user_data);
SCFree(ipv4_addr);
SCFree(ip_str);
} else {
/* if we are here, we have an IPV6 address */
if ( (ipv6_addr = ValidateIPV6Address(ip_str)) == NULL) {
- SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
+ SCLogError("Invalid IPV6 address inside");
SCHInfoFreeUserDataOSPolicy(user_data);
SCFree(ip_str);
return -1;
} else {
if (StringParseU8RangeCheck(&netmask_value, 10, 0, (const char *)netmask_str, 0, 128) <
0) {
- SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV6 Netblock");
+ SCLogError("Invalid IPV6 Netblock");
SCHInfoFreeUserDataOSPolicy(user_data);
SCFree(ipv6_addr);
SCFree(ip_str);
if (strchr(ip_addr_str, ':') != NULL) {
if ( (ipv6_addr = ValidateIPV6Address(ip_addr_str)) == NULL) {
- SCLogError(SC_ERR_INVALID_IPV4_ADDR, "Invalid IPV4 address");
+ SCLogError("Invalid IPV4 address");
return -1;
}
return *((int *)user_data);
} else {
if ( (ipv4_addr = ValidateIPV4Address(ip_addr_str)) == NULL) {
- SCLogError(SC_ERR_INVALID_IPV4_ADDR, "Invalid IPV4 address");
+ SCLogError("Invalid IPV4 address");
return -1;
}
if (host->val != NULL && strchr(host->val, ':') != NULL)
is_ipv4 = 0;
if (SCHInfoAddHostOSInfo(policy->name, host->val, is_ipv4) == -1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to add host \"%s\" with policy \"%s\" to host "
- "info database", host->val, policy->name);
+ SCLogError("Failed to add host \"%s\" with policy \"%s\" to host "
+ "info database",
+ host->val, policy->name);
exit(EXIT_FAILURE);
}
}
}
if (ioctl(fd, SIOCGIFMTU, (char *)&ifr) < 0) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to get MTU via ioctl for '%s': %s (%d)",
- pcap_dev, strerror(errno), errno);
+ SCLogWarning("Failure when trying to get MTU via ioctl for '%s': %s (%d)", pcap_dev,
+ strerror(errno), errno);
close(fd);
return -1;
}
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) {
- SCLogError(SC_ERR_SYSCALL,
- "Unable to get flags for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to get flags for iface \"%s\": %s", ifname, strerror(errno));
close(fd);
return -1;
}
#endif
if (ioctl(fd, SIOCSIFFLAGS, &ifr) == -1) {
- SCLogError(SC_ERR_SYSCALL,
- "Unable to set flags for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to set flags for iface \"%s\": %s", ifname, strerror(errno));
close(fd);
return -1;
}
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFCAP, &ifr) == -1) {
- SCLogError(SC_ERR_SYSCALL,
- "Unable to get caps for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to get caps for iface \"%s\": %s", ifname, strerror(errno));
close(fd);
return -1;
}
ifr.ifr_reqcap = caps;
if (ioctl(fd, SIOCSIFCAP, &ifr) == -1) {
- SCLogError(SC_ERR_SYSCALL,
- "Unable to set caps for iface \"%s\": %s",
- ifname, strerror(errno));
+ SCLogError("Unable to set caps for iface \"%s\": %s", ifname, strerror(errno));
close(fd);
return -1;
}
ethv.cmd = cmd;
ifr.ifr_data = (void *) ðv;
if (ioctl(fd, SIOCETHTOOL, (char *)&ifr) < 0) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to get feature via ioctl for '%s': %s (%d)",
- dev, strerror(errno), errno);
+ SCLogWarning("Failure when trying to get feature via ioctl for '%s': %s (%d)", dev,
+ strerror(errno), errno);
close(fd);
return -1;
}
ethv.data = value;
ifr.ifr_data = (void *) ðv;
if (ioctl(fd, SIOCETHTOOL, (char *)&ifr) < 0) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to set feature via ioctl for '%s': %s (%d)",
- dev, strerror(errno), errno);
+ SCLogWarning("Failure when trying to set feature via ioctl for '%s': %s (%d)", dev,
+ strerror(errno), errno);
close(fd);
return -1;
}
if (csum_ret == 0)
SCLogPerf("NIC offloading on %s: RX %s TX %s", dev, rx, tx);
else {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "NIC offloading on %s: RX %s TX %s. Run: "
- "ethtool -K %s rx off tx off", dev, rx, tx, dev);
+ SCLogWarning("NIC offloading on %s: RX %s TX %s. Run: "
+ "ethtool -K %s rx off tx off",
+ dev, rx, tx, dev);
ret = 1;
}
}
SCLogPerf("NIC offloading on %s: SG: %s, GRO: %s, LRO: %s, "
"TSO: %s, GSO: %s", dev, sg, gro, lro, tso, gso);
} else {
- SCLogWarning(SC_ERR_NIC_OFFLOADING, "NIC offloading on %s: SG: %s, "
- " GRO: %s, LRO: %s, TSO: %s, GSO: %s. Run: "
- "ethtool -K %s sg off gro off lro off tso off gso off",
+ SCLogWarning("NIC offloading on %s: SG: %s, "
+ " GRO: %s, LRO: %s, TSO: %s, GSO: %s. Run: "
+ "ethtool -K %s sg off gro off lro off tso off gso off",
dev, sg, gro, lro, tso, gso, dev);
ret = 1;
}
SCLogDebug("if_caps %X", if_caps);
if (if_caps & IFCAP_RXCSUM) {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "Using %s with RXCSUM activated can lead to capture "
- "problems. Run: ifconfig %s -rxcsum", ifname, ifname);
+ SCLogWarning("Using %s with RXCSUM activated can lead to capture "
+ "problems. Run: ifconfig %s -rxcsum",
+ ifname, ifname);
ret = 1;
}
#ifdef IFCAP_TOE
if (if_caps & (IFCAP_TSO|IFCAP_TOE|IFCAP_LRO)) {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "Using %s with TSO, TOE or LRO activated can lead to "
- "capture problems. Run: ifconfig %s -tso -toe -lro",
+ SCLogWarning("Using %s with TSO, TOE or LRO activated can lead to "
+ "capture problems. Run: ifconfig %s -tso -toe -lro",
ifname, ifname);
ret = 1;
}
#else
if (if_caps & (IFCAP_TSO|IFCAP_LRO)) {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "Using %s with TSO or LRO activated can lead to "
- "capture problems. Run: ifconfig %s -tso -lro",
+ SCLogWarning("Using %s with TSO or LRO activated can lead to "
+ "capture problems. Run: ifconfig %s -tso -lro",
ifname, ifname);
ret = 1;
}
(void)strlcpy(ifr.ifr_name, pcap_dev, sizeof(ifr.ifr_name));
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when opening socket for ioctl: %s (%d)",
- strerror(errno), errno);
+ SCLogWarning("Failure when opening socket for ioctl: %s (%d)", strerror(errno), errno);
return -1;
}
if (ioctl(fd, SIOCETHTOOL, (char *)&ifr) < 0) {
if (errno != ENOTSUP) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to get number of RSS queue ioctl for '%s': %s (%d)",
- pcap_dev, strerror(errno), errno);
+ SCLogWarning("Failure when trying to get number of RSS queue ioctl for '%s': %s (%d)",
+ pcap_dev, strerror(errno), errno);
}
close(fd);
return 0;
return NULL;
if ( (addr = SCMalloc(sizeof(struct in_addr))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in ValidateIPV4Address. Exiting...");
+ FatalError("Fatal error encountered in ValidateIPV4Address. Exiting...");
}
if (inet_pton(AF_INET, addr_str, addr) <= 0) {
return NULL;
if ( (addr = SCMalloc(sizeof(struct in6_addr))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in ValidateIPV6Address. Exiting...");
+ FatalError("Fatal error encountered in ValidateIPV6Address. Exiting...");
}
if (inet_pton(AF_INET6, addr_str, addr) <= 0) {
buffer->size *= 2;
char *tmp = SCRealloc(buffer->data, buffer->size);
if (tmp == NULL) {
- SCLogError(SC_ENOMEM, "Error resizing JA3 buffer");
+ SCLogError("Error resizing JA3 buffer");
return -1;
}
buffer->data = tmp;
int Ja3BufferAppendBuffer(JA3Buffer **buffer1, JA3Buffer **buffer2)
{
if (*buffer1 == NULL || *buffer2 == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Buffers should not be NULL");
+ SCLogError("Buffers should not be NULL");
return -1;
}
int Ja3BufferAddValue(JA3Buffer **buffer, uint32_t value)
{
if (*buffer == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Buffer should not be NULL");
+ SCLogError("Buffer should not be NULL");
return -1;
}
if ((*buffer)->data == NULL) {
(*buffer)->data = SCMalloc(JA3_BUFFER_INITIAL_SIZE);
if ((*buffer)->data == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory for JA3 data");
+ SCLogError("Error allocating memory for JA3 data");
Ja3BufferFree(buffer);
return -1;
}
char *Ja3GenerateHash(JA3Buffer *buffer)
{
if (buffer == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Buffer should not be NULL");
+ SCLogError("Buffer should not be NULL");
return NULL;
}
if (buffer->data == NULL) {
- SCLogError(SC_EINVAL, "Buffer data should not be NULL");
+ SCLogError("Buffer data should not be NULL");
return NULL;
}
char *ja3_hash = SCMalloc(SC_MD5_HEX_LEN + 1);
if (ja3_hash == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating memory for JA3 hash");
+ SCLogError("Error allocating memory for JA3 hash");
return NULL;
}
bool is_enabled = SSLJA3IsEnabled();
if (is_enabled == 0) {
if (strcmp(type, "rule") != 0) {
- SCLogWarning(SC_WARN_JA3_DISABLED, "JA3 is disabled, skipping %s",
- type);
+ SCLogWarning("JA3 is disabled, skipping %s", type);
}
return 1;
}
{
struct landlock_ruleset *ruleset = SCCalloc(1, sizeof(struct landlock_ruleset));
if (ruleset == NULL) {
- SCLogError(SC_ENOMEM, "Can't alloc landlock ruleset");
+ SCLogError("Can't alloc landlock ruleset");
return NULL;
}
}
if (abi < 2) {
if (RequiresFeature(FEATURE_OUTPUT_FILESTORE)) {
- SCLogError(SC_ERR_NOT_SUPPORTED,
- "Landlock disabled: need Linux 5.19+ for file store support");
+ SCLogError("Landlock disabled: need Linux 5.19+ for file store support");
SCFree(ruleset);
return NULL;
} else {
ruleset->fd = landlock_create_ruleset(&ruleset->attr, sizeof(ruleset->attr), 0);
if (ruleset->fd < 0) {
SCFree(ruleset);
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Can't create landlock ruleset");
+ SCLogError("Can't create landlock ruleset");
return NULL;
}
return ruleset;
static inline void LandlockEnforceRuleset(struct landlock_ruleset *ruleset)
{
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1) {
- SCLogError(
- SC_ERR_CONF_YAML_ERROR, "Can't self restrict (prctl phase): %s", strerror(errno));
+ SCLogError("Can't self restrict (prctl phase): %s", strerror(errno));
return;
}
if (landlock_restrict_self(ruleset->fd, 0)) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Can't self restrict (landlock phase): %s",
- strerror(errno));
+ SCLogError("Can't self restrict (landlock phase): %s", strerror(errno));
}
}
int dir_fd = open(directory, O_PATH | O_CLOEXEC | O_DIRECTORY);
if (dir_fd == -1) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Can't open %s", directory);
+ SCLogError("Can't open %s", directory);
return -1;
}
path_beneath.parent_fd = dir_fd;
if (landlock_add_rule(ruleset->fd, LANDLOCK_RULE_PATH_BENEATH, &path_beneath, 0)) {
- SCLogError(SC_ERR_CONF_YAML_ERROR, "Can't add write rule: %s", strerror(errno));
+ SCLogError("Can't add write rule: %s", strerror(errno));
close(dir_fd);
return -1;
}
}
struct landlock_ruleset *ruleset = LandlockCreateRuleset();
if (ruleset == NULL) {
- SCLogError(SC_ERR_NOT_SUPPORTED, "Kernel does not support Landlock");
+ SCLogError("Kernel does not support Landlock");
return;
}
LandlockSandboxingReadPath(ruleset, dirname(file_name));
}
} else {
- SCLogError(SC_ERR_OPENING_FILE, "Can't open pcap file");
+ SCLogError("Can't open pcap file");
}
SCFree(file_name);
}
ConfNode *read_dirs = ConfGetNode("security.landlock.directories.read");
if (read_dirs) {
if (!ConfNodeIsSequence(read_dirs)) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Invalid security.landlock.directories.read configuration section: "
- "expected a list of directory names.");
+ SCLogWarning("Invalid security.landlock.directories.read configuration section: "
+ "expected a list of directory names.");
} else {
ConfNode *directory;
TAILQ_FOREACH (directory, &read_dirs->head, next) {
ConfNode *write_dirs = ConfGetNode("security.landlock.directories.write");
if (write_dirs) {
if (!ConfNodeIsSequence(write_dirs)) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Invalid security.landlock.directories.write configuration section: "
- "expected a list of directory names.");
+ SCLogWarning("Invalid security.landlock.directories.write configuration section: "
+ "expected a list of directory names.");
} else {
ConfNode *directory;
TAILQ_FOREACH (directory, &write_dirs->head, next) {
{
SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
if (ctx == NULL) {
- FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
+ FatalError("Unable to allocate redis context");
}
ctx->sync = NULL;
#if HAVE_LIBEVENT
{
SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
if (unlikely(ctx == NULL)) {
- FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
+ FatalError("Unable to allocate redis context");
}
ctx->sync = NULL;
} else {
ctx->connected = 0;
if (ctx->tried == 0) {
- SCLogWarning(SC_ERR_SOCKET, "Failed to connect to Redis... (will keep trying)");
+ SCLogWarning("Failed to connect to Redis... (will keep trying)");
}
ctx->tried = time(NULL);
}
}
if (ctx->async == NULL) {
- SCLogError(SC_ENOMEM, "Error allocate redis async.");
+ SCLogError("Error allocate redis async.");
ctx->tried = time(NULL);
return -1;
}
if (ctx->async != NULL && ctx->async->err) {
- SCLogError(SC_ERR_SOCKET, "Error setting to redis async: [%s].", ctx->async->errstr);
+ SCLogError("Error setting to redis async: [%s].", ctx->async->errstr);
ctx->tried = time(NULL);
return -1;
}
ctx->sync = redisConnectUnix(redis_server);
}
if (ctx->sync == NULL) {
- SCLogError(SC_ERR_SOCKET, "Error connecting to redis server.");
+ SCLogError("Error connecting to redis server.");
ctx->tried = time(NULL);
return -1;
}
if (ctx->sync->err) {
- SCLogError(SC_ERR_SOCKET, "Error connecting to redis server: [%s].", ctx->sync->errstr);
+ SCLogError("Error connecting to redis server: [%s].", ctx->sync->errstr);
redisFree(ctx->sync);
ctx->sync = NULL;
ctx->tried = time(NULL);
}
break;
default:
- SCLogWarning(SC_EINVAL, "Unsupported error code %d", redis->err);
+ SCLogWarning("Unsupported error code %d", redis->err);
return -1;
}
}
if (reply) {
switch (reply->type) {
case REDIS_REPLY_ERROR:
- SCLogWarning(SC_ERR_SOCKET, "Redis error: %s", reply->str);
+ SCLogWarning("Redis error: %s", reply->str);
SCConfLogReopenSyncRedis(file_ctx);
break;
case REDIS_REPLY_INTEGER:
ret = 0;
break;
default:
- SCLogError(SC_EINVAL, "Redis default triggered with %d", reply->type);
+ SCLogError("Redis default triggered with %d", reply->type);
SCConfLogReopenSyncRedis(file_ctx);
break;
}
LogFileCtx *log_ctx = lf_ctx;
if (log_ctx->threaded) {
- FatalError(SC_ERR_FATAL, "redis does not support threaded output");
+ FatalError("redis does not support threaded output");
}
const char *redis_port = NULL;
#ifndef HAVE_LIBEVENT
if (is_async) {
- SCLogWarning(SC_ERR_NO_REDIS_ASYNC, "async option not available.");
+ SCLogWarning("async option not available.");
}
is_async = 0;
#endif //ifndef HAVE_LIBEVENT
} else if(!strcmp(redis_mode,"channel") || !strcmp(redis_mode,"publish")) {
log_ctx->redis_setup.command = redis_publish_cmd;
} else {
- FatalError(SC_ERR_FATAL, "Invalid redis mode");
+ FatalError("Invalid redis mode");
}
/* store server params for reconnection */
if (!log_ctx->redis_setup.server) {
- FatalError(SC_ERR_FATAL, "Error allocating redis server string");
+ FatalError("Error allocating redis server string");
}
if (StringParseUint16(&log_ctx->redis_setup.port, 10, 0, (const char *)redis_port) < 0) {
- FatalError(SC_EINVAL, "Invalid value for redis port: %s", redis_port);
+ FatalError("Invalid value for redis port: %s", redis_port);
}
log_ctx->Close = SCLogFileCloseRedis;
err:
if (log_err)
- SCLogWarning(SC_ERR_SOCKET,
- "Error connecting to socket \"%s\": %s (will keep trying)",
- path, strerror(errno));
+ SCLogWarning(
+ "Error connecting to socket \"%s\": %s (will keep trying)", path, strerror(errno));
if (s >= 0)
close(s);
{
int disconnected = 0;
if (log_ctx->fp) {
- SCLogWarning(SC_ERR_SOCKET,
- "Write error on Unix socket \"%s\": %s; reconnecting...",
- log_ctx->filename, strerror(errno));
+ SCLogWarning("Write error on Unix socket \"%s\": %s; reconnecting...", log_ctx->filename,
+ strerror(errno));
fclose(log_ctx->fp);
log_ctx->fp = NULL;
log_ctx->reconn_timer = 0;
/* Connected at last (or reconnected) */
SCLogNotice("Reconnected socket \"%s\"", log_ctx->filename);
} else if (disconnected) {
- SCLogWarning(SC_ERR_SOCKET, "Reconnect failed: %s (will keep trying)",
- strerror(errno));
+ SCLogWarning("Reconnect failed: %s (will keep trying)", strerror(errno));
}
return log_ctx->fp ? 1 : 0;
if (1 != SCFwriteUnlocked(buffer, buffer_len, 1, log_ctx->fp)) {
/* Only the first error is logged */
if (!log_ctx->output_errors) {
- SCLogError(SC_ERR_LOG_OUTPUT, "%s error while writing to %s",
+ SCLogError("%s error while writing to %s",
SCFerrorUnlocked(log_ctx->fp) ? strerror(errno) : "unknown error",
log_ctx->filename);
}
if (1 != fwrite(buffer, buffer_len, 1, log_ctx->fp)) {
/* Only the first error is logged */
if (!log_ctx->output_errors) {
- SCLogError(SC_ERR_LOG_OUTPUT, "%s error while writing to %s",
+ SCLogError("%s error while writing to %s",
ferror(log_ctx->fp) ? strerror(errno) : "unknown error",
log_ctx->filename);
}
fclose(log_ctx->fp);
if (log_ctx->output_errors) {
- SCLogError(SC_ERR_LOG_OUTPUT, "There were %" PRIu64 " output errors to %s",
- log_ctx->output_errors, log_ctx->filename);
+ SCLogError("There were %" PRIu64 " output errors to %s", log_ctx->output_errors,
+ log_ctx->filename);
}
}
{
parent_ctx->threads = SCCalloc(1, sizeof(LogThreadedFileCtx));
if (!parent_ctx->threads) {
- SCLogError(SC_ENOMEM, "Unable to allocate threads container");
+ SCLogError("Unable to allocate threads container");
return false;
}
parent_ctx->threads->append = SCStrdup(append == NULL ? DEFAULT_LOG_MODE_APPEND : append);
if (!parent_ctx->threads->append) {
- SCLogError(SC_ENOMEM, "Unable to allocate threads append setting");
+ SCLogError("Unable to allocate threads append setting");
goto error_exit;
}
parent_ctx->threads->slot_count = slot_count;
parent_ctx->threads->lf_slots = SCCalloc(slot_count, sizeof(LogFileCtx *));
if (!parent_ctx->threads->lf_slots) {
- SCLogError(SC_ENOMEM, "Unable to allocate thread slots");
+ SCLogError("Unable to allocate thread slots");
goto error_exit;
}
SCLogDebug("Allocated %d file context pointers for threaded array",
}
if (ret == NULL) {
- SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s",
- filename, strerror(errno));
+ SCLogError("Error opening file: \"%s\": %s", filename, strerror(errno));
} else {
if (mode != 0) {
#ifdef OS_WIN32
int r = fchmod(fileno(ret), (mode_t)mode);
#endif
if (r < 0) {
- SCLogWarning(SC_WARN_CHMOD, "Could not chmod %s to %o: %s",
- filename, mode, strerror(errno));
+ SCLogWarning("Could not chmod %s to %o: %s", filename, mode, strerror(errno));
}
}
}
// Arg check
if (conf == NULL || log_ctx == NULL || default_filename == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "SCConfLogOpenGeneric(conf %p, ctx %p, default %p) "
+ SCLogError("SCConfLogOpenGeneric(conf %p, ctx %p, default %p) "
"missing an argument",
- conf, log_ctx, default_filename);
+ conf, log_ctx, default_filename);
return -1;
}
if (log_ctx->fp != NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "SCConfLogOpenGeneric: previously initialized Log CTX "
+ SCLogError("SCConfLogOpenGeneric: previously initialized Log CTX "
"encountered");
return -1;
}
else {
log_ctx->rotate_interval = SCParseTimeSizeString(rotate_int);
if (log_ctx->rotate_interval == 0) {
- FatalError(SC_ERR_FATAL,
- "invalid rotate-interval value");
+ FatalError("invalid rotate-interval value");
}
log_ctx->rotate_time = now + log_ctx->rotate_interval;
}
#ifdef BUILD_WITH_UNIXSOCKET
if (log_ctx->threaded) {
if (strcasecmp(filetype, "unix_stream") == 0 || strcasecmp(filetype, "unix_dgram") == 0) {
- FatalError(SC_ERR_FATAL, "Socket file types do not support threaded output");
+ FatalError("Socket file types do not support threaded output");
}
}
#endif
OutputRegisterFileRotationFlag(&log_ctx->rotation_flag);
}
} else {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "Invalid entry for "
+ SCLogError("Invalid entry for "
"%s.filetype. Expected \"regular\" (default), \"unix_stream\", "
"or \"unix_dgram\"",
- conf->name);
+ conf->name);
}
log_ctx->filename = SCStrdup(log_path);
if (unlikely(log_ctx->filename == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to allocate memory for filename");
+ SCLogError("Failed to allocate memory for filename");
return -1;
}
}
if (log_ctx->filename == NULL) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENT,
- "Can't re-open LogFileCtx without a filename.");
+ SCLogWarning("Can't re-open LogFileCtx without a filename.");
return -1;
}
if (new_array == NULL) {
SCMutexUnlock(&parent_ctx->threads->mutex);
- SCLogError(SC_ENOMEM, "Unable to increase file context array size to %d", new_size);
+ SCLogError("Unable to increase file context array size to %d", new_size);
return NULL;
}
const char *base = SCBasename(original_name);
if (!base) {
- FatalError(SC_ERR_FATAL,
- "Invalid filename for threaded mode \"%s\"; "
- "no basename found.",
+ FatalError("Invalid filename for threaded mode \"%s\"; "
+ "no basename found.",
original_name);
}
if (strlen(tname) && strlen(ext)) {
snprintf(threaded_name, len, "%s.%u.%s", tname, unique_id, ext);
} else {
- FatalError(SC_ERR_FATAL,
- "Invalid filename for threaded mode \"%s\"; "
- "filenames must include an extension, e.g: \"name.ext\"",
+ FatalError("Invalid filename for threaded mode \"%s\"; "
+ "filenames must include an extension, e.g: \"name.ext\"",
original_name);
}
SCFree(tname);
{
LogFileCtx *thread = SCCalloc(1, sizeof(LogFileCtx));
if (!thread) {
- SCLogError(SC_ENOMEM, "Unable to allocate thread file context slot %d", thread_id);
+ SCLogError("Unable to allocate thread file context slot %d", thread_id);
return false;
}
if (parent_ctx->type == LOGFILE_TYPE_FILE) {
char fname[LOGFILE_NAME_MAX];
if (!LogFileThreadedName(log_path, fname, sizeof(fname), SC_ATOMIC_ADD(eve_file_id, 1))) {
- SCLogError(sc_errno, "Unable to create threaded filename for log");
+ SCLogError("Unable to create threaded filename for log");
goto error;
}
SCLogDebug("Thread open -- using name %s [replaces %s]", fname, log_path);
}
thread->filename = SCStrdup(fname);
if (!thread->filename) {
- SCLogError(SC_ENOMEM, "Unable to duplicate filename for context slot %d", thread_id);
+ SCLogError("Unable to duplicate filename for context slot %d", thread_id);
goto error;
}
thread->is_regular = true;
lua_getstack(luastate, 1, &ar);
lua_getinfo(luastate, "nSl", &ar);
const char *funcname = ar.name ? ar.name : ar.what;
- SCLogWarningRaw(SC_WARN_LUA_SCRIPT, ar.short_src, funcname, ar.currentline, "%s", msg);
+ SCLogWarningRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}
lua_getstack(luastate, 1, &ar);
lua_getinfo(luastate, "nSl", &ar);
const char *funcname = ar.name ? ar.name : ar.what;
- SCLogErrorRaw(SC_ERR_LUA_SCRIPT, ar.short_src, funcname, ar.currentline, "%s", msg);
+ SCLogErrorRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
return 0;
}
luajit_states = PoolInit(0, cnt, 0, LuaStatePoolAlloc, NULL, NULL, NULL, LuaStatePoolFree);
if (luajit_states == NULL) {
- SCLogError(SC_ERR_LUA_ERROR, "luastate pool init failed, lua/luajit keywords won't work");
+ SCLogError("luastate pool init failed, lua/luajit keywords won't work");
retval = -1;
}
s = (lua_State *)PoolGet(luajit_states);
if (s != NULL) {
if (luajit_states_cnt == luajit_states_size) {
- SCLogWarning(SC_WARN_LUA_SCRIPT,
- "luajit states pool size %d "
- "reached. Increase luajit.states config option. "
- "See tickets #1577 and #1955",
+ SCLogWarning("luajit states pool size %d "
+ "reached. Increase luajit.states config option. "
+ "See tickets #1577 and #1955",
luajit_states_size);
}
}
ms = SCCalloc(1, sizeof(*ms));
if (unlikely(ms == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to allocate MacSet memory");
+ SCLogError("Unable to allocate MacSet memory");
return NULL;
}
(void) SC_ATOMIC_ADD(flow_memuse, (sizeof(*ms)));
}
ms->buf[side] = SCCalloc(ms->size, sizeof(MacAddr));
if (unlikely(ms->buf[side] == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to allocate "
- "MacSet memory");
+ SCLogError("Unable to allocate "
+ "MacSet memory");
return;
}
(void) SC_ATOMIC_ADD(flow_memuse, (ms->size * sizeof(MacAddr)));
ctx = magic_open(0);
if (ctx == NULL) {
- SCLogError(SC_ERR_MAGIC_OPEN, "magic_open failed: %s",
- magic_error(ctx));
+ SCLogError("magic_open failed: %s", magic_error(ctx));
goto error;
}
SCLogConfig("using magic-file %s", filename);
if ( (fd = fopen(filename, "r")) == NULL) {
- SCLogWarning(SC_ERR_FOPEN, "Error opening file: \"%s\": %s",
- filename, strerror(errno));
+ SCLogWarning("Error opening file: \"%s\": %s", filename, strerror(errno));
goto error;
}
fclose(fd);
}
if (magic_load(ctx, filename) != 0) {
- SCLogError(SC_ERR_MAGIC_LOAD, "magic_load failed: %s",
- magic_error(ctx));
+ SCLogError("magic_load failed: %s", magic_error(ctx));
goto error;
}
return ctx;
if (result != NULL) {
magic = SCStrdup(result);
if (unlikely(magic == NULL)) {
- SCLogError(SC_ENOMEM, "Unable to dup magic");
+ SCLogError("Unable to dup magic");
}
}
}
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
uintmax_t scmalloc_size_ = (uintmax_t)sz;
- SCLogError(SC_ENOMEM,
- "SCMalloc failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes",
+ SCLogError("SCMalloc failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes",
strerror(errno), scmalloc_size_);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
return ptrmem;
void *ptrmem = realloc(ptr, size);
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
- SCLogError(SC_ENOMEM,
- "SCRealloc failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes",
+ SCLogError("SCRealloc failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes",
strerror(errno), (uintmax_t)size);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
return ptrmem;
void *ptrmem = calloc(nm, sz);
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
- SCLogError(SC_ENOMEM,
- "SCCalloc failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes",
+ SCLogError("SCCalloc failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes",
strerror(errno), (uintmax_t)nm * sz);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
return ptrmem;
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
size_t _scstrdup_len = strlen(s);
- SCLogError(SC_ENOMEM,
- "SCStrdup failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes",
+ SCLogError("SCStrdup failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes",
strerror(errno), (uintmax_t)_scstrdup_len);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
return ptrmem;
#endif
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
- SCLogError(SC_ENOMEM,
- "SCStrndup failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes",
+ SCLogError("SCStrndup failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes",
strerror(errno), (uintmax_t)(n + 1));
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
return ptrmem;
void *ptrmem = _mm_malloc(size, align);
if (unlikely(ptrmem == NULL)) {
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
- SCLogError(SC_ENOMEM,
- "SCMallocAligned(posix_memalign) failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
+ SCLogError("SCMallocAligned(posix_memalign) failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
strerror(errno), (uintmax_t)size, (uintmax_t)align);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
#else
ptrmem = NULL;
}
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
- SCLogError(SC_ENOMEM,
- "SCMallocAligned(posix_memalign) failed: %s, while trying "
- "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
+ SCLogError("SCMallocAligned(posix_memalign) failed: %s, while trying "
+ "to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
strerror(errno), (uintmax_t)size, (uintmax_t)align);
- FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
+ FatalError("Out of memory. The engine cannot be initialized. Exiting...");
}
}
#endif
if (parse_regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
PARSE_REGEX, (int)eo, errbuffer);
exit(EXIT_FAILURE);
}
*res = 0;
if (size == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS,"invalid size argument - NULL. Valid size "
+ SCLogError("invalid size argument - NULL. Valid size "
"argument should be in the format - \n"
"xxx <- indicates it is just bytes\n"
"xxxkb or xxxKb or xxxKB or xxxkB <- indicates kilobytes\n"
"xxxmb or xxxMb or xxxMB or xxxmB <- indicates megabytes\n"
- "xxxgb or xxxGb or xxxGB or xxxgB <- indicates gigabytes.\n"
- );
+ "xxxgb or xxxGb or xxxGB or xxxgB <- indicates gigabytes.\n");
retval = -2;
goto end;
}
parse_regex, (PCRE2_SPTR8)size, strlen(size), 0, 0, parse_regex_match, NULL);
if (!(pcre2_match_ret == 2 || pcre2_match_ret == 3)) {
- SCLogError(SC_ERR_PCRE_MATCH, "invalid size argument - %s. Valid size "
+ SCLogError("invalid size argument - %s. Valid size "
"argument should be in the format - \n"
"xxx <- indicates it is just bytes\n"
"xxxkb or xxxKb or xxxKB or xxxkB <- indicates kilobytes\n"
"xxxmb or xxxMb or xxxMB or xxxmB <- indicates megabytes\n"
"xxxgb or xxxGb or xxxGB or xxxgB <- indicates gigabytes.\n",
- size);
+ size);
retval = -2;
goto end;
}
size_t copylen = sizeof(str);
r = pcre2_substring_copy_bynumber(parse_regex_match, 1, (PCRE2_UCHAR8 *)str, ©len);
if (r < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
retval = -2;
goto end;
}
errno = 0;
*res = strtod(str_ptr, &endptr);
if (errno == ERANGE) {
- SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range");
+ SCLogError("Numeric value out of range");
retval = -1;
goto end;
} else if (endptr == str_ptr) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE, "Invalid numeric value");
+ SCLogError("Invalid numeric value");
retval = -1;
goto end;
}
r = pcre2_substring_copy_bynumber(parse_regex_match, 2, (PCRE2_UCHAR8 *)str2, ©len);
if (r < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
retval = -2;
goto end;
}
etc.
* \param value Default value to be printed.
*/
-#define WarnInvalidConfEntry(param_name, format, value) do { \
- SCLogWarning(SC_ERR_INVALID_YAML_CONF_ENTRY, \
- "Invalid conf entry found for " \
- "\"%s\". Using default value of \"" format "\".", \
- param_name, value); \
+#define WarnInvalidConfEntry(param_name, format, value) \
+ do { \
+ SCLogWarning("Invalid conf entry found for " \
+ "\"%s\". Using default value of \"" format "\".", \
+ param_name, value); \
} while (0)
/* size string parsing API */
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->output_table = ptmp;
if (ptmp == NULL) {
SCFree(output_state->pids);
output_state->pids = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
output_state->pids = ptmp;
q->top = 0;
if (q->top == q->bot) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "Just ran out of space in the queue. "
+ SCLogCritical("Just ran out of space in the queue. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
q->bot = 0;
if (q->bot == q->top) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "StateQueue behaving weirdly. "
+ SCLogCritical("StateQueue behaving weirdly. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
if (ptmp == NULL) {
SCFree(output_dst_state->pids);
output_dst_state->pids = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
else {
output_dst_state->pids = ptmp;
* every state(SCACBSCtx->state_count) */
ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
if (ctx->failure_table == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
ctx->state_table_u16 = SCMalloc(ctx->state_count *
sizeof(SC_AC_BS_STATE_TYPE_U16) * 256);
if (ctx->state_table_u16 == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_u16, 0,
ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U16) * 256);
ctx->state_table_u32 = SCMalloc(ctx->state_count *
sizeof(SC_AC_BS_STATE_TYPE_U32) * 256);
if (ctx->state_table_u32 == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_u32, 0,
ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U32) * 256);
256 * sizeof(SC_AC_BS_STATE_TYPE_U16) * 1);
ctx->state_table_mod = SCMalloc(size);
if (ctx->state_table_mod == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_mod, 0, size);
* directly to access its state data */
ctx->state_table_mod_pointers = SCMalloc(ctx->state_count * sizeof(uint8_t *));
if (ctx->state_table_mod_pointers == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_mod_pointers, 0,
ctx->state_count * sizeof(uint8_t *));
256 * sizeof(SC_AC_BS_STATE_TYPE_U32) * 1);
ctx->state_table_mod = SCMalloc(size);
if (ctx->state_table_mod == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_mod, 0, size);
* directly to access its state data */
ctx->state_table_mod_pointers = SCMalloc(ctx->state_count * sizeof(uint8_t *));
if (ctx->state_table_mod_pointers == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_mod_pointers, 0,
ctx->state_count * sizeof(uint8_t *));
/* handle no case patterns */
ctx->pid_pat_list = SCMalloc((mpm_ctx->max_pat_id + 1)* sizeof(SCACBSPatternList));
if (ctx->pid_pat_list == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->pid_pat_list, 0, (mpm_ctx->max_pat_id + 1) * sizeof(SCACBSPatternList));
if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len);
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->output_table = ptmp;
}
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(output_state->patterns);
output_state->patterns = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
output_state->patterns = ptmp;
q->top = 0;
if (q->top == q->bot) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "Just ran out of space in the queue. "
+ SCLogCritical("Just ran out of space in the queue. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
q->bot = 0;
if (q->bot == q->top) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "StateQueue behaving weirdly. "
+ SCLogCritical("StateQueue behaving weirdly. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
if (ptmp == NULL) {
SCFree(output_dst_state->patterns);
output_dst_state->patterns = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
output_dst_state->patterns = ptmp;
* every state(SCACTileCtx->state_count) */
ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
if (ctx->failure_table == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
uint8_t encoded_next_state = (uint8_t)next_state;
if (next_state == SC_AC_TILE_FAIL) {
- FatalError(SC_ERR_FATAL, "Error FAIL state in output");
+ FatalError("Error FAIL state in output");
}
if (outputs == 0)
uint16_t encoded_next_state = (uint16_t)next_state;
if (next_state == SC_AC_TILE_FAIL) {
- FatalError(SC_ERR_FATAL, "Error FAIL state in output");
+ FatalError("Error FAIL state in output");
}
if (outputs == 0)
uint32_t encoded_next_state = next_state;
if (next_state == SC_AC_TILE_FAIL) {
- FatalError(SC_ERR_FATAL, "Error FAIL state in output");
+ FatalError("Error FAIL state in output");
}
if (outputs == 0)
int size = ctx->state_count * ctx->bytes_per_state * ctx->alphabet_storage;
void *state_table = SCMalloc(size);
if (unlikely(state_table == NULL)) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(state_table, 0, size);
ctx->state_table = state_table;
size_t mem_size = string_space_needed + pattern_list_size;
void *mem_block = SCCalloc(1, mem_size);
if (mem_block == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += mem_size;
{
/* check for safety of multiplication operation */
if (b > 0 && a > SIZE_MAX / b) {
- SCLogError(SC_EINVAL,
- "%" PRIuMAX " * %" PRIuMAX " > %" PRIuMAX
- " would overflow size_t calculating buffer size",
+ SCLogError("%" PRIuMAX " * %" PRIuMAX " > %" PRIuMAX
+ " would overflow size_t calculating buffer size",
(uintmax_t)a, (uintmax_t)b, (uintmax_t)SIZE_MAX);
exit(EXIT_FAILURE);
}
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->output_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
ctx->output_table = ptmp;
}
if (ptmp == NULL) {
SCFree(output_state->pids);
output_state->pids = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
output_state->pids = ptmp;
q->top = 0;
if (q->top == q->bot) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "Just ran out of space in the queue. "
+ SCLogCritical("Just ran out of space in the queue. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
q->bot = 0;
if (q->bot == q->top) {
- SCLogCritical(SC_ERR_AHO_CORASICK, "StateQueue behaving weirdly. "
+ SCLogCritical("StateQueue behaving weirdly. "
"Fatal Error. Exiting. Please file a bug report on this");
exit(EXIT_FAILURE);
}
if (ptmp == NULL) {
SCFree(output_dst_state->pids);
output_dst_state->pids = NULL;
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
output_dst_state->pids = ptmp;
* every state(SCACCtx->state_count) */
ctx->failure_table = SCMalloc(ctx->state_count * sizeof(int32_t));
if (ctx->failure_table == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
ctx->state_table_u16 = SCMalloc(ctx->state_count *
sizeof(SC_AC_STATE_TYPE_U16) * 256);
if (ctx->state_table_u16 == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_u16, 0,
ctx->state_count * sizeof(SC_AC_STATE_TYPE_U16) * 256);
ctx->state_table_u32 = SCMalloc(ctx->state_count *
sizeof(SC_AC_STATE_TYPE_U32) * 256);
if (ctx->state_table_u32 == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->state_table_u32, 0,
ctx->state_count * sizeof(SC_AC_STATE_TYPE_U32) * 256);
/* handle no case patterns */
ctx->pid_pat_list = SCMalloc((mpm_ctx->max_pat_id + 1)* sizeof(SCACPatternList));
if (ctx->pid_pat_list == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(ctx->pid_pat_list, 0, (mpm_ctx->max_pat_id + 1) * sizeof(SCACPatternList));
if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len);
{
hs_error_t err = hs_set_allocator(SCHSMalloc, SCHSFree);
if (err != HS_SUCCESS) {
- FatalError(SC_ERR_FATAL, "Failed to set Hyperscan allocator.");
+ FatalError("Failed to set Hyperscan allocator.");
}
}
}
if (patlen == 0) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "pattern length 0");
+ SCLogWarning("pattern length 0");
return 0;
}
&compile_err);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "failed to compile hyperscan database");
+ SCLogError("failed to compile hyperscan database");
if (compile_err) {
- SCLogError(SC_ERR_FATAL, "compile error: %s", compile_err->message);
+ SCLogError("compile error: %s", compile_err->message);
}
hs_free_compile_error(compile_err);
SCMutexUnlock(&g_db_table_mutex);
err = hs_alloc_scratch(pd->hs_db, &g_scratch_proto);
SCMutexUnlock(&g_scratch_proto_mutex);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "failed to allocate scratch");
+ SCLogError("failed to allocate scratch");
SCMutexUnlock(&g_db_table_mutex);
goto error;
}
err = hs_database_size(pd->hs_db, &ctx->hs_db_size);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "failed to query database size");
+ SCLogError("failed to query database size");
SCMutexUnlock(&g_db_table_mutex);
goto error;
}
SCMutexUnlock(&g_scratch_proto_mutex);
if (err != HS_SUCCESS) {
- FatalError(SC_ERR_FATAL, "Unable to clone scratch prototype");
+ FatalError("Unable to clone scratch prototype");
}
err = hs_scratch_size(ctx->scratch, &ctx->scratch_size);
if (err != HS_SUCCESS) {
- FatalError(SC_ERR_FATAL, "Unable to query scratch size");
+ FatalError("Unable to query scratch size");
}
mpm_thread_ctx->memory_cnt++;
/* An error value (other than HS_SCAN_TERMINATED) from hs_scan()
* indicates that it was passed an invalid database or scratch region,
* which is not something we can recover from at scan time. */
- SCLogError(SC_ERR_FATAL, "Hyperscan returned error %d", err);
+ SCLogError("Hyperscan returned error %d", err);
exit(EXIT_FAILURE);
} else {
ret = cctx.match_count;
if (de_ctx->mpm_ctx_factory_container == NULL) {
de_ctx->mpm_ctx_factory_container = SCCalloc(1, sizeof(MpmCtxFactoryContainer));
if (de_ctx->mpm_ctx_factory_container == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
de_ctx->mpm_ctx_factory_container->max_id = ENGINE_SGH_MPM_FACTORY_CONTEXT_START_ID_RANGE;
}
MpmCtxFactoryItem *nitem = SCCalloc(1, sizeof(MpmCtxFactoryItem));
if (unlikely(nitem == NULL)) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
nitem->name = name;
nitem->sm_list = sm_list;
/* toserver */
nitem->mpm_ctx_ts = SCCalloc(1, sizeof(MpmCtx));
if (nitem->mpm_ctx_ts == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
nitem->mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
/* toclient */
nitem->mpm_ctx_tc = SCCalloc(1, sizeof(MpmCtx));
if (nitem->mpm_ctx_tc == NULL) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
nitem->mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
if (unlikely(mpm_ctx == NULL)) {
- FatalError(SC_ERR_FATAL, "Error allocating memory");
+ FatalError("Error allocating memory");
}
memset(mpm_ctx, 0, sizeof(MpmCtx));
return mpm_ctx;
} else if (id < -1) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument - %d\n", id);
+ SCLogError("Invalid argument - %d\n", id);
return NULL;
} else if (id >= de_ctx->mpm_ctx_factory_container->max_id) {
/* this id does not exist */
mpm_ctx, patlen, pid);
if (patlen == 0) {
- SCLogWarning(SC_ERR_INVALID_ARGUMENTS, "pattern length 0");
+ SCLogWarning("pattern length 0");
return 0;
}
mpm_table[i].RegisterUnittests();
} else {
if (coverage_unittests)
- SCLogWarning(SC_WARN_NO_UNITTESTS, "mpm module %s has no "
- "unittest registration function.", mpm_table[i].name);
+ SCLogWarning("mpm module %s has no "
+ "unittest registration function.",
+ mpm_table[i].name);
}
}
if (num_adapters == -1) {
if ((status = NT_InfoOpen(&hInfo, "InfoStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
hInfoSys.cmd = NT_INFO_CMD_READ_SYSTEM;
if ((status = NT_InfoRead(hInfo, &hInfoSys)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_OPEN_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
snprintf(flow_name, sizeof(flow_name), "Flow stream %d", adapter );
SCLogInfo("Opening flow programming stream: %s\n", flow_name);
if ((status = NT_FlowOpen_Attr(&hFlowStream, flow_name, &attr)) != NT_SUCCESS) {
- SCLogWarning(SC_WARN_COMPATIBILITY, "Napatech bypass functionality not supported by the FPGA version on adapter %d - disabling support.", adapter);
+ SCLogWarning("Napatech bypass functionality not supported by the FPGA version on "
+ "adapter %d - disabling support.",
+ adapter);
bypass_supported = 0;
return 0;
}
hStat.u.flowData_v0.clear = clear_stats;
hStat.u.flowData_v0.adapterNo = adapter;
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(1);
}
programed = hStat.u.flowData_v0.learnDone;
stat.u.usageData_v0.streamid = (uint8_t) stream_config[inst].stream_id;
if ((status = NT_StatRead(hstat_stream, &stat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return 0;
}
/* Query the system to get the number of streams currently instantiated */
hStreamInfo.cmd = NT_INFO_CMD_READ_STREAM;
if ((status = NT_InfoRead(hInfo, &hStreamInfo)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
hStat.u.usageData_v0.streamid = (uint8_t) stream_config[inst_id].stream_id;
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return 0;
}
SCLogInfo("Statistics timed out - will retry next time.");
return 0;
} else {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return 0;
}
}
/* Open the info and Statistics */
if ((status = NT_InfoOpen(&hInfo, "StatsLoopInfoStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return NULL;
}
if ((status = NT_StatOpen(&hstat_stream, "StatsLoopStatsStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return NULL;
}
#endif /* !NAPATECH_ENABLE_BYPASS */
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return 0;
}
for (int i = 0; i < stream_cnt; ++i) {
char *pkts_buf = SCCalloc(1, 32);
if (unlikely(pkts_buf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(pkts_buf, 32, "napa%d.pkts", stream_config[i].stream_id);
char *byte_buf = SCCalloc(1, 32);
if (unlikely(byte_buf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(byte_buf, 32, "napa%d.bytes", stream_config[i].stream_id);
stream_counters[i].byte = StatsRegisterCounter(byte_buf, tv);
char *drop_pkts_buf = SCCalloc(1, 32);
if (unlikely(drop_pkts_buf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(drop_pkts_buf, 32, "napa%d.drop_pkts", stream_config[i].stream_id);
stream_counters[i].drop_pkts = StatsRegisterCounter(drop_pkts_buf, tv);
char *drop_byte_buf = SCCalloc(1, 32);
if (unlikely(drop_byte_buf == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Failed to allocate memory for NAPATECH stream counter.");
+ FatalError("Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(drop_byte_buf, 32, "napa%d.drop_byte", stream_config[i].stream_id);
stream_counters[i].drop_byte = StatsRegisterCounter(drop_byte_buf, tv);
if (!NapatechIsAutoConfigEnabled() && (num_active < stream_cnt)) {
SCLogInfo("num_active: %d, stream_cnt: %d", num_active, stream_cnt);
- SCLogWarning(SC_ERR_NAPATECH_CONFIG_STREAM,
- "Some or all of the configured streams are not created. Proceeding with active streams.");
+ SCLogWarning("Some or all of the configured streams are not created. Proceeding with "
+ "active streams.");
}
TmThreadsSetFlag(tv, THV_INIT_DONE);
/* CLEAN UP NT Resources and Close the info stream */
if ((status = NT_InfoClose(hInfo)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return NULL;
}
/* Close the statistics stream */
if ((status = NT_StatClose(hstat_stream)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return NULL;
}
if (strncmp(lnode->val, "all", 4) == 0) {
/* check that the sting in the config file is correctly specified */
if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
- FatalError(SC_ERR_FATAL,
- "Only one Napatech port specifier type allowed.");
+ FatalError("Only one Napatech port specifier type allowed.");
}
cpu_spec = CONFIG_SPECIFIER_RANGE;
worker_count = UtilCpuGetNumProcessorsConfigured();
} else if ((end_str = strchr(lnode->val, '-'))) {
/* check that the sting in the config file is correctly specified */
if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
- FatalError(SC_ERR_FATAL,
- "Only one Napatech port specifier type allowed.");
+ FatalError("Only one Napatech port specifier type allowed.");
}
cpu_spec = CONFIG_SPECIFIER_RANGE;
if (StringParseUint8(&start, 10, end_str - lnode->val, (const char *)lnode->val) < 0) {
- FatalError(SC_EINVAL,
- "Napatech invalid"
- " worker range start: '%s'",
+ FatalError("Napatech invalid"
+ " worker range start: '%s'",
lnode->val);
}
if (StringParseUint8(&end, 10, 0, (const char *) (end_str + 1)) < 0) {
- FatalError(SC_EINVAL,
- "Napatech invalid"
- " worker range end: '%s'",
+ FatalError("Napatech invalid"
+ " worker range end: '%s'",
(end_str != NULL) ? (const char *)(end_str + 1) : "Null");
}
if (end < start) {
- FatalError(SC_EINVAL,
- "Napatech invalid"
- " worker range start: '%d' is greater than end: '%d'",
+ FatalError("Napatech invalid"
+ " worker range start: '%d' is greater than end: '%d'",
start, end);
}
worker_count = end - start + 1;
} else {
/* check that the sting in the config file is correctly specified */
if (cpu_spec == CONFIG_SPECIFIER_RANGE) {
- FatalError(SC_ERR_FATAL,
- "Napatech port range specifiers cannot be combined with individual stream specifiers.");
+ FatalError("Napatech port range specifiers cannot be combined with "
+ "individual stream specifiers.");
}
cpu_spec = CONFIG_SPECIFIER_INDIVIDUAL;
++worker_count;
}
if ((status = NT_InfoOpen(&info_stream, "SuricataStreamInfo")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
if ((status = NT_StatOpen(&hstat_stream, "StatsStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
if (use_all_streams) {
info.cmd = NT_INFO_CMD_READ_STREAM;
if ((status = NT_InfoRead(info_stream, &info)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
/* Get the status code as text */
NT_ExplainError(status, error_buffer, sizeof (error_buffer));
- SCLogError(SC_ERR_NAPATECH_INIT_FAILED, "NT_StatRead() failed: %s\n", error_buffer);
+ SCLogError("NT_StatRead() failed: %s\n", error_buffer);
return -1;
}
/* When not using the default streams we need to
* parse the array of streams from the conf */
if ((ntstreams = ConfGetNode("napatech.streams")) == NULL) {
- SCLogError(SC_ERR_RUNMODE, "Failed retrieving napatech.streams from Config");
+ SCLogError("Failed retrieving napatech.streams from Config");
if (NapatechIsAutoConfigEnabled() && (set_cpu_affinity == 0)) {
- SCLogError(SC_ERR_RUNMODE,
- "if set-cpu-affinity: no in conf then napatech.streams must be defined");
+ SCLogError("if set-cpu-affinity: no in conf then napatech.streams must be "
+ "defined");
}
exit(EXIT_FAILURE);
}
{
if (stream == NULL) {
- SCLogError(SC_ERR_NAPATECH_INIT_FAILED, "Couldn't Parse Stream Configuration");
+ SCLogError("Couldn't Parse Stream Configuration");
return -1;
}
char *end_str = strchr(stream->val, '-');
if (end_str) {
if (stream_spec != CONFIG_SPECIFIER_UNDEFINED) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Only one Napatech stream range specifier allowed.");
+ SCLogError("Only one Napatech stream range specifier allowed.");
return -1;
}
stream_spec = CONFIG_SPECIFIER_RANGE;
if (StringParseUint8(&start, 10, end_str - stream->val,
(const char *)stream->val) < 0) {
- FatalError(SC_EINVAL,
- "Napatech invalid "
- "stream id start: '%s'",
+ FatalError("Napatech invalid "
+ "stream id start: '%s'",
stream->val);
}
if (StringParseUint8(&end, 10, 0, (const char *) (end_str + 1)) < 0) {
- FatalError(SC_EINVAL,
- "Napatech invalid "
- "stream id end: '%s'",
+ FatalError("Napatech invalid "
+ "stream id end: '%s'",
(end_str != NULL) ? (const char *)(end_str + 1) : "Null");
}
} else {
if (stream_spec == CONFIG_SPECIFIER_RANGE) {
- FatalError(SC_ERR_FATAL,
- "Napatech range and individual specifiers cannot be combined.");
+ FatalError("Napatech range and individual specifiers cannot be combined.");
}
stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
if (StringParseUint8(&stream_config[instance_cnt].stream_id,
10, 0, (const char *)stream->val) < 0) {
- FatalError(SC_EINVAL,
- "Napatech invalid "
- "stream id: '%s'",
+ FatalError("Napatech invalid "
+ "stream id: '%s'",
stream->val);
}
start = stream_config[instance_cnt].stream_id;
(uint8_t) stream_config[instance_cnt].stream_id;
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
/* Close the statistics stream */
if ((status = NT_StatClose(hstat_stream)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
if ((status = NT_InfoClose(info_stream)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
return -1;
}
/* Open the info and Statistics */
if ((status = NT_InfoOpen(&hInfo, "InfoStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
if ((status = NT_StatOpen(&hstat_stream, "StatsStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
/* Read the info on all streams instantiated in the system */
hStreamInfo.cmd = NT_INFO_CMD_READ_STREAM;
if ((status = NT_InfoRead(hInfo, &hStreamInfo)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
/* Read the info on all streams instantiated in the system */
hStreamInfo.cmd = NT_INFO_CMD_READ_STREAM;
if ((status = NT_InfoRead(hInfo, &hStreamInfo)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
hStat.u.usageData_v0.streamid = (uint8_t) stream_id;
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
}
if ((status = NT_InfoClose(hInfo)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
/* Close the statistics stream */
if ((status = NT_StatClose(hstat_stream)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
"custom", NapatechStatsLoop, 0);
if (stats_tv == NULL) {
- FatalError(SC_ERR_FATAL,
- "Error creating a thread for NapatechStats - Killing engine.");
+ FatalError("Error creating a thread for NapatechStats - Killing engine.");
}
if (TmThreadSpawn(stats_tv) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to spawn thread for NapatechStats - Killing engine.");
+ FatalError("Failed to spawn thread for NapatechStats - Killing engine.");
}
#ifdef NAPATECH_ENABLE_BYPASS
"custom", NapatechBufMonitorLoop, 0);
if (buf_monitor_tv == NULL) {
- FatalError(SC_ERR_FATAL,
- "Error creating a thread for NapatechBufMonitor - Killing engine.");
+ FatalError("Error creating a thread for NapatechBufMonitor - Killing engine.");
}
if (TmThreadSpawn(buf_monitor_tv) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to spawn thread for NapatechBufMonitor - Killing engine.");
+ FatalError("Failed to spawn thread for NapatechBufMonitor - Killing engine.");
}
NtNtplInfo_t ntpl_info;
if ((status = NT_ConfigOpen(&hconfig, "ConfigStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
return false;
}
/* Issue the NTPL command */
if ((status = NT_ConfigOpen(&hconfig, "ConfigStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
return false;
}
stream_numas[i] = -1;
if ((status = NT_StatOpen(&hstat_stream, "StatsStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
hStat.u.usageData_v0.streamid = (uint8_t) stream_id;
if ((status = NT_StatRead(hstat_stream, &hStat)) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
NtNtplInfo_t ntpl_info;
if ((status = NT_ConfigOpen(&hconfig, "ConfigStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
NapatechSetHashmode();
if ((status = NT_ConfigOpen(&hconfig, "ConfigStream")) != NT_SUCCESS) {
- NAPATECH_ERROR(SC_ERR_NAPATECH_INIT_FAILED, status);
+ NAPATECH_ERROR(status);
exit(EXIT_FAILURE);
}
* the array of streams from the conf
*/
if ((ntports = ConfGetNode("napatech.ports")) == NULL) {
- FatalError(SC_ERR_FATAL, "Failed retrieving napatech.ports from Conf");
+ FatalError("Failed retrieving napatech.ports from Conf");
}
/* Loop through all ports in the array */
TAILQ_FOREACH(port, &ntports->head, next)
{
if (port == NULL) {
- FatalError(SC_ERR_FATAL,
- "Couldn't Parse Port Configuration");
+ FatalError("Couldn't Parse Port Configuration");
}
if (NapatechUseHWBypass()) {
if (ports_spec.first[iteration] == ports_spec.second[iteration]) {
if (is_inline) {
- FatalError(SC_ERR_FATAL,
- "Error with napatec.ports in conf file. When running in inline mode the two ports specifying a segment must be different.");
+ FatalError("Error with napatec.ports in conf file. When running in inline "
+ "mode the two ports specifying a segment must be different.");
} else {
/* SPAN port configuration */
is_span_port[ports_spec.first[iteration]] = 1;
}
if (NapatechGetAdapter(ports_spec.first[iteration]) != NapatechGetAdapter(ports_spec.first[iteration])) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Invalid napatech.ports specification in conf file.");
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Two ports on a segment must reside on the same adapter. port %d is on adapter %d, port %d is on adapter %d.",
+ SCLogError("Invalid napatech.ports specification in conf file.");
+ SCLogError("Two ports on a segment must reside on the same adapter. port %d "
+ "is on adapter %d, port %d is on adapter %d.",
ports_spec.first[iteration],
NapatechGetAdapter(ports_spec.first[iteration]),
ports_spec.second[iteration],
- NapatechGetAdapter(ports_spec.second[iteration])
- );
+ NapatechGetAdapter(ports_spec.second[iteration]));
exit(EXIT_FAILURE);
}
strlcat(ports_spec.str, temp, sizeof(ports_spec.str));
}
} else {
- FatalError(SC_ERR_FATAL,
- "When using hardware flow bypass ports must be specified as segments. E.g. ports: [0-1, 0-2]");
+ FatalError("When using hardware flow bypass ports must be specified as segments. "
+ "E.g. ports: [0-1, 0-2]");
}
#endif
} else { // !NapatechUseHWBypass()
if (strncmp(port->val, "all", 3) == 0) {
/* check that the sting in the config file is correctly specified */
if (stream_spec != CONFIG_SPECIFIER_UNDEFINED) {
- FatalError(SC_ERR_FATAL,
- "Only one Napatech port specifier type is allowed.");
+ FatalError("Only one Napatech port specifier type is allowed.");
}
stream_spec = CONFIG_SPECIFIER_RANGE;
} else if (strchr(port->val, '-')) {
/* check that the sting in the config file is correctly specified */
if (stream_spec != CONFIG_SPECIFIER_UNDEFINED) {
- FatalError(SC_ERR_FATAL,
- "Only one Napatech port specifier is allowed when hardware bypass is disabled. (E.g. ports: [0-4], NOT ports: [0-1,2-3])");
+ FatalError("Only one Napatech port specifier is allowed when hardware bypass "
+ "is disabled. (E.g. ports: [0-4], NOT ports: [0-1,2-3])");
}
stream_spec = CONFIG_SPECIFIER_RANGE;
} else {
/* check that the sting in the config file is correctly specified */
if (stream_spec == CONFIG_SPECIFIER_RANGE) {
- FatalError(SC_ERR_FATAL,
- "Napatech port range specifiers cannot be combined with individual stream specifiers.");
+ FatalError("Napatech port range specifiers cannot be combined with individual "
+ "stream specifiers.");
}
stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
}
} else {
if (is_inline) {
- FatalError(SC_ERR_FATAL,
- "Napatech Inline operation not supported by this FPGA version.");
+ FatalError("Napatech Inline operation not supported by this FPGA version.");
}
if (NapatechIsAutoConfigEnabled()){
extern void NapatechStartStats(void);
-#define NAPATECH_ERROR(err_type, status) { \
- char errorBuffer[1024]; \
- NT_ExplainError((status), errorBuffer, sizeof (errorBuffer) - 1); \
- SCLogError((err_type), "Napatech Error: %s", errorBuffer); \
+#define NAPATECH_ERROR(status) \
+ { \
+ char errorBuffer[1024]; \
+ NT_ExplainError((status), errorBuffer, sizeof(errorBuffer) - 1); \
+ SCLogError("Napatech Error: %s", errorBuffer); \
}
-#define NAPATECH_NTPL_ERROR(ntpl_cmd, ntpl_info, status) { \
- char errorBuffer[1024]; \
- NT_ExplainError(status, errorBuffer, sizeof (errorBuffer) - 1); \
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
- " NTPL failed: %s", errorBuffer); \
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
- " cmd: %s", ntpl_cmd); \
- if (strncmp(ntpl_info.u.errorData.errBuffer[0], "", 256) != 0) \
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
- " %s", ntpl_info.u.errorData.errBuffer[0]); \
- if (strncmp(ntpl_info.u.errorData.errBuffer[1], "", 256) != 0) \
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
- " %s", ntpl_info.u.errorData.errBuffer[1]); \
- if (strncmp(ntpl_info.u.errorData.errBuffer[2], "", 256) != 0) \
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED, \
- " %s", ntpl_info.u.errorData.errBuffer[2]); \
-}
+#define NAPATECH_NTPL_ERROR(ntpl_cmd, ntpl_info, status) \
+ { \
+ char errorBuffer[1024]; \
+ NT_ExplainError(status, errorBuffer, sizeof(errorBuffer) - 1); \
+ SCLogError(" NTPL failed: %s", errorBuffer); \
+ SCLogError(" cmd: %s", ntpl_cmd); \
+ if (strncmp(ntpl_info.u.errorData.errBuffer[0], "", 256) != 0) \
+ SCLogError(" %s", ntpl_info.u.errorData.errBuffer[0]); \
+ if (strncmp(ntpl_info.u.errorData.errBuffer[1], "", 256) != 0) \
+ SCLogError(" %s", ntpl_info.u.errorData.errBuffer[1]); \
+ if (strncmp(ntpl_info.u.errorData.errBuffer[2], "", 256) != 0) \
+ SCLogError(" %s", ntpl_info.u.errorData.errBuffer[2]); \
+ }
// #define ENABLE_NT_DEBUG
#ifdef ENABLE_NT_DEBUG
uint16_t max_path_len = MAX(buf_len, PATH_MAX);
int bytes_written = snprintf(out_buf, max_path_len, "%s%c%s", dir, DIRECTORY_SEPARATOR, fname);
if (bytes_written <= 0) {
- SCLogError(SC_ERR_SPRINTF, "Could not join filename to path");
+ SCLogError("Could not join filename to path");
SCReturnInt(TM_ECODE_FAILED);
}
char *tmp_buf = SCRealPath(out_buf, NULL);
if (tmp_buf == NULL) {
- SCLogError(SC_ERR_SPRINTF, "Error resolving path: %s", strerror(errno));
+ SCLogError("Error resolving path: %s", strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
memset(out_buf, 0, buf_len);
size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
if (len <= 0) {
- SCLogError(SC_ERR_PIDFILE_SNPRINTF, "Pid error (%s)", strerror(errno));
+ SCLogError("Pid error (%s)", strerror(errno));
SCReturnInt(-1);
}
pidfd = open(pidfile, O_CREAT | O_TRUNC | O_NOFOLLOW | O_WRONLY, 0644);
if (pidfd < 0) {
- SCLogError(SC_ERR_PIDFILE_OPEN, "unable to set pidfile '%s': %s",
- pidfile,
- strerror(errno));
+ SCLogError("unable to set pidfile '%s': %s", pidfile, strerror(errno));
SCReturnInt(-1);
}
ssize_t r = write(pidfd, val, (unsigned int)len);
if (r == -1) {
- SCLogError(SC_ERR_PIDFILE_WRITE, "unable to write pidfile: %s", strerror(errno));
+ SCLogError("unable to write pidfile: %s", strerror(errno));
close(pidfd);
SCReturnInt(-1);
} else if ((size_t)r != len) {
- SCLogError(SC_ERR_PIDFILE_WRITE, "unable to write pidfile: wrote"
- " %"PRIdMAX" of %"PRIuMAX" bytes.", (intmax_t)r, (uintmax_t)len);
+ SCLogError("unable to write pidfile: wrote"
+ " %" PRIdMAX " of %" PRIuMAX " bytes.",
+ (intmax_t)r, (uintmax_t)len);
close(pidfd);
SCReturnInt(-1);
}
pf = fopen(pid_filename, "r");
if (pf == NULL) {
if (access(pid_filename, F_OK) == 0) {
- SCLogError(SC_ERR_INITIALIZATION, "pid file '%s' exists and can not be read. Aborting!",
- pid_filename);
+ SCLogError("pid file '%s' exists and can not be read. Aborting!", pid_filename);
return -1;
} else {
return 0;
#ifndef OS_WIN32
pid_t pidv;
if (fscanf(pf, "%d", &pidv) == 1 && kill(pidv, 0) == 0) {
- SCLogError(SC_ERR_INITIALIZATION,
- "pid file '%s' exists and Suricata appears to be running. "
- "Aborting!",
+ SCLogError("pid file '%s' exists and Suricata appears to be running. "
+ "Aborting!",
pid_filename);
} else
#endif
{
- SCLogError(SC_ERR_INITIALIZATION,
- "pid file '%s' exists but appears stale. "
- "Make sure Suricata is not running and then remove %s. "
- "Aborting!",
+ SCLogError("pid file '%s' exists but appears stale. "
+ "Make sure Suricata is not running and then remove %s. "
+ "Aborting!",
pid_filename, pid_filename);
}
PluginListNode *node = SCCalloc(1, sizeof(*node));
if (node == NULL) {
- SCLogError(SC_ENOMEM, "Failed to allocate memory for plugin");
+ SCLogError("Failed to allocate memory for plugin");
return false;
}
node->plugin = plugin;
SCPluginRegisterFunc plugin_register = dlsym(lib, "SCPluginRegister");
if (plugin_register == NULL) {
- SCLogError(SC_ERR_PLUGIN, "Plugin does not export SCPluginRegister function: %s", path);
+ SCLogError("Plugin does not export SCPluginRegister function: %s", path);
dlclose(lib);
return;
}
if (!RegisterPlugin(plugin_register(), lib)) {
- SCLogError(SC_ERR_PLUGIN, "Plugin registration failed: %s", path);
+ SCLogError("Plugin registration failed: %s", path);
dlclose(lib);
return;
}
TAILQ_FOREACH(plugin, &conf->head, next) {
struct stat statbuf;
if (stat(plugin->val, &statbuf) == -1) {
- SCLogError(SC_ERR_STAT, "Bad plugin path: %s: %s",
- plugin->val, strerror(errno));
+ SCLogError("Bad plugin path: %s: %s", plugin->val, strerror(errno));
continue;
}
if (S_ISDIR(statbuf.st_mode)) {
// coverity[toctou : FALSE]
DIR *dir = opendir(plugin->val);
if (dir == NULL) {
- SCLogError(SC_ERR_DIR_OPEN, "Failed to open plugin directory %s: %s",
- plugin->val, strerror(errno));
+ SCLogError("Failed to open plugin directory %s: %s", plugin->val, strerror(errno));
continue;
}
struct dirent *entry = NULL;
if (run_mode == RUNMODE_PLUGIN) {
SCCapturePlugin *capture = SCPluginFindCaptureByName(capture_plugin_name);
if (capture == NULL) {
- FatalError(SC_ERR_PLUGIN, "No capture plugin found with name %s",
- capture_plugin_name);
+ FatalError("No capture plugin found with name %s", capture_plugin_name);
}
capture->Init(capture_plugin_args, RUNMODE_PLUGIN, TMM_RECEIVEPLUGIN,
TMM_DECODEPLUGIN);
{
/* First check that the name doesn't conflict with a built-in filetype. */
if (IsBuiltinTypeName(plugin->name)) {
- SCLogError(SC_ERR_LOG_OUTPUT, "Eve file type name conflicts with built-in type: %s",
- plugin->name);
+ SCLogError("Eve file type name conflicts with built-in type: %s", plugin->name);
return false;
}
SCEveFileType *existing = NULL;
TAILQ_FOREACH (existing, &output_types, entries) {
if (strcmp(existing->name, plugin->name) == 0) {
- SCLogError(SC_ERR_LOG_OUTPUT,
- "Eve file type name conflicts with previously registered type: %s",
+ SCLogError("Eve file type name conflicts with previously registered type: %s",
plugin->name);
return false;
}
int PoolThreadExpand(PoolThread *pt)
{
if (pt == NULL || pt->array == NULL || pt->size == 0) {
- SCLogError(SC_EINVAL, "pool grow failed");
+ SCLogError("pool grow failed");
return -1;
}
if (ptmp == NULL) {
SCFree(pt->array);
pt->array = NULL;
- SCLogError(SC_EINVAL, "pool grow failed");
+ SCLogError("pool grow failed");
return -1;
}
pt->array = ptmp;
settings.Cleanup, settings.Free);
SCMutexUnlock(&e->lock);
if (e->pool == NULL) {
- SCLogError(SC_EINVAL, "pool grow failed");
+ SCLogError("pool grow failed");
return -1;
}
new_size * sizeof(SigIntId));
if (unlikely(new_array == NULL)) {
- SCLogError(SC_ENOMEM, "Failed to realloc PatternMatchQueue"
- " rule ID array. Some signature ID matches lost");
+ SCLogError("Failed to realloc PatternMatchQueue"
+ " rule ID array. Some signature ID matches lost");
return 0;
}
}
/* current IPv6 format is fixed size */
if (size < 8 * 5) {
- SCLogWarning(SC_ERR_ARG_LEN_LONG, "Too small buffer to write IPv6 address");
+ SCLogWarning("Too small buffer to write IPv6 address");
return NULL;
}
memset(dst, 0, size);
/* Format IPv6 without deleting zeroes */
return PrintInetIPv6(src, dst, size);
default:
- SCLogError(SC_EINVAL, "Unsupported protocol: %d", af);
+ SCLogError("Unsupported protocol: %d", af);
}
return NULL;
}
if (capng_change_id(userid, groupid, CAPNG_DROP_SUPP_GRP |
CAPNG_CLEAR_BOUNDING) < 0)
{
- FatalError(SC_ERR_FATAL, "capng_change_id for main thread"
+ FatalError("capng_change_id for main thread"
" failed");
}
/* Get the user ID */
if (isdigit((unsigned char)user_name[0]) != 0) {
if (ByteExtractStringUint32(&userid, 10, 0, (const char *)user_name) < 0) {
- FatalError(SC_ERR_UID_FAILED, "invalid user id value: '%s'", user_name);
+ FatalError("invalid user id value: '%s'", user_name);
}
pw = getpwuid(userid);
if (pw == NULL) {
- FatalError(SC_ERR_FATAL, "unable to get the user ID, "
- "check if user exist!!");
+ FatalError("unable to get the user ID, "
+ "check if user exist!!");
}
} else {
pw = getpwnam(user_name);
if (pw == NULL) {
- FatalError(SC_ERR_FATAL, "unable to get the user ID, "
+ FatalError("unable to get the user ID, "
"check if user exist!!");
}
userid = pw->pw_uid;
if (isdigit((unsigned char)group_name[0]) != 0) {
if (ByteExtractStringUint32(&groupid, 10, 0, (const char *)group_name) < 0) {
- FatalError(SC_ERR_GID_FAILED, "invalid group id: '%s'", group_name);
+ FatalError("invalid group id: '%s'", group_name);
}
} else {
gp = getgrnam(group_name);
if (gp == NULL) {
- FatalError(SC_ERR_FATAL, "unable to get the group"
+ FatalError("unable to get the group"
" ID, check if group exist!!");
}
groupid = gp->gr_gid;
/* Get the group ID */
if (isdigit((unsigned char)group_name[0]) != 0) {
if (ByteExtractStringUint32(&grpid, 10, 0, (const char *)group_name) < 0) {
- FatalError(SC_ERR_GID_FAILED, "invalid group id: '%s'", group_name);
+ FatalError("invalid group id: '%s'", group_name);
}
} else {
gp = getgrnam(group_name);
if (gp == NULL) {
- FatalError(SC_ERR_FATAL, "unable to get the group ID,"
+ FatalError("unable to get the group ID,"
" check if group exist!!");
}
grpid = gp->gr_gid;
int ret = pledge("stdio rpath wpath cpath fattr unix dns bpf", NULL);
if (ret != 0) {
- SCLogError(SC_ERR_PLEDGE_FAILED, "unable to pledge,"
- " check permissions!! ret=%i errno=%i", ret, errno);
+ SCLogError("unable to pledge,"
+ " check permissions!! ret=%i errno=%i",
+ ret, errno);
exit(EXIT_FAILURE);
}
fp = fopen(profiling_file_name, profiling_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
- strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_file_name, strerror(errno));
return;
}
} else {
memset(ctx, 0x00, sizeof(SCProfileKeywordDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to initialize hash table mutex.");
+ FatalError("Failed to initialize hash table mutex.");
}
}
fp = fopen(profiling_locks_file_name, profiling_locks_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s",
- profiling_locks_file_name, strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_locks_file_name, strerror(errno));
return;
}
} else {
fp = fopen(profiling_file_name, profiling_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
- strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_file_name, strerror(errno));
return;
}
} else {
memset(ctx, 0x00, sizeof(SCProfilePrefilterDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to initialize hash table mutex.");
+ FatalError("Failed to initialize hash table mutex.");
}
}
fp = fopen(profiling_file_name, profiling_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
- strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_file_name, strerror(errno));
return;
}
} else {
SCProfileSghDetectCtx *ctx = SCCalloc(1, sizeof(SCProfileSghDetectCtx));
if (ctx != NULL) {
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- FatalError(SC_ERR_FATAL, "Failed to initialize mutex.");
+ FatalError("Failed to initialize mutex.");
}
}
SET_ONE(SC_PROFILING_RULES_SORT_BY_MAX_TICKS);
}
else {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Invalid profiling sort order: %s", val);
+ SCLogError("Invalid profiling sort order: %s", val);
exit(EXIT_FAILURE);
}
}
if (val != NULL) {
if (StringParseUint32(&profiling_rules_limit, 10,
(uint16_t)strlen(val), val) <= 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid limit: %s", val);
+ SCLogError("Invalid limit: %s", val);
exit(EXIT_FAILURE);
}
}
fp = fopen(profiling_file_name, profiling_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
- strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_file_name, strerror(errno));
return;
}
} else {
int summary_size = sizeof(SCProfileSummary) * rules_ctx->size;
SCProfileSummary *summary = SCMalloc(summary_size);
if (unlikely(summary == NULL)) {
- SCLogError(SC_ENOMEM, "Error allocating memory for profiling summary");
+ SCLogError("Error allocating memory for profiling summary");
return;
}
memset(ctx, 0x00, sizeof(SCProfileDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to initialize hash table mutex.");
+ FatalError("Failed to initialize hash table mutex.");
}
}
profiling_packets_enabled = 1;
if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
- FatalError(SC_ERR_FATAL,
- "Failed to initialize packet profiling mutex.");
+ FatalError("Failed to initialize packet profiling mutex.");
}
memset(&packet_profile_data4, 0, sizeof(packet_profile_data4));
memset(&packet_profile_data6, 0, sizeof(packet_profile_data6));
profiling_csv_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_csv_file_name == NULL)) {
- FatalError(SC_ERR_FATAL, "out of memory");
+ FatalError("out of memory");
}
snprintf(profiling_csv_file_name, PATH_MAX, "%s/%s", log_dir, filename);
if (conf != NULL) {
if (ConfNodeChildValueIsTrue(conf, "enabled")) {
#ifndef PROFILE_LOCKING
- SCLogWarning(SC_WARN_PROFILE, "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
+ SCLogWarning(
+ "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
#else
profiling_locks_enabled = 1;
profiling_locks_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_locks_file_name == NULL)) {
- FatalError(SC_ERR_FATAL, "can't duplicate file name");
+ FatalError("can't duplicate file name");
}
snprintf(profiling_locks_file_name, PATH_MAX, "%s/%s", log_dir, filename);
fp = fopen(profiling_packets_file_name, profiling_packets_file_mode);
if (fp == NULL) {
- SCLogError(SC_ERR_FOPEN, "failed to open %s: %s",
- profiling_packets_file_name, strerror(errno));
+ SCLogError("failed to open %s: %s", profiling_packets_file_name, strerror(errno));
return;
}
} else {
void SCProfilingAddPacket(Packet *);
int SCProfileRuleStart(Packet *p);
-#define RULE_PROFILING_START(p) \
- uint64_t profile_rule_start_ = 0; \
- uint64_t profile_rule_end_ = 0; \
- if (profiling_rules_enabled && SCProfileRuleStart((p))) { \
- if (profiling_rules_entered > 0) { \
- SCLogError(SC_ERR_FATAL, "Re-entered profiling, exiting."); \
- exit(1); \
- } \
- profiling_rules_entered++; \
- profile_rule_start_ = UtilCpuGetTicks(); \
+#define RULE_PROFILING_START(p) \
+ uint64_t profile_rule_start_ = 0; \
+ uint64_t profile_rule_end_ = 0; \
+ if (profiling_rules_enabled && SCProfileRuleStart((p))) { \
+ if (profiling_rules_entered > 0) { \
+ SCLogError("Re-entered profiling, exiting."); \
+ exit(1); \
+ } \
+ profiling_rules_entered++; \
+ profile_rule_start_ = UtilCpuGetTicks(); \
}
#define RULE_PROFILING_END(ctx, r, m, p) \
(ctx)->keyword_perf_list = (list); \
}
-#define KEYWORD_PROFILING_START \
- uint64_t profile_keyword_start_ = 0; \
- uint64_t profile_keyword_end_ = 0; \
- if (profiling_keyword_enabled) { \
- if (profiling_keyword_entered > 0) { \
- SCLogError(SC_ERR_FATAL, "Re-entered profiling, exiting."); \
- abort(); \
- } \
- profiling_keyword_entered++; \
- profile_keyword_start_ = UtilCpuGetTicks(); \
+#define KEYWORD_PROFILING_START \
+ uint64_t profile_keyword_start_ = 0; \
+ uint64_t profile_keyword_end_ = 0; \
+ if (profiling_keyword_enabled) { \
+ if (profiling_keyword_entered > 0) { \
+ SCLogError("Re-entered profiling, exiting."); \
+ abort(); \
+ } \
+ profiling_keyword_entered++; \
+ profile_keyword_start_ = UtilCpuGetTicks(); \
}
/* we allow this macro to be called if profiling_keyword_entered == 0,
uint64_t profile_prefilter_end_ = 0; \
if (profiling_prefilter_enabled) { \
if (profiling_prefilter_entered > 0) { \
- SCLogError(SC_ERR_FATAL, "Re-entered profiling, exiting."); \
+ SCLogError("Re-entered profiling, exiting."); \
abort(); \
} \
profiling_prefilter_entered++; \
{
ProtoNameHashEntry *proto_ent = SCCalloc(1, sizeof(ProtoNameHashEntry));
if (!proto_ent) {
- FatalError(SC_ERR_HASH_TABLE_INIT, "Unable to allocate protocol hash entry");
+ FatalError("Unable to allocate protocol hash entry");
}
proto_ent->name = SCStrdup(proto_name);
if (!proto_ent->name)
- FatalError(SC_ENOMEM, "Unable to allocate memory for protocol name entries");
+ FatalError("Unable to allocate memory for protocol name entries");
proto_ent->number = proto_number;
SCLogDebug("new protocol entry: name: \"%s\"; protocol number: %d", proto_ent->name,
proto_ent->number);
if (0 != HashTableAdd(proto_ht, proto_ent, 0)) {
- FatalError(SC_ERR_HASH_ADD,
- "Unable to add entry to proto hash table for "
- "name: \"%s\"; number: %d",
+ FatalError("Unable to add entry to proto hash table for "
+ "name: \"%s\"; number: %d",
proto_ent->name, proto_ent->number);
}
return;
proto_ht =
HashTableInit(256, ProtoNameHashFunc, ProtoNameHashCompareFunc, ProtoNameHashFreeFunc);
if (proto_ht == NULL) {
- FatalError(SC_ERR_HASH_TABLE_INIT, "Unable to initialize protocol name/number table");
+ FatalError("Unable to initialize protocol name/number table");
}
for (uint16_t i = 0; i < ARRAY_SIZE(known_proto); i++) {
{
SCRadixUserData *user_data = SCMalloc(sizeof(SCRadixUserData));
if (unlikely(user_data == NULL)) {
- SCLogError(SC_ENOMEM, "Error allocating memory");
+ SCLogError("Error allocating memory");
return NULL;
}
SCRadixUserData *prev = NULL;
if (new == NULL || list == NULL) {
- FatalError(SC_ERR_FATAL, "new or list supplied as NULL");
+ FatalError("new or list supplied as NULL");
}
/* add to the list in descending order. The reason we do this is for
SCRadixPrefix *prefix = NULL;
if ((key_bitlen % 8 != 0)) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid argument bitlen - %d",
- key_bitlen);
+ SCLogError("Invalid argument bitlen - %d", key_bitlen);
return NULL;
}
if (key_stream == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Argument \"stream\" NULL");
+ SCLogError("Argument \"stream\" NULL");
return NULL;
}
void *user)
{
if (prefix == NULL || user == NULL) {
- FatalError(SC_ERR_FATAL, "prefix or user NULL");
+ FatalError("prefix or user NULL");
}
SCRadixAppendToSCRadixUserDataList(SCRadixAllocSCRadixUserData(netmask, user),
SCRadixUserData *temp = NULL, *prev = NULL;
if (prefix == NULL) {
- FatalError(SC_ERR_FATAL, "prefix NULL");
+ FatalError("prefix NULL");
}
prev = temp = prefix->user_data;
SCRadixUserData *user_data = NULL;
if (prefix == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "prefix is NULL");
+ SCLogError("prefix is NULL");
goto no_match;
}
uint32_t count = 0;
if (prefix == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "prefix is NULL");
+ SCLogError("prefix is NULL");
return 0;
}
SCRadixUserData *user_data = NULL;
if (prefix == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "prefix is NULL");
+ SCLogError("prefix is NULL");
goto no_match;
}
SCRadixNode *node = NULL;
if ( (node = SCMalloc(sizeof(SCRadixNode))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixCreateNode. Mem not allocated...");
+ SCLogError("Fatal error encountered in SCRadixCreateNode. Mem not allocated...");
return NULL;
}
memset(node, 0, sizeof(SCRadixNode));
SCRadixTree *tree = NULL;
if ( (tree = SCMalloc(sizeof(SCRadixTree))) == NULL) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
+ FatalError("Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
}
memset(tree, 0, sizeof(SCRadixTree));
uint16_t j = 0;
if (tree == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Argument \"tree\" NULL");
+ SCLogError("Argument \"tree\" NULL");
return NULL;
}
SCRadixPrefix *prefix = NULL;
if ( (prefix = SCRadixCreatePrefix(key_stream, key_bitlen, user,
netmask)) == NULL) {
- SCLogError(SC_ERR_RADIX_TREE_GENERIC, "Error creating prefix");
+ SCLogError("Error creating prefix");
return NULL;
}
node = SCRadixCreateNode();
sizeof(uint8_t)))) == NULL) {
SCFree(node->netmasks);
node->netmasks = NULL;
- SCLogError(SC_ENOMEM, "Fatal error encountered in SCRadixAddKey. Mem not allocated");
+ SCLogError("Fatal error encountered in SCRadixAddKey. Mem not allocated");
return NULL;
}
node->netmasks = ptmp;
sizeof(uint8_t)))) == NULL) {
SCFree(node->netmasks);
node->netmasks = NULL;
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixAddKey. Mem not allocated...");
+ SCLogError("Fatal error encountered in SCRadixAddKey. Mem not allocated...");
return NULL;
}
node->netmasks = ptmp;
SCRadixPrefix *prefix = NULL;
if ( (prefix = SCRadixCreatePrefix(key_stream, key_bitlen, user,
netmask)) == NULL) {
- SCLogError(SC_ERR_RADIX_TREE_GENERIC, "Error creating prefix");
+ SCLogError("Error creating prefix");
return NULL;
}
new_node = SCRadixCreateNode();
if (i < node->netmask_cnt) {
if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
sizeof(uint8_t))) == NULL) {
- SCLogError(SC_ENOMEM,
- "Fatal error encountered in SCRadixAddKey. Mem not allocated...");
+ SCLogError("Fatal error encountered in SCRadixAddKey. Mem not allocated...");
SCRadixReleaseNode(inter_node, tree);
SCRadixReleaseNode(new_node, tree);
return NULL;
sizeof(uint8_t)))) == NULL) {
SCFree(node->netmasks);
node->netmasks = NULL;
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in SCRadixAddKey. Exiting...");
+ FatalError("Fatal error encountered in SCRadixAddKey. Exiting...");
}
node->netmasks = ptmp;
if (masked != ip) {
char nstr[16];
PrintInet(AF_INET, (void *)&masked, nstr, sizeof(nstr));
- SCLogWarning(SC_ERR_INVALID_IP_NETBLOCK, "adding '%s' as '%s/%u'", str, nstr, netmask);
+ SCLogWarning("adding '%s' as '%s/%u'", str, nstr, netmask);
ip = masked;
}
#if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
if (diff) {
char nstr[64];
PrintInet(AF_INET6, (void *)&addr.s6_addr, nstr, sizeof(nstr));
- SCLogWarning(SC_ERR_INVALID_IP_NETBLOCK, "adding '%s' as '%s/%u'", str, nstr, netmask);
+ SCLogWarning("adding '%s' as '%s/%u'", str, nstr, netmask);
}
#if defined(DEBUG_VALIDATION) || defined(UNITTESTS)
SCRadixValidateIPv6Key((uint8_t *)&addr.s6_addr, netmask);
void *ptmp = NULL;
if (src == NULL || dest == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "src or dest NULL");
+ SCLogError("src or dest NULL");
return;
}
int i = 0;
if (node == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument. Node is NULL");
+ SCLogError("Invalid argument. Node is NULL");
return;
}
if (regex == NULL) {
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogWarning(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogWarning("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
SC_RCONF_REGEX, (int)eo, errbuffer);
return;
}
SCRConfReferenceHashCompareFunc,
SCRConfReferenceHashFree);
if (de_ctx->reference_conf_ht == NULL) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "Error initializing the hash "
+ SCLogError("Error initializing the hash "
"table");
return NULL;
}
return NULL; // silently fail
}
#endif
- SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename,
- strerror(errno));
+ SCLogError("Error opening file: \"%s\": %s", filename, strerror(errno));
return NULL;
}
}
ret = pcre2_match(regex, (PCRE2_SPTR8)line, strlen(line), 0, 0, regex_match, NULL);
if (ret < 0) {
- SCLogError(SC_ERR_REFERENCE_CONFIG, "Invalid Reference Config in "
+ SCLogError("Invalid Reference Config in "
"reference.config file");
goto error;
}
size_t copylen = sizeof(system);
ret = pcre2_substring_copy_bynumber(regex_match, 1, (PCRE2_UCHAR8 *)system, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber() failed");
+ SCLogError("pcre2_substring_copy_bynumber() failed");
goto error;
}
copylen = sizeof(url);
ret = pcre2_substring_copy_bynumber(regex_match, 2, (PCRE2_UCHAR8 *)url, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber() failed");
+ SCLogError("pcre2_substring_copy_bynumber() failed");
goto error;
}
SCRConfReference *ref = NULL;
if (system == NULL) {
- SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid arguments. system NULL");
+ SCLogError("Invalid arguments. system NULL");
return NULL;
}
return -1;
}
#endif
- SCLogError(SC_ERR_OPENING_FILE, "please check the \"reference-config-file\" "
- "option in your suricata.yaml file");
+ SCLogError("please check the \"reference-config-file\" "
+ "option in your suricata.yaml file");
return -1;
}
ROHashTable *ROHashInit(uint8_t hash_bits, uint16_t item_size)
{
if (item_size % 4 != 0 || item_size == 0) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "data size must be multiple of 4");
+ SCLogError("data size must be multiple of 4");
return NULL;
}
if (hash_bits < 4 || hash_bits > 31) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "invalid hash_bits setting, valid range is 4-31");
+ SCLogError("invalid hash_bits setting, valid range is 4-31");
return NULL;
}
ROHashTable *table = SCMalloc(sizeof(ROHashTable) + size);
if (unlikely(table == NULL)) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "failed to alloc memory");
+ SCLogError("failed to alloc memory");
return NULL;
}
memset(table, 0, sizeof(ROHashTable) + size);
int ROHashInitQueueValue(ROHashTable *table, void *value, uint16_t size)
{
if (table->locked) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "can't add value to locked table");
+ SCLogError("can't add value to locked table");
return 0;
}
if (table->item_size != size) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "wrong size for data %u != %u", size, table->item_size);
+ SCLogError("wrong size for data %u != %u", size, table->item_size);
return 0;
}
int ROHashInitFinalize(ROHashTable *table)
{
if (table->locked) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "table already locked");
+ SCLogError("table already locked");
return 0;
}
}
if (table->items == 0) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "no items");
+ SCLogError("no items");
return 0;
}
uint32_t newsize = table->items * table->item_size;
table->data = SCMalloc(newsize);
if (table->data == NULL) {
- SCLogError(SC_ERR_HASH_TABLE_INIT, "failed to alloc memory");
+ SCLogError("failed to alloc memory");
return 0;
}
memset(table->data, 0x00, newsize);
}
if (ConfGet(conf_var_full_name, &conf_var_full_name_value) != 1) {
- SCLogError(SC_ERR_UNDEFINED_VAR, "Variable \"%s\" is not defined in "
- "configuration file", conf_var_name);
+ SCLogError("Variable \"%s\" is not defined in "
+ "configuration file",
+ conf_var_name);
goto end;
}
char *queues = SCMalloc(queues_size);
if (unlikely(queues == NULL)) {
- SCLogError(SC_ENOMEM, "failed to alloc queues buffer: %s", strerror(errno));
+ SCLogError("failed to alloc queues buffer: %s", strerror(errno));
return NULL;
}
memset(queues, 0x00, queues_size);
char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- FatalError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
+ FatalError("RunmodeAutoFpCreatePickupQueuesString failed");
}
if ((nlive <= 1) && (live_dev != NULL)) {
void *aconf = ConfigParser(live_dev);
if (aconf == NULL) {
- FatalError(SC_ERR_RUNMODE, "Failed to allocate config for %s",
- live_dev);
+ FatalError("Failed to allocate config for %s", live_dev);
}
int threads_count = ModThreadsCount(aconf);
"packetpool", "packetpool",
queues, "flow", "pktacqloop");
if (tv_receive == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
TmModule *tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE,
- "TmModuleGetByName failed for %s",
- recv_mod_name);
+ FatalError("TmModuleGetByName failed for %s", recv_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, aconf);
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE,
- "TmModuleGetByName %s failed", decode_mod_name);
+ FatalError("TmModuleGetByName %s failed", decode_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
} else { /* Multiple input device */
const char *visual_devname = LiveGetShortName(dev);
if (dev == NULL) {
- FatalError(SC_ERR_RUNMODE, "Failed to lookup live dev %d", lthread);
+ FatalError("Failed to lookup live dev %d", lthread);
}
SCLogDebug("dev %s", dev);
void *aconf = ConfigParser(dev);
if (aconf == NULL) {
- FatalError(SC_ERR_RUNMODE, "Multidev: Failed to allocate config for %s (%d)",
- dev, lthread);
+ FatalError("Multidev: Failed to allocate config for %s (%d)", dev, lthread);
}
int threads_count = ModThreadsCount(aconf);
for (int thread = 0; thread < threads_count; thread++) {
char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(dev)));
if (unlikely(printable_threadname == NULL)) {
- FatalError(SC_ENOMEM, "failed to alloc printable thread name: %s",
- strerror(errno));
+ FatalError("failed to alloc printable thread name: %s", strerror(errno));
}
snprintf(tname, sizeof(tname), "%s#%02d-%s", thread_name,
thread+1, visual_devname);
"packetpool", "packetpool",
queues, "flow", "pktacqloop");
if (tv_receive == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tv_receive->printable_name = printable_threadname;
TmModule *tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName failed for %s", recv_mod_name);
+ FatalError("TmModuleGetByName failed for %s", recv_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, aconf);
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", decode_mod_name);
+ FatalError("TmModuleGetByName %s failed", decode_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
}
"packetpool", "packetpool",
"varslot");
if (tv_detect_ncpu == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
TmModule *tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
tm_module = TmModuleGetByName("RespondReject");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName RespondReject failed");
+ FatalError("TmModuleGetByName RespondReject failed");
}
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
const char *visual_devname = LiveGetShortName(live_dev);
char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(live_dev)));
if (unlikely(printable_threadname == NULL)) {
- FatalError(SC_ENOMEM, "failed to alloc printable thread name: %s", strerror(errno));
+ FatalError("failed to alloc printable thread name: %s", strerror(errno));
exit(EXIT_FAILURE);
}
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
- FatalError(SC_ERR_THREAD_CREATE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tv->printable_name = printable_threadname;
tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
- FatalError(SC_EINVAL, "TmModuleGetByName failed for %s", recv_mod_name);
+ FatalError("TmModuleGetByName failed for %s", recv_mod_name);
}
TmSlotSetFuncAppend(tv, tm_module, aconf);
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
- FatalError(SC_EINVAL, "TmModuleGetByName %s failed", decode_mod_name);
+ FatalError("TmModuleGetByName %s failed", decode_mod_name);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("RespondReject");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName RespondReject failed");
+ FatalError("TmModuleGetByName RespondReject failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
TmThreadSetCPU(tv, WORKER_CPU_SET);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
- FatalError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
void *aconf;
if (nlive > 1) {
- FatalError(SC_ERR_RUNMODE,
- "Can't use the 'single' runmode with multiple devices");
+ FatalError("Can't use the 'single' runmode with multiple devices");
}
if (live_dev != NULL) {
char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- FatalError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
+ FatalError("RunmodeAutoFpCreatePickupQueuesString failed");
}
/* create the threads */
for (int i = 0; i < nqueue; i++) {
const char *cur_queue = LiveGetDeviceName(i);
if (cur_queue == NULL) {
- FatalError(SC_ERR_RUNMODE, "invalid queue number");
+ FatalError("invalid queue number");
}
memset(tname, 0, sizeof(tname));
snprintf(tname, sizeof(tname), "%s-%s", thread_name_autofp, cur_queue);
"packetpool", "packetpool",
queues, "flow", "pktacqloop");
if (tv_receive == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName failed for %s", recv_mod_name);
+ FatalError("TmModuleGetByName failed for %s", recv_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, (void *) ConfigParser(i));
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", decode_mod_name);
+ FatalError("TmModuleGetByName %s failed", decode_mod_name);
}
TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
"verdict-queue", "simple",
"varslot");
if (tv_detect_ncpu == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
TmThreadSetGroupName(tv_detect_ncpu, "Detect");
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
"packetpool", "packetpool",
"varslot");
if (tv_verdict == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tm_module = TmModuleGetByName(verdict_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", verdict_mod_name);
+ FatalError("TmModuleGetByName %s failed", verdict_mod_name);
}
TmSlotSetFuncAppend(tv_verdict, tm_module, (void *)ConfigParser(i));
tm_module = TmModuleGetByName("RespondReject");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for RespondReject failed");
+ FatalError("TmModuleGetByName for RespondReject failed");
}
TmSlotSetFuncAppend(tv_verdict, tm_module, NULL);
TmThreadSetCPU(tv_verdict, VERDICT_CPU_SET);
if (TmThreadSpawn(tv_verdict) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
/* create the threads */
const char *cur_queue = LiveGetDeviceName(i);
if (cur_queue == NULL) {
- FatalError(SC_ERR_RUNMODE, "invalid queue number");
+ FatalError("invalid queue number");
}
char tname[TM_THREAD_NAME_MAX];
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
- FatalError(SC_ERR_THREAD_CREATE, "TmThreadsCreate failed");
+ FatalError("TmThreadsCreate failed");
}
tm_module = TmModuleGetByName(recv_mod_name);
if (tm_module == NULL) {
- FatalError(SC_EINVAL, "TmModuleGetByName failed for %s", recv_mod_name);
+ FatalError("TmModuleGetByName failed for %s", recv_mod_name);
}
TmSlotSetFuncAppend(tv, tm_module, (void *) ConfigParser(i));
tm_module = TmModuleGetByName(decode_mod_name);
if (tm_module == NULL) {
- FatalError(SC_EINVAL, "TmModuleGetByName %s failed", decode_mod_name);
+ FatalError("TmModuleGetByName %s failed", decode_mod_name);
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
+ FatalError("TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName(verdict_mod_name);
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", verdict_mod_name);
+ FatalError("TmModuleGetByName %s failed", verdict_mod_name);
}
TmSlotSetFuncAppend(tv, tm_module, (void *) ConfigParser(i));
tm_module = TmModuleGetByName("RespondReject");
if (tm_module == NULL) {
- FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for RespondReject failed");
+ FatalError("TmModuleGetByName for RespondReject failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
TmThreadSetCPU(tv, WORKER_CPU_SET);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
- FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
+ FatalError("TmThreadSpawn failed");
}
}
{
BmCtx *new = SCMalloc(sizeof(BmCtx) + sizeof(uint16_t) * (needle_len + 1));
if (unlikely(new == NULL)) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
+ FatalError("Fatal error encountered in BoyerMooreCtxInit. Exiting...");
}
/* Prepare bad chars */
/* Prepare good Suffixes */
if (PreBmGs(needle, needle_len, new->bmGs) == -1) {
- FatalError(SC_ERR_FATAL,
- "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
+ FatalError("Fatal error encountered in BooyerMooreCtxInit. Exiting...");
}
hs_error_t err = hs_compile(expr, flags, HS_MODE_BLOCK, NULL, &db,
&compile_err);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "Unable to compile '%s' with Hyperscan, "
- "returned %d.", expr, err);
+ SCLogError("Unable to compile '%s' with Hyperscan, "
+ "returned %d.",
+ expr, err);
exit(EXIT_FAILURE);
}
if (err != HS_SUCCESS) {
/* If scratch allocation failed, this is not recoverable: other SPM
* contexts may need this scratch space. */
- SCLogError(SC_ERR_FATAL,
- "Unable to alloc scratch for Hyperscan, returned %d.", err);
+ SCLogError("Unable to alloc scratch for Hyperscan, returned %d.", err);
exit(EXIT_FAILURE);
}
global_thread_ctx->ctx = scratch;
/* An error value (other than HS_SCAN_TERMINATED) from hs_scan()
* indicates that it was passed an invalid database or scratch region,
* which is not something we can recover from at scan time. */
- SCLogError(SC_ERR_FATAL, "Hyperscan returned fatal error %d.", err);
+ SCLogError("Hyperscan returned fatal error %d.", err);
exit(EXIT_FAILURE);
}
hs_scratch_t *scratch = NULL;
hs_error_t err = hs_clone_scratch(global_thread_ctx->ctx, &scratch);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "Unable to clone scratch (error %d).",
- err);
+ SCLogError("Unable to clone scratch (error %d).", err);
exit(EXIT_FAILURE);
}
thread_ctx->ctx = scratch;
#ifndef BUILD_HYPERSCAN
if ((spm_algo != NULL) && (strcmp(spm_algo, "hs") == 0)) {
- FatalError(SC_EINVAL, "Hyperscan (hs) support for spm-algo is "
- "not compiled into Suricata.");
+ FatalError("Hyperscan (hs) support for spm-algo is "
+ "not compiled into Suricata.");
}
#endif
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,
- "Invalid spm algo supplied "
+ SCLogError("Invalid spm algo supplied "
"in the yaml conf file: \"%s\"",
- spm_algo);
+ spm_algo);
exit(EXIT_FAILURE);
}
StorageList *list = storage_list;
while (list) {
if (strcmp(name, list->map.name) == 0 && type == list->map.type) {
- SCLogError(SC_EINVAL,
- "storage for type \"%s\" with "
- "name \"%s\" already registered",
+ SCLogError("storage for type \"%s\" with "
+ "name \"%s\" already registered",
StoragePrintType(type), name);
return -1;
}
DEBUG_VALIDATE_BUG_ON(sb->buf_size > BIT_U32(30));
if (size > BIT_U32(30)) { // 1GiB
if (!g2s_warn_once) {
- SCLogWarning(SC_ENOMEM,
+ SCLogWarning(
"StreamingBuffer::GrowToSize() tried to alloc %u bytes, exceeds limit of %lu",
size, BIT_U32(30));
g2s_warn_once = true;
uint32_t grow = sb->buf_size * 2;
if (grow > BIT_U32(30)) { // 1GiB
if (!grow_warn_once) {
- SCLogWarning(SC_ENOMEM,
- "StreamingBuffer::Grow() tried to alloc %u bytes, exceeds limit of %lu", grow,
- BIT_U32(30));
+ SCLogWarning("StreamingBuffer::Grow() tried to alloc %u bytes, exceeds limit of %lu",
+ grow, BIT_U32(30));
grow_warn_once = true;
}
return -1;
char sentence[64];
if (!path || strlen(path) > SYSFS_MAX_FILENAME_SIZE) {
- SCLogWarning(SC_ERR_ARG_LEN_LONG, "File path too long, max allowed: %d",
- SYSFS_MAX_FILENAME_SIZE);
+ SCLogWarning("File path too long, max allowed: %d", SYSFS_MAX_FILENAME_SIZE);
SCReturnInt(TM_ECODE_FAILED);
}
/* File must be present and process have correct capabilities to open */
int fd = open(fname, O_WRONLY);
if (fd < 0) {
- SCLogError(SC_ERR_FOPEN, "Could not open file: %s", fname);
+ SCLogError("Could not open file: %s", fname);
SCReturnInt(TM_ECODE_FAILED);
}
ssize_t len = strlen(sentence);
if (write(fd, sentence, len) != len) {
- SCLogError(SC_ERR_FWRITE, "Could not write to file: %s", fname);
+ SCLogError("Could not write to file: %s", fname);
close(fd);
SCReturnInt(TM_ECODE_FAILED);
}
{
THashDataQueue *q = (THashDataQueue *)SCMalloc(sizeof(THashDataQueue));
if (q == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in THashDataQueueNew. Exiting...");
+ SCLogError("Fatal error encountered in THashDataQueueNew. Exiting...");
exit(EXIT_SUCCESS);
}
q = THashDataQueueInit(q);
if ((ConfGet(varname, &conf_val)) == 1)
{
if (ParseSizeStringU64(conf_val, &ctx->config.memcap) < 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error parsing %s "
+ SCLogError("Error parsing %s "
"from conf file - %s. Killing engine",
- varname, conf_val);
+ varname, conf_val);
return -1;
}
}
/* alloc hash memory */
uint64_t hash_size = ctx->config.hash_size * sizeof(THashHashRow);
if (!(THASH_CHECK_MEMCAP(ctx, hash_size))) {
- SCLogError(SC_ERR_THASH_INIT, "allocating hash failed: "
- "max hash memcap is smaller than projected hash size. "
- "Memcap: %"PRIu64", Hash table size %"PRIu64". Calculate "
- "total hash size by multiplying \"hash-size\" with %"PRIuMAX", "
- "which is the hash bucket size.", ctx->config.memcap, hash_size,
- (uintmax_t)sizeof(THashHashRow));
+ SCLogError("allocating hash failed: "
+ "max hash memcap is smaller than projected hash size. "
+ "Memcap: %" PRIu64 ", Hash table size %" PRIu64 ". Calculate "
+ "total hash size by multiplying \"hash-size\" with %" PRIuMAX ", "
+ "which is the hash bucket size.",
+ ctx->config.memcap, hash_size, (uintmax_t)sizeof(THashHashRow));
return -1;
}
ctx->array = SCMallocAligned(ctx->config.hash_size * sizeof(THashHashRow), CLS);
if (unlikely(ctx->array == NULL)) {
- SCLogError(SC_ERR_THASH_INIT, "Fatal error encountered in THashInitConfig. Exiting...");
+ SCLogError("Fatal error encountered in THashInitConfig. Exiting...");
return -1;
}
memset(ctx->array, 0, ctx->config.hash_size * sizeof(THashHashRow));
/* pre allocate prealloc */
for (i = 0; i < ctx->config.prealloc; i++) {
if (!(THASH_CHECK_MEMCAP(ctx, THASH_DATA_SIZE(ctx)))) {
- SCLogError(SC_ERR_THASH_INIT, "preallocating data failed: "
- "max thash memcap reached. Memcap %"PRIu64", "
- "Memuse %"PRIu64".", ctx->config.memcap,
+ SCLogError("preallocating data failed: "
+ "max thash memcap reached. Memcap %" PRIu64 ", "
+ "Memuse %" PRIu64 ".",
+ ctx->config.memcap,
((uint64_t)SC_ATOMIC_GET(ctx->memuse) + THASH_DATA_SIZE(ctx)));
return -1;
}
THashData *h = THashDataAlloc(ctx);
if (h == NULL) {
- SCLogError(SC_ERR_THASH_INIT, "preallocating data failed: %s", strerror(errno));
+ SCLogError("preallocating data failed: %s", strerror(errno));
return -1;
}
THashDataEnqueue(&ctx->spare_q,h);
(PCRE2_SPTR8)DETECT_BASE_REGEX, PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
if (regex_base == NULL) {
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- FatalError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ FatalError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
DETECT_BASE_REGEX, (int)eo, errbuffer);
}
regex_base_match = pcre2_match_data_create_from_pattern(regex_base, NULL);
(PCRE2_SPTR8)DETECT_THRESHOLD_REGEX, PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
if (regex_threshold == NULL) {
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- FatalError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ FatalError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
DETECT_THRESHOLD_REGEX, (int)eo, errbuffer);
}
regex_threshold_match = pcre2_match_data_create_from_pattern(regex_threshold, NULL);
(PCRE2_SPTR8)DETECT_RATE_REGEX, PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
if (regex_rate == NULL) {
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- FatalError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ FatalError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
DETECT_RATE_REGEX, (int)eo, errbuffer);
}
regex_rate_match = pcre2_match_data_create_from_pattern(regex_rate, NULL);
(PCRE2_SPTR8)DETECT_SUPPRESS_REGEX, PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
if (regex_suppress == NULL) {
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- FatalError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ FatalError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
DETECT_SUPPRESS_REGEX, (int)eo, errbuffer);
}
regex_suppress_match = pcre2_match_data_create_from_pattern(regex_suppress, NULL);
#endif
filename = SCThresholdConfGetConfFilename(de_ctx);
if ( (fd = fopen(filename, "r")) == NULL) {
- SCLogWarning(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno));
+ SCLogWarning("Error opening file: \"%s\": %s", filename, strerror(errno));
goto error;
}
#ifdef UNITTESTS
#endif
if (SCThresholdConfParseFile(de_ctx, fd) < 0) {
- SCLogWarning(
- SC_WARN_THRESH_CONFIG, "Error loading threshold configuration from %s", filename);
+ SCLogWarning("Error loading threshold configuration from %s", filename);
/* maintain legacy behavior so no errors unless config testing */
if (RunmodeGetCurrent() == RUNMODE_CONF_TEST) {
ret = -1;
orig_de->timeout = parsed_timeout;
if (DetectAddressParse((const DetectEngineCtx *)de_ctx, &orig_de->addrs, (char *)th_ip) <
0) {
- SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "failed to parse %s", th_ip);
+ SCLogError("failed to parse %s", th_ip);
goto error;
}
}
/* Install it */
if (id == 0 && gid == 0) {
if (parsed_track == TRACK_RULE) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "suppressing all rules");
+ SCLogWarning("suppressing all rules");
}
/* update each sig with our suppress info */
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
}
} else if (id == 0 && gid > 0) {
if (parsed_track == TRACK_RULE) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "suppressing all rules with gid %"PRIu32, gid);
+ SCLogWarning("suppressing all rules with gid %" PRIu32, gid);
}
/* set up suppression for each signature with a matching gid */
for (s = de_ctx->sig_list; s != NULL; s = s->next) {
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_SUPPRESS);
}
} else if (id > 0 && gid == 0) {
- SCLogError(SC_EINVAL, "Can't use a event config that has "
- "sid > 0 and gid == 0. Please fix this "
- "in your threshold.config file");
+ SCLogError("Can't use a event config that has "
+ "sid > 0 and gid == 0. Please fix this "
+ "in your threshold.config file");
goto error;
} else {
s = SigFindSignatureBySidGid(de_ctx, id, gid);
if (s == NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "can't suppress sid "
- "%"PRIu32", gid %"PRIu32": unknown rule", id, gid);
+ SCLogWarning("can't suppress sid "
+ "%" PRIu32 ", gid %" PRIu32 ": unknown rule",
+ id, gid);
} else {
if (parsed_track == TRACK_RULE) {
s->flags |= SIG_FLAG_NOALERT;
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
sm = DetectGetLastSMByListId(s,
DETECT_SM_LIST_THRESHOLD, DETECT_THRESHOLD, -1);
if (sm != NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "signature sid:%"PRIu32 " has "
- "an event var set. The signature event var is "
- "given precedence over the threshold.conf one. "
- "We'll change this in the future though.", s->id);
+ SCLogWarning("signature sid:%" PRIu32 " has "
+ "an event var set. The signature event var is "
+ "given precedence over the threshold.conf one. "
+ "We'll change this in the future though.",
+ s->id);
continue;
}
sm = DetectGetLastSMByListId(s,
DETECT_SM_LIST_THRESHOLD, DETECT_DETECTION_FILTER, -1);
if (sm != NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "signature sid:%"PRIu32 " has "
- "an event var set. The signature event var is "
- "given precedence over the threshold.conf one. "
- "We'll change this in the future though.", s->id);
+ SCLogWarning("signature sid:%" PRIu32 " has "
+ "an event var set. The signature event var is "
+ "given precedence over the threshold.conf one. "
+ "We'll change this in the future though.",
+ s->id);
continue;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
sm = DetectGetLastSMByListId(s, DETECT_SM_LIST_THRESHOLD,
DETECT_THRESHOLD, DETECT_DETECTION_FILTER, -1);
if (sm != NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "signature sid:%"PRIu32 " has "
- "an event var set. The signature event var is "
- "given precedence over the threshold.conf one. "
- "We'll change this in the future though.", id);
+ SCLogWarning("signature sid:%" PRIu32 " has "
+ "an event var set. The signature event var is "
+ "given precedence over the threshold.conf one. "
+ "We'll change this in the future though.",
+ id);
continue;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
}
}
} else if (id > 0 && gid == 0) {
- SCLogError(SC_EINVAL, "Can't use a event config that has "
- "sid > 0 and gid == 0. Please fix this "
- "in your threshold.conf file");
+ SCLogError("Can't use a event config that has "
+ "sid > 0 and gid == 0. Please fix this "
+ "in your threshold.conf file");
} else {
s = SigFindSignatureBySidGid(de_ctx, id, gid);
if (s == NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "can't suppress sid "
- "%"PRIu32", gid %"PRIu32": unknown rule", id, gid);
+ SCLogWarning("can't suppress sid "
+ "%" PRIu32 ", gid %" PRIu32 ": unknown rule",
+ id, gid);
} else {
if (parsed_type != TYPE_SUPPRESS && parsed_type != TYPE_THRESHOLD &&
parsed_type != TYPE_BOTH && parsed_type != TYPE_LIMIT)
sm = DetectGetLastSMByListId(s,
DETECT_SM_LIST_THRESHOLD, DETECT_THRESHOLD, -1);
if (sm != NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "signature sid:%"PRIu32 " has "
- "a threshold set. The signature event var is "
- "given precedence over the threshold.conf one. "
- "Bug #425.", s->id);
+ SCLogWarning("signature sid:%" PRIu32 " has "
+ "a threshold set. The signature event var is "
+ "given precedence over the threshold.conf one. "
+ "Bug #425.",
+ s->id);
goto end;
}
sm = DetectGetLastSMByListId(s, DETECT_SM_LIST_THRESHOLD,
DETECT_DETECTION_FILTER, -1);
if (sm != NULL) {
- SCLogWarning(SC_ERR_EVENT_ENGINE, "signature sid:%"PRIu32 " has "
- "a detection_filter set. The signature event var is "
- "given precedence over the threshold.conf one. "
- "Bug #425.", s->id);
+ SCLogWarning("signature sid:%" PRIu32 " has "
+ "a detection_filter set. The signature event var is "
+ "given precedence over the threshold.conf one. "
+ "Bug #425.",
+ s->id);
goto end;
}
sm = SigMatchAlloc();
if (sm == NULL) {
- SCLogError(SC_ENOMEM, "Error allocating SigMatch");
+ SCLogError("Error allocating SigMatch");
goto error;
}
ret = pcre2_match(
regex_base, (PCRE2_SPTR8)rawstr, strlen(rawstr), 0, 0, regex_base_match, NULL);
if (ret < 4) {
- SCLogError(SC_ERR_PCRE_MATCH, "pcre2_match parse error, ret %" PRId32 ", string %s", ret,
- rawstr);
+ SCLogError("pcre2_match parse error, ret %" PRId32 ", string %s", ret, rawstr);
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_base_match, 1, (PCRE2_UCHAR8 *)th_rule_type, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
copylen = sizeof(th_gid);
ret = pcre2_substring_copy_bynumber(regex_base_match, 2, (PCRE2_UCHAR8 *)th_gid, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
copylen = sizeof(th_sid);
ret = pcre2_substring_copy_bynumber(regex_base_match, 3, (PCRE2_UCHAR8 *)th_sid, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_get_bynumber(
regex_base_match, 4, (PCRE2_UCHAR8 **)&rule_extend, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
} else if (strcasecmp(th_rule_type,"suppress") == 0) {
rule_type = THRESHOLD_TYPE_SUPPRESS;
} else {
- SCLogError(SC_EINVAL, "rule type %s is unknown", th_rule_type);
+ SCLogError("rule type %s is unknown", th_rule_type);
goto error;
}
ret = pcre2_match(regex_threshold, (PCRE2_SPTR8)rule_extend, strlen(rule_extend), 0,
0, regex_threshold_match, NULL);
if (ret < 4) {
- SCLogError(SC_ERR_PCRE_MATCH,
- "pcre2_match parse error, ret %" PRId32 ", string %s", ret,
+ SCLogError("pcre2_match parse error, ret %" PRId32 ", string %s", ret,
rule_extend);
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_threshold_match, 1, (PCRE2_UCHAR8 *)th_type, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_threshold_match, 2, (PCRE2_UCHAR8 *)th_track, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_threshold_match, 3, (PCRE2_UCHAR8 *)th_count, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_threshold_match, 4, (PCRE2_UCHAR8 *)th_seconds, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
else if (strcasecmp(th_type,"threshold") == 0)
parsed_type = TYPE_THRESHOLD;
else {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "limit type not supported: %s", th_type);
+ SCLogError("limit type not supported: %s", th_type);
goto error;
}
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "rule invalid: %s", rawstr);
+ SCLogError("rule invalid: %s", rawstr);
goto error;
}
break;
ret = pcre2_match(regex_suppress, (PCRE2_SPTR8)rule_extend, strlen(rule_extend), 0,
0, regex_suppress_match, NULL);
if (ret < 2) {
- SCLogError(SC_ERR_PCRE_MATCH,
- "pcre2_match parse error, ret %" PRId32 ", string %s", ret,
+ SCLogError("pcre2_match parse error, ret %" PRId32 ", string %s", ret,
rule_extend);
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_suppress_match, 1, (PCRE2_UCHAR8 *)th_track, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
/* retrieve the IP; use "get" for heap allocation */
ret = pcre2_substring_get_bynumber(
regex_suppress_match, 2, (PCRE2_UCHAR8 **)&th_ip, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
+ SCLogError("pcre2_substring_get_bynumber failed");
goto error;
}
} else {
ret = pcre2_match(regex_rate, (PCRE2_SPTR8)rule_extend, strlen(rule_extend), 0, 0,
regex_rate_match, NULL);
if (ret < 5) {
- SCLogError(SC_ERR_PCRE_MATCH,
- "pcre2_match parse error, ret %" PRId32 ", string %s", ret,
+ SCLogError("pcre2_match parse error, ret %" PRId32 ", string %s", ret,
rule_extend);
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_rate_match, 1, (PCRE2_UCHAR8 *)th_track, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_rate_match, 2, (PCRE2_UCHAR8 *)th_count, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_rate_match, 3, (PCRE2_UCHAR8 *)th_seconds, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_rate_match, 4, (PCRE2_UCHAR8 *)th_new_action, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
ret = pcre2_substring_copy_bynumber(
regex_rate_match, 5, (PCRE2_UCHAR8 *)th_timeout, ©len);
if (ret < 0) {
- SCLogError(SC_ERR_PCRE_COPY_SUBSTRING, "pcre2_substring_copy_bynumber failed");
+ SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
}
parsed_type = TYPE_RATE;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "rule invalid: %s", rawstr);
+ SCLogError("rule invalid: %s", rawstr);
goto error;
}
break;
else if (strcasecmp(th_track,"by_rule") == 0)
parsed_track = TRACK_RULE;
else {
- SCLogError(SC_EINVAL, "Invalid track parameter %s in %s", th_track, rawstr);
+ SCLogError("Invalid track parameter %s in %s", th_track, rawstr);
goto error;
}
goto error;
}
if (parsed_count == 0) {
- SCLogError(SC_EINVAL, "rate filter count should be > 0");
+ SCLogError("rate filter count should be > 0");
goto error;
}
parsed_track = TRACK_EITHER;
}
else {
- SCLogError(
- SC_EINVAL, "Invalid track parameter %s in %s", th_track, rule_extend);
+ SCLogError("Invalid track parameter %s in %s", th_track, rule_extend);
goto error;
}
}
DecodeThreadVars dtv;
ThreadVars th_v;
if (raw_eth == NULL || pktsize == NULL || numpkts <= 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "The arrays cant be null, and the number"
- " of packets should be grater thatn zero");
+ SCLogError("The arrays cant be null, and the number"
+ " of packets should be grater thatn zero");
return NULL;
}
Packet **p = NULL;
int result = 0;
if (pkt == NULL || sigs == NULL || numpkts == 0
|| sids == NULL || results == NULL || numsigs == 0) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Arguments invalid, that the pointer/arrays are not NULL, and the number of signatures and packets is > 0");
+ SCLogError("Arguments invalid, that the pointer/arrays are not NULL, and the number of "
+ "signatures and packets is > 0");
goto end;
}
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
uint32_t results[], int numsids)
{
if (p == NULL || sids == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Arguments invalid, check if the "
- "packet is NULL, and if the array contain sids is set");
+ SCLogError("Arguments invalid, check if the "
+ "packet is NULL, and if the array contain sids is set");
return 0;
}
for (int i = 0; i < numsigs; i++) {
if (sigs[i] == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Check the signature"
- " at position %d", i);
+ SCLogError("Check the signature"
+ " at position %d",
+ i);
return 0;
}
Signature *s = DetectEngineAppendSig(de_ctx, sigs[i]);
if (s == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Check the signature at"
- " position %d (%s)", i, sigs[i]);
+ SCLogError("Check the signature at"
+ " position %d (%s)",
+ i, sigs[i]);
return 0;
}
}
{
PCRE2_UCHAR errbuffer[256];
pcre2_get_error_message(en, errbuffer, sizeof(errbuffer));
- SCLogError(SC_ERR_PCRE_COMPILE,
- "pcre2 compile of \"%s\" failed at "
- "offset %d: %s",
+ SCLogError("pcre2 compile of \"%s\" failed at "
+ "offset %d: %s",
regex_arg, (int)eo, errbuffer);
goto error;
}
/* mark service as stopped */
if (!SetServiceStatus(service_status_handle, &status)) {
- SCLogWarning(SC_ERR_SVC, "Can't set service status: %d", (int)GetLastError());
+ SCLogWarning("Can't set service status: %d", (int)GetLastError());
} else {
SCLogInfo("Service status set to: SERVICE_STOPPED");
}
/* mark service as stop pending */
if (!SetServiceStatus(service_status_handle, &status)) {
- SCLogWarning(SC_ERR_SVC, "Can't set service status: %d", (int)GetLastError());
+ SCLogWarning("Can't set service status: %d", (int)GetLastError());
} else {
SCLogInfo("Service status set to: SERVICE_STOP_PENDING");
}
};
if ((service_status_handle = RegisterServiceCtrlHandlerEx((char *)PROG_NAME, SCServiceCtrlHandlerEx, NULL)) == (SERVICE_STATUS_HANDLE)0) {
- SCLogError(SC_ERR_SVC, "Can't register service control handler: %d", (int)GetLastError());
+ SCLogError("Can't register service control handler: %d", (int)GetLastError());
return;
}
/* register exit handler */
if (atexit(SCAtExitHandler)) {
- SCLogWarning(SC_ERR_SVC, "Can't register exit handler: %d", (int)GetLastError());
+ SCLogWarning("Can't register exit handler: %d", (int)GetLastError());
}
/* mark service as running immediately */
if (!SetServiceStatus(service_status_handle, &status)) {
- SCLogWarning(SC_ERR_SVC, "Can't set service status: %d", (int)GetLastError());
+ SCLogWarning("Can't set service status: %d", (int)GetLastError());
} else {
SCLogInfo("Service status set to: SERVICE_RUNNING");
}
status.dwCurrentState = SERVICE_STOPPED;
if (!SetServiceStatus(service_status_handle, &status)) {
- SCLogWarning(SC_ERR_SVC, "Can't set service status: %d", (int)GetLastError());
+ SCLogWarning("Can't set service status: %d", (int)GetLastError());
} else {
SCLogInfo("Service status set to: SERVICE_STOPPED");
}
/* continue with suricata initialization */
if (service_initialized) {
- SCLogWarning(SC_ERR_SVC, "Service is already initialized.");
+ SCLogWarning("Service is already initialized.");
return 0;
}
memset(path, 0, sizeof(path));
if (GetModuleFileName(NULL, path, MAX_PATH) == 0 ){
- SCLogError(SC_ERR_SVC, "Can't get path to service binary: %d", (int)GetLastError());
+ SCLogError("Can't get path to service binary: %d", (int)GetLastError());
break;
}
}
if ((scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) {
- SCLogError(SC_ERR_SVC, "Can't open SCM: %d", (int)GetLastError());
+ SCLogError("Can't open SCM: %d", (int)GetLastError());
break;
}
NULL);
if (service == NULL) {
- SCLogError(SC_ERR_SVC, "Can't create service: %d", (int)GetLastError());
+ SCLogError("Can't create service: %d", (int)GetLastError());
break;
}
do {
if ((scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) {
- SCLogError(SC_ERR_SVC, "Can't open SCM: %d", (int)GetLastError());
+ SCLogError("Can't open SCM: %d", (int)GetLastError());
break;
}
if ((service = OpenService(scm, PROG_NAME, SERVICE_ALL_ACCESS)) == NULL) {
- SCLogError(SC_ERR_SVC, "Can't open service: %d", (int)GetLastError());
+ SCLogError("Can't open service: %d", (int)GetLastError());
break;
}
if (!QueryServiceStatus(service, &status)) {
- SCLogError(SC_ERR_SVC, "Can't query service status: %d", (int)GetLastError());
+ SCLogError("Can't query service status: %d", (int)GetLastError());
break;
}
if (status.dwCurrentState != SERVICE_STOPPED) {
- SCLogError(SC_ERR_SVC, "Service isn't in stopped state: %d", (int)GetLastError());
+ SCLogError("Service isn't in stopped state: %d", (int)GetLastError());
break;
}
if (!DeleteService(service)) {
- SCLogError(SC_ERR_SVC, "Can't delete service: %d", (int)GetLastError());
+ SCLogError("Can't delete service: %d", (int)GetLastError());
break;
}
memset(path, 0, sizeof(path));
if (GetModuleFileName(NULL, path, MAX_PATH) == 0 ){
- SCLogError(SC_ERR_SVC, "Can't get path to service binary: %d", (int)GetLastError());
+ SCLogError("Can't get path to service binary: %d", (int)GetLastError());
break;
}
}
if ((scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) {
- SCLogError(SC_ERR_SVC, "Can't open SCM: %d", (int)GetLastError());
+ SCLogError("Can't open SCM: %d", (int)GetLastError());
break;
}
if ((service = OpenService(scm, PROG_NAME, SERVICE_ALL_ACCESS)) == NULL) {
- SCLogError(SC_ERR_SVC, "Can't open service: %d", (int)GetLastError());
+ SCLogError("Can't open service: %d", (int)GetLastError());
break;
}
NULL,
PROG_NAME))
{
- SCLogError(SC_ERR_SVC, "Can't change service configuration: %d", (int)GetLastError());
+ SCLogError("Can't change service configuration: %d", (int)GetLastError());
break;
}
int GetIfaceOffloadingWin32(const char *ifname, int csum, int other)
{
- SCLogWarning(SC_ERR_SYSCALL, "Suricata not targeted for Windows Vista or "
- "higher. Network offload interrogation not "
- "available.");
+ SCLogWarning("Suricata not targeted for Windows Vista or "
+ "higher. Network offload interrogation not "
+ "available.");
return -1;
}
int DisableIfaceOffloadingWin32(LiveDevice *ldev, int csum, int other)
{
- SCLogWarning(SC_ERR_SYSCALL, "Suricata not targeted for Windows Vista or "
- "higher. Network offload interrogation not "
- "available.");
+ SCLogWarning("Suricata not targeted for Windows Vista or "
+ "higher. Network offload interrogation not "
+ "available.");
return -1;
}
int RestoreIfaceOffloadingWin32(LiveDevice *ldev)
{
- SCLogWarning(SC_ERR_SYSCALL, "Suricata not targeted for Windows Vista or "
- "higher. Network offload interrogation not "
- "available.");
+ SCLogWarning("Suricata not targeted for Windows Vista or "
+ "higher. Network offload interrogation not "
+ "available.");
return -1;
}
if (err != S_OK) {
const char *errbuf = Win32GetErrorString(err, WmiUtils());
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to get MTU via syscall for '%s': %s "
+ SCLogWarning("Failure when trying to get MTU via syscall for '%s': %s "
"(0x%08" PRIx32 ")",
- pcap_dev, errbuf, (uint32_t)err);
+ pcap_dev, errbuf, (uint32_t)err);
LocalFree((LPVOID)errbuf);
} else {
SCLogInfo("Found an MTU of %d for '%s'", mtu, pcap_dev);
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, 0, (LPTSTR)&errbuf, 0, NULL);
- SCLogWarning(
- SC_ERR_SYSCALL,
- "Failure when trying to get global MTU via syscall: %s (%" PRId32
- ")",
- errbuf, (uint32_t)err);
+ SCLogWarning("Failure when trying to get global MTU via syscall: %s (%" PRId32 ")", errbuf,
+ (uint32_t)err);
return -1;
}
BSTR resource_bstr = SysAllocString(resource);
if (resource_bstr == NULL) {
hr = HRESULT_FROM_WIN32(E_OUTOFMEMORY);
- SCLogWarning(SC_ERR_SYSCALL, "Failed to allocate BSTR");
+ SCLogWarning("Failed to allocate BSTR");
goto release;
}
hr = S_OK;
} else {
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "COM CoInitializeEx failed: 0x%" PRIx32, (uint32_t)hr);
+ SCLogWarning("COM CoInitializeEx failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
hr = CoInitializeSecurity(
NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "COM CoInitializeSecurity failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("COM CoInitializeSecurity failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
}
hr = CoCreateInstance(&CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER,
&IID_IWbemLocator, (LPVOID *)&instance->locator);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL, "COM CoCreateInstance failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("COM CoCreateInstance failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
hr = instance->locator->lpVtbl->ConnectServer(
instance->locator, resource_bstr, NULL, NULL, NULL, 0, NULL, NULL,
&instance->services);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL, "COM ConnectServer failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("COM ConnectServer failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
name_bstr = SysAllocString(name);
if (name_bstr == NULL) {
hr = HRESULT_FROM_WIN32(E_OUTOFMEMORY);
- SCLogWarning(SC_ERR_SYSCALL, "Failed to allocate BSTR");
+ SCLogWarning("Failed to allocate BSTR");
goto release;
}
NULL, p_class, NULL);
if (hr != S_OK) {
WbemLogDebug(hr);
- SCLogWarning(SC_ERR_SYSCALL, "WMI GetObject failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI GetObject failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
hr = class->lpVtbl->SpawnInstance(class, 0, p_instance);
if (hr != WBEM_S_NO_ERROR) {
WbemLogDebug(hr);
- SCLogWarning(SC_ERR_SYSCALL, "WMI SpawnInstance failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI SpawnInstance failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
BSTR class_name_bstr = SysAllocString(class_name);
if (class_name_bstr == NULL) {
hr = HRESULT_FROM_WIN32(E_OUTOFMEMORY);
- SCLogWarning(SC_ERR_SYSCALL, "Failed to allocate BSTR");
+ SCLogWarning("Failed to allocate BSTR");
goto release;
}
method->method_name = SysAllocString(method_name);
if (method->method_name == NULL) {
hr = HRESULT_FROM_WIN32(E_OUTOFMEMORY);
- SCLogWarning(SC_ERR_SYSCALL, "Failed to allocate BSTR");
+ SCLogWarning("Failed to allocate BSTR");
goto release;
}
&method->out_params);
if (hr != WBEM_S_NO_ERROR) {
WbemLogDebug(hr);
- SCLogWarning(SC_ERR_SYSCALL, "WMI GetMethod failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI GetMethod failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
call->instance_path = SysAllocString(instance_path);
if (call->instance_path == NULL) {
hr = HRESULT_FROM_WIN32(E_OUTOFMEMORY);
- SCLogWarning(SC_ERR_SYSCALL, "Failed to allocate BSTR: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("Failed to allocate BSTR: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
&call->in_params);
if (hr != S_OK) {
WbemLogDebug(hr);
- SCLogWarning(SC_ERR_SYSCALL,
- "WMI SpawnInstance failed on in_params: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI SpawnInstance failed on in_params: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
hr = unknown->lpVtbl->QueryInterface(unknown, &IID_IWbemClassObject,
(void **)sub_object);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "WMI QueryInterface (IWbemClassObject) failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI QueryInterface (IWbemClassObject) failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
hr = object->lpVtbl->QueryInterface(object, &IID_IUnknown,
(void **)p_unknown);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "WMI QueryInterface (IUnknown) failed: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("WMI QueryInterface (IUnknown) failed: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
IWbemClassObject *ndis_offload = NULL;
if (if_description == NULL) {
- SCLogWarning(SC_ERR_SYSCALL, "No description specified for device");
+ SCLogWarning("No description specified for device");
hr = HRESULT_FROM_WIN32(E_INVALIDARG);
goto release;
}
wcslen(instance_name_fmt);
LPWSTR instance_name = SCMalloc((n_chars + 1) * sizeof(wchar_t));
if (instance_name == NULL) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to allocate buffer for instance path");
+ SCLogWarning("Failed to allocate buffer for instance path");
goto release;
}
instance_name[n_chars] = 0; /* defensively null-terminate */
hr = StringCchPrintfW(instance_name, n_chars, instance_name_fmt, class_name,
if_description);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to format WMI class instance name: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("Failed to format WMI class instance name: 0x%" PRIx32, (uint32_t)hr);
goto release;
}
/* method name */
size_t if_description_len = wcslen(if_description);
char *if_description_ansi = SCMalloc(if_description_len + 1);
if (if_description_ansi == NULL) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to allocate buffer for interface description");
+ SCLogWarning("Failed to allocate buffer for interface description");
goto release;
}
if_description_ansi[if_description_len] = 0;
(offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP4) != 0,
(offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP6) != 0);
} else {
- SCLogWarning(SC_ERR_NIC_OFFLOADING,
- "NIC offloading on %s: Checksum IPv4 Rx: %d Tx: %d IPv6 "
+ SCLogWarning("NIC offloading on %s: Checksum IPv4 Rx: %d Tx: %d IPv6 "
"Rx: %d Tx: %d LSOv1 IPv4: %d LSOv2 IPv4: %d IPv6: %d",
- pcap_dev,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP4RX) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP4TX) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP6RX) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP6TX) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV1_IP4) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP4) != 0,
- (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP6) != 0);
+ pcap_dev, (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP4RX) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP4TX) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP6RX) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_CSUM_IP6TX) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV1_IP4) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP4) != 0,
+ (offload_flags & WIN32_TCP_OFFLOAD_FLAG_LSOV2_IP6) != 0);
}
release:
if (ret == -1) {
const char *err_str = Win32GetErrorString(err, WmiUtils());
- SCLogWarning(SC_ERR_SYSCALL,
- "Failure when trying to get feature via syscall for '%s': "
+ SCLogWarning("Failure when trying to get feature via syscall for '%s': "
"%s (0x%08" PRIx32 ")",
- pcap_dev, err_str, (uint32_t)err);
+ pcap_dev, err_str, (uint32_t)err);
LocalFree((LPVOID)err_str);
}
IWbemClassObject *ndis_tcp_offload_parameters = NULL;
if (if_description == NULL) {
- SCLogWarning(SC_ERR_SYSCALL, "No description specified for device");
+ SCLogWarning("No description specified for device");
return E_INVALIDARG;
}
wcslen(instance_name_fmt);
LPWSTR instance_name = SCMalloc((n_chars + 1) * sizeof(wchar_t));
if (instance_name == NULL) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to allocate buffer for instance path");
+ SCLogWarning("Failed to allocate buffer for instance path");
goto release;
}
instance_name[n_chars] = 0; /* defensively null-terminate */
hr = StringCchPrintfW(instance_name, n_chars, instance_name_fmt, class_name,
if_description);
if (hr != S_OK) {
- SCLogWarning(SC_ERR_SYSCALL,
- "Failed to format WMI class instance name: 0x%" PRIx32,
- (uint32_t)hr);
+ SCLogWarning("Failed to format WMI class instance name: 0x%" PRIx32, (uint32_t)hr);
goto release;
}