Have "All Capture Files" match only capture files.
[metze/wireshark/wip.git] / wiretap / libpcap.h
1 /* libpcap.h
2  *
3  * Wiretap Library
4  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef __W_LIBPCAP_H__
22 #define __W_LIBPCAP_H__
23
24 #include <glib.h>
25 #include <wiretap/wtap.h>
26 #include "ws_symbol_export.h"
27
28 /* Magic numbers in "libpcap" files.
29
30    "libpcap" file records are written in the byte order of the host that
31    writes them, and the reader is expected to fix this up.
32
33    PCAP_MAGIC is the magic number, in host byte order; PCAP_SWAPPED_MAGIC
34    is a byte-swapped version of that.
35
36    PCAP_MODIFIED_MAGIC is for Alexey Kuznetsov's modified "libpcap"
37    format, as generated on Linux systems that have a "libpcap" with
38    his patches, at
39
40         http://ftp.sunet.se/pub/os/Linux/ip-routing/lbl-tools/
41
42    applied; PCAP_SWAPPED_MODIFIED_MAGIC is the byte-swapped version.
43
44    PCAP_NSEC_MAGIC is for Ulf Lamping's modified "libpcap" format,
45    which uses the same common file format as PCAP_MAGIC, but the
46    timestamps are saved in nanosecond resolution instead of microseconds.
47    PCAP_SWAPPED_NSEC_MAGIC is a byte-swapped version of that. */
48 #define PCAP_MAGIC                      0xa1b2c3d4
49 #define PCAP_SWAPPED_MAGIC              0xd4c3b2a1
50 #define PCAP_MODIFIED_MAGIC             0xa1b2cd34
51 #define PCAP_SWAPPED_MODIFIED_MAGIC     0x34cdb2a1
52 #define PCAP_NSEC_MAGIC                 0xa1b23c4d
53 #define PCAP_SWAPPED_NSEC_MAGIC         0x4d3cb2a1
54
55 /* "libpcap" file header (minus magic number). */
56 struct pcap_hdr {
57         guint16 version_major;  /* major version number */
58         guint16 version_minor;  /* minor version number */
59         gint32  thiszone;       /* GMT to local correction */
60         guint32 sigfigs;        /* accuracy of timestamps */
61         guint32 snaplen;        /* max length of captured packets, in octets */
62         guint32 network;        /* data link type */
63 };
64
65 /* "libpcap" record header. */
66 struct pcaprec_hdr {
67         guint32 ts_sec;         /* timestamp seconds */
68         guint32 ts_usec;        /* timestamp microseconds (nsecs for PCAP_NSEC_MAGIC) */
69         guint32 incl_len;       /* number of octets of packet saved in file */
70         guint32 orig_len;       /* actual length of packet */
71 };
72
73 /* "libpcap" record header for Alexey's patched version. */
74 struct pcaprec_modified_hdr {
75         struct pcaprec_hdr hdr; /* the regular header */
76         guint32 ifindex;        /* index, in *capturing* machine's list of
77                                    interfaces, of the interface on which this
78                                    packet came in. */
79         guint16 protocol;       /* Ethernet packet type */
80         guint8 pkt_type;        /* broadcast/multicast/etc. indication */
81         guint8 pad;             /* pad to a 4-byte boundary */
82 };
83
84 /* "libpcap" record header for Alexey's patched version in its ss990915
85    incarnation; this version shows up in SuSE Linux 6.3. */
86 struct pcaprec_ss990915_hdr {
87         struct pcaprec_hdr hdr; /* the regular header */
88         guint32 ifindex;        /* index, in *capturing* machine's list of
89                                    interfaces, of the interface on which this
90                                    packet came in. */
91         guint16 protocol;       /* Ethernet packet type */
92         guint8 pkt_type;        /* broadcast/multicast/etc. indication */
93         guint8 cpu1, cpu2;      /* SMP debugging gunk? */
94         guint8 pad[3];          /* pad to a 4-byte boundary */
95 };
96
97 /* "libpcap" record header for version used on some Nokia boxes (firewalls?) */
98 struct pcaprec_nokia_hdr {
99         struct pcaprec_hdr hdr; /* the regular header */
100         guint8 stuff[4];        /* mysterious stuff */
101 };
102
103 wtap_open_return_val libpcap_open(wtap *wth, int *err, gchar **err_info);
104 gboolean libpcap_dump_open(wtap_dumper *wdh, int *err);
105 int libpcap_dump_can_write_encap(int encap);
106
107 #endif