Example #1
0
static bool test_4to6(char *addr4_str, char *addr6_str)
{
	struct in_addr addr4;
	struct in6_addr addr6;
	bool success = true;

	log_debug("Testing %s -> %s...", addr4_str, addr6_str);

	if (str_to_addr4(addr4_str, &addr4))
		return false;

	if (addr6_str) {
		success &= ASSERT_INT(0, eamt_xlat_4to6(&addr4, &addr6), "errcode");
		success &= ASSERT_ADDR6(addr6_str, &addr6, "resulting address");
	} else {
		success &= ASSERT_INT(-ESRCH, eamt_xlat_4to6(&addr4, &addr6), "errcode");
	}

	return success;
}
Example #2
0
static bool assert_bib_exists(char *addr6, u16 port6, char *addr4, u16 port4,
		l4_protocol proto, unsigned int session_count)
{
	struct bib_entry bib;
	struct ipv6_transport_addr tuple_addr;
	bool success = true;

	if (str_to_addr6(addr6, &tuple_addr.l3))
		return false;
	tuple_addr.l4 = port6;

	success &= ASSERT_INT(0, bib_find6(jool.nat64.bib, proto, &tuple_addr, &bib), "BIB exists");
	if (!success)
		return false;

	success &= ASSERT_ADDR6(addr6, &bib.ipv6.l3, "IPv6 address");
	success &= ASSERT_UINT(port6, bib.ipv6.l4, "IPv6 port");
	success &= ASSERT_ADDR4(addr4, &bib.ipv4.l3, "IPv4 address");
	/* The IPv4 port is unpredictable. */
	success &= ASSERT_BOOL(proto, bib.l4_proto, "BIB proto");

	return success;
}