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

Go to the source code of this file.

Functions

int CIDRFromMask (uint32_t netmask)
 Turn 32 bit mask into CIDR. More...
 
uint32_t CIDRGet (int)
 
void CIDRGetIPv6 (int cidr, struct in6_addr *in6)
 Creates a cidr ipv6 netblock, based on the cidr netblock value. More...
 
void UtilCIDRTests (void)
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file util-cidr.h.

Function Documentation

◆ CIDRFromMask()

int CIDRFromMask ( uint32_t  netmask)

Turn 32 bit mask into CIDR.

Return values
cidrThe cidr value or -1 if the netmask can't be expressed as cidr

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

◆ CIDRGet()

uint32_t CIDRGet ( int  )

Definition at line 57 of file util-cidr.c.

References SCLogDebug.

Referenced by SCRadixAddKeyIPV4String().

Here is the caller graph for this function:

◆ CIDRGetIPv6()

void CIDRGetIPv6 ( int  cidr,
struct in6_addr *  in6 
)

Creates a cidr ipv6 netblock, based on the cidr netblock value.

   For example if we send a cidr of 7 as argument, an ipv6 address
   mask of the value FE:00:00:00:00:00:00:00 is created and updated
   in the argument struct in6_addr *in6.
Todo:
I think for the final section: while (cidr > 0), we can simply replace it with a if (cidr > 0) { in6->s6_addr[i] = -1 << (8 - cidr);
Parameters
cidrThe value of the cidr.
in6Pointer to an ipv6 address structure(struct in6_addr) which will hold the cidr netblock result.

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

Referenced by SCRadixAddKeyIPV6String().

Here is the caller graph for this function:

◆ UtilCIDRTests()

void UtilCIDRTests ( void  )

Definition at line 149 of file util-cidr.c.

References UtRegisterTest().

Here is the call graph for this function: