libnet_t *c; /* libnet context */
char ebuf[LIBNET_ERRBUF_SIZE];
int result;
- char *devname = NULL;
+ const char *devname = NULL;
/* fill in struct defaults */
lpacket.ttl = 0;
libnet_t *c; /* libnet context */
char ebuf[LIBNET_ERRBUF_SIZE];
int result;
- char *devname = NULL;
+ const char *devname = NULL;
/* fill in struct defaults */
lpacket.ttl = 0;
libnet_t *c; /* libnet context */
char ebuf[LIBNET_ERRBUF_SIZE];
int result;
- char *devname = NULL;
+ const char *devname = NULL;
/* fill in struct defaults */
lpacket.ttl = 0;
libnet_t *c; /* libnet context */
char ebuf[LIBNET_ERRBUF_SIZE];
int result;
- char *devname = NULL;
+ const char *devname = NULL;
/* fill in struct defaults */
lpacket.ttl = 0;
if_default = ConfNodeLookupKeyValue(af_packet_node, "interface", "default");
for (ldev = 0; ldev < nlive; ldev++) {
- char *live_dev = LiveGetDeviceName(ldev);
+ const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0;
if (has_ids && has_ips) {
SCLogInfo("AF_PACKET mode using IPS and IDS mode");
for (ldev = 0; ldev < nlive; ldev++) {
- char *live_dev = LiveGetDeviceName(ldev);
+ const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0;
if_default = ConfNodeLookupKeyValue(netmap_node, "interface", "default");
for (ldev = 0; ldev < nlive; ldev++) {
- char *live_dev = LiveGetDeviceName(ldev);
+ const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0;
if (has_ids && has_ips) {
SCLogInfo("Netmap mode using IPS and IDS mode");
for (ldev = 0; ldev < nlive; ldev++) {
- char *live_dev = LiveGetDeviceName(ldev);
+ const char *live_dev = LiveGetDeviceName(ldev);
if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0;
ptv->tv = tv;
int result;
- char *link_name = (char *)initdata;
-
+ const char *link_name = (char *)initdata;
+
MpipeRegisterPerfCounters(ptv, tv);
*data = (void *)ptv;
case RUNMODE_PFRING:
nlive = LiveGetDeviceCount();
for (lthread = 0; lthread < nlive; lthread++) {
- char *live_dev = LiveGetDeviceName(lthread);
+ const char *live_dev = LiveGetDeviceName(lthread);
char dev[32];
(void)strlcpy(dev, live_dev, sizeof(dev));
-/* Copyright (C) 2011-2012 Open Information Security Foundation
+/* Copyright (C) 2011-2016 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
/** if set to 0 when we don't have real devices */
static int live_devices_stats = 1;
+static int LiveSafeDeviceName(const char *devname,
+ char *newdevname, size_t destlen);
+
/**
* \brief Add a pcap device for monitoring
*
SCFree(pd);
return -1;
}
+ /* create a short version to be used in thread names */
+ if (strlen(pd->dev) > MAX_DEVNAME) {
+ LiveSafeDeviceName(pd->dev, pd->dev_short, sizeof(pd->dev_short));
+ } else {
+ (void)strlcpy(pd->dev_short, pd->dev, sizeof(pd->dev_short));
+ }
+
SC_ATOMIC_INIT(pd->pkts);
SC_ATOMIC_INIT(pd->drop);
SC_ATOMIC_INIT(pd->invalid_checksums);
* \retval ptr pointer to the string containing the device
* \retval NULL on error
*/
-char *LiveGetDeviceName(int number)
+const char *LiveGetDeviceName(int number)
{
int i = 0;
LiveDevice *pd;
return NULL;
}
-/**
+/** \internal
* \brief Shorten a device name that is to long
*
* \param device name from config and destination for modified
*
* \retval None, is added to destination char *newdevname
*/
-int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen)
+static int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen)
{
size_t devnamelen = strlen(devname);
return NULL;
}
-
+const char *LiveGetShortName(const char *dev)
+{
+ LiveDevice *live_dev = LiveGetDevice(dev);
+ if (live_dev == NULL)
+ return NULL;
+ return live_dev->dev_short;
+}
int LiveBuildDeviceList(const char *runmode)
{
-/* Copyright (C) 2011-2012 Open Information Security Foundation
+/* Copyright (C) 2011-2016 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "queue.h"
#include "unix-manager.h"
+#define MAX_DEVNAME 10
+
/** storage for live device names */
typedef struct LiveDevice_ {
char *dev; /**< the device (e.g. "eth0") */
+ char dev_short[MAX_DEVNAME + 1];
int ignore_checksum;
SC_ATOMIC_DECLARE(uint64_t, pkts);
SC_ATOMIC_DECLARE(uint64_t, drop);
int LiveRegisterDevice(const char *dev);
int LiveGetDeviceCount(void);
-char *LiveGetDeviceName(int number);
-int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen);
+const char *LiveGetDeviceName(int number);
LiveDevice *LiveGetDevice(const char *dev);
+const char *LiveGetShortName(const char *dev);
int LiveBuildDeviceList(const char *base);
void LiveDeviceHasNoStats(void);
int LiveDeviceListClean(void);
int lthread;
for (lthread = 0; lthread < nlive; lthread++) {
- char *live_dev = LiveGetDeviceName(lthread);
- char visual_devname[11] = "";
- int shortening_result;
+ const char *live_dev = LiveGetDeviceName(lthread);
+ const char *visual_devname = LiveGetShortName(live_dev);
void *aconf;
int threads_count;
threads_count = ModThreadsCount(aconf);
for (thread = 0; thread < threads_count; thread++) {
- shortening_result = LiveSafeDeviceName(live_dev, visual_devname, sizeof(visual_devname));
- if (shortening_result != 0) {
- SCLogError(SC_ERR_INVALID_VALUE, "Could not shorten long devicename: %s", live_dev);
- exit(EXIT_FAILURE);
- }
-
snprintf(tname, sizeof(tname), "%s#%02d-%s", thread_name,
thread+1, visual_devname);
/* create the threads */
for (thread = 0; thread < threads_count; thread++) {
char tname[TM_THREAD_NAME_MAX];
- char visual_devname[11] = "";
- int shortening_result;
ThreadVars *tv = NULL;
TmModule *tm_module = NULL;
-
- shortening_result = LiveSafeDeviceName(live_dev, visual_devname, sizeof(visual_devname));
- if (shortening_result != 0) {
- SCLogError(SC_ERR_INVALID_VALUE, "Could not shorten long devicename: %s", live_dev);
- exit(EXIT_FAILURE);
- }
+ const char *visual_devname = LiveGetShortName(live_dev);
if (single_mode) {
snprintf(tname, sizeof(tname), "%s#01-%s", thread_name, visual_devname);
char tname[TM_THREAD_NAME_MAX];
char qname[TM_QUEUE_NAME_MAX];
TmModule *tm_module ;
- char *cur_queue = NULL;
+ const char *cur_queue = NULL;
char *queues = NULL;
int thread;
char tname[TM_THREAD_NAME_MAX];
ThreadVars *tv = NULL;
TmModule *tm_module = NULL;
- char *cur_queue = NULL;
+ const char *cur_queue = NULL;
int nqueue = LiveGetDeviceCount();