libbgp
0.6
A C++ BGP Library.
|
IPv4 Route/Prefix related utilities. More...
#include <prefix4.h>
Public Member Functions | |
Prefix4 () | |
Construct a new Prefix4 object. | |
Prefix4 (uint32_t prefix, uint8_t length) | |
Construct a new Prefix4 object. More... | |
Prefix4 (const char *prefix, uint8_t length) | |
Construct a new Prefix4:: Prefix4 object. More... | |
ssize_t | parse (const uint8_t *buffer, size_t buf_sz) |
Parse a IPv4 NLRI prefix from buffer. More... | |
ssize_t | write (uint8_t *buffer, size_t buf_sz) const |
Write a IPv4 prefix to NLRI buffer. More... | |
bool | includes (uint32_t address) const |
Test if an address is inside this prefix. More... | |
bool | includes (const char *address) const |
Test if an address is inside this prefix. More... | |
bool | includes (const Prefix &other) const |
Test if another prefix is inside this prefix. More... | |
bool | includes (uint32_t prefix, uint8_t length) const |
Test if another prefix is inside this prefix. More... | |
bool | includes (const char *prefix, uint8_t length) const |
Test if another prefix is inside this prefix. More... | |
bool | operator== (const Prefix &other) const |
Test if two routes are equals. More... | |
bool | operator> (const Prefix &other) const |
bool | operator< (const Prefix &other) const |
bool | operator>= (const Prefix &other) const |
bool | operator<= (const Prefix &other) const |
bool | operator!= (const Prefix &other) const |
bool | set (uint32_t prefix, uint8_t length) |
Set Prefix4. More... | |
bool | setPrefix (uint32_t prefix) |
Set prefix. More... | |
bool | setLength (uint8_t length) |
Set netmask. More... | |
uint32_t | getPrefix () const |
Get prefix. More... | |
uint8_t | getLength () const |
Get netmask. More... | |
uint32_t | getMask () const |
Get netmask. More... | |
Static Public Member Functions | |
static bool | Includes (uint32_t prefix, uint8_t length, uint32_t address) |
Test if an address is inside a prefix. More... | |
static bool | Includes (uint32_t prefix_a, uint8_t length_a, uint32_t prefix_b, uint8_t length_b) |
Test if a prefix is inside another prefix. More... | |
Additional Inherited Members | |
Public Attributes inherited from libbgp::Prefix | |
Afi | afi |
IPv4 Route/Prefix related utilities.
libbgp::Prefix4::Prefix4 | ( | uint32_t | prefix, |
uint8_t | length | ||
) |
Construct a new Prefix4 object.
prefix | Prefix in network bytes order. |
length | Netmask in CIDR notation. |
bad_route_length | Netmask invalid. |
Definition at line 54 of file prefix4.cc.
libbgp::Prefix4::Prefix4 | ( | const char * | prefix, |
uint8_t | length | ||
) |
Construct a new Prefix4:: Prefix4 object.
prefix | Prefix in dotted string notation. |
length | Netmask in CIDR notation. |
bad_route_length | Netmask invalid. |
Definition at line 68 of file prefix4.cc.
uint8_t libbgp::Prefix4::getLength | ( | ) | const |
Get netmask.
Definition at line 297 of file prefix4.cc.
uint32_t libbgp::Prefix4::getMask | ( | ) | const |
Get netmask.
bad_route_length | Netmask invalid. |
Definition at line 307 of file prefix4.cc.
uint32_t libbgp::Prefix4::getPrefix | ( | ) | const |
Get prefix.
Definition at line 288 of file prefix4.cc.
|
static |
Test if an address is inside a prefix.
prefix | The prefix in network bytes order. |
length | The netmask of prefix in CIDR notation. |
address | The address in network bytes order. |
Definition at line 120 of file prefix4.cc.
|
static |
Test if a prefix is inside another prefix.
prefix_a | The prefix in network bytes order. |
length_a | The netmask of prefix in CIDR notation. |
prefix_b | The prefix to test against. |
length_b | The netmask of prefix to test against in CIDR notation. |
Definition at line 135 of file prefix4.cc.
bool libbgp::Prefix4::includes | ( | uint32_t | address | ) | const |
Test if an address is inside this prefix.
address | The address in network bytes order. |
Definition at line 148 of file prefix4.cc.
Referenced by includes().
bool libbgp::Prefix4::includes | ( | const char * | address | ) | const |
Test if an address is inside this prefix.
address | The address in dotted string notation. |
Definition at line 159 of file prefix4.cc.
References includes().
|
virtual |
Test if another prefix is inside this prefix.
other | The other prefix. |
Implements libbgp::Prefix.
Definition at line 186 of file prefix4.cc.
bool libbgp::Prefix4::includes | ( | uint32_t | prefix, |
uint8_t | length | ||
) | const |
Test if another prefix is inside this prefix.
prefix | The prefix in network bytes order. |
length | The netmask of prefix in CIDR notation. |
Definition at line 173 of file prefix4.cc.
bool libbgp::Prefix4::includes | ( | const char * | prefix, |
uint8_t | length | ||
) | const |
Test if another prefix is inside this prefix.
prefix | The prefix in dotted string notation. |
length | The netmask of prefix in CIDR notation. |
Definition at line 200 of file prefix4.cc.
References includes().
|
virtual |
Test if two routes are equals.
other | The other route object. |
Implements libbgp::Prefix.
Definition at line 213 of file prefix4.cc.
|
virtual |
Parse a IPv4 NLRI prefix from buffer.
buffer | Buffer to parse from. |
buf_sz | Size of the buffer. |
-1 | Failed to parse prefix. |
>=0 | Bytes read. |
Implements libbgp::Prefix.
Definition at line 84 of file prefix4.cc.
bool libbgp::Prefix4::set | ( | uint32_t | prefix, |
uint8_t | length | ||
) |
Set Prefix4.
prefix | The prefix in netowkr byte order. |
length | The netmask in CIDR notation. |
Definition at line 251 of file prefix4.cc.
bool libbgp::Prefix4::setLength | ( | uint8_t | length | ) |
Set netmask.
length | The netmask in CIDR notation. |
Definition at line 277 of file prefix4.cc.
bool libbgp::Prefix4::setPrefix | ( | uint32_t | prefix | ) |
Set prefix.
prefix | The prefix to set in network byte order. |
Definition at line 265 of file prefix4.cc.
|
virtual |
Write a IPv4 prefix to NLRI buffer.
buffer | Buffer to write to. |
buf_sz | Size of the buffer (max write size). |
-1 | Failed to write. |
>=0 | Bytes written. |
Implements libbgp::Prefix.
Definition at line 103 of file prefix4.cc.