aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.h
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2000-05-19 23:07:04 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2000-05-19 23:07:04 +0000
commitd7e6e0e384967a4d3ac1f57d6446f5a04e83b3c6 (patch)
tree349138fc92b8d0ed8fa5f5f4be28c0be0ed92b41 /wiretap/wtap.h
parent586e1b6fca8da9b031bb99b7010c3c77fbd85045 (diff)
Add wtap-int.h. Move definitions relevant to the internal workins of wiretap
to that file, leave public definitions in wtap.h. Rename "union pseudo_header" to "union wtap_pseudo_header". Make the wtap_pseudo_header pointer available in packet_info struct. svn path=/trunk/; revision=1989
Diffstat (limited to 'wiretap/wtap.h')
-rw-r--r--wiretap/wtap.h218
1 files changed, 9 insertions, 209 deletions
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index f4e4c70e2f..82de7bdca3 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.70 2000/05/18 09:09:50 guy Exp $
+ * $Id: wtap.h,v 1.71 2000/05/19 23:07:04 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -142,63 +142,6 @@
#include <glib.h>
#include <stdio.h>
-#ifdef HAVE_LIBZ
-#include "zlib.h"
-#define FILE_T gzFile
-#else /* No zLib */
-#define FILE_T FILE *
-#endif /* HAVE_LIBZ */
-
-typedef struct {
- double timeunit;
- time_t start;
- int is_atm;
-} ngsniffer_t;
-
-typedef struct {
- gboolean byte_swapped;
- int bchannel_prot[2]; /* For the V.120 heuristic */
-} i4btrace_t;
-
-typedef struct {
- gboolean is_hpux_11;
-} nettl_t;
-
-typedef struct {
- time_t start;
-} lanalyzer_t;
-
-typedef struct {
- gboolean byte_swapped;
- gboolean modified;
- guint16 version_major;
- guint16 version_minor;
-} libpcap_t;
-
-typedef struct {
- time_t start_secs;
- guint32 start_usecs;
- guint8 version_major;
- guint32 *frame_table;
- int frame_table_size;
- int current_frame;
-} netmon_t;
-
-typedef struct {
- time_t start_time;
- double timeunit;
- double start_timestamp;
- int wrapped;
- int end_offset;
- int version_major;
-} netxray_t;
-
-typedef struct {
- time_t inittime;
- int adjusted;
- int seek_add;
-} ascend_t;
-
/* Packet "pseudo-header" information for X.25 capture files. */
struct x25_phdr {
guint8 flags; /* ENCAP_LAPB : 1st bit means From DCE */
@@ -292,7 +235,7 @@ struct lapd_phdr {
#define AHLT_VCMX_FRAGMENTS 0xc /* VCMX: Fragments */
#define AHLT_VCMX_BPDU 0xe /* VCMX: BPDU */
-union pseudo_header {
+union wtap_pseudo_header {
struct x25_phdr x25;
struct ngsniffer_atm_phdr ngsniffer_atm;
struct ascend_phdr ascend;
@@ -307,89 +250,14 @@ struct wtap_pkthdr {
};
typedef void (*wtap_handler)(u_char*, const struct wtap_pkthdr*,
- int, union pseudo_header *pseudo_header, const u_char *);
+ int, union wtap_pseudo_header *pseudo_header, const u_char *);
struct wtap;
struct Buffer;
-
-typedef int (*subtype_read_func)(struct wtap*, int*);
-typedef int (*subtype_seek_read_func)(struct wtap*, int, union pseudo_header*,
- guint8*, int);
-typedef struct wtap {
- FILE_T fh;
- int fd; /* File descriptor for cap file */
- FILE_T random_fh; /* Secondary FILE_T for random access */
- int file_type;
- int snapshot_length;
- struct Buffer *frame_buffer;
- struct wtap_pkthdr phdr;
- union pseudo_header pseudo_header;
-
- long data_offset;
-
- union {
- libpcap_t *pcap;
- lanalyzer_t *lanalyzer;
- ngsniffer_t *ngsniffer;
- i4btrace_t *i4btrace;
- nettl_t *nettl;
- netmon_t *netmon;
- netxray_t *netxray;
- ascend_t *ascend;
- } capture;
-
- subtype_read_func subtype_read;
- subtype_seek_read_func subtype_seek_read;
- void (*subtype_close)(struct wtap*);
- int file_encap; /* per-file, for those
- file formats that have
- per-file encapsulation
- types */
-} wtap;
-
struct wtap_dumper;
-typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
- const struct wtap_pkthdr*, const union pseudo_header*,
- const u_char*, int*);
-typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*);
-
-typedef struct {
- gboolean first_frame;
- time_t start;
-} ngsniffer_dump_t;
-
-typedef struct {
- gboolean first_frame;
- struct timeval start;
- guint32 nframes;
-} netxray_dump_t;
-
-typedef struct {
- gboolean got_first_record_time;
- struct timeval first_record_time;
- guint32 frame_table_offset;
- guint32 *frame_table;
- int frame_table_index;
- int frame_table_size;
-} netmon_dump_t;
-
-typedef struct wtap_dumper {
- FILE* fh;
- int file_type;
- int snaplen;
- int encap;
-
- union {
- void *opaque;
- ngsniffer_dump_t *ngsniffer;
- netmon_dump_t *netmon;
- netxray_dump_t *netxray;
- } dump;
-
- subtype_write_func subtype_write;
- subtype_close_func subtype_close;
-} wtap_dumper;
+typedef struct wtap wtap;
+typedef struct wtap_dumper wtap_dumper;
/*
* On failure, "wtap_open_offline()" returns NULL, and puts into the
@@ -399,7 +267,7 @@ typedef struct wtap_dumper {
*
* a negative number, indicating the type of error, on other failures.
*/
-wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random);
+struct wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random);
int wtap_loop(wtap *wth, int, wtap_handler, u_char*, int*);
int wtap_read(wtap *wth, int *err);
@@ -421,9 +289,9 @@ const char *wtap_strerror(int err);
void wtap_sequential_close(wtap *wth);
void wtap_close(wtap *wth);
int wtap_seek_read (wtap *wth, int seek_off,
- union pseudo_header *pseudo_header, guint8 *pd, int len);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len);
int wtap_def_seek_read (wtap *wth, int seek_off,
- union pseudo_header *pseudo_header, guint8 *pd, int len);
+ union wtap_pseudo_header *pseudo_header, guint8 *pd, int len);
gboolean wtap_dump_can_open(int filetype);
gboolean wtap_dump_can_write_encap(int filetype, int encap);
@@ -432,7 +300,7 @@ wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap,
wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen,
int *err);
gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *,
- const union pseudo_header *pseudo_header, const u_char *, int *err);
+ const union wtap_pseudo_header *pseudo_header, const u_char *, int *err);
FILE* wtap_dump_file(wtap_dumper *);
gboolean wtap_dump_close(wtap_dumper *, int *);
@@ -480,73 +348,5 @@ int wtap_pcap_encap_to_wtap_encap(int encap);
#define WTAP_ERR_ZLIB_MAX -100
#define WTAP_ERR_ZLIB_MIN -300
-/* Macros to byte-swap 32-bit and 16-bit quantities. */
-#define BSWAP32(x) \
- ((((x)&0xFF000000)>>24) | \
- (((x)&0x00FF0000)>>8) | \
- (((x)&0x0000FF00)<<8) | \
- (((x)&0x000000FF)<<24))
-#define BSWAP16(x) \
- ((((x)&0xFF00)>>8) | \
- (((x)&0x00FF)<<8))
-
-/* Turn host-byte-order values into little-endian values. */
-#ifdef WORDS_BIGENDIAN
-#define htoles(s) ((guint16) \
- ((guint16)((s) & 0x00FF)<<8| \
- (guint16)((s) & 0xFF00)>>8))
-
-#define htolel(l) ((guint32)((l) & 0x000000FF)<<24| \
- (guint32)((l) & 0x0000FF00)<<8| \
- (guint32)((l) & 0x00FF0000)>>8| \
- (guint32)((l) & 0xFF000000)>>24)
-#else
-#define htoles(s) (s)
-#define htolel(l) (l)
-#endif
-
-/* Pointer versions of ntohs and ntohl. Given a pointer to a member of a
- * byte array, returns the value of the two or four bytes at the pointer.
- * The pletoh[sl] versions return the little-endian representation.
- */
-
-#ifndef pntohs
-#define pntohs(p) ((guint16) \
- ((guint16)*((guint8 *)p+0)<<8| \
- (guint16)*((guint8 *)p+1)<<0))
-#endif
-
-#ifndef pntohl
-#define pntohl(p) ((guint32)*((guint8 *)p+0)<<24| \
- (guint32)*((guint8 *)p+1)<<16| \
- (guint32)*((guint8 *)p+2)<<8| \
- (guint32)*((guint8 *)p+3)<<0)
-#endif
-
-#ifndef phtons
-#define phtons(p) ((guint16) \
- ((guint16)*((guint8 *)p+0)<<8| \
- (guint16)*((guint8 *)p+1)<<0))
-#endif
-
-#ifndef phtonl
-#define phtonl(p) ((guint32)*((guint8 *)p+0)<<24| \
- (guint32)*((guint8 *)p+1)<<16| \
- (guint32)*((guint8 *)p+2)<<8| \
- (guint32)*((guint8 *)p+3)<<0)
-#endif
-
-#ifndef pletohs
-#define pletohs(p) ((guint16) \
- ((guint16)*((guint8 *)p+1)<<8| \
- (guint16)*((guint8 *)p+0)<<0))
-#endif
-
-#ifndef pletohl
-#define pletohl(p) ((guint32)*((guint8 *)p+3)<<24| \
- (guint32)*((guint8 *)p+2)<<16| \
- (guint32)*((guint8 *)p+1)<<8| \
- (guint32)*((guint8 *)p+0)<<0)
-#endif
#endif /* __WTAP_H__ */