unittests/lib/packet_parser_test.c in trema-0.2.5 vs unittests/lib/packet_parser_test.c in trema-0.2.6
- old
+ new
@@ -16,17 +16,16 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <pcap.h>
-#include <netinet/ip.h>
#include <netinet/igmp.h>
+#include <netinet/ip.h>
+#include <pcap.h>
+#include <stdio.h>
+#include <string.h>
#include "checks.h"
#include "cmockery_trema.h"
#include "packet_info.h"
#include "wrapper.h"
@@ -101,11 +100,11 @@
u_char oui[] = { 0xff, 0xff, 0x00 };
assert_memory_equal( packet_info->snap_llc, llc, SNAP_LLC_LENGTH );
assert_memory_equal( packet_info->snap_oui, oui, SNAP_OUI_LENGTH );
assert_int_equal( packet_info->snap_type, 0xb700 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l2_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l2_payload );
assert_int_equal( sample, 0x0400 );
assert_int_equal( packet_info->l2_payload_length, 0xb2 );
free_buffer( buffer );
@@ -211,11 +210,11 @@
assert_int_equal( packet_info->udp_src_port, 61616 );
assert_int_equal( packet_info->udp_dst_port, 23499 );
assert_int_equal( packet_info->udp_len, 0x38 );
assert_int_equal( packet_info->udp_checksum, 0x04a1 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0xf937 );
assert_int_equal( packet_info->l4_payload_length, 48 );
free_buffer( buffer );
@@ -258,11 +257,11 @@
assert_int_equal( packet_info->udp_src_port, 0xa2c7 );
assert_int_equal( packet_info->udp_dst_port, 0x1f90 );
assert_int_equal( packet_info->udp_len, 0x2330 );
assert_int_equal( packet_info->udp_checksum, 0x8749 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0x8020 );
assert_int_equal( packet_info->l4_payload_length, 1472 );
free_buffer( buffer );
@@ -298,11 +297,11 @@
assert_int_equal( packet_info->ipv4_protocol, IPPROTO_UDP );
assert_int_equal( packet_info->ipv4_checksum, 0xdf7c );
assert_int_equal( packet_info->ipv4_saddr, 0xc0a8642c );
assert_int_equal( packet_info->ipv4_daddr, 0xc0a8642b );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l3_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l3_payload );
assert_int_equal( sample, 0x9102 );
assert_int_equal( packet_info->l3_payload_length, 1480 );
// L4 parsing phase is skipped for fragmented packets.
@@ -409,11 +408,11 @@
assert_int_equal( packet_info->tcp_flags, 0x18 );
assert_int_equal( packet_info->tcp_window, 0x2086 );
assert_int_equal( packet_info->tcp_checksum, 0x4c2d );
assert_int_equal( packet_info->tcp_urgent, 0 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0x4854 );
assert_int_equal( packet_info->l4_payload_length, 30 );
free_buffer( buffer );
@@ -456,11 +455,11 @@
assert_int_equal( packet_info->icmpv4_type, ICMP_TYPE_ECHOREQ );
assert_int_equal( packet_info->icmpv4_code, 0 );
assert_int_equal( packet_info->icmpv4_id, 1076 );
assert_int_equal( packet_info->icmpv4_seq, 1 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0xa0a9 );
assert_int_equal( packet_info->l4_payload_length, 56 );
assert_true( packet_type_icmpv4_echo_request( buffer ) );
@@ -515,11 +514,11 @@
assert_int_equal( packet_info->icmpv4_type, ICMP_TYPE_ECHOREQ );
assert_int_equal( packet_info->icmpv4_code, 0 );
assert_int_equal( packet_info->icmpv4_id, 1024 );
assert_int_equal( packet_info->icmpv4_seq, 24576 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0x6162 );
assert_int_equal( packet_info->l4_payload_length, 32 );
assert_true( packet_type_icmpv4_echo_request( buffer ) );
assert_false( packet_type_icmpv4_dst_unreach( buffer ) );
@@ -573,11 +572,11 @@
assert_int_equal( packet_info->icmpv4_type, ICMP_TYPE_ECHOREP );
assert_int_equal( packet_info->icmpv4_code, 0 );
assert_int_equal( packet_info->icmpv4_id, 1024 );
assert_int_equal( packet_info->icmpv4_seq, 24576 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0x6162 );
assert_int_equal( packet_info->l4_payload_length, 32 );
assert_false( packet_type_icmpv4_echo_request( buffer ) );
assert_false( packet_type_icmpv4_dst_unreach( buffer ) );
@@ -631,11 +630,11 @@
u_char macda[] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e };
u_char macsa[] = { 0xba, 0x22, 0xd3, 0x75, 0x8f, 0x7c };
assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l3_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l3_payload );
assert_int_equal( sample, 0x0205 );
assert_int_equal( packet_info->l3_payload_length, 46 );
free_buffer( buffer );
}
@@ -668,11 +667,11 @@
assert_int_equal( packet_info->ipv4_protocol, 97 );
assert_int_equal( packet_info->ipv4_checksum, 0 );
assert_int_equal( packet_info->ipv4_saddr, 0x0a2a7aca );
assert_int_equal( packet_info->ipv4_daddr, 0x0a2a7ad4 );
- uint16_t sample = ntohs( * ( uint16_t * ) packet_info->l4_payload );
+ uint16_t sample = ntohs( *( uint16_t * ) packet_info->l4_payload );
assert_int_equal( sample, 0x0180 );
assert_int_equal( packet_info->l4_payload_length, 31 );
assert_int_equal( packet_info->etherip_version, ETHERIP_VERSION );
assert_int_equal( packet_info->etherip_offset, 36 );
@@ -693,10 +692,10 @@
u_char lldp_macsa[] = { 0xfe, 0xab, 0x7e, 0x15, 0x3f, 0xc6 };
assert_memory_equal( packet_info->eth_macda, lldp_macda, ETH_ADDRLEN );
assert_memory_equal( packet_info->eth_macsa, lldp_macsa, ETH_ADDRLEN );
- sample = ntohs( * ( uint16_t * ) packet_info->l3_payload );
+ sample = ntohs( *( uint16_t * ) packet_info->l3_payload );
assert_int_equal( sample, 0x0205 );
assert_int_equal( packet_info->l3_payload_length, 17 );
free_buffer( copy );