UCommon
|
A class to hold internet segment routing rules. More...
#include <socket.h>
Public Types | |
typedef LinkedObject | policy |
A convenience type for using a pointer to a linked list as a policy chain. | |
Public Member Functions | |
cidr () | |
Create an uninitialized cidr. | |
cidr (const char *string) | |
Create an unlinked cidr from a string. More... | |
cidr (policy **policy, const char *string) | |
Create an unnamed cidr entry on a specified policy chain. More... | |
cidr (policy **policy, const char *string, const char *name) | |
Create a named cidr entry on a specified policy chain. More... | |
cidr (const cidr &existing) | |
Construct a copy of an existing cidr. More... | |
struct hostaddr_internet | getBroadcast (void) const |
Get the broadcast host address represented by our cidr. More... | |
int | getFamily (void) const |
Get the address family of our cidr block object. More... | |
unsigned | getMask (void) const |
Get the number of bits in the cidr bitmask. More... | |
const char * | getName (void) const |
Get the saved name of our cidr. More... | |
struct hostaddr_internet | getNetmask (void) const |
Get the effective network mask for our cidr block. More... | |
struct hostaddr_internet | getNetwork (void) const |
Get the network host base address of our cidr block. More... | |
bool | is_member (const struct sockaddr *address) const |
Test if a given socket address falls within this cidr. More... | |
bool | operator!= (const struct sockaddr *address) const |
Test if a given socket address falls outside this cidr. More... | |
bool | operator== (const struct sockaddr *address) const |
Test if a given socket address falls within this cidr. More... | |
void | set (const char *string) |
Set our cidr to a string address. More... | |
![]() | |
void | delist (LinkedObject **root) |
Locate and remove ourselves from a list of objects. More... | |
void | enlist (LinkedObject **root) |
Add our object to an existing linked list through a pointer. More... | |
LinkedObject * | getNext (void) const |
Get next effective object when iterating. More... | |
bool | is_member (LinkedObject *list) const |
Search to see if we are a member of a specific list. More... | |
virtual void | release (void) |
Release list, mark as no longer linked. More... | |
virtual void | retain (void) |
Retain by marking as self referenced list. More... | |
![]() | |
ObjectProtocol * | copy (void) |
Retain (increase retention of) object when copying. | |
void | operator++ (void) |
Increase retention operator. | |
void | operator-- (void) |
Decrease retention operator. | |
virtual | ~ObjectProtocol () |
Required virtual destructor. | |
Static Public Member Functions | |
static const cidr * | container (const policy *policy, const struct sockaddr *address) |
Get the largest container cidr entry in a list that matches the socket address. More... | |
static const cidr * | find (const policy *policy, const struct sockaddr *address) |
Find the smallest cidr entry in a list that matches the socket address. More... | |
![]() | |
static unsigned | count (const LinkedObject *root) |
Count the number of linked objects in a list. More... | |
static LinkedObject * | getIndexed (LinkedObject *root, unsigned index) |
Get member by index. More... | |
static void | purge (LinkedObject *root) |
Release all objects from a list. More... | |
Protected Member Functions | |
struct hostaddr_internet | broadcast (void) const |
unsigned | mask (const char *cp) const |
unsigned | mask (void) const |
![]() | |
LinkedObject (LinkedObject **root) | |
Construct base class attached to a chain of objects. More... | |
LinkedObject () | |
Construct base class unattached to anyone. More... | |
LinkedObject (const LinkedObject &from) | |
Protected Attributes | |
int | Family |
char | Name [16] |
struct hostaddr_internet Netmask | Network |
![]() | |
LinkedObject * | Next |
A class to hold internet segment routing rules.
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.
ucommon::cidr::cidr | ( | const 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, |
const 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, |
const char * | string, | ||
const 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 | ( | const cidr & | existing | ) |
Construct a copy of an existing cidr.
existing | cidr we copy from. |
|
static |
Get the largest container cidr entry in a list that matches the socket address.
policy | chain to search. |
address | to search for. |
|
static |
Find the smallest cidr entry in a list that matches the socket address.
policy | chain to search. |
address | to search for. |
|
inline |
|
inline |
|
inline |
|
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".
|
inline |
|
inline |
bool ucommon::cidr::is_member | ( | const struct sockaddr * | address | ) | const |
Test if a given socket address falls within this cidr.
address | of socket to test. |
|
inline |
|
inline |
void ucommon::cidr::set | ( | const char * | string | ) |
Set our cidr to a string address.
Replaces prior value.
string | to set for cidr. |