diff options
author | Guy Harris <guy@alum.mit.edu> | 2010-02-23 03:50:42 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2010-02-23 03:50:42 +0000 |
commit | c85899e946cf25597d3bd1328632bbb5c5456012 (patch) | |
tree | 864989b98b67999c070743fbddc217c37a99e1f8 /wiretap | |
parent | add4e4dfbd7ea5bd6f5e435413633605c627a0f7 (diff) |
Move the declarations of wtap_pcap_encap_to_wtap_encap() and
wtap_wtap_encap_to_pcap_encap() to wiretap/pcap-encap.h. Include it
where it's needed; don't include other Wiretap headers where they're not
needed.
Include pcapng.h in pcapng.c, to declare the functions defined in
pcapng.c. Add some casts to squelch some warnings, and add to a comment
to indicate one of the problems.
svn path=/trunk/; revision=31960
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/Makefile.common | 1 | ||||
-rw-r--r-- | wiretap/libpcap.c | 1 | ||||
-rw-r--r-- | wiretap/libpcap.h | 1 | ||||
-rw-r--r-- | wiretap/pcap-common.c | 1 | ||||
-rw-r--r-- | wiretap/pcap-common.h | 2 | ||||
-rw-r--r-- | wiretap/pcap-encap.h | 28 | ||||
-rw-r--r-- | wiretap/pcapng.c | 15 |
7 files changed, 43 insertions, 6 deletions
diff --git a/wiretap/Makefile.common b/wiretap/Makefile.common index 531f22dc03..0a4de5d6b0 100644 --- a/wiretap/Makefile.common +++ b/wiretap/Makefile.common @@ -116,6 +116,7 @@ NONGENERATED_HEADER_FILES = \ ngsniffer.h \ packetlogger.h \ pcap-common.h \ + pcap-encap.h \ pcapng.h \ pppdump.h \ radcom.h \ diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index cdca16f234..b36cb9d3b0 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -32,6 +32,7 @@ #include "buffer.h" #include "atm.h" #include "pcap-common.h" +#include "pcap-encap.h" #include "libpcap.h" /* See source to the "libpcap" library for information on the "libpcap" diff --git a/wiretap/libpcap.h b/wiretap/libpcap.h index 7ade3e7132..401cf343a7 100644 --- a/wiretap/libpcap.h +++ b/wiretap/libpcap.h @@ -101,6 +101,5 @@ struct pcaprec_nokia_hdr { int libpcap_open(wtap *wth, int *err, gchar **err_info); gboolean libpcap_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err); int libpcap_dump_can_write_encap(int encap); -int wtap_pcap_encap_to_wtap_encap(int encap); #endif diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index 19b9a8d8da..d404859ca8 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -34,6 +34,7 @@ #include "wtap-int.h" #include "file_wrappers.h" #include "erf.h" +#include "pcap-encap.h" #include "pcap-common.h" /* diff --git a/wiretap/pcap-common.h b/wiretap/pcap-common.h index cf4f81ed1e..60762abe77 100644 --- a/wiretap/pcap-common.h +++ b/wiretap/pcap-common.h @@ -24,8 +24,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -extern int wtap_wtap_encap_to_pcap_encap(int encap); - extern int pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, gboolean byte_swapped, guint packet_size, gboolean check_packet_size, struct wtap_pkthdr *phdr, diff --git a/wiretap/pcap-encap.h b/wiretap/pcap-encap.h new file mode 100644 index 0000000000..97482ae7bc --- /dev/null +++ b/wiretap/pcap-encap.h @@ -0,0 +1,28 @@ +/* pcap-encap.h + * Declarations for routines to handle libpcap/pcap-NG linktype values + * + * $Id: pcap-common.h 28863 2009-06-27 16:08:18Z tuexen $ + * + * Wiretap Library + * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> + * + * File format support for pcap-ng file format + * Copyright (c) 2007 by Ulf Lamping <ulf.lamping@web.de> + * + * 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. + * + * 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. + * + * 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. + */ + +extern int wtap_pcap_encap_to_wtap_encap(int encap); +extern int wtap_wtap_encap_to_pcap_encap(int encap); diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index f3bc3a2f71..905d96a73d 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -41,6 +41,8 @@ #include "buffer.h" #include "libpcap.h" #include "pcap-common.h" +#include "pcap-encap.h" +#include "pcapng.h" #if 0 #define pcapng_debug0(str) g_warning(str) @@ -252,7 +254,14 @@ typedef struct wtapng_block_s { wtapng_if_stats_t if_stats; } data; - /* XXX - currently don't know how to handle these! */ + /* + * XXX - currently don't know how to handle these! + * + * For one thing, when we're reading a block, they must be + * writable, i.e. not const, so that we can read into them, + * but, when we're writing a block, they can be const, and, + * in fact, they sometimes point to const values. + */ const union wtap_pseudo_header *pseudo_header; struct wtap_pkthdr *packet_header; const guchar *frame_buffer; @@ -1264,7 +1273,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info) wth->file_encap = WTAP_ENCAP_UNKNOWN; wth->snapshot_length = 0; wth->tsprecision = WTAP_FILE_TSPREC_NSEC; - wth->capture.pcapng = g_malloc(sizeof(pcapng_t)); + wth->capture.pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t)); *wth->capture.pcapng = pn; wth->subtype_read = pcapng_read; wth->subtype_seek_read = pcapng_seek_read; @@ -1766,7 +1775,7 @@ pcapng_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err) /* This is a pcapng file */ wdh->subtype_write = pcapng_dump; wdh->subtype_close = pcapng_dump_close; - wdh->dump.pcapng = g_malloc(sizeof(pcapng_dump_t)); + wdh->dump.pcapng = (pcapng_dump_t *)g_malloc(sizeof(pcapng_dump_t)); wdh->dump.pcapng->interface_data = g_array_new(FALSE, FALSE, sizeof(interface_data_t)); wdh->dump.pcapng->number_of_interfaces = 0; |