From Joerg Mayer:

All files:
  - Replace types from sys/types.h by those from glib.h
  - Replace ntoh family of macros from netinet/in.h and winsock2.h
    by g_ntoh family from glib.h
  - Remove now unneeded includes of sys/types.h, netinet/in.h and
    winsock2.h
wtap.h
  Move includes to the top

svn path=/trunk/; revision=5909
This commit is contained in:
Guy Harris 2002-07-29 06:09:59 +00:00
parent 4298a1f07d
commit 6e21561be8
19 changed files with 133 additions and 165 deletions

View File

@ -1,6 +1,6 @@
/* buffer.c
*
* $Id: buffer.c,v 1.12 2001/11/13 23:55:43 gram Exp $
* $Id: buffer.c,v 1.13 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -29,16 +29,12 @@
#include <string.h>
#include <glib.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include "buffer.h"
/* Initializes a buffer with a certain amount of allocated space */
void buffer_init(Buffer* buffer, unsigned int space)
{
buffer->data = (u_char*)g_malloc(space);
buffer->data = (guchar*)g_malloc(space);
buffer->allocated = space;
buffer->start = 0;
buffer->first_free = 0;
@ -88,10 +84,10 @@ void buffer_assure_space(Buffer* buffer, unsigned int space)
/* We'll allocate more space */
buffer->allocated += space + 1024;
buffer->data = (u_char*)g_realloc(buffer->data, buffer->allocated);
buffer->data = (guchar*)g_realloc(buffer->data, buffer->allocated);
}
void buffer_append(Buffer* buffer, u_char *from, unsigned int bytes)
void buffer_append(Buffer* buffer, guchar *from, unsigned int bytes)
{
buffer_assure_space(buffer, bytes);
memcpy(buffer->data + buffer->first_free, from, bytes);
@ -129,14 +125,14 @@ unsigned int buffer_length(Buffer* buffer)
#endif
#ifndef SOME_FUNCTIONS_ARE_DEFINES
u_char* buffer_start_ptr(Buffer* buffer)
guchar* buffer_start_ptr(Buffer* buffer)
{
return buffer->data + buffer->start;
}
#endif
#ifndef SOME_FUNCTIONS_ARE_DEFINES
u_char* buffer_end_ptr(Buffer* buffer)
guchar* buffer_end_ptr(Buffer* buffer)
{
return buffer->data + buffer->first_free;
}

View File

@ -1,6 +1,6 @@
/* buffer.h
*
* $Id: buffer.h,v 1.9 2002/06/23 10:32:36 guy Exp $
* $Id: buffer.h,v 1.10 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -26,12 +26,8 @@
#define SOME_FUNCTIONS_ARE_DEFINES
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h> /* to define u_char */
#endif
typedef struct Buffer {
u_char *data;
guchar *data;
unsigned int allocated;
unsigned int start;
unsigned int first_free;
@ -40,7 +36,7 @@ typedef struct Buffer {
void buffer_init(Buffer* buffer, unsigned int space);
void buffer_free(Buffer* buffer);
void buffer_assure_space(Buffer* buffer, unsigned int space);
void buffer_append(Buffer* buffer, u_char *from, unsigned int bytes);
void buffer_append(Buffer* buffer, guchar *from, unsigned int bytes);
void buffer_remove_start(Buffer* buffer, unsigned int bytes);
#ifdef SOME_FUNCTIONS_ARE_DEFINES
@ -51,8 +47,8 @@ void buffer_remove_start(Buffer* buffer, unsigned int bytes);
#else
void buffer_increase_length(Buffer* buffer, unsigned int bytes);
unsigned int buffer_length(Buffer* buffer);
u_char* buffer_start_ptr(Buffer* buffer);
u_char* buffer_end_ptr(Buffer* buffer);
guchar* buffer_start_ptr(Buffer* buffer);
guchar* buffer_end_ptr(Buffer* buffer);
#endif
#endif

View File

@ -2,7 +2,7 @@
* Routines for opening EtherPeek (and TokenPeek?) files
* Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net>
*
* $Id: etherpeek.c,v 1.20 2002/06/07 07:27:34 guy Exp $
* $Id: etherpeek.c,v 1.21 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -31,10 +31,6 @@
#include "file_wrappers.h"
#include "buffer.h"
#include "etherpeek.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
/* CREDITS
*
* This file decoder could not have been writen without examining how
@ -142,7 +138,7 @@ static const etherpeek_encap_lookup_t etherpeek_encap[] = {
static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset);
static gboolean etherpeek_seek_read_v7(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static gboolean etherpeek_read_v56(wtap *wth, int *err, long *data_offset);
static void etherpeek_close(wtap *wth);
@ -195,9 +191,9 @@ int etherpeek_open(wtap *wth, int *err)
* we can get.
*/
ep_hdr.secondary.v567.mediaType =
ntohl(ep_hdr.secondary.v567.mediaType);
g_ntohl(ep_hdr.secondary.v567.mediaType);
ep_hdr.secondary.v567.physMedium =
ntohl(ep_hdr.secondary.v567.physMedium);
g_ntohl(ep_hdr.secondary.v567.physMedium);
switch (ep_hdr.secondary.v567.physMedium) {
@ -265,19 +261,19 @@ int etherpeek_open(wtap *wth, int *err)
* uncompressed, but it might be compressed.
*/
ep_hdr.secondary.v567.filelength =
ntohl(ep_hdr.secondary.v567.filelength);
g_ntohl(ep_hdr.secondary.v567.filelength);
ep_hdr.secondary.v567.numPackets =
ntohl(ep_hdr.secondary.v567.numPackets);
g_ntohl(ep_hdr.secondary.v567.numPackets);
ep_hdr.secondary.v567.timeDate =
ntohl(ep_hdr.secondary.v567.timeDate);
g_ntohl(ep_hdr.secondary.v567.timeDate);
ep_hdr.secondary.v567.timeStart =
ntohl(ep_hdr.secondary.v567.timeStart);
g_ntohl(ep_hdr.secondary.v567.timeStart);
ep_hdr.secondary.v567.timeStop =
ntohl(ep_hdr.secondary.v567.timeStop);
g_ntohl(ep_hdr.secondary.v567.timeStop);
ep_hdr.secondary.v567.appVers =
ntohl(ep_hdr.secondary.v567.appVers);
g_ntohl(ep_hdr.secondary.v567.appVers);
ep_hdr.secondary.v567.linkSpeed =
ntohl(ep_hdr.secondary.v567.linkSpeed);
g_ntohl(ep_hdr.secondary.v567.linkSpeed);
/* Get the reference time as a "struct timeval" */
reference_time.tv_sec =
@ -442,7 +438,7 @@ static gboolean etherpeek_read_v7(wtap *wth, int *err, long *data_offset)
static gboolean
etherpeek_seek_read_v7(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
airopeek_radio_hdr_t radio_hdr;

View File

@ -1,6 +1,6 @@
/* file.c
*
* $Id: file.c,v 1.94 2002/07/16 07:15:08 guy Exp $
* $Id: file.c,v 1.95 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -646,7 +646,7 @@ FILE* wtap_dump_file(wtap_dumper *wdh)
}
gboolean wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err)
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
return (wdh->subtype_write)(wdh, phdr, pseudo_header, pd, err);
}

View File

@ -1,6 +1,6 @@
/* i4btrace.c
*
* $Id: i4btrace.c,v 1.21 2002/06/07 07:27:34 guy Exp $
* $Id: i4btrace.c,v 1.22 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
@ -34,10 +34,10 @@
static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset);
static gboolean i4btrace_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static int i4b_read_rec_header(FILE_T fh, i4b_trace_hdr_t *hdr, int *err);
static void i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr);
static gboolean i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err);
static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
static void i4b_set_pseudo_header(wtap *wth, i4b_trace_hdr_t *hdr,
union wtap_pseudo_header *pseudo_header);
static void i4btrace_close(wtap *wth);
@ -223,7 +223,7 @@ static gboolean i4btrace_read(wtap *wth, int *err, long *data_offset)
static gboolean
i4btrace_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
int ret;
i4b_trace_hdr_t hdr;
@ -290,7 +290,7 @@ i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr)
}
static gboolean
i4b_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;

View File

@ -1,6 +1,6 @@
/* iptrace.c
*
* $Id: iptrace.c,v 1.41 2002/06/07 07:27:34 guy Exp $
* $Id: iptrace.c,v 1.42 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -34,12 +34,12 @@
static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset);
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err);
static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset);
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err);
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
@ -166,7 +166,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, long *data_offset)
}
static gboolean iptrace_seek_read_1_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err)
{
int ret;
@ -287,7 +287,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, long *data_offset)
}
static gboolean iptrace_seek_read_2_0(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err)
{
int ret;

View File

@ -1,6 +1,6 @@
/* lanalyzer.c
*
* $Id: lanalyzer.c,v 1.35 2002/07/16 07:15:08 guy Exp $
* $Id: lanalyzer.c,v 1.36 2002/07/29 06:09:58 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -487,7 +487,7 @@ static void my_timersub(const struct timeval *a,
static gboolean lanalyzer_dump(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const u_char *pd, int *err)
const guchar *pd, int *err)
{
double x;
int i;

View File

@ -1,6 +1,6 @@
/* libpcap.c
*
* $Id: libpcap.c,v 1.79 2002/07/16 07:15:08 guy Exp $
* $Id: libpcap.c,v 1.80 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -23,6 +23,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <errno.h>
#include "wtap-int.h"
@ -31,6 +32,9 @@
#include "libpcap.h"
#ifdef HAVE_PCAP_H
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
#include <pcap.h>
#include "wtap-capture.h"
#endif
@ -62,7 +66,7 @@ static libpcap_try_t libpcap_try(wtap *wth, int *err);
static gboolean libpcap_read(wtap *wth, int *err, long *data_offset);
static gboolean libpcap_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static int libpcap_read_header(wtap *wth, int *err,
struct pcaprec_ss990915_hdr *hdr, gboolean silent);
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
@ -70,11 +74,11 @@ static void libpcap_get_atm_pseudoheader(const struct sunatm_hdr *atm_phdr,
union wtap_pseudo_header *pseudo_header);
static gboolean libpcap_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean libpcap_read_rec_data(FILE_T fh, u_char *pd, int length,
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void libpcap_close(wtap *wth);
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
/*
* Either LBL NRG wasn't an adequate central registry (e.g., because of
@ -898,7 +902,7 @@ static gboolean libpcap_read(wtap *wth, int *err, long *data_offset)
static gboolean
libpcap_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
@ -1138,7 +1142,7 @@ libpcap_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header
}
static gboolean
libpcap_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
libpcap_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;
@ -1187,9 +1191,9 @@ static int wtap_wtap_encap_to_pcap_encap(int encap)
* fill in the Wiretap packet header, and return a pointer to the
* beginning of the non-pseudo-header data in the packet.
*/
const u_char *
const guchar *
wtap_process_pcap_packet(gint linktype, const struct pcap_pkthdr *phdr,
const u_char *pd, union wtap_pseudo_header *pseudo_header,
const guchar *pd, union wtap_pseudo_header *pseudo_header,
struct wtap_pkthdr *whdr, int *err)
{
/* "phdr->ts" may not necessarily be a "struct timeval" - it may
@ -1327,7 +1331,7 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
static gboolean libpcap_dump(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const u_char *pd, int *err)
const guchar *pd, int *err)
{
struct pcaprec_ss990915_hdr rec_hdr;
size_t hdr_size;

View File

@ -1,6 +1,6 @@
/* netmon.c
*
* $Id: netmon.c,v 1.57 2002/07/16 07:15:08 guy Exp $
* $Id: netmon.c,v 1.58 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -29,10 +29,6 @@
#include "file_wrappers.h"
#include "buffer.h"
#include "netmon.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
/* The file at
*
* ftp://ftp.microsoft.com/developr/drg/cifs/cifs/Bhfile.zip
@ -108,15 +104,15 @@ struct netmon_atm_hdr {
static gboolean netmon_read(wtap *wth, int *err, long *data_offset);
static gboolean netmon_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean netmon_read_rec_data(FILE_T fh, u_char *pd, int length,
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void netmon_sequential_close(wtap *wth);
static void netmon_close(wtap *wth);
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
int netmon_open(wtap *wth, int *err)
@ -447,7 +443,7 @@ static gboolean netmon_read(wtap *wth, int *err, long *data_offset)
static gboolean
netmon_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
@ -483,8 +479,8 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
return FALSE;
}
vpi = ntohs(atm_phdr.vpi);
vci = ntohs(atm_phdr.vci);
vpi = g_ntohs(atm_phdr.vpi);
vci = g_ntohs(atm_phdr.vci);
/*
* Assume it's AAL5, unless it's VPI 0 and VCI 5, in which case
@ -511,7 +507,7 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
}
static gboolean
netmon_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
netmon_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;
@ -616,7 +612,7 @@ gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
/* Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err)
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
netmon_dump_t *netmon = wdh->dump.netmon;
struct netmonrec_1_x_hdr rec_1_x_hdr;
@ -696,8 +692,8 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
*/
memset(&atm_hdr.dest, 0, sizeof atm_hdr.dest);
memset(&atm_hdr.src, 0, sizeof atm_hdr.src);
atm_hdr.vpi = htons(pseudo_header->atm.vpi);
atm_hdr.vci = htons(pseudo_header->atm.vci);
atm_hdr.vpi = g_htons(pseudo_header->atm.vpi);
atm_hdr.vci = g_htons(pseudo_header->atm.vci);
nwritten = fwrite(&atm_hdr, 1, sizeof atm_hdr, wdh->fh);
if (nwritten != sizeof atm_hdr) {
if (nwritten == 0 && ferror(wdh->fh))

View File

@ -1,6 +1,6 @@
/* nettl.c
*
* $Id: nettl.c,v 1.29 2002/06/07 07:27:35 guy Exp $
* $Id: nettl.c,v 1.30 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -32,10 +32,10 @@
#include "buffer.h"
#include "nettl.h"
static u_char nettl_magic_hpux9[12] = {
static guchar nettl_magic_hpux9[12] = {
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xD0, 0x00
};
static u_char nettl_magic_hpux10[12] = {
static guchar nettl_magic_hpux10[12] = {
0x54, 0x52, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80
};
@ -125,12 +125,12 @@ struct nettlrec_ns_ls_drv_eth_hdr {
static gboolean nettl_read(wtap *wth, int *err, long *data_offset);
static gboolean nettl_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd,
union wtap_pseudo_header *pseudo_header, guchar *pd,
int length, int *err);
static int nettl_read_rec_header(wtap *wth, FILE_T fh,
struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
int *err);
static gboolean nettl_read_rec_data(FILE_T fh, u_char *pd, int length,
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void nettl_close(wtap *wth);
@ -212,7 +212,7 @@ static gboolean nettl_read(wtap *wth, int *err, long *data_offset)
static gboolean
nettl_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd,
union wtap_pseudo_header *pseudo_header, guchar *pd,
int length, int *err)
{
int ret;
@ -443,7 +443,7 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
}
static gboolean
nettl_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;

View File

@ -1,6 +1,6 @@
/* netxray.c
*
* $Id: netxray.c,v 1.57 2002/07/16 07:15:09 guy Exp $
* $Id: netxray.c,v 1.58 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -130,7 +130,7 @@ union netxrayrec_hdr {
static gboolean netxray_read(wtap *wth, int *err, long *data_offset);
static gboolean netxray_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static int netxray_read_rec_header(wtap *wth, FILE_T fh,
union netxrayrec_hdr *hdr, int *err);
static void netxray_set_pseudo_header(wtap *wth,
@ -140,11 +140,11 @@ static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr,
static void netxray_close(wtap *wth);
static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err);
static gboolean netxray_dump_2_0(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err);
int netxray_open(wtap *wth, int *err)
@ -404,7 +404,7 @@ reread:
static gboolean
netxray_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
union netxrayrec_hdr hdr;
@ -585,7 +585,7 @@ gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err)
static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const u_char *pd, int *err)
const guchar *pd, int *err)
{
netxray_dump_t *netxray = wdh->dump.netxray;
guint32 timestamp;
@ -732,7 +732,7 @@ gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err)
static gboolean netxray_dump_2_0(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const u_char *pd, int *err)
const guchar *pd, int *err)
{
netxray_dump_t *netxray = wdh->dump.netxray;
guint32 timestamp;

View File

@ -1,6 +1,6 @@
/* ngsniffer.c
*
* $Id: ngsniffer.c,v 1.83 2002/07/16 07:15:09 guy Exp $
* $Id: ngsniffer.c,v 1.84 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -286,7 +286,7 @@ static double Usec[] = { 15.0, 0.838096, 15.0, 0.5, 2.0, 1.0, 0.1 };
static int skip_header_records(wtap *wth, int *err, gint16 version);
static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset);
static gboolean ngsniffer_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err);
static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
guint16 *typep, guint16 *lengthp, int *err);
@ -303,13 +303,13 @@ static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random,
static void set_pseudo_header_frame6(union wtap_pseudo_header *pseudo_header,
struct frame6_rec *frame6);
static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random,
u_char *pd, int length, int *err);
guchar *pd, int length, int *err);
static void fix_pseudo_header(wtap *wth,
union wtap_pseudo_header *pseudo_header);
static void ngsniffer_sequential_close(wtap *wth);
static void ngsniffer_close(wtap *wth);
static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err);
static int SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err );
@ -659,7 +659,7 @@ static gboolean ngsniffer_read(wtap *wth, int *err, long *data_offset)
struct frame6_rec frame6;
double t;
guint16 time_low, time_med, time_high, true_size, size;
u_char *pd;
guchar *pd;
for (;;) {
/*
@ -870,7 +870,7 @@ found:
}
static gboolean ngsniffer_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err)
{
int ret;
@ -1309,7 +1309,7 @@ static void set_pseudo_header_frame6(
}
static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random,
u_char *pd, int length, int *err)
guchar *pd, int length, int *err)
{
int bytes_read;
@ -1438,7 +1438,7 @@ gboolean ngsniffer_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
/* Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err)
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
ngsniffer_dump_t *priv = wdh->dump.ngsniffer;
struct frame2_rec rec_hdr;

View File

@ -1,6 +1,6 @@
/* radcom.c
*
* $Id: radcom.c,v 1.37 2002/06/07 07:27:35 guy Exp $
* $Id: radcom.c,v 1.38 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -69,11 +69,11 @@ struct radcomrec_hdr {
static gboolean radcom_read(wtap *wth, int *err, long *data_offset);
static gboolean radcom_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err);
static int radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr,
int *err);
static gboolean radcom_read_rec_data(FILE_T fh, u_char *pd, int length,
static gboolean radcom_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
int radcom_open(wtap *wth, int *err)
@ -297,7 +297,7 @@ static gboolean radcom_read(wtap *wth, int *err, long *data_offset)
static gboolean
radcom_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
int ret;
struct radcomrec_hdr hdr;
@ -345,7 +345,7 @@ radcom_read_rec_header(FILE_T fh, struct radcomrec_hdr *hdr, int *err)
}
static gboolean
radcom_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
radcom_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;

View File

@ -1,6 +1,6 @@
/* snoop.c
*
* $Id: snoop.c,v 1.53 2002/07/16 07:15:09 guy Exp $
* $Id: snoop.c,v 1.54 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -30,10 +30,6 @@
#include "buffer.h"
#include "atm.h"
#include "snoop.h"
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
/* See RFC 1761 for a description of the "snoop" file format. */
/* Magic number in "snoop" files. */
@ -68,13 +64,13 @@ struct snoop_atm_hdr {
static gboolean snoop_read(wtap *wth, int *err, long *data_offset);
static gboolean snoop_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err);
static gboolean snoop_read_atm_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err);
static gboolean snoop_read_rec_data(FILE_T fh, u_char *pd, int length,
static gboolean snoop_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static gboolean snoop_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
/*
* See
@ -260,8 +256,8 @@ int snoop_open(wtap *wth, int *err)
* only for padding, but if there's more, it's probably a Shomiti
* tool, which uses the padding for additional information.
*/
hdr.version = ntohl(hdr.version);
hdr.network = ntohl(hdr.network);
hdr.version = g_ntohl(hdr.version);
hdr.network = g_ntohl(hdr.network);
switch (hdr.version) {
case 2: /* Solaris 2.x and later snoop, and Shomiti
@ -328,9 +324,9 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
}
wth->data_offset += sizeof hdr;
rec_size = ntohl(hdr.rec_len);
orig_size = ntohl(hdr.orig_len);
packet_size = ntohl(hdr.incl_len);
rec_size = g_ntohl(hdr.rec_len);
orig_size = g_ntohl(hdr.orig_len);
packet_size = g_ntohl(hdr.incl_len);
if (packet_size > WTAP_MAX_PACKET_SIZE) {
/*
* Probably a corrupt capture file; don't blow up trying
@ -380,8 +376,8 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
return FALSE; /* Read error */
wth->data_offset += packet_size;
wth->phdr.ts.tv_sec = ntohl(hdr.ts_sec);
wth->phdr.ts.tv_usec = ntohl(hdr.ts_usec);
wth->phdr.ts.tv_sec = g_ntohl(hdr.ts_sec);
wth->phdr.ts.tv_usec = g_ntohl(hdr.ts_usec);
wth->phdr.caplen = packet_size;
wth->phdr.len = orig_size;
wth->phdr.pkt_encap = wth->file_encap;
@ -425,7 +421,7 @@ static gboolean snoop_read(wtap *wth, int *err, long *data_offset)
static gboolean
snoop_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int length, int *err)
union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
@ -547,7 +543,7 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
}
static gboolean
snoop_read_rec_data(FILE_T fh, u_char *pd, int length, int *err)
snoop_read_rec_data(FILE_T fh, guchar *pd, int length, int *err)
{
int bytes_read;
@ -617,8 +613,8 @@ gboolean snoop_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
}
/* current "snoop" format is 2 */
file_hdr.version = htonl(2);
file_hdr.network = htonl(wtap_encap[wdh->encap]);
file_hdr.version = g_htonl(2);
file_hdr.network = g_htonl(wtap_encap[wdh->encap]);
nwritten = fwrite(&file_hdr, 1, sizeof file_hdr, wdh->fh);
if (nwritten != sizeof file_hdr) {
if (nwritten == 0 && ferror(wdh->fh))
@ -636,7 +632,7 @@ gboolean snoop_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
static gboolean snoop_dump(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header _U_,
const u_char *pd, int *err)
const guchar *pd, int *err)
{
struct snooprec_hdr rec_hdr;
size_t nwritten;
@ -658,12 +654,12 @@ static gboolean snoop_dump(wtap_dumper *wdh,
padlen = ((reclen + 3) & ~3) - reclen;
reclen += padlen;
rec_hdr.orig_len = htonl(phdr->len + atm_hdrsize);
rec_hdr.incl_len = htonl(phdr->caplen + atm_hdrsize);
rec_hdr.rec_len = htonl(reclen);
rec_hdr.orig_len = g_htonl(phdr->len + atm_hdrsize);
rec_hdr.incl_len = g_htonl(phdr->caplen + atm_hdrsize);
rec_hdr.rec_len = g_htonl(reclen);
rec_hdr.cum_drops = 0;
rec_hdr.ts_sec = htonl(phdr->ts.tv_sec);
rec_hdr.ts_usec = htonl(phdr->ts.tv_usec);
rec_hdr.ts_sec = g_htonl(phdr->ts.tv_sec);
rec_hdr.ts_usec = g_htonl(phdr->ts.tv_usec);
nwritten = fwrite(&rec_hdr, 1, sizeof rec_hdr, wdh->fh);
if (nwritten != sizeof rec_hdr) {
if (nwritten == 0 && ferror(wdh->fh))
@ -707,7 +703,7 @@ static gboolean snoop_dump(wtap_dumper *wdh,
break;
}
atm_hdr.vpi = pseudo_header->atm.vpi;
atm_hdr.vci = htons(pseudo_header->atm.vci);
atm_hdr.vci = g_htons(pseudo_header->atm.vci);
nwritten = fwrite(&atm_hdr, 1, sizeof atm_hdr, wdh->fh);
if (nwritten != sizeof atm_hdr) {
if (nwritten == 0 && ferror(wdh->fh))

View File

@ -2,7 +2,7 @@
* File read and write routines for Visual Networks cap files.
* Copyright (c) 2001, Tom Nisbet tnisbet@visualnetworks.com
*
* $Id: visual.c,v 1.9 2002/07/16 07:15:09 guy Exp $
* $Id: visual.c,v 1.10 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -115,10 +115,10 @@ struct visual_write_info
static gboolean visual_read(wtap *wth, int *err, long *data_offset);
static void visual_close(wtap *wth);
static gboolean visual_seek_read(wtap *wth, long seek_off,
union wtap_pseudo_header *pseudo_header, u_char *pd, int packet_size,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err);
static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean visual_dump_close(wtap_dumper *wdh, int *err);
static void visual_dump_free(wtap_dumper *wdh);
@ -451,7 +451,7 @@ gboolean visual_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
/* Write a packet to a Visual dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const u_char *pd, int *err)
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
struct visual_write_info * visual = wdh->dump.opaque;
struct visual_pkt_hdr vpkt_hdr;

View File

@ -1,6 +1,6 @@
/* wtap_capture.h
*
* $Id: wtap-capture.h,v 1.1 2002/06/07 21:11:24 guy Exp $
* $Id: wtap-capture.h,v 1.2 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -25,8 +25,8 @@
/* XXX - needed until "wiretap" can do live packet captures */
int wtap_pcap_encap_to_wtap_encap(int encap);
const u_char *wtap_process_pcap_packet(gint linktype,
const struct pcap_pkthdr *phdr, const u_char *pd,
const guchar *wtap_process_pcap_packet(gint linktype,
const struct pcap_pkthdr *phdr, const guchar *pd,
union wtap_pseudo_header *pseudo_header, struct wtap_pkthdr *whdr,
int *err);

View File

@ -1,6 +1,6 @@
/* wtap-int.h
*
* $Id: wtap-int.h,v 1.25 2002/06/23 10:32:36 guy Exp $
* $Id: wtap-int.h,v 1.26 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -23,18 +23,10 @@
#ifndef __WTAP_INT_H__
#define __WTAP_INT_H__
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <glib.h>
#include <stdio.h>
#include <time.h>
@ -163,7 +155,7 @@ struct wtap_dumper;
typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
const struct wtap_pkthdr*, const union wtap_pseudo_header*,
const u_char*, int*);
const guchar*, int*);
typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*);
typedef struct {

View File

@ -1,6 +1,6 @@
/* wtap.c
*
* $Id: wtap.c,v 1.67 2002/07/16 07:15:09 guy Exp $
* $Id: wtap.c,v 1.68 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -291,7 +291,7 @@ wtap_buf_ptr(wtap *wth)
}
gboolean
wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user, int *err)
wtap_loop(wtap *wth, int count, wtap_handler callback, guchar* user, int *err)
{
long data_offset;
int loop = 0;

View File

@ -1,6 +1,6 @@
/* wtap.h
*
* $Id: wtap.h,v 1.117 2002/07/16 07:15:09 guy Exp $
* $Id: wtap.h,v 1.118 2002/07/29 06:09:59 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@ -23,6 +23,13 @@
#ifndef __WTAP_H__
#define __WTAP_H__
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <glib.h>
#include <stdio.h>
/* Encapsulation types. Choose names that truly reflect
* what is contained in the packet trace file.
*
@ -155,21 +162,6 @@
*/
#define WTAP_MAX_PACKET_SIZE 65535
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <glib.h>
#include <stdio.h>
/*
* "Pseudo-headers" are used to supply to the clients of wiretap
* per-packet information that's not part of the packet payload
@ -314,8 +306,8 @@ struct wtap_pkthdr {
int pkt_encap;
};
typedef void (*wtap_handler)(u_char*, const struct wtap_pkthdr*,
long, union wtap_pseudo_header *pseudo_header, const u_char *);
typedef void (*wtap_handler)(guchar*, const struct wtap_pkthdr*,
long, union wtap_pseudo_header *pseudo_header, const guchar *);
struct wtap;
struct Buffer;
@ -336,7 +328,7 @@ struct wtap* wtap_open_offline(const char *filename, int *err, gboolean do_rando
/* Returns TRUE if entire loop-reading was successful. If read failure
* happened, FALSE is returned and err is set. */
gboolean wtap_loop(wtap *wth, int, wtap_handler, u_char*, int *err);
gboolean wtap_loop(wtap *wth, int, wtap_handler, guchar*, int *err);
/* Returns TRUE if read was successful. FALSE if failure. data_offset is
* set the the offset in the file where the data for the read packet is
@ -375,7 +367,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 wtap_pseudo_header *pseudo_header, const u_char *, int *err);
const union wtap_pseudo_header *pseudo_header, const guchar *, int *err);
FILE* wtap_dump_file(wtap_dumper *);
gboolean wtap_dump_close(wtap_dumper *, int *);
long wtap_get_bytes_dumped(wtap_dumper *);