2000-05-19 23:07:04 +00:00
|
|
|
/* wtap-int.h
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2000-05-19 23:07:04 +00:00
|
|
|
*
|
|
|
|
* Wiretap Library
|
2001-11-13 23:55:44 +00:00
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
2000-05-19 23:07:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
2000-05-19 23:07:04 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
2000-05-19 23:07:04 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WTAP_INT_H__
|
|
|
|
#define __WTAP_INT_H__
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
2000-08-25 21:25:43 +00:00
|
|
|
#include <time.h>
|
2000-05-19 23:07:04 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBZ
|
2002-10-15 05:38:01 +00:00
|
|
|
#ifdef HAVE_WINSOCK2_H
|
|
|
|
#include <winsock2.h>
|
|
|
|
#endif
|
2002-07-31 22:52:38 +00:00
|
|
|
#include <zlib.h>
|
2000-05-19 23:07:04 +00:00
|
|
|
#define FILE_T gzFile
|
|
|
|
#else /* No zLib */
|
|
|
|
#define FILE_T FILE *
|
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
|
|
|
|
#include "wtap.h"
|
|
|
|
|
2000-05-25 09:00:24 +00:00
|
|
|
/* Information for a compressed Sniffer data stream. */
|
|
|
|
typedef struct {
|
2000-08-11 07:28:12 +00:00
|
|
|
unsigned char *buf; /* buffer into which we uncompress data */
|
|
|
|
size_t nbytes; /* number of bytes of data in that buffer */
|
|
|
|
int nextout; /* offset in that buffer of stream's current position */
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 comp_offset; /* current offset in compressed data stream */
|
|
|
|
gint64 uncomp_offset; /* current offset in uncompressed data stream */
|
2000-05-25 09:00:24 +00:00
|
|
|
} ngsniffer_comp_stream_t;
|
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
typedef struct {
|
|
|
|
guint8 *sdate; /* Packet start date */
|
|
|
|
gboolean tcp_formatted; /* TCP/IP data formated Y/N */
|
|
|
|
int format; /* Trace format type */
|
|
|
|
} iseries_t;
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
typedef struct {
|
2003-01-09 01:38:30 +00:00
|
|
|
guint maj_vers;
|
|
|
|
guint min_vers;
|
2000-05-19 23:07:04 +00:00
|
|
|
double timeunit;
|
|
|
|
time_t start;
|
2005-10-22 03:49:23 +00:00
|
|
|
guint network; /* network type */
|
2000-05-25 09:00:24 +00:00
|
|
|
ngsniffer_comp_stream_t seq; /* sequential access */
|
|
|
|
ngsniffer_comp_stream_t rand; /* random access */
|
2000-08-11 07:28:12 +00:00
|
|
|
GList *first_blob; /* list element for first blob */
|
|
|
|
GList *last_blob; /* list element for last blob */
|
|
|
|
GList *current_blob; /* list element for current blob */
|
2000-05-19 23:07:04 +00:00
|
|
|
} ngsniffer_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
gboolean byte_swapped;
|
|
|
|
} i4btrace_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
gboolean is_hpux_11;
|
|
|
|
} nettl_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
time_t start;
|
|
|
|
} lanalyzer_t;
|
|
|
|
|
2003-10-24 23:55:34 +00:00
|
|
|
typedef enum {
|
|
|
|
NOT_SWAPPED,
|
|
|
|
SWAPPED,
|
|
|
|
MAYBE_SWAPPED
|
|
|
|
} swapped_type_t;
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
typedef struct {
|
|
|
|
gboolean byte_swapped;
|
2003-10-24 23:55:34 +00:00
|
|
|
swapped_type_t lengths_swapped;
|
2000-05-19 23:07:04 +00:00
|
|
|
guint16 version_major;
|
|
|
|
guint16 version_minor;
|
|
|
|
} libpcap_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
time_t start_secs;
|
|
|
|
guint32 start_usecs;
|
|
|
|
guint8 version_major;
|
|
|
|
guint32 *frame_table;
|
2001-08-25 03:18:48 +00:00
|
|
|
guint32 frame_table_size;
|
|
|
|
guint current_frame;
|
2000-05-19 23:07:04 +00:00
|
|
|
} netmon_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2002-04-08 09:09:49 +00:00
|
|
|
time_t start_time;
|
2007-05-29 14:20:54 +00:00
|
|
|
double ticks_per_sec;
|
2002-04-08 09:09:49 +00:00
|
|
|
double start_timestamp;
|
|
|
|
gboolean wrapped;
|
2005-09-09 08:40:58 +00:00
|
|
|
guint32 nframes;
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 start_offset;
|
|
|
|
gint64 end_offset;
|
2002-04-08 09:09:49 +00:00
|
|
|
int version_major;
|
2003-10-01 07:11:49 +00:00
|
|
|
gboolean fcs_valid; /* if packets have valid FCS at the end */
|
2003-01-07 03:52:59 +00:00
|
|
|
guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
|
2000-05-19 23:07:04 +00:00
|
|
|
} netxray_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
time_t inittime;
|
|
|
|
int adjusted;
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 next_packet_seek_start;
|
2000-05-19 23:07:04 +00:00
|
|
|
} ascend_t;
|
|
|
|
|
2000-08-08 22:16:42 +00:00
|
|
|
typedef struct {
|
|
|
|
gboolean byteswapped;
|
|
|
|
} csids_t;
|
2000-05-19 23:07:04 +00:00
|
|
|
|
2002-01-18 00:25:50 +00:00
|
|
|
typedef struct {
|
2002-01-18 01:08:36 +00:00
|
|
|
struct timeval reference_time;
|
2002-01-18 00:25:50 +00:00
|
|
|
} etherpeek_t;
|
|
|
|
|
2004-02-06 20:50:44 +00:00
|
|
|
typedef struct {
|
|
|
|
gboolean has_fcs;
|
|
|
|
} airopeek9_t;
|
|
|
|
|
2003-08-26 07:10:39 +00:00
|
|
|
typedef struct {
|
|
|
|
guint32 atm_encap;
|
From Stephen Donnelly of Endace:
The code for reading ERF files has not been significantly
updated since 2004. This patch brings it up to date with a
number of changes.
1) Increase number of decodable ERF types from 7 to 12. This
covers newer DAG card models and firmware updates.
2) Fix timestamp conversion. Was calculating only microsecond
precision, now displaying with nanosecond resolution. Hardware
precision is 7.5 to 30 ns depending on model.
3) Allow the user to specify HDLC encapsulation as 'chdlc',
'ppp_serial', 'frelay' or 'mtp2'. This is needed because the
ERF HDLC capture formats do not include information on what
protocol is used at the next level. This is currently done via
an environment variable 'ERF_HDLC_ENCAP' and is analagous to the
existing 'ERF_ATM_ENCAP' variable.
If the user does not specify an HDLC encapsulation it tries to
guess, and falls back to MTP2 for backwards compatibility with
Florent's existing behaviour.
I know environment variables are ugly, suggestions are welcome.
4) When reading HDLC captures as MTP2, use
WTAP_ENCAP_MTP2_WITH_PHDR rather than WTAP_ENCAP_MTP2. This
allows us to put the 'Multi-Channel ERF' record 'channel
number' field into the MTP2 pseudo header > 'link_number'
field. This is then displayed in Frame information, and can
be filtered on. (Would be nice if it could be made a display
column?)
Because the ERF record does not specify whether Annex A is used
or not, we pass MTP2_ANNEX_A_USED_UNKNOWN and allow the existing
user preference to decide.
Move the MTP2_ANNEX_A_ definitions into Wiretap, make the annex_a_used
field a guint8, and change MTP2_ANNEX_A_USED_UNKNOWN to 2 so it fits in
a guint8. (This means that if you can save an ERF MTP2 file as a
libpcap file, the pseudo-header will have MTP2_ANNEX_A_USED_UNKNOWN in
it.)
svn path=/trunk/; revision=22067
2007-06-08 17:06:13 +00:00
|
|
|
guint32 hdlc_encap;
|
2003-08-26 07:10:39 +00:00
|
|
|
gboolean is_rawatm;
|
|
|
|
} erf_t;
|
|
|
|
|
2005-06-10 16:01:16 +00:00
|
|
|
typedef struct _k12_t k12_t;
|
|
|
|
|
2006-04-14 12:41:06 +00:00
|
|
|
typedef struct {
|
|
|
|
time_t start_secs;
|
|
|
|
guint32 start_usecs;
|
|
|
|
} catapult_dct2000_t;
|
|
|
|
|
All private data for a capture in a Wiretap module must be per-file, not
static to the module.
Add the older(?) ID tag for MPEG audio.
Just use the ID at the beginning to identify MPEG audio files; don't
check the file any further.
If the read of the magic number doesn't work, get the error, and, if
there is no error (i.e., it's a short read), just return 0 (meaning "no
error, but this isn't that type of file).
Similarly, if the magic number doesn't match, just return 0, so other
types of file are tried.
svn path=/trunk/; revision=21192
2007-03-25 22:07:40 +00:00
|
|
|
typedef struct {
|
|
|
|
struct wtap_nstime now;
|
2007-08-21 22:00:06 +00:00
|
|
|
time_t t0;
|
All private data for a capture in a Wiretap module must be per-file, not
static to the module.
Add the older(?) ID tag for MPEG audio.
Just use the ID at the beginning to identify MPEG audio files; don't
check the file any further.
If the read of the magic number doesn't work, get the error, and, if
there is no error (i.e., it's a short read), just return 0 (meaning "no
error, but this isn't that type of file).
Similarly, if the magic number doesn't match, just return 0, so other
types of file are tried.
svn path=/trunk/; revision=21192
2007-03-25 22:07:40 +00:00
|
|
|
} mpeg_t;
|
|
|
|
|
2006-11-05 22:46:44 +00:00
|
|
|
typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
|
|
|
|
typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, union wtap_pseudo_header*,
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
guint8*, int, int *, char **);
|
2000-05-19 23:07:04 +00:00
|
|
|
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 wtap_pseudo_header pseudo_header;
|
|
|
|
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 data_offset;
|
2000-05-19 23:07:04 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
libpcap_t *pcap;
|
|
|
|
lanalyzer_t *lanalyzer;
|
|
|
|
ngsniffer_t *ngsniffer;
|
2005-11-25 20:30:42 +00:00
|
|
|
iseries_t *iseries;
|
2000-05-19 23:07:04 +00:00
|
|
|
i4btrace_t *i4btrace;
|
|
|
|
nettl_t *nettl;
|
|
|
|
netmon_t *netmon;
|
|
|
|
netxray_t *netxray;
|
|
|
|
ascend_t *ascend;
|
2000-08-08 22:16:42 +00:00
|
|
|
csids_t *csids;
|
2002-01-18 00:25:50 +00:00
|
|
|
etherpeek_t *etherpeek;
|
2004-02-06 20:50:44 +00:00
|
|
|
airopeek9_t *airopeek9;
|
2003-08-26 07:10:39 +00:00
|
|
|
erf_t *erf;
|
2005-06-10 16:01:16 +00:00
|
|
|
k12_t *k12;
|
All private data for a capture in a Wiretap module must be per-file, not
static to the module.
Add the older(?) ID tag for MPEG audio.
Just use the ID at the beginning to identify MPEG audio files; don't
check the file any further.
If the read of the magic number doesn't work, get the error, and, if
there is no error (i.e., it's a short read), just return 0 (meaning "no
error, but this isn't that type of file).
Similarly, if the magic number doesn't match, just return 0, so other
types of file are tried.
svn path=/trunk/; revision=21192
2007-03-25 22:07:40 +00:00
|
|
|
catapult_dct2000_t *catapult_dct2000;
|
|
|
|
mpeg_t *mpeg;
|
2000-09-19 17:22:11 +00:00
|
|
|
void *generic;
|
2000-05-19 23:07:04 +00:00
|
|
|
} capture;
|
|
|
|
|
|
|
|
subtype_read_func subtype_read;
|
|
|
|
subtype_seek_read_func subtype_seek_read;
|
2000-05-25 09:00:24 +00:00
|
|
|
void (*subtype_sequential_close)(struct wtap*);
|
2000-05-19 23:07:04 +00:00
|
|
|
void (*subtype_close)(struct wtap*);
|
|
|
|
int file_encap; /* per-file, for those
|
|
|
|
file formats that have
|
|
|
|
per-file encapsulation
|
|
|
|
types */
|
2005-08-24 21:31:56 +00:00
|
|
|
int tsprecision; /* timestamp precision of the lower 32bits
|
2006-12-25 21:34:11 +00:00
|
|
|
* e.g. WTAP_FILE_TSPREC_USEC */
|
2000-05-19 23:07:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wtap_dumper;
|
|
|
|
|
|
|
|
typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
|
|
|
|
const struct wtap_pkthdr*, const union wtap_pseudo_header*,
|
2002-07-29 06:09:59 +00:00
|
|
|
const guchar*, int*);
|
2000-05-19 23:07:04 +00:00
|
|
|
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;
|
2005-08-24 21:31:56 +00:00
|
|
|
struct wtap_nstime start;
|
2000-05-19 23:07:04 +00:00
|
|
|
guint32 nframes;
|
|
|
|
} netxray_dump_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
gboolean got_first_record_time;
|
2005-08-24 21:31:56 +00:00
|
|
|
struct wtap_nstime first_record_time;
|
2000-05-19 23:07:04 +00:00
|
|
|
guint32 frame_table_offset;
|
|
|
|
guint32 *frame_table;
|
2001-08-25 03:18:48 +00:00
|
|
|
guint frame_table_index;
|
|
|
|
guint frame_table_size;
|
2000-05-19 23:07:04 +00:00
|
|
|
} netmon_dump_t;
|
|
|
|
|
2003-07-29 19:42:01 +00:00
|
|
|
typedef struct {
|
|
|
|
guint32 nframes;
|
|
|
|
} _5views_dump_t;
|
|
|
|
|
2003-11-06 22:45:28 +00:00
|
|
|
typedef struct {
|
|
|
|
guint64 packet_count;
|
|
|
|
guint8 network_type;
|
|
|
|
} niobserver_dump_t;
|
|
|
|
|
2005-06-17 17:26:43 +00:00
|
|
|
typedef struct {
|
|
|
|
guint32 file_len;
|
|
|
|
guint32 num_of_records;
|
|
|
|
guint32 file_offset;
|
|
|
|
} k12_dump_t;
|
|
|
|
|
2006-04-14 12:41:06 +00:00
|
|
|
typedef struct {
|
|
|
|
gboolean first_packet_written;
|
|
|
|
struct wtap_nstime start_time;
|
|
|
|
} dct2000_dump_t;
|
2005-06-17 17:26:43 +00:00
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
struct wtap_dumper {
|
|
|
|
FILE* fh;
|
|
|
|
int file_type;
|
|
|
|
int snaplen;
|
|
|
|
int encap;
|
2005-09-14 21:57:30 +00:00
|
|
|
gboolean compressed;
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 bytes_dumped;
|
2000-05-19 23:07:04 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
void *opaque;
|
|
|
|
ngsniffer_dump_t *ngsniffer;
|
|
|
|
netmon_dump_t *netmon;
|
|
|
|
netxray_dump_t *netxray;
|
2003-07-29 19:42:01 +00:00
|
|
|
_5views_dump_t *_5views;
|
2003-11-06 22:45:28 +00:00
|
|
|
niobserver_dump_t *niobserver;
|
2005-06-17 17:26:43 +00:00
|
|
|
k12_dump_t *k12;
|
2006-04-14 12:41:06 +00:00
|
|
|
dct2000_dump_t *dct2000;
|
2000-05-19 23:07:04 +00:00
|
|
|
} dump;
|
|
|
|
|
|
|
|
subtype_write_func subtype_write;
|
|
|
|
subtype_close_func subtype_close;
|
2005-08-30 09:43:47 +00:00
|
|
|
|
|
|
|
int tsprecision; /* timestamp precision of the lower 32bits
|
|
|
|
* e.g. WTAP_FILE_TSPREC_USEC */
|
2000-05-19 23:07:04 +00:00
|
|
|
};
|
|
|
|
|
2005-09-14 21:57:30 +00:00
|
|
|
extern size_t wtap_dump_file_write(wtap_dumper *wdh, const void *buf, unsigned bufsize);
|
|
|
|
extern int wtap_dump_file_ferror(wtap_dumper *wdh);
|
2000-05-19 23:07:04 +00:00
|
|
|
|
2007-05-05 10:47:35 +00:00
|
|
|
extern gint wtap_num_file_types;
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
/* 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))
|
|
|
|
|
2007-05-28 06:47:50 +00:00
|
|
|
/* Macros to byte-swap possibly-unaligned 32-bit and 16-bit quantities;
|
|
|
|
* they take a pointer to the quantity, and byte-swap it in place.
|
|
|
|
*/
|
|
|
|
#define PBSWAP32(p) \
|
|
|
|
{ \
|
|
|
|
guint8 tmp; \
|
|
|
|
tmp = (p)[3]; \
|
|
|
|
(p)[3] = (p)[0]; \
|
|
|
|
(p)[0] = tmp; \
|
|
|
|
tmp = (p)[2]; \
|
|
|
|
(p)[2] = (p)[1]; \
|
|
|
|
(p)[1] = tmp; \
|
|
|
|
}
|
|
|
|
#define PBSWAP16(p) \
|
|
|
|
{ \
|
|
|
|
guint8 tmp; \
|
|
|
|
tmp = (p)[1]; \
|
|
|
|
(p)[1] = (p)[0]; \
|
|
|
|
(p)[0] = tmp; \
|
|
|
|
}
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
/* Turn host-byte-order values into little-endian values. */
|
2003-07-29 20:49:32 +00:00
|
|
|
#define htoles(s) GUINT16_TO_LE(s)
|
|
|
|
#define htolel(l) GUINT32_TO_LE(l)
|
2001-02-13 00:50:05 +00:00
|
|
|
#define htolell(ll) GUINT64_TO_LE(ll)
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
/* 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.
|
2007-05-28 06:47:50 +00:00
|
|
|
* We also provide pntohll and pletohll, which extract 64-bit integral
|
2005-08-26 19:40:46 +00:00
|
|
|
* quantities.
|
2007-05-28 06:47:50 +00:00
|
|
|
*
|
|
|
|
* These will work regardless of the byte alignment of the pointer.
|
2000-05-19 23:07:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef pntohs
|
|
|
|
#define pntohs(p) ((guint16) \
|
2002-11-27 22:21:41 +00:00
|
|
|
((guint16)*((const guint8 *)(p)+0)<<8| \
|
|
|
|
(guint16)*((const guint8 *)(p)+1)<<0))
|
2001-02-13 00:50:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef pntoh24
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pntoh24(p) ((guint32)*((const guint8 *)(p)+0)<<16| \
|
|
|
|
(guint32)*((const guint8 *)(p)+1)<<8| \
|
|
|
|
(guint32)*((const guint8 *)(p)+2)<<0)
|
2000-05-19 23:07:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef pntohl
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pntohl(p) ((guint32)*((const guint8 *)(p)+0)<<24| \
|
|
|
|
(guint32)*((const guint8 *)(p)+1)<<16| \
|
|
|
|
(guint32)*((const guint8 *)(p)+2)<<8| \
|
|
|
|
(guint32)*((const guint8 *)(p)+3)<<0)
|
2001-02-13 00:50:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef pntohll
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pntohll(p) ((guint64)*((const guint8 *)(p)+0)<<56| \
|
|
|
|
(guint64)*((const guint8 *)(p)+1)<<48| \
|
|
|
|
(guint64)*((const guint8 *)(p)+2)<<40| \
|
|
|
|
(guint64)*((const guint8 *)(p)+3)<<32| \
|
|
|
|
(guint64)*((const guint8 *)(p)+4)<<24| \
|
|
|
|
(guint64)*((const guint8 *)(p)+5)<<16| \
|
|
|
|
(guint64)*((const guint8 *)(p)+6)<<8| \
|
|
|
|
(guint64)*((const guint8 *)(p)+7)<<0)
|
2000-05-19 23:07:04 +00:00
|
|
|
#endif
|
2001-02-13 00:50:05 +00:00
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
|
|
|
|
#ifndef pletohs
|
|
|
|
#define pletohs(p) ((guint16) \
|
2002-11-27 22:21:41 +00:00
|
|
|
((guint16)*((const guint8 *)(p)+1)<<8| \
|
|
|
|
(guint16)*((const guint8 *)(p)+0)<<0))
|
2001-02-13 00:50:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef pletoh24
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pletoh24(p) ((guint32)*((const guint8 *)(p)+2)<<16| \
|
|
|
|
(guint32)*((const guint8 *)(p)+1)<<8| \
|
|
|
|
(guint32)*((const guint8 *)(p)+0)<<0)
|
2000-05-19 23:07:04 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-13 00:50:05 +00:00
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
#ifndef pletohl
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \
|
|
|
|
(guint32)*((const guint8 *)(p)+2)<<16| \
|
|
|
|
(guint32)*((const guint8 *)(p)+1)<<8| \
|
|
|
|
(guint32)*((const guint8 *)(p)+0)<<0)
|
2000-05-19 23:07:04 +00:00
|
|
|
#endif
|
|
|
|
|
2000-09-19 17:22:11 +00:00
|
|
|
|
2001-02-13 00:50:05 +00:00
|
|
|
#ifndef pletohll
|
2002-11-27 22:21:41 +00:00
|
|
|
#define pletohll(p) ((guint64)*((const guint8 *)(p)+7)<<56| \
|
|
|
|
(guint64)*((const guint8 *)(p)+6)<<48| \
|
|
|
|
(guint64)*((const guint8 *)(p)+5)<<40| \
|
|
|
|
(guint64)*((const guint8 *)(p)+4)<<32| \
|
|
|
|
(guint64)*((const guint8 *)(p)+3)<<24| \
|
|
|
|
(guint64)*((const guint8 *)(p)+2)<<16| \
|
|
|
|
(guint64)*((const guint8 *)(p)+1)<<8| \
|
|
|
|
(guint64)*((const guint8 *)(p)+0)<<0)
|
2001-02-13 00:50:05 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-28 06:47:50 +00:00
|
|
|
/* Pointer routines to put items out in a particular byte order.
|
|
|
|
* These will work regardless of the byte alignment of the pointer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef phtons
|
|
|
|
#define phtons(p, v) \
|
2007-05-28 08:31:18 +00:00
|
|
|
{ \
|
|
|
|
(p)[0] = (guint8)((v) >> 8); \
|
|
|
|
(p)[1] = (guint8)((v) >> 0); \
|
2007-05-28 06:47:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef phtonl
|
|
|
|
#define phtonl(p, v) \
|
|
|
|
{ \
|
2007-05-28 08:31:18 +00:00
|
|
|
(p)[0] = (guint8)((v) >> 24); \
|
|
|
|
(p)[1] = (guint8)((v) >> 16); \
|
|
|
|
(p)[2] = (guint8)((v) >> 8); \
|
|
|
|
(p)[3] = (guint8)((v) >> 0); \
|
2007-05-28 06:47:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-09-19 17:22:11 +00:00
|
|
|
#define wtap_file_read_unknown_bytes(target, num_bytes, fh, err) \
|
|
|
|
G_STMT_START \
|
|
|
|
{ \
|
|
|
|
int _bytes_read; \
|
|
|
|
_bytes_read = file_read((target), 1, (num_bytes), (fh)); \
|
2004-01-05 17:33:28 +00:00
|
|
|
if (_bytes_read != (int) (num_bytes)) { \
|
2000-09-19 17:22:11 +00:00
|
|
|
*(err) = file_error((fh)); \
|
|
|
|
return FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
#define wtap_file_read_expected_bytes(target, num_bytes, fh, err) \
|
|
|
|
G_STMT_START \
|
|
|
|
{ \
|
|
|
|
int _bytes_read; \
|
|
|
|
_bytes_read = file_read((target), 1, (num_bytes), (fh)); \
|
2004-01-05 17:33:28 +00:00
|
|
|
if (_bytes_read != (int) (num_bytes)) { \
|
2000-09-19 17:22:11 +00:00
|
|
|
*(err) = file_error((fh)); \
|
|
|
|
if (*(err) == 0 && _bytes_read > 0) { \
|
|
|
|
*(err) = WTAP_ERR_SHORT_READ; \
|
|
|
|
} \
|
|
|
|
return FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
G_STMT_END
|
|
|
|
|
2001-12-13 05:49:13 +00:00
|
|
|
/* glib doesn't have g_ptr_array_len of all things!*/
|
|
|
|
#ifndef g_ptr_array_len
|
|
|
|
#define g_ptr_array_len(a) ((a)->len)
|
|
|
|
#endif
|
|
|
|
|
2000-05-19 23:07:04 +00:00
|
|
|
#endif /* __WTAP_INT_H__ */
|