Loading...
Searching...
No Matches
ip.h
/*
* This file is part of RTRlib.
*
* This file is subject to the terms and conditions of the MIT license.
* See the file LICENSE in the top level directory for more details.
*
* Website: http://rtrlib.realmv6.org/
*/
#ifndef LRTR_IP_PUBLIC_H
#define LRTR_IP_PUBLIC_H
#include "rtrlib/lib/ipv4.h"
#include "rtrlib/lib/ipv6.h"
#include <stdbool.h>
enum lrtr_ip_version {
LRTR_IPV4,
LRTR_IPV6
};
struct lrtr_ip_addr {
enum lrtr_ip_version ver;
union {
struct lrtr_ipv4_addr addr4;
struct lrtr_ipv6_addr addr6;
} u;
};
int lrtr_ip_addr_to_str(const struct lrtr_ip_addr *ip, char *str, const unsigned int len);
int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip);
bool lrtr_ip_addr_equal(const struct lrtr_ip_addr a, const struct lrtr_ip_addr b);
bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2);
#endif
lrtr_ip_addr_to_str
int lrtr_ip_addr_to_str(const struct lrtr_ip_addr *ip, char *str, const unsigned int len)
lrtr_ip_addr_equal
bool lrtr_ip_addr_equal(const struct lrtr_ip_addr a, const struct lrtr_ip_addr b)
Checks if two lrtr_ip_addr structs are equal.
lrtr_ip_str_cmp
bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2)
lrtr_ip_version
lrtr_ip_version
Version of the IP protocol.
Definition ip.h:25
lrtr_ip_str_to_addr
int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip)
LRTR_IPV6
@ LRTR_IPV6
Definition ip.h:30
LRTR_IPV4
@ LRTR_IPV4
Definition ip.h:27
lrtr_ip_addr
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition ip.h:38
lrtr_ipv4_addr
Struct storing an IPv4 address in host byte order.
Definition ipv4.h:19
lrtr_ipv6_addr
Struct holding an IPv6 address in host byte order.
Definition ipv6.h:18