Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
wtap.h
Go to the documentation of this file.
1
9#ifndef __WTAP_H__
10#define __WTAP_H__
11
12#include <wireshark.h>
13#include <time.h>
14#include <wsutil/buffer.h>
15#include <wsutil/nstime.h>
16#include <wsutil/inet_addr.h>
17#include "wtap_opttypes.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
23/* Encapsulation types. Choose names that truly reflect
24 * what is contained in the packet trace file.
25 *
26 * WTAP_ENCAP_PER_PACKET is a value passed to "wtap_dump_open()" or
27 * "wtap_dump_fdopen()" to indicate that there is no single encapsulation
28 * type for all packets in the file; this may cause those routines to
29 * fail if the capture file format being written can't support that.
30 * It's also returned by "wtap_file_encap()" for capture files that
31 * don't have a single encapsulation type for all packets in the file.
32 *
33 * WTAP_ENCAP_UNKNOWN is returned by "wtap_pcap_encap_to_wtap_encap()"
34 * if it's handed an unknown encapsulation. It is also used by file
35 * types for encapsulations which are unsupported by libwiretap.
36 *
37 * WTAP_ENCAP_NONE is an initial value used by file types like pcapng
38 * that do not have a single file level encapsulation type. If and when
39 * something that indicate encapsulation is read, the encapsulation will
40 * change (possibly to WTAP_ENCAP_PER_PACKET) and appropriate IDBs will
41 * be generated. If a file type uses this value, it MUST provide IDBs
42 * (possibly fake) when the encapsulation changes; otherwise, it should
43 * return WTAP_ENCAP_UNKNOWN so that attempts to write an output file
44 * without reading the entire input file first fail gracefully.
45 *
46 * WTAP_ENCAP_FDDI_BITSWAPPED is for FDDI captures on systems where the
47 * MAC addresses you get from the hardware are bit-swapped. Ideally,
48 * the driver would tell us that, but I know of none that do, so, for
49 * now, we base it on the machine on which we're *reading* the
50 * capture, rather than on the machine on which the capture was taken
51 * (they're probably likely to be the same). We assume that they're
52 * bit-swapped on everything except for systems running Ultrix, Alpha
53 * systems, and BSD/OS systems (that's what "tcpdump" does; I guess
54 * Digital decided to bit-swap addresses in the hardware or in the
55 * driver, and I guess BSDI bit-swapped them in the driver, given that
56 * BSD/OS generally runs on Boring Old PC's). If we create a wiretap
57 * save file format, we'd use the WTAP_ENCAP values to flag the
58 * encapsulation of a packet, so there we'd at least be able to base
59 * it on the machine on which the capture was taken.
60 *
61 * WTAP_ENCAP_LINUX_ATM_CLIP is the encapsulation you get with the
62 * ATM on Linux code from <http://linux-atm.sourceforge.net/>;
63 * that code adds a DLT_ATM_CLIP DLT_ code of 19, and that
64 * encapsulation isn't the same as the DLT_ATM_RFC1483 encapsulation
65 * presumably used on some BSD systems, which we turn into
66 * WTAP_ENCAP_ATM_RFC1483.
67 *
68 * WTAP_ENCAP_NULL corresponds to DLT_NULL from "libpcap". This
69 * corresponds to
70 *
71 * 1) PPP-over-HDLC encapsulation, at least with some versions
72 * of ISDN4BSD (but not the current ones, it appears, unless
73 * I've missed something);
74 *
75 * 2) a 4-byte header containing the AF_ address family, in
76 * the byte order of the machine that saved the capture,
77 * for the packet, as used on many BSD systems for the
78 * loopback device and some other devices, or a 4-byte header
79 * containing the AF_ address family in network byte order,
80 * as used on recent OpenBSD systems for the loopback device;
81 *
82 * 3) a 4-byte header containing 2 octets of 0 and an Ethernet
83 * type in the byte order from an Ethernet header, that being
84 * what older versions of "libpcap" on Linux turn the Ethernet
85 * header for loopback interfaces into (0.6.0 and later versions
86 * leave the Ethernet header alone and make it DLT_EN10MB). */
87#define WTAP_ENCAP_NONE -2
88#define WTAP_ENCAP_PER_PACKET -1
89#define WTAP_ENCAP_UNKNOWN 0
90#define WTAP_ENCAP_ETHERNET 1
91#define WTAP_ENCAP_TOKEN_RING 2
92#define WTAP_ENCAP_SLIP 3
93#define WTAP_ENCAP_PPP 4
94#define WTAP_ENCAP_FDDI 5
95#define WTAP_ENCAP_FDDI_BITSWAPPED 6
96#define WTAP_ENCAP_RAW_IP 7
97#define WTAP_ENCAP_ARCNET 8
98#define WTAP_ENCAP_ARCNET_LINUX 9
99#define WTAP_ENCAP_ATM_RFC1483 10
100#define WTAP_ENCAP_LINUX_ATM_CLIP 11
101#define WTAP_ENCAP_LAPB 12
102#define WTAP_ENCAP_ATM_PDUS 13
103#define WTAP_ENCAP_ATM_PDUS_UNTRUNCATED 14
104#define WTAP_ENCAP_NULL 15
105#define WTAP_ENCAP_ASCEND 16
106#define WTAP_ENCAP_ISDN 17
107#define WTAP_ENCAP_IP_OVER_FC 18
108#define WTAP_ENCAP_PPP_WITH_PHDR 19
109#define WTAP_ENCAP_IEEE_802_11 20
110#define WTAP_ENCAP_IEEE_802_11_PRISM 21
111#define WTAP_ENCAP_IEEE_802_11_WITH_RADIO 22
112#define WTAP_ENCAP_IEEE_802_11_RADIOTAP 23
113#define WTAP_ENCAP_IEEE_802_11_AVS 24
114#define WTAP_ENCAP_SLL 25
115#define WTAP_ENCAP_FRELAY 26
116#define WTAP_ENCAP_FRELAY_WITH_PHDR 27
117#define WTAP_ENCAP_CHDLC 28
118#define WTAP_ENCAP_CISCO_IOS 29
119#define WTAP_ENCAP_LOCALTALK 30
120#define WTAP_ENCAP_OLD_PFLOG 31
121#define WTAP_ENCAP_HHDLC 32
122#define WTAP_ENCAP_DOCSIS 33
123#define WTAP_ENCAP_COSINE 34
124#define WTAP_ENCAP_WFLEET_HDLC 35
125#define WTAP_ENCAP_SDLC 36
126#define WTAP_ENCAP_TZSP 37
127#define WTAP_ENCAP_ENC 38
128#define WTAP_ENCAP_PFLOG 39
129#define WTAP_ENCAP_CHDLC_WITH_PHDR 40
130#define WTAP_ENCAP_BLUETOOTH_H4 41
131#define WTAP_ENCAP_MTP2 42
132#define WTAP_ENCAP_MTP3 43
133#define WTAP_ENCAP_IRDA 44
134#define WTAP_ENCAP_USER0 45
135#define WTAP_ENCAP_USER1 46
136#define WTAP_ENCAP_USER2 47
137#define WTAP_ENCAP_USER3 48
138#define WTAP_ENCAP_USER4 49
139#define WTAP_ENCAP_USER5 50
140#define WTAP_ENCAP_USER6 51
141#define WTAP_ENCAP_USER7 52
142#define WTAP_ENCAP_USER8 53
143#define WTAP_ENCAP_USER9 54
144#define WTAP_ENCAP_USER10 55
145#define WTAP_ENCAP_USER11 56
146#define WTAP_ENCAP_USER12 57
147#define WTAP_ENCAP_USER13 58
148#define WTAP_ENCAP_USER14 59
149#define WTAP_ENCAP_USER15 60
150#define WTAP_ENCAP_SYMANTEC 61
151#define WTAP_ENCAP_APPLE_IP_OVER_IEEE1394 62
152#define WTAP_ENCAP_BACNET_MS_TP 63
153#define WTAP_ENCAP_NETTL_RAW_ICMP 64
154#define WTAP_ENCAP_NETTL_RAW_ICMPV6 65
155#define WTAP_ENCAP_GPRS_LLC 66
156#define WTAP_ENCAP_JUNIPER_ATM1 67
157#define WTAP_ENCAP_JUNIPER_ATM2 68
158#define WTAP_ENCAP_REDBACK 69
159#define WTAP_ENCAP_NETTL_RAW_IP 70
160#define WTAP_ENCAP_NETTL_ETHERNET 71
161#define WTAP_ENCAP_NETTL_TOKEN_RING 72
162#define WTAP_ENCAP_NETTL_FDDI 73
163#define WTAP_ENCAP_NETTL_UNKNOWN 74
164#define WTAP_ENCAP_MTP2_WITH_PHDR 75
165#define WTAP_ENCAP_JUNIPER_PPPOE 76
166#define WTAP_ENCAP_GCOM_TIE1 77
167#define WTAP_ENCAP_GCOM_SERIAL 78
168#define WTAP_ENCAP_NETTL_X25 79
169#define WTAP_ENCAP_K12 80
170#define WTAP_ENCAP_JUNIPER_MLPPP 81
171#define WTAP_ENCAP_JUNIPER_MLFR 82
172#define WTAP_ENCAP_JUNIPER_ETHER 83
173#define WTAP_ENCAP_JUNIPER_PPP 84
174#define WTAP_ENCAP_JUNIPER_FRELAY 85
175#define WTAP_ENCAP_JUNIPER_CHDLC 86
176#define WTAP_ENCAP_JUNIPER_GGSN 87
177#define WTAP_ENCAP_LINUX_LAPD 88
178#define WTAP_ENCAP_CATAPULT_DCT2000 89
179#define WTAP_ENCAP_BER 90
180#define WTAP_ENCAP_JUNIPER_VP 91
181#define WTAP_ENCAP_USB_FREEBSD 92
182#define WTAP_ENCAP_IEEE802_16_MAC_CPS 93
183#define WTAP_ENCAP_NETTL_RAW_TELNET 94
184#define WTAP_ENCAP_USB_LINUX 95
185#define WTAP_ENCAP_MPEG 96
186#define WTAP_ENCAP_PPI 97
187#define WTAP_ENCAP_ERF 98
188#define WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR 99
189#define WTAP_ENCAP_SITA 100
190#define WTAP_ENCAP_SCCP 101
191#define WTAP_ENCAP_BLUETOOTH_HCI 102 /*raw packets without a transport layer header e.g. H4*/
192#define WTAP_ENCAP_IPMB_KONTRON 103
193#define WTAP_ENCAP_IEEE802_15_4 104
194#define WTAP_ENCAP_X2E_XORAYA 105
195#define WTAP_ENCAP_FLEXRAY 106
196#define WTAP_ENCAP_LIN 107
197#define WTAP_ENCAP_MOST 108
198#define WTAP_ENCAP_CAN20B 109
199#define WTAP_ENCAP_LAYER1_EVENT 110
200#define WTAP_ENCAP_X2E_SERIAL 111
201#define WTAP_ENCAP_I2C_LINUX 112
202#define WTAP_ENCAP_IEEE802_15_4_NONASK_PHY 113
203#define WTAP_ENCAP_TNEF 114
204#define WTAP_ENCAP_USB_LINUX_MMAPPED 115
205#define WTAP_ENCAP_GSM_UM 116
206#define WTAP_ENCAP_DPNSS 117
207#define WTAP_ENCAP_PACKETLOGGER 118
208#define WTAP_ENCAP_NSTRACE_1_0 119
209#define WTAP_ENCAP_NSTRACE_2_0 120
210#define WTAP_ENCAP_FIBRE_CHANNEL_FC2 121
211#define WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS 122
212#define WTAP_ENCAP_JPEG_JFIF 123 /* obsoleted by WTAP_ENCAP_MIME*/
213#define WTAP_ENCAP_IPNET 124
214#define WTAP_ENCAP_SOCKETCAN 125
215#define WTAP_ENCAP_IEEE_802_11_NETMON 126
216#define WTAP_ENCAP_IEEE802_15_4_NOFCS 127
217#define WTAP_ENCAP_RAW_IPFIX 128
218#define WTAP_ENCAP_RAW_IP4 129
219#define WTAP_ENCAP_RAW_IP6 130
220#define WTAP_ENCAP_LAPD 131
221#define WTAP_ENCAP_DVBCI 132
222#define WTAP_ENCAP_MUX27010 133
223#define WTAP_ENCAP_MIME 134
224#define WTAP_ENCAP_NETANALYZER 135
225#define WTAP_ENCAP_NETANALYZER_TRANSPARENT 136
226#define WTAP_ENCAP_IP_OVER_IB_SNOOP 137
227#define WTAP_ENCAP_MPEG_2_TS 138
228#define WTAP_ENCAP_PPP_ETHER 139
229#define WTAP_ENCAP_NFC_LLCP 140
230#define WTAP_ENCAP_NFLOG 141
231#define WTAP_ENCAP_V5_EF 142
232#define WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR 143
233#define WTAP_ENCAP_IXVERIWAVE 144
234#define WTAP_ENCAP_SDH 145
235#define WTAP_ENCAP_DBUS 146
236#define WTAP_ENCAP_AX25_KISS 147
237#define WTAP_ENCAP_AX25 148
238#define WTAP_ENCAP_SCTP 149
239#define WTAP_ENCAP_INFINIBAND 150
240#define WTAP_ENCAP_JUNIPER_SVCS 151
241#define WTAP_ENCAP_USBPCAP 152
242#define WTAP_ENCAP_RTAC_SERIAL 153
243#define WTAP_ENCAP_BLUETOOTH_LE_LL 154
244#define WTAP_ENCAP_WIRESHARK_UPPER_PDU 155
245#define WTAP_ENCAP_STANAG_4607 156
246#define WTAP_ENCAP_STANAG_5066_D_PDU 157
247#define WTAP_ENCAP_NETLINK 158
248#define WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR 159
249#define WTAP_ENCAP_BLUETOOTH_BREDR_BB 160
250#define WTAP_ENCAP_BLUETOOTH_LE_LL_WITH_PHDR 161
251#define WTAP_ENCAP_NSTRACE_3_0 162
252#define WTAP_ENCAP_LOGCAT 163
253#define WTAP_ENCAP_LOGCAT_BRIEF 164
254#define WTAP_ENCAP_LOGCAT_PROCESS 165
255#define WTAP_ENCAP_LOGCAT_TAG 166
256#define WTAP_ENCAP_LOGCAT_THREAD 167
257#define WTAP_ENCAP_LOGCAT_TIME 168
258#define WTAP_ENCAP_LOGCAT_THREADTIME 169
259#define WTAP_ENCAP_LOGCAT_LONG 170
260#define WTAP_ENCAP_PKTAP 171
261#define WTAP_ENCAP_EPON 172
262#define WTAP_ENCAP_IPMI_TRACE 173
263#define WTAP_ENCAP_LOOP 174
264#define WTAP_ENCAP_JSON 175
265#define WTAP_ENCAP_NSTRACE_3_5 176
266#define WTAP_ENCAP_ISO14443 177
267#define WTAP_ENCAP_GFP_T 178
268#define WTAP_ENCAP_GFP_F 179
269#define WTAP_ENCAP_IP_OVER_IB_PCAP 180
270#define WTAP_ENCAP_JUNIPER_VN 181
271#define WTAP_ENCAP_USB_DARWIN 182
272#define WTAP_ENCAP_LORATAP 183
273#define WTAP_ENCAP_3MB_ETHERNET 184
274#define WTAP_ENCAP_VSOCK 185
275#define WTAP_ENCAP_NORDIC_BLE 186
276#define WTAP_ENCAP_NETMON_NET_NETEVENT 187
277#define WTAP_ENCAP_NETMON_HEADER 188
278#define WTAP_ENCAP_NETMON_NET_FILTER 189
279#define WTAP_ENCAP_NETMON_NETWORK_INFO_EX 190
280#define WTAP_ENCAP_MA_WFP_CAPTURE_V4 191
281#define WTAP_ENCAP_MA_WFP_CAPTURE_V6 192
282#define WTAP_ENCAP_MA_WFP_CAPTURE_2V4 193
283#define WTAP_ENCAP_MA_WFP_CAPTURE_2V6 194
284#define WTAP_ENCAP_MA_WFP_CAPTURE_AUTH_V4 195
285#define WTAP_ENCAP_MA_WFP_CAPTURE_AUTH_V6 196
286#define WTAP_ENCAP_JUNIPER_ST 197
287#define WTAP_ENCAP_ETHERNET_MPACKET 198
288#define WTAP_ENCAP_DOCSIS31_XRA31 199
289#define WTAP_ENCAP_DPAUXMON 200
290#define WTAP_ENCAP_RUBY_MARSHAL 201
291#define WTAP_ENCAP_RFC7468 202
292#define WTAP_ENCAP_SYSTEMD_JOURNAL 203 /* Event, not a packet */
293#define WTAP_ENCAP_EBHSCR 204
294#define WTAP_ENCAP_VPP 205
295#define WTAP_ENCAP_IEEE802_15_4_TAP 206
296#define WTAP_ENCAP_LOG_3GPP 207
297#define WTAP_ENCAP_USB_2_0 208
298#define WTAP_ENCAP_MP4 209
299#define WTAP_ENCAP_SLL2 210
300#define WTAP_ENCAP_ZWAVE_SERIAL 211
301#define WTAP_ENCAP_ETW 212
302#define WTAP_ENCAP_ERI_ENB_LOG 213
303#define WTAP_ENCAP_ZBNCP 214
304#define WTAP_ENCAP_USB_2_0_LOW_SPEED 215
305#define WTAP_ENCAP_USB_2_0_FULL_SPEED 216
306#define WTAP_ENCAP_USB_2_0_HIGH_SPEED 217
307#define WTAP_ENCAP_AUTOSAR_DLT 218
308#define WTAP_ENCAP_AUERSWALD_LOG 219
309#define WTAP_ENCAP_ATSC_ALP 220
310#define WTAP_ENCAP_FIRA_UCI 221
311#define WTAP_ENCAP_SILABS_DEBUG_CHANNEL 222
312#define WTAP_ENCAP_MDB 223
313#define WTAP_ENCAP_EMS 224
314#define WTAP_ENCAP_DECT_NR 225
315#define WTAP_ENCAP_MMODULE 226
316#define WTAP_ENCAP_PROCMON 227
317
318/* After adding new item here, please also add new item to encap_table_base array */
319
320#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()
321
322/* Value to be used as a file type/subtype value if the type is unknown */
323#define WTAP_FILE_TYPE_SUBTYPE_UNKNOWN -1
324
325/* timestamp precision (currently only these values are supported) */
326#define WTAP_TSPREC_UNKNOWN -2
327#define WTAP_TSPREC_PER_PACKET -1 /* as a per-file value, means per-packet */
328/*
329 * These values are the number of digits of precision after the integral part.
330 * They're the same as WS_TSPREC values; we define them here so that
331 * tools/make-enums.py sees them.
332 */
333#define WTAP_TSPREC_SEC 0
334#define WTAP_TSPREC_100_MSEC 1
335#define WTAP_TSPREC_DSEC 1 /* Backwards compatibility */
336#define WTAP_TSPREC_10_MSEC 2
337#define WTAP_TSPREC_CSEC 2 /* Backwards compatibility */
338#define WTAP_TSPREC_MSEC 3
339#define WTAP_TSPREC_100_USEC 4
340#define WTAP_TSPREC_10_USEC 5
341#define WTAP_TSPREC_USEC 6
342#define WTAP_TSPREC_100_NSEC 7
343#define WTAP_TSPREC_10_NSEC 8
344#define WTAP_TSPREC_NSEC 9
345/* if you add to the above, update wtap_tsprec_string() */
346
347/*
348 * Maximum packet sizes.
349 *
350 * For most link-layer types, we use 262144, which is currently
351 * libpcap's MAXIMUM_SNAPLEN.
352 *
353 * For WTAP_ENCAP_DBUS, the maximum is 128MiB, as per
354 *
355 * https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
356 *
357 * For WTAP_ENCAP_EBHSCR, the maximum is 8MiB, as per
358 *
359 * https://www.elektrobit.com/ebhscr
360 *
361 * For WTAP_ENCAP_USBPCAP, the maximum is 128MiB, as per
362 *
363 * https://gitlab.com/wireshark/wireshark/-/issues/15985
364 *
365 * We don't want to write out files that specify a maximum packet size
366 * greater than 262144 if we don't have to, as software reading those
367 * files might allocate a buffer much larger than necessary, wasting memory.
368 */
369#define WTAP_MAX_PACKET_SIZE_STANDARD 262144U
370#define WTAP_MAX_PACKET_SIZE_USBPCAP (128U*1024U*1024U)
371#define WTAP_MAX_PACKET_SIZE_EBHSCR (32U*1024U*1024U)
372#define WTAP_MAX_PACKET_SIZE_DBUS (128U*1024U*1024U)
373
374/*
375 * "Pseudo-headers" are used to supply to the clients of wiretap
376 * per-packet information that's not part of the packet payload
377 * proper.
378 *
379 * NOTE: do not use pseudo-header structures to hold information
380 * used by the code to read a particular capture file type; to
381 * keep that sort of state information, add a new structure for
382 * that private information to "wtap-int.h", add a pointer to that
383 * type of structure to the "capture" member of the "struct wtap"
384 * structure, and allocate one of those structures and set that member
385 * in the "open" routine for that capture file type if the open
386 * succeeds. See various other capture file type handlers for examples
387 * of that.
388 */
389
390
391/* Packet "pseudo-header" information for Ethernet capture files. */
392struct eth_phdr {
393 int fcs_len; /* Number of bytes of FCS - -1 means "unknown" */
394};
395
396/* Packet "pseudo-header" information for capture files for traffic
397 between DTE and DCE. */
398#define FROM_DCE 0x80
400 uint8_t flags; /* ENCAP_LAPB, ENCAP_V120, ENCAP_FRELAY: 1st bit means From DCE */
401};
402
403/* Packet "pseudo-header" information for ISDN capture files. */
404
405/* Direction */
406struct isdn_phdr {
407 bool uton;
408 uint8_t channel; /* 0 = D-channel; n = B-channel n */
409};
410
411/* Packet "pseudo-header" for ATM capture files.
412 Not all of this information is supplied by all capture types.
413 These originally came from the Network General (DOS-based)
414 ATM Sniffer file format, but we've added some additional
415 items. */
416
417/*
418 * Status bits.
419 */
420#define ATM_RAW_CELL 0x01 /* true if the packet is a single cell */
421#define ATM_NO_HEC 0x02 /* true if the cell has HEC stripped out */
422#define ATM_AAL2_NOPHDR 0x04 /* true if the AAL2 PDU has no pseudo-header */
423#define ATM_REASSEMBLY_ERROR 0x08 /* true if this is an incompletely-reassembled PDU */
424
425/*
426 * AAL types.
427 */
428#define AAL_UNKNOWN 0 /* AAL unknown */
429#define AAL_1 1 /* AAL1 */
430#define AAL_2 2 /* AAL2 */
431#define AAL_3_4 3 /* AAL3/4 */
432#define AAL_5 4 /* AAL5 */
433#define AAL_USER 5 /* User AAL */
434#define AAL_SIGNALLING 6 /* Signaling AAL */
435#define AAL_OAMCELL 7 /* OAM cell */
436
437/*
438 * Traffic types.
439 */
440#define TRAF_UNKNOWN 0 /* Unknown */
441#define TRAF_LLCMX 1 /* LLC multiplexed (RFC 1483) */
442#define TRAF_VCMX 2 /* VC multiplexed (RFC 1483) */
443#define TRAF_LANE 3 /* LAN Emulation */
444#define TRAF_ILMI 4 /* ILMI */
445#define TRAF_FR 5 /* Frame Relay */
446#define TRAF_SPANS 6 /* FORE SPANS */
447#define TRAF_IPSILON 7 /* Ipsilon */
448#define TRAF_UMTS_FP 8 /* UMTS Frame Protocol */
449#define TRAF_GPRS_NS 9 /* GPRS Network Services */
450#define TRAF_SSCOP 10 /* SSCOP */
451
452/*
453 * Traffic subtypes.
454 */
455#define TRAF_ST_UNKNOWN 0 /* Unknown */
456
457/*
458 * For TRAF_VCMX:
459 */
460#define TRAF_ST_VCMX_802_3_FCS 1 /* 802.3 with an FCS */
461#define TRAF_ST_VCMX_802_4_FCS 2 /* 802.4 with an FCS */
462#define TRAF_ST_VCMX_802_5_FCS 3 /* 802.5 with an FCS */
463#define TRAF_ST_VCMX_FDDI_FCS 4 /* FDDI with an FCS */
464#define TRAF_ST_VCMX_802_6_FCS 5 /* 802.6 with an FCS */
465#define TRAF_ST_VCMX_802_3 7 /* 802.3 without an FCS */
466#define TRAF_ST_VCMX_802_4 8 /* 802.4 without an FCS */
467#define TRAF_ST_VCMX_802_5 9 /* 802.5 without an FCS */
468#define TRAF_ST_VCMX_FDDI 10 /* FDDI without an FCS */
469#define TRAF_ST_VCMX_802_6 11 /* 802.6 without an FCS */
470#define TRAF_ST_VCMX_FRAGMENTS 12 /* Fragments */
471#define TRAF_ST_VCMX_BPDU 13 /* BPDU */
472
473/*
474 * For TRAF_LANE:
475 */
476#define TRAF_ST_LANE_LE_CTRL 1 /* LANE: LE Ctrl */
477#define TRAF_ST_LANE_802_3 2 /* LANE: 802.3 */
478#define TRAF_ST_LANE_802_5 3 /* LANE: 802.5 */
479#define TRAF_ST_LANE_802_3_MC 4 /* LANE: 802.3 multicast */
480#define TRAF_ST_LANE_802_5_MC 5 /* LANE: 802.5 multicast */
481
482/*
483 * For TRAF_IPSILON:
484 */
485#define TRAF_ST_IPSILON_FT0 1 /* Ipsilon: Flow Type 0 */
486#define TRAF_ST_IPSILON_FT1 2 /* Ipsilon: Flow Type 1 */
487#define TRAF_ST_IPSILON_FT2 3 /* Ipsilon: Flow Type 2 */
488
489struct atm_phdr {
490 uint32_t flags; /* status flags */
491 uint8_t aal; /* AAL of the traffic */
492 uint8_t type; /* traffic type */
493 uint8_t subtype; /* traffic subtype */
494 uint16_t vpi; /* virtual path identifier */
495 uint16_t vci; /* virtual circuit identifier */
496 uint8_t aal2_cid; /* channel id */
497 uint16_t channel; /* link: 0 for DTE->DCE, 1 for DCE->DTE */
498 uint16_t cells; /* number of cells */
499 uint16_t aal5t_u2u; /* user-to-user indicator */
500 uint16_t aal5t_len; /* length of the packet */
501 uint32_t aal5t_chksum; /* checksum for AAL5 packet */
502};
503
504/* Packet "pseudo-header" for the output from "wandsession", "wannext",
505 "wandisplay", and similar commands on Lucent/Ascend access equipment. */
506
507#define ASCEND_MAX_STR_LEN 64
508
509#define ASCEND_PFX_WDS_X 1
510#define ASCEND_PFX_WDS_R 2
511#define ASCEND_PFX_WDD 3
512#define ASCEND_PFX_ISDN_X 4
513#define ASCEND_PFX_ISDN_R 5
514#define ASCEND_PFX_ETHER 6
515
517 uint16_t type; /* ASCEND_PFX_*, as defined above */
518 char user[ASCEND_MAX_STR_LEN]; /* Username, from wandsession header */
519 uint32_t sess; /* Session number, from wandsession header */
520 char call_num[ASCEND_MAX_STR_LEN]; /* Called number, from WDD header */
521 uint32_t chunk; /* Chunk number, from WDD header */
522 uint32_t task; /* Task number */
523};
524
525/* Packet "pseudo-header" for point-to-point links with direction flags. */
526struct p2p_phdr {
527 bool sent;
528};
529
530/*
531 * Packet "pseudo-header" information for 802.11.
532 * Radio information is only present in this form for
533 * WTAP_ENCAP_IEEE_802_11_WITH_RADIO. This is used for file formats in
534 * which the radio information isn't provided as a pseudo-header in the
535 * packet data. It is also used by the dissectors for the pseudo-headers
536 * in the packet data to supply radio information, in a form independent
537 * of the file format and pseudo-header format, to the "802.11 radio"
538 * dissector.
539 *
540 * Signal strength, etc. information:
541 *
542 * Raw signal strength can be measured in milliwatts.
543 * It can also be represented as dBm, which is 10 times the log base 10
544 * of the signal strength in mW.
545 *
546 * The Receive Signal Strength Indicator is an integer in the range 0 to 255.
547 * The actual RSSI value for a given signal strength is dependent on the
548 * vendor (and perhaps on the adapter). The maximum possible RSSI value
549 * is also dependent on the vendor and perhaps the adapter.
550 *
551 * The signal strength can be represented as a percentage, which is 100
552 * times the ratio of the RSSI and the maximum RSSI.
553 */
554
555/*
556 * PHY types.
557 */
558#define PHDR_802_11_PHY_UNKNOWN 0 /* PHY not known */
559#define PHDR_802_11_PHY_11_FHSS 1 /* 802.11 FHSS */
560#define PHDR_802_11_PHY_11_IR 2 /* 802.11 IR */
561#define PHDR_802_11_PHY_11_DSSS 3 /* 802.11 DSSS */
562#define PHDR_802_11_PHY_11B 4 /* 802.11b */
563#define PHDR_802_11_PHY_11A 5 /* 802.11a */
564#define PHDR_802_11_PHY_11G 6 /* 802.11g */
565#define PHDR_802_11_PHY_11N 7 /* 802.11n */
566#define PHDR_802_11_PHY_11AC 8 /* 802.11ac */
567#define PHDR_802_11_PHY_11AD 9 /* 802.11ad */
568#define PHDR_802_11_PHY_11AH 10 /* 802.11ah */
569#define PHDR_802_11_PHY_11AX 11 /* 802.11ax */
570#define PHDR_802_11_PHY_11BE 12 /* 802.11be - EHT */
571
572/*
573 * PHY-specific information.
574 */
575
576/*
577 * 802.11 legacy FHSS.
578 */
580 unsigned has_hop_set:1;
581 unsigned has_hop_pattern:1;
582 unsigned has_hop_index:1;
583
584 uint8_t hop_set; /* Hop set */
585 uint8_t hop_pattern; /* Hop pattern */
586 uint8_t hop_index; /* Hop index */
587};
588
589/*
590 * 802.11b.
591 */
593 /* Which of this information is present? */
594 unsigned has_short_preamble:1;
595
596 bool short_preamble; /* Short preamble */
597};
598
599/*
600 * 802.11a.
601 */
603 /* Which of this information is present? */
604 unsigned has_channel_type:1;
605 unsigned has_turbo_type:1;
606
607 unsigned channel_type:2;
608 unsigned turbo_type:2;
609};
610
611/*
612 * Channel type values.
613 */
614#define PHDR_802_11A_CHANNEL_TYPE_NORMAL 0
615#define PHDR_802_11A_CHANNEL_TYPE_HALF_CLOCKED 1
616#define PHDR_802_11A_CHANNEL_TYPE_QUARTER_CLOCKED 2
617
618/*
619 * "Turbo" is an Atheros proprietary extension with 40 MHz-wide channels.
620 * It can be dynamic or static.
621 *
622 * See
623 *
624 * http://wifi-insider.com/atheros/turbo.htm
625 */
626#define PHDR_802_11A_TURBO_TYPE_NORMAL 0
627#define PHDR_802_11A_TURBO_TYPE_TURBO 1 /* If we don't know whether it's static or dynamic */
628#define PHDR_802_11A_TURBO_TYPE_DYNAMIC_TURBO 2
629#define PHDR_802_11A_TURBO_TYPE_STATIC_TURBO 3
630
631/*
632 * 802.11g.
633 *
634 * This should only be used for packets sent using OFDM; packets
635 * sent on an 11g network using DSSS should have the PHY set to
636 * 11b.
637 */
639 /* Which of this information is present? */
640 unsigned has_mode:1;
641
642 uint32_t mode; /* Various proprietary extensions */
643};
644
645/*
646 * Mode values.
647 */
648#define PHDR_802_11G_MODE_NORMAL 0
649#define PHDR_802_11G_MODE_SUPER_G 1 /* Atheros Super G */
650
651/*
652 * 802.11n.
653 */
655 /* Which of this information is present? */
656 unsigned has_mcs_index:1;
657 unsigned has_bandwidth:1;
658 unsigned has_short_gi:1;
659 unsigned has_greenfield:1;
660 unsigned has_fec:1;
661 unsigned has_stbc_streams:1;
662 unsigned has_ness:1;
663
664 uint16_t mcs_index; /* MCS index */
665 unsigned bandwidth; /* Bandwidth = 20 MHz, 40 MHz, etc. */
666 unsigned short_gi:1; /* True for short guard interval */
667 unsigned greenfield:1; /* True for greenfield, short for mixed */
668 unsigned fec:1; /* FEC: 0 = BCC, 1 = LDPC */
669 unsigned stbc_streams:2; /* Number of STBC streams */
670 unsigned ness; /* Number of extension spatial streams */
671};
672
673/*
674 * Bandwidth values; used for both 11n and 11ac.
675 */
676#define PHDR_802_11_BANDWIDTH_20_MHZ 0 /* 20 MHz */
677#define PHDR_802_11_BANDWIDTH_40_MHZ 1 /* 40 MHz */
678#define PHDR_802_11_BANDWIDTH_20_20L 2 /* 20 + 20L, 40 MHz */
679#define PHDR_802_11_BANDWIDTH_20_20U 3 /* 20 + 20U, 40 MHz */
680#define PHDR_802_11_BANDWIDTH_80_MHZ 4 /* 80 MHz */
681#define PHDR_802_11_BANDWIDTH_40_40L 5 /* 40 + 40L MHz, 80 MHz */
682#define PHDR_802_11_BANDWIDTH_40_40U 6 /* 40 + 40U MHz, 80 MHz */
683#define PHDR_802_11_BANDWIDTH_20LL 7 /* ???, 80 MHz */
684#define PHDR_802_11_BANDWIDTH_20LU 8 /* ???, 80 MHz */
685#define PHDR_802_11_BANDWIDTH_20UL 9 /* ???, 80 MHz */
686#define PHDR_802_11_BANDWIDTH_20UU 10 /* ???, 80 MHz */
687#define PHDR_802_11_BANDWIDTH_160_MHZ 11 /* 160 MHz */
688#define PHDR_802_11_BANDWIDTH_80_80L 12 /* 80 + 80L, 160 MHz */
689#define PHDR_802_11_BANDWIDTH_80_80U 13 /* 80 + 80U, 160 MHz */
690#define PHDR_802_11_BANDWIDTH_40LL 14 /* ???, 160 MHz */
691#define PHDR_802_11_BANDWIDTH_40LU 15 /* ???, 160 MHz */
692#define PHDR_802_11_BANDWIDTH_40UL 16 /* ???, 160 MHz */
693#define PHDR_802_11_BANDWIDTH_40UU 17 /* ???, 160 MHz */
694#define PHDR_802_11_BANDWIDTH_20LLL 18 /* ???, 160 MHz */
695#define PHDR_802_11_BANDWIDTH_20LLU 19 /* ???, 160 MHz */
696#define PHDR_802_11_BANDWIDTH_20LUL 20 /* ???, 160 MHz */
697#define PHDR_802_11_BANDWIDTH_20LUU 21 /* ???, 160 MHz */
698#define PHDR_802_11_BANDWIDTH_20ULL 22 /* ???, 160 MHz */
699#define PHDR_802_11_BANDWIDTH_20ULU 23 /* ???, 160 MHz */
700#define PHDR_802_11_BANDWIDTH_20UUL 24 /* ???, 160 MHz */
701#define PHDR_802_11_BANDWIDTH_20UUU 25 /* ???, 160 MHz */
702
703/*
704 * 802.11ac.
705 */
707 /* Which of this information is present? */
708 unsigned has_stbc:1;
709 unsigned has_txop_ps_not_allowed:1;
710 unsigned has_short_gi:1;
711 unsigned has_short_gi_nsym_disambig:1;
712 unsigned has_ldpc_extra_ofdm_symbol:1;
713 unsigned has_beamformed:1;
714 unsigned has_bandwidth:1;
715 unsigned has_fec:1;
716 unsigned has_group_id:1;
717 unsigned has_partial_aid:1;
718
719 unsigned stbc:1; /* 1 if all spatial streams have STBC */
720 unsigned txop_ps_not_allowed:1;
721 unsigned short_gi:1; /* True for short guard interval */
722 unsigned short_gi_nsym_disambig:1;
723 unsigned ldpc_extra_ofdm_symbol:1;
724 unsigned beamformed:1;
725 uint8_t bandwidth; /* Bandwidth = 20 MHz, 40 MHz, etc. */
726 uint8_t mcs[4]; /* MCS index per user */
727 uint8_t nss[4]; /* NSS per user */
728 uint8_t fec; /* Bit array of FEC per user: 0 = BCC, 1 = LDPC */
729 uint8_t group_id;
730 uint16_t partial_aid;
731};
732
733/*
734 * 802.11ad.
735 */
736
737/*
738 * Min and Max frequencies for 802.11ad and a macro for checking for 802.11ad.
739 */
740
741#define PHDR_802_11AD_MIN_FREQUENCY 57000
742#define PHDR_802_11AD_MAX_FREQUENCY 71000
743
744#define IS_80211AD(frequency) (((frequency) >= PHDR_802_11AD_MIN_FREQUENCY) &&\
745 ((frequency) <= PHDR_802_11AD_MAX_FREQUENCY))
746
748 /* Which of this information is present? */
749 unsigned has_mcs_index:1;
750
751 uint8_t mcs; /* MCS index */
752};
753
754/*
755 * 802.11ax (HE).
756 */
758 /* Which of this information is present? */
759 unsigned has_mcs_index:1;
760 unsigned has_bwru:1;
761 unsigned has_gi:1;
762
763 uint8_t nsts:4; /* Number of Space-time Streams */
764 uint8_t mcs:4; /* MCS index */
765 uint8_t bwru:4; /* Bandwidth/RU allocation */
766 uint8_t gi:2; /* Guard Interval */
767};
768
769/*
770 * 802.11be (EHT).
771 */
773 unsigned sta_id_known:1;
774 unsigned mcs_known:1;
775 unsigned coding_known:1;
776 unsigned rsv_known:1;
777 unsigned nsts_known:1;
778 unsigned bf_known:1;
779 unsigned spatial_config_known:1;
780 unsigned data_for_this_user:1;
781 unsigned sta_id:11;
782 unsigned ldpc_coding:1;
783 unsigned mcs:4;
784 unsigned nsts:4;
785 unsigned rsv:1;
786 unsigned beamform:1;
787 unsigned rsv2:2;
788};
789
790#define PHDR_802_11BE_MAX_USERS 4
792 /* Which of this information is present? */
793 unsigned has_ru_mru_size:1;
794 unsigned has_gi:1;
795 unsigned has_bandwidth:1;
796
797 uint8_t bandwidth;
798 uint8_t ru_mru_size:4; /* RU/MRU allocation */
799 uint8_t gi:2; /* Guard Interval */
800 uint8_t num_users;
801 struct ieee_802_11be_user_info user[PHDR_802_11BE_MAX_USERS]; /* Adding info for only upto 4 users */
802};
803
804
806 struct ieee_802_11_fhss info_11_fhss;
807 struct ieee_802_11b info_11b;
808 struct ieee_802_11a info_11a;
809 struct ieee_802_11g info_11g;
810 struct ieee_802_11n info_11n;
811 struct ieee_802_11ac info_11ac;
812 struct ieee_802_11ad info_11ad;
813 struct ieee_802_11ax info_11ax;
814 struct ieee_802_11be info_11be;
815};
816
818 int fcs_len; /* Number of bytes of FCS - -1 means "unknown" */
819 unsigned decrypted:1; /* true if frame is decrypted even if "protected" bit is set */
820 unsigned datapad:1; /* true if frame has padding between 802.11 header and payload */
821 unsigned no_a_msdus:1; /* true if we should ignore the A-MSDU bit */
822 unsigned phy; /* PHY type */
823 union ieee_802_11_phy_info phy_info;
824
825 /* Which of this information is present? */
826 unsigned has_channel:1;
827 unsigned has_frequency:1;
828 unsigned has_data_rate:1;
829 unsigned has_signal_percent:1;
830 unsigned has_noise_percent:1;
831 unsigned has_signal_dbm:1;
832 unsigned has_noise_dbm:1;
833 unsigned has_signal_db:1;
834 unsigned has_noise_db:1;
835 unsigned has_tsf_timestamp:1;
836 unsigned has_aggregate_info:1; /* aggregate flags and ID */
837 unsigned has_zero_length_psdu_type:1; /* zero-length PSDU type */
838
839 uint16_t channel; /* Channel number */
840 uint32_t frequency; /* Channel center frequency */
841 uint16_t data_rate; /* Data rate, in .5 Mb/s units */
842 uint8_t signal_percent; /* Signal level, as a percentage */
843 uint8_t noise_percent; /* Noise level, as a percentage */
844 int8_t signal_dbm; /* Signal level, in dBm */
845 int8_t noise_dbm; /* Noise level, in dBm */
846 uint8_t signal_db; /* Signal level, in dB from an arbitrary point */
847 uint8_t noise_db; /* Noise level, in dB from an arbitrary point */
848 uint64_t tsf_timestamp;
849 uint32_t aggregate_flags; /* A-MPDU flags */
850 uint32_t aggregate_id; /* ID for A-MPDU reassembly */
851 uint8_t zero_length_psdu_type; /* type of zero-length PSDU */
852};
853
854/*
855 * A-MPDU flags.
856 */
857#define PHDR_802_11_LAST_PART_OF_A_MPDU 0x00000001 /* this is the last part of an A-MPDU */
858#define PHDR_802_11_A_MPDU_DELIM_CRC_ERROR 0x00000002 /* delimiter CRC error after this part */
859
860/*
861 * Zero-length PSDU types.
862 */
863#define PHDR_802_11_SOUNDING_PSDU 0 /* sounding PPDU */
864#define PHDR_802_11_DATA_NOT_CAPTURED 1 /* data not captured, (e.g. multi-user PPDU) */
865#define PHDR_802_11_0_LENGTH_PSDU_VENDOR_SPECIFIC 0xff
866
867/* Packet "pseudo-header" for the output from CoSine L2 debug output. */
868
869#define COSINE_MAX_IF_NAME_LEN 128
870
871#define COSINE_ENCAP_TEST 1
872#define COSINE_ENCAP_PPoATM 2
873#define COSINE_ENCAP_PPoFR 3
874#define COSINE_ENCAP_ATM 4
875#define COSINE_ENCAP_FR 5
876#define COSINE_ENCAP_HDLC 6
877#define COSINE_ENCAP_PPP 7
878#define COSINE_ENCAP_ETH 8
879#define COSINE_ENCAP_UNKNOWN 99
880
881#define COSINE_DIR_TX 1
882#define COSINE_DIR_RX 2
883
885 uint8_t encap; /* COSINE_ENCAP_* as defined above */
886 uint8_t direction; /* COSINE_DIR_*, as defined above */
887 char if_name[COSINE_MAX_IF_NAME_LEN]; /* Encap & Logical I/F name */
888 uint16_t pro; /* Protocol */
889 uint16_t off; /* Offset */
890 uint16_t pri; /* Priority */
891 uint16_t rm; /* Rate Marking */
892 uint16_t err; /* Error Code */
893};
894
895/* Packet "pseudo-header" for IrDA capture files. */
896
897/*
898 * Direction of the packet
899 */
900#define IRDA_INCOMING 0x0000
901#define IRDA_OUTGOING 0x0004
902
903/*
904 * "Inline" log messages produced by IrCOMM2k on Windows
905 */
906#define IRDA_LOG_MESSAGE 0x0100 /* log message */
907#define IRDA_MISSED_MSG 0x0101 /* missed log entry or frame */
908
909/*
910 * Differentiate between frames and log messages
911 */
912#define IRDA_CLASS_FRAME 0x0000
913#define IRDA_CLASS_LOG 0x0100
914#define IRDA_CLASS_MASK 0xFF00
915
916struct irda_phdr {
917 uint16_t pkttype; /* packet type */
918};
919
920/* Packet "pseudo-header" for nettl (HP-UX) capture files. */
921
923 uint16_t subsys;
924 uint32_t devid;
925 uint32_t kind;
926 int32_t pid;
927 uint32_t uid;
928};
929
930/* Packet "pseudo-header" for MTP2 files. */
931
932#define MTP2_ANNEX_A_NOT_USED 0
933#define MTP2_ANNEX_A_USED 1
934#define MTP2_ANNEX_A_USED_UNKNOWN 2
935
936struct mtp2_phdr {
937 uint8_t sent;
938 uint8_t annex_a_used;
939 uint16_t link_number;
940};
941
942/* Packet "pseudo-header" for K12 files. */
943
944typedef union {
945 struct {
946 uint16_t vp;
947 uint16_t vc;
948 uint16_t cid;
949 } atm;
950
951 uint32_t ds0mask;
953
954struct k12_phdr {
955 uint32_t input;
956 const char *input_name;
957 const char *stack_file;
958 uint32_t input_type;
959 k12_input_info_t input_info;
960 uint8_t *extra_info;
961 uint32_t extra_length;
962 void* stuff;
963};
964
965#define K12_PORT_DS0S 0x00010008
966#define K12_PORT_DS1 0x00100008
967#define K12_PORT_ATMPVC 0x01020000
968
969struct lapd_phdr {
970 uint16_t pkttype; /* packet type */
971 uint8_t we_network;
972};
973
974struct wtap;
976{
977 union
978 {
979 struct isdn_phdr isdn;
980 struct atm_phdr atm;
981 struct p2p_phdr p2p;
982 } inner_pseudo_header;
983 int64_t seek_off;
984 struct wtap *wth;
985};
986
987/*
988 * Endace Record Format pseudo header
989 */
990struct erf_phdr {
991 uint64_t ts; /* Time stamp */
992 uint8_t type;
993 uint8_t flags;
994 uint16_t rlen;
995 uint16_t lctr;
996 uint16_t wlen;
997};
998
999struct erf_ehdr {
1000 uint64_t ehdr;
1001};
1002
1003/*
1004 * ERF pseudo header with optional subheader
1005 * (Multichannel or Ethernet)
1006 */
1007
1008#define MAX_ERF_EHDR 16
1009
1011 uint8_t offset;
1012 uint8_t pad;
1013};
1014
1016 struct erf_phdr phdr;
1017 struct erf_ehdr ehdr_list[MAX_ERF_EHDR];
1018 union
1019 {
1021 uint32_t mc_hdr;
1022 uint32_t aal2_hdr;
1023 } subhdr;
1024};
1025
1026#define SITA_FRAME_DIR_TXED (0x00) /* values of sita_phdr.flags */
1027#define SITA_FRAME_DIR_RXED (0x01)
1028#define SITA_FRAME_DIR (0x01) /* mask */
1029#define SITA_ERROR_NO_BUFFER (0x80)
1030
1031#define SITA_SIG_DSR (0x01) /* values of sita_phdr.signals */
1032#define SITA_SIG_DTR (0x02)
1033#define SITA_SIG_CTS (0x04)
1034#define SITA_SIG_RTS (0x08)
1035#define SITA_SIG_DCD (0x10)
1036#define SITA_SIG_UNDEF1 (0x20)
1037#define SITA_SIG_UNDEF2 (0x40)
1038#define SITA_SIG_UNDEF3 (0x80)
1039
1040#define SITA_ERROR_TX_UNDERRUN (0x01) /* values of sita_phdr.errors2 (if SITA_FRAME_DIR_TXED) */
1041#define SITA_ERROR_TX_CTS_LOST (0x02)
1042#define SITA_ERROR_TX_UART_ERROR (0x04)
1043#define SITA_ERROR_TX_RETX_LIMIT (0x08)
1044#define SITA_ERROR_TX_UNDEF1 (0x10)
1045#define SITA_ERROR_TX_UNDEF2 (0x20)
1046#define SITA_ERROR_TX_UNDEF3 (0x40)
1047#define SITA_ERROR_TX_UNDEF4 (0x80)
1048
1049#define SITA_ERROR_RX_FRAMING (0x01) /* values of sita_phdr.errors1 (if SITA_FRAME_DIR_RXED) */
1050#define SITA_ERROR_RX_PARITY (0x02)
1051#define SITA_ERROR_RX_COLLISION (0x04)
1052#define SITA_ERROR_RX_FRAME_LONG (0x08)
1053#define SITA_ERROR_RX_FRAME_SHORT (0x10)
1054#define SITA_ERROR_RX_UNDEF1 (0x20)
1055#define SITA_ERROR_RX_UNDEF2 (0x40)
1056#define SITA_ERROR_RX_UNDEF3 (0x80)
1057
1058#define SITA_ERROR_RX_NONOCTET_ALIGNED (0x01) /* values of sita_phdr.errors2 (if SITA_FRAME_DIR_RXED) */
1059#define SITA_ERROR_RX_ABORT (0x02)
1060#define SITA_ERROR_RX_CD_LOST (0x04)
1061#define SITA_ERROR_RX_DPLL (0x08)
1062#define SITA_ERROR_RX_OVERRUN (0x10)
1063#define SITA_ERROR_RX_FRAME_LEN_VIOL (0x20)
1064#define SITA_ERROR_RX_CRC (0x40)
1065#define SITA_ERROR_RX_BREAK (0x80)
1066
1067#define SITA_PROTO_UNUSED (0x00) /* values of sita_phdr.proto */
1068#define SITA_PROTO_BOP_LAPB (0x01)
1069#define SITA_PROTO_ETHERNET (0x02)
1070#define SITA_PROTO_ASYNC_INTIO (0x03)
1071#define SITA_PROTO_ASYNC_BLKIO (0x04)
1072#define SITA_PROTO_ALC (0x05)
1073#define SITA_PROTO_UTS (0x06)
1074#define SITA_PROTO_PPP_HDLC (0x07)
1075#define SITA_PROTO_SDLC (0x08)
1076#define SITA_PROTO_TOKENRING (0x09)
1077#define SITA_PROTO_I2C (0x10)
1078#define SITA_PROTO_DPM_LINK (0x11)
1079#define SITA_PROTO_BOP_FRL (0x12)
1080
1082 uint8_t sita_flags;
1083 uint8_t sita_signals;
1084 uint8_t sita_errors1;
1085 uint8_t sita_errors2;
1086 uint8_t sita_proto;
1087};
1088
1089/*pseudo header for Bluetooth HCI*/
1091 bool sent;
1092 uint32_t channel;
1093};
1094
1095#define BTHCI_CHANNEL_COMMAND 1
1096#define BTHCI_CHANNEL_ACL 2
1097#define BTHCI_CHANNEL_SCO 3
1098#define BTHCI_CHANNEL_EVENT 4
1099#define BTHCI_CHANNEL_ISO 5
1100
1101/* pseudo header for WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR */
1103 uint16_t adapter_id;
1104 uint16_t opcode;
1105};
1106
1107/* pseudo header for WTAP_ENCAP_LAYER1_EVENT */
1109 bool uton;
1110};
1111
1112/* * I2C pseudo header */
1113struct i2c_phdr {
1114 uint8_t is_event;
1115 uint8_t bus;
1116 uint32_t flags;
1117};
1118
1119/* pseudo header for WTAP_ENCAP_GSM_UM */
1121 bool uplink;
1122 uint8_t channel;
1123 /* The following are only populated for downlink */
1124 uint8_t bsic;
1125 uint16_t arfcn;
1126 uint32_t tdma_frame;
1127 uint8_t error;
1128 uint16_t timeshift;
1129};
1130
1131#define GSM_UM_CHANNEL_UNKNOWN 0
1132#define GSM_UM_CHANNEL_BCCH 1
1133#define GSM_UM_CHANNEL_SDCCH 2
1134#define GSM_UM_CHANNEL_SACCH 3
1135#define GSM_UM_CHANNEL_FACCH 4
1136#define GSM_UM_CHANNEL_CCCH 5
1137#define GSM_UM_CHANNEL_RACH 6
1138#define GSM_UM_CHANNEL_AGCH 7
1139#define GSM_UM_CHANNEL_PCH 8
1140
1141/* Pseudo-header for nstrace packets */
1143 int64_t rec_offset;
1144 int32_t rec_len;
1145 uint8_t nicno_offset;
1146 uint8_t nicno_len;
1147 uint8_t dir_offset;
1148 uint8_t dir_len;
1149 uint16_t eth_offset;
1150 uint8_t pcb_offset;
1151 uint8_t l_pcb_offset;
1152 uint8_t rec_type;
1153 uint8_t vlantag_offset;
1154 uint8_t coreid_offset;
1155 uint8_t srcnodeid_offset;
1156 uint8_t destnodeid_offset;
1157 uint8_t clflags_offset;
1158 uint8_t src_vmname_len_offset;
1159 uint8_t dst_vmname_len_offset;
1160 uint8_t ns_activity_offset;
1161 uint8_t data_offset;
1162};
1163
1164/* Packet "pseudo-header" for Nokia output */
1166 struct eth_phdr eth;
1167 uint8_t stuff[4]; /* mysterious stuff */
1168};
1169
1170#define LLCP_PHDR_FLAG_SENT 0
1172 uint8_t adapter;
1173 uint8_t flags;
1174};
1175
1176/* pseudo header for WTAP_ENCAP_LOGCAT */
1178 int version;
1179};
1180
1181/* Packet "pseudo-header" information for header data from NetMon files. */
1182
1184 uint8_t* title; /* Comment title, as a null-terminated UTF-8 string */
1185 uint32_t descLength; /* Number of bytes in the comment description */
1186 uint8_t* description; /* Comment description, in ASCII RTF */
1187 unsigned sub_encap; /* "Real" encap value for the record that will be used once pseudo header data is display */
1189 struct eth_phdr eth;
1190 struct atm_phdr atm;
1191 struct ieee_802_11_phdr ieee_802_11;
1192 } subheader;
1193};
1194
1195/* Record "pseudo-header" information for header data from MS ProcMon files. */
1196
1198 bool system_bitness; /* System bitness: 1 if the system is 64 bit, 0 otherwise. */
1199};
1200
1201/* File "pseudo-header" for BER data files. */
1202struct ber_phdr {
1203 const char *pathname; /* Path name of file. */
1204};
1205
1206/* File "pseudo-header" for M-Module files. */
1208 uint8_t chunktype;
1209};
1210
1212 struct eth_phdr eth;
1213 struct dte_dce_phdr dte_dce;
1214 struct isdn_phdr isdn;
1215 struct atm_phdr atm;
1216 struct ascend_phdr ascend;
1217 struct p2p_phdr p2p;
1218 struct ieee_802_11_phdr ieee_802_11;
1219 struct cosine_phdr cosine;
1220 struct irda_phdr irda;
1221 struct nettl_phdr nettl;
1222 struct mtp2_phdr mtp2;
1223 struct k12_phdr k12;
1224 struct lapd_phdr lapd;
1225 struct catapult_dct2000_phdr dct2000;
1226 struct erf_mc_phdr erf;
1227 struct sita_phdr sita;
1228 struct bthci_phdr bthci;
1229 struct btmon_phdr btmon;
1230 struct l1event_phdr l1event;
1231 struct i2c_phdr i2c;
1232 struct gsm_um_phdr gsm_um;
1233 struct nstr_phdr nstr;
1234 struct nokia_phdr nokia;
1235 struct llcp_phdr llcp;
1236 struct logcat_phdr logcat;
1237 struct netmon_phdr netmon;
1238 struct procmon_phdr procmon;
1239 struct ber_phdr ber;
1240 struct mmodule_phdr mmodule;
1241};
1242
1243/*
1244 * Record type values.
1245 *
1246 * This list will expand over time, so don't assume everything will
1247 * forever be one of the types listed below.
1248 *
1249 * For file-type-specific records, the "ftsrec" field of the pseudo-header
1250 * contains a file-type-specific subtype value, such as a block type for
1251 * a pcapng file.
1252 *
1253 * An "event" is an indication that something happened during the capture
1254 * process, such as a status transition of some sort on the network.
1255 * These should, ideally, have a time stamp and, if they're relevant to
1256 * a particular interface on a multi-interface capture, should also have
1257 * an interface ID. The data for the event is file-type-specific and
1258 * subtype-specific. These should be dissected and displayed just as
1259 * packets are.
1260 *
1261 * A "report" supplies information not corresponding to an event;
1262 * for example, a pcapng Interface Statistics Block would be a report,
1263 * as it doesn't correspond to something happening on the network.
1264 * They may have a time stamp, and should be dissected and displayed
1265 * just as packets are.
1266 *
1267 * We distinguish between "events" and "reports" so that, for example,
1268 * the packet display can show the delta between a packet and an event
1269 * but not show the delta between a packet and a report, as the time
1270 * stamp of a report may not correspond to anything interesting on
1271 * the network but the time stamp of an event would.
1272 *
1273 * XXX - are there any file-type-specific records that *shouldn't* be
1274 * dissected and displayed? If so, they should be parsed and the
1275 * information in them stored somewhere, and used somewhere, whether
1276 * it's just used when saving the file in its native format or also
1277 * used to parse *other* file-type-specific records.
1278 *
1279 * These would be similar to, for example, pcapng Interface Description
1280 * Blocks, for which the position within the file is significant only
1281 * in that an IDB for an interface must appear before any packets from
1282 * the interface; the fact that an IDB appears at some point doesn't
1283 * necessarily mean something happened in the capture at that point.
1284 * Name Resolution Blocks are another example of such a record.
1285 *
1286 * (XXX - if you want to have a record that says "this interface first
1287 * showed up at this time", that needs to be a separate record type
1288 * from the IDB. We *could* add a "New Interface Description Block",
1289 * with a time stamp, for that purpose, but we'd *still* have to
1290 * provide IDBs for those interfaces, for compatibility with programs
1291 * that don't know about the NIDB. An ISB with only an isb_starttime
1292 * option would suffice for this purpose, so nothing needs to be
1293 * added to pcapng for this.)
1294 */
1295#define REC_TYPE_PACKET 0
1296#define REC_TYPE_FT_SPECIFIC_EVENT 1
1297#define REC_TYPE_FT_SPECIFIC_REPORT 2
1298#define REC_TYPE_SYSCALL 3
1299#define REC_TYPE_SYSTEMD_JOURNAL_EXPORT 4
1300#define REC_TYPE_CUSTOM_BLOCK 5
1302typedef struct {
1303 uint32_t caplen; /* data length in the file */
1304 uint32_t len; /* data length on the wire */
1305 int pkt_encap; /* WTAP_ENCAP_ value for this packet */
1306 /* pcapng variables */
1307 uint32_t interface_id; /* identifier of the interface. */
1308 /* options */
1309
1310 union wtap_pseudo_header pseudo_header;
1312
1313/*
1314 * The pcapng specification says "The word is encoded as an unsigned
1315 * 32-bit integer, using the endianness of the Section Header Block
1316 * scope it is in. In the following table, the bits are numbered with
1317 * 0 being the most-significant bit and 31 being the least-significant
1318 * bit of the 32-bit unsigned integer."
1319 *
1320 * From that, the direction, in bits 0 and 1, is at the *top* of the word.
1321 *
1322 * However, several implementations, such as:
1323 *
1324 * the Wireshark pcapng file reading code;
1325 *
1326 * macOS libpcap and tcpdump;
1327 *
1328 * text2pcap;
1329 *
1330 * and probably the software that generated the capture in bug 11665;
1331 *
1332 * treat 0 as the *least*-significant bit and bit 31 being the *most*-
1333 * significant bit of the flags word, and put the direction at the
1334 * *bottom* of the word.
1335 *
1336 * For now, we go with the known implementations.
1337 */
1338
1339/* Direction field of the packet flags */
1340#define PACK_FLAGS_DIRECTION_MASK 0x00000003 /* unshifted */
1341#define PACK_FLAGS_DIRECTION_SHIFT 0
1342#define PACK_FLAGS_DIRECTION(pack_flags) (((pack_flags) & PACK_FLAGS_DIRECTION_MASK) >> PACK_FLAGS_DIRECTION_SHIFT)
1343#define PACK_FLAGS_DIRECTION_UNKNOWN 0
1344#define PACK_FLAGS_DIRECTION_INBOUND 1
1345#define PACK_FLAGS_DIRECTION_OUTBOUND 2
1346
1347/* Reception type field of the packet flags */
1348#define PACK_FLAGS_RECEPTION_TYPE_MASK 0x0000001C /* unshifted */
1349#define PACK_FLAGS_RECEPTION_TYPE_SHIFT 2
1350#define PACK_FLAGS_RECEPTION_TYPE(pack_flags) (((pack_flags) & PACK_FLAGS_RECEPTION_TYPE_MASK) >> PACK_FLAGS_RECEPTION_TYPE_SHIFT)
1351#define PACK_FLAGS_RECEPTION_TYPE_UNSPECIFIED 0
1352#define PACK_FLAGS_RECEPTION_TYPE_UNICAST 1
1353#define PACK_FLAGS_RECEPTION_TYPE_MULTICAST 2
1354#define PACK_FLAGS_RECEPTION_TYPE_BROADCAST 3
1355#define PACK_FLAGS_RECEPTION_TYPE_PROMISCUOUS 4
1356
1357/* FCS length field of the packet flags */
1358#define PACK_FLAGS_FCS_LENGTH_MASK 0x000001E0 /* unshifted */
1359#define PACK_FLAGS_FCS_LENGTH_SHIFT 5
1360#define PACK_FLAGS_FCS_LENGTH(pack_flags) (((pack_flags) & PACK_FLAGS_FCS_LENGTH_MASK) >> PACK_FLAGS_FCS_LENGTH_SHIFT)
1361
1362/* Reserved bits of the packet flags */
1363#define PACK_FLAGS_RESERVED_MASK 0x0000FE00
1364
1365/* Link-layer-dependent errors of the packet flags */
1366
1367/* For Ethernet and possibly some other network types */
1368#define PACK_FLAGS_CRC_ERROR 0x01000000
1369#define PACK_FLAGS_PACKET_TOO_LONG 0x02000000
1370#define PACK_FLAGS_PACKET_TOO_SHORT 0x04000000
1371#define PACK_FLAGS_WRONG_INTER_FRAME_GAP 0x08000000
1372#define PACK_FLAGS_UNALIGNED_FRAME 0x10000000
1373#define PACK_FLAGS_START_FRAME_DELIMITER_ERROR 0x20000000
1374#define PACK_FLAGS_PREAMBLE_ERROR 0x40000000
1375#define PACK_FLAGS_SYMBOL_ERROR 0x80000000
1376
1377/* Construct a pack_flags value from its subfield values */
1378#define PACK_FLAGS_VALUE(direction, reception_type, fcs_length, ll_dependent_errors) \
1379 (((direction) << 30) | \
1380 ((reception_type) << 27) | \
1381 ((fcs_length) << 23) | \
1382 (ll_dependent_errors))
1383
1384typedef struct {
1385 int file_type_subtype; /* the type of file this is for */
1386 unsigned record_type; /* the type of record this is - file type-specific value */
1387 uint32_t record_len; /* length of the record */
1388 union wtap_pseudo_header pseudo_header;
1389
1391
1392typedef struct {
1393 const char *pathname; /* Path name of file. */
1394 unsigned record_type; /* XXX match ft_specific_record_phdr so that we chain off of packet-pcapng_block for now. */
1395 int byte_order;
1396 /* uint32_t sentinel; */
1397 uint64_t timestamp; /* ns since epoch - XXX dup of ts */
1398 uint64_t thread_id;
1399 uint32_t event_len; /* length of the event (ppm event len) */
1400 uint32_t event_data_len; /* length of the event data (ppm event len - ppm event header len) */
1401 uint32_t nparams; /* number of parameters of the event */
1402 uint32_t flags;
1403 uint16_t event_type;
1404 uint16_t cpu_id;
1405 /* ... Event ... */
1407
1408typedef struct {
1409 uint32_t record_len; /* length of the record */
1411
1412typedef struct {
1413 uint32_t pen; /* private enterprise number */
1414 uint32_t length; /* length of the Custom Data plus options */
1415 bool copy_allowed; /* CB can be written */
1417
1418/*
1419 * The largest nstime.secs value that can be put into an unsigned
1420 * 32-bit quantity.
1421 *
1422 * We assume that time_t is signed; it is signed on Windows/MSVC and
1423 * on many UN*Xes.
1424 *
1425 * So, if time_t is 32-bit, we define this as INT32_MAX, as that's
1426 * the largest value a time_t can have, and it fits in an unsigned
1427 * 32-bit quantity. If it's 64-bit or larger, we define this as
1428 * UINT32_MAX, as, even if it's signed, it can be as large as
1429 * UINT32_MAX, and that's the largest value that can fit in
1430 * a 32-bit unsigned quantity.
1431 *
1432 * Comparing against this, rather than against G_MAXINT2, when checking
1433 * whether a time stamp will fit in a 32-bit unsigned integer seconds
1434 * field in a capture file being written avoids signed vs. unsigned
1435 * warnings if time_t is a signed 32-bit type.
1436 *
1437 * XXX - what if time_t is unsigned? Are there any platforms where
1438 * it is?
1439 */
1440#define WTAP_NSTIME_32BIT_SECS_MAX ((time_t)(sizeof(time_t) > sizeof(int32_t) ? UINT32_MAX : INT32_MAX))
1441
1442typedef struct wtap_rec {
1443 unsigned rec_type; /* what type of record is this? */
1444 uint32_t presence_flags; /* what stuff do we have? */
1445 unsigned section_number; /* section, within file, containing this record */
1446 nstime_t ts; /* time stamp */
1447 int tsprec; /* WTAP_TSPREC_ value for this record */
1448 const char *rec_type_name; /* name of this record type */
1449 union {
1450 wtap_packet_header packet_header;
1451 wtap_ft_specific_header ft_specific_header;
1452 wtap_syscall_header syscall_header;
1453 wtap_systemd_journal_export_header systemd_journal_export_header;
1454 wtap_custom_block_header custom_block_header;
1455 } rec_header;
1456
1457 /*
1458 * XXX - some if not all of the rec_header information may belong
1459 * here, or may already be here. Eliminating rec_header in favor
1460 * of this might simplify the process of adding new record/block
1461 * types. For example, some of it might belong in block->mandatory_data.
1462 *
1463 * It also has a type field that's somewhat equivalent to rec_type.
1464 *
1465 * It's null for some record types.
1466 */
1467 wtap_block_t block; /* block information */
1468 bool block_was_modified; /* true if ANY aspect of the block has been modified */
1469
1470 /*
1471 * We use a Buffer so that we don't have to allocate and free
1472 * a buffer for the options for each record.
1473 */
1474 Buffer options_buf; /* file-type specific data */
1475
1476 /* Buffer for the record data. */
1477 Buffer data;
1478} wtap_rec;
1479
1480/*
1481 * Bits in presence_flags, indicating which of the fields we have.
1482 *
1483 * For the time stamp, we may need some more flags to indicate
1484 * whether the time stamp is an absolute date-and-time stamp, an
1485 * absolute time-only stamp (which can make relative time
1486 * calculations tricky, as you could in theory have two time
1487 * stamps separated by an unknown number of days), or a time stamp
1488 * relative to some unspecified time in the past (see mpeg.c).
1489 *
1490 * There is no presence flag for len - there has to be *some* length
1491 * value for the packet. (The "captured length" can be missing if
1492 * the file format doesn't report a captured length distinct from
1493 * the on-the-network length because the application(s) producing those
1494 * files don't support slicing packets.)
1495 *
1496 * There could be a presence flag for the packet encapsulation - if it's
1497 * absent, use the file encapsulation - but it's not clear that's useful;
1498 * we currently do that in the module for the file format.
1499 *
1500 * Only WTAP_HAS_TS and WTAP_HAS_SECTION_NUMBER apply to all record types.
1501 */
1502#define WTAP_HAS_TS 0x00000001
1503#define WTAP_HAS_CAP_LEN 0x00000002
1504#define WTAP_HAS_INTERFACE_ID 0x00000004
1505#define WTAP_HAS_SECTION_NUMBER 0x00000008
1507/*
1508 * The old max name length define, both for backwards compatibility and because
1509 * other name types (in epan) use it. While Name Resolution Blocks (NRBs) only
1510 * support IPv4 and IPv6 currently, they could later support other name types.
1511 */
1512#ifndef MAXNAMELEN
1513#define MAXNAMELEN 64 /* max name length (most names: DNS labels, services, eth) */
1514#endif
1515
1516#ifndef MAXDNSNAMELEN
1517#define MAXDNSNAMELEN 256 /* max total length of a domain name in DNS */
1518#endif
1519
1520typedef struct hashipv4 {
1521 unsigned addr;
1522 uint8_t flags; /* B0 dummy_entry, B1 resolve, B2 If the address is used in the trace */
1523 char ip[WS_INET_ADDRSTRLEN];
1524 char name[MAXDNSNAMELEN];
1525 char cidr_addr[WS_INET_CIDRADDRSTRLEN];
1526} hashipv4_t;
1527
1528typedef struct hashipv6 {
1529 uint8_t addr[16];
1530 uint8_t flags; /* B0 dummy_entry, B1 resolve, B2 If the address is used in the trace */
1531 char ip6[WS_INET6_ADDRSTRLEN];
1532 char name[MAXDNSNAMELEN];
1533} hashipv6_t;
1534
1542
1583
1584/* Zero-initializer for wtap_dump_params. */
1585#define WTAP_DUMP_PARAMS_INIT {.snaplen=0}
1586
1587struct wtap_dumper;
1588
1589typedef struct wtap wtap;
1590typedef struct wtap_dumper wtap_dumper;
1591
1592typedef struct wtap_reader *FILE_T;
1593
1594/* Similar to the wtap_open_routine_info for open routines, the following
1595 * wtap_wslua_file_info struct is used by wslua code for Lua-based file writers.
1596 *
1597 * This concept is necessary because when wslua goes to invoke the
1598 * registered dump/write_open routine callback in Lua, it needs the ref number representing
1599 * the hooked function inside Lua. This will be stored in the thing pointed to
1600 * by the void* data here. This 'data' pointer will be copied into the
1601 * wtap_dumper struct's 'void* data' member when calling the dump_open function,
1602 * which is how wslua finally retrieves it. Unlike wtap_dumper's 'priv' member, its
1603 * 'data' member is not free'd in wtap_dump_close().
1604 */
1605typedef struct wtap_wslua_file_info {
1606 int (*wslua_can_write_encap)(int, void*); /* a can_write_encap func for wslua uses */
1607 void* wslua_data; /* holds the wslua data */
1609
1610/*
1611 * For registering extensions used for file formats.
1612 *
1613 * These items are used in dialogs for opening files, so that
1614 * the user can ask to see all capture files (as identified
1615 * by file extension) or particular types of capture files.
1616 *
1617 * Each item has a human-readable description of the file types
1618 * (possibly more than one!) that use all of this set of extensions,
1619 * a flag indicating whether it's a capture file or just some file
1620 * whose contents we can dissect, and a list of extensions files of
1621 * that type might have.
1622 *
1623 * Note that entries in this table do *not* necessarily correspond
1624 * to single file types; for example, the entry that lists just "cap"
1625 * is for several file formats, all of which use the extension ".cap".
1626 *
1627 * Also note that a given extension may appear in multiple entries;
1628 * for example, "cap" (again!) is in an entry for some file types
1629 * that use only ".cap" and in entries for file types that use
1630 * ".cap" and some other extensions, and ".trc" is used both for
1631 * DOS Sniffer Token Ring captures ("trc") and EyeSDN USB ISDN
1632 * trace files ("tr{a}c{e}").
1633 *
1634 * Some entries aren't for capture file types, they're just generic types,
1635 * such as "text file" or "XML file", that can be used for, among other
1636 * things, captures we can read, or for file formats we can read in
1637 * order to dissect the contents of the file (think of this as "Fileshark",
1638 * which is a program that we really should have). Those are marked
1639 * specially, because, in file section dialogs, the user should be able
1640 * to select "All Capture Files" and get a set of extensions that are
1641 * associated with capture file formats, but not with files in other
1642 * formats that might or might not contain captured packets (such as
1643 * .txt or .xml") or formats that aren't capture files but that we
1644 * support as "we're being Fileshark now" (such as .jpeg). The routine
1645 * that constructs a list of extensions for "All Capture Files" omits
1646 * extensions for those entries.
1647 */
1649 /* the file type description */
1650 const char *name;
1651
1652 /* true if this is a capture file type */
1653 bool is_capture_file;
1654
1655 /* a semicolon-separated list of file extensions used for this type */
1656 const char *extensions;
1657};
1658
1659/*
1660 * For registering file types that we can open.
1661 *
1662 * Each file type has an open routine.
1663 *
1664 * The open routine should return:
1665 *
1666 * WTAP_OPEN_ERROR on an I/O error;
1667 *
1668 * WTAP_OPEN_MINE if the file it's reading is one of the types
1669 * it handles;
1670 *
1671 * WTAP_OPEN_NOT_MINE if the file it's reading isn't one of the
1672 * types it handles.
1673 *
1674 * If the routine handles this type of file, it should set the
1675 * "file_type_subtype" field in the "struct wtap" to the type of the file.
1676 *
1677 * Note that the routine does not have to free the private data pointer on
1678 * error. The caller takes care of that by calling wtap_close on error.
1679 * (See https://gitlab.com/wireshark/wireshark/-/issues/8518)
1680 *
1681 * However, the caller does have to free the private data pointer when
1682 * returning WTAP_OPEN_NOT_MINE, since the next file type will be called
1683 * and will likely just overwrite the pointer.
1684 */
1685typedef enum {
1686 WTAP_OPEN_NOT_MINE = 0,
1687 WTAP_OPEN_MINE = 1,
1688 WTAP_OPEN_ERROR = -1
1689} wtap_open_return_val;
1690
1691typedef wtap_open_return_val (*wtap_open_routine_t)(struct wtap*, int *,
1692 char **);
1693
1694/*
1695 * Some file formats have defined magic numbers at fixed offsets from
1696 * the beginning of the file; those routines should return 1 if and
1697 * only if the file has the magic number at that offset. (pcapng
1698 * is a bit of a special case, as it has both the Section Header Block
1699 * type field and its byte-order magic field; it checks for both.)
1700 * Those file formats do not require a file name extension in order
1701 * to recognize them or to avoid recognizing other file types as that
1702 * type, and have no extensions specified for them.
1703 *
1704 * Other file formats don't have defined magic numbers at fixed offsets,
1705 * so a heuristic is required. If that file format has any file name
1706 * extensions used for it, a list of those extensions should be
1707 * specified, so that, if the name of the file being opened has an
1708 * extension, the file formats that use that extension are tried before
1709 * the ones that don't, to handle the case where a file of one type
1710 * might be recognized by the heuristics for a different file type.
1711 */
1712typedef enum {
1713 OPEN_INFO_MAGIC = 0,
1714 OPEN_INFO_HEURISTIC = 1
1715} wtap_open_type;
1716
1717WS_DLL_PUBLIC void init_open_routines(void);
1718
1719void cleanup_open_routines(void);
1720
1721/*
1722 * Information about a given file type that applies to all subtypes of
1723 * the file type.
1724 *
1725 * Each file type has:
1726 *
1727 * a human-readable description of the file type, for use in the
1728 * user interface;
1729 * a wtap_open_type indication of how the open routine
1730 * determines whether a file is of that type;
1731 * an open routine;
1732 * an optional list of extensions used for this file type;
1733 * data to be passed to Lua file readers - this should be NULL for
1734 * non-Lua (C) file readers.
1735 *
1736 * The list of file extensions is used as a hint when calling open routines
1737 * to open a file; heuristic open routines whose list of extensions includes
1738 * the file's extension are called before heuristic open routines whose
1739 * (possibly-empty) list of extensions doesn't contain the file's extension,
1740 * to reduce the chances that a file will be misidentified due to an heuristic
1741 * test with a weak heuristic being done before a heuristic test for the
1742 * file's type.
1743 *
1744 * The list of extensions should be NULL for magic-number open routines,
1745 * as it will not be used for any purpose (no such hinting is done).
1746 */
1748 const char *name; /* Description */
1749 wtap_open_type type; /* Open routine type */
1750 wtap_open_routine_t open_routine; /* Open routine */
1751 const char *extensions; /* List of extensions used for this file type */
1752 char **extensions_set; /* Array of those extensions; populated using extensions member during initialization */
1753 void* wslua_data; /* Data for Lua file readers */
1754};
1755WS_DLL_PUBLIC struct open_info *open_routines;
1756
1757/*
1758 * Types of comments.
1759 */
1760#define WTAP_COMMENT_PER_SECTION 0x00000001 /* per-file/per-file-section */
1761#define WTAP_COMMENT_PER_INTERFACE 0x00000002 /* per-interface */
1762#define WTAP_COMMENT_PER_PACKET 0x00000004 /* per-packet */
1763
1764/*
1765 * For a given option type in a certain block type, does a file format
1766 * not support it, support only one such option, or support multiple
1767 * such options?
1768 */
1769typedef enum {
1770 OPTION_NOT_SUPPORTED,
1771 ONE_OPTION_SUPPORTED,
1772 MULTIPLE_OPTIONS_SUPPORTED
1773} option_support_t;
1774
1775/*
1776 * Entry in a table of supported option types.
1777 */
1779 unsigned opt;
1780 option_support_t support; /* OPTION_NOT_SUPPORTED allowed, equivalent to absence */
1781};
1782
1783#define OPTION_TYPES_SUPPORTED(option_type_array) \
1784 array_length(option_type_array), option_type_array
1785
1786#define NO_OPTIONS_SUPPORTED \
1787 0, NULL
1788
1789/*
1790 * For a given block type, does a file format not support it, support
1791 * only one such block, or support multiple such blocks?
1792 */
1793typedef enum {
1794 BLOCK_NOT_SUPPORTED,
1795 ONE_BLOCK_SUPPORTED,
1796 MULTIPLE_BLOCKS_SUPPORTED
1797} block_support_t;
1798
1799/*
1800 * Entry in a table of supported block types.
1801 */
1803 wtap_block_type_t type;
1804 block_support_t support; /* BLOCK_NOT_SUPPORTED allowed, equivalent to absence */
1805 size_t num_supported_options;
1806 const struct supported_option_type *supported_options;
1807};
1808
1809#define BLOCKS_SUPPORTED(block_type_array) \
1810 array_length(block_type_array), block_type_array
1811
1816 const char *description;
1817
1822 const char *name;
1823
1829
1837
1842
1847
1852
1861 int (*can_write_encap)(int);
1862
1867 bool (*dump_open)(wtap_dumper *, int *, char **);
1868
1874};
1875
1876#define WTAP_TYPE_AUTO 0
1877
1883WS_DLL_PUBLIC
1884void wtap_init(bool load_wiretap_plugins);
1885
1898WS_DLL_PUBLIC
1899struct wtap* wtap_open_offline(const char *filename, unsigned int type, int *err,
1900 char **err_info, bool do_random);
1901
1907WS_DLL_PUBLIC
1908void wtap_cleareof(wtap *wth);
1909
1914typedef void (*wtap_new_ipv4_callback_t) (const unsigned addr, const char *name, const bool static_entry);
1915WS_DLL_PUBLIC
1916void wtap_set_cb_new_ipv4(wtap *wth, wtap_new_ipv4_callback_t add_new_ipv4);
1917
1918typedef void (*wtap_new_ipv6_callback_t) (const ws_in6_addr *addrp, const char *name, const bool static_entry);
1919WS_DLL_PUBLIC
1920void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6);
1921
1926typedef void (*wtap_new_secrets_callback_t)(uint32_t secrets_type, const void *secrets, unsigned size);
1927WS_DLL_PUBLIC
1928void wtap_set_cb_new_secrets(wtap *wth, wtap_new_secrets_callback_t add_new_secrets);
1929
1944WS_DLL_PUBLIC
1945bool wtap_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
1946 int64_t *offset);
1947
1963WS_DLL_PUBLIC
1964bool wtap_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
1965 int *err, char **err_info);
1966
1967/*** initialize a wtap_rec structure ***/
1968WS_DLL_PUBLIC
1969void wtap_rec_init(wtap_rec *rec, gsize space);
1970
1971/*** Apply a snapshot value ***/
1972WS_DLL_PUBLIC
1973void wtap_rec_apply_snapshot(wtap_rec *rec, uint32_t snaplen);
1974
1975/*** Re-initialize a wtap_rec structure ***/
1976WS_DLL_PUBLIC
1977void wtap_rec_reset(wtap_rec *rec);
1978
1979/*** clean up a wtap_rec structure, freeing what wtap_rec_init() allocated */
1980WS_DLL_PUBLIC
1981void wtap_rec_cleanup(wtap_rec *rec);
1982
1986WS_DLL_PUBLIC
1988
1992WS_DLL_PUBLIC
1993void wtap_setup_packet_rec(wtap_rec *rec, int encap);
1994
1999WS_DLL_PUBLIC
2000void wtap_setup_ft_specific_event_rec(wtap_rec *rec, int file_type_subtype,
2001 unsigned record_type);
2002
2007WS_DLL_PUBLIC
2008void wtap_setup_ft_specific_report_rec(wtap_rec *rec, int file_type_subtype,
2009 unsigned record_type);
2010
2014WS_DLL_PUBLIC
2016
2021WS_DLL_PUBLIC
2023
2027WS_DLL_PUBLIC
2028void wtap_setup_custom_block_rec(wtap_rec *rec, uint32_t pen,
2029 uint32_t payload_length, bool copy_allowed);
2030
2031/*
2032 * Types of compression for a file, including "none".
2033 */
2034typedef enum {
2035 WTAP_UNCOMPRESSED,
2036 WTAP_GZIP_COMPRESSED,
2037 WTAP_ZSTD_COMPRESSED,
2038 WTAP_LZ4_COMPRESSED,
2039 WTAP_UNKNOWN_COMPRESSION,
2040} wtap_compression_type;
2041
2042WS_DLL_PUBLIC
2043wtap_compression_type wtap_get_compression_type(wtap *wth);
2044WS_DLL_PUBLIC
2045wtap_compression_type wtap_name_to_compression_type(const char *name);
2046WS_DLL_PUBLIC
2047wtap_compression_type wtap_extension_to_compression_type(const char *ext);
2048WS_DLL_PUBLIC
2049const char *wtap_compression_type_description(wtap_compression_type compression_type);
2050WS_DLL_PUBLIC
2051const char *wtap_compression_type_extension(wtap_compression_type compression_type);
2052WS_DLL_PUBLIC
2053const char *wtap_compression_type_name(wtap_compression_type compression_type);
2054WS_DLL_PUBLIC
2055GSList *wtap_get_all_compression_type_extensions_list(void);
2056WS_DLL_PUBLIC
2057GSList *wtap_get_all_output_compression_type_names_list(void);
2058WS_DLL_PUBLIC
2059bool wtap_can_write_compression_type(wtap_compression_type compression_type);
2060
2061/*** get various information snippets about the current file ***/
2062
2065WS_DLL_PUBLIC
2066int64_t wtap_read_so_far(wtap *wth);
2067WS_DLL_PUBLIC
2068int64_t wtap_file_size(wtap *wth, int *err);
2069WS_DLL_PUBLIC
2070unsigned wtap_snapshot_length(wtap *wth); /* per file */
2071WS_DLL_PUBLIC
2072int wtap_file_type_subtype(wtap *wth);
2073WS_DLL_PUBLIC
2074int wtap_file_encap(wtap *wth);
2075WS_DLL_PUBLIC
2076int wtap_file_tsprec(wtap *wth);
2077WS_DLL_PUBLIC
2078const nstime_t* wtap_file_start_ts(wtap *wth);
2079WS_DLL_PUBLIC
2080const nstime_t* wtap_file_end_ts(wtap *wth);
2081
2089WS_DLL_PUBLIC
2090unsigned wtap_file_get_num_shbs(wtap *wth);
2091
2104WS_DLL_PUBLIC
2105wtap_block_t wtap_file_get_shb(wtap *wth, unsigned shb_num);
2106
2117WS_DLL_PUBLIC
2118void wtap_write_shb_comment(wtap *wth, char *comment);
2119
2131WS_DLL_PUBLIC
2132unsigned wtap_file_get_shb_global_interface_id(wtap *wth, unsigned shb_num, uint32_t interface_id);
2133
2144WS_DLL_PUBLIC
2146
2147
2148WS_DLL_PUBLIC
2149wtapng_dpib_lookup_info_t * wtap_file_get_dpib_lookup_info(wtap *wth);
2150
2160WS_DLL_PUBLIC
2162
2175WS_DLL_PUBLIC
2177
2189WS_DLL_PUBLIC
2190char *wtap_get_debug_if_descr(const wtap_block_t if_descr,
2191 const int indent,
2192 const char* line_end);
2193
2206WS_DLL_PUBLIC
2208
2216WS_DLL_PUBLIC
2217unsigned wtap_file_get_num_dsbs(wtap *wth);
2218
2229WS_DLL_PUBLIC
2230wtap_block_t wtap_file_get_dsb(wtap *wth, unsigned dsb_num);
2231
2240WS_DLL_PUBLIC
2242
2251WS_DLL_PUBLIC
2253
2254/*** close the file descriptors for the current file ***/
2255WS_DLL_PUBLIC
2256void wtap_fdclose(wtap *wth);
2257
2258/*** reopen the random file descriptor for the current file ***/
2259WS_DLL_PUBLIC
2260bool wtap_fdreopen(wtap *wth, const char *filename, int *err);
2261
2263WS_DLL_PUBLIC
2264void wtap_sequential_close(wtap *wth);
2265
2267WS_DLL_PUBLIC
2268void wtap_close(wtap *wth);
2269
2270/*** dump packets into a capture file ***/
2271WS_DLL_PUBLIC
2272bool wtap_dump_can_open(int filetype);
2273
2278WS_DLL_PUBLIC
2279int wtap_dump_required_file_encap_type(const GArray *file_encaps);
2280
2285WS_DLL_PUBLIC
2286bool wtap_dump_can_write_encap(int file_type_subtype, int encap);
2287
2292WS_DLL_PUBLIC
2293bool wtap_dump_can_compress(int file_type_subtype);
2294
2304WS_DLL_PUBLIC
2305void wtap_dump_params_init(wtap_dump_params *params, wtap *wth);
2306
2321WS_DLL_PUBLIC
2323
2331WS_DLL_PUBLIC
2333
2341WS_DLL_PUBLIC
2343
2350WS_DLL_PUBLIC
2352
2365WS_DLL_PUBLIC
2366wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype,
2367 wtap_compression_type compression_type, const wtap_dump_params *params,
2368 int *err, char **err_info);
2369
2385WS_DLL_PUBLIC
2386wtap_dumper* wtap_dump_open_tempfile(const char *tmpdir, char **filenamep,
2387 const char *pfx,
2388 int file_type_subtype, wtap_compression_type compression_type,
2389 const wtap_dump_params *params, int *err, char **err_info);
2390
2403WS_DLL_PUBLIC
2404wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype,
2405 wtap_compression_type compression_type, const wtap_dump_params *params,
2406 int *err, char **err_info);
2407
2419WS_DLL_PUBLIC
2420wtap_dumper* wtap_dump_open_stdout(int file_type_subtype,
2421 wtap_compression_type compression_type, const wtap_dump_params *params,
2422 int *err, char **err_info);
2423
2424/*
2425 * Add an IDB to the list of IDBs for a file we're writing.
2426 * Makes a copy of the IDB, so it can be freed after this call is made.
2427 *
2428 * @param wdh handle for the file we're writing.
2429 * @param idb the IDB to add
2430 * @param[out] err Will be set to an error code on failure.
2431 * @param[out] err_info for some errors, a string giving more details of
2432 * the error.
2433 * @return true on success, false on failure.
2434 */
2435WS_DLL_PUBLIC
2436bool wtap_dump_add_idb(wtap_dumper *wdh, wtap_block_t idb, int *err,
2437 char **err_info);
2438WS_DLL_PUBLIC
2439bool wtap_dump(wtap_dumper *, const wtap_rec *, int *err, char **err_info);
2440WS_DLL_PUBLIC
2441bool wtap_dump_flush(wtap_dumper *, int *);
2442WS_DLL_PUBLIC
2443int wtap_dump_file_type_subtype(const wtap_dumper *wdh);
2444WS_DLL_PUBLIC
2445int64_t wtap_get_bytes_dumped(const wtap_dumper *);
2446WS_DLL_PUBLIC
2447void wtap_set_bytes_dumped(wtap_dumper *wdh, int64_t bytes_dumped);
2448struct addrinfo;
2449WS_DLL_PUBLIC
2450bool wtap_addrinfo_list_empty(const addrinfo_lists_t *addrinfo_lists);
2451WS_DLL_PUBLIC
2452bool wtap_dump_set_addrinfo_list(wtap_dumper *wdh, addrinfo_lists_t *addrinfo_lists);
2453WS_DLL_PUBLIC
2454void wtap_dump_discard_name_resolution(wtap_dumper *wdh);
2455WS_DLL_PUBLIC
2456void wtap_dump_discard_decryption_secrets(wtap_dumper *wdh);
2457
2474WS_DLL_PUBLIC
2475bool wtap_dump_close(wtap_dumper *wdh, bool *needs_reload,
2476 int *err, char **err_info);
2477
2482WS_DLL_PUBLIC
2483bool wtap_dump_can_write(const GArray *file_encaps, uint32_t required_comment_types);
2484
2497WS_DLL_PUBLIC
2498void wtap_buffer_append_epdu_tag(Buffer *buf, uint16_t epdu_tag, const uint8_t *data, uint16_t data_len);
2499
2508WS_DLL_PUBLIC
2509void wtap_buffer_append_epdu_uint(Buffer *buf, uint16_t epdu_tag, uint32_t val);
2510
2519WS_DLL_PUBLIC
2520void wtap_buffer_append_epdu_string(Buffer *buf, uint16_t epdu_tag, const char *val);
2521
2530WS_DLL_PUBLIC
2532
2533/*
2534 * Sort the file types by name or by description?
2535 */
2536typedef enum {
2537 FT_SORT_BY_NAME,
2538 FT_SORT_BY_DESCRIPTION
2539} ft_sort_order;
2540
2546WS_DLL_PUBLIC
2547GArray *wtap_get_savable_file_types_subtypes_for_file(int file_type_subtype,
2548 const GArray *file_encaps, uint32_t required_comment_types,
2549 ft_sort_order sort_order);
2550
2554WS_DLL_PUBLIC
2555GArray *wtap_get_writable_file_types_subtypes(ft_sort_order sort_order);
2556
2557/*** various file type/subtype functions ***/
2558WS_DLL_PUBLIC
2559const char *wtap_file_type_subtype_description(int file_type_subtype);
2560WS_DLL_PUBLIC
2561const char *wtap_file_type_subtype_name(int file_type_subtype);
2562WS_DLL_PUBLIC
2563int wtap_name_to_file_type_subtype(const char *name);
2564WS_DLL_PUBLIC
2565int wtap_pcap_file_type_subtype(void);
2566WS_DLL_PUBLIC
2567int wtap_pcap_nsec_file_type_subtype(void);
2568WS_DLL_PUBLIC
2569int wtap_pcapng_file_type_subtype(void);
2570
2575WS_DLL_PUBLIC
2576block_support_t wtap_file_type_subtype_supports_block(int file_type_subtype,
2577 wtap_block_type_t type);
2578
2583WS_DLL_PUBLIC
2584option_support_t wtap_file_type_subtype_supports_option(int file_type_subtype,
2585 wtap_block_type_t type, unsigned opttype);
2586
2587/* Return a list of all extensions that are used by all capture file
2588 * types, including compressed extensions, e.g. not just "pcap" but
2589 * also "pcap.gz" if we can read gzipped files.
2590 *
2591 * "Capture files" means "include file types that correspond to
2592 * collections of network packets, but not file types that
2593 * store data that just happens to be transported over protocols
2594 * such as HTTP but that aren't collections of network packets",
2595 * so that it could be used for "All Capture Files" without picking
2596 * up JPEG files or files such as that - those aren't capture files,
2597 * and we *do* have them listed in the long list of individual file
2598 * types, so omitting them from "All Capture Files" is the right
2599 * thing to do.
2600 *
2601 * All strings in the list are allocated with g_malloc() and must be freed
2602 * with g_free().
2603 *
2604 * This is used to generate a list of extensions to look for if the user
2605 * chooses "All Capture Files" in a file open dialog.
2606 */
2607WS_DLL_PUBLIC
2608GSList *wtap_get_all_capture_file_extensions_list(void);
2609
2610/* Return a list of all extensions that are used by all file types that
2611 * we can read, including compressed extensions, e.g. not just "pcap" but
2612 * also "pcap.gz" if we can read gzipped files.
2613 *
2614 * "File type" means "include file types that correspond to collections
2615 * of network packets, as well as file types that store data that just
2616 * happens to be transported over protocols such as HTTP but that aren't
2617 * collections of network packets, and plain text files".
2618 *
2619 * All strings in the list are allocated with g_malloc() and must be freed
2620 * with g_free().
2621 */
2622WS_DLL_PUBLIC
2623GSList *wtap_get_all_file_extensions_list(void);
2624
2625/*
2626 * Free a list returned by wtap_get_file_extension_type_extensions(),
2627 * wtap_get_all_capture_file_extensions_list, wtap_get_file_extensions_list(),
2628 * or wtap_get_all_file_extensions_list().
2629 */
2630WS_DLL_PUBLIC
2631void wtap_free_extensions_list(GSList *extensions);
2632
2633/*
2634 * Return the default file extension to use with the specified file type
2635 * and subtype; that's just the extension, without any ".".
2636 */
2637WS_DLL_PUBLIC
2638const char *wtap_default_file_extension(int file_type_subtype);
2639
2640/* Return a list of file extensions that are used by the specified file type
2641 * and subtype.
2642 *
2643 * If include_compressed is true, the list will include compressed
2644 * extensions, e.g. not just "pcap" but also "pcap.gz" if we can read
2645 * gzipped files.
2646 *
2647 * All strings in the list are allocated with g_malloc() and must be freed
2648 * with g_free().
2649 */
2650WS_DLL_PUBLIC
2651GSList *wtap_get_file_extensions_list(int file_type_subtype, bool include_compressed);
2652
2653WS_DLL_PUBLIC
2654const char *wtap_encap_name(int encap);
2655WS_DLL_PUBLIC
2656const char *wtap_encap_description(int encap);
2657WS_DLL_PUBLIC
2658int wtap_name_to_encap(const char *short_name);
2659
2660WS_DLL_PUBLIC
2661const char* wtap_tsprec_string(int tsprec);
2662
2663WS_DLL_PUBLIC
2664const char *wtap_strerror(int err);
2665
2666/*** get available number of file types and encapsulations ***/
2667WS_DLL_PUBLIC
2668int wtap_get_num_file_type_extensions(void);
2669WS_DLL_PUBLIC
2670int wtap_get_num_encap_types(void);
2671
2672/*** get information for file type extension ***/
2673WS_DLL_PUBLIC
2674const char *wtap_get_file_extension_type_name(int extension_type);
2675WS_DLL_PUBLIC
2676GSList *wtap_get_file_extension_type_extensions(unsigned extension_type);
2677
2678/*** dynamically register new file types and encapsulations ***/
2679WS_DLL_PUBLIC
2680void wtap_register_file_type_extension(const struct file_extension_info *ei);
2681
2682typedef struct {
2683 void (*register_wtap_module)(void); /* routine to call to register a wiretap module */
2684} wtap_plugin;
2685
2686WS_DLL_PUBLIC
2687void wtap_register_plugin(const wtap_plugin *plug);
2688
2694WS_DLL_PUBLIC
2695int wtap_plugins_supported(void);
2696
2697WS_DLL_PUBLIC
2698void wtap_register_open_info(struct open_info *oi, const bool first_routine);
2699WS_DLL_PUBLIC
2700bool wtap_has_open_info(const char *name);
2701WS_DLL_PUBLIC
2702bool wtap_uses_lua_filehandler(const wtap* wth);
2703WS_DLL_PUBLIC
2704void wtap_deregister_open_info(const char *name);
2705
2706WS_DLL_PUBLIC
2707unsigned int open_info_name_to_type(const char *name);
2708WS_DLL_PUBLIC
2709int wtap_register_file_type_subtype(const struct file_type_subtype_info* fi);
2710WS_DLL_PUBLIC
2711void wtap_deregister_file_type_subtype(const int file_type_subtype);
2712
2713WS_DLL_PUBLIC
2714int wtap_register_encap_type(const char *description, const char *name);
2715
2716/*** Cleanup the internal library structures */
2717WS_DLL_PUBLIC
2718void wtap_cleanup(void);
2719
2723#define WTAP_ERR_NOT_REGULAR_FILE -1
2726#define WTAP_ERR_RANDOM_OPEN_PIPE -2
2729#define WTAP_ERR_FILE_UNKNOWN_FORMAT -3
2732#define WTAP_ERR_UNSUPPORTED -4
2736#define WTAP_ERR_CANT_WRITE_TO_PIPE -5
2739#define WTAP_ERR_CANT_OPEN -6
2742#define WTAP_ERR_UNWRITABLE_FILE_TYPE -7
2745#define WTAP_ERR_UNWRITABLE_ENCAP -8
2749#define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED -9
2752#define WTAP_ERR_CANT_WRITE -10
2755#define WTAP_ERR_CANT_CLOSE -11
2758#define WTAP_ERR_SHORT_READ -12
2761#define WTAP_ERR_BAD_FILE -13
2764#define WTAP_ERR_SHORT_WRITE -14
2767#define WTAP_ERR_UNC_OVERFLOW -15
2770#define WTAP_ERR_RANDOM_OPEN_STDIN -16
2773#define WTAP_ERR_COMPRESSION_NOT_SUPPORTED -17
2776#define WTAP_ERR_CANT_SEEK -18
2779#define WTAP_ERR_CANT_SEEK_COMPRESSED -19
2782#define WTAP_ERR_DECOMPRESS -20
2785#define WTAP_ERR_INTERNAL -21
2788#define WTAP_ERR_PACKET_TOO_LARGE -22
2792#define WTAP_ERR_CHECK_WSLUA -23
2796#define WTAP_ERR_UNWRITABLE_REC_TYPE -24
2799#define WTAP_ERR_UNWRITABLE_REC_DATA -25
2802#define WTAP_ERR_DECOMPRESSION_NOT_SUPPORTED -26
2805#define WTAP_ERR_TIME_STAMP_NOT_SUPPORTED -27
2809#define WTAP_ERR_REC_MALFORMED -28
2813#ifdef __cplusplus
2814}
2815#endif /* __cplusplus */
2816
2817#endif /* __WTAP_H__ */
2818
2819/*
2820 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2821 *
2822 * Local variables:
2823 * c-basic-offset: 4
2824 * tab-width: 8
2825 * indent-tabs-mode: nil
2826 * End:
2827 *
2828 * vi: set shiftwidth=4 tabstop=8 expandtab:
2829 * :indentSize=4:tabSize=8:noTabs=true:
2830 */
Definition packet-eth.h:15
Definition buffer.h:22
Definition wtap.h:1538
GList * ipv6_addr_list
Definition wtap.h:1540
GList * ipv4_addr_list
Definition wtap.h:1539
Definition wtap.h:516
Definition wtap.h:489
Definition wtap.h:1202
Definition wtap.h:1090
Definition wtap.h:1102
Definition wtap.h:976
Definition wtap.h:884
Definition wtap.h:399
Definition inet_addr.h:27
Definition wtap.h:999
Definition wtap.h:1015
Definition wtap.h:990
Definition wtap.h:392
Definition wtap.h:1648
Definition wtap.h:1812
wtap_wslua_file_info_t * wslua_info
Definition wtap.h:1873
const char * name
Definition wtap.h:1822
const char * additional_file_extensions
Definition wtap.h:1836
int(* can_write_encap)(int)
Definition wtap.h:1861
const struct supported_block_type * supported_blocks
Definition wtap.h:1851
bool writing_must_seek
Definition wtap.h:1841
const char * description
Definition wtap.h:1816
bool(* dump_open)(wtap_dumper *, int *, char **)
Definition wtap.h:1867
size_t num_supported_blocks
Definition wtap.h:1846
const char * default_file_extension
Definition wtap.h:1828
Definition wtap.h:1120
Definition wtap.h:1520
Definition wtap.h:1528
Definition wtap.h:1113
Definition pcapio.c:124
Definition wtap.h:579
Definition wtap.h:817
Definition wtap.h:602
Definition wtap.h:706
Definition wtap.h:747
Definition wtap.h:757
Definition wtap.h:592
Definition wtap.h:772
Definition wtap.h:791
Definition wtap.h:638
Definition wtap.h:654
Definition tvbuff_lz77huff.c:32
Definition wtap.h:916
Definition wtap.h:406
Definition wtap.h:954
Definition wtap.h:1108
Definition wtap.h:969
Definition wtap.h:1171
Definition wtap.h:1177
Definition wtap.h:1207
Definition wtap.h:936
Definition wtap.h:1183
Definition wtap.h:922
Definition wtap.h:1165
Definition nstime.h:26
Definition wtap.h:1142
Definition wtap.h:1747
Definition wtap.h:526
Definition wtap.h:1197
Definition ngsniffer.c:81
Definition wtap.h:1081
Definition wtap.h:1802
Definition wtap.h:1778
Definition wtap_opttypes.h:272
Definition wtap.h:1412
Definition wtap.h:1559
const GArray * nrbs_growing
Definition wtap.h:1568
const GArray * dsbs_growing
Definition wtap.h:1572
int tsprec
Definition wtap.h:1562
GArray * shb_hdrs
Definition wtap.h:1563
int encap
Definition wtap.h:1560
bool dont_copy_idbs
Definition wtap.h:1581
GArray * dsbs_initial
Definition wtap.h:1571
wtapng_iface_descriptions_t * idb_inf
Definition wtap.h:1567
const GArray * mevs_growing
Definition wtap.h:1575
const GArray * shb_iface_to_global
Definition wtap.h:1564
const GArray * dpibs_growing
Definition wtap.h:1578
int snaplen
Definition wtap.h:1561
Definition wtap-int.h:110
Definition wtap.h:1010
Definition wtap.h:1384
Definition wtap.h:1302
Definition wtap.h:2682
Definition file_wrappers.c:215
Definition wtap.h:1442
Definition wtap.h:1392
Definition wtap.h:1605
Definition wtap-int.h:37
Definition wtap_opttypes.h:308
Definition wtap_opttypes.h:300
Definition wtap.h:805
Definition wtap.h:944
Definition wtap.h:1211
WS_DLL_PUBLIC void wtap_buffer_append_epdu_tag(Buffer *buf, uint16_t epdu_tag, const uint8_t *data, uint16_t data_len)
Definition wtap.c:2194
void(* wtap_new_secrets_callback_t)(uint32_t secrets_type, const void *secrets, unsigned size)
Definition wtap.h:1926
WS_DLL_PUBLIC GArray * wtap_get_savable_file_types_subtypes_for_file(int file_type_subtype, const GArray *file_encaps, uint32_t required_comment_types, ft_sort_order sort_order)
Definition file_access.c:1534
WS_DLL_PUBLIC void wtap_init(bool load_wiretap_plugins)
Initialize the Wiretap library.
Definition wtap.c:2275
WS_DLL_PUBLIC char * wtap_unwritable_rec_type_err_string(const wtap_rec *rec)
Definition wtap.c:1777
WS_DLL_PUBLIC int wtap_plugins_supported(void)
Definition wtap.c:55
WS_DLL_PUBLIC wtap_block_t wtap_file_get_shb(wtap *wth, unsigned shb_num)
Gets existing section header block, not for new file.
Definition wtap.c:144
WS_DLL_PUBLIC void wtap_dump_params_cleanup(wtap_dump_params *params)
Definition wtap.c:642
WS_DLL_PUBLIC wtapng_iface_descriptions_t * wtap_file_get_idb_info(wtap *wth)
Gets existing interface descriptions.
Definition wtap.c:196
WS_DLL_PUBLIC void wtap_setup_packet_rec(wtap_rec *rec, int encap)
Definition wtap.c:1787
WS_DLL_PUBLIC bool wtap_dump_close(wtap_dumper *wdh, bool *needs_reload, int *err, char **err_info)
Definition file_access.c:2658
WS_DLL_PUBLIC wtap_block_t wtap_get_next_interface_description(wtap *wth)
Gets next interface description.
Definition wtap.c:219
WS_DLL_PUBLIC wtap_dumper * wtap_dump_open(const char *filename, int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, char **err_info)
Opens a new capture file for writing.
Definition file_access.c:2320
WS_DLL_PUBLIC bool wtap_read(wtap *wth, wtap_rec *rec, int *err, char **err_info, int64_t *offset)
Definition wtap.c:1848
WS_DLL_PUBLIC void wtap_buffer_append_epdu_string(Buffer *buf, uint16_t epdu_tag, const char *val)
Definition wtap.c:2241
WS_DLL_PUBLIC void wtap_free_idb_info(wtapng_iface_descriptions_t *idb_info)
Free's a interface description block and all of its members.
Definition wtap.c:394
WS_DLL_PUBLIC void wtap_dump_params_discard_decryption_secrets(wtap_dump_params *params)
Definition wtap.c:629
WS_DLL_PUBLIC int wtap_dump_required_file_encap_type(const GArray *file_encaps)
Definition file_access.c:1368
WS_DLL_PUBLIC void wtap_dump_params_discard_name_resolution(wtap_dump_params *params)
Definition wtap.c:623
WS_DLL_PUBLIC wtap_dumper * wtap_dump_open_tempfile(const char *tmpdir, char **filenamep, const char *pfx, int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, char **err_info)
Creates a dumper for a temporary file.
Definition file_access.c:2359
WS_DLL_PUBLIC void wtap_dump_params_init_no_idbs(wtap_dump_params *params, wtap *wth)
Definition wtap.c:600
WS_DLL_PUBLIC void wtap_buffer_append_epdu_uint(Buffer *buf, uint16_t epdu_tag, uint32_t val)
Definition wtap.c:2225
WS_DLL_PUBLIC void wtap_setup_custom_block_rec(wtap_rec *rec, uint32_t pen, uint32_t payload_length, bool copy_allowed)
Definition wtap.c:1837
WS_DLL_PUBLIC unsigned wtap_file_get_shb_global_interface_id(wtap *wth, unsigned shb_num, uint32_t interface_id)
Gets the unique interface id for a SHB's interface.
Definition wtap.c:153
WS_DLL_PUBLIC unsigned wtap_file_get_num_shbs(wtap *wth)
Gets number of section header blocks.
Definition wtap.c:138
WS_DLL_PUBLIC void wtap_dump_params_init(wtap_dump_params *params, wtap *wth)
Definition wtap.c:573
WS_DLL_PUBLIC void wtap_write_shb_comment(wtap *wth, char *comment)
Sets or replaces the section header comment.
Definition wtap.c:188
WS_DLL_PUBLIC int64_t wtap_read_so_far(wtap *wth)
Definition wtap.c:1986
WS_DLL_PUBLIC void wtap_file_add_decryption_secrets(wtap *wth, const wtap_block_t dsb)
Adds a Decryption Secrets Block to the open wiretap session.
Definition wtap.c:260
WS_DLL_PUBLIC void wtap_setup_systemd_journal_export_rec(wtap_rec *rec)
Definition wtap.c:1827
WS_DLL_PUBLIC void wtap_cleareof(wtap *wth)
Definition wtap.c:1635
struct addrinfo_lists addrinfo_lists_t
WS_DLL_PUBLIC unsigned wtap_file_get_num_dsbs(wtap *wth)
Gets number of decryption secrets blocks.
Definition wtap.c:242
WS_DLL_PUBLIC void wtap_close(wtap *wth)
Definition wtap.c:1604
WS_DLL_PUBLIC void wtap_setup_syscall_rec(wtap_rec *rec)
Definition pcapng-sysdig.c:40
WS_DLL_PUBLIC bool wtap_dump_can_write_encap(int file_type_subtype, int encap)
Definition file_access.c:1381
WS_DLL_PUBLIC bool wtap_dump_can_write(const GArray *file_encaps, uint32_t required_comment_types)
Definition file_access.c:1483
WS_DLL_PUBLIC void wtap_setup_ft_specific_report_rec(wtap_rec *rec, int file_type_subtype, unsigned record_type)
Definition wtap.c:1813
WS_DLL_PUBLIC wtap_dumper * wtap_dump_open_stdout(int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, char **err_info)
Creates a dumper for the standard output.
Definition file_access.c:2456
WS_DLL_PUBLIC wtap_block_t wtap_file_get_dsb(wtap *wth, unsigned dsb_num)
Gets existing decryption secrets block, not for new file.
Definition wtap.c:251
WS_DLL_PUBLIC bool wtap_dump_can_compress(int file_type_subtype)
Definition file_access.c:2181
WS_DLL_PUBLIC bool wtap_file_discard_decryption_secrets(wtap *wth)
Definition wtap.c:269
WS_DLL_PUBLIC void wtap_setup_ft_specific_event_rec(wtap_rec *rec, int file_type_subtype, unsigned record_type)
Definition wtap.c:1799
WS_DLL_PUBLIC int wtap_buffer_append_epdu_end(Buffer *buf)
Definition wtap.c:2258
WS_DLL_PUBLIC block_support_t wtap_file_type_subtype_supports_block(int file_type_subtype, wtap_block_type_t type)
Definition file_access.c:1821
WS_DLL_PUBLIC GArray * wtap_get_writable_file_types_subtypes(ft_sort_order sort_order)
Definition file_access.c:1646
WS_DLL_PUBLIC wtap_dumper * wtap_dump_fdopen(int fd, int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, char **err_info)
Creates a dumper for an existing file descriptor.
Definition file_access.c:2421
WS_DLL_PUBLIC char * wtap_get_debug_if_descr(const wtap_block_t if_descr, const int indent, const char *line_end)
Gets a debug string of an interface description.
Definition wtap.c:404
WS_DLL_PUBLIC struct wtap * wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_info, bool do_random)
Definition file_access.c:926
WS_DLL_PUBLIC wtap_block_t wtap_file_get_nrb(wtap *wth)
Gets existing name resolution block, not for new file.
Definition wtap.c:543
WS_DLL_PUBLIC void wtap_sequential_close(wtap *wth)
Definition wtap.c:1571
void(* wtap_new_ipv4_callback_t)(const unsigned addr, const char *name, const bool static_entry)
Definition wtap.h:1914
WS_DLL_PUBLIC option_support_t wtap_file_type_subtype_supports_option(int file_type_subtype, wtap_block_type_t type, unsigned opttype)
Definition file_access.c:1856
WS_DLL_PUBLIC bool wtap_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, int *err, char **err_info)
Definition wtap.c:2063