Added more SAP types, from the ncpfs source.
[obnox/wireshark/wip.git] / file.h
1 /* file.h
2  * Definitions for file structures and routines
3  *
4  * $Id: file.h,v 1.3 1998/09/17 03:12:25 gerald Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __FILE_H__
27 #define __FILE_H__
28
29 #include <sys/types.h>
30 #include <sys/time.h>
31
32 #include <pcap.h>
33
34 /* Data file formats */
35 #define CD_UNKNOWN    0
36 #define CD_WIRE       1
37 #define CD_SNOOP      2
38 #define CD_PCAP_BE    3
39 #define CD_PCAP_LE    4
40 #define CD_NA_UNCOMPR 5
41
42 /* Data file magic info */
43 #define SNOOP_MAGIC_1 0x736e6f6f /* 'snoop' in ASCII */
44 #define SNOOP_MAGIC_2 0x70000000
45 #define PCAP_MAGIC    0xa1b2c3d4
46
47 /* Data file format versions we can handle */
48 #define SNOOP_MIN_VERSION 2
49 #define SNOOP_MAX_VERSION 2
50
51 /* Link types (removed in favor of the DLT_* defines from bpf.h */
52
53 typedef struct bpf_program bpf_prog;
54
55 typedef struct _capture_file {
56   FILE       *fh;        /* Capture file */
57   gchar      *filename;  /* filename */
58   long        f_len;     /* File length */
59   int         swap;      /* Swap data bytes? */
60   guint16     cd_t;      /* Capture data type */
61   guint32     vers;      /* Version.  For tcpdump minor is appended to major */
62   guint32     lnk_t;     /* Network link type */
63   guint32     count;     /* Packet count */
64   guint32     drops;     /* Dropped packets */
65   guint32     esec;      /* Elapsed seconds */
66   guint32     eusec;     /* Elapsed microseconds */
67   guint32     snap;      /* Captured packet length */
68   gchar      *iface;     /* Interface */
69   gchar      *save_file; /* File to write capture data */
70   pcap_t     *pfh;       /* Pcap session */
71   gchar      *filter;    /* Pcap filter string */
72   bpf_prog    fcode;     /* Compiled filter program */
73   guint8      pd[4096];  /* Packet data */
74   GList      *plist;     /* Packet list */
75   frame_data *cur;       /* Current list item */
76 } capture_file;
77
78 /* Taken from RFC 1761 */
79
80 typedef struct _snoop_file_hdr {
81   guint32 magic1;
82   guint32 magic2;
83   guint32 vers;
84   guint32 s_lnk_t;
85 } snoop_file_hdr;
86
87 typedef struct _snoop_frame_hdr {
88   guint32 orig_len;
89   guint32 inc_len;
90   guint32 pr_len;
91   guint32 drops;
92   guint32 secs;
93   guint32 usecs;
94 } snoop_frame_hdr;
95
96 int  open_cap_file(char *, capture_file *);
97 void close_cap_file(capture_file *, GtkWidget *, guint);
98 int  load_cap_file(char *, capture_file *);
99 void pcap_dispatch_cb(u_char *, const struct pcap_pkthdr *, const u_char *);
100 /* size_t read_frame_header(capture_file *); */
101
102 #endif /* file.h */