From Hannes Gredler
[obnox/wireshark/wip.git] / wiretap / wtap.h
1 /* wtap.h
2  *
3  * $Id$
4  *
5  * Wiretap Library
6  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifndef __WTAP_H__
24 #define __WTAP_H__
25
26 #ifdef HAVE_SYS_TIME_H
27 #include <sys/time.h>
28 #endif
29
30 #ifdef HAVE_WINSOCK2_H
31 # include <winsock2.h>
32 #endif
33
34 #include <glib.h>
35 #include <stdio.h>
36
37 /* Encapsulation types. Choose names that truly reflect
38  * what is contained in the packet trace file.
39  *
40  * WTAP_ENCAP_PER_PACKET is a value passed to "wtap_dump_open()" or
41  * "wtap_dump_fd_open()" to indicate that there is no single encapsulation
42  * type for all packets in the file; this may cause those routines to
43  * fail if the capture file format being written can't support that.
44  * It's also returned by "wtap_file_encap()" for capture files that
45  * don't have a single encapsulation type for all packets in the file.
46  *
47  * WTAP_ENCAP_UNKNOWN is returned by "wtap_pcap_encap_to_wtap_encap()"
48  * if it's handed an unknown encapsulation.
49  *
50  * WTAP_ENCAP_FDDI_BITSWAPPED is for FDDI captures on systems where the
51  * MAC addresses you get from the hardware are bit-swapped.  Ideally,
52  * the driver would tell us that, but I know of none that do, so, for
53  * now, we base it on the machine on which we're *reading* the
54  * capture, rather than on the machine on which the capture was taken
55  * (they're probably likely to be the same).  We assume that they're
56  * bit-swapped on everything except for systems running Ultrix, Alpha
57  * systems, and BSD/OS systems (that's what "tcpdump" does; I guess
58  * Digital decided to bit-swap addresses in the hardware or in the
59  * driver, and I guess BSDI bit-swapped them in the driver, given that
60  * BSD/OS generally runs on Boring Old PC's).  If we create a wiretap
61  * save file format, we'd use the WTAP_ENCAP values to flag the
62  * encapsulation of a packet, so there we'd at least be able to base
63  * it on the machine on which the capture was taken.
64  *
65  * WTAP_ENCAP_LINUX_ATM_CLIP is the encapsulation you get with the
66  * ATM on Linux code from <http://linux-atm.sourceforge.net/>;
67  * that code adds a DLT_ATM_CLIP DLT_ code of 19, and that
68  * encapsulation isn't the same as the DLT_ATM_RFC1483 encapsulation
69  * presumably used on some BSD systems, which we turn into
70  * WTAP_ENCAP_ATM_RFC1483.
71  *
72  * WTAP_ENCAP_NULL corresponds to DLT_NULL from "libpcap".  This
73  * corresponds to
74  *
75  *      1) PPP-over-HDLC encapsulation, at least with some versions
76  *         of ISDN4BSD (but not the current ones, it appears, unless
77  *         I've missed something);
78  *
79  *      2) a 4-byte header containing the AF_ address family, in
80  *         the byte order of the machine that saved the capture,
81  *         for the packet, as used on many BSD systems for the
82  *         loopback device and some other devices, or a 4-byte header
83  *         containing the AF_ address family in network byte order,
84  *         as used on recent OpenBSD systems for the loopback device;
85  *
86  *      3) a 4-byte header containing 2 octets of 0 and an Ethernet
87  *         type in the byte order from an Ethernet header, that being
88  *         what older versions of "libpcap" on Linux turn the Ethernet
89  *         header for loopback interfaces into (0.6.0 and later versions
90  *         leave the Ethernet header alone and make it DLT_EN10MB). */
91 #define WTAP_ENCAP_PER_PACKET                   -1
92 #define WTAP_ENCAP_UNKNOWN                      0
93 #define WTAP_ENCAP_ETHERNET                     1
94 #define WTAP_ENCAP_TOKEN_RING                   2
95 #define WTAP_ENCAP_SLIP                         3
96 #define WTAP_ENCAP_PPP                          4
97 #define WTAP_ENCAP_FDDI                         5
98 #define WTAP_ENCAP_FDDI_BITSWAPPED              6
99 #define WTAP_ENCAP_RAW_IP                       7
100 #define WTAP_ENCAP_ARCNET                       8
101 #define WTAP_ENCAP_ARCNET_LINUX                 9
102 #define WTAP_ENCAP_ATM_RFC1483                  10
103 #define WTAP_ENCAP_LINUX_ATM_CLIP               11
104 #define WTAP_ENCAP_LAPB                         12
105 #define WTAP_ENCAP_ATM_PDUS                     13
106 #define WTAP_ENCAP_ATM_PDUS_UNTRUNCATED         14
107 #define WTAP_ENCAP_NULL                         15
108 #define WTAP_ENCAP_ASCEND                       16
109 #define WTAP_ENCAP_ISDN                         17
110 #define WTAP_ENCAP_IP_OVER_FC                   18
111 #define WTAP_ENCAP_PPP_WITH_PHDR                19
112 #define WTAP_ENCAP_IEEE_802_11                  20
113 #define WTAP_ENCAP_PRISM_HEADER                 21
114 #define WTAP_ENCAP_IEEE_802_11_WITH_RADIO       22
115 #define WTAP_ENCAP_IEEE_802_11_WLAN_RADIOTAP    23
116 #define WTAP_ENCAP_IEEE_802_11_WLAN_AVS         24
117 #define WTAP_ENCAP_SLL                          25
118 #define WTAP_ENCAP_FRELAY                       26
119 #define WTAP_ENCAP_FRELAY_WITH_PHDR             27
120 #define WTAP_ENCAP_CHDLC                        28
121 #define WTAP_ENCAP_CISCO_IOS                    29
122 #define WTAP_ENCAP_LOCALTALK                    30
123 #define WTAP_ENCAP_OLD_PFLOG                    31
124 #define WTAP_ENCAP_HHDLC                        32
125 #define WTAP_ENCAP_DOCSIS                       33
126 #define WTAP_ENCAP_COSINE                       34
127 #define WTAP_ENCAP_WFLEET_HDLC                  35
128 #define WTAP_ENCAP_SDLC                         36
129 #define WTAP_ENCAP_TZSP                         37
130 #define WTAP_ENCAP_ENC                          38
131 #define WTAP_ENCAP_PFLOG                        39
132 #define WTAP_ENCAP_CHDLC_WITH_PHDR              40
133 #define WTAP_ENCAP_BLUETOOTH_H4                 41
134 #define WTAP_ENCAP_MTP2                         42
135 #define WTAP_ENCAP_MTP3                         43
136 #define WTAP_ENCAP_IRDA                         44
137 #define WTAP_ENCAP_USER0                        45
138 #define WTAP_ENCAP_USER1                        46
139 #define WTAP_ENCAP_USER2                        47
140 #define WTAP_ENCAP_USER3                        48
141 #define WTAP_ENCAP_USER4                        49
142 #define WTAP_ENCAP_USER5                        50
143 #define WTAP_ENCAP_USER6                        51
144 #define WTAP_ENCAP_USER7                        52
145 #define WTAP_ENCAP_USER8                        53
146 #define WTAP_ENCAP_USER9                        54
147 #define WTAP_ENCAP_USER10                       55
148 #define WTAP_ENCAP_USER11                       56
149 #define WTAP_ENCAP_USER12                       57
150 #define WTAP_ENCAP_USER13                       58
151 #define WTAP_ENCAP_USER14                       59
152 #define WTAP_ENCAP_USER15                       60
153 #define WTAP_ENCAP_SYMANTEC                     61
154 #define WTAP_ENCAP_APPLE_IP_OVER_IEEE1394       62
155 #define WTAP_ENCAP_BACNET_MS_TP                 63
156 #define WTAP_ENCAP_NETTL_RAW_ICMP               64
157 #define WTAP_ENCAP_NETTL_RAW_ICMPV6             65
158 #define WTAP_ENCAP_GPRS_LLC                     67
159 #define WTAP_ENCAP_JUNIPER_ATM1                 68
160 #define WTAP_ENCAP_JUNIPER_ATM2                 69
161 #define WTAP_ENCAP_REDBACK                      70
162 #define WTAP_ENCAP_NETTL_RAW_IP                 71
163 #define WTAP_ENCAP_NETTL_ETHERNET               72
164 #define WTAP_ENCAP_NETTL_TOKEN_RING             73
165 #define WTAP_ENCAP_NETTL_FDDI                   74
166 #define WTAP_ENCAP_NETTL_UNKNOWN                75
167 #define WTAP_ENCAP_MTP2_WITH_PHDR               76
168 #define WTAP_ENCAP_JUNIPER_PPPOE                77
169 /* last WTAP_ENCAP_ value + 1 */
170 #define WTAP_NUM_ENCAP_TYPES                    78
171
172 /* File types that can be read by wiretap.
173    We support writing some many of these file types, too, so we
174    distinguish between different versions of them. */
175 #define WTAP_FILE_UNKNOWN                       0
176 #define WTAP_FILE_WTAP                          1
177 #define WTAP_FILE_PCAP                          2
178 #define WTAP_FILE_PCAP_SS990417                 3
179 #define WTAP_FILE_PCAP_SS990915                 4
180 #define WTAP_FILE_PCAP_SS991029                 5
181 #define WTAP_FILE_PCAP_NOKIA                    6
182 #define WTAP_FILE_PCAP_AIX                      7
183 #define WTAP_FILE_LANALYZER                     8
184 #define WTAP_FILE_NGSNIFFER_UNCOMPRESSED        9
185 #define WTAP_FILE_NGSNIFFER_COMPRESSED          10
186 #define WTAP_FILE_SNOOP                         11
187 #define WTAP_FILE_SHOMITI                       12
188 #define WTAP_FILE_IPTRACE_1_0                   13
189 #define WTAP_FILE_IPTRACE_2_0                   14
190 #define WTAP_FILE_NETMON_1_x                    15
191 #define WTAP_FILE_NETMON_2_x                    16
192 #define WTAP_FILE_NETXRAY_OLD                   17
193 #define WTAP_FILE_NETXRAY_1_0                   18
194 #define WTAP_FILE_NETXRAY_1_1                   19
195 #define WTAP_FILE_NETXRAY_2_00x                 20
196 #define WTAP_FILE_RADCOM                        21
197 #define WTAP_FILE_ASCEND                        22
198 #define WTAP_FILE_NETTL                         23
199 #define WTAP_FILE_TOSHIBA                       24
200 #define WTAP_FILE_I4BTRACE                      25
201 #define WTAP_FILE_CSIDS                         26
202 #define WTAP_FILE_PPPDUMP                       27
203 #define WTAP_FILE_ETHERPEEK_V56                 28
204 #define WTAP_FILE_ETHERPEEK_V7                  29
205 #define WTAP_FILE_VMS                           30
206 #define WTAP_FILE_DBS_ETHERWATCH                31
207 #define WTAP_FILE_VISUAL_NETWORKS               32
208 #define WTAP_FILE_COSINE                        33
209 #define WTAP_FILE_5VIEWS                        34
210 #define WTAP_FILE_ERF                           35
211 #define WTAP_FILE_HCIDUMP                       36
212 #define WTAP_FILE_NETWORK_INSTRUMENTS_V9        37
213 #define WTAP_FILE_AIROPEEK_V9                   38
214 #define WTAP_FILE_EYESDN                        39
215
216 /* last WTAP_FILE_ value + 1 */
217 #define WTAP_NUM_FILE_TYPES                     40
218
219 /*
220  * Maximum packet size we'll support.
221  * It must be at least 65535.
222  */
223 #define WTAP_MAX_PACKET_SIZE                    65535
224
225 /*
226  * "Pseudo-headers" are used to supply to the clients of wiretap
227  * per-packet information that's not part of the packet payload
228  * proper.
229  *
230  * NOTE: do not use pseudo-header structures to hold information
231  * used by the code to read a particular capture file type; to
232  * keep that sort of state information, add a new structure for
233  * that private information to "wtap-int.h", add a pointer to that
234  * type of structure to the "capture" member of the "struct wtap"
235  * structure, and allocate one of those structures and set that member
236  * in the "open" routine for that capture file type if the open
237  * succeeds.  See various other capture file type handlers for examples
238  * of that.
239  */
240
241 /* Packet "pseudo-header" information for Ethernet capture files. */
242 struct eth_phdr {
243         gint    fcs_len;        /* Number of bytes of FCS - -1 means "unknown" */
244 };
245
246 /* Packet "pseudo-header" information for X.25 capture files. */
247 #define FROM_DCE                        0x80
248 struct x25_phdr {
249         guint8  flags; /* ENCAP_LAPB, ENCAP_V120 : 1st bit means From DCE */
250 };
251
252 /* Packet "pseudo-header" information for ISDN capture files. */
253
254 /* Direction */
255 struct isdn_phdr {
256         gboolean uton;
257         guint8  channel;                /* 0 = D-channel; n = B-channel n */
258 };
259
260 /* Packet "pseudo-header" for ATM capture files.
261    Not all of this information is supplied by all capture types. */
262
263 /*
264  * Status bits.
265  */
266 #define ATM_RAW_CELL    0x01    /* TRUE if the packet is a single cell */
267
268 /*
269  * AAL types.
270  */
271 #define AAL_UNKNOWN     0       /* AAL unknown */
272 #define AAL_1           1       /* AAL1 */
273 #define AAL_2           2       /* AAL2 */
274 #define AAL_3_4         3       /* AAL3/4 */
275 #define AAL_5           4       /* AAL5 */
276 #define AAL_USER        5       /* User AAL */
277 #define AAL_SIGNALLING  6       /* Signaling AAL */
278 #define AAL_OAMCELL     7       /* OAM cell */
279
280 /*
281  * Traffic types.
282  */
283 #define TRAF_UNKNOWN    0       /* Unknown */
284 #define TRAF_LLCMX      1       /* LLC multiplexed (RFC 1483) */
285 #define TRAF_VCMX       2       /* VC multiplexed (RFC 1483) */
286 #define TRAF_LANE       3       /* LAN Emulation */
287 #define TRAF_ILMI       4       /* ILMI */
288 #define TRAF_FR         5       /* Frame Relay */
289 #define TRAF_SPANS      6       /* FORE SPANS */
290 #define TRAF_IPSILON    7       /* Ipsilon */
291
292 /*
293  * Traffic subtypes.
294  */
295 #define TRAF_ST_UNKNOWN         0       /* Unknown */
296
297 /*
298  * For TRAF_VCMX:
299  */
300 #define TRAF_ST_VCMX_802_3_FCS  1       /* 802.3 with an FCS */
301 #define TRAF_ST_VCMX_802_4_FCS  2       /* 802.4 with an FCS */
302 #define TRAF_ST_VCMX_802_5_FCS  3       /* 802.5 with an FCS */
303 #define TRAF_ST_VCMX_FDDI_FCS   4       /* FDDI with an FCS */
304 #define TRAF_ST_VCMX_802_6_FCS  5       /* 802.6 with an FCS */
305 #define TRAF_ST_VCMX_802_3      7       /* 802.3 without an FCS */
306 #define TRAF_ST_VCMX_802_4      8       /* 802.4 without an FCS */
307 #define TRAF_ST_VCMX_802_5      9       /* 802.5 without an FCS */
308 #define TRAF_ST_VCMX_FDDI       10      /* FDDI without an FCS */
309 #define TRAF_ST_VCMX_802_6      11      /* 802.6 without an FCS */
310 #define TRAF_ST_VCMX_FRAGMENTS  12      /* Fragments */
311 #define TRAF_ST_VCMX_BPDU       13      /* BPDU */
312
313 /*
314  * For TRAF_LANE:
315  */
316 #define TRAF_ST_LANE_LE_CTRL    1       /* LANE: LE Ctrl */
317 #define TRAF_ST_LANE_802_3      2       /* LANE: 802.3 */
318 #define TRAF_ST_LANE_802_5      3       /* LANE: 802.5 */
319 #define TRAF_ST_LANE_802_3_MC   4       /* LANE: 802.3 multicast */
320 #define TRAF_ST_LANE_802_5_MC   5       /* LANE: 802.5 multicast */
321
322 /*
323  * For TRAF_IPSILON:
324  */
325 #define TRAF_ST_IPSILON_FT0     1       /* Ipsilon: Flow Type 0 */
326 #define TRAF_ST_IPSILON_FT1     2       /* Ipsilon: Flow Type 1 */
327 #define TRAF_ST_IPSILON_FT2     3       /* Ipsilon: Flow Type 2 */
328
329 struct atm_phdr {
330         guint32 flags;          /* status flags */
331         guint8  aal;            /* AAL of the traffic */
332         guint8  type;           /* traffic type */
333         guint8  subtype;        /* traffic subtype */
334         guint16 vpi;            /* virtual path identifier */
335         guint16 vci;            /* virtual circuit identifier */
336         guint16 channel;        /* link: 0 for DTE->DCE, 1 for DCE->DTE */
337         guint16 cells;          /* number of cells */
338         guint16 aal5t_u2u;      /* user-to-user indicator */
339         guint16 aal5t_len;      /* length of the packet */
340         guint32 aal5t_chksum;   /* checksum for AAL5 packet */
341 };
342
343 /* Packet "pseudo-header" for the output from "wandsession", "wannext",
344    "wandisplay", and similar commands on Lucent/Ascend access equipment. */
345
346 #define ASCEND_MAX_STR_LEN 64
347
348 #define ASCEND_PFX_WDS_X 1
349 #define ASCEND_PFX_WDS_R 2
350 #define ASCEND_PFX_WDD   3
351 #define ASCEND_PFX_ISDN_X 4
352 #define ASCEND_PFX_ISDN_R 5
353 #define ASCEND_PFX_ETHER 6
354
355 struct ascend_phdr {
356         guint16 type;                   /* ASCEND_PFX_*, as defined above */
357         char    user[ASCEND_MAX_STR_LEN];   /* Username, from wandsession header */
358         guint32 sess;                   /* Session number, from wandsession header */
359         char    call_num[ASCEND_MAX_STR_LEN];   /* Called number, from WDD header */
360         guint32 chunk;                  /* Chunk number, from WDD header */
361         guint32 task;                   /* Task number */
362 };
363
364 /* Packet "pseudo-header" for point-to-point links with direction flags. */
365 struct p2p_phdr {
366         gboolean        sent; /* TRUE=sent, FALSE=received */
367 };
368
369 /* Packet "pseudo-header" information for 802.11
370    Radio information is only present for WTAP_ENCAP_IEEE_802_11_WITH_RADIO. */
371 struct ieee_802_11_phdr {
372         gint    fcs_len;        /* Number of bytes of FCS - -1 means "unknown" */
373         guint8  channel;        /* Channel number */
374         guint8  data_rate;      /* in .5 Mb/s units */
375         guint8  signal_level;   /* percentage */
376 };
377
378 /* Packet "pseudo-header" for the output from CoSine L2 debug output. */
379
380 #define COSINE_MAX_IF_NAME_LEN  128
381
382 #define COSINE_ENCAP_TEST       1
383 #define COSINE_ENCAP_PPoATM     2
384 #define COSINE_ENCAP_PPoFR      3
385 #define COSINE_ENCAP_ATM        4
386 #define COSINE_ENCAP_FR         5
387 #define COSINE_ENCAP_HDLC       6
388 #define COSINE_ENCAP_PPP        7
389 #define COSINE_ENCAP_ETH        8
390 #define COSINE_ENCAP_UNKNOWN    99
391
392 #define COSINE_DIR_TX 1
393 #define COSINE_DIR_RX 2
394
395 struct cosine_phdr {
396         guint8 encap;           /* COSINE_ENCAP_* as defined above */
397         guint8 direction;       /* COSINE_DIR_*, as defined above */
398         char if_name[COSINE_MAX_IF_NAME_LEN];  /* Encap & Logical I/F name */
399         guint16 pro;            /* Protocol */
400         guint16 off;            /* Offset */
401         guint16 pri;            /* Priority */
402         guint16 rm;             /* Rate Marking */
403         guint16 err;            /* Error Code */
404 };
405
406 /* Packet "pseudo-header" for IrDA capture files. */
407
408 /*
409  * Direction of the packet
410  */
411 #define IRDA_INCOMING       0x0000
412 #define IRDA_OUTGOING       0x0004
413
414 /*
415  * "Inline" log messages produced by IrCOMM2k on Windows
416  */
417 #define IRDA_LOG_MESSAGE    0x0100  /* log message */
418 #define IRDA_MISSED_MSG     0x0101  /* missed log entry or frame */
419
420 /*
421  * Differentiate between frames and log messages
422  */
423 #define IRDA_CLASS_FRAME    0x0000
424 #define IRDA_CLASS_LOG      0x0100
425 #define IRDA_CLASS_MASK     0xFF00
426
427 struct irda_phdr {
428         guint16 pkttype;    /* packet type */
429 };
430
431 /* Packet "pseudo-header" for nettl (HP-UX) capture files. */
432
433 struct nettl_phdr {
434         guint16 subsys;
435         guint32 devid;
436         guint32 kind;
437         gint32  pid;
438         gint16  uid;
439 };
440
441 /* Packet "pseudo-header" for MTP2 files. */
442
443 struct mtp2_phdr {
444         guint8  sent;         
445         guint8  annex_a_used;   
446         guint16 link_number;  
447 };
448
449 union wtap_pseudo_header {
450         struct eth_phdr         eth;
451         struct x25_phdr         x25;
452         struct isdn_phdr        isdn;
453         struct atm_phdr         atm;
454         struct ascend_phdr      ascend;
455         struct p2p_phdr         p2p;
456         struct ieee_802_11_phdr ieee_802_11;
457         struct cosine_phdr      cosine;
458         struct irda_phdr        irda;
459         struct nettl_phdr       nettl;
460         struct mtp2_phdr        mtp2;
461 };
462
463 struct wtap_pkthdr {
464         struct timeval ts;
465         guint32 caplen;
466         guint32 len;
467         int pkt_encap;
468 };
469
470 struct wtap;
471 struct Buffer;
472 struct wtap_dumper;
473
474 typedef struct wtap wtap;
475 typedef struct wtap_dumper wtap_dumper;
476
477 /*
478  * On failure, "wtap_open_offline()" returns NULL, and puts into the
479  * "int" pointed to by its second argument:
480  *
481  * a positive "errno" value if the capture file can't be opened;
482  *
483  * a negative number, indicating the type of error, on other failures.
484  */
485 struct wtap* wtap_open_offline(const char *filename, int *err,
486     gchar **err_info, gboolean do_random);
487
488 /* Returns TRUE if read was successful. FALSE if failure. data_offset is
489  * set the the offset in the file where the data for the read packet is
490  * located. */
491 gboolean wtap_read(wtap *wth, int *err, gchar **err_info,
492     long *data_offset);
493
494 struct wtap_pkthdr *wtap_phdr(wtap *wth);
495 union wtap_pseudo_header *wtap_pseudoheader(wtap *wth);
496 guint8 *wtap_buf_ptr(wtap *wth);
497
498 int wtap_fd(wtap *wth);
499 int wtap_snapshot_length(wtap *wth); /* per file */
500 int wtap_file_type(wtap *wth);
501 int wtap_file_encap(wtap *wth);
502
503 const char *wtap_file_type_string(int filetype);
504 const char *wtap_file_type_short_string(int filetype);
505 int wtap_short_string_to_file_type(const char *short_name);
506
507 const char *wtap_encap_string(int encap);
508 const char *wtap_encap_short_string(int encap);
509 int wtap_short_string_to_encap(const char *short_name);
510
511 const char *wtap_strerror(int err);
512 void wtap_sequential_close(wtap *wth);
513 void wtap_close(wtap *wth);
514 gboolean wtap_seek_read (wtap *wth, long seek_off,
515         union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
516         int *err, gchar **err_info);
517
518 gboolean wtap_dump_can_open(int filetype);
519 gboolean wtap_dump_can_write_encap(int filetype, int encap);
520 wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap,
521         int snaplen, int *err);
522 wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen,
523         int *err);
524 gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *,
525         const union wtap_pseudo_header *pseudo_header, const guchar *, int *err);
526 FILE* wtap_dump_file(wtap_dumper *);
527 gboolean wtap_dump_close(wtap_dumper *, int *);
528 long wtap_get_bytes_dumped(wtap_dumper *);
529 void wtap_set_bytes_dumped(wtap_dumper *wdh, long bytes_dumped);
530
531 /*
532  * Wiretap error codes.
533  */
534 #define WTAP_ERR_NOT_REGULAR_FILE               -1
535         /* The file being opened for reading isn't a plain file (or pipe) */
536 #define WTAP_ERR_RANDOM_OPEN_PIPE               -2
537         /* The file is being opened for random access and it's a pipe */
538 #define WTAP_ERR_FILE_UNKNOWN_FORMAT            -3
539         /* The file being opened is not a capture file in a known format */
540 #define WTAP_ERR_UNSUPPORTED                    -4
541         /* Supported file type, but there's something in the file we
542            can't support */
543 #define WTAP_ERR_CANT_WRITE_TO_PIPE             -5
544         /* Wiretap can't save to a pipe in the specified format */
545 #define WTAP_ERR_CANT_OPEN                      -6
546         /* The file couldn't be opened, reason unknown */
547 #define WTAP_ERR_UNSUPPORTED_FILE_TYPE          -7
548         /* Wiretap can't save files in the specified format */
549 #define WTAP_ERR_UNSUPPORTED_ENCAP              -8
550         /* Wiretap can't read or save files in the specified format with the
551            specified encapsulation */
552 #define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED   -9
553         /* The specified format doesn't support per-packet encapsulations */
554 #define WTAP_ERR_CANT_CLOSE                     -10
555         /* The file couldn't be closed, reason unknown */
556 #define WTAP_ERR_CANT_READ                      -11
557         /* An attempt to read failed, reason unknown */
558 #define WTAP_ERR_SHORT_READ                     -12
559         /* An attempt to read read less data than it should have */
560 #define WTAP_ERR_BAD_RECORD                     -13
561         /* We read an invalid record */
562 #define WTAP_ERR_SHORT_WRITE                    -14
563         /* An attempt to write wrote less data than it should have */
564 #define WTAP_ERR_UNC_TRUNCATED                  -15
565         /* Sniffer compressed data was oddly truncated */
566 #define WTAP_ERR_UNC_OVERFLOW                   -16
567         /* Uncompressing Sniffer data would overflow buffer */
568 #define WTAP_ERR_UNC_BAD_OFFSET                 -17
569         /* LZ77 compressed data has bad offset to string */
570 #define WTAP_ERR_RANDOM_OPEN_STDIN              -18
571         /* We're trying to open the standard input for random access */
572
573 /* Errors from zlib; zlib error Z_xxx turns into Wiretap error
574    WTAP_ERR_ZLIB + Z_xxx.
575
576    WTAP_ERR_ZLIB_MIN and WTAP_ERR_ZLIB_MAX bound the range of zlib
577    errors; we leave room for 100 positive and 100 negative error
578    codes. */
579
580 #define WTAP_ERR_ZLIB                           -200
581 #define WTAP_ERR_ZLIB_MAX                       -100
582 #define WTAP_ERR_ZLIB_MIN                       -300
583
584
585 #endif /* __WTAP_H__ */