RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
ip.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * RTRlib is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * RTRlib is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with RTRlib; see the file COPYING.LESSER.
16  *
17  * INET group, Hamburg University of Applied Sciences,
18  * CST group, Freie Universitaet Berlin
19  * Website: http://rpki.realmv6.org/
20  */
21 
22 #ifndef RTR_IP_H
23 #define RTR_IP_H
24 #include "rtrlib/lib/ipv4.h"
25 #include "rtrlib/lib/ipv6.h"
26 
27 
31 enum ip_version {
33  IPV4,
34 
36  IPV6
37 };
38 
44 struct ip_addr {
45  enum ip_version ver;
46  union {
47  struct ipv4_addr addr4;
48  struct ipv6_addr addr6;
49  } u;
50 };
51 
58 bool ip_addr_is_zero(const struct ip_addr);
59 
68 struct ip_addr ip_addr_get_bits(const struct ip_addr *val, const uint8_t from, const uint8_t number);
69 
80 bool ip_addr_equal(const struct ip_addr a, const struct ip_addr b);
81 
91 int ip_addr_to_str(const struct ip_addr *ip, char *str, const unsigned int len);
92 
100 int ip_str_to_addr(const char *str, struct ip_addr *ip);
101 
109 bool ip_str_cmp(const struct ip_addr *addr1, const char *addr2);
110 
111 #endif
112 /* @} */
int ip_str_to_addr(const char *str, struct ip_addr *ip)
Definition: ip.c:68
The ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition: ip.h:44
int ip_addr_to_str(const struct ip_addr *ip, char *str, const unsigned int len)
Definition: ip.c:61
Struct storing an IPv4 address in host byte order.
Definition: ipv4.h:31
Struct holding an IPv6 address in host byte order.
Definition: ipv6.h:33
bool ip_str_cmp(const struct ip_addr *addr1, const char *addr2)
Definition: ip.c:78