/* * Copyright (c) 2021 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef NETWORK_TRAFFIC_PACKETS_H #define NETWORK_TRAFFIC_PACKETS_H #include #include struct Packet{ size_t size; size_t preL2Size; size_t l2Size; size_t l3Size; size_t payloadSize; uint8_t* packet; uint8_t* payload() const { return packet + preL2Size + l2Size + l3Size; } uint8_t* l2Packet() const { return packet + preL2Size; } size_t l2PacketSize() const { return size - preL2Size; } uint8_t* l3Packet() const { return packet + preL2Size + l2Size; } size_t l3PacketSize() const { return size - preL2Size - l2Size; } }; constexpr size_t qmapIpv4TcpPacketArrSize = 139; uint8_t qmapIpv4TcpPacketArr[qmapIpv4TcpPacketArrSize] = { 0x40, 0x00, 0x00, 0x83, 0x06, 0x80, 0x00, 0x20, 0x45, 0x00, 0x00, 0x83, 0xf5, 0x7a, 0x40, 0x00, 0x40, 0x06, 0xc1, 0x70, 0xc0, 0xa8, 0x01, 0x11, 0xc0, 0xa8, 0x01, 0x28, 0xdd, 0xd5, 0xfd, 0x76, 0x40, 0x35, 0xff, 0xc7, 0xb8, 0x35, 0xf0, 0xad, 0x50, 0x18, 0x01, 0xd9, 0x40, 0xa0, 0x00, 0x00, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x33, 0x30, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0d, 0x0a, 0x0d, 0x0a }; constexpr size_t ipv4UdpPacketArrSize = 46; uint8_t ipv4UdpPacketArr[ipv4UdpPacketArrSize] = { 0x45, 0x00, 0x00, 0x25, 0xd7, 0xa9, 0x00, 0x00, 0x72, 0x11, 0xeb, 0x8f, 0x0a, 0x3f, 0x8d, 0xc4, 0xac, 0x10, 0x41, 0x7b, 0x0d, 0x3d, 0xe8, 0x19, 0x00, 0x11, 0x88, 0xd7, 0x00, 0x04, 0xc0, 0x1a, 0x3b, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; constexpr size_t udpPacketArrSize = 80; uint8_t udpPacketArr[udpPacketArrSize] = { 0x07, 0xc1, 0x07, 0xc1, 0x00, 0x50, 0x39, 0x1a, 0x01, 0x28, 0x02, 0x00, 0x05, 0x04, 0x00, 0x03, 0xa0, 0xe0, 0xaf, 0x89, 0xb7, 0x3f, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x0b, 0xb8, 0xac, 0x10, 0x41, 0x01, 0x61, 0x6e, 0x2d, 0x72, 0x74, 0x2d, 0x30, 0x32, 0x2e, 0x71, 0x75, 0x61, 0x04, 0x1c, 0x01, 0x00, 0x00, 0x00, 0xac, 0x10, 0x41, 0x02, 0x00, 0x00, 0x00, 0x01, 0x74, 0x18, 0x26, 0xc7, 0xa5, 0x29, 0x24, 0xa1, 0xcc, 0x77, 0x76, 0xdc, 0x6f, 0x52, 0xfb, 0xbf }; constexpr size_t ipv6UdpPacketArrSize = 64; uint8_t ipv6UdpPacketArr[ipv6UdpPacketArrSize] = { 0x60, 0x05, 0xc1, 0xfd, 0x00, 0x18, 0x11, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x51, 0xfb, 0xff, 0xfe, 0x41, 0xf5, 0xbd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0xa4, 0x21, 0xa4, 0x00, 0x18, 0xb2, 0x04, 0x42, 0x4a, 0x4e, 0x50, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Packet QmapIpv4TcpPacket{ .size=qmapIpv4TcpPacketArrSize, .preL2Size=8, .l2Size=20, .l3Size=20, .payloadSize=91, .packet=qmapIpv4TcpPacketArr }; Packet ipv4UdpPacket{ .size=ipv4UdpPacketArrSize, .preL2Size=0, .l2Size=20, .l3Size=8, .payloadSize=18, .packet=ipv4UdpPacketArr }; Packet udpPacket{ .size=udpPacketArrSize, .preL2Size=0, .l2Size=0, .l3Size=8, .payloadSize=72, .packet=udpPacketArr }; Packet ipv6UdpPacket{ .size=ipv6UdpPacketArrSize, .preL2Size=0, .l2Size=40, .l3Size=8, .payloadSize=16, .packet=ipv6UdpPacketArr }; #endif //NETWORK_TRAFFIC_PACKETS_H