11 #ifndef BGP_PREFIX4_H_ 12 #define BGP_PREFIX4_H_ 28 Prefix4(uint32_t prefix, uint8_t length);
29 Prefix4(
const char* prefix, uint8_t length);
31 ssize_t
parse(
const uint8_t *buffer,
size_t buf_sz);
32 ssize_t
write(uint8_t *buffer,
size_t buf_sz)
const;
35 static bool Includes (uint32_t prefix, uint8_t length, uint32_t address);
36 static bool Includes (uint32_t prefix_a, uint8_t length_a, uint32_t prefix_b, uint8_t length_b);
39 bool includes (uint32_t address)
const;
40 bool includes (
const char* address)
const;
44 bool includes (uint32_t prefix, uint8_t length)
const;
45 bool includes (
const char* prefix, uint8_t length)
const;
52 bool operator> (
const Prefix &other)
const;
56 bool operator< (
const Prefix &other)
const;
58 bool operator>= (
const Prefix &other)
const;
59 bool operator<= (
const Prefix &other)
const;
60 bool operator!= (
const Prefix &other)
const;
62 bool set(uint32_t prefix, uint8_t length);
76 #endif // BGP_PREFIX4_H_ uint32_t getPrefix() const
Get prefix.
uint32_t getMask() const
Get netmask.
static bool Includes(uint32_t prefix, uint8_t length, uint32_t address)
Test if an address is inside a prefix.
Route/Prefix related utilities.
bool setLength(uint8_t length)
Set netmask.
bool includes(uint32_t address) const
Test if an address is inside this prefix.
bool operator==(const Prefix &other) const
Test if two routes are equals.
uint8_t getLength() const
Get netmask.
uint32_t cidr_to_mask(uint8_t cidr)
Convert netmask in CIDR notation to network bytes integer.
Prefix4()
Construct a new Prefix4 object.
bool setPrefix(uint32_t prefix)
Set prefix.
IPv4 Route/Prefix related utilities.
ssize_t write(uint8_t *buffer, size_t buf_sz) const
Write a IPv4 prefix to NLRI buffer.
Route/Prefix related utilities.
ssize_t parse(const uint8_t *buffer, size_t buf_sz)
Parse a IPv4 NLRI prefix from buffer.