suricata
util-device.h
Go to the documentation of this file.
1 /* Copyright (C) 2011-2025 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 SURICATA_UTIL_DEVICE_H
19 #define SURICATA_UTIL_DEVICE_H
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 #define OFFLOAD_FLAG_SG (1<<0)
27 #define OFFLOAD_FLAG_TSO (1<<1)
28 #define OFFLOAD_FLAG_GSO (1<<2)
29 #define OFFLOAD_FLAG_GRO (1<<3)
30 #define OFFLOAD_FLAG_LRO (1<<4)
31 #define OFFLOAD_FLAG_RXCSUM (1<<5)
32 #define OFFLOAD_FLAG_TXCSUM (1<<6)
33 #define OFFLOAD_FLAG_TOE (1<<7)
34 
35 void LiveSetOffloadDisable(void);
36 void LiveSetOffloadWarn(void);
37 int LiveGetOffload(void);
38 
39 /**
40  * \brief Public definition of LiveDevice.
41  *
42  * The private definition can be found in util-device-private.h.
43  */
44 typedef struct LiveDevice_ LiveDevice;
45 
46 void LiveDevRegisterExtension(void);
47 
48 int LiveRegisterDeviceName(const char *dev);
49 int LiveRegisterDevice(const char *dev);
51 void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family);
52 void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family);
53 void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family);
54 void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family);
55 int LiveGetDeviceCount(void);
56 const char *LiveGetDeviceName(int number);
57 LiveDevice *LiveGetDevice(const char *dev);
58 const char *LiveGetShortName(const char *dev);
59 int LiveBuildDeviceList(const char *base);
60 void LiveDeviceHasNoStats(void);
61 int LiveDeviceListClean(void);
62 int LiveBuildDeviceListCustom(const char *base, const char *itemname);
63 
65 
66 void LiveDeviceFinalize(void);
67 
68 #ifdef BUILD_UNIX_SOCKET
69 TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *server_msg, void *data);
70 TmEcode LiveDeviceIfaceList(json_t *cmd, json_t *server_msg, void *data);
71 TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data);
72 #endif
73 
76 void LiveDevicePktsAdd(LiveDevice *dev, uint64_t n);
77 void LiveDeviceDropAdd(LiveDevice *dev, uint64_t n);
78 void LiveDeviceBypassedAdd(LiveDevice *dev, uint64_t n);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif /* SURICATA_UTIL_DEVICE_H */
LiveDevAddBypassSuccess
void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:558
LiveSetOffloadDisable
void LiveSetOffloadDisable(void)
Definition: util-device.c:76
LiveDevicePktsAdd
void LiveDevicePktsAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:627
LiveDevSubBypassStats
void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:520
LiveDeviceInvalidChecksumsGet
uint64_t LiveDeviceInvalidChecksumsGet(LiveDevice *dev)
Definition: util-device.c:642
LiveDevice_
Definition: util-device-private.h:32
LiveGetDeviceName
const char * LiveGetDeviceName(int number)
Get a pointer to the device name at idx.
Definition: util-device.c:189
LiveRegisterDevice
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
Definition: util-device.c:131
LiveRegisterDeviceName
int LiveRegisterDeviceName(const char *dev)
Add a device for monitoring.
Definition: util-device.c:102
LiveDeviceFinalize
void LiveDeviceFinalize(void)
Definition: util-device.c:447
LiveDeviceDropAdd
void LiveDeviceDropAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:632
LiveDevAddBypassFail
void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:539
LiveDevAddBypassStats
void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:501
LiveBuildDeviceList
int LiveBuildDeviceList(const char *base)
Definition: util-device.c:279
LiveDevicePktsIncr
void LiveDevicePktsIncr(LiveDevice *dev)
Definition: util-device.c:622
LiveDeviceForEach
LiveDevice * LiveDeviceForEach(LiveDevice **ldev, LiveDevice **ndev)
Definition: util-device.c:425
LiveDeviceListClean
int LiveDeviceListClean(void)
Definition: util-device.c:319
LiveGetDeviceCount
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:169
LiveDevice_::dev
char * dev
Definition: util-device-private.h:33
LiveDevRegisterExtension
void LiveDevRegisterExtension(void)
Definition: util-device.c:470
LiveGetOffload
int LiveGetOffload(void)
Definition: util-device.c:86
LiveBuildDeviceListCustom
int LiveBuildDeviceListCustom(const char *base, const char *itemname)
Definition: util-device.c:284
TmEcode
TmEcode
Definition: tm-threads-common.h:80
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
LiveDeviceHasNoStats
void LiveDeviceHasNoStats(void)
Definition: util-device.c:314
LiveGetShortName
const char * LiveGetShortName(const char *dev)
Definition: util-device.c:271
LiveDevicePktsGet
uint64_t LiveDevicePktsGet(LiveDevice *dev)
Definition: util-device.c:617
LiveGetDevice
LiveDevice * LiveGetDevice(const char *dev)
Get a pointer to the device at idx.
Definition: util-device.c:253
LiveSetOffloadWarn
void LiveSetOffloadWarn(void)
Definition: util-device.c:81
LiveDeviceBypassedAdd
void LiveDeviceBypassedAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:637
LiveDevUseBypass
int LiveDevUseBypass(LiveDevice *dev)
Definition: util-device.c:479