RTRlib
Loading...
Searching...
No Matches
ipv6_private.h File Reference
#include "ipv6.h"
#include "rtrlib/lib/convert_byte_order_private.h"
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>

Go to the source code of this file.

Functions

bool lrtr_ipv6_addr_equal (const struct lrtr_ipv6_addr *a, const struct lrtr_ipv6_addr *b)
 Compares two lrtr_ipv6_addr structs.
 
struct lrtr_ipv6_addr lrtr_ipv6_get_bits (const struct lrtr_ipv6_addr *val, const uint8_t first_bit, const uint8_t quantity)
 Extracts quantity bits from an IPv6 address.
 
int lrtr_ipv6_addr_to_str (const struct lrtr_ipv6_addr *ip, char *str, const unsigned int len)
 Converts the passed ipv6_addr to string representation.
 
int lrtr_ipv6_str_to_addr (const char *str, struct lrtr_ipv6_addr *ip)
 Converts the passed IPv6 address string in to lrtr_ipv6_addr struct.
 
void lrtr_ipv6_addr_convert_byte_order (const uint32_t *src, uint32_t *dest, const enum target_byte_order tbo)
 Converts the passed IPv6 address to given byte order.
 

Function Documentation

◆ lrtr_ipv6_addr_equal()

bool lrtr_ipv6_addr_equal ( const struct lrtr_ipv6_addr a,
const struct lrtr_ipv6_addr b 
)

Compares two lrtr_ipv6_addr structs.

Parameters
[in]alrtr_ipv6_addr
[in]blrtr_ipv6_addr
Returns
true if a == b
false if a != b

◆ lrtr_ipv6_addr_to_str()

int lrtr_ipv6_addr_to_str ( const struct lrtr_ipv6_addr ip,
char *  str,
const unsigned int  len 
)

Converts the passed ipv6_addr to string representation.

Parameters
[in]ip_addrPointer to an IPv6 address
[out]strPointer to string buf, at least INET6_ADDRSTRLEN bytes.
[in]lenLength of string buffer str
Returns
0 on success
-1 on error

◆ lrtr_ipv6_get_bits()

struct lrtr_ipv6_addr lrtr_ipv6_get_bits ( const struct lrtr_ipv6_addr val,
const uint8_t  first_bit,
const uint8_t  quantity 
)

Extracts quantity bits from an IPv6 address.

The bit with the highest significance is bit 0. All bits that aren't in the specified range will be 0.

Parameters
[in]valipv6_addr
[in]first_bitPosition of the first bit that is extracted, inclusive.
[in]quantityHow many bits will be extracted.
Returns
ipv6_addr, with all bits not in specified range set to 0.

◆ lrtr_ipv6_str_to_addr()

int lrtr_ipv6_str_to_addr ( const char *  str,
struct lrtr_ipv6_addr ip 
)

Converts the passed IPv6 address string in to lrtr_ipv6_addr struct.

Parameters
[in]strPointer to a string buffer
[out]ipPointer to lrtr_ipv6_addr
Returns
0 on success
-1 on error