suricata
util-device.c
Go to the documentation of this file.
1 /* Copyright (C) 2011-2016 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #include "suricata-common.h"
19 #include "conf.h"
20 #include "util-device.h"
21 #include "util-ioctl.h"
22 #include "util-misc.h"
23 
24 #include "device-storage.h"
25 
26 #define MAX_DEVNAME 10
27 
28 static int g_bypass_storage_id = -1;
29 
30 /**
31  * \file
32  *
33  * \author Eric Leblond <eric@regit.org>
34  *
35  * \brief Utility functions to handle device list
36  */
37 
38 /** private device list */
39 static TAILQ_HEAD(, LiveDevice_) live_devices =
40  TAILQ_HEAD_INITIALIZER(live_devices);
41 
42 /** List of the name of devices
43  *
44  * As we don't know the size of the Storage on devices
45  * before the parsing we need to wait and use this list
46  * to create later the LiveDevice via LiveDeviceFinalize()
47  */
48 static TAILQ_HEAD(, LiveDeviceName_) pre_live_devices =
49  TAILQ_HEAD_INITIALIZER(pre_live_devices);
50 
51 typedef struct BypassInfo_ {
52  SC_ATOMIC_DECLARE(uint64_t, ipv4_hash_count);
53  SC_ATOMIC_DECLARE(uint64_t, ipv4_fail);
54  SC_ATOMIC_DECLARE(uint64_t, ipv4_success);
55  SC_ATOMIC_DECLARE(uint64_t, ipv6_hash_count);
56  SC_ATOMIC_DECLARE(uint64_t, ipv6_fail);
57  SC_ATOMIC_DECLARE(uint64_t, ipv6_success);
59 
60 /** if set to 0 when we don't have real devices */
61 static int live_devices_stats = 1;
62 
63 
64 static int LiveSafeDeviceName(const char *devname,
65  char *newdevname, size_t destlen);
66 
67 static int g_live_devices_disable_offloading = 1;
68 
70 {
71  g_live_devices_disable_offloading = 1;
72 }
73 
75 {
76  g_live_devices_disable_offloading = 0;
77 }
78 
79 int LiveGetOffload(void)
80 {
81  return g_live_devices_disable_offloading;
82 }
83 
84 /**
85  * \brief Add a device for monitoring
86  *
87  * To be used during option parsing. When a device has
88  * to be created during runmode init, use LiveRegisterDevice()
89  *
90  * \param dev string with the device name
91  *
92  * \retval 0 on success.
93  * \retval -1 on failure.
94  */
95 int LiveRegisterDeviceName(const char *dev)
96 {
97  LiveDeviceName *pd = NULL;
98 
99  pd = SCCalloc(1, sizeof(LiveDeviceName));
100  if (unlikely(pd == NULL)) {
101  return -1;
102  }
103 
104  pd->dev = SCStrdup(dev);
105  if (unlikely(pd->dev == NULL)) {
106  SCFree(pd);
107  return -1;
108  }
109 
110  TAILQ_INSERT_TAIL(&pre_live_devices, pd, next);
111 
112  SCLogDebug("Device \"%s\" registered.", dev);
113  return 0;
114 }
115 
116 /**
117  * \brief Add a pcap device for monitoring and create structure
118  *
119  * \param dev string with the device name
120  *
121  * \retval 0 on success.
122  * \retval -1 on failure.
123  */
124 int LiveRegisterDevice(const char *dev)
125 {
126  LiveDevice *pd = NULL;
127 
128  pd = SCCalloc(1, sizeof(LiveDevice) + LiveDevStorageSize());
129  if (unlikely(pd == NULL)) {
130  return -1;
131  }
132 
133  pd->dev = SCStrdup(dev);
134  if (unlikely(pd->dev == NULL)) {
135  SCFree(pd);
136  return -1;
137  }
138  /* create a short version to be used in thread names */
139  LiveSafeDeviceName(pd->dev, pd->dev_short, sizeof(pd->dev_short));
140 
141  SC_ATOMIC_INIT(pd->pkts);
142  SC_ATOMIC_INIT(pd->drop);
143  SC_ATOMIC_INIT(pd->invalid_checksums);
144  pd->ignore_checksum = 0;
145  pd->id = LiveGetDeviceCount();
146  TAILQ_INSERT_TAIL(&live_devices, pd, next);
147 
148  SCLogDebug("Device \"%s\" registered and created.", dev);
149  return 0;
150 }
151 
152 /**
153  * \brief Get the number of registered devices
154  *
155  * \retval cnt the number of registered devices
156  */
158 {
159  int i = 0;
160  LiveDevice *pd;
161 
162  TAILQ_FOREACH(pd, &live_devices, next) {
163  i++;
164  }
165 
166  return i;
167 }
168 
169 /**
170  * \brief Get a pointer to the device name at idx
171  *
172  * \param number idx of the device in our list
173  *
174  * \retval ptr pointer to the string containing the device
175  * \retval NULL on error
176  */
177 const char *LiveGetDeviceName(int number)
178 {
179  int i = 0;
180  LiveDevice *pd;
181 
182  TAILQ_FOREACH(pd, &live_devices, next) {
183  if (i == number) {
184  return pd->dev;
185  }
186 
187  i++;
188  }
189 
190  return NULL;
191 }
192 
193 /** \internal
194  * \brief Shorten a device name that is to long
195  *
196  * \param device name from config and destination for modified
197  *
198  * \retval None, is added to destination char *newdevname
199  */
200 static int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen)
201 {
202  const size_t devnamelen = strlen(devname);
203 
204  /* If we have to shorten the interface name */
205  if (devnamelen > MAX_DEVNAME) {
206 
207  /* IF the dest length is over 10 chars long it will not do any
208  * good for the shortening. The shortening is done due to the
209  * max length of pthread names (15 chars) and we use 3 chars
210  * for the threadname indicator eg. "W#-" and one-two chars for
211  * the thread number. And if the destination buffer is under
212  * 6 chars there is no point in shortening it since we must at
213  * least enter two periods (.) into the string.
214  */
215  if ((destlen-1) > 10 || (destlen-1) < 6) {
216  return 1;
217  }
218 
219  ShortenString(devname, newdevname, destlen, '.');
220 
221  SCLogInfo("Shortening device name to: %s", newdevname);
222  } else {
223  strlcpy(newdevname, devname, destlen);
224  }
225  return 0;
226 }
227 
228 /**
229  * \brief Get a pointer to the device at idx
230  *
231  * \param number idx of the device in our list
232  *
233  * \retval ptr pointer to the string containing the device
234  * \retval NULL on error
235  */
236 LiveDevice *LiveGetDevice(const char *name)
237 {
238  int i = 0;
239  LiveDevice *pd;
240 
241  if (name == NULL) {
242  SCLogWarning(SC_ERR_INVALID_VALUE, "Name of device should not be null");
243  return NULL;
244  }
245 
246  TAILQ_FOREACH(pd, &live_devices, next) {
247  if (!strcmp(name, pd->dev)) {
248  return pd;
249  }
250 
251  i++;
252  }
253 
254  return NULL;
255 }
256 
257 const char *LiveGetShortName(const char *dev)
258 {
259  LiveDevice *live_dev = LiveGetDevice(dev);
260  if (live_dev == NULL)
261  return NULL;
262  return live_dev->dev_short;
263 }
264 
265 int LiveBuildDeviceList(const char *runmode)
266 {
267  return LiveBuildDeviceListCustom(runmode, "interface");
268 }
269 
270 int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
271 {
272  ConfNode *base = ConfGetNode(runmode);
273  ConfNode *child;
274  int i = 0;
275 
276  if (base == NULL)
277  return 0;
278 
279  TAILQ_FOREACH(child, &base->head, next) {
280  ConfNode *subchild;
281  TAILQ_FOREACH(subchild, &child->head, next) {
282  if ((!strcmp(subchild->name, itemname))) {
283  if (!strcmp(subchild->val, "default"))
284  break;
285  SCLogConfig("Adding %s %s from config file",
286  itemname, subchild->val);
287  LiveRegisterDeviceName(subchild->val);
288  i++;
289  }
290  }
291  }
292 
293  return i;
294 }
295 
296 /** Call this function to disable stat on live devices
297  *
298  * This can be useful in the case, this is not a real interface.
299  */
301 {
302  live_devices_stats = 0;
303 }
304 
306 {
307  SCEnter();
308  LiveDevice *pd, *tpd;
309 
310  TAILQ_FOREACH_SAFE(pd, &live_devices, next, tpd) {
311  if (live_devices_stats) {
312  SCLogNotice("Stats for '%s': pkts: %" PRIu64", drop: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64,
313  pd->dev,
314  SC_ATOMIC_GET(pd->pkts),
315  SC_ATOMIC_GET(pd->drop),
316  100 * (SC_ATOMIC_GET(pd->drop) * 1.0) / SC_ATOMIC_GET(pd->pkts),
317  SC_ATOMIC_GET(pd->invalid_checksums));
318  }
319 
321 
322  if (pd->dev)
323  SCFree(pd->dev);
324  SC_ATOMIC_DESTROY(pd->pkts);
325  SC_ATOMIC_DESTROY(pd->drop);
326  SC_ATOMIC_DESTROY(pd->invalid_checksums);
327  LiveDevFreeStorage(pd);
328  SCFree(pd);
329  }
330 
332 }
333 
334 #ifdef BUILD_UNIX_SOCKET
335 TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *answer, void *data)
336 {
337  SCEnter();
338  LiveDevice *pd;
339  const char * name = NULL;
340  json_t *jarg = json_object_get(cmd, "iface");
341  if(!json_is_string(jarg)) {
342  json_object_set_new(answer, "message", json_string("Iface is not a string"));
344  }
345  name = json_string_value(jarg);
346  if (name == NULL) {
347  json_object_set_new(answer, "message", json_string("Iface name is NULL"));
349  }
350 
351  TAILQ_FOREACH(pd, &live_devices, next) {
352  if (!strcmp(name, pd->dev)) {
353  json_t *jdata = json_object();
354  if (jdata == NULL) {
355  json_object_set_new(answer, "message",
356  json_string("internal error at json object creation"));
358  }
359  json_object_set_new(jdata, "pkts",
360  json_integer(SC_ATOMIC_GET(pd->pkts)));
361  json_object_set_new(jdata, "invalid-checksums",
362  json_integer(SC_ATOMIC_GET(pd->invalid_checksums)));
363  json_object_set_new(jdata, "drop",
364  json_integer(SC_ATOMIC_GET(pd->drop)));
365  json_object_set_new(jdata, "bypassed",
366  json_integer(SC_ATOMIC_GET(pd->bypassed)));
367  json_object_set_new(answer, "message", jdata);
369  }
370  }
371  json_object_set_new(answer, "message", json_string("Iface does not exist"));
373 }
374 
375 TmEcode LiveDeviceIfaceList(json_t *cmd, json_t *answer, void *data)
376 {
377  SCEnter();
378  json_t *jdata;
379  json_t *jarray;
380  LiveDevice *pd;
381  int i = 0;
382 
383  jdata = json_object();
384  if (jdata == NULL) {
385  json_object_set_new(answer, "message",
386  json_string("internal error at json object creation"));
387  return TM_ECODE_FAILED;
388  }
389  jarray = json_array();
390  if (jarray == NULL) {
391  json_object_set_new(answer, "message",
392  json_string("internal error at json object creation"));
393  return TM_ECODE_FAILED;
394  }
395  TAILQ_FOREACH(pd, &live_devices, next) {
396  json_array_append_new(jarray, json_string(pd->dev));
397  i++;
398  }
399 
400  json_object_set_new(jdata, "count", json_integer(i));
401  json_object_set_new(jdata, "ifaces", jarray);
402  json_object_set_new(answer, "message", jdata);
404 }
405 
406 #endif /* BUILD_UNIX_SOCKET */
407 
409 {
410  if (*ldev == NULL) {
411  *ldev = TAILQ_FIRST(&live_devices);
412  *ndev = TAILQ_NEXT(*ldev, next);
413  return *ldev;
414  } else {
415  *ldev = *ndev;
416  if (*ldev) {
417  *ndev = TAILQ_NEXT(*ldev, next);
418  }
419  return *ldev;
420  }
421  return NULL;
422 }
423 
424 /**
425  * Create registered devices
426  *
427  * This function creates all needed LiveDevice from
428  * the LiveDeviceName list created via LiveRegisterDevice()
429  */
431 {
432  LiveDeviceName *ld, *pld;
433  SCLogDebug("Finalize live device");
434  /* Iter on devices and register them */
435  TAILQ_FOREACH_SAFE(ld, &pre_live_devices, next, pld) {
436  if (ld->dev) {
437  LiveRegisterDevice(ld->dev);
438  SCFree(ld->dev);
439  }
440  SCFree(ld);
441  }
442 }
443 
444 static void LiveDevExtensionFree(void *x)
445 {
446  if (x)
447  SCFree(x);
448 }
449 
450 /**
451  * Register bypass stats storage
452  */
454 {
455  g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", sizeof(void *),
456  NULL, LiveDevExtensionFree);
457 }
458 
459 /**
460  * Prepare a LiveDevice so we can set bypass stats
461  */
463 {
464  BypassInfo *bpinfo = SCCalloc(1, sizeof(*bpinfo));
465  if (bpinfo == NULL) {
466  SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bypass info structure");
467  return -1;
468  }
469 
470  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
471  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
472 
473  LiveDevSetStorageById(dev, g_bypass_storage_id, bpinfo);
474  return 0;
475 }
476 
477 /**
478  * Set number of currently bypassed flows for a protocol family
479  *
480  * \param dev pointer to LiveDevice to set stats for
481  * \param cnt number of currently bypassed flows
482  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
483  */
484 void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family)
485 {
486  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
487  if (bpfdata) {
488  if (family == AF_INET) {
489  SC_ATOMIC_SET(bpfdata->ipv4_hash_count, cnt);
490  } else if (family == AF_INET6) {
491  SC_ATOMIC_SET(bpfdata->ipv6_hash_count, cnt);
492  }
493  }
494 }
495 
496 /**
497  * Increase number of currently bypassed flows for a protocol family
498  *
499  * \param dev pointer to LiveDevice to set stats for
500  * \param cnt number of flows to add
501  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
502  */
503 void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
504 {
505  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
506  if (bpfdata) {
507  if (family == AF_INET) {
508  SC_ATOMIC_ADD(bpfdata->ipv4_hash_count, cnt);
509  } else if (family == AF_INET6) {
510  SC_ATOMIC_ADD(bpfdata->ipv6_hash_count, cnt);
511  }
512  }
513 }
514 
515 /**
516  * Decrease number of currently bypassed flows for a protocol family
517  *
518  * \param dev pointer to LiveDevice to set stats for
519  * \param cnt number of flows to remove
520  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
521  */
522 void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
523 {
524  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
525  if (bpfdata) {
526  if (family == AF_INET) {
527  SC_ATOMIC_SUB(bpfdata->ipv4_hash_count, cnt);
528  } else if (family == AF_INET6) {
529  SC_ATOMIC_SUB(bpfdata->ipv6_hash_count, cnt);
530  }
531  }
532 }
533 
534 /**
535  * Increase number of failed captured flows for a protocol family
536  *
537  * \param dev pointer to LiveDevice to set stats for
538  * \param cnt number of flows to add
539  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
540  */
541 void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
542 {
543  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
544  if (bpfdata) {
545  if (family == AF_INET) {
546  SC_ATOMIC_ADD(bpfdata->ipv4_fail, cnt);
547  } else if (family == AF_INET6) {
548  SC_ATOMIC_ADD(bpfdata->ipv6_fail, cnt);
549  }
550  }
551 }
552 
553 /**
554  * Increase number of currently succesfully bypassed flows for a protocol family
555  *
556  * \param dev pointer to LiveDevice to set stats for
557  * \param cnt number of flows to add
558  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
559  */
560 void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
561 {
562  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
563  if (bpfdata) {
564  if (family == AF_INET) {
565  SC_ATOMIC_ADD(bpfdata->ipv4_success, cnt);
566  } else if (family == AF_INET6) {
567  SC_ATOMIC_ADD(bpfdata->ipv6_success, cnt);
568  }
569  }
570 }
571 
572 #ifdef BUILD_UNIX_SOCKET
573 TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data)
574 {
575  LiveDevice *ldev = NULL, *ndev;
576 
577  json_t *ifaces = NULL;
578  while(LiveDeviceForEach(&ldev, &ndev)) {
579  BypassInfo *bpinfo = LiveDevGetStorageById(ldev, g_bypass_storage_id);
580  if (bpinfo) {
581  uint64_t ipv4_hash_count = SC_ATOMIC_GET(bpinfo->ipv4_hash_count);
582  uint64_t ipv6_hash_count = SC_ATOMIC_GET(bpinfo->ipv6_hash_count);
583  uint64_t ipv4_success = SC_ATOMIC_GET(bpinfo->ipv4_success);
584  uint64_t ipv4_fail = SC_ATOMIC_GET(bpinfo->ipv4_fail);
585  uint64_t ipv6_success = SC_ATOMIC_GET(bpinfo->ipv6_success);
586  uint64_t ipv6_fail = SC_ATOMIC_GET(bpinfo->ipv6_fail);
587  json_t *iface = json_object();
588  if (ifaces == NULL) {
589  ifaces = json_object();
590  if (ifaces == NULL) {
591  json_object_set_new(answer, "message",
592  json_string("internal error at json object creation"));
593  return TM_ECODE_FAILED;
594  }
595  }
596  json_object_set_new(iface, "ipv4_maps_count", json_integer(ipv4_hash_count));
597  json_object_set_new(iface, "ipv4_success", json_integer(ipv4_success));
598  json_object_set_new(iface, "ipv4_fail", json_integer(ipv4_fail));
599  json_object_set_new(iface, "ipv6_maps_count", json_integer(ipv6_hash_count));
600  json_object_set_new(iface, "ipv6_success", json_integer(ipv6_success));
601  json_object_set_new(iface, "ipv6_fail", json_integer(ipv6_fail));
602  json_object_set_new(ifaces, ldev->dev, iface);
603  }
604  }
605  if (ifaces) {
606  json_object_set_new(answer, "message", ifaces);
608  }
609 
610  json_object_set_new(answer, "message",
611  json_string("No interface using bypass"));
613 }
614 #endif
const char * LiveGetDeviceName(int number)
Get a pointer to the device name at idx.
Definition: util-device.c:177
#define SCLogDebug(...)
Definition: util-debug.h:335
#define TAILQ_FIRST(head)
Definition: queue.h:339
#define SC_ATOMIC_DECLARE(type, name)
wrapper to declare an atomic variable including a (spin) lock to protect it.
Definition: util-atomic.h:56
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:350
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
Definition: util-device.c:124
struct HtpBodyChunk_ * next
LiveDevice * LiveDeviceForEach(LiveDevice **ldev, LiveDevice **ndev)
Definition: util-device.c:408
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:522
#define unlikely(expr)
Definition: util-optimize.h:35
void LiveDevFreeStorage(LiveDevice *d)
int LiveDevSetStorageById(LiveDevice *d, int id, void *ptr)
Store a pointer in a given LiveDevice storage.
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:356
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:107
int LiveBuildDeviceList(const char *runmode)
Definition: util-device.c:265
unsigned int LiveDevStorageSize(void)
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:157
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
Definition: util-atomic.h:124
#define TAILQ_HEAD(name, type)
Definition: queue.h:321
char * val
Definition: conf.h:34
char dev_short[MAX_DEVNAME+1]
Definition: util-device.h:42
#define SC_ATOMIC_DESTROY(name)
Destroy the lock used to protect this variable.
Definition: util-atomic.h:97
void LiveDevRegisterExtension(void)
Definition: util-device.c:453
char * dev
Definition: util-device.h:41
void LiveDeviceFinalize(void)
Definition: util-device.c:430
#define SC_ATOMIC_INIT(name)
Initialize the previously declared atomic variable and it&#39;s lock.
Definition: util-atomic.h:81
void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:541
#define SCCalloc(nm, a)
Definition: util-mem.h:253
int LiveDeviceListClean()
Definition: util-device.c:305
BypassInfo
Definition: util-device.c:58
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SCEnter(...)
Definition: util-debug.h:337
void ShortenString(const char *input, char *output, size_t output_size, char c)
Definition: util-misc.c:220
void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:484
int LiveDevUseBypass(LiveDevice *dev)
Definition: util-device.c:462
#define SCReturnInt(x)
Definition: util-debug.h:341
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Definition: util-device.c:236
void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:503
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:385
Definition: conf.h:32
int ignore_checksum
Definition: util-device.h:45
void * LiveDevGetStorageById(LiveDevice *d, int id)
Get a value from a given LiveDevice storage.
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
Definition: util-atomic.h:207
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:254
#define SCFree(a)
Definition: util-mem.h:322
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:269
const char * LiveGetShortName(const char *dev)
Definition: util-device.c:257
char * name
Definition: conf.h:33
int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
Definition: util-device.c:270
#define MAX_DEVNAME
Definition: util-device.c:26
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192
void LiveSetOffloadWarn(void)
Definition: util-device.c:74
int LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *))
Register a LiveDevice storage.
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
Definition: conf.c:176
#define SCStrdup(a)
Definition: util-mem.h:268
void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:560
#define TAILQ_NEXT(elm, field)
Definition: queue.h:341
void LiveSetOffloadDisable(void)
Definition: util-device.c:69
void RestoreIfaceOffloading(LiveDevice *dev)
Definition: util-ioctl.c:724
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:327
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
int LiveGetOffload(void)
Definition: util-device.c:79
void LiveDeviceHasNoStats()
Definition: util-device.c:300
int LiveRegisterDeviceName(const char *dev)
Add a device for monitoring.
Definition: util-device.c:95