suricata
util-device.h File Reference
#include "queue.h"
#include "unix-manager.h"
Include dependency graph for util-device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LiveDevice_
 
struct  LiveDeviceName_
 

Macros

#define OFFLOAD_FLAG_SG   (1<<0)
 
#define OFFLOAD_FLAG_TSO   (1<<1)
 
#define OFFLOAD_FLAG_GSO   (1<<2)
 
#define OFFLOAD_FLAG_GRO   (1<<3)
 
#define OFFLOAD_FLAG_LRO   (1<<4)
 
#define OFFLOAD_FLAG_RXCSUM   (1<<5)
 
#define OFFLOAD_FLAG_TXCSUM   (1<<6)
 
#define OFFLOAD_FLAG_TOE   (1<<7)
 
#define MAX_DEVNAME   10
 

Typedefs

typedef struct LiveDevice_ LiveDevice
 
typedef struct LiveDeviceName_ LiveDeviceName
 

Functions

void LiveSetOffloadDisable (void)
 
void LiveSetOffloadWarn (void)
 
int LiveGetOffload (void)
 
void LiveDevRegisterExtension (void)
 
int LiveRegisterDeviceName (const char *dev)
 Add a device for monitoring. More...
 
int LiveRegisterDevice (const char *dev)
 Add a pcap device for monitoring and create structure. More...
 
int LiveDevUseBypass (LiveDevice *dev)
 
void LiveDevSetBypassStats (LiveDevice *dev, uint64_t cnt, int family)
 
void LiveDevAddBypassStats (LiveDevice *dev, uint64_t cnt, int family)
 
void LiveDevSubBypassStats (LiveDevice *dev, uint64_t cnt, int family)
 
void LiveDevAddBypassFail (LiveDevice *dev, uint64_t cnt, int family)
 
void LiveDevAddBypassSuccess (LiveDevice *dev, uint64_t cnt, int family)
 
int LiveGetDeviceCount (void)
 Get the number of registered devices. More...
 
const char * LiveGetDeviceName (int number)
 Get a pointer to the device name at idx. More...
 
LiveDeviceLiveGetDevice (const char *dev)
 Get a pointer to the device at idx. More...
 
const char * LiveGetShortName (const char *dev)
 
int LiveBuildDeviceList (const char *base)
 
void LiveDeviceHasNoStats (void)
 
int LiveDeviceListClean (void)
 
int LiveBuildDeviceListCustom (const char *base, const char *itemname)
 
LiveDeviceLiveDeviceForEach (LiveDevice **ldev, LiveDevice **ndev)
 
void LiveDeviceFinalize (void)
 

Macro Definition Documentation

#define MAX_DEVNAME   10

Definition at line 37 of file util-device.h.

#define OFFLOAD_FLAG_GRO   (1<<3)

Definition at line 27 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_GSO   (1<<2)

Definition at line 26 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_LRO   (1<<4)

Definition at line 28 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_RXCSUM   (1<<5)

Definition at line 29 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_SG   (1<<0)

Definition at line 24 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_TOE   (1<<7)

Definition at line 31 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_TSO   (1<<1)

Definition at line 25 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

#define OFFLOAD_FLAG_TXCSUM   (1<<6)

Definition at line 30 of file util-device.h.

Referenced by GetIfaceMaxPacketSize().

Typedef Documentation

typedef struct LiveDevice_ LiveDevice

storage for live device names

Function Documentation

int LiveBuildDeviceList ( const char *  base)

Definition at line 265 of file util-device.c.

References LiveBuildDeviceListCustom().

Referenced by RegisterAllModules().

Here is the call graph for this function:

Here is the caller graph for this function:

int LiveBuildDeviceListCustom ( const char *  base,
const char *  itemname 
)

Definition at line 270 of file util-device.c.

References ConfGetNode(), LiveRegisterDeviceName(), ConfNode_::name, next, TAILQ_FOREACH, and ConfNode_::val.

Referenced by LiveBuildDeviceList(), and RegisterAllModules().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDevAddBypassFail ( LiveDevice dev,
uint64_t  cnt,
int  family 
)

Increase number of failed captured flows for a protocol family

Parameters
devpointer to LiveDevice to set stats for
cntnumber of flows to add
familyAF_INET to set IPv4 count or AF_INET6 to set IPv6 count

Definition at line 541 of file util-device.c.

References BypassInfo, LiveDevGetStorageById(), and SC_ATOMIC_ADD.

Referenced by AFPSetBPFFilter().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDevAddBypassStats ( LiveDevice dev,
uint64_t  cnt,
int  family 
)

Increase number of currently bypassed flows for a protocol family

Parameters
devpointer to LiveDevice to set stats for
cntnumber of flows to add
familyAF_INET to set IPv4 count or AF_INET6 to set IPv6 count

Definition at line 503 of file util-device.c.

References BypassInfo, LiveDevGetStorageById(), and SC_ATOMIC_ADD.

Referenced by AFPSetBPFFilter().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDevAddBypassSuccess ( LiveDevice dev,
uint64_t  cnt,
int  family 
)

Increase number of currently succesfully bypassed flows for a protocol family

Parameters
devpointer to LiveDevice to set stats for
cntnumber of flows to add
familyAF_INET to set IPv4 count or AF_INET6 to set IPv6 count

Definition at line 560 of file util-device.c.

References BypassInfo, MimeDecParseState::data, LiveDevice_::dev, LiveDevGetStorageById(), LiveDeviceForEach(), SC_ATOMIC_ADD, SC_ATOMIC_GET, SCReturnInt, TM_ECODE_FAILED, and TM_ECODE_OK.

Referenced by AFPSetBPFFilter().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDeviceFinalize ( void  )

Create registered devices

This function creates all needed LiveDevice from the LiveDeviceName list created via LiveRegisterDevice()

Definition at line 430 of file util-device.c.

References LiveDeviceName_::dev, LiveRegisterDevice(), next, SCFree, SCLogDebug, and TAILQ_FOREACH_SAFE.

Referenced by PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

LiveDevice* LiveDeviceForEach ( LiveDevice **  ldev,
LiveDevice **  ndev 
)

Definition at line 408 of file util-device.c.

References next, TAILQ_FIRST, and TAILQ_NEXT.

Referenced by LiveDevAddBypassSuccess().

Here is the caller graph for this function:

void LiveDeviceHasNoStats ( void  )

Call this function to disable stat on live devices

This can be useful in the case, this is not a real interface.

Definition at line 300 of file util-device.c.

Referenced by RunModeIpsIPFWAutoFp(), RunModeIpsIPFWWorker(), RunModeIpsNFQAutoFp(), RunModeIpsNFQWorker(), RunModeIpsWinDivertAutoFp(), and RunModeNapatechRegister().

Here is the caller graph for this function:

int LiveDeviceListClean ( void  )

Definition at line 305 of file util-device.c.

References MimeDecParseState::data, LiveDevice_::dev, LiveDevFreeStorage(), next, RestoreIfaceOffloading(), SC_ATOMIC_DESTROY, SC_ATOMIC_GET, SCEnter, SCFree, SCLogNotice, SCReturnInt, TAILQ_FOREACH, TAILQ_FOREACH_SAFE, TM_ECODE_FAILED, and TM_ECODE_OK.

Referenced by GlobalsInitPreConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDevRegisterExtension ( void  )

Register bypass stats storage

Definition at line 453 of file util-device.c.

References LiveDevStorageRegister().

Referenced by PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void LiveDevSetBypassStats ( LiveDevice dev,
uint64_t  cnt,
int  family 
)

Set number of currently bypassed flows for a protocol family

Parameters
devpointer to LiveDevice to set stats for
cntnumber of currently bypassed flows
familyAF_INET to set IPv4 count or AF_INET6 to set IPv6 count

Definition at line 484 of file util-device.c.

References BypassInfo, LiveDevGetStorageById(), and SC_ATOMIC_SET.

Here is the call graph for this function:

void LiveDevSubBypassStats ( LiveDevice dev,
uint64_t  cnt,
int  family 
)

Decrease number of currently bypassed flows for a protocol family

Parameters
devpointer to LiveDevice to set stats for
cntnumber of flows to remove
familyAF_INET to set IPv4 count or AF_INET6 to set IPv6 count

Definition at line 522 of file util-device.c.

References BypassInfo, LiveDevGetStorageById(), and SC_ATOMIC_SUB.

Referenced by FlowDisableFlowManagerThread().

Here is the call graph for this function:

Here is the caller graph for this function:

int LiveDevUseBypass ( LiveDevice dev)

Prepare a LiveDevice so we can set bypass stats

Definition at line 462 of file util-device.c.

