Example #1
0
int init_module(void)
{
	START_TESTS("Session");

	INIT_CALL_END(init(), simple_session(), end(), "Single Session");
	INIT_CALL_END(init(), test_address_filtering(), end(), "Address-dependent filtering.");
	INIT_CALL_END(init(), test_compare_session4(), end(), "compare_session4()");

	INIT_CALL_END(init(), test_tcp_v4_init_state_handle_v6syn(), end(), "TCP-V4 INIT-V6 syn");
	INIT_CALL_END(init(), test_tcp_v4_init_state_handle_else(), end(), "TCP-V4 INIT-else");
	INIT_CALL_END(init(), test_tcp_v6_init_state_handle_v6syn(), end(), "TCP-V6 INIT-V6 SYN");
	INIT_CALL_END(init(), test_tcp_v6_init_state_handle_v4syn(), end(), "TCP-V6 INIT-V4 SYN");
	INIT_CALL_END(init(), test_tcp_v6_init_state_handle_else(), end(), "TCP-V6 INIT-else");
	INIT_CALL_END(init(), test_tcp_established_state_handle_v4fin(), end(), "TCP-established-V4 fin");
	INIT_CALL_END(init(), test_tcp_established_state_handle_v6fin(), end(), "TCP-established-V6 fin");
	INIT_CALL_END(init(), test_tcp_established_state_handle_v4rst(), end(), "TCP-established-V4 rst");
	INIT_CALL_END(init(), test_tcp_established_state_handle_v6rst(), end(), "TCP-established-V6 rst");
	INIT_CALL_END(init(), test_tcp_established_state_handle_else(), end(), "TCP-established-else");
	INIT_CALL_END(init(), test_tcp_v4_fin_rcv_state_handle_v6fin(), end(), "TCP-V4 FIN RCV-V6 fin");
	INIT_CALL_END(init(), test_tcp_v4_fin_rcv_state_handle_else(), end(), "TCP-V4 FIN RCV-else");
	INIT_CALL_END(init(), test_tcp_v6_fin_rcv_state_handle_v4fin(), end(), "TCP-V6 FIN RCV-v4fin");
	INIT_CALL_END(init(), test_tcp_v6_fin_rcv_state_handle_else(), end(), "TCP-V6 FIN RCV-else");
	INIT_CALL_END(init(), test_tcp_trans_state_handle_v6rst(), end(), "TCP-TRANS-V6 rst");
	INIT_CALL_END(init(), test_tcp_trans_state_handle_v4rst(), end(), "TCP-TRANS-V4 rst");
	INIT_CALL_END(init(), test_tcp_trans_state_handle_else(), end(), "TCP-TRANS-else");

	END_TESTS;
}
Example #2
0
int main() {
	
	// Prevent output buffering, so we don't see weird shit when multiple processes are active
	setbuf(stdout, NULL);
	
	// Seed the random number generator
	srand(time(NULL));
	
	// Test!
	START_TESTS();
	
	TEST_AREA("open & release");
	RUN_TEST(open_release_simple);
	RUN_TEST(two_releases_processes);
	RUN_TEST(two_releases_threads);
	RUN_TEST(open_release_open);
	RUN_TEST(first_open_is_white);
	RUN_TEST(open_race_threads);
	RUN_TEST(open_race_processes);
	RUN_TEST(games_race_threads);
	RUN_TEST(games_race_processes);
	
	// That's all folks
	END_TESTS();
	return 0;
	
}
Example #3
0
int init_module(void)
{
	START_TESTS("Session");

	INIT_CALL_END(init(), simple_session(), end(), "Single Session");

	END_TESTS;
}
Example #4
0
int init_module(void)
{
	START_TESTS("Session table");

	INIT_CALL_END(init(), test_foreach(), end(), "Foreach");

	END_TESTS;
}
int init_module(void)
{
	START_TESTS("Determine incoming tuple");

	CALL_TEST(test_determine_in_tuple_ipv4(), "3 fragments IPv4 packet.");
	CALL_TEST(test_determine_in_tuple_ipv6(), "3 fragments IPv6 packet.");

	END_TESTS;
}
Example #6
0
static int pktqueue_test_init(void)
{
	START_TESTS("Packet queue");

	INIT_CALL_END(init(), test_pkt_queue_asr(), end(), "test_pkt_queue 1");
	INIT_CALL_END(init(), test_pkt_queue_ars(), end(), "test_pkt_queue 2");

	END_TESTS;
}
Example #7
0
int init_module(void)
{
	START_TESTS("Addr");

	CALL_TEST(addr_count_test(), "Addr count");
	CALL_TEST(contains_test(), "Prefix contains");

	END_TESTS;
}
Example #8
0
static int configproto_test_init(void)
{
	START_TESTS("Packet queue");

	INIT_CALL_END(init(), basic_test(), end(), "basic test");
	INIT_CALL_END(init(), translate_nulls_mtu(), end(), "nulls mtus");

	END_TESTS;
}
Example #9
0
int init_module(void)
{
	START_TESTS("Hash table");

	CALL_TEST(test(), "Everything, except for_each");
	CALL_TEST(test_for_each_function(), "for_each function");

	END_TESTS;
}
int init_module(void)
{
	START_TESTS("IPv6 header iterator");

	CALL_TEST(test_no_subheaders(), "No subheaders");
	CALL_TEST(test_subheaders(), "Subheaders");

	END_TESTS;
}
Example #11
0
int init_module(void)
{
	START_TESTS("Pool");

	INIT_CALL_END(init(), test_get_any_function(), destroy(), "Get simple");
	INIT_CALL_END(init(), test_return_function(), destroy(), "Get and Return");
	INIT_CALL_END(init(), test_get_similar_function(), destroy(), "Allocate functions");

	END_TESTS;
}
Example #12
0
static int send_packet_test_init(void)
{
	START_TESTS("Send Packet test");

	INIT_CALL_END(init(), divide_skb6_udp(), end(), "test_send_packet IPv6 UDP fragmentation");
	INIT_CALL_END(init(), divide_skb6_icmp(), end(), "test_send_packet IPv6 ICMP fragmentation");
	INIT_CALL_END(init(), divide_skb6_tcp(), end(), "test_send_packet IPv6 TCP fragmentation");

	END_TESTS;
}
Example #13
0
static int address_mapping_test_init(void)
{
	START_TESTS("Address Mapping test");

	INIT_CALL_END(init(), add_test(), end(), "add function");
	INIT_CALL_END(init(), daniel_test(), end(), "Daniel's xlat tests");
	INIT_CALL_END(init(), anderson_test(), end(), "Tore's xlat tests");
	INIT_CALL_END(init(), remove_test(), end(), "remove function");

	END_TESTS;
}
Example #14
0
int init_module(void)
{
	START_TESTS("BIB");

	INIT_CALL_END(init(), simple_bib(), end(), "Single BIB");
	INIT_CALL_END(init(), test_allocate_ipv4_transport_address(), end(), "Allocate function.");
	INIT_CALL_END(init(), test_compare_addr6(), end(), "compare_addr6");
	INIT_CALL_END(init(), test_compare_full6(), end(), "compare_full6");
	INIT_CALL_END(init(), test_compare_addr4(), end(), "compare_addr4");

	END_TESTS;
}
Example #15
0
int init_module(void)
{
	START_TESTS("BIB-Session");

	INIT_CALL_END(init(), simple_bib(), end(), "Single BIB");
	INIT_CALL_END(init(), simple_session(), end(), "Single Session");
	INIT_CALL_END(init(), test_clean_old_sessions(), end(), "Session cleansing.");
	INIT_CALL_END(init(), test_address_filtering(), end(), "Address-dependent filtering.");
	INIT_CALL_END(init(), test_for_each(), end(), "for-each function.");

	END_TESTS;
}
int init_module(void)
{
	START_TESTS("Determine incoming tuple");

	if (is_error(pktmod_init()))
		return -EINVAL;

	CALL_TEST(test_determine_in_tuple_ipv4(), "3 fragments IPv4 packet.");
	CALL_TEST(test_determine_in_tuple_ipv6(), "3 fragments IPv6 packet.");

	pktmod_destroy();

	END_TESTS;
}
Example #17
0
int init_module(void)
{
    START_TESTS("Pool");

    INIT_CALL_END(init(), test_get_any_function_udp(), destroy(), "Get simple-UDP");
    INIT_CALL_END(init(), test_get_any_function_tcp(), destroy(), "Get simple-TCP");
    INIT_CALL_END(init(), test_get_any_function_icmp(), destroy(), "Get simple-ICMP");
    INIT_CALL_END(init(), test_get_similar_function_udp(), destroy(), "Get similar-UDP");
    INIT_CALL_END(init(), test_get_similar_function_tcp(), destroy(), "Get similar-TCP");
    INIT_CALL_END(init(), test_get_similar_function_icmp(), destroy(), "Get similar-ICMP");
    INIT_CALL_END(init(), test_return_function(), destroy(), "Return function");

    END_TESTS;
}
int __init filtering_test_init(void)
{
    START_TESTS("Filtering and Updating");
    
    log_debug("\n\n\n");
    log_debug("\n\nNAT64 %s TEST module inserted!", "filtering_test");

    // Initialize the NAT configuration for the tests.
    if ( !config_init() )
		return -EINVAL;

    /*      UDP & ICMP      */
    CALL_TEST(test_transport_address_ipv4(), "test_transport_address_ipv4");
    CALL_TEST(test_transport_address_ipv6(), "test_transport_address_ipv6");
    CALL_TEST(test_extract_ipv4_from_ipv6(), "test_extract_ipv4_from_ipv6");
    CALL_TEST(test_embed_ipv4_in_ipv6(), "test_embed_ipv4_in_ipv6");
    CALL_TEST(test_allocate_ipv4_transport_address(), "test_allocate_ipv4_transport_address");
    CALL_TEST(test_allocate_ipv4_transport_address_digger(), "test_allocate_ipv4_transport_address_digger");
    INIT_CALL_END(init_full(), test_ipv6_udp(), end_full(), "test_ipv6_udp");
    INIT_CALL_END(init_full(), test_ipv4_udp(), end_full(), "test_ipv4_udp");
    INIT_CALL_END(init_full(), test_ipv6_icmp6(), end_full(), "test_ipv6_icmp6");
    INIT_CALL_END(init_full(), test_ipv4_icmp4(), end_full(), "test_ipv4_icmp4");
    //~ CALL_TEST(test_send_icmp_error_message(), "test_send_icmp_error_message"); // Not implemented yet!
    INIT_CALL_END(init_full(), test_filtering_and_updating(), end_full(), "test_filtering_and_updating");

    /*      TCP      */
    CALL_TEST(test_packet_is_ipv4(), "test_packet_is_ipv4");
    CALL_TEST(test_packet_is_ipv6(), "test_packet_is_ipv6");
    CALL_TEST(test_packet_is_v4_syn(), "test_packet_is_v4_syn");
    CALL_TEST(test_packet_is_v6_syn(), "test_packet_is_v6_syn");
    CALL_TEST(test_packet_is_v4_fin(), "test_packet_is_v4_fin");
    CALL_TEST(test_packet_is_v6_fin(), "test_packet_is_v6_fin");
    CALL_TEST(test_packet_is_v4_rst(), "test_packet_is_v4_rst");
    CALL_TEST(test_packet_is_v6_rst(), "test_packet_is_v6_rst");
    CALL_TEST(test_send_probe_packet(), "test_send_probe_packet");
    INIT_CALL_END(init_full(), test_tcp_closed_state_handle_6(), end_full(), "test_tcp_closed_state_handle_6");
    INIT_CALL_END(init_full(), test_tcp_closed_state_handle_4(), end_full(), "test_tcp_closed_state_handle_4");
    CALL_TEST(test_tcp_v4_init_state_handle(), "test_tcp_v4_init_state_handle");
    CALL_TEST(test_tcp_v6_init_state_handle(), "test_tcp_v6_init_state_handle");
    CALL_TEST(test_tcp_established_state_handle(), "test_tcp_established_state_handle");
    CALL_TEST(test_tcp_v4_fin_rcv_state_handle(), "test_tcp_v4_fin_rcv_state_handle");
    CALL_TEST(test_tcp_v6_fin_rcv_state_handle(), "test_tcp_v6_fin_rcv_state_handle");
    CALL_TEST(test_tcp_trans_state_handle(), "test_tcp_trans_state_handle");
    INIT_CALL_END(init_full(), test_tcp(), end_full(), "test_tcp");

	config_destroy();
    /* A non 0 return means a test failed; module can't be loaded. */
    END_TESTS;
}
Example #19
0
int init_module(void)
{
	START_TESTS("IPv4 Pool DB");

	/*
	 * TODO (test) This is missing a multiple-tables test.
	 * (it always does mark = 1.)
	 */

	INIT_CALL_END(init(), test_foreach_sample(), destroy(), "Sample for");
	INIT_CALL_END(init(), test_add(), destroy(), "Add");
	INIT_CALL_END(init(), test_rm(), destroy(), "Rm");
	INIT_CALL_END(init(), test_flush(), destroy(), "Flush");

	END_TESTS;
}
Example #20
0
int init_module(void)
{
    int i;
    START_TESTS("nf_nat64_rfc6052.c");

    // test the extract function.
    for (i = 0; i < 6; i++) {
        CALL_TEST(test_extract_ipv4(arr_ipv6[i], pref[i]), arr_ipv6[i]);
    }

    // Test the append function.
    for (i = 0; i < 6; i++) {
        CALL_TEST(test_append_ipv4(arr_ipv6[i], prefix[i], pref[i]), arr_ipv6[i]);
    }

    END_TESTS;
}
Example #21
0
int init_module(void)
{
	START_TESTS("IPv4 Pool");

	INIT_CALL_END(init(), test_get_match_function_udp(), destroy(), "Get match-UDP");
	INIT_CALL_END(init(), test_get_match_function_tcp(), destroy(), "Get match-TCP");
	INIT_CALL_END(init(), test_get_match_function_icmp(), destroy(), "Get match-ICMP");
	INIT_CALL_END(init(), test_get_any_port_function_udp(), destroy(), "Get any port-UDP");
	INIT_CALL_END(init(), test_get_any_port_function_tcp(), destroy(), "Get any port-TCP");
	INIT_CALL_END(init(), test_get_any_port_function_icmp(), destroy(), "Get any port-ICMP");
	INIT_CALL_END(init(), test_get_any_addr_function_udp(), destroy(), "Get any addr-UDP");
	INIT_CALL_END(init(), test_get_any_addr_function_tcp(), destroy(), "Get any addr-TCP");
	INIT_CALL_END(init(), test_get_any_addr_function_icmp(), destroy(), "Get any addr-ICMP");
	INIT_CALL_END(init(), test_return_function(), destroy(), "Return function");

	END_TESTS;
}
Example #22
0
int init_module(void)
{
	START_TESTS("Outgoing");

	if (!init())
		return -EINVAL;

	CALL_TEST(test_6to4(L4PROTO_UDP), "Tuple-5, 6 to 4, UDP");
	CALL_TEST(test_4to6(L4PROTO_UDP), "Tuple-5, 4 to 6, UDP");
	CALL_TEST(test_6to4(L4PROTO_TCP), "Tuple-5, 6 to 4, TCP");
	CALL_TEST(test_4to6(L4PROTO_TCP), "Tuple-5, 4 to 6, TCP");
	CALL_TEST(test_6to4(L4PROTO_ICMP), "Tuple-3, 6 to 4, ICMP");
	CALL_TEST(test_4to6(L4PROTO_ICMP), "Tuple-3, 4 to 6, ICMP");

	cleanup();

	END_TESTS;
}
Example #23
0
int init_module(void)
{
	START_TESTS("IPv6 header iterator");

	CALL_TEST(test_next_no_subheaders(), "next function, no subheaders");
	CALL_TEST(test_next_subheaders(), "next function, subheaders");
	CALL_TEST(test_next_unsupported(), "next function, unsupported hdrs");

	CALL_TEST(test_last_no_subheaders(), "last function, no subheaders");
	CALL_TEST(test_last_subheaders(), "last function, subheaders");
	CALL_TEST(test_last_unsupported(), "last function, unsupported hdrs");

	CALL_TEST(test_find_no_subheaders(), "find function, no subheaders");
	CALL_TEST(test_find_subheaders(), "find function, subheaders");
	CALL_TEST(test_find_unsupported(), "find function, unsupported hdrs");

	END_TESTS;
}
Example #24
0
int init_module(void)
{
	START_TESTS("Translating the Packet");

	if (is_error(translate_packet_init()))
		return -EINVAL;

	/* Misc single function tests */
	CALL_TEST(test_function_has_unexpired_src_route(), "Unexpired source route querier");
	CALL_TEST(test_function_build_id_field(), "Identification builder");
	CALL_TEST(test_function_icmp6_minimum_mtu(), "ICMP6 Minimum MTU function");
	CALL_TEST(test_function_icmp4_to_icmp6_param_prob(), "Param problem function");

	CALL_TEST(test_function_generate_ipv4_id_nofrag(), "Generate id function (no frag)");
	CALL_TEST(test_function_generate_df_flag(), "Generate DF flag function");
	CALL_TEST(test_function_build_protocol_field(), "Build protocol function");
	CALL_TEST(test_function_has_nonzero_segments_left(), "Segments left indicator function");
	CALL_TEST(test_function_generate_ipv4_id_dofrag(), "Generate id function (frag)");
	CALL_TEST(test_function_icmp4_minimum_mtu(), "ICMP4 Minimum MTU function");

	/* Full packet translation tests */
	CALL_TEST(test_4to6_udp(), "Full translation, 4->6 UDP");
	CALL_TEST(test_4to6_tcp(), "Full translation, 4->6 TCP");
	CALL_TEST(test_4to6_icmp_info(), "Full translation, 4->6 ICMP info");
	CALL_TEST(test_4to6_icmp_error(), "Full translation, 4->6 ICMP error");
	CALL_TEST(test_4to6frag_tcp(), "Full Fragments, 4->6 TCP");
	CALL_TEST(test_4to6frag_udp(), "Full Fragments, 4->6 UDP");
	CALL_TEST(test_4to6frag_icmp(), "Full Fragments, 4->6 ICMP");

	CALL_TEST(test_6to4_udp(), "Full translation, 6->4 UDP");
	CALL_TEST(test_6to4_tcp(), "Full translation, 6->4 TCP");
	CALL_TEST(test_6to4_icmp_info(), "Full translation, 6->4 ICMP info");
	CALL_TEST(test_6to4_icmp_error(), "Full translation, 6->4 ICMP error");
	CALL_TEST(test_6to4frag_tcp(), "Full Fragments, 6->4 TCP");
	CALL_TEST(test_6to4frag_udp(), "Full Fragments, 6->4 UDP");
	CALL_TEST(test_6to4frag_icmp(), "Full Fragments, 6->4 ICMP");

	/* TODO (test) still need to test zero IPv4-UDP checksums. I think that's all. */

	translate_packet_destroy();

	END_TESTS;
}
static int init_test_module(void)
{
	START_TESTS("Handling Hairpinning");

	if (!init())
		return -EINVAL;

	/*
	 * Well, the only thing not being tested here, I think, is hairpinning not getting in the way
	 * when there's no need for it.
	 * But that's handled in every other test, ever.
	 */

	CALL_TEST(test_hairpin(L4PROTO_UDP, create_skb6_udp), "UDP");
	CALL_TEST(test_hairpin(L4PROTO_TCP, create_skb6_tcp), "TCP");
	CALL_TEST(test_icmp(), "ICMP");

	deinit();

	END_TESTS;
}
Example #26
0
int init_module(void)
{
	START_TESTS("Packet");
	if (str_to_addr6("1::1", &dummies6[0]) != 0)
		return -EINVAL;
	if (str_to_addr6("2::2", &dummies6[1]) != 0)
		return -EINVAL;
	if (str_to_addr4("1.1.1.1", &dummies4[0]) != 0)
		return -EINVAL;
	if (str_to_addr4("2.2.2.2", &dummies4[1]) != 0)
		return -EINVAL;

	CALL_TEST(test_function_is_dont_fragment_set(), "Dont fragment getter");
	CALL_TEST(test_function_is_more_fragments_set(), "More fragments getter");
	CALL_TEST(test_function_build_ipv4_frag_off_field(), "Generate frag offset + flags function");

	CALL_TEST(test_inner_packet_validation4(), "Inner packet IPv4 Validation");
	CALL_TEST(test_inner_packet_validation6(), "Inner packet IPv6 Validation");

	END_TESTS;
}
Example #27
0
int init_module(void)
{
	START_TESTS("IPv6 header iterator");

	CALL_TEST(test_next_function_no_subheaders(), "next function, no subheaders");
	CALL_TEST(test_next_function_subheaders(), "next function, subheaders");
	CALL_TEST(test_next_function_unsupported(), "next function, unsupported headers");
	CALL_TEST(test_next_function_overflow(), "next function, corrupted packet");

	CALL_TEST(test_last_function_no_subheaders(), "last function, no subheaders");
	CALL_TEST(test_last_function_subheaders(), "last function, subheaders");
	CALL_TEST(test_last_function_unsupported(), "last function, unsupported headers");
	CALL_TEST(test_last_function_overflow(), "last function, corrupted packet");

	CALL_TEST(test_get_ext_function_no_subheaders(), "get ext function, no subheaders");
	CALL_TEST(test_get_ext_function_subheaders(), "get ext function, subheaders");
	CALL_TEST(test_get_ext_function_unsupported(), "get ext function, unsupported headers");
	CALL_TEST(test_get_ext_function_overflow(), "get ext function, corrupted packet");

	END_TESTS;
}
Example #28
0
int init_module(void)
{
	int i;
	START_TESTS("rfc6052.c");

	if (!init())
		return -EINVAL;

	// test the extract function.
	for (i = 0; i < 6; i++) {
		CALL_TEST(test_addr_6to4(&ipv6_addr[i], &prefixes[i], &ipv4_addr), "Extract-%pI6c",
				&ipv6_addr[i]);
	}

	// Test the append function.
	for (i = 0; i < 6; i++) {
		CALL_TEST(test_addr_4to6(&ipv4_addr, &prefixes[i], &ipv6_addr[i]), "Append-%pI6c",
				&ipv6_addr[i]);
	}

	END_TESTS;
}
Example #29
0
int init_module(void)
{
	START_TESTS("Translating the Packet");

	if (config_init(&config))
		return false;

	/* Misc single function tests */
	CALL_TEST(test_function_has_unexpired_src_route(), "Unexpired source route querier");
	CALL_TEST(test_function_build_id_field(), "Identification builder");
	CALL_TEST(test_function_icmp6_minimum_mtu(), "ICMP6 Minimum MTU function");
	CALL_TEST(test_function_icmp4_to_icmp6_param_prob(), "Param problem function");

	CALL_TEST(test_function_generate_ipv4_id(), "Generate id function");
	CALL_TEST(test_function_generate_df_flag(), "Generate DF flag function");
	CALL_TEST(test_function_build_protocol_field(), "Build protocol function");
	CALL_TEST(test_function_has_nonzero_segments_left(), "Segments left indicator function");
	CALL_TEST(test_function_icmp4_minimum_mtu(), "ICMP4 Minimum MTU function");

	config_put(config);

	END_TESTS;
}