3 * $Id: wtap-int.h,v 1.7 2000/08/25 21:25:43 gram Exp $
6 * Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
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 #ifndef __WTAP_INT_H__
25 #define __WTAP_INT_H__
27 #ifdef HAVE_SYS_TYPES_H
28 #include <sys/types.h>
31 #ifdef HAVE_SYS_TIME_H
48 #endif /* HAVE_LIBZ */
52 /* Information for a compressed Sniffer data stream. */
54 unsigned char *buf; /* buffer into which we uncompress data */
55 size_t nbytes; /* number of bytes of data in that buffer */
56 int nextout; /* offset in that buffer of stream's current position */
57 long comp_offset; /* current offset in compressed data stream */
58 long uncomp_offset; /* current offset in uncompressed data stream */
59 } ngsniffer_comp_stream_t;
65 ngsniffer_comp_stream_t seq; /* sequential access */
66 ngsniffer_comp_stream_t rand; /* random access */
67 GList *first_blob; /* list element for first blob */
68 GList *last_blob; /* list element for last blob */
69 GList *current_blob; /* list element for current blob */
73 gboolean byte_swapped;
74 int bchannel_prot[2]; /* For the V.120 heuristic */
86 gboolean byte_swapped;
87 guint16 version_major;
88 guint16 version_minor;
103 double start_timestamp;
116 gboolean byteswapped;
119 typedef int (*subtype_read_func)(struct wtap*, int*);
120 typedef int (*subtype_seek_read_func)(struct wtap*, int, union wtap_pseudo_header*,
124 int fd; /* File descriptor for cap file */
125 FILE_T random_fh; /* Secondary FILE_T for random access */
128 struct Buffer *frame_buffer;
129 struct wtap_pkthdr phdr;
130 union wtap_pseudo_header pseudo_header;
136 lanalyzer_t *lanalyzer;
137 ngsniffer_t *ngsniffer;
138 i4btrace_t *i4btrace;
146 subtype_read_func subtype_read;
147 subtype_seek_read_func subtype_seek_read;
148 void (*subtype_sequential_close)(struct wtap*);
149 void (*subtype_close)(struct wtap*);
150 int file_encap; /* per-file, for those
151 file formats that have
152 per-file encapsulation
158 typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
159 const struct wtap_pkthdr*, const union wtap_pseudo_header*,
160 const u_char*, int*);
161 typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*);
164 gboolean first_frame;
169 gboolean first_frame;
170 struct timeval start;
175 gboolean got_first_record_time;
176 struct timeval first_record_time;
177 guint32 frame_table_offset;
178 guint32 *frame_table;
179 int frame_table_index;
180 int frame_table_size;
191 ngsniffer_dump_t *ngsniffer;
192 netmon_dump_t *netmon;
193 netxray_dump_t *netxray;
196 subtype_write_func subtype_write;
197 subtype_close_func subtype_close;
201 /* Macros to byte-swap 32-bit and 16-bit quantities. */
203 ((((x)&0xFF000000)>>24) | \
204 (((x)&0x00FF0000)>>8) | \
205 (((x)&0x0000FF00)<<8) | \
206 (((x)&0x000000FF)<<24))
208 ((((x)&0xFF00)>>8) | \
211 /* Turn host-byte-order values into little-endian values. */
212 #ifdef WORDS_BIGENDIAN
213 #define htoles(s) ((guint16) \
214 ((guint16)((s) & 0x00FF)<<8| \
215 (guint16)((s) & 0xFF00)>>8))
217 #define htolel(l) ((guint32)((l) & 0x000000FF)<<24| \
218 (guint32)((l) & 0x0000FF00)<<8| \
219 (guint32)((l) & 0x00FF0000)>>8| \
220 (guint32)((l) & 0xFF000000)>>24)
222 #define htoles(s) (s)
223 #define htolel(l) (l)
226 /* Pointer versions of ntohs and ntohl. Given a pointer to a member of a
227 * byte array, returns the value of the two or four bytes at the pointer.
228 * The pletoh[sl] versions return the little-endian representation.
232 #define pntohs(p) ((guint16) \
233 ((guint16)*((guint8 *)p+0)<<8| \
234 (guint16)*((guint8 *)p+1)<<0))
238 #define pntohl(p) ((guint32)*((guint8 *)p+0)<<24| \
239 (guint32)*((guint8 *)p+1)<<16| \
240 (guint32)*((guint8 *)p+2)<<8| \
241 (guint32)*((guint8 *)p+3)<<0)
245 #define phtons(p) ((guint16) \
246 ((guint16)*((guint8 *)p+0)<<8| \
247 (guint16)*((guint8 *)p+1)<<0))
251 #define phtonl(p) ((guint32)*((guint8 *)p+0)<<24| \
252 (guint32)*((guint8 *)p+1)<<16| \
253 (guint32)*((guint8 *)p+2)<<8| \
254 (guint32)*((guint8 *)p+3)<<0)
258 #define pletohs(p) ((guint16) \
259 ((guint16)*((guint8 *)p+1)<<8| \
260 (guint16)*((guint8 *)p+0)<<0))
264 #define pletohl(p) ((guint32)*((guint8 *)p+3)<<24| \
265 (guint32)*((guint8 *)p+2)<<16| \
266 (guint32)*((guint8 *)p+1)<<8| \
267 (guint32)*((guint8 *)p+0)<<0)
270 #endif /* __WTAP_INT_H__ */