11 #ifndef BGP_PREFIX6_H_ 12 #define BGP_PREFIX6_H_ 20 bool mask_ipv6(
const uint8_t prefix[16], uint8_t mask, uint8_t masked_addr[16]);
30 Prefix6(
const uint8_t prefix[16], uint8_t length);
31 Prefix6(
const char* prefix, uint8_t length);
33 ssize_t
parse(
const uint8_t *buffer,
size_t buf_sz);
34 ssize_t
write(uint8_t *buffer,
size_t buf_sz)
const;
37 static bool Includes (
const uint8_t prefix[16], uint8_t length,
const uint8_t address[16]);
38 static bool Includes (
const uint8_t prefix_a[16], uint8_t length_a,
const uint8_t prefix_b[16], uint8_t length_b);
41 bool includes (
const uint8_t address[16])
const;
42 bool includes (
const char* address)
const;
46 bool includes (
const uint8_t prefix[16], uint8_t length)
const;
47 bool includes (
const char* prefix, uint8_t length)
const;
54 bool operator> (
const Prefix &other)
const;
58 bool operator< (
const Prefix &other)
const;
60 bool operator>= (
const Prefix &other)
const;
61 bool operator<= (
const Prefix &other)
const;
62 bool operator!= (
const Prefix &other)
const;
64 bool set(
const uint8_t prefix[16], uint8_t length);
69 void getMask(uint8_t mask[16])
const;
78 #endif // BGP_PREFIX6_H_ IPv6 Route/Prefix related utilities.
static bool Includes(const uint8_t prefix[16], uint8_t length, const uint8_t address[16])
Test if an address is inside a prefix.
uint8_t getLength() const
Get netmask.
bool cidr_to_mask6(uint8_t src, uint8_t dst[16])
Convert IPv6 mask in CIDR notation to bytes array.
Route/Prefix related utilities.
bool operator==(const Prefix &other) const
Test if two routes are equals.
bool includes(const uint8_t address[16]) const
Test if an address is inside this prefix.
Prefix6()
Construct a new Prefix6 object.
bool v6addr_is_zero(const uint8_t prefix[16])
Test if a IPv6 addresss is all zero.
bool setPrefix(const uint8_t prefix[16])
Set prefix.
bool mask_ipv6(const uint8_t prefix[16], uint8_t mask, uint8_t masked_addr[16])
Mask a IPv6 address with given netmask.
ssize_t parse(const uint8_t *buffer, size_t buf_sz)
Parse a IPv6 NLRI prefix from buffer.
Route/Prefix related utilities.
void getPrefix(uint8_t prefix[16]) const
Get prefix.
ssize_t write(uint8_t *buffer, size_t buf_sz) const
Write a IPv6 prefix to NLRI buffer.
bool setLength(uint8_t length)
Set netmask.
void getMask(uint8_t mask[16]) const
Get netmask.