suricata
util-host-os-info.c File Reference
#include "suricata-common.h"
#include "util-host-os-info.h"
#include "util-error.h"
#include "util-debug.h"
#include "util-ip.h"
#include "util-radix-tree.h"
#include "util-byte.h"
#include "stream-tcp-private.h"
#include "stream-tcp-reassemble.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "util-enum.h"
#include "util-unittest.h"
Include dependency graph for util-host-os-info.c:

Go to the source code of this file.

Functions

int SCHInfoAddHostOSInfo (const char *host_os, const char *host_os_ip_range, int is_ipv4)
 Used to add the host-os-info data obtained from the conf. More...
 
int SCHInfoGetHostOSFlavour (const char *ip_addr_str)
 Retrieves the host os flavour, given an ipv4/ipv6 address as a string. More...
 
int SCHInfoGetIPv4HostOSFlavour (uint8_t *ipv4_addr)
 Retrieves the host os flavour, given an ipv4 address in the raw address format. More...
 
int SCHInfoGetIPv6HostOSFlavour (uint8_t *ipv6_addr)
 Retrieves the host os flavour, given an ipv6 address in the raw address format. More...
 
void SCHInfoCleanResources (void)
 
void SCHInfoLoadFromConfig (void)
 Load the host os policy information from the configuration. More...
 
void SCHInfoRegisterTests (void)
 

Variables

SCEnumCharMap sc_hinfo_os_policy_map []
 

Detailed Description

Author
Anoop Saldanha anoop.nosp@m.sald.nosp@m.anha@.nosp@m.gmai.nosp@m.l.com

Host info utility functions

Definition in file util-host-os-info.c.

Function Documentation

◆ SCHInfoAddHostOSInfo()

int SCHInfoAddHostOSInfo ( const char *  host_os,
const char *  host_os_ip_range,
int  is_ipv4 
)

Used to add the host-os-info data obtained from the conf.

Parameters
host_osThe host_os name/flavour from the conf file
host_os_ip_rangePointer to a char string holding the ip/ip_netblock for the host_os specified in the first argument
is_ipv4Indicates if the ip address to be considered for the default configuration is IPV4; if not it is IPV6. Specified using SC_HINFO_IS_IPV6 or SC_HINFO_IS_IPV4
Return values
0On successfully adding the host os info to the Radix tree
-1On failure \initonly (only specified from config, at the startup)

Definition at line 122 of file util-host-os-info.c.

References SCLogError.

◆ SCHInfoCleanResources()

void SCHInfoCleanResources ( void  )

Definition at line 320 of file util-host-os-info.c.

◆ SCHInfoGetHostOSFlavour()

int SCHInfoGetHostOSFlavour ( const char *  ip_addr_str)

Retrieves the host os flavour, given an ipv4/ipv6 address as a string.

Parameters
Pointerto a string containing an IP address
Return values
TheOS flavour on success; -1 on failure, or on not finding the key

Definition at line 248 of file util-host-os-info.c.

References SCLogError, SCRadixFindKeyIPV6BestMatch(), and ValidateIPV6Address().

Here is the call graph for this function:

◆ SCHInfoGetIPv4HostOSFlavour()

int SCHInfoGetIPv4HostOSFlavour ( uint8_t *  ipv4_addr)

Retrieves the host os flavour, given an ipv4 address in the raw address format.

Parameters
Pointerto a raw ipv4 address.
Return values
TheOS flavour on success; -1 on failure, or on not finding the key

Definition at line 292 of file util-host-os-info.c.

References SCRadixFindKeyIPV4BestMatch().

Referenced by DefragGetOsPolicy(), and StreamTcpSetOSPolicy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCHInfoGetIPv6HostOSFlavour()

int SCHInfoGetIPv6HostOSFlavour ( uint8_t *  ipv6_addr)

Retrieves the host os flavour, given an ipv6 address in the raw address format.

Parameters
Pointerto a raw ipv6 address.
Return values
TheOS flavour on success; -1 on failure, or on not finding the key

Definition at line 310 of file util-host-os-info.c.

References SCRadixFindKeyIPV6BestMatch().

Referenced by DefragGetOsPolicy(), and StreamTcpSetOSPolicy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCHInfoLoadFromConfig()

void SCHInfoLoadFromConfig ( void  )

Load the host os policy information from the configuration.

\initonly (A mem alloc error should cause an exit failure)

Definition at line 335 of file util-host-os-info.c.

◆ SCHInfoRegisterTests()

void SCHInfoRegisterTests ( void  )

Definition at line 1610 of file util-host-os-info.c.

References UtRegisterTest().

Here is the call graph for this function:

Variable Documentation

◆ sc_hinfo_os_policy_map

SCEnumCharMap sc_hinfo_os_policy_map[]
Initial value:
= {
{ "none", OS_POLICY_NONE },
{ "bsd", OS_POLICY_BSD },
{ "bsd-right", OS_POLICY_BSD_RIGHT },
{ "old-linux", OS_POLICY_OLD_LINUX },
{ "linux", OS_POLICY_LINUX },
{ "old-solaris", OS_POLICY_OLD_SOLARIS },
{ "solaris", OS_POLICY_SOLARIS },
{ "hpux10", OS_POLICY_HPUX10 },
{ "hpux11", OS_POLICY_HPUX11 },
{ "irix", OS_POLICY_IRIX },
{ "macos", OS_POLICY_MACOS },
{ "windows", OS_POLICY_WINDOWS },
{ "vista", OS_POLICY_VISTA },
{ "windows2k3", OS_POLICY_WINDOWS2K3 },
{ NULL, -1 },
}

Enum map for the various OS flavours

Definition at line 43 of file util-host-os-info.c.

OS_POLICY_MACOS
@ OS_POLICY_MACOS
Definition: stream-tcp-reassemble.h:46
OS_POLICY_OLD_LINUX
@ OS_POLICY_OLD_LINUX
Definition: stream-tcp-reassemble.h:39
OS_POLICY_IRIX
@ OS_POLICY_IRIX
Definition: stream-tcp-reassemble.h:45
OS_POLICY_BSD
@ OS_POLICY_BSD
Definition: stream-tcp-reassemble.h:37
OS_POLICY_NONE
@ OS_POLICY_NONE
Definition: stream-tcp-reassemble.h:36
OS_POLICY_OLD_SOLARIS
@ OS_POLICY_OLD_SOLARIS
Definition: stream-tcp-reassemble.h:41
OS_POLICY_HPUX10
@ OS_POLICY_HPUX10
Definition: stream-tcp-reassemble.h:43
OS_POLICY_VISTA
@ OS_POLICY_VISTA
Definition: stream-tcp-reassemble.h:48
OS_POLICY_SOLARIS
@ OS_POLICY_SOLARIS
Definition: stream-tcp-reassemble.h:42
OS_POLICY_WINDOWS
@ OS_POLICY_WINDOWS
Definition: stream-tcp-reassemble.h:47
OS_POLICY_LINUX
@ OS_POLICY_LINUX
Definition: stream-tcp-reassemble.h:40
OS_POLICY_HPUX11
@ OS_POLICY_HPUX11
Definition: stream-tcp-reassemble.h:44
OS_POLICY_WINDOWS2K3
@ OS_POLICY_WINDOWS2K3
Definition: stream-tcp-reassemble.h:49
OS_POLICY_BSD_RIGHT
@ OS_POLICY_BSD_RIGHT
Definition: stream-tcp-reassemble.h:38