References BypassInfo, LiveDevSetStorageById(), SC_ATOMIC_INIT, SC_ERR_MEM_ALLOC, SCCalloc, and SCLogError.

Here is the call graph for this function:

LiveDevice* LiveGetDevice ( const char *  name)

Get a pointer to the device at idx.

Parameters
numberidx of the device in our list
Return values
ptrpointer to the string containing the device
NULLon error

Definition at line 236 of file util-device.c.

References LiveDevice_::dev, next, SC_ERR_INVALID_VALUE, SCLogWarning, and TAILQ_FOREACH.

Referenced by DetectEngineReloadTenantBlocking(), LiveGetShortName(), NFQRegisterQueue(), NoNFLOGSupportExit(), ReceiveAFPThreadInit(), ReceiveErfDagThreadInit(), ReceivePcapThreadInit(), ReceivePfringThreadInit(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsPfringRegister(), and TmModuleDecodeNetmapRegister().

Here is the caller graph for this function:

int LiveGetDeviceCount ( void  )

Get the number of registered devices.

Return values
cntthe number of registered devices

Definition at line 157 of file util-device.c.

References next, and TAILQ_FOREACH.

Referenced by AFPRunModeIsIPS(), LiveRegisterDevice(), PostRunDeinit(), RunModeIdsNetmapRegister(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), RunModeSetLiveCaptureAutoFp(), RunModeSetLiveCaptureSingle(), and RunModeSetLiveCaptureWorkers().

Here is the caller graph for this function:

const char* LiveGetDeviceName ( int  number)

Get a pointer to the device name at idx.

Parameters
numberidx of the device in our list
Return values
ptrpointer to the string containing the device
NULLon error

Definition at line 177 of file util-device.c.

References LiveDevice_::dev, MAX_DEVNAME, next, SCLogInfo, ShortenString(), strlcpy(), and TAILQ_FOREACH.

Referenced by AFPRunModeIsIPS(), PostRunDeinit(), RunModeIdsNetmapRegister(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), RunModeSetLiveCaptureAutoFp(), RunModeSetLiveCaptureSingle(), and RunModeSetLiveCaptureWorkers().

Here is the call graph for this function:

Here is the caller graph for this function:

int LiveGetOffload ( void  )

Definition at line 79 of file util-device.c.

Referenced by NoWinDivertSupportExit(), ReceivePcapThreadInit(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), and RunModeIdsPfringRegister().

Here is the caller graph for this function:

const char* LiveGetShortName ( const char *  dev)

Definition at line 257 of file util-device.c.

References LiveDevice_::dev_short, and LiveGetDevice().

Referenced by RunModeSetLiveCaptureAutoFp().

Here is the call graph for this function:

Here is the caller graph for this function:

int LiveRegisterDevice ( const char *  dev)

Add a pcap device for monitoring and create structure.

Parameters
devstring with the device name
Return values
0on success.
-1on failure.

Definition at line 124 of file util-device.c.

References LiveDevice_::dev, LiveDevice_::dev_short, LiveDevice_::id, LiveDevice_::ignore_checksum, LiveDevStorageSize(), LiveGetDeviceCount(), next, SC_ATOMIC_INIT, SCCalloc, SCFree, SCLogDebug, SCStrdup, TAILQ_INSERT_TAIL, and unlikely.

Referenced by LiveDeviceFinalize(), NFQRegisterQueue(), NoWinDivertSupportExit(), RunModeIdsPfringRegister(), and RunModeNapatechRegister().

Here is the call graph for this function:

Here is the caller graph for this function:

int LiveRegisterDeviceName ( const char *  dev)

Add a device for monitoring.

To be used during option parsing. When a device has to be created during runmode init, use LiveRegisterDevice()

Parameters
devstring with the device name
Return values
0on success.
-1on failure.

Definition at line 95 of file util-device.c.

References LiveDeviceName_::dev, next, SCCalloc, SCFree, SCLogDebug, SCStrdup, TAILQ_INSERT_TAIL, and unlikely.

Referenced by IPFWRegisterQueue(), LiveBuildDeviceListCustom(), and RegisterAllModules().

Here is the caller graph for this function:

void LiveSetOffloadDisable ( void  )

Definition at line 69 of file util-device.c.

Referenced by PostRunDeinit().

Here is the caller graph for this function:

void LiveSetOffloadWarn ( void  )

Definition at line 74 of file util-device.c.

Referenced by PostRunDeinit().

Here is the caller graph for this function: