44 struct argv a = { 0 };
55get_ipv6_addr(
const char *prefix_str,
struct in6_addr *network,
unsigned int *netbits,
63getaddr(
unsigned int flags,
const char *hostname,
int resolve_retry,
bool *succeeded,
72 int resolve_retry_seconds,
struct signal_info *sig_info,
int ai_family,
73 struct addrinfo **res)
106 assert_int_equal(netbits, 8);
109 assert_int_equal(netbits, 24);
112 assert_int_equal(netbits, 0);
116 assert_int_equal(netbits, -1);
142 struct in6_addr want;
145 assert_int_equal(inet_pton(AF_INET6, addr, &
r6.network), 1);
146 assert_int_equal(inet_pton(AF_INET6, expected, &want), 1);
147 r6.netbits = netbits;
150 assert_memory_equal(&
r6.network, &want,
sizeof(
struct in6_addr));
struct argv argv_new(void)
Allocates a new struct argv and ensures it is initialised.
bool is_special_addr(const char *addr_str)
int netmask_to_netbits2(in_addr_t netmask)
void route_ipv6_clear_host_bits(struct route_ipv6 *r6)
bool netmask_to_netbits(const in_addr_t network, const in_addr_t netmask, int *netbits)
struct signal_info siginfo_static
static void openvpn_unit_test_setup(void)
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
static void test_route_ipv6_clear_host_bits(void **state)
int route_tests(void)
Runs the route.c unit tests, returns the number of failures.
static void test_netmask_to_netbits(void **state)
int openvpn_getaddrinfo(unsigned int flags, const char *hostname, const char *servname, int resolve_retry_seconds, struct signal_info *sig_info, int ai_family, struct addrinfo **res)
bool get_ipv6_addr(const char *prefix_str, struct in6_addr *network, unsigned int *netbits, msglvl_t msglevel)
Translate an IPv6 addr or hostname from string form to in6_addr.
int signal_reset(struct signal_info *si, int signum)
Clear the signal if its current value equals signum.
static void assert_clear_host_bits(const char *addr, unsigned int netbits, const char *expected)
in_addr_t getaddr(unsigned int flags, const char *hostname, int resolve_retry, bool *succeeded, struct signal_info *sig_info)
Translate an IPv4 addr or hostname from string form to in_addr_t.
static const struct CMUnitTest route_test_list[]
void argv_free(struct argv *a)
Frees all memory allocations allocated by the struct argv related functions.
static void test_netmask_to_netbits2(void **state)
static void test_is_special_addr(void **state)