bool test_ipv4_icmp4( void ) { u_int8_t protocol; struct tuple tuple; struct sk_buff* skb = NULL; bool success = true; protocol = IPPROTO_ICMP; success &= init_tuple_for_test_ipv4( &tuple , protocol ); skb = init_skb_for_test( &tuple, protocol ); success &= assert_not_null(skb, "init_skb_for_test"); success &= assert_equals_int(NF_DROP, ipv4_icmp4( skb, &tuple ), "See if we discard an IPv4 ICMP packet, which tries to start a communication."); kfree_skb(skb); protocol = IPPROTO_ICMP; success &= init_tuple_for_test_ipv6( &tuple , protocol ); skb = init_skb_for_test( &tuple, protocol ); success &= assert_not_null(skb, "init_skb_for_test"); success &= assert_equals_int(NF_ACCEPT, ipv6_icmp6(skb, &tuple ), "See if we can process correctly an IPv6 ICMP packet."); kfree_skb(skb); protocol = IPPROTO_ICMP; success &= init_tuple_for_test_ipv4( &tuple , protocol ); skb = init_skb_for_test( &tuple, protocol ); success &= assert_not_null(skb, "init_skb_for_test"); success &= assert_equals_int(NF_ACCEPT, ipv4_icmp4( skb, &tuple ), "See if we can process correctly an expected IPv4 ICMP packet."); kfree_skb(skb); return success; }
bool test_ipv6_icmp6( void ) { u_int8_t protocol = IPPROTO_ICMP; struct tuple tuple; struct sk_buff *skb; bool success = true; success &= init_tuple_for_test_ipv6( &tuple , protocol ); skb = init_skb_for_test( &tuple, protocol ); success &= assert_not_null(skb, "init_skb_for_test"); if (!success) return false; success &= assert_equals_int(NF_ACCEPT, ipv6_icmp6(skb, &tuple), "See if we can process correctly an IPv6 ICMP packet."); kfree_skb(skb); return success; }