3 * $Id: wtap.h,v 1.5 1998/11/15 05:29:17 guy Exp $
6 * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
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.
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.
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.
24 /* Encapsulation types */
25 #define WTAP_ENCAP_NONE 0
26 #define WTAP_ENCAP_ETHERNET 1
27 #define WTAP_ENCAP_TR 2
28 #define WTAP_ENCAP_SLIP 3
29 #define WTAP_ENCAP_PPP 4
30 #define WTAP_ENCAP_FDDI 5
31 #define WTAP_ENCAP_RAW_IP 6
32 #define WTAP_ENCAP_ARCNET 7
34 /* File types that can be read by wiretap */
35 #define WTAP_FILE_UNKNOWN 0
36 #define WTAP_FILE_WTAP 1
37 #define WTAP_FILE_PCAP 2
38 #define WTAP_FILE_LANALYZER 3
39 #define WTAP_FILE_NGSNIFFER 4
40 #define WTAP_FILE_SNOOP 6
41 #define WTAP_FILE_IPTRACE 7
43 #include <sys/types.h>
61 guint16 version_major;
62 guint16 version_minor;
71 typedef void (*wtap_handler)(u_char*, const struct wtap_pkthdr*,
75 typedef int (*subtype_func)(struct wtap*);
80 unsigned long frame_number;
81 unsigned long file_byte_offset;
83 struct wtap_pkthdr phdr;
87 lanalyzer_t *lanalyzer;
88 ngsniffer_t *ngsniffer;
91 subtype_func subtype_read;
96 wtap* wtap_open_offline(char *filename, int filetype);
97 void wtap_loop(wtap *wth, int, wtap_handler, u_char*);
99 FILE* wtap_file(wtap *wth);
100 int wtap_snapshot_length(wtap *wth); /* per file */
101 int wtap_file_type(wtap *wth);
102 int wtap_encapsulation(wtap *wth); /* per file */
103 void wtap_close(wtap *wth);
106 /* Pointer versions of ntohs and ntohl. Given a pointer to a member of a
107 * byte array, returns the value of the two or four bytes at the pointer.
108 * The pletoh[sl] versions return the little-endian representation.
111 #define pntohs(p) ((guint16) \
112 ((guint16)*((guint8 *)p+0)<<8| \
113 (guint16)*((guint8 *)p+1)<<0))
115 #define pntohl(p) ((guint32)*((guint8 *)p+0)<<24| \
116 (guint32)*((guint8 *)p+1)<<16| \
117 (guint32)*((guint8 *)p+2)<<8| \
118 (guint32)*((guint8 *)p+3)<<0)
120 #define pletohs(p) ((guint16) \
121 ((guint16)*((guint8 *)p+1)<<8| \
122 (guint16)*((guint8 *)p+0)<<0))
124 #define pletohl(p) ((guint32)*((guint8 *)p+3)<<24| \
125 (guint32)*((guint8 *)p+2)<<16| \
126 (guint32)*((guint8 *)p+1)<<8| \
127 (guint32)*((guint8 *)p+0)<<0)
131 #define DLT_NULL 0 /* no link-layer encapsulation */
132 #define DLT_EN10MB 1 /* Ethernet (10Mb) */
133 #define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
134 #define DLT_AX25 3 /* Amateur Radio AX.25 */
135 #define DLT_PRONET 4 /* Proteon ProNET Token Ring */
136 #define DLT_CHAOS 5 /* Chaos */
137 #define DLT_IEEE802 6 /* IEEE 802 Networks */
138 #define DLT_ARCNET 7 /* ARCNET */
139 #define DLT_SLIP 8 /* Serial Line IP */
140 #define DLT_PPP 9 /* Point-to-point Protocol */
141 #define DLT_FDDI 10 /* FDDI */
142 #define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
143 #define DLT_RAW 12 /* raw IP */
144 #define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */
145 #define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */