fd56251f2b45437656d6ba50288654b3166db495
[obnox/wireshark/wip.git] / wiretap / libpcap.h
1 /* libpcap.h
2  *
3  * $Id: libpcap.h,v 1.11 2001/11/13 23:55:43 gram Exp $
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
24 #ifndef __W_LIBPCAP_H__
25 #define __W_LIBPCAP_H__
26
27 /* Magic numbers in "libpcap" files.
28
29    "libpcap" file records are written in the byte order of the host that
30    writes them, and the reader is expected to fix this up.
31
32    PCAP_MAGIC is the magic number, in host byte order; PCAP_SWAPPED_MAGIC
33    is a byte-swapped version of that.
34
35    PCAP_MODIFIED_MAGIC is for Alexey Kuznetsov's modified "libpcap"
36    format, as generated on Linux systems that have a "libpcap" with
37    his patches, at
38    
39         http://ftp.sunet.se/pub/os/Linux/ip-routing/lbl-tools/
40
41    applied; PCAP_SWAPPED_MODIFIED_MAGIC is the byte-swapped version. */
42 #define PCAP_MAGIC                      0xa1b2c3d4
43 #define PCAP_SWAPPED_MAGIC              0xd4c3b2a1
44 #define PCAP_MODIFIED_MAGIC             0xa1b2cd34
45 #define PCAP_SWAPPED_MODIFIED_MAGIC     0x34cdb2a1
46
47 /* "libpcap" file header (minus magic number). */
48 struct pcap_hdr {
49         guint16 version_major;  /* major version number */
50         guint16 version_minor;  /* minor version number */
51         gint32  thiszone;       /* GMT to local correction */
52         guint32 sigfigs;        /* accuracy of timestamps */
53         guint32 snaplen;        /* max length of captured packets, in octets */
54         guint32 network;        /* data link type */
55 };
56
57 /* "libpcap" record header. */
58 struct pcaprec_hdr {
59         guint32 ts_sec;         /* timestamp seconds */
60         guint32 ts_usec;        /* timestamp microseconds */
61         guint32 incl_len;       /* number of octets of packet saved in file */
62         guint32 orig_len;       /* actual length of packet */
63 };
64
65 /* "libpcap" record header for Alexey's patched version. */
66 struct pcaprec_modified_hdr {
67         struct pcaprec_hdr hdr; /* the regular header */
68         guint32 ifindex;        /* index, in *capturing* machine's list of
69                                    interfaces, of the interface on which this
70                                    packet came in. */
71         guint16 protocol;       /* Ethernet packet type */
72         guint8 pkt_type;        /* broadcast/multicast/etc. indication */
73         guint8 pad;             /* pad to a 4-byte boundary */
74 };
75
76 /* "libpcap" record header for Alexey's patched version in its ss990915
77    incarnation; this version shows up in SuSE Linux 6.3. */
78 struct pcaprec_ss990915_hdr {
79         struct pcaprec_hdr hdr; /* the regular header */
80         guint32 ifindex;        /* index, in *capturing* machine's list of
81                                    interfaces, of the interface on which this
82                                    packet came in. */
83         guint16 protocol;       /* Ethernet packet type */
84         guint8 pkt_type;        /* broadcast/multicast/etc. indication */
85         guint8 cpu1, cpu2;      /* SMP debugging gunk? */
86         guint8 pad[3];          /* pad to a 4-byte boundary */
87 };
88
89 /* "libpcap" record header for version used on some Nokia boxes (firewalls?) */
90 struct pcaprec_nokia_hdr {
91         struct pcaprec_hdr hdr; /* the regular header */
92         guint8 stuff[4];        /* mysterious stuff */
93 };
94
95 int libpcap_open(wtap *wth, int *err);
96 gboolean libpcap_dump_open(wtap_dumper *wdh, int *err);
97 int libpcap_dump_can_write_encap(int filetype, int encap);
98
99 #endif