r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
alproto_name, ".detection-ports");
if (r < 0) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "Unable to alloc SpmGlobalThreadCtx.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
}
node = ConfGetNode(param);
exit(EXIT_FAILURE);
}
if (limit == 0) {
- SCLogError(SC_ERR_SIZE_PARSE, "Error meta-field-limit "
+ FatalError(SC_ERR_FATAL, "Error meta-field-limit "
"from conf file cannot be 0. Killing engine");
- exit(EXIT_FAILURE);
}
/* set default soft-limit with our new hard limit */
htp_config_set_field_limits(cfg_prec->cfg,
/* Default Config */
cfglist.cfg = htp_config_create();
if (NULL == cfglist.cfg) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to create HTP default config");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to create HTP server config");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to create HTP server config");
}
HTPConfigSetDefaultsPhase1(htprec);
r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
alproto_name, ".enabled");
if (r < 0) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "snprintf failure.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "snprintf failure.");
} else if (r > (int)sizeof(param)) {
- SCLogError(SC_ERR_FATAL, "buffer not big enough to write param.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "buffer not big enough to write param.");
}
node = ConfGetNode(param);
if (ep == NULL) {
conf_dirname = SCStrdup(".");
if (conf_dirname == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "ERROR: Failed to allocate memory while loading configuration.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "ERROR: Failed to allocate memory while loading configuration.");
}
}
else {
conf_dirname = SCStrdup(filename);
if (conf_dirname == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "ERROR: Failed to allocate memory while loading configuration.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "ERROR: Failed to allocate memory while loading configuration.");
}
conf_dirname[ep - filename] = '\0';
}
}
root = ConfNodeNew();
if (root == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "ERROR: Failed to allocate memory for root configuration node, "
- "aborting.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "ERROR: Failed to allocate memory for root configuration node, "
+ "aborting.");
}
SCLogDebug("configuration module initialized");
}
/* init the lock used by StatsThreadStore */
if (SCMutexInit(&stats_ctx->sts_lock, NULL) != 0) {
- SCLogError(SC_ERR_INITIALIZATION, "error initializing sts mutex");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "error initializing sts mutex");
}
if (stats_enabled && !OutputStatsLoggersRegistered()) {
{
BUG_ON(stats_ctx != NULL);
if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in StatsInitCtx. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_THREAD_CREATE, "TmThreadCreateMgmtThread "
+ FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread "
"failed");
- exit(EXIT_FAILURE);
}
if (TmThreadSpawn(tv_wakeup) != 0) {
- SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
"StatsWakeupThread");
- exit(EXIT_FAILURE);
}
/* spawn the stats mgmt thread */
tv_mgmt = TmThreadCreateMgmtThread(thread_name_counter_stats,
StatsMgmtThread, 1);
if (tv_mgmt == NULL) {
- SCLogError(SC_ERR_THREAD_CREATE,
- "TmThreadCreateMgmtThread failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadCreateMgmtThread failed");
}
if (TmThreadSpawn(tv_mgmt) != 0) {
- SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed for "
"StatsWakeupThread");
- exit(EXIT_FAILURE);
}
SCReturn;
uint64_t *user_data = NULL;
if ( (user_data = SCMalloc(sizeof(uint64_t))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
}
*user_data = timeout;
defrag_tree = SCRadixCreateRadixTree(DefragPolicyFreeUserData, NULL);
if (defrag_tree == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Can't alloc memory for the defrag config tree.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Can't alloc memory for the defrag config tree.");
}
ConfNode *server_config = ConfGetNode("defrag.host-config");
}
defragtracker_hash = SCCalloc(defrag_config.hash_size, sizeof(DefragTrackerHashRow));
if (unlikely(defragtracker_hash == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
}
memset(defragtracker_hash, 0, defrag_config.hash_size * sizeof(DefragTrackerHashRow));
sizeof(Frag),
NULL, DefragFragInit, dc, NULL, NULL);
if (dc->frag_pool == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Defrag: Failed to initialize fragment pool.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Defrag: Failed to initialize fragment pool.");
}
if (SCMutexInit(&dc->frag_pool_lock, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Defrag: Failed to initialize frag pool mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Defrag: Failed to initialize frag pool mutex.");
}
/* Set the default timeout. */
}
else {
if (timeout < TIMEOUT_MIN) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "defrag: Timeout less than minimum allowed value.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "defrag: Timeout less than minimum allowed value.");
}
else if (timeout > TIMEOUT_MAX) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "defrag: Tiemout greater than maximum allowed value.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "defrag: Tiemout greater than maximum allowed value.");
}
dc->timeout = timeout;
}
/* Allocate the DefragContext. */
defrag_context = DefragContextNew();
if (defrag_context == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for the Defrag module.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate memory for the Defrag module.");
}
DefragSetDefaultTimeout(defrag_context->timeout);
uint16_t patlen = fp_cd->content_len;
uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
if (unlikely(pat == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memcpy(pat, fp_cd->content, fp_cd->content_len);
pat[fp_cd->content_len] = '\0';
uint16_t patlen = fp_cd->content_len;
uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
if (unlikely(pat == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memcpy(pat, fp_cd->content, fp_cd->content_len);
pat[fp_cd->content_len] = '\0';
const DetectContentData *cd = (const DetectContentData *)smd->ctx;
uint8_t *pat = SCMalloc(cd->content_len + 1);
if (unlikely(pat == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memcpy(pat, cd->content, cd->content_len);
pat[cd->content_len] = '\0';
SigInitStandardMpmFactoryContexts(de_ctx);
if (SigAddressPrepareStage1(de_ctx) != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
if (SigAddressPrepareStage2(de_ctx) != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
if (SigAddressPrepareStage3(de_ctx) != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
if (SigAddressPrepareStage4(de_ctx) != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
int r = DetectMpmPrepareBuiltinMpms(de_ctx);
r |= DetectMpmPrepareAppMpms(de_ctx);
r |= DetectMpmPreparePktMpms(de_ctx);
if (r != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
if (SigMatchPrepare(de_ctx) != 0) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
#ifdef PROFILING
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
if (unlikely(new == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayNew. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SigNumArrayNew. Exiting...");
}
memset(new, 0, sizeof(SigNumArray));
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
if (unlikely(new == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayCopy. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SigNumArrayCopy. Exiting...");
}
memset(new, 0, sizeof(SigNumArray));
io_ctx->sig_init_size = DetectEngineGetMaxSigId(de_ctx) / 8 + 1;
if ( (io_ctx->sig_init_array = SCMalloc(io_ctx->sig_init_size)) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in IPOnlyInit. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in IPOnlyInit. Exiting...");
}
memset(io_ctx->sig_init_array, 0, io_ctx->sig_init_size);
if (mpm_algo != NULL) {
#if __BYTE_ORDER == __BIG_ENDIAN
if (strcmp(mpm_algo, "ac-ks") == 0) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY, "ac-ks does "
- "not work on big endian systems at this time.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "ac-ks does "
+ "not work on big endian systems at this time.");
}
#endif
if (strcmp("auto", mpm_algo) == 0) {
}
if ( (temp = SCMalloc(sizeof(SCSigOrderFunc))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCSigRegisterSignatureOrderingFunc. Exiting...");
}
memset(temp, 0, sizeof(SCSigOrderFunc));
host_tag_id = HostStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
if (host_tag_id == -1) {
- SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for tag");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Can't initiate host storage for tag");
}
flow_tag_id = FlowStorageRegister("tag", sizeof(void *), NULL, DetectTagDataListFree);
if (flow_tag_id == -1) {
- SCLogError(SC_ERR_FLOW_INIT, "Can't initiate flow storage for tag");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Can't initiate flow storage for tag");
}
}
{
host_threshold_id = HostStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
if (host_threshold_id == -1) {
- SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for thresholding");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Can't initiate host storage for thresholding");
}
ippair_threshold_id = IPPairStorageRegister("threshold", sizeof(void *), NULL, ThresholdListFree);
if (ippair_threshold_id == -1) {
- SCLogError(SC_ERR_HOST_INIT, "Can't initiate IP pair storage for thresholding");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Can't initiate IP pair storage for thresholding");
}
}
void ThresholdHashInit(DetectEngineCtx *de_ctx)
{
if (SCMutexInit(&de_ctx->ths_ctx.threshold_table_lock, NULL) != 0) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Threshold: Failed to initialize hash table mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Threshold: Failed to initialize hash table mutex.");
}
}
SigMatchData *smd = (SigMatchData *)SCCalloc(len, sizeof(SigMatchData));
if (smd == NULL) {
- SCLogError(SC_ERR_DETECT_PREPARE, "initializing the detection engine failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing the detection engine failed");
}
SigMatchData *out = smd;
if ((ConfGet("flow.memcap", &conf_val)) == 1)
{
if (conf_val == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.memcap: NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Invalid value for flow.memcap: NULL");
}
if (ParseSizeStringU64(conf_val, &flow_memcap_copy) < 0) {
if ((ConfGet("flow.hash-size", &conf_val)) == 1)
{
if (conf_val == NULL) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.hash-size: NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_INVALID_YAML_CONF_ENTRY,"Invalid value for flow.prealloc: NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Invalid value for flow.prealloc: NULL");
}
if (StringParseUint32(&configval, 10, strlen(conf_val),
}
flow_hash = SCMallocAligned(flow_config.hash_size * sizeof(FlowBucket), CLS);
if (unlikely(flow_hash == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowInitConfig. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in FlowInitConfig. Exiting...");
}
memset(flow_hash, 0, flow_config.hash_size * sizeof(FlowBucket));
{
host_bit_id = HostStorageRegister("bit", sizeof(void *), NULL, HostBitFreeAll);
if (host_bit_id == -1) {
- SCLogError(SC_ERR_HOST_INIT, "Can't initiate host storage for bits");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Can't initiate host storage for bits");
}
}
}
host_hash = SCMallocAligned(host_config.hash_size * sizeof(HostHashRow), CLS);
if (unlikely(host_hash == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostInitConfig. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in HostInitConfig. Exiting...");
}
memset(host_hash, 0, host_config.hash_size * sizeof(HostHashRow));
{
ippair_bit_id = IPPairStorageRegister("bit", sizeof(void *), NULL, XBitFreeAll);
if (ippair_bit_id == -1) {
- SCLogError(SC_ERR_IPPAIR_INIT, "Can't initiate ippair storage for bits");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Can't initiate ippair storage for bits");
}
}
}
ippair_hash = SCMallocAligned(ippair_config.hash_size * sizeof(IPPairHashRow), CLS);
if (unlikely(ippair_hash == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in IPPairInitConfig. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in IPPairInitConfig. Exiting...");
}
memset(ippair_hash, 0, ippair_config.hash_size * sizeof(IPPairHashRow));
PcapLogData *pl = SCMalloc(sizeof(PcapLogData));
if (unlikely(pl == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate Memory for PcapLogData");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to allocate Memory for PcapLogData");
}
memset(pl, 0, sizeof(PcapLogData));
pl->h = SCMalloc(sizeof(*pl->h));
if (pl->h == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate Memory for pcap header struct");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate Memory for pcap header struct");
}
/* Set the defaults */
uint64_t size = pl->size_limit * 1024 * 1024;
pl->size_limit = size;
} else if (pl->size_limit < MIN_LIMIT) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Fail to initialize pcap-log output, limit less than "
- "allowed minimum.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fail to initialize pcap-log output, limit less than "
+ "allowed minimum.");
}
}
}
}
if (s_dir == NULL) {
if (pl->mode == LOGMODE_SGUIL) {
- SCLogError(SC_ERR_LOGPCAP_SGUIL_BASE_DIR_MISSING,
- "log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
- "option to be set.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
+ "option to be set.");
} else {
const char *log_dir = NULL;
log_dir = ConfigGetLogDirectory();
comp->buffer = SCMalloc(comp->buffer_size);
if (unlikely(comp->buffer == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for "
- "lz4 output buffer.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to allocate memory for "
+ "lz4 output buffer.");
}
comp->bytes_in_block = 0;
max_number_of_files_s);
exit(EXIT_FAILURE);
} else if (max_file_limit < 1) {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "Failed to initialize pcap-log output, limit less than "
- "allowed minimum.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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;
} else if (ConfValIsTrue(use_stream_depth)) {
pl->use_stream_depth = USE_STREAM_DEPTH_ENABLED;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "log-pcap use_stream_depth specified is invalid must be");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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 {
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "log-pcap honor-pass-rules specified is invalid");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "log-pcap honor-pass-rules specified is invalid");
}
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
if (unlikely(output_ctx == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for OutputCtx.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to allocate memory for OutputCtx.");
}
output_ctx->data = pl;
output_ctx->DeInit = PcapLogFileDeInitCtx;
profiling_pcaplog_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_pcaplog_file_name == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "can't duplicate file name");
}
snprintf(profiling_pcaplog_file_name, PATH_MAX, "%s/%s", log_dir, filename);
SCLogRedisInit();
json_ctx->json_out = LOGFILE_TYPE_REDIS;
#else
- SCLogError(SC_ERR_INVALID_ARGUMENT,
- "redis JSON output option is not compiled");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "redis JSON output option is not compiled");
#endif
} else {
SCLogError(SC_ERR_INVALID_ARGUMENT,
json_ctx->file_ctx->prefix = SCStrdup(prefix);
if (json_ctx->file_ctx->prefix == NULL)
{
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for eve-log.prefix setting.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate memory for eve-log.prefix setting.");
}
json_ctx->file_ctx->prefix_len = strlen(prefix);
}
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
- SCLogError(SC_ERR_LUA_ERROR,
- "Error during setup of lua output. Details should be "
- "described in previous error messages. Shutting down...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Error during setup of lua output. Details should be "
+ "described in previous error messages. Shutting down...");
}
return result;
while (t->next)
t = t->next;
if (t->id * 2 > UINT32_MAX) {
- SCLogError(SC_ERR_FATAL, "Too many loggers registered.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Too many loggers registered.");
}
op->id = t->id * 2;
t->next = op;
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in OutputRegisterModule. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in OutputRegisterModule. Exiting...");
}
/**
SCLogDebug("Packet logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Packet logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Tx logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("File logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("File logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Filedata logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Filedata logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Flow logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Flow logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Streaming logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Streaming logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Stats logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
SCLogDebug("Stats logger \"%s\" registered.", name);
return;
error:
- SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
}
/**
{
SReputation *user_data = NULL;
if ((user_data = SCMalloc(sizeof(SReputation))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
}
memset(user_data, 0x00, sizeof(SReputation));
SCLogDebug("live_dev %s", live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to init peers list.");
}
ret = RunModeSetLiveCaptureAutoFp(ParseAFPConfig,
"DecodeAFP", thread_name_autofp,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPAutoFp initialised");
(void)ConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to init peers list.");
}
ret = RunModeSetLiveCaptureSingle(ParseAFPConfig,
"DecodeAFP", thread_name_single,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPSingle initialised");
(void)ConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Unable to init peers list.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to init peers list.");
}
ret = RunModeSetLiveCaptureWorkers(ParseAFPConfig,
"DecodeAFP", thread_name_workers,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
/* In IPS mode each threads must have a peer */
if (AFPPeersListCheck() != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "Some IPS capture threads did not peer.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Some IPS capture threads did not peer.");
}
SCLogDebug("RunModeIdsAFPWorkers initialised");
thread_name_single,
NULL);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "DAG single runmode failed to start");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "DAG single runmode failed to start");
}
SCLogInfo("RunModeIdsDagSingle initialised");
thread_name_autofp,
NULL);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "DAG autofp runmode failed to start");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "DAG autofp runmode failed to start");
}
SCLogInfo("RunModeIdsDagAutoFp initialised");
thread_name_workers,
NULL);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "DAG workers runmode failed to start");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "DAG workers runmode failed to start");
}
SCLogInfo("RunModeIdsErfDagWorkers initialised");
SCEnter();
if (ConfGet("erf-file.file", &file) == 0) {
- SCLogError(SC_ERR_RUNMODE, "Failed to get erf-file.file from config.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to get erf-file.file from config.");
}
RunModeInitialize();
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
const char *file = NULL;
if (ConfGet("erf-file.file", &file) == 0) {
- SCLogError(SC_ERR_RUNMODE,
- "Failed retrieving erf-file.file from config");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed retrieving erf-file.file from config");
}
TimeModeSetOffline();
queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- SCLogError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "RunmodeAutoFpCreatePickupQueuesString failed");
}
/* create the threads */
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_RUNMODE, "napatech.auto-config cannot be used in configuration file at the same time as napatech.use-all-streams.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_RUNMODE, "napatech auto-config must be enabled when using napatech.use_hw_bypass.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate memory for NAPATECH stream counter.");
}
snprintf(plive_dev_buf, 9, "nt%d", stream_config[inst].stream_id);
plive_dev_buf);
SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
"run /opt/napatech3/bin/ntpl -e \"delete=all\" to delete existing stream");
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "or disable auto-config in the conf file before running.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "or disable auto-config in the conf file before running.");
}
} else {
SCLogInfo("Registering Napatech device: %s - active stream%sfound.",
status = NapatechRegisterDeviceStreams();
if (status < 0 || num_configured_streams <= 0) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Unable to find existing Napatech Streams");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Unable to find existing Napatech Streams");
}
struct NapatechStreamDevConf *conf =
SCCalloc(1, sizeof (struct NapatechStreamDevConf));
if (unlikely(conf == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH device.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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 {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Napatech Hardware Bypass requested in conf but is not supported by the hardware.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech Hardware Bypass requested in conf but is not supported by the hardware.");
}
#else
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Napatech Hardware Bypass requested in conf but is not enabled by the software.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
return 0;
}
"DecodeNetmap", thread_name_autofp,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogDebug("RunModeIdsNetmapAutoFp initialised");
"DecodeNetmap", thread_name_single,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogDebug("RunModeIdsNetmapSingle initialised");
"DecodeNetmap", thread_name_workers,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogDebug("RunModeIdsNetmapWorkers initialised");
strlcpy(nflogconf->numgroup, group, sizeof(nflogconf->numgroup));
if (ParseSizeStringU16(group, &nflogconf->group) < 0) {
- SCLogError(SC_ERR_NFLOG_GROUP, "NFLOG's group number invalid.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "NFLOG's group number invalid.");
}
boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
thread_name_autofp,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogAutoFp initialised");
thread_name_single,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogSingle initialised");
thread_name_workers,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogInfo("RunModeIdsNflogWorkers initialised");
char tname[TM_THREAD_NAME_MAX];
if (ConfGet("pcap-file.file", &file) == 0) {
- SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
}
RunModeInitialize();
"packetpool", "packetpool",
"pktacqloop");
if (tv == NULL) {
- SCLogError(SC_ERR_RUNMODE, "threading setup failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "threading setup failed");
}
TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName failed for ReceivePcap");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
}
TmSlotSetFuncAppend(tv, tm_module, file);
tm_module = TmModuleGetByName("DecodePcapFile");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName DecodePcap failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName for FlowWorker failed");
}
TmSlotSetFuncAppend(tv, tm_module, NULL);
TmThreadSetCPU(tv, WORKER_CPU_SET);
if (TmThreadSpawn(tv) != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
}
return 0;
}
const char *file = NULL;
if (ConfGet("pcap-file.file", &file) == 0) {
- SCLogError(SC_ERR_RUNMODE, "Failed retrieving pcap-file from Conf");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed retrieving pcap-file from Conf");
}
SCLogDebug("file %s", file);
queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
if (queues == NULL) {
- SCLogError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "RunmodeAutoFpCreatePickupQueuesString failed");
}
snprintf(tname, sizeof(tname), "%s#01", thread_name_autofp);
SCFree(queues);
if (tv_receivepcap == NULL) {
- SCLogError(SC_ERR_FATAL, "threading setup failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "threading setup failed");
}
TmModule *tm_module = TmModuleGetByName("ReceivePcapFile");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName failed for ReceivePcap");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName failed for ReceivePcap");
}
TmSlotSetFuncAppend(tv_receivepcap, tm_module, file);
tm_module = TmModuleGetByName("DecodePcapFile");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName DecodePcap failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmModuleGetByName DecodePcap failed");
}
TmSlotSetFuncAppend(tv_receivepcap, tm_module, NULL);
TmThreadSetCPU(tv_receivepcap, RECEIVE_CPU_SET);
if (TmThreadSpawn(tv_receivepcap) != TM_ECODE_OK) {
- SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
}
for (thread = 0; thread < (uint16_t)thread_max; thread++) {
"packetpool", "packetpool",
"varslot");
if (tv_detect_ncpu == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
}
tm_module = TmModuleGetByName("FlowWorker");
if (tm_module == NULL) {
- SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
}
if ((cpu + 1) == ncpus)
"DecodePcap", thread_name_single,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
SCLogInfo("RunModeIdsPcapSingle initialised");
"DecodePcap", thread_name_autofp,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
SCLogInfo("RunModeIdsPcapAutoFp initialised");
"DecodePcap", thread_name_workers,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Unable to start runmode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to start runmode");
}
SCLogInfo("RunModeIdsPcapWorkers initialised");
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
- "Unable to get parser and interface params");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureAutoFp(tparser,
"DecodePfring", thread_name_autofp,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
SCLogInfo("RunModeIdsPfringAutoFp initialised");
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
- "Unable to get parser and interface params");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureSingle(tparser,
"DecodePfring", thread_name_single,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
SCLogInfo("RunModeIdsPfringSingle initialised");
ret = GetDevAndParser(&live_dev, &tparser);
if (ret != 0) {
- SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
- "Unable to get parser and interface params");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Unable to get parser and interface params");
}
ret = RunModeSetLiveCaptureWorkers(tparser,
"DecodePfring", thread_name_workers,
live_dev);
if (ret != 0) {
- SCLogError(SC_ERR_RUNMODE, "Runmode start failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Runmode start failed");
}
SCLogInfo("RunModeIdsPfringWorkers initialised");
exit(EXIT_SUCCESS);
#else
- SCLogError(SC_ERR_NOT_SUPPORTED, "Unittests are not build-in");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unittests are not build-in");
#endif /* UNITTESTS */
}
break;
#endif
default:
- SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unknown runtime mode. Aborting");
}
} else { /* if (custom_mode == NULL) */
/* Add compability with old 'worker' name */
"to 'workers', please modify your setup.");
local_custom_mode = SCStrdup("workers");
if (unlikely(local_custom_mode == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup custom mode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to dup custom mode");
}
custom_mode = local_custom_mode;
}
}
active_runmode = SCStrdup(custom_mode);
if (unlikely(active_runmode == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup active mode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to dup active mode");
}
if (strcasecmp(active_runmode, "autofp") == 0) {
ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
if (unlikely(ewtn == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for ERF DAG thread vars.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate memory for ERF DAG thread vars.");
}
memset(ewtn, 0, sizeof(*ewtn));
NapatechThreadVars *ntv = SCCalloc(1, sizeof (NapatechThreadVars));
if (unlikely(ntv == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH thread vars.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to allocate memory for NAPATECH thread vars.");
}
memset(ntv, 0, sizeof (NapatechThreadVars));
exit(EXIT_FAILURE);
} else if (status == 0x20000008) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Check napatech.ports in the suricata config file.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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);
SCLogDebug("binding netfilter_log as nflog handler for AF_INET and AF_INET6");
if (nflog_bind_pf(ntv->h, AF_INET) < 0) {
- SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET failed");
}
if (nflog_bind_pf(ntv->h, AF_INET6) < 0) {
- SCLogError(SC_ERR_NFLOG_BIND, "nflog_bind_pf() for AF_INET6 failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nflog_bind_pf() for AF_INET6 failed");
}
ntv->gh = nflog_bind_group(ntv->h, ntv->group);
SCLogDebug("closing nflog group %d", ntv->group);
if (nflog_unbind_pf(ntv->h, AF_INET) < 0) {
- SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET failed");
}
if (nflog_unbind_pf(ntv->h, AF_INET6) < 0) {
- SCLogError(SC_ERR_NFLOG_UNBIND, "nflog_unbind_pf() for AF_INET6 failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nflog_unbind_pf() for AF_INET6 failed");
}
if (ntv->gh) {
} else if (!strcmp("route", nfq_mode)) {
nfq_config.mode = NFQ_ROUTE_MODE;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "Unknown nfq.mode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unknown nfq.mode");
}
}
* 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) {
- SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nfq_unbind_pf() for AF_INET failed");
}
if (nfq_unbind_pf(q->h, AF_INET6) < 0) {
- SCLogError(SC_ERR_NFQ_UNBIND, "nfq_unbind_pf() for AF_INET6 failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET failed");
}
if (nfq_bind_pf(q->h, AF_INET6) < 0) {
- SCLogError(SC_ERR_NFQ_BIND, "nfq_bind_pf() for AF_INET6 failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "nfq_bind_pf() for AF_INET6 failed");
}
}
temp_rdrange);
exit(EXIT_FAILURE);
} else if (rdrange >= 100) {
- SCLogError(SC_ERR_INVALID_VALUE,
- "stream.reassembly.randomize-chunk-range "
- "must be lower than 100");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "stream.reassembly.randomize-chunk-range "
+ "must be lower than 100");
}
}
}
size_t nm = 0;
if (EngineModeIsIPS()) {
- SCLogError(SC_ERR_NOT_SUPPORTED,
- "BPF filter not available in IPS mode."
- " Use firewall filtering if possible.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "BPF filter not available in IPS mode."
+ " Use firewall filtering if possible.");
}
#ifdef OS_WIN32
/* Quick validation. */
char *val = strchr(optarg, '=');
if (val == NULL) {
- SCLogError(SC_ERR_CMD_LINE,
- "Invalid argument for --set, must be key=val.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Invalid argument for --set, must be key=val.");
}
if (!ConfSetFromString(optarg, 1)) {
fprintf(stderr, "Failed to set configuration value %s.",
if (mt_enabled)
(void)ConfGetBool("multi-detect.default", &default_tenant);
if (DetectEngineMultiTenantSetup() == -1) {
- SCLogError(SC_ERR_INITIALIZATION, "initializing multi-detect "
- "detection engine contexts failed.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing multi-detect "
+ "detection engine contexts failed.");
}
if (suri->delayed_detect && suri->run_mode != RUNMODE_CONF_TEST) {
de_ctx = DetectEngineCtxInitStubForDD();
de_ctx = DetectEngineCtxInit();
}
if (de_ctx == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
- "context failed.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "initializing detection engine "
+ "context failed.");
}
if (de_ctx->type == DETECT_ENGINE_TYPE_NORMAL) {
/* Wait till all the threads have been initialized */
if (TmThreadWaitOnThreadInit() == TM_ECODE_FAILED) {
- SCLogError(SC_ERR_INITIALIZATION, "Engine initialization failed, "
+ FatalError(SC_ERR_FATAL, "Engine initialization failed, "
"aborting...");
- exit(EXIT_FAILURE);
}
SC_ATOMIC_SET(engine_stage, SURICATA_RUNTIME);
void TmThreadInitMC(ThreadVars *tv)
{
if ( (tv->ctrl_mutex = SCMalloc(sizeof(*tv->ctrl_mutex))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in TmThreadInitMC. "
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in TmThreadInitMC. "
"Exiting...");
- exit(EXIT_FAILURE);
}
if (SCCtrlMutexInit(tv->ctrl_mutex, NULL) != 0) {
}
if ( (tv->ctrl_cond = SCMalloc(sizeof(*tv->ctrl_cond))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in TmThreadInitMC. "
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in TmThreadInitMC. "
"Exiting...");
- exit(EXIT_FAILURE);
}
if (SCCtrlCondInit(tv->ctrl_cond, NULL) != 0) {
- SCLogError(SC_ERR_FATAL, "Error initializing the tv->cond condition "
+ FatalError(SC_ERR_FATAL, "Error initializing the tv->cond condition "
"variable");
- exit(EXIT_FAILURE);
}
return;
for (i = 0; i < max_pending_packets; i++) {
Packet *p = PacketGetFromAlloc();
if (unlikely(p == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered while allocating a packet. Exiting...");
}
PacketPoolStorePacket(p);
}
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
- SCLogError(SC_ERR_INITIALIZATION,
- "Unable to create unix command socket");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Unable to create unix command socket");
} else {
SCLogWarning(SC_ERR_INITIALIZATION,
"Unable to create unix command socket");
"UnixManager", 0);
if (tv_unixmgr == NULL) {
- SCLogError(SC_ERR_INITIALIZATION, "TmThreadsCreate failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadsCreate failed");
}
if (TmThreadSpawn(tv_unixmgr) != TM_ECODE_OK) {
- SCLogError(SC_ERR_INITIALIZATION, "TmThreadSpawn failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "TmThreadSpawn failed");
}
if (mode == 1) {
if (TmThreadsCheckFlag(tv_unixmgr, THV_RUNNING_DONE)) {
- SCLogError(SC_ERR_INITIALIZATION, "Unix socket init failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unix socket init failed");
}
}
return;
ConfNode *nprio = NULL;
if (taf == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu-affinity type");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unknown cpu-affinity type");
} else {
SCLogConfig("Found affinity definition for \"%s\"", setname);
}
} else if (!strcmp(node->val, "high")) {
taf->prio = PRIO_HIGH;
} else {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu_affinity prio");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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 {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "unknown cpu_affinity node");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unknown cpu_affinity node");
}
}
"count: '%s'", node->val);
}
if (! taf->nb_threads) {
- SCLogError(SC_ERR_INVALID_ARGUMENT, "bad value for threads count");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "bad value for threads count");
}
}
}
if (waitpid(pid, &status, WNOHANG)) {
/* Check if the child is still there, otherwise the parent should exit */
if (WIFEXITED(status) || WIFSIGNALED(status)) {
- SCLogError(SC_ERR_DAEMON, "Child died unexpectedly");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Child died unexpectedly");
}
}
/* sigsuspend(); */
if (pid < 0) {
/* Fork error */
- SCLogError(SC_ERR_DAEMON, "Error forking the process");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error forking the process");
} else if (pid == 0) {
/* Child continues here */
const char *daemondir;
sid = setsid();
if (sid < 0) {
- SCLogError(SC_ERR_DAEMON, "Error creating new session");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error creating new session");
}
if (ConfGet("daemon-directory", &daemondir) == 1) {
if ((chdir(daemondir)) < 0) {
- SCLogError(SC_ERR_DAEMON, "Error changing to working directory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Error changing to working directory");
}
}
#ifndef OS_WIN32
SCLogFGFilterLine *fgf_line_temp = NULL;
if ( (fgf_file_temp = SCMalloc(sizeof(SCLogFGFilterFile))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
}
memset(fgf_file_temp, 0, sizeof(SCLogFGFilterFile));
}
if ( (fgf_func_temp = SCMalloc(sizeof(SCLogFGFilterFunc))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
}
memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
}
if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFileList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
}
memset(fgf_func_temp, 0, sizeof(SCLogFGFilterFunc));
}
if ( (fgf_line_temp = SCMalloc(sizeof(SCLogFGFilterLine))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFFuncList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogAddToFGFLineList. Exiting...");
}
memset(fgf_line_temp, 0, sizeof(SCLogFGFilterLine));
if ( (buffer = SCMalloc(sc_log_config->op_ifaces_cnt *
sizeof(SCLogOPBuffer))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogAllocLogOPBuffer. Exiting...");
}
op_iface_ctx = sc_log_config->op_ifaces;
SCLogOPIfaceCtx *iface_ctx = NULL;
if ( (iface_ctx = SCMalloc(sizeof(SCLogOPIfaceCtx))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting...");
}
memset(iface_ctx, 0, sizeof(SCLogOPIfaceCtx));
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if (iface_ctx == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitFileOPIface. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogInitFileOPIface. Exiting...");
}
if (file == NULL) {
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if (iface_ctx == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogInitConsoleOPIface. Exiting...");
}
iface_ctx->iface = SC_LOG_OP_IFACE_CONSOLE;
SCLogOPIfaceCtx *iface_ctx = SCLogAllocLogOPIfaceCtx();
if ( iface_ctx == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitSyslogOPIface. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_MUTEX, "Failed to initialize log mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to initialize log mutex.");
}
#endif /* OS_WIN32 */
/* sc_log_config is a global variable */
if ( (sc_log_config = SCMalloc(sizeof(SCLogConfig))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCLogInitLogModule. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCLogInitLogModule. Exiting...");
}
memset(sc_log_config, 0, sizeof(SCLogConfig));
else if (strcmp(output->name, "file") == 0) {
const char *filename = ConfNodeLookupChildValue(output, "filename");
if (filename == NULL) {
- SCLogError(SC_ERR_MISSING_CONFIG_PARAM,
- "Logging to file requires a filename");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Logging to file requires a filename");
}
char *path = NULL;
if (!(PathIsAbsolute(filename))) {
int *user_data = NULL;
if ( (user_data = SCMalloc(sizeof(int))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Error allocating memory. Exiting");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory. Exiting");
}
/* the host os flavour that has to be sent as user data */
}
if ( (ip_str = SCStrdup(host_os_ip_range)) == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
/* check if we have more addresses in the host_os_ip_range */
return NULL;
if ( (addr = SCMalloc(sizeof(struct in_addr))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in ValidateIPV4Address. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in ValidateIPV6Address. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in ValidateIPV6Address. Exiting...");
}
if (inet_pton(AF_INET6, addr_str, addr) <= 0) {
{
SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
if (ctx == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis context");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
}
ctx->sync = NULL;
#if HAVE_LIBEVENT
{
SCLogRedisContext* ctx = (SCLogRedisContext*) SCCalloc(1, sizeof(SCLogRedisContext));
if (unlikely(ctx == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis context");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to allocate redis context");
}
ctx->sync = NULL;
} else if(!strcmp(redis_mode,"channel") || !strcmp(redis_mode,"publish")) {
log_ctx->redis_setup.command = redis_publish_cmd;
} else {
- SCLogError(SC_ERR_REDIS_CONFIG,"Invalid redis mode");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Invalid redis mode");
}
/* store server params for reconnection */
if (!log_ctx->redis_setup.server) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating redis server string");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating redis server string");
}
if (StringParseUint16(&log_ctx->redis_setup.port, 10, 0, (const char *)redis_port) < 0) {
FatalError(SC_ERR_INVALID_VALUE, "Invalid value for redis port: %s", redis_port);
else {
log_ctx->rotate_interval = SCParseTimeSizeString(rotate_int);
if (log_ctx->rotate_interval == 0) {
- SCLogError(SC_ERR_INVALID_NUMERIC_VALUE,
- "invalid rotate-interval value");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "invalid rotate-interval value");
}
log_ctx->rotate_time = now + log_ctx->rotate_interval;
}
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->output_table = ptmp;
if (ptmp == NULL) {
SCFree(output_state->pids);
output_state->pids = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
output_state->pids = ptmp;
if (ptmp == NULL) {
SCFree(output_dst_state->pids);
output_dst_state->pids = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->output_table = ptmp;
}
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(output_state->patterns);
output_state->patterns = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
output_state->patterns = ptmp;
if (ptmp == NULL) {
SCFree(output_dst_state->patterns);
output_dst_state->patterns = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(ctx->failure_table, 0, ctx->state_count * sizeof(int32_t));
uint8_t encoded_next_state = next_state;
if (next_state == SC_AC_TILE_FAIL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error FAIL state in output");
}
if (outputs == 0)
uint16_t encoded_next_state = next_state;
if (next_state == SC_AC_TILE_FAIL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error FAIL state in output");
}
if (outputs == 0)
uint32_t encoded_next_state = next_state;
if (next_state == SC_AC_TILE_FAIL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error FAIL state in output");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
mpm_ctx->memory_cnt++;
mpm_ctx->memory_size += mem_size;
if (ptmp == NULL) {
SCFree(ctx->goto_table);
ctx->goto_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->goto_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->output_table = ptmp;
if (ptmp == NULL) {
SCFree(ctx->output_table);
ctx->output_table = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
ctx->output_table = ptmp;
}
if (ptmp == NULL) {
SCFree(output_state->pids);
output_state->pids = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
output_state->pids = ptmp;
if (ptmp == NULL) {
SCFree(output_dst_state->pids);
output_dst_state->pids = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "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) {
- SCLogError(SC_ERR_FATAL, "Failed to set Hyperscan allocator.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to set Hyperscan allocator.");
}
}
SCMutexUnlock(&g_scratch_proto_mutex);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "Unable to clone scratch prototype");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to clone scratch prototype");
}
err = hs_scratch_size(ctx->scratch, &ctx->scratch_size);
if (err != HS_SUCCESS) {
- SCLogError(SC_ERR_FATAL, "Unable to query scratch size");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Unable to query scratch size");
}
mpm_thread_ctx->memory_cnt++;
if (de_ctx->mpm_ctx_factory_container == NULL) {
de_ctx->mpm_ctx_factory_container = SCMalloc(sizeof(MpmCtxFactoryContainer));
if (de_ctx->mpm_ctx_factory_container == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
if (unlikely(item == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
item[0].name = name;
/* toserver */
item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
if (item[0].mpm_ctx_ts == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
item[0].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
/* toclient */
item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
if (item[0].mpm_ctx_tc == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
item[0].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
if (items[i].mpm_ctx_ts == NULL) {
items[i].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
if (items[i].mpm_ctx_ts == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(items[i].mpm_ctx_ts, 0, sizeof(MpmCtx));
items[i].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
if (items[i].mpm_ctx_tc == NULL) {
items[i].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
if (items[i].mpm_ctx_tc == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(items[i].mpm_ctx_tc, 0, sizeof(MpmCtx));
items[i].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
if (unlikely(ptmp == NULL)) {
SCFree(items);
items = NULL;
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
items = ptmp;
/* toserver */
new_item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
if (new_item[0].mpm_ctx_ts == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(new_item[0].mpm_ctx_ts, 0, sizeof(MpmCtx));
new_item[0].mpm_ctx_ts->flags |= MPMCTX_FLAGS_GLOBAL;
/* toclient */
new_item[0].mpm_ctx_tc = SCMalloc(sizeof(MpmCtx));
if (new_item[0].mpm_ctx_tc == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(new_item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
new_item[0].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)) {
- SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(mpm_ctx, 0, sizeof(MpmCtx));
return mpm_ctx;
for (int i = 0; i < stream_cnt; ++i) {
char *pkts_buf = SCCalloc(1, 32);
if (unlikely(pkts_buf == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH stream counter.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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 (strncmp(lnode->val, "all", 4) == 0) {
/* check that the sting in the config file is correctly specified */
if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Only one Napatech port specifier type allowed.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Only one Napatech port specifier type allowed.");
}
cpu_spec = CONFIG_SPECIFIER_RANGE;
worker_count = UtilCpuGetNumProcessorsConfigured();
} else if (strchr(lnode->val, '-')) {
/* check that the sting in the config file is correctly specified */
if (cpu_spec != CONFIG_SPECIFIER_UNDEFINED) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Only one Napatech port specifier type allowed.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Only one Napatech port specifier type allowed.");
}
cpu_spec = CONFIG_SPECIFIER_RANGE;
} else {
/* check that the sting in the config file is correctly specified */
if (cpu_spec == CONFIG_SPECIFIER_RANGE) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Napatech port range specifiers cannot be combined with individual stream specifiers.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech port range specifiers cannot be combined with individual stream specifiers.");
}
cpu_spec = CONFIG_SPECIFIER_INDIVIDUAL;
++worker_count;
}
} else {
if (stream_spec == CONFIG_SPECIFIER_RANGE) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Napatech range and individual specifiers cannot be combined.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech range and individual specifiers cannot be combined.");
}
stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
if (StringParseUint16(&stream_config[instance_cnt].stream_id,
"custom", NapatechStatsLoop, 0);
if (stats_tv == NULL) {
- SCLogError(SC_ERR_THREAD_CREATE,
- "Error creating a thread for NapatechStats - Killing engine.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Error creating a thread for NapatechStats - Killing engine.");
}
if (TmThreadSpawn(stats_tv) != 0) {
- SCLogError(SC_ERR_THREAD_SPAWN,
- "Failed to spawn thread for NapatechStats - Killing engine.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to spawn thread for NapatechStats - Killing engine.");
}
#ifdef NAPATECH_ENABLE_BYPASS
"custom", NapatechBufMonitorLoop, 0);
if (buf_monitor_tv == NULL) {
- SCLogError(SC_ERR_THREAD_CREATE,
- "Error creating a thread for NapatechBufMonitor - Killing engine.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Error creating a thread for NapatechBufMonitor - Killing engine.");
}
if (TmThreadSpawn(buf_monitor_tv) != 0) {
- SCLogError(SC_ERR_THREAD_SPAWN,
- "Failed to spawn thread for NapatechBufMonitor - Killing engine.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to spawn thread for NapatechBufMonitor - Killing engine.");
}
}
if (is_inline) {
- SCLogError(SC_ERR_RUNMODE, "Napatech inline mode not supported. (Only available when Hardware Bypass support is enabled.)");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech inline mode not supported. (Only available when Hardware Bypass support is enabled.)");
}
#endif
* the array of streams from the conf
*/
if ((ntports = ConfGetNode("napatech.ports")) == NULL) {
- SCLogError(SC_ERR_RUNMODE, "Failed retrieving napatech.ports from Conf");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed retrieving napatech.ports from Conf");
}
/* Loop through all ports in the array */
TAILQ_FOREACH(port, &ntports->head, next)
{
if (port == NULL) {
- SCLogError(SC_ERR_NAPATECH_STREAMS_REGISTER_FAILED,
- "Couldn't Parse Port Configuration");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Couldn't Parse Port Configuration");
}
if (NapatechUseHWBypass()) {
if (ports_spec.first[iteration] == ports_spec.second[iteration]) {
if (is_inline) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Error with napatec.ports in conf file. When running in inline mode the two ports specifying a segment must be different.");
- exit(EXIT_FAILURE);
+ 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.");
} else {
/* SPAN port configuration */
is_span_port[ports_spec.first[iteration]] = 1;
strlcat(ports_spec.str, temp, sizeof(ports_spec.str));
}
} else {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "When using hardware flow bypass ports must be specified as segments. E.g. ports: [0-1, 0-2]");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Only one Napatech port specifier type is allowed.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Only one Napatech port specifier is allowed when hardware bypass is disabled. (E.g. ports: [0-4], NOT ports: [0-1,2-3])");
- exit(EXIT_FAILURE);
+ 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])");
}
stream_spec = CONFIG_SPECIFIER_RANGE;
} else {
/* check that the sting in the config file is correctly specified */
if (stream_spec == CONFIG_SPECIFIER_RANGE) {
- SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG,
- "Napatech port range specifiers cannot be combined with individual stream specifiers.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech port range specifiers cannot be combined with individual stream specifiers.");
}
stream_spec = CONFIG_SPECIFIER_INDIVIDUAL;
}
} else {
if (is_inline) {
- SCLogError(SC_WARN_COMPATIBILITY,
- "Napatech Inline operation not supported by this FPGA version.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Napatech Inline operation not supported by this FPGA version.");
}
if (NapatechIsAutoConfigEnabled()){
if (capng_change_id(userid, groupid, CAPNG_DROP_SUPP_GRP |
CAPNG_CLEAR_BOUNDING) < 0)
{
- SCLogError(SC_ERR_CHANGING_CAPS_FAILED, "capng_change_id for main thread"
- " failed");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "capng_change_id for main thread"
+ " failed");
}
SCLogInfo("dropped the caps for main thread");
}
pw = getpwuid(userid);
if (pw == NULL) {
- SCLogError(SC_ERR_UID_FAILED, "unable to get the user ID, "
- "check if user exist!!");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unable to get the user ID, "
+ "check if user exist!!");
}
} else {
pw = getpwnam(user_name);
if (pw == NULL) {
- SCLogError(SC_ERR_UID_FAILED, "unable to get the user ID, "
- "check if user exist!!");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unable to get the user ID, "
+ "check if user exist!!");
}
userid = pw->pw_uid;
}
} else {
gp = getgrnam(group_name);
if (gp == NULL) {
- SCLogError(SC_ERR_GID_FAILED, "unable to get the group"
- " ID, check if group exist!!");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unable to get the group"
+ " ID, check if group exist!!");
}
groupid = gp->gr_gid;
}
} else {
gp = getgrnam(group_name);
if (gp == NULL) {
- SCLogError(SC_ERR_GID_FAILED, "unable to get the group ID,"
- " check if group exist!!");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "unable to get the group ID,"
+ " check if group exist!!");
}
grpid = gp->gr_gid;
}
memset(ctx, 0x00, sizeof(SCProfileKeywordDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Failed to initialize hash table mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to initialize hash table mutex.");
}
}
memset(ctx, 0x00, sizeof(SCProfilePrefilterDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Failed to initialize hash table mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to initialize hash table mutex.");
}
}
SCProfileSghDetectCtx *ctx = SCCalloc(1, sizeof(SCProfileSghDetectCtx));
if (ctx != NULL) {
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Failed to initialize mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "Failed to initialize mutex.");
}
}
memset(ctx, 0x00, sizeof(SCProfileDetectCtx));
if (pthread_mutex_init(&ctx->data_m, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Failed to initialize hash table mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Failed to initialize hash table mutex.");
}
}
profiling_packets_enabled = 1;
if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
- SCLogError(SC_ERR_MUTEX,
- "Failed to initialize packet profiling mutex.");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "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)) {
- SCLogError(SC_ERR_MEM_ALLOC, "out of memory");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "out of memory");
}
snprintf(profiling_csv_file_name, PATH_MAX, "%s/%s", log_dir, filename);
profiling_locks_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_locks_file_name == NULL)) {
- SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "can't duplicate file name");
}
snprintf(profiling_locks_file_name, PATH_MAX, "%s/%s", log_dir, filename);
SCRadixUserData *prev = NULL;
if (new == NULL || list == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "new or list supplied as NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "new or list supplied as NULL");
}
/* add to the list in descending order. The reason we do this is for
void *user)
{
if (prefix == NULL || user == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "prefix or user NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "prefix or user NULL");
}
SCRadixAppendToSCRadixUserDataList(SCRadixAllocSCRadixUserData(netmask, user),
SCRadixUserData *temp = NULL, *prev = NULL;
if (prefix == NULL) {
- SCLogError(SC_ERR_INVALID_ARGUMENTS, "prefix NULL");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL, "prefix NULL");
}
prev = temp = prefix->user_data;
SCRadixTree *tree = NULL;
if ( (tree = SCMalloc(sizeof(SCRadixTree))) == NULL) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCRadixCreateRadixTree. Exiting...");
}
memset(tree, 0, sizeof(SCRadixTree));
sizeof(uint8_t)))) == NULL) {
SCFree(node->netmasks);
node->netmasks = NULL;
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCRadixAddKey. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in SCRadixAddKey. Exiting...");
}
node->netmasks = ptmp;
{
BmCtx *new = SCMalloc(sizeof(BmCtx) + sizeof(uint16_t) * (needle_len + 1));
if (unlikely(new == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
}
/* Prepare bad chars */
/* Prepare good Suffixes */
if (PreBmGs(needle, needle_len, new->bmGs) == -1) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
}
}
ctx->array = SCMallocAligned(ctx->config.hash_size * sizeof(THashHashRow), CLS);
if (unlikely(ctx->array == NULL)) {
- SCLogError(SC_ERR_FATAL, "Fatal error encountered in THashInitConfig. Exiting...");
- exit(EXIT_FAILURE);
+ FatalError(SC_ERR_FATAL,
+ "Fatal error encountered in THashInitConfig. Exiting...");
}
memset(ctx->array, 0, ctx->config.hash_size * sizeof(THashHashRow));