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 /**
194  * \brief Get the number of pre registered devices
195  *
196  * \retval cnt the number of pre registered devices
197  */
199 {
200  int i = 0;
201  LiveDeviceName *pd;
202 
203  TAILQ_FOREACH(pd, &pre_live_devices, next) {
204  i++;
205  }
206 
207  return i;
208 }
209 
210 /**
211  * \brief Get a pointer to the pre device name at idx
212  *
213  * \param number idx of the pre device in our list
214  *
215  * \retval ptr pointer to the string containing the device
216  * \retval NULL on error
217  */
218 const char *LiveGetDeviceNameName(int number)
219 {
220  int i = 0;
221  LiveDeviceName *pd;
222 
223  TAILQ_FOREACH(pd, &pre_live_devices, next) {
224  if (i == number) {
225  return pd->dev;
226  }
227 
228  i++;
229  }
230 
231  return NULL;
232 }
233 
234 
235 
236 /** \internal
237  * \brief Shorten a device name that is to long
238  *
239  * \param device name from config and destination for modified
240  *
241  * \retval None, is added to destination char *newdevname
242  */
243 static int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen)
244 {
245  const size_t devnamelen = strlen(devname);
246 
247  /* If we have to shorten the interface name */
248  if (devnamelen > MAX_DEVNAME) {
249 
250  /* IF the dest length is over 10 chars long it will not do any
251  * good for the shortening. The shortening is done due to the
252  * max length of pthread names (15 chars) and we use 3 chars
253  * for the threadname indicator eg. "W#-" and one-two chars for
254  * the thread number. And if the destination buffer is under
255  * 6 chars there is no point in shortening it since we must at
256  * least enter two periods (.) into the string.
257  */
258  if ((destlen-1) > 10 || (destlen-1) < 6) {
259  return 1;
260  }
261 
262  ShortenString(devname, newdevname, destlen, '.');
263 
264  SCLogInfo("Shortening device name to: %s", newdevname);
265  } else {
266  strlcpy(newdevname, devname, destlen);
267  }
268  return 0;
269 }
270 
271 /**
272  * \brief Get a pointer to the device at idx
273  *
274  * \param number idx of the device in our list
275  *
276  * \retval ptr pointer to the string containing the device
277  * \retval NULL on error
278  */
279 LiveDevice *LiveGetDevice(const char *name)
280 {
281  int i = 0;
282  LiveDevice *pd;
283 
284  if (name == NULL) {
285  SCLogWarning(SC_ERR_INVALID_VALUE, "Name of device should not be null");
286  return NULL;
287  }
288 
289  TAILQ_FOREACH(pd, &live_devices, next) {
290  if (!strcmp(name, pd->dev)) {
291  return pd;
292  }
293 
294  i++;
295  }
296 
297  return NULL;
298 }
299 
300 const char *LiveGetShortName(const char *dev)
301 {
302  LiveDevice *live_dev = LiveGetDevice(dev);
303  if (live_dev == NULL)
304  return NULL;
305  return live_dev->dev_short;
306 }
307 
308 int LiveBuildDeviceList(const char *runmode)
309 {
310  return LiveBuildDeviceListCustom(runmode, "interface");
311 }
312 
313 int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
314 {
315  ConfNode *base = ConfGetNode(runmode);
316  ConfNode *child;
317  int i = 0;
318 
319  if (base == NULL)
320  return 0;
321 
322  TAILQ_FOREACH(child, &base->head, next) {
323  ConfNode *subchild;
324  TAILQ_FOREACH(subchild, &child->head, next) {
325  if ((!strcmp(subchild->name, itemname))) {
326  if (!strcmp(subchild->val, "default"))
327  break;
328  SCLogConfig("Adding %s %s from config file",
329  itemname, subchild->val);
330  LiveRegisterDeviceName(subchild->val);
331  i++;
332  }
333  }
334  }
335 
336  return i;
337 }
338 
339 /** Call this function to disable stat on live devices
340  *
341  * This can be useful in the case, this is not a real interface.
342  */
344 {
345  live_devices_stats = 0;
346 }
347 
349 {
350  SCEnter();
351  LiveDevice *pd, *tpd;
352 
353  TAILQ_FOREACH_SAFE(pd, &live_devices, next, tpd) {
354  if (live_devices_stats) {
355  SCLogNotice("Stats for '%s': pkts: %" PRIu64", drop: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64,
356  pd->dev,
357  SC_ATOMIC_GET(pd->pkts),
358  SC_ATOMIC_GET(pd->drop),
359  100 * (SC_ATOMIC_GET(pd->drop) * 1.0) / SC_ATOMIC_GET(pd->pkts),
360  SC_ATOMIC_GET(pd->invalid_checksums));
361  }
362 
364 
365  if (pd->dev)
366  SCFree(pd->dev);
367  SC_ATOMIC_DESTROY(pd->pkts);
368  SC_ATOMIC_DESTROY(pd->drop);
369  SC_ATOMIC_DESTROY(pd->invalid_checksums);
370  LiveDevFreeStorage(pd);
371  SCFree(pd);
372  }
373 
375 }
376 
377 #ifdef BUILD_UNIX_SOCKET
378 TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *answer, void *data)
379 {
380  SCEnter();
381  LiveDevice *pd;
382  const char * name = NULL;
383  json_t *jarg = json_object_get(cmd, "iface");
384  if(!json_is_string(jarg)) {
385  json_object_set_new(answer, "message", json_string("Iface is not a string"));
387  }
388  name = json_string_value(jarg);
389  if (name == NULL) {
390  json_object_set_new(answer, "message", json_string("Iface name is NULL"));
392  }
393 
394  TAILQ_FOREACH(pd, &live_devices, next) {
395  if (!strcmp(name, pd->dev)) {
396  json_t *jdata = json_object();
397  if (jdata == NULL) {
398  json_object_set_new(answer, "message",
399  json_string("internal error at json object creation"));
401  }
402  json_object_set_new(jdata, "pkts",
403  json_integer(SC_ATOMIC_GET(pd->pkts)));
404  json_object_set_new(jdata, "invalid-checksums",
405  json_integer(SC_ATOMIC_GET(pd->invalid_checksums)));
406  json_object_set_new(jdata, "drop",
407  json_integer(SC_ATOMIC_GET(pd->drop)));
408  json_object_set_new(jdata, "bypassed",
409  json_integer(SC_ATOMIC_GET(pd->bypassed)));
410  json_object_set_new(answer, "message", jdata);
412  }
413  }
414  json_object_set_new(answer, "message", json_string("Iface does not exist"));
416 }
417 
418 TmEcode LiveDeviceIfaceList(json_t *cmd, json_t *answer, void *data)
419 {
420  SCEnter();
421  json_t *jdata;
422  json_t *jarray;
423  LiveDevice *pd;
424  int i = 0;
425 
426  jdata = json_object();
427  if (jdata == NULL) {
428  json_object_set_new(answer, "message",
429  json_string("internal error at json object creation"));
430  return TM_ECODE_FAILED;
431  }
432  jarray = json_array();
433  if (jarray == NULL) {
434  json_object_set_new(answer, "message",
435  json_string("internal error at json object creation"));
436  return TM_ECODE_FAILED;
437  }
438  TAILQ_FOREACH(pd, &live_devices, next) {
439  json_array_append_new(jarray, json_string(pd->dev));
440  i++;
441  }
442 
443  json_object_set_new(jdata, "count", json_integer(i));
444  json_object_set_new(jdata, "ifaces", jarray);
445  json_object_set_new(answer, "message", jdata);
447 }
448 
449 #endif /* BUILD_UNIX_SOCKET */
450 
452 {
453  if (*ldev == NULL) {
454  *ldev = TAILQ_FIRST(&live_devices);
455  *ndev = TAILQ_NEXT(*ldev, next);
456  return *ldev;
457  } else {
458  *ldev = *ndev;
459  if (*ldev) {
460  *ndev = TAILQ_NEXT(*ldev, next);
461  }
462  return *ldev;
463  }
464  return NULL;
465 }
466 
467 /**
468  * Create registered devices
469  *
470  * This function creates all needed LiveDevice from
471  * the LiveDeviceName list created via LiveRegisterDevice()
472  */
474 {
475  LiveDeviceName *ld, *pld;
476  SCLogDebug("Finalize live device");
477  /* Iter on devices and register them */
478  TAILQ_FOREACH_SAFE(ld, &pre_live_devices, next, pld) {
479  if (ld->dev) {
480  LiveRegisterDevice(ld->dev);
481  SCFree(ld->dev);
482  }
483  SCFree(ld);
484  }
485 }
486 
487 static void LiveDevExtensionFree(void *x)
488 {
489  if (x)
490  SCFree(x);
491 }
492 
493 /**
494  * Register bypass stats storage
495  */
497 {
498  g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", sizeof(void *),
499  NULL, LiveDevExtensionFree);
500 }
501 
502 /**
503  * Prepare a LiveDevice so we can set bypass stats
504  */
506 {
507  BypassInfo *bpinfo = SCCalloc(1, sizeof(*bpinfo));
508  if (bpinfo == NULL) {
509  SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate bypass info structure");
510  return -1;
511  }
512 
513  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
514  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
515 
516  LiveDevSetStorageById(dev, g_bypass_storage_id, bpinfo);
517  return 0;
518 }
519 
520 /**
521  * Set number of currently bypassed flows for a protocol family
522  *
523  * \param dev pointer to LiveDevice to set stats for
524  * \param cnt number of currently bypassed flows
525  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
526  */
527 void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family)
528 {
529  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
530  if (bpfdata) {
531  if (family == AF_INET) {
532  SC_ATOMIC_SET(bpfdata->ipv4_hash_count, cnt);
533  } else if (family == AF_INET6) {
534  SC_ATOMIC_SET(bpfdata->ipv6_hash_count, cnt);
535  }
536  }
537 }
538 
539 /**
540  * Increase number of currently bypassed flows for a protocol family
541  *
542  * \param dev pointer to LiveDevice to set stats for
543  * \param cnt number of flows to add
544  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
545  */
546 void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
547 {
548  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
549  if (bpfdata) {
550  if (family == AF_INET) {
551  SC_ATOMIC_ADD(bpfdata->ipv4_hash_count, cnt);
552  } else if (family == AF_INET6) {
553  SC_ATOMIC_ADD(bpfdata->ipv6_hash_count, cnt);
554  }
555  }
556 }
557 
558 /**
559  * Decrease number of currently bypassed flows for a protocol family
560  *
561  * \param dev pointer to LiveDevice to set stats for
562  * \param cnt number of flows to remove
563  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
564  */
565 void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
566 {
567  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
568  if (bpfdata) {
569  if (family == AF_INET) {
570  SC_ATOMIC_SUB(bpfdata->ipv4_hash_count, cnt);
571  } else if (family == AF_INET6) {
572  SC_ATOMIC_SUB(bpfdata->ipv6_hash_count, cnt);
573  }
574  }
575 }
576 
577 /**
578  * Increase number of failed captured flows for a protocol family
579  *
580  * \param dev pointer to LiveDevice to set stats for
581  * \param cnt number of flows to add
582  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
583  */
584 void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
585 {
586  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
587  if (bpfdata) {
588  if (family == AF_INET) {
589  SC_ATOMIC_ADD(bpfdata->ipv4_fail, cnt);
590  } else if (family == AF_INET6) {
591  SC_ATOMIC_ADD(bpfdata->ipv6_fail, cnt);
592  }
593  }
594 }
595 
596 /**
597  * Increase number of currently succesfully bypassed flows for a protocol family
598  *
599  * \param dev pointer to LiveDevice to set stats for
600  * \param cnt number of flows to add
601  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
602  */
603 void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
604 {
605  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
606  if (bpfdata) {
607  if (family == AF_INET) {
608  SC_ATOMIC_ADD(bpfdata->ipv4_success, cnt);
609  } else if (family == AF_INET6) {
610  SC_ATOMIC_ADD(bpfdata->ipv6_success, cnt);
611  }
612  }
613 }
614 
615 #ifdef BUILD_UNIX_SOCKET
616 TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data)
617 {
618  LiveDevice *ldev = NULL, *ndev;
619 
620  json_t *ifaces = NULL;
621  while(LiveDeviceForEach(&ldev, &ndev)) {
622  BypassInfo *bpinfo = LiveDevGetStorageById(ldev, g_bypass_storage_id);
623  if (bpinfo) {
624  uint64_t ipv4_hash_count = SC_ATOMIC_GET(bpinfo->ipv4_hash_count);
625  uint64_t ipv6_hash_count = SC_ATOMIC_GET(bpinfo->ipv6_hash_count);
626  uint64_t ipv4_success = SC_ATOMIC_GET(bpinfo->ipv4_success);
627  uint64_t ipv4_fail = SC_ATOMIC_GET(bpinfo->ipv4_fail);
628  uint64_t ipv6_success = SC_ATOMIC_GET(bpinfo->ipv6_success);
629  uint64_t ipv6_fail = SC_ATOMIC_GET(bpinfo->ipv6_fail);
630  json_t *iface = json_object();
631  if (ifaces == NULL) {
632  ifaces = json_object();
633  if (ifaces == NULL) {
634  json_object_set_new(answer, "message",
635  json_string("internal error at json object creation"));
636  return TM_ECODE_FAILED;
637  }
638  }
639  json_object_set_new(iface, "ipv4_maps_count", json_integer(ipv4_hash_count));
640  json_object_set_new(iface, "ipv4_success", json_integer(ipv4_success));
641  json_object_set_new(iface, "ipv4_fail", json_integer(ipv4_fail));
642  json_object_set_new(iface, "ipv6_maps_count", json_integer(ipv6_hash_count));
643  json_object_set_new(iface, "ipv6_success", json_integer(ipv6_success));
644  json_object_set_new(iface, "ipv6_fail", json_integer(ipv6_fail));
645  json_object_set_new(ifaces, ldev->dev, iface);
646  }
647  }
648  if (ifaces) {
649  json_object_set_new(answer, "message", ifaces);
651  }
652 
653  json_object_set_new(answer, "message",
654  json_string("No interface using bypass"));
656 }
657 #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:451
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:565
const char * LiveGetDeviceNameName(int number)
Get a pointer to the pre device name at idx.
Definition: util-device.c:218
#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:308
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:496
char * dev
Definition: util-device.h:41
void LiveDeviceFinalize(void)
Definition: util-device.c:473
#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:584
#define SCCalloc(nm, a)
Definition: util-mem.h:253
int LiveDeviceListClean()
Definition: util-device.c:348
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:527
int LiveDevUseBypass(LiveDevice *dev)
Definition: util-device.c:505
#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:279
void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:546
#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:300
char * name
Definition: conf.h:33
int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
Definition: util-device.c:313
#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:603
#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
int LiveGetDeviceNameCount(void)
Get the number of pre registered devices.
Definition: util-device.c:198
void LiveDeviceHasNoStats()
Definition: util-device.c:343
int LiveRegisterDeviceName(const char *dev)
Add a device for monitoring.
Definition: util-device.c:95