bool simple_bib_session(void)
{
	struct bib_entry *bib;
	struct session_entry *session;

	bib = create_bib_entry(0, 0);
	if (!bib) {
		log_warning("Could not allocate a BIB entry.");
		return false;
	}
	session = create_session_entry(1, 0, 1, 0, bib, IPPROTO_TCP, 12345);
	if (!session) {
		log_warning("Could not allocate a Session entry.");
		return false;
	}

	// Insert the BIB entry.
	if (!bib_add(bib, IPPROTO_TCP)) {
		log_warning("Test 'BIB insertion' failed: Call returned false.");
		return false;
	}
	if (!assert_bib("BIB insertion", bib, false, true, false))
		return false;

	// Insert the session entry.
	if (!session_add(session)) {
		log_warning("Test 'Session insertion' failed: Call returned false.");
		return false;
	}
	if (!assert_session("Session insertion", session, false, true, false))
		return false;

	// The BIB entry has a session entry, so it shouldn't be removable.
	if (bib_remove(bib, IPPROTO_TCP)) {
		log_warning("Test 'Bib removal' failed: Removal shouldn't have succeeded.");
		return false;
	}
	if (!assert_bib("Bib removal (bib table)", bib, false, true, false))
		return false;
	if (!assert_session("BIB removal (session table)", session, false, true, false))
		return false;

	// Remove the session entry.
	// Because the BIB entry no longer has sessions, it should be automatically removed as well.
	if (!session_remove(session)) {
		log_warning("Test 'Session removal' failed: Call returned false.");
		return false;
	}
	if (!assert_bib("Session removal (bib table)", bib, false, false, false))
		return false;
	if (!assert_session("Session removal (session table)", session, false, false, false))
		return false;

	// Quit.
	return true;
}
Exemple #2
0
bool simple_session(void)
{
	struct session_entry *session;
	bool success = true;

	session = create_session_entry(1, 0, 1, 0, NULL, IPPROTO_TCP, 12345);
	if (!assert_not_null(session, "Allocation of test session entry"))
		return false;

	success &= assert_equals_int(0, session_add(session), "Session insertion call");
	success &= assert_session("Session insertion state", session, false, true, false);
	if (!success)
		return false; /* See simple_bib(). */

	success &= assert_true(session_remove(session), "Session removal call");
	success &= assert_session("Session removal state", session, false, false, false);
	if (!success)
		return false;

	kfree(session);
	return true;
}
Exemple #3
0
static bool simple_session(void)
{
	struct session_entry *session;
	bool success = true;

	session = create_session_entry(1, 0, 1, 0, L4PROTO_TCP);
	if (!assert_not_null(session, "Allocation of test session entry"))
		return false;

	success &= assert_equals_int(0, sessiondb_add(session, SESSIONTIMER_EST),
			"Session insertion call");
	success &= assert_session("Session insertion state", session, false, true, false);
	if (!success)
		return false;

	return true;
}
Exemple #4
0
static bool test_db(void)
{
	unsigned int la; /* local addr */
	unsigned int lp; /* local port */
	unsigned int ra; /* remote addr */
	unsigned int rp; /* remote port */
	bool success = true;

	for (la = 0; la < 4; la++) {
		for (lp = 0; lp < 4; lp++) {
			for (ra = 0; ra < 4; ra++) {
				for (rp = 0; rp < 4; rp++) {
					success &= assert_session(la, lp, ra, rp);
				}
			}
		}
	}

	return success;
}