1 /*
2  * FreeRTOS+TCP V3.1.0
3  * Copyright (C) 2022 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * http://aws.amazon.com/freertos
25  * http://www.FreeRTOS.org
26  */
27 
28 /*
29  * dump_packets.c
30  * Used in the PC/Win project to dump Ethernet packets, along with some description.
31  */
32 
33 #ifndef DUMP_PACKETS_H
34 
35 
36 #define DUMP_PACKETS_H
37 
38 #ifndef dumpMAX_DUMP_ENTRIES
39     #define dumpMAX_DUMP_ENTRIES    16
40 #endif
41 
42 #define flag_ICMP4                  0x00000001UL
43 #define flag_ICMP6                  0x00000002UL
44 #define flag_UDP                    0x00000004UL
45 #define flag_TCP                    0x00000008UL
46 #define flag_DNS                    0x00000010UL
47 #define flag_REPLY                  0x00000020UL
48 #define flag_REQUEST                0x00000040UL
49 #define flag_SYN                    0x00000080UL
50 #define flag_FIN                    0x00000100UL
51 #define flag_RST                    0x00000200UL
52 #define flag_ACK                    0x00000400UL
53 #define flag_IN                     0x00000800UL
54 #define flag_OUT                    0x00001000UL
55 #define flag_FRAME_ARP              0x00002000UL
56 #define flag_ARP                    0x00004000UL
57 #define flag_UNKNOWN                0x00008000UL
58 #define flag_FRAME_4                0x00010000UL
59 #define flag_FRAME_6                0x00020000UL
60 #define flag_Unknown_FRAME          0x00040000UL
61 
62 /**
63  * Structure to hold information about one dump entry.
64  */
65 typedef struct xDumpEntry
66 {
67     uint32_t ulMask; /**< The mask of the entry */
68     size_t uxMax;    /**< The max value of the entry */
69     size_t uxCount;  /**< The count of the entry */
70 } DumpEntry_t;
71 
72 /**
73  * Structure to hold information of all the entries in this data dump.
74  */
75 typedef struct xDumpEntries
76 {
77     size_t uxEntryCount;                          /**< The number of entries*/
78     DumpEntry_t xEntries[ dumpMAX_DUMP_ENTRIES ]; /**< Array of struct for all the entries */
79 } DumpEntries_t;
80 
81 /*
82  *
83  */
84 
85 #if ( ipconfigUSE_DUMP_PACKETS != 0 )
86 
87     extern void dump_packet_init( const char * pcFileName,
88                                   DumpEntries_t * pxEntries );
89     #define iptraceDUMP_INIT( pcFileName, pxEntries ) \
90     dump_packet_init( pcFileName, pxEntries )
91 
92     extern void dump_packet( const uint8_t * pucBuffer,
93                              size_t uxLength,
94                              BaseType_t xIncoming );
95     #define iptraceDUMP_PACKET( pucBuffer, uxLength, xIncoming ) \
96     dump_packet( pucBuffer, uxLength, xIncoming )
97 
98 #endif /* if ( ipconfigUSE_DUMP_PACKETS != 0 ) */
99 
100 #endif /* ifndef DUMP_PACKETS_H */
101