RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
ip.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * This file is subject to the terms and conditions of the MIT license.
5  * See the file LICENSE in the top level directory for more details.
6  *
7  * Website: http://rtrlib.realmv6.org/
8 */
9 
10 #ifndef LRTR_IP_H
11 #define LRTR_IP_H
12 #include "rtrlib/lib/ipv4.h"
13 #include "rtrlib/lib/ipv6.h"
14 
15 
19 enum lrtr_ip_version {
21  LRTR_IPV4,
22 
24  LRTR_IPV6
25 };
26 
32 struct lrtr_ip_addr {
33  enum lrtr_ip_version ver;
34  union {
35  struct lrtr_ipv4_addr addr4;
36  struct lrtr_ipv6_addr addr6;
37  } u;
38 };
39 
46 bool lrtr_ip_addr_is_zero(const struct lrtr_ip_addr);
47 
56 struct lrtr_ip_addr lrtr_ip_addr_get_bits(const struct lrtr_ip_addr *val, const uint8_t from, const uint8_t number);
57 
68 bool lrtr_ip_addr_equal(const struct lrtr_ip_addr a, const struct lrtr_ip_addr b);
69 
79 int lrtr_ip_addr_to_str(const struct lrtr_ip_addr *ip, char *str, const unsigned int len);
80 
88 int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip);
89 
97 bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2);
98 
99 #endif
100 /* @} */
bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2)
Definition: ip.c:66
int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip)
Definition: ip.c:56
Struct holding an IPv6 address in host byte order.
Definition: ipv6.h:21
int lrtr_ip_addr_to_str(const struct lrtr_ip_addr *ip, char *str, const unsigned int len)
Definition: ip.c:49
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition: ip.h:32
Struct storing an IPv4 address in host byte order.
Definition: ipv4.h:19