#include "conf.h"
#include "util-device.h"
+#define MAX_DEVNAME 12
+#define DEVNAME_CHUNCK 5
+
/**
* \file
*
return NULL;
}
+/**
+ * \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
+ */
+void LiveSafeDeviceName(const char *devname, char *newdevname)
+{
+ size_t devnamelen = strlen(devname);
+
+ if (devnamelen > MAX_DEVNAME) {
+ strncpy(newdevname, devname, DEVNAME_CHUNCK);
+ strncpy(newdevname+DEVNAME_CHUNCK, "...", 3);
+ strncpy(newdevname+8, devname+(devnamelen-DEVNAME_CHUNCK), DEVNAME_CHUNCK);
+ strncpy(newdevname+13, "\0", 1);
+ SCLogInfo("Shortening device name to: %s", newdevname);
+ } else {
+ strcpy(newdevname, devname);
+ }
+}
+
/**
* \brief Get a pointer to the device at idx
*
int LiveRegisterDevice(const char *dev);
int LiveGetDeviceCount(void);
char *LiveGetDeviceName(int number);
+void LiveSafeDeviceName(const char *devname, char *newdevname);
LiveDevice *LiveGetDevice(const char *dev);
int LiveBuildDeviceList(const char *base);
void LiveDeviceHasNoStats(void);
for (lthread = 0; lthread < nlive; lthread++) {
char *live_dev = LiveGetDeviceName(lthread);
+ char visual_devname[14] = "";
void *aconf;
int threads_count;
threads_count = ModThreadsCount(aconf);
for (thread = 0; thread < threads_count; thread++) {
+ LiveSafeDeviceName(live_dev, visual_devname);
snprintf(tname, sizeof(tname), "%s%s%d", thread_name,
live_dev, thread+1);
ThreadVars *tv_receive =
/* create the threads */
for (thread = 0; thread < threads_count; thread++) {
char tname[TM_THREAD_NAME_MAX];
+ char *n_thread_name = NULL;
+ char visual_devname[13] = "";
ThreadVars *tv = NULL;
TmModule *tm_module = NULL;
if (single_mode) {
snprintf(tname, sizeof(tname), "%s", thread_name);
} else {
+ LiveSafeDeviceName(live_dev, visual_devname);
+ SCLogInfo("New dev name %s", visual_devname);
snprintf(tname, sizeof(tname), "%s%s%d",
thread_name, live_dev, thread+1);
}