Skip to content

Commit

Permalink
There's no need for a member of a "capture_file" structure holding a
Browse files Browse the repository at this point in the history
compiled capture filter program, so remove it, and remove the include of
<pcap.h> from "file.h"; instead, have local "struct bpf_program"
structures where needed, and have those files that need stuff from
<pcap.h> include it.

This cleans stuff up a bit, and should eliminate a pile of compile
warnings with Visual C++ due to <pcap.h> and some GTK+/GLib header file
(or files they include) both defining "inline".

svn path=/trunk/; revision=2954
  • Loading branch information
guyharris committed Jan 28, 2001
1 parent 22a76b4 commit 00fcdc0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
13 changes: 6 additions & 7 deletions capture.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
* $Id: capture.c,v 1.136 2001/01/13 03:17:15 gram Exp $
* $Id: capture.c,v 1.137 2001/01/28 23:56:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
Expand Down Expand Up @@ -100,14 +100,12 @@
#include <signal.h>
#include <errno.h>

#include <pcap.h>

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif

#ifndef lib_pcap_h
#include <pcap.h>
#endif

#ifdef _WIN32
#include <process.h> /* For spawning child process */
#endif
Expand Down Expand Up @@ -1119,6 +1117,7 @@ capture(void)
int snaplen;
gchar err_str[PCAP_ERRBUF_SIZE], label_str[64];
bpf_u_int32 netnum, netmask;
struct bpf_program fcode;
time_t upd_time, cur_time;
int err, inpkts, i;
char errmsg[4096+1];
Expand Down Expand Up @@ -1279,12 +1278,12 @@ capture(void)
*/
netmask = 0;
}
if (pcap_compile(pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) {
if (pcap_compile(pch, &fcode, cfile.cfilter, 1, netmask) < 0) {
snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).",
pcap_geterr(pch));
goto error;
}
if (pcap_setfilter(pch, &cfile.fcode) < 0) {
if (pcap_setfilter(pch, &fcode) < 0) {
snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).",
pcap_geterr(pch));
goto error;
Expand Down
9 changes: 1 addition & 8 deletions file.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* file.h
* Definitions for file structures and routines
*
* $Id: file.h,v 1.78 2000/10/20 04:26:38 gram Exp $
* $Id: file.h,v 1.79 2001/01/28 23:56:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
Expand Down Expand Up @@ -32,10 +32,6 @@

#include "wiretap/wtap.h"

#ifdef HAVE_LIBPCAP
#include <pcap.h>
#endif

#include "dfilter.h"
#include "print.h"

Expand All @@ -56,8 +52,6 @@
#define file_close fclose
#endif /* HAVE_LIBZ */

typedef struct bpf_program bpf_prog;

/* Current state of file. */
typedef enum {
FILE_CLOSED, /* No file open */
Expand Down Expand Up @@ -93,7 +87,6 @@ typedef struct _capture_file {
dfilter *dfcode; /* Compiled display filter program */
#ifdef HAVE_LIBPCAP
gchar *cfilter; /* Capture filter string */
bpf_prog fcode; /* Compiled capture filter program */
#endif
gchar *sfilter; /* Search filter string */
gboolean sbackward; /* TRUE if search is backward, FALSE if forward */
Expand Down
4 changes: 3 additions & 1 deletion gtk/capture_dlg.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
* $Id: capture_dlg.c,v 1.36 2001/01/02 01:32:21 guy Exp $
* $Id: capture_dlg.c,v 1.37 2001/01/28 23:56:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
Expand Down Expand Up @@ -41,6 +41,8 @@

#include <time.h>

#include <pcap.h>

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
Expand Down
6 changes: 5 additions & 1 deletion gtk/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.175 2001/01/28 09:13:10 guy Exp $
* $Id: main.c,v 1.176 2001/01/28 23:56:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
Expand Down Expand Up @@ -73,6 +73,10 @@

#include <signal.h>

#ifdef HAVE_LIBPCAP
#include <pcap.h>
#endif

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
Expand Down
9 changes: 6 additions & 3 deletions tethereal.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.61 2001/01/04 00:16:43 guy Exp $
* $Id: tethereal.c,v 1.62 2001/01/28 23:56:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
Expand Down Expand Up @@ -53,6 +53,8 @@

#include <signal.h>

#include <pcap.h>

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
Expand Down Expand Up @@ -531,6 +533,7 @@ capture(int packet_count, int out_file_type)
{
gchar err_str[PCAP_ERRBUF_SIZE];
bpf_u_int32 netnum, netmask;
struct bpf_program fcode;
void (*oldhandler)(int);
int err, inpkts;
char errmsg[1024+1];
Expand Down Expand Up @@ -609,12 +612,12 @@ capture(int packet_count, int out_file_type)
"Warning: Couldn't obtain netmask info (%s)\n.", err_str);
netmask = 0;
}
if (pcap_compile(ld.pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) {
if (pcap_compile(ld.pch, &fcode, cfile.cfilter, 1, netmask) < 0) {
snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).",
pcap_geterr(ld.pch));
goto error;
}
if (pcap_setfilter(ld.pch, &cfile.fcode) < 0) {
if (pcap_setfilter(ld.pch, &fcode) < 0) {
snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).",
pcap_geterr(ld.pch));
goto error;
Expand Down
4 changes: 3 additions & 1 deletion util.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
* $Id: util.c,v 1.48 2000/12/23 19:50:36 guy Exp $
* $Id: util.c,v 1.49 2001/01/28 23:56:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
Expand Down Expand Up @@ -75,6 +75,8 @@ typedef int mode_t; /* for win32 */
#include <sys/ioctl.h>
#endif

#include <pcap.h>

#ifndef WIN32
#include <net/if.h>
#endif
Expand Down

0 comments on commit 00fcdc0

Please sign in to comment.