Beispiel #1
0
static bool test_get_any_port_aux(enum l4_protocol proto, int id_count,
		char *test_name)
{
	int a, p; /* address counter, port counter */
	__u16 result;
	bool success = true;

	for (a = 0; a < ARRAY_SIZE(expected_ips); a++) {
		for (p = 0; p < id_count; p++) {
			success &= assert_equals_int(0, pool4_get_any_port(proto, &expected_ips[a], &result),
					test_name);
			success &= assert_false(ports[a][result], test_name);
			ports[a][result] = true;

			if (!success)
				return success;
		}

		if (!assert_equals_int(-ESRCH, pool4_get_any_port(proto, &expected_ips[a], &result),
				test_name))
			return false;
	}

	return true;
}
Beispiel #2
0
/**
 * Inserts a single entry, validates it, removes it, validates again.
 * Does not touch the session tables.
 */
static bool simple_bib(void)
{
	struct ipv4_transport_addr addr = addr4[0];
	struct bib_entry *bib;
	bool success = true;

	if (is_error(pool4_get_any_port(L4PROTO_TCP, &addr.l3, &addr.l4)))
		return false;

	bib = bib_create(&addr, &addr6[0], false, L4PROTO_TCP);
	if (!assert_not_null(bib, "Allocation of test BIB entry"))
		return false;

	success &= assert_equals_int(0, bibdb_add(bib), "BIB insertion call");
	success &= assert_bib("BIB insertion state", bib, false, true, false);
	if (!success)
		return false;

	success &= assert_equals_int(0, bibdb_remove(bib, false), "BIB removal call");
	success &= assert_bib("BIB removal state", bib, false, false, false);
	if (!success)
		return false;

	bib_kfree(bib);
	return success;
}