suricata
util-ip.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool IPv4AddressStringIsValid (const char *str)
 determine if a string is a valid ipv4 address More...
 
bool IPv6AddressStringIsValid (const char *str)
 determine if a string is a valid ipv6 address More...
 
struct in_addr * ValidateIPV4Address (const char *)
 Validates an IPV4 address and returns the network endian arranged version of the IPV4 address. More...
 
struct in6_addr * ValidateIPV6Address (const char *)
 Validates an IPV6 address and returns the network endian arranged version of the IPV6 address. More...
 
void MaskIPNetblock (uint8_t *, int, int)
 Culls the non-netmask portion of the IP address. For example an IP address 192.168.240.1 would be chopped to 192.168.224.0 against a netmask value of 19. More...
 

Detailed Description

Function Documentation

◆ IPv4AddressStringIsValid()

bool IPv4AddressStringIsValid ( const char *  str)

determine if a string is a valid ipv4 address

Return values
boolis addr valid?

Definition at line 35 of file util-ip.c.

References len, SCLogDebug, str, and StringParseUint8().

Referenced by ValidateIPV4Address().

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

◆ IPv6AddressStringIsValid()

bool IPv6AddressStringIsValid ( const char *  str)

determine if a string is a valid ipv6 address

Return values
boolis addr valid?

Definition at line 82 of file util-ip.c.

References len, SCLogDebug, and str.

Referenced by ValidateIPV6Address().

Here is the caller graph for this function:

◆ MaskIPNetblock()

void MaskIPNetblock ( uint8_t *  stream,
int  netmask,
int  key_bitlen 
)

Culls the non-netmask portion of the IP address. For example an IP address 192.168.240.1 would be chopped to 192.168.224.0 against a netmask value of 19.

Parameters
streamPointer the IP address that has to be masked
netmaskThe netmask value (cidr) to which the IP address has to be culled
key_bitlenThe bitlen of the stream

Definition at line 187 of file util-ip.c.

◆ ValidateIPV4Address()

struct in_addr* ValidateIPV4Address ( const char *  addr_str)

Validates an IPV4 address and returns the network endian arranged version of the IPV4 address.

Parameters
addrPointer to a character string containing an IPV4 address. A valid IPV4 address is a character string containing a dotted format of "ddd.ddd.ddd.ddd"
Return values
Pointerto an in_addr instance containing the network endian format of the IPV4 address
NULLif the IPV4 address is invalid

Definition at line 130 of file util-ip.c.

References FatalError, IPv4AddressStringIsValid(), SCFree, and SCMalloc.

Here is the call graph for this function:

◆ ValidateIPV6Address()

struct in6_addr* ValidateIPV6Address ( const char *  addr_str)

Validates an IPV6 address and returns the network endian arranged version of the IPV6 address.

Parameters
addrPointer to a character string containing an IPV6 address
Return values
Pointerto a in6_addr instance containing the network endian format of the IPV6 address
NULLif the IPV6 address is invalid

Definition at line 159 of file util-ip.c.

References FatalError, IPv6AddressStringIsValid(), SCFree, and SCMalloc.

Here is the call graph for this function: