/** * Prepares the environment for the tests. * * @return whether the initialization was successful or not. An error message has been printed to * the kernel ring buffer. */ static bool init(void) { u_int8_t protocols[] = { IPPROTO_UDP, IPPROTO_TCP, IPPROTO_ICMP }; int i; struct ipv6_prefix prefix; // Init test addresses if (str_to_addr6(remote_ipv6_str, &remote_ipv6) != 0) { log_warning("Can't parse address '%s'. Failing test...", remote_ipv6_str); return false; } if (str_to_addr6(local_ipv6_str, &local_ipv6) != 0) { log_warning("Can't parse address '%s'. Failing test...", local_ipv6_str); return false; } if (str_to_addr4(local_ipv4_str, &local_ipv4) != 0) { log_warning("Can't parse address '%s'. Failing test...", local_ipv4_str); return false; } if (str_to_addr4(remote_ipv4_str, &remote_ipv4) != 0) { log_warning("Can't parse address '%s'. Failing test...", remote_ipv4_str); return false; } // Init the IPv6 pool module if (!pool6_init()) return false; if (str_to_addr6("64:ff9b::", &prefix.address) != 0) { log_warning("Cannot parse the IPv6 prefix. Failing..."); return false; } prefix.len = 96; if (pool6_register(&prefix) != 0) { log_warning("Could not add the IPv6 prefix. Failing..."); return false; } // Init the BIB module if (!bib_init()) return false; for (i = 0; i < ARRAY_SIZE(protocols); i++) if (!add_bib(&local_ipv4, 80, &remote_ipv6, 1500, protocols[i])) return false; return true; }
/** * Prepares the environment for the tests. * * @return whether the initialization was successful or not. An error message has been printed to * the kernel ring buffer. */ static bool init(void) { l4_protocol l4_protos[] = { L4PROTO_UDP, L4PROTO_TCP, L4PROTO_ICMP }; int i; struct ipv6_prefix prefix; /* Init test addresses */ if (str_to_addr6(remote_ipv6_str, &remote_ipv6) != 0) { log_warning("Can't parse address '%s'. Failing test...", remote_ipv6_str); return false; } if (str_to_addr6(local_ipv6_str, &local_ipv6) != 0) { log_warning("Can't parse address '%s'. Failing test...", local_ipv6_str); return false; } if (str_to_addr4(local_ipv4_str, &local_ipv4) != 0) { log_warning("Can't parse address '%s'. Failing test...", local_ipv4_str); return false; } if (str_to_addr4(remote_ipv4_str, &remote_ipv4) != 0) { log_warning("Can't parse address '%s'. Failing test...", remote_ipv4_str); return false; } /* Init the IPv6 pool module */ if (is_error(pool6_init(NULL, 0))) /* we'll use the defaults. */ return false; if (str_to_addr6("64:ff9b::", &prefix.address) != 0) { log_warning("Cannot parse the IPv6 prefix. Failing..."); return false; } prefix.len = 96; /* Init the BIB module */ if (is_error(bib_init())) return false; for (i = 0; i < ARRAY_SIZE(l4_protos); i++) if (!add_bib(&local_ipv4, 80, &remote_ipv6, 1500, l4_protos[i])) return false; return true; }