示例#1
0
static bool assert_session_entry_equals(struct session_entry* expected,
		struct session_entry* actual, char* test_name)
{
	if (expected == actual)
		return true;

	if (!expected) {
		log_err("Test '%s' failed: Expected null, obtained " SESSION_PRINT_KEY ".",
				test_name, PRINT_SESSION(actual));
		return false;
	}
	if (!actual) {
		log_err("Test '%s' failed: Expected " SESSION_PRINT_KEY ", got null.",
				test_name, PRINT_SESSION(expected));
		return false;
	}

	if (expected->l4_proto != actual->l4_proto
			|| !ipv6_transport_addr_equals(&expected->remote6, &actual->remote6)
			|| !ipv6_transport_addr_equals(&expected->local6, &actual->local6)
			|| !ipv4_transport_addr_equals(&expected->local4, &actual->local4)
			|| !ipv4_transport_addr_equals(&expected->remote4, &actual->remote4)) {
		log_err("Test '%s' failed: Expected " SESSION_PRINT_KEY ", got " SESSION_PRINT_KEY ".",
				test_name, PRINT_SESSION(expected), PRINT_SESSION(actual));
		return false;
	}

	return true;
}
示例#2
0
static struct session_entry *create_session_entry(int remote_id_4, int local_id_4,
		int local_id_6, int remote_id_6,
		l4_protocol l4_proto)
{
	struct session_entry* entry = session_create(&addr6[remote_id_6], &addr6[local_id_6],
			&addr4[local_id_4], &addr4[remote_id_4],
			l4_proto, NULL);
	if (!entry)
		return NULL;

	log_debug(SESSION_PRINT_KEY, PRINT_SESSION(entry));

	return entry;
}
示例#3
0
bool assert_session_entry_equals(struct session_entry* expected, struct session_entry* actual,
		char* test_name)
{
	if (expected == actual)
		return true;

	if (expected == NULL) {
		log_warning("Test '%s' failed: Expected null, obtained " SESSION_PRINT_KEY ".",
				test_name, PRINT_SESSION(actual));
		return false;
	}
	if (actual == NULL) {
		log_warning("Test '%s' failed: Expected " SESSION_PRINT_KEY ", got null.",
				test_name, PRINT_SESSION(expected));
		return false;
	}
	if (!session_entry_equals(expected, actual)) {
		log_warning("Test '%s' failed: Expected " SESSION_PRINT_KEY ", got " SESSION_PRINT_KEY ".",
				test_name, PRINT_SESSION(expected), PRINT_SESSION(actual));
		return false;
	}

	return true;
}