suricata
util-device.c File Reference

Utility functions to handle device list. More...

#include "suricata-common.h"
#include "conf.h"
#include "util-device.h"
#include "util-ioctl.h"
#include "device-storage.h"
Include dependency graph for util-device.c:

Go to the source code of this file.

Macros

#define MAX_DEVNAME   10
 

Functions

void LiveSetOffloadWarn (void)
 
int LiveGetOffload (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 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 *name)
 Get a pointer to the device at idx. More...
 
const char * LiveGetShortName (const char *dev)
 
int LiveBuildDeviceList (const char *runmode)
 
int LiveBuildDeviceListCustom (const char *runmode, const char *itemname)
 
void LiveDeviceHasNoStats ()
 
int LiveDeviceListClean ()
 
LiveDeviceLiveDeviceForEach (LiveDevice **ldev, LiveDevice **ndev)
 
void LiveDeviceFinalize (void)
 

Detailed Description

Utility functions to handle device list.

Author
Eric Leblond eric@.nosp@m.regi.nosp@m.t.org

Definition in file util-device.c.

Macro Definition Documentation

#define MAX_DEVNAME   10

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

Referenced by LiveGetDeviceName(), and LiveRegisterDevice().

Function Documentation

int LiveBuildDeviceList ( const char *  runmode)

Definition at line 277 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 *  runmode,
const char *  itemname 
)

Definition at line 282 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 LiveDeviceFinalize ( void  )

Create registered devices

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

Definition at line 442 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 420 of file util-device.c.

References next, TAILQ_FIRST, and TAILQ_NEXT.

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 312 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 317 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:

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 248 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 148 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 168 of file util-device.c.

References LiveDevice_::dev, length, MAX_DEVNAME, next, SCLogInfo, strlcat(), 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 66 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 269 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 111 of file util-device.c.

References LiveDevice_::dev, LiveDevice_::dev_short, LiveDevice_::id, LiveDevice_::ignore_checksum, LiveDevStorageSize(), LiveGetDeviceCount(), MAX_DEVNAME, next, SC_ATOMIC_INIT, SCCalloc, SCFree, SCLogDebug, SCStrdup, strlcpy(), 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 82 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 LiveSetOffloadWarn ( void  )

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

Referenced by PostRunDeinit().

Here is the caller graph for this function: