#include <socket.h>
Inheritance diagram for ucommon::cidr:
Public Types | |
typedef LinkedObject | policy |
A convenience type for using a pointer to a linked list as a policy chain. | |
Public Member Functions | |
cidr (cidr &existing) | |
Construct a copy of an existing cidr. | |
cidr (policy **policy, char *string, char *name) | |
Create a named cidr entry on a specified policy chain. | |
cidr (policy **policy, char *string) | |
Create an unnamed cidr entry on a specified policy chain. | |
cidr (char *string) | |
Create an unlinked cidr from a string. | |
cidr () | |
Create an uninitialized cidr. | |
inethostaddr_t | getBroadcast (void) |
Get the broadcast host address represented by our cidr. | |
int | getFamily (void) |
Get the address family of our cidr block object. | |
unsigned | getMask (void) |
Get the number of bits in the cidr bitmask. | |
char * | getName (void) |
Get the saved name of our cidr. | |
inethostaddr_t | getNetmask (void) |
Get the effective network mask for our cidr block. | |
inethostaddr_t | getNetwork (void) |
Get the network host base address of our cidr block. | |
bool | is_member (struct sockaddr *address) |
Test if a given socket address falls within this cidr. | |
bool | operator!= (struct sockaddr *address) |
Test if a given socket address falls outside this cidr. | |
bool | operator== (struct sockaddr *address) |
Test if a given socket address falls within this cidr. | |
void | set (char *string) |
Set our cidr to a string address. | |
Static Public Member Functions | |
static cidr * | container (policy *policy, struct sockaddr *address) |
Get the largest container cidr entry in a list that matches the socket address. | |
static cidr * | find (policy *policy, struct sockaddr *address) |
Find the smallest cidr entry in a list that matches the socket address. | |
Protected Member Functions | |
inethostaddr_t | broadcast (void) |
unsigned | mask (void) |
unsigned | mask (char *cp) |
Protected Attributes | |
int | Family |
char | Name [16] |
inethostaddr_t | Netmask |
inethostaddr_t | Network |
This class can be used to provide a stand-alone representation of a cidr block of internet addresses or chained together into some form of access control list. The cidr class can hold segments for both IPV4 and IPV6 addresses. The class accepts cidr's defined as C strings, typically in the form of address/bits or address/submask. These routines auto-detect ipv4 and ipv6 addresses.
Definition at line 158 of file socket.h.
ucommon::cidr::cidr | ( | char * | string | ) |
Create an unlinked cidr from a string.
The string is typically in the form base-host-address/range, where range might be a bit count or a network mask.
string | for cidr block. |
ucommon::cidr::cidr | ( | policy ** | policy, | |
char * | string | |||
) |
Create an unnamed cidr entry on a specified policy chain.
policy | chain to link cidr to. | |
string | for cidr block. |
ucommon::cidr::cidr | ( | policy ** | policy, | |
char * | string, | |||
char * | name | |||
) |
Create a named cidr entry on a specified policy chain.
policy | chain to link cidr to. | |
string | for cidr block. | |
name | of this policy object. |
ucommon::cidr::cidr | ( | cidr & | existing | ) |
Construct a copy of an existing cidr.
existing | cidr we copy from. |
Get the largest container cidr entry in a list that matches the socket address.
policy | chain to search. | |
address | to search for. |
Find the smallest cidr entry in a list that matches the socket address.
policy | chain to search. | |
address | to search for. |
inethostaddr_t ucommon::cidr::getBroadcast | ( | void | ) | [inline] |
int ucommon::cidr::getFamily | ( | void | ) | [inline] |
unsigned ucommon::cidr::getMask | ( | void | ) | [inline] |
char* ucommon::cidr::getName | ( | void | ) | [inline] |
Get the saved name of our cidr.
This is typically used with find when the same policy name might be associated with multiple non- overlapping cidr blocks. A typical use might to have a cidr block like 127/8 named "localdomain", as well as the ipv6 "::1".
inethostaddr_t ucommon::cidr::getNetmask | ( | void | ) | [inline] |
inethostaddr_t ucommon::cidr::getNetwork | ( | void | ) | [inline] |
bool ucommon::cidr::is_member | ( | struct sockaddr * | address | ) |
Test if a given socket address falls within this cidr.
address | of socket to test. |
bool ucommon::cidr::operator!= | ( | struct sockaddr * | address | ) | [inline] |
Test if a given socket address falls outside this cidr.
address | of socket to test. |
Definition at line 299 of file socket.h.
References ucommon::LinkedObject::is_member().
Here is the call graph for this function:
bool ucommon::cidr::operator== | ( | struct sockaddr * | address | ) | [inline] |
Test if a given socket address falls within this cidr.
address | of socket to test. |
Definition at line 291 of file socket.h.
References ucommon::LinkedObject::is_member().
Here is the call graph for this function:
void ucommon::cidr::set | ( | char * | string | ) |
Set our cidr to a string address.
Replaces prior value.
string | to set for cidr. |