libbgp  0.6
A C++ BGP Library.
Functions | Variables
prefix6.cc File Reference

IPv6 Route/Prefix related utilities. More...

#include <string.h>
#include <arpa/inet.h>
#include "prefix6.h"
#include "value-op.h"
Include dependency graph for prefix6.cc:

Go to the source code of this file.

Functions

bool libbgp::cidr_to_mask6 (uint8_t src, uint8_t dst[16])
 Convert IPv6 mask in CIDR notation to bytes array. More...
 
bool libbgp::mask_ipv6 (const uint8_t prefix[16], uint8_t mask, uint8_t masked_addr[16])
 Mask a IPv6 address with given netmask. More...
 
bool libbgp::v6addr_is_zero (const uint8_t prefix[16])
 Test if a IPv6 addresss is all zero. More...
 

Variables

const uint8_t libbgp::CIDR_MASK_MAP6 [129][16]
 
const uint16_t libbgp::zero_prefix [16]
 

Detailed Description

IPv6 Route/Prefix related utilities.

Author
Nato Morichika nat@n.nosp@m.at.m.nosp@m.oe
Version
0.1
Date
2019-07-21

Definition in file prefix6.cc.

Function Documentation

◆ cidr_to_mask6()

bool libbgp::cidr_to_mask6 ( uint8_t  src,
uint8_t  dst[16] 
)

Convert IPv6 mask in CIDR notation to bytes array.

Parameters
srcIPv6 mask in CIDR notation.
dstBytes array to write to.
Returns
true Converted.
false Failed to convert.

Definition at line 158 of file prefix6.cc.

References libbgp::cidr_to_mask6().

Referenced by libbgp::cidr_to_mask6(), and libbgp::Prefix6::getMask().

◆ mask_ipv6()

bool libbgp::mask_ipv6 ( const uint8_t  prefix[16],
uint8_t  mask,
uint8_t  masked_addr[16] 
)

Mask a IPv6 address with given netmask.

Parameters
prefixPrefix to mask.
maskIPv6 mask in CIDR notation.
masked_addrBytes array to store masked address.
Returns
true Masked.
false Failed to mask.

Definition at line 173 of file prefix6.cc.

References libbgp::mask_ipv6().

Referenced by libbgp::Prefix6::Includes(), and libbgp::mask_ipv6().

◆ v6addr_is_zero()

bool libbgp::v6addr_is_zero ( const uint8_t  prefix[16])

Test if a IPv6 addresss is all zero.

Parameters
prefixThe prefix to test.
Returns
true Address is all zero;
false Address is not all zero.

Definition at line 195 of file prefix6.cc.

References libbgp::v6addr_is_zero().

Referenced by libbgp::BgpPathAttribMpReachNlriIpv6::length(), and libbgp::v6addr_is_zero().

Variable Documentation

◆ zero_prefix

const uint16_t libbgp::zero_prefix[16]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 184 of file prefix6.cc.