本文整理汇总了C++中SCLogWarning函数的典型用法代码示例。如果您正苦于以下问题:C++ SCLogWarning函数的具体用法?C++ SCLogWarning怎么用?C++ SCLogWarning使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SCLogWarning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIfaceOffloadingBSD
static int GetIfaceOffloadingBSD(const char *ifname)
{
int ret = 0;
int if_caps = GetIfaceCaps(ifname);
if (if_caps == -1) {
return -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);
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",
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",
ifname, ifname);
ret = 1;
}
#endif
return ret;
}
示例2: StreamSegmentForEach
/** \brief Run callback for all segments
*
* \return -1 in case of error, the number of segment in case of success
*/
int StreamSegmentForEach(Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
{
switch(p->proto) {
case IPPROTO_TCP:
return StreamTcpSegmentForEach(p, flag, CallbackFunc, data);
break;
case IPPROTO_UDP:
SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "UDP is currently unsupported");
break;
default:
SCLogWarning(SC_ERR_UNKNOWN_PROTOCOL, "This protocol is currently unsupported");
break;
}
return 0;
}
示例3: NFQRecvPkt
/**
* \brief NFQ function to get a packet from the kernel
*
* \note separate functions for Linux and Win32 for readability.
*/
static void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv)
{
int rv, ret;
int flag = NFQVerdictCacheLen(t) ? MSG_DONTWAIT : 0;
/* XXX what happens on rv == 0? */
rv = recv(t->fd, tv->data, tv->datalen, flag);
if (rv < 0) {
if (errno == EINTR || errno == EWOULDBLOCK) {
/* no error on timeout */
if (flag)
NFQVerdictCacheFlush(t);
/* inject a fake packet on timeout */
TmThreadsCaptureInjectPacket(tv->tv, tv->slot, NULL);
} else {
#ifdef COUNTERS
NFQMutexLock(t);
t->errs++;
NFQMutexUnlock(t);
#endif /* COUNTERS */
}
} else if(rv == 0) {
SCLogWarning(SC_ERR_NFQ_RECV, "recv got returncode 0");
} else {
#ifdef DBG_PERF
if (rv > t->dbg_maxreadsize)
t->dbg_maxreadsize = rv;
#endif /* DBG_PERF */
//printf("NFQRecvPkt: t %p, rv = %" PRId32 "\n", t, rv);
NFQMutexLock(t);
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");
ret = -1;
}
NFQMutexUnlock(t);
if (ret != 0) {
SCLogWarning(SC_ERR_NFQ_HANDLE_PKT, "nfq_handle_packet error %"PRId32" %s",
ret, strerror(errno));
}
}
}
示例4: TmModuleRegisterTests
/** \brief register all unittests for the tm modules */
void TmModuleRegisterTests(void)
{
#ifdef UNITTESTS
TmModule *t;
uint16_t i;
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL)
continue;
g_ut_modules++;
if (t->RegisterTests == NULL) {
if (coverage_unittests)
SCLogWarning(SC_WARN_NO_UNITTESTS, "threading module %s has no unittest "
"registration function.", t->name);
} else {
t->RegisterTests();
g_ut_covered++;
}
}
#endif /* UNITTESTS */
}
示例5: NFQVerdictCacheFlush
static void NFQVerdictCacheFlush(NFQQueueVars *t)
{
#ifdef HAVE_NFQ_SET_VERDICT_BATCH
int ret;
int iter = 0;
do {
if (t->verdict_cache.mark_valid)
ret = nfq_set_verdict_batch2(t->qh,
t->verdict_cache.packet_id,
t->verdict_cache.verdict,
t->verdict_cache.mark);
else
ret = nfq_set_verdict_batch(t->qh,
t->verdict_cache.packet_id,
t->verdict_cache.verdict);
} 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));
} else {
t->verdict_cache.len = 0;
t->verdict_cache.mark_valid = 0;
}
#endif
}
示例6: SetEthtoolValue
static int SetEthtoolValue(const char *dev, int cmd, uint32_t value)
{
struct ifreq ifr;
int fd;
struct ethtool_value ethv;
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
return -1;
}
(void)strlcpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
ethv.cmd = cmd;
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);
close(fd);
return -1;
}
close(fd);
return 0;
}
示例7: GetIfaceMTU
/**
* \brief output the link MTU
*
* \param Name of link
* \retval -1 in case of error, 0 if MTU can not be found
*/
int GetIfaceMTU(const char *pcap_dev)
{
#if defined SIOCGIFMTU
struct ifreq ifr;
int fd;
(void)strlcpy(ifr.ifr_name, pcap_dev, sizeof(ifr.ifr_name));
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
return -1;
}
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);
close(fd);
return -1;
}
close(fd);
SCLogInfo("Found an MTU of %d for '%s'", ifr.ifr_mtu,
pcap_dev);
return ifr.ifr_mtu;
#elif defined OS_WIN32
return GetIfaceMTUWin32(pcap_dev);
#else
/* ioctl is not defined, let's pretend returning 0 is ok */
return 0;
#endif
}
示例8: JsonDropLogInitCtx
static OutputInitResult JsonDropLogInitCtx(ConfNode *conf)
{
OutputInitResult result = { NULL, false };
if (OutputDropLoggerEnable() != 0) {
SCLogError(SC_ERR_CONF_YAML_ERROR, "only one 'drop' logger "
"can be enabled");
return result;
}
JsonDropOutputCtx *drop_ctx = SCCalloc(1, sizeof(*drop_ctx));
if (drop_ctx == NULL)
return result;
drop_ctx->file_ctx = LogFileNewCtx();
if (drop_ctx->file_ctx == NULL) {
JsonDropOutputCtxFree(drop_ctx);
return result;
}
if (SCConfLogOpenGeneric(conf, drop_ctx->file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
JsonDropOutputCtxFree(drop_ctx);
return result;
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
if (unlikely(output_ctx == NULL)) {
JsonDropOutputCtxFree(drop_ctx);
return result;
}
if (conf) {
const char *extended = ConfNodeLookupChildValue(conf, "alerts");
if (extended != NULL) {
if (ConfValIsTrue(extended)) {
drop_ctx->flags = LOG_DROP_ALERTS;
}
}
extended = ConfNodeLookupChildValue(conf, "flows");
if (extended != NULL) {
if (strcasecmp(extended, "start") == 0) {
g_droplog_flows_start = 1;
} 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'");
}
}
}
output_ctx->data = drop_ctx;
output_ctx->DeInit = JsonDropLogDeInitCtx;
result.ctx = output_ctx;
result.ok = true;
return result;
}
示例9: NFQRecvPkt
void NFQRecvPkt(NFQQueueVars *t, NFQThreadVars *tv) {
int rv, ret;
/* XXX what happens on rv == 0? */
rv = recv(t->fd, tv->data, tv->datalen, 0);
if (rv < 0) {
if (errno == EINTR || errno == EWOULDBLOCK) {
/* no error on timeout */
} else {
#ifdef COUNTERS
NFQMutexLock(t);
t->errs++;
NFQMutexUnlock(t);
#endif /* COUNTERS */
}
} else if(rv == 0) {
SCLogWarning(SC_ERR_NFQ_RECV, "recv got returncode 0");
} else {
#ifdef DBG_PERF
if (rv > t->dbg_maxreadsize)
t->dbg_maxreadsize = rv;
#endif /* DBG_PERF */
//printf("NFQRecvPkt: t %p, rv = %" PRId32 "\n", t, rv);
NFQMutexLock(t);
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");
ret = -1;
}
NFQMutexUnlock(t);
if (ret != 0) {
SCLogWarning(SC_ERR_NFQ_HANDLE_PKT, "nfq_handle_packet error %" PRId32 "", ret);
}
}
}
示例10: BUG_ON
static void *DetectFilemagicThreadInit(void *data)
{
char *filename = NULL;
FILE *fd = NULL;
DetectFilemagicData *filemagic = (DetectFilemagicData *)data;
BUG_ON(filemagic == NULL);
DetectFilemagicThreadData *t = SCMalloc(sizeof(DetectFilemagicThreadData));
if (unlikely(t == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "couldn't alloc ctx memory");
return NULL;
}
memset(t, 0x00, sizeof(DetectFilemagicThreadData));
t->ctx = magic_open(0);
if (t->ctx == NULL) {
SCLogError(SC_ERR_MAGIC_OPEN, "magic_open failed: %s", magic_error(t->ctx));
goto error;
}
(void)ConfGet("magic-file", &filename);
if (filename != NULL) {
if (strlen(filename) == 0) {
/* set filename to NULL on *nix systems so magic_load uses system default path (see man libmagic) */
SCLogInfo("using system default magic-file");
filename = NULL;
}
else {
SCLogInfo("using magic-file %s", filename);
if ( (fd = fopen(filename, "r")) == NULL) {
SCLogWarning(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno));
goto error;
}
fclose(fd);
}
}
if (magic_load(t->ctx, filename) != 0) {
SCLogError(SC_ERR_MAGIC_LOAD, "magic_load failed: %s", magic_error(t->ctx));
goto error;
}
return (void *)t;
error:
if (t->ctx)
magic_close(t->ctx);
SCFree(t);
return NULL;
}
示例11: NFQRegisterQueue
/**
* \brief Add a single Netfilter queue
*
* \param string with the queue number
*
* \retval 0 on success.
* \retval -1 on failure.
*/
int NFQRegisterQueue(const uint16_t number)
{
NFQThreadVars *ntv = NULL;
NFQQueueVars *nq = NULL;
char queue[10] = { 0 };
static bool many_queues_warned = false;
uint16_t num_cpus = UtilCpuGetNumProcessorsOnline();
if (g_nfq_t == NULL || g_nfq_q == NULL) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "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) "
"may degrade performance",
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);
SCMutexUnlock(&nfq_init_lock);
return -1;
}
ntv = &g_nfq_t[receive_queue_num];
ntv->nfq_index = receive_queue_num;
nq = &g_nfq_q[receive_queue_num];
nq->queue_num = number;
receive_queue_num++;
SCMutexUnlock(&nfq_init_lock);
snprintf(queue, sizeof(queue) - 1, "NFQ#%hu", number);
LiveRegisterDevice(queue);
ntv->livedev = LiveGetDevice(queue);
if (ntv->livedev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Unable to find Live device");
return -1;
}
SCLogDebug("Queue %d registered.", number);
return 0;
}
示例12: ConfNodeLookupChildValue
/**
* \brief Create a new LogFileCtx for "syslog" output style.
*
* \param conf The configuration node for this output.
* \return A OutputCtx pointer on success, NULL on failure.
*/
OutputCtx *AlertSyslogInitCtx(ConfNode *conf)
{
const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
if (facility_s == NULL) {
facility_s = DEFAULT_ALERT_SYSLOG_FACILITY_STR;
}
LogFileCtx *logfile_ctx = LogFileNewCtx();
if (logfile_ctx == NULL) {
SCLogDebug("AlertSyslogInitCtx: Could not create new LogFileCtx");
return NULL;
}
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);
facility = DEFAULT_ALERT_SYSLOG_FACILITY;
}
const char *level_s = ConfNodeLookupChildValue(conf, "level");
if (level_s != NULL) {
int level = SCMapEnumNameToValue(level_s, SCSyslogGetLogLevelMap());
if (level != -1) {
alert_syslog_level = level;
}
}
const char *ident = ConfNodeLookupChildValue(conf, "identity");
/* if null we just pass that to openlog, which will then
* figure it out by itself. */
openlog(ident, LOG_PID|LOG_NDELAY, facility);
OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
if (unlikely(output_ctx == NULL)) {
SCLogDebug("AlertSyslogInitCtx: Could not create new OutputCtx");
return NULL;
}
memset(output_ctx, 0x00, sizeof(OutputCtx));
output_ctx->data = logfile_ctx;
output_ctx->DeInit = AlertSyslogDeInitCtx;
SCLogInfo("Syslog output initialized");
return output_ctx;
}
示例13: GetIfaceRSSQueuesNum
int GetIfaceRSSQueuesNum(const char *pcap_dev)
{
#if defined HAVE_LINUX_ETHTOOL_H && defined ETHTOOL_GRXRINGS
struct ifreq ifr;
struct ethtool_rxnfc nfccmd;
int fd;
(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);
return -1;
}
nfccmd.cmd = ETHTOOL_GRXRINGS;
ifr.ifr_data = (void*) &nfccmd;
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);
}
close(fd);
return 0;
}
close(fd);
SCLogInfo("Found %d RX RSS queues for '%s'", (int)nfccmd.data,
pcap_dev);
return (int)nfccmd.data;
#else
return 0;
#endif
}
示例14: LogFilestoreFinalizeFiles
static void LogFilestoreFinalizeFiles(const File *ff) {
char pid_expression[PATH_MAX] = "";
if (FileIncludePid())
snprintf(pid_expression, sizeof(pid_expression), ".%d", getpid());
char final_filename[PATH_MAX] = "";
if (snprintf(final_filename, sizeof(final_filename), "%s/file%s.%u",
g_logfile_base_dir, pid_expression, ff->file_store_id) == sizeof(final_filename))
return;
char working_filename[PATH_MAX] = "";
if (snprintf(working_filename, sizeof(working_filename), "%s%s",
final_filename, g_working_file_suffix) == sizeof(working_filename))
return;
if (rename(working_filename, final_filename) != 0) {
SCLogWarning(SC_WARN_RENAMING_FILE, "renaming file %s to %s failed",
working_filename, final_filename);
return;
}
if (FileWriteMeta()) {
LogFilestoreLogCloseMetaFile(ff);
char final_metafilename[PATH_MAX] = "";
if (snprintf(final_metafilename, sizeof(final_metafilename),
"%s.meta", final_filename) == sizeof(final_metafilename))
return;
char working_metafilename[PATH_MAX] = "";
if (snprintf(working_metafilename, sizeof(working_metafilename),
"%s%s", final_metafilename, g_working_file_suffix) == sizeof(working_metafilename))
return;
if (rename(working_metafilename, final_metafilename) != 0) {
SCLogWarning(SC_WARN_RENAMING_FILE,
"renaming metafile %s to %s failed", working_metafilename,
final_metafilename);
}
}
}
示例15: ReceiveIPFWThreadDeinit
/**
* \brief DeInit function closes divert socket at exit.
* \todo Unit tests are needed for this module.
* \param tv pointer to ThreadVars
* \param data pointer that gets cast into IPFWThreadVars for ptv
*/
TmEcode ReceiveIPFWThreadDeinit(ThreadVars *tv, void *data)
{
IPFWThreadVars *ptv = (IPFWThreadVars *)data;
IPFWQueueVars *nq = IPFWGetQueue(ptv->ipfw_index);
SCEnter();
/* 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));
SCReturnInt(TM_ECODE_FAILED);
}
SCReturnInt(TM_ECODE_OK);
}