Debian Codegraph @

src/basic/pcapng.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "basic-forward.h"
5
6 /*
7 * For details about the file format see RFC:
8 * https://www.ietf.org/id/draft-tuexen-opsawg-pcapng-03.html
9 * and
10 * https://github.com/pcapng/pcapng/
11 */
12 enum pcapng_block_types {
13 PCAPNG_INTERFACE_BLOCK = 1,
14 PCAPNG_PACKET_BLOCK, /* Obsolete */
15 PCAPNG_SIMPLE_PACKET_BLOCK,
16 PCAPNG_NAME_RESOLUTION_BLOCK,
17 PCAPNG_INTERFACE_STATS_BLOCK,
18 PCAPNG_ENHANCED_PACKET_BLOCK,
19
20 PCAPNG_SECTION_BLOCK = 0x0A0D0D0A,
21 };
22
23 struct pcapng_option {
24 uint16_t code;
25 uint16_t length;
26 uint8_t data[];
27 };
28
29 #define PCAPNG_BYTE_ORDER_MAGIC 0x1A2B3C4D
30 #define PCAPNG_MAJOR_VERS 1
31 #define PCAPNG_MINOR_VERS 0
32
33 enum pcapng_opt {
34 PCAPNG_OPT_END = 0,
35 PCAPNG_OPT_COMMENT = 1,
36 };
37
38 struct pcapng_section {
39 uint32_t block_type;
40 uint32_t block_length;
41 uint32_t byte_order_magic;
42 uint16_t major_version;
43 uint16_t minor_version;
44 uint64_t section_length;
45 };
46
47 enum pcapng_section_opt {
48 PCAPNG_SHB_HARDWARE = 2,
49 PCAPNG_SHB_OS = 3,
50 PCAPNG_SHB_USERAPPL = 4,
51 };
52
53 struct pcapng_interface_block {
54 uint32_t block_type; /* 1 */
55 uint32_t block_length;
56 uint16_t link_type;
57 uint16_t reserved;
58 uint32_t snap_len;
59 };
60
61 enum pcapng_interface_options {
62 PCAPNG_IFB_NAME = 2,
63 PCAPNG_IFB_DESCRIPTION,
64 PCAPNG_IFB_IPV4ADDR,
65 PCAPNG_IFB_IPV6ADDR,
66 PCAPNG_IFB_MACADDR,
67 PCAPNG_IFB_EUIADDR,
68 PCAPNG_IFB_SPEED,
69 PCAPNG_IFB_TSRESOL,
70 PCAPNG_IFB_TZONE,
71 PCAPNG_IFB_FILTER,
72 PCAPNG_IFB_OS,
73 PCAPNG_IFB_FCSLEN,
74 PCAPNG_IFB_TSOFFSET,
75 PCAPNG_IFB_HARDWARE,
76 };
77
78 struct pcapng_enhance_packet_block {
79 uint32_t block_type; /* 6 */
80 uint32_t block_length;
81 uint32_t interface_id;
82 uint32_t timestamp_hi;
83 uint32_t timestamp_lo;
84 uint32_t capture_length;
85 uint32_t original_length;
86 };
87
88 /* Flags values */
89 #define PCAPNG_IFB_INBOUND 0b01
90 #define PCAPNG_IFB_OUTBOUND 0b10
91
92 enum pcapng_epb_options {
93 PCAPNG_EPB_FLAGS = 2,
94 PCAPNG_EPB_HASH,
95 PCAPNG_EPB_DROPCOUNT,
96 PCAPNG_EPB_PACKETID,
97 PCAPNG_EPB_QUEUE,
98 PCAPNG_EPB_VERDICT,
99 };
100
101 struct pcapng_statistics_block {
102 uint32_t block_type; /* 5 */
103 uint32_t block_length;
104 uint32_t interface_id;
105 uint32_t timestamp_hi;
106 uint32_t timestamp_lo;
107 };
108
109 enum pcapng_isb_options {
110 PCAPNG_ISB_STARTTIME = 2,
111 PCAPNG_ISB_ENDTIME,
112 PCAPNG_ISB_IFRECV,
113 PCAPNG_ISB_IFDROP,
114 PCAPNG_ISB_FILTERACCEPT,
115 PCAPNG_ISB_OSDROP,
116 PCAPNG_ISB_USRDELIV,
117 };