suricata
util-ip.c File Reference
#include "suricata-common.h"
#include "util-ip.h"
Include dependency graph for util-ip.c:

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 *addr_str)
 Validates an IPV4 address and returns the network endian arranged version of the IPV4 address. More...
 
struct in6_addr * ValidateIPV6Address (const char *addr_str)
 Validates an IPV6 address and returns the network endian arranged version of the IPV6 addresss. More...
 
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. More...
 

Detailed Description

Author
Anoop Saldanha anoop.nosp@m.sald.nosp@m.anha@.nosp@m.gmai.nosp@m.l.com
Duarte Silva duart.nosp@m.e.si.nosp@m.lva@s.nosp@m.eria.nosp@m.lizin.nosp@m.g.me

IP addresses related utility functions

Definition in file util-ip.c.

Function Documentation

bool IPv4AddressStringIsValid ( const char *  str)

determine if a string is a valid ipv4 address

Return values
boolis addr valid?

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

References len, and SCLogDebug.

Referenced by MimeDecAddEntity(), and ValidateIPV4Address().

Here is the caller graph for this function:

bool IPv6AddressStringIsValid ( const char *  str)

determine if a string is a valid ipv6 address

Return values
boolis addr valid?

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

References len, and SCLogDebug.

Referenced by MimeDecAddEntity(), and ValidateIPV6Address().

Here is the caller graph for this function:

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.

Referenced by SCHInfoAddHostOSInfo(), SCRadixReleaseRadixTree(), and SRepDestroy().

Here is the caller graph for this function:

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 128 of file util-ip.c.

References IPv4AddressStringIsValid(), SC_ERR_FATAL, SCFree, SCLogError, and SCMalloc.

Referenced by SCHInfoAddHostOSInfo(), and SCHInfoGetHostOSFlavour().

Here is the call graph for this function:

Here is the caller graph for this function:

struct in6_addr* ValidateIPV6Address ( const char *  addr_str)

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

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 158 of file util-ip.c.

References IPv6AddressStringIsValid(), SC_ERR_FATAL, SCFree, SCLogError, and SCMalloc.

Referenced by SCHInfoAddHostOSInfo(), and SCHInfoGetHostOSFlavour().

Here is the call graph for this function:

Here is the caller graph for this function: