suricata
util-device.h
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 #ifndef __UTIL_DEVICE_H__
19 #define __UTIL_DEVICE_H__
20 
21 #include "queue.h"
22 
23 #define OFFLOAD_FLAG_SG (1<<0)
24 #define OFFLOAD_FLAG_TSO (1<<1)
25 #define OFFLOAD_FLAG_GSO (1<<2)
26 #define OFFLOAD_FLAG_GRO (1<<3)
27 #define OFFLOAD_FLAG_LRO (1<<4)
28 #define OFFLOAD_FLAG_RXCSUM (1<<5)
29 #define OFFLOAD_FLAG_TXCSUM (1<<6)
30 #define OFFLOAD_FLAG_TOE (1<<7)
31 
32 void LiveSetOffloadDisable(void);
33 void LiveSetOffloadWarn(void);
34 int LiveGetOffload(void);
35 
36 #define MAX_DEVNAME 10
37 
38 /** storage for live device names */
39 typedef struct LiveDevice_ {
40  char *dev; /**< the device (e.g. "eth0") */
43 
44  int id;
45 
46  SC_ATOMIC_DECLARE(uint64_t, pkts);
47  SC_ATOMIC_DECLARE(uint64_t, drop);
48  SC_ATOMIC_DECLARE(uint64_t, bypassed);
49  SC_ATOMIC_DECLARE(uint64_t, invalid_checksums);
51 
52  uint32_t tenant_id; /**< tenant id in multi-tenancy */
53  uint32_t offload_orig; /**< original offload settings to restore @exit */
55 
56 typedef struct LiveDeviceName_ {
57  char *dev; /**< the device (e.g. "eth0") */
60 
61 void LiveDevRegisterExtension(void);
62 
63 int LiveRegisterDeviceName(const char *dev);
64 int LiveGetDeviceNameCount(void);
65 const char *LiveGetDeviceNameName(int number);
66 int LiveRegisterDevice(const char *dev);
68 void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family);
69 void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family);
70 void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family);
71 void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family);
72 void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family);
73 int LiveGetDeviceCount(void);
74 const char *LiveGetDeviceName(int number);
75 LiveDevice *LiveGetDevice(const char *dev);
76 const char *LiveGetShortName(const char *dev);
77 int LiveBuildDeviceList(const char *base);
78 void LiveDeviceHasNoStats(void);
79 int LiveDeviceListClean(void);
80 int LiveBuildDeviceListCustom(const char *base, const char *itemname);
81 
83 
84 void LiveDeviceFinalize(void);
85 
86 #ifdef BUILD_UNIX_SOCKET
87 TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *server_msg, void *data);
88 TmEcode LiveDeviceIfaceList(json_t *cmd, json_t *server_msg, void *data);
89 TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data);
90 #endif
91 
92 #endif /* __UTIL_DEVICE_H__ */
LiveDevAddBypassSuccess
void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:600
LiveSetOffloadDisable
void LiveSetOffloadDisable(void)
Definition: util-device.c:70
LiveDevSubBypassStats
void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:562
LiveDevice_::id
int id
Definition: util-device.h:44
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
LiveDevice_
Definition: util-device.h:39
LiveDevice_::tenant_id_set
bool tenant_id_set
Definition: util-device.h:42
LiveDevice
struct LiveDevice_ LiveDevice
LiveGetDeviceName
const char * LiveGetDeviceName(int number)
Get a pointer to the device name at idx.
Definition: util-device.c:177
LiveRegisterDevice
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
Definition: util-device.c:125
LiveDeviceName_::TAILQ_ENTRY
TAILQ_ENTRY(LiveDeviceName_) next
LiveRegisterDeviceName
int LiveRegisterDeviceName(const char *dev)
Add a device for monitoring.
Definition: util-device.c:96
LiveDeviceFinalize
void LiveDeviceFinalize(void)
Definition: util-device.c:470
LiveDevAddBypassFail
void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:581
LiveDevAddBypassStats
void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:543
MAX_DEVNAME
#define MAX_DEVNAME
Definition: util-device.h:36
LiveBuildDeviceList
int LiveBuildDeviceList(const char *base)
Definition: util-device.c:308
LiveDevice_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint64_t, invalid_checksums)
LiveDeviceName
struct LiveDeviceName_ LiveDeviceName
LiveDeviceForEach
LiveDevice * LiveDeviceForEach(LiveDevice **ldev, LiveDevice **ndev)
Definition: util-device.c:448
LiveGetDeviceNameName
const char * LiveGetDeviceNameName(int number)
Get a pointer to the pre device name at idx.
Definition: util-device.c:218
LiveDeviceListClean
int LiveDeviceListClean(void)
Definition: util-device.c:348
LiveDevice_::tenant_id
uint32_t tenant_id
Definition: util-device.h:52
LiveGetDeviceCount
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:157
LiveDevice_::dev
char * dev
Definition: util-device.h:40
LiveDevSetBypassStats
void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:524
LiveDevRegisterExtension
void LiveDevRegisterExtension(void)
Definition: util-device.c:493
LiveDeviceName_::dev
char * dev
Definition: util-device.h:57
LiveGetOffload
int LiveGetOffload(void)
Definition: util-device.c:80
LiveDevice_::offload_orig
uint32_t offload_orig
Definition: util-device.h:53
LiveBuildDeviceListCustom
int LiveBuildDeviceListCustom(const char *base, const char *itemname)
Definition: util-device.c:313
TmEcode
TmEcode
Definition: tm-threads-common.h:81
queue.h
LiveDevice_::TAILQ_ENTRY
TAILQ_ENTRY(LiveDevice_) next
LiveDevice_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint64_t, bypassed)
LiveDevice_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint64_t, pkts)
LiveDeviceName_
Definition: util-device.h:56
LiveDevice_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint64_t, drop)
LiveDeviceHasNoStats
void LiveDeviceHasNoStats(void)
Definition: util-device.c:343
LiveGetShortName
const char * LiveGetShortName(const char *dev)
Definition: util-device.c:300
LiveGetDevice
LiveDevice * LiveGetDevice(const char *dev)
Get a pointer to the device at idx.
Definition: util-device.c:279
LiveDevice_::dev_short
char dev_short[MAX_DEVNAME+1]
Definition: util-device.h:41
LiveSetOffloadWarn
void LiveSetOffloadWarn(void)
Definition: util-device.c:75
LiveDevUseBypass
int LiveDevUseBypass(LiveDevice *dev)
Definition: util-device.c:502
LiveGetDeviceNameCount
int LiveGetDeviceNameCount(void)
Get the number of pre registered devices.
Definition: util-device.c:198