316 lines
20 KiB
C++
316 lines
20 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "packet_internal.h"
|
|
#include "packet_parser.h"
|
|
|
|
/******************************************************************************
|
|
* [Protocols in frame: eth:ethertype:ip:data]
|
|
******************************************************************************
|
|
*
|
|
* Frame 4: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
|
|
* Ethernet II, Src: Fortinet_cc:87:22 (e8:1c:ba:cc:87:22), Dst: EvocInte_2f:35:b8 (00:22:46:2f:35:b8)
|
|
* Destination: EvocInte_2f:35:b8 (00:22:46:2f:35:b8)
|
|
* Source: Fortinet_cc:87:22 (e8:1c:ba:cc:87:22)
|
|
* Type: IPv4 (0x0800)
|
|
* Padding: 0000
|
|
* Internet Protocol Version 4, Src: 192.168.36.103, Dst: 192.168.40.137
|
|
* 0100 .... = Version: 4
|
|
* .... 0101 = Header Length: 20 bytes (5)
|
|
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
|
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
|
* Total Length: 44
|
|
* Identification: 0xffff (65535)
|
|
* 001. .... = Flags: 0x1, More fragments
|
|
* 0... .... = Reserved bit: Not set
|
|
* .0.. .... = Don't fragment: Not set
|
|
* ..1. .... = More fragments: Set
|
|
* ...0 0000 0000 0000 = Fragment Offset: 0
|
|
* Time to Live: 127
|
|
* Protocol: TCP (6)
|
|
* Header Checksum: 0x4d8b [correct]
|
|
* [Header checksum status: Good]
|
|
* [Calculated Checksum: 0x4d8b]
|
|
* Source Address: 192.168.36.103
|
|
* Destination Address: 192.168.40.137
|
|
* [Reassembled IPv4 in frame: 5]
|
|
* Data (24 bytes)
|
|
* Data: f4a5270f9107248703d518e75018ff005e9200003132330a
|
|
* [Length: 24]
|
|
*/
|
|
|
|
unsigned char data1[] = {
|
|
0x00, 0x22, 0x46, 0x2f, 0x35, 0xb8, 0xe8, 0x1c, 0xba, 0xcc, 0x87, 0x22, 0x08, 0x00, 0x45, 0x00, 0x00, 0x2c, 0xff, 0xff, 0x20, 0x00, 0x7f, 0x06, 0x4d, 0x8b,
|
|
0xc0, 0xa8, 0x24, 0x67, 0xc0, 0xa8, 0x28, 0x89, 0xf4, 0xa5, 0x27, 0x0f, 0x91, 0x07, 0x24, 0x87, 0x03, 0xd5, 0x18, 0xe7, 0x50, 0x18, 0xff, 0x00, 0x5e, 0x92,
|
|
0x00, 0x00, 0x31, 0x32, 0x33, 0x0a, 0x00, 0x00};
|
|
|
|
#if 1
|
|
TEST(PACKET_FRAG, IPV4_FRAGMENT)
|
|
{
|
|
struct packet handler;
|
|
memset(&handler, 0, sizeof(handler));
|
|
packet_parse(&handler, (const char *)data1, sizeof(data1));
|
|
EXPECT_TRUE(packet_is_fragment(&handler) == true);
|
|
|
|
struct packet *dup = packet_dup(&handler);
|
|
EXPECT_TRUE(dup != NULL);
|
|
EXPECT_TRUE(packet_is_fragment(dup) == true);
|
|
packet_free(dup);
|
|
}
|
|
#endif
|
|
|
|
/******************************************************************************
|
|
* [Protocols in frame: eth:ethertype:ipv6:ipv6.fraghdr:data]
|
|
******************************************************************************
|
|
*
|
|
* Frame 5: 1510 bytes on wire (12080 bits), 1510 bytes captured (12080 bits)
|
|
* Ethernet II, Src: Apple_c0:61:b6 (68:5b:35:c0:61:b6), Dst: Dell_94:65:38 (00:1d:09:94:65:38)
|
|
* Destination: Dell_94:65:38 (00:1d:09:94:65:38)
|
|
* Source: Apple_c0:61:b6 (68:5b:35:c0:61:b6)
|
|
* Type: IPv6 (0x86dd)
|
|
* Internet Protocol Version 6, Src: 2607:f010:3f9::1001, Dst: 2607:f010:3f9::11:0
|
|
* 0110 .... = Version: 6
|
|
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
|
|
* .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
|
* .... 0010 0001 0010 1000 1001 = Flow Label: 0x21289
|
|
* Payload Length: 1456
|
|
* Next Header: Fragment Header for IPv6 (44)
|
|
* Hop Limit: 64
|
|
* Source Address: 2607:f010:3f9::1001
|
|
* Destination Address: 2607:f010:3f9::11:0
|
|
* Fragment Header for IPv6
|
|
* Next header: UDP (17)
|
|
* Reserved octet: 0x00
|
|
* 0000 1011 0101 0... = Offset: 362 (2896 bytes)
|
|
* .... .... .... .00. = Reserved bits: 0
|
|
* .... .... .... ...1 = More Fragments: Yes
|
|
* Identification: 0xf88eb466
|
|
* [Reassembled IPv6 in frame: 6]
|
|
* Data (1448 bytes)
|
|
* Data: 686868686868686868686868686868686868686868686868686868686868686868686868…
|
|
* [Length: 1448]
|
|
*/
|
|
|
|
unsigned char data2[] = {
|
|
0x00, 0x1d, 0x09, 0x94, 0x65, 0x38, 0x68, 0x5b, 0x35, 0xc0, 0x61, 0xb6, 0x86, 0xdd, 0x60, 0x02, 0x12, 0x89, 0x05, 0xb0, 0x2c, 0x40, 0x26, 0x07, 0xf0, 0x10,
|
|
0x03, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x26, 0x07, 0xf0, 0x10, 0x03, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
|
|
0x00, 0x00, 0x11, 0x00, 0x0b, 0x51, 0xf8, 0x8e, 0xb4, 0x66, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
|
0x68, 0x68};
|
|
|
|
#if 1
|
|
TEST(PACKET_FRAG, IPV6_FRAGMENT)
|
|
{
|
|
struct packet handler;
|
|
memset(&handler, 0, sizeof(handler));
|
|
packet_parse(&handler, (const char *)data2, sizeof(data2));
|
|
EXPECT_TRUE(packet_is_fragment(&handler) == true);
|
|
|
|
struct packet *dup = packet_dup(&handler);
|
|
EXPECT_TRUE(dup != NULL);
|
|
EXPECT_TRUE(packet_is_fragment(dup) == true);
|
|
packet_free(dup);
|
|
}
|
|
#endif
|
|
|
|
/******************************************************************************
|
|
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
|
******************************************************************************
|
|
*
|
|
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
|
* Ethernet II, Src: JuniperN_45:88:29 (2c:6b:f5:45:88:29), Dst: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
|
* Destination: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
|
* Source: JuniperN_45:88:29 (2c:6b:f5:45:88:29)
|
|
* Type: IPv4 (0x0800)
|
|
* Internet Protocol Version 4, Src: 210.77.88.163, Dst: 59.66.4.50
|
|
* 0100 .... = Version: 4
|
|
* .... 0101 = Header Length: 20 bytes (5)
|
|
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* Total Length: 92
|
|
* Identification: 0x0b4d (2893)
|
|
* 000. .... = Flags: 0x0
|
|
* ...0 0000 0000 0000 = Fragment Offset: 0
|
|
* Time to Live: 59
|
|
* Protocol: IPv6 (41)
|
|
* Header Checksum: 0x09c8 [validation disabled]
|
|
* [Header checksum status: Unverified]
|
|
* Source Address: 210.77.88.163
|
|
* Destination Address: 59.66.4.50
|
|
* Internet Protocol Version 6, Src: 2001:da8:200:900e:200:5efe:d24d:58a3, Dst: 2600:140e:6::1702:1058
|
|
* 0110 .... = Version: 6
|
|
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
|
* Payload Length: 32
|
|
* Next Header: TCP (6)
|
|
* Hop Limit: 64
|
|
* Source Address: 2001:da8:200:900e:200:5efe:d24d:58a3
|
|
* Destination Address: 2600:140e:6::1702:1058
|
|
* [Source ISATAP IPv4: 210.77.88.163]
|
|
* Transmission Control Protocol, Src Port: 52556, Dst Port: 80, Seq: 0, Len: 0
|
|
* Source Port: 52556
|
|
* Destination Port: 80
|
|
* [Stream index: 0]
|
|
* [Conversation completeness: Complete, WITH_DATA (31)]
|
|
* [TCP Segment Len: 0]
|
|
* Sequence Number: 0 (relative sequence number)
|
|
* Sequence Number (raw): 2172673142
|
|
* [Next Sequence Number: 1 (relative sequence number)]
|
|
* Acknowledgment Number: 0
|
|
* Acknowledgment number (raw): 0
|
|
* 1000 .... = Header Length: 32 bytes (8)
|
|
* Flags: 0x002 (SYN)
|
|
* Window: 8192
|
|
* [Calculated window size: 8192]
|
|
* Checksum: 0xf757 [unverified]
|
|
* [Checksum Status: Unverified]
|
|
* Urgent Pointer: 0
|
|
* Options: (12 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), SACK permitted
|
|
* [Timestamps]
|
|
*/
|
|
|
|
unsigned char data3[] = {
|
|
0x5c, 0x5e, 0xab, 0x2a, 0xa2, 0x00, 0x2c, 0x6b, 0xf5, 0x45, 0x88, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x5c, 0x0b, 0x4d, 0x00, 0x00, 0x3b, 0x29, 0x09, 0xc8,
|
|
0xd2, 0x4d, 0x58, 0xa3, 0x3b, 0x42, 0x04, 0x32, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40, 0x20, 0x01, 0x0d, 0xa8, 0x02, 0x00, 0x90, 0x0e, 0x02, 0x00,
|
|
0x5e, 0xfe, 0xd2, 0x4d, 0x58, 0xa3, 0x26, 0x00, 0x14, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x02, 0x10, 0x58, 0xcd, 0x4c, 0x00, 0x50,
|
|
0x81, 0x80, 0x5c, 0x76, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, 0x00, 0xf7, 0x57, 0x00, 0x00, 0x02, 0x04, 0x04, 0xc4, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
|
|
0x04, 0x02};
|
|
|
|
#if 1
|
|
TEST(PACKET_FRAG, IPV4_IPV6_NOT_FRAGMENT)
|
|
{
|
|
struct packet handler;
|
|
memset(&handler, 0, sizeof(handler));
|
|
packet_parse(&handler, (const char *)data3, sizeof(data3));
|
|
EXPECT_TRUE(packet_is_fragment(&handler) == false);
|
|
|
|
struct packet *dup = packet_dup(&handler);
|
|
EXPECT_TRUE(dup != NULL);
|
|
EXPECT_TRUE(packet_is_fragment(dup) == false);
|
|
packet_free(dup);
|
|
}
|
|
#endif
|
|
|
|
/******************************************************************************
|
|
* [Protocols in frame: eth:ethertype:ipv6:ipv6:udp:data]
|
|
******************************************************************************
|
|
*
|
|
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
|
* Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
|
|
* Destination: Broadcast (ff:ff:ff:ff:ff:ff)
|
|
* Source: 00:00:00_00:00:00 (00:00:00:00:00:00)
|
|
* Type: IPv6 (0x86dd)
|
|
* Internet Protocol Version 6, Src: 2001:4f8:4:7:2e0:81ff:fe52:ffff, Dst: 2001:4f8:4:7:2e0:81ff:fe52:9a6b
|
|
* 0110 .... = Version: 6
|
|
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
|
* Payload Length: 52
|
|
* Next Header: IPv6 (41)
|
|
* Hop Limit: 64
|
|
* Source Address: 2001:4f8:4:7:2e0:81ff:fe52:ffff
|
|
* Destination Address: 2001:4f8:4:7:2e0:81ff:fe52:9a6b
|
|
* [Source SLAAC MAC: TyanComp_52:ff:ff (00:e0:81:52:ff:ff)]
|
|
* [Destination SLAAC MAC: TyanComp_52:9a:6b (00:e0:81:52:9a:6b)]
|
|
* Internet Protocol Version 6, Src: dead::beef, Dst: cafe::babe
|
|
* 0110 .... = Version: 6
|
|
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
|
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
|
* Payload Length: 12
|
|
* Next Header: UDP (17)
|
|
* Hop Limit: 64
|
|
* Source Address: dead::beef
|
|
* Destination Address: cafe::babe
|
|
* User Datagram Protocol, Src Port: 30000, Dst Port: 13000
|
|
* Source Port: 30000
|
|
* Destination Port: 13000
|
|
* Length: 12
|
|
* Checksum: 0x83d2 [unverified]
|
|
* [Checksum Status: Unverified]
|
|
* [Stream index: 0]
|
|
* [Timestamps]
|
|
* UDP payload (4 bytes)
|
|
* Data (4 bytes)
|
|
*/
|
|
|
|
unsigned char data4[] = {
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x34, 0x29, 0x40, 0x20, 0x01, 0x04, 0xf8,
|
|
0x00, 0x04, 0x00, 0x07, 0x02, 0xe0, 0x81, 0xff, 0xfe, 0x52, 0xff, 0xff, 0x20, 0x01, 0x04, 0xf8, 0x00, 0x04, 0x00, 0x07, 0x02, 0xe0, 0x81, 0xff, 0xfe, 0x52,
|
|
0x9a, 0x6b, 0x60, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x11, 0x40, 0xde, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0xef,
|
|
0xca, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0xbe, 0x75, 0x30, 0x32, 0xc8, 0x00, 0x0c, 0x83, 0xd2, 0x58, 0x58,
|
|
0x58, 0x58};
|
|
|
|
#if 1
|
|
TEST(PACKET_FRAG, IPV6_IPV6_NOT_FRAGMENT)
|
|
{
|
|
struct packet handler;
|
|
memset(&handler, 0, sizeof(handler));
|
|
packet_parse(&handler, (const char *)data4, sizeof(data4));
|
|
EXPECT_TRUE(packet_is_fragment(&handler) == false);
|
|
|
|
struct packet *dup = packet_dup(&handler);
|
|
EXPECT_TRUE(dup != NULL);
|
|
EXPECT_TRUE(packet_is_fragment(dup) == false);
|
|
packet_free(dup);
|
|
}
|
|
#endif
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|