RTRlib
Loading...
Searching...
No Matches
ipv4_private.h File Reference
#include "ipv4.h"
#include "rtrlib/lib/convert_byte_order_private.h"
#include <inttypes.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

struct lrtr_ipv4_addr lrtr_ipv4_get_bits (const struct lrtr_ipv4_addr *val, const uint8_t from, const uint8_t number)
 Extracts number bits from the passed ipv4_addr,.
 
int lrtr_ipv4_str_to_addr (const char *str, struct lrtr_ipv4_addr *ip)
 Converts ab IPv4 address from string to ipv4_addr struct.
 
int lrtr_ipv4_addr_to_str (const struct lrtr_ipv4_addr *ip, char *str, const unsigned int len)
 Converts an ipv4_addr struct to its string representation.
 
bool lrtr_ipv4_addr_equal (const struct lrtr_ipv4_addr *a, const struct lrtr_ipv4_addr *b)
 Compares two ipv4_addr structs.
 
void lrtr_ipv4_addr_convert_byte_order (const uint32_t src, uint32_t *dest, const enum target_byte_order tbo)
 [{
 

Function Documentation

◆ lrtr_ipv4_addr_equal()

bool lrtr_ipv4_addr_equal ( const struct lrtr_ipv4_addr a,
const struct lrtr_ipv4_addr b 
)

Compares two ipv4_addr structs.

Parameters
[in]aipv4_addr
[in]bipv4_addr
Returns
true if a == b
false if a != b

◆ lrtr_ipv4_addr_to_str()

int lrtr_ipv4_addr_to_str ( const struct lrtr_ipv4_addr ip,
char *  str,
const unsigned int  len 
)

Converts an ipv4_addr struct to its string representation.

Parameters
[in]ipipv4_addr
[out]strPointer to a string buffer, of at least INET_ADDRSTRLEN.
[in]lengthof *str
Returns
0 on success
-1 on error

◆ lrtr_ipv4_get_bits()

struct lrtr_ipv4_addr lrtr_ipv4_get_bits ( const struct lrtr_ipv4_addr val,
const uint8_t  from,
const uint8_t  number 
)

Extracts number bits from the passed ipv4_addr,.

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

Parameters
[in]valipv4_addr
[in]fromPosition of the first bit that is extracted.
[in]numberHow many bits will be extracted.
Returns
An ipv4_addr, with all bits not in the specified range set to 0.

◆ lrtr_ipv4_str_to_addr()

int lrtr_ipv4_str_to_addr ( const char *  str,
struct lrtr_ipv4_addr ip 
)

Converts ab IPv4 address from string to ipv4_addr struct.

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