aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2000-02-09 19:18:42 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2000-02-09 19:18:42 +0000
commitf9a8a11ef521d6d9ae6160a8d75085264f07d8e2 (patch)
tree084de5debceb828e118edd682e44e95e968dfc14
parentae1f986db1bc9e03e50dbf0a14985fb509e7a44f (diff)
Integrate Ed Meaney's <emeaney@altiga.com> changes for using libpcap
from WinDump with Ethereal. We now have packet capturing on Win32. :) svn path=/trunk/; revision=1612
-rw-r--r--Makefile.nmake20
-rw-r--r--README.win3216
-rw-r--r--capture.c16
-rw-r--r--config.h.win322
-rw-r--r--config.nmake5
-rw-r--r--gtk/Makefile.nmake3
-rw-r--r--gtk/main.c6
-rw-r--r--mkstemp.c5
-rw-r--r--packet-ip.c5
-rw-r--r--plugins/Makefile.nmake7
-rw-r--r--plugins/gryphon/Makefile.nmake7
-rw-r--r--snprintf.c2
-rw-r--r--util.c30
13 files changed, 96 insertions, 28 deletions
diff --git a/Makefile.nmake b/Makefile.nmake
index 08ed023218..fa8472c338 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -9,10 +9,11 @@ CC = cl
LINK= link
LDFLAGS = /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /MACHINE:I386 \
- /OUT:ethereal.exe
+ $(LOCAL_LDFLAGS) /OUT:ethereal.exe
CFLAGS=-DHAVE_CONFIG_H $(LOCAL_CFLAGS) /I$(GLIB_DIR) /I$(GLIB_DIR)\gmodule \
- /I$(GTK_DIR) /Iwiretap /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32
+ /I$(GTK_DIR) /Iwiretap /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 \
+ /I$(PCAP_DIR)/include
DISSECTOR_OBJECTS = \
packet-aarp.obj \
@@ -159,15 +160,16 @@ EXTRA_ethereal_OBJECTS = \
inet_ntop.obj
-LIBS= wiretap\libwtap.lib gtk\libui.lib wsock32.lib \
+LIBS= wiretap\libwtap.lib gtk\libui.lib wsock32.lib user32.lib \
$(GTK_DIR)\gtk\gtk-$(GTK_VERSION).lib \
$(GTK_DIR)\gdk\win32\gdk-$(GTK_VERSION).lib \
$(GLIB_DIR)\glib-$(GLIB_VERSION).lib \
- $(GLIB_DIR)\gmodule-$(GLIB_VERSION).lib
+ $(GLIB_DIR)\gmodule-$(GLIB_VERSION).lib \
+ $(PCAP_DIR)\lib\libpcap.lib
-all: ethereal.exe plugins\plugins_api.obj
+all: ethereal.exe
-ethereal.exe : config.h $(ethereal_OBJECTS) $(EXTRA_ethereal_OBJECTS) wiretap\libwtap.lib gtk\libui.lib
+ethereal.exe : config.h $(ethereal_OBJECTS) $(EXTRA_ethereal_OBJECTS) wiretap gtk plugins
$(LINK) @<<
$(LDFLAGS) $(LIBS) $(ethereal_OBJECTS) $(EXTRA_ethereal_OBJECTS)
<<
@@ -189,17 +191,17 @@ dfilter-grammar.c dfilter-grammer.h : dfilter-grammar.y
clean:
rm -f $(ethereal_OBJECTS) $(EXTRA_ethereal_OBJECTS) ethereal.exe
-wiretap\libwtap.lib::
+wiretap::
cd wiretap
nmake -f Makefile.nmake
cd ..
-gtk\libui.lib::
+gtk::
cd gtk
nmake -f Makefile.nmake
cd ..
-plugins\plugins_api.obj::
+plugins::
cd plugins
nmake -f Makefile.nmake
cd ..
diff --git a/README.win32 b/README.win32
index 828c913882..2a6575c89f 100644
--- a/README.win32
+++ b/README.win32
@@ -1,4 +1,4 @@
-$Id: README.win32,v 1.5 2000/02/09 00:41:02 gram Exp $
+$Id: README.win32,v 1.6 2000/02/09 19:17:50 gram Exp $
Ethereal can be compiled on Win32 platforms. Some libraries are
needed, however.
@@ -31,13 +31,21 @@ or
http://www.iki.fi/~tml/gimp/win32/index-19990828.html
+A win32 version libpcap is also needed. You'll need the WinDump
+developer's pack available from
+http://netgroup-serv.polito.it/windump/install/download.htm
+
+In order to capture with Win32, you need to install the NDIS
+packet capture driver available from the same WinDump site.
+
+The home page for WinDump (TCPdump for Windows) is at:
+http://netgroup-serv.polito.it/windump/
+
+
The UCD SNMP library for win32 can be had from
ftp://ftp.revelstone.com/pub/snmp/, but it has not been tested
with Ethereal.
-The win32 versions of libpcap have not been integrated into
-Ethereal yet.
-
Zlib (or 'libz') is available for Win32 from
http://www.winimage.com/zLibDll/
but also has not been made to work successfully with Ethereal.
diff --git a/capture.c b/capture.c
index 91accb6484..957703a96d 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.94 2000/02/02 18:38:52 gram Exp $
+ * $Id: capture.c,v 1.95 2000/02/09 19:17:50 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -41,6 +41,9 @@
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#include <gtk/gtk.h>
#include <stdlib.h>
@@ -115,6 +118,11 @@ typedef struct _loop_data {
wtap_dumper *pdh;
} loop_data;
+/* Win32 needs the O_BINARY flag for open() */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
/* Open a specified file, or create a temporary file, and start a capture
to the file in question. */
void
@@ -131,7 +139,7 @@ do_capture(char *capfile_name)
if (capfile_name != NULL) {
/* Try to open/create the specified file for use as a capture buffer. */
- cf.save_file_fd = open(capfile_name, O_RDWR|O_TRUNC|O_CREAT, 0600);
+ cf.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600);
is_tempfile = FALSE;
} else {
/* Choose a random name for the capture buffer */
@@ -150,6 +158,7 @@ do_capture(char *capfile_name)
cf.save_file = capfile_name;
if (sync_mode) { /* use fork() for capture */
+#ifndef _WIN32
int fork_child;
char ssnap[24];
char scount[24]; /* need a constant for len of numbers */
@@ -283,6 +292,7 @@ do_capture(char *capfile_name)
}
}
}
+#endif
} else {
/* Not sync mode. */
capture_succeeded = capture();
@@ -305,6 +315,7 @@ do_capture(char *capfile_name)
}
}
+#ifndef _WIN32
/* There's stuff to read from the sync pipe, meaning the child has sent
us a message, or the sync pipe has closed, meaning the child has
closed it (perhaps because it exited). */
@@ -474,6 +485,7 @@ cap_file_input_cb(gpointer data, gint source, GdkInputCondition condition)
(gpointer) cf,
NULL);
}
+#endif /* _WIN32 */
/*
* Timeout, in milliseconds, for reads from the stream of captured packets.
diff --git a/config.h.win32 b/config.h.win32
index ea3e6e4a18..0922d8dcbd 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -51,7 +51,7 @@
/* #define HAVE_UNISTD_H 1 */
/* Define if you have the pcap library (-lpcap). */
-/* #define HAVE_LIBPCAP 1 */
+#define HAVE_LIBPCAP 1
/* Define if you have the z library (-lz). */
/*#define HAVE_LIBZ 1*/
diff --git a/config.nmake b/config.nmake
index 1a6366a042..5056a3816a 100644
--- a/config.nmake
+++ b/config.nmake
@@ -5,7 +5,10 @@ GLIB_VERSION=1.3
GLIB_DIR=T:\w32-ix86\ethereal\glib
GTK_DIR=T:\w32-ix86\ethereal\gtk+
-LOCAL_CFLAGS=
+PCAP_DIR=T:\w32-ix86\ethereal\WDdpack
+
+LOCAL_CFLAGS=-Zi
+LOCAL_LDFLAGS=/DEBUG
LEX=t:\w32-ix86\cygnus\cygwin-b20\H-i586-cygwin32\bin\flex
YACC=t:\w32-ix86\cygnus\cygwin-b20\H-i586-cygwin32\bin\bison
diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake
index 3202513275..b1842d8e57 100644
--- a/gtk/Makefile.nmake
+++ b/gtk/Makefile.nmake
@@ -4,7 +4,8 @@ include ..\config.nmake
CFLAGS=/DHAVE_CONFIG_H /I.. /I../wiretap \
/I$(GLIB_DIR) /I$(GTK_DIR) /I$(GLIB_DIR)/gmodule \
- /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 $(LOCAL_CFLAGS)
+ /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 \
+ /I$(PCAP_DIR)\include $(LOCAL_CFLAGS)
# gtkclist.obj is not in here because it is gtk+-1.2 code,
# while the DLL for GTK+ on windows is gtk+-1.3, and there's
diff --git a/gtk/main.c b/gtk/main.c
index 408fc5b0aa..cea03affc8 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.102 2000/01/29 16:41:28 gram Exp $
+ * $Id: main.c,v 1.103 2000/02/09 19:18:04 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1021,8 +1021,12 @@ main(int argc, char *argv[])
gboolean arg_error = FALSE;
#endif
#ifdef HAVE_LIBPCAP
+#ifdef WIN32
+ char pcap_version[] = "0.4a6";
+#else
extern char pcap_version[];
#endif
+#endif
char *pf_path;
int pf_open_errno = 0;
int err;
diff --git a/mkstemp.c b/mkstemp.c
index 3245cff177..90051bdaf4 100644
--- a/mkstemp.c
+++ b/mkstemp.c
@@ -36,6 +36,9 @@
#ifndef __set_errno
#define __set_errno(x) errno=(x)
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
@@ -68,7 +71,7 @@ mkstemp (template)
template[len - 6] = letters[i];
- fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+ fd = open (template, O_RDWR|O_BINARY|O_CREAT|O_EXCL, 0600);
if (fd >= 0)
return fd;
}
diff --git a/packet-ip.c b/packet-ip.c
index 71930ecfb8..d2ae6a4b5d 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.72 2000/02/02 22:07:38 oabad Exp $
+ * $Id: packet-ip.c,v 1.73 2000/02/09 19:17:51 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1040,6 +1040,9 @@ again:
case IP_PROTO_IPV6:
dissect_ipv6(pd, offset, fd, tree);
break;
+ case IP_PROTO_IPV4:
+ dissect_ip(pd, offset, fd, tree);
+ break;
case IP_PROTO_PIM:
dissect_pim(pd, offset, fd, tree);
break;
diff --git a/plugins/Makefile.nmake b/plugins/Makefile.nmake
index 5da3f0c404..1292b55d75 100644
--- a/plugins/Makefile.nmake
+++ b/plugins/Makefile.nmake
@@ -4,13 +4,14 @@ include ..\config.nmake
CFLAGS=/DHAVE_CONFIG_H /I.. /I../wiretap /I. \
/I$(GLIB_DIR) /I$(GTK_DIR) /I$(GLIB_DIR)/gmodule \
- /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 $(LOCAL_CFLAGS)
+ /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 \
+ /I$(PCAP_DIR)\include $(LOCAL_CFLAGS)
OBJECTS=plugin_api.obj
-all: plugin_api.obj gryphon\gryphon.dll
+all: plugin_api.obj gryphon
-gryphon\gryphon.dll::
+gryphon::
cd gryphon
nmake -f Makefile.nmake
cd ..
diff --git a/plugins/gryphon/Makefile.nmake b/plugins/gryphon/Makefile.nmake
index b9a4b32b59..a94683a344 100644
--- a/plugins/gryphon/Makefile.nmake
+++ b/plugins/gryphon/Makefile.nmake
@@ -4,9 +4,10 @@ include ..\..\config.nmake
CFLAGS=/DHAVE_CONFIG_H /I../.. /I../wiretap \
/I$(GLIB_DIR) /I$(GTK_DIR) /I$(GLIB_DIR)/gmodule \
- /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 $(LOCAL_CFLAGS)
+ /I$(GTK_DIR)\gdk /I$(GTK_DIR)\gdk\win32 \
+ /I$(PCAP_DIR)\include $(LOCAL_CFLAGS)
OBJECTS=packet-gryphon.obj
-gryphon.dll gryphon.exp gryphon.lib : packet-gryphon.obj
- link -dll /out:gryphon.dll packet-gryphon.obj ../plugin_api.obj
+gryphon.dll gryphon.exp gryphon.lib : packet-gryphon.obj ..\plugin_api.obj
+ link -dll /out:gryphon.dll packet-gryphon.obj ..\plugin_api.obj
diff --git a/snprintf.c b/snprintf.c
index 7bf36f4deb..13cc4a3047 100644
--- a/snprintf.c
+++ b/snprintf.c
@@ -90,6 +90,8 @@ double r;
if (r < 0.)
r = -r;
+ if (r == 0.0)
+ return(0);
if (r < 1.) {
while (result >= r) {result *= .1; i++;}
return (-i);
diff --git a/util.c b/util.c
index 155d77434b..70d86d82ee 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.35 2000/01/31 19:34:25 gram Exp $
+ * $Id: util.c,v 1.36 2000/02/09 19:17:52 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -416,6 +416,7 @@ search_for_if_cb(gpointer data, gpointer user_data);
static void
free_if_cb(gpointer data, gpointer user_data);
+#ifndef WIN32
GList *
get_interface_list(int *err, char *err_str)
{
@@ -562,6 +563,33 @@ search_for_if_cb(gpointer data, gpointer user_data)
if (strcmp((char *)data, search_user_data->name) == 0)
search_user_data->found = TRUE;
}
+#else
+GList *
+get_interface_list(int *err, char *err_str) {
+ GList *il = NULL;
+ wchar_t *names;
+ char newname[255];
+ int i, j, done;
+
+ names = (wchar_t *)pcap_lookupdev(err_str);
+ i = done = 0;
+
+ if (names)
+ do
+ {
+ j = 0;
+ while (names[i] != 0)
+ newname[j++] = names[i++];
+ i++;
+ if (names[i] == 0)
+ done = 1;
+ newname[j++] = 0;
+ il = g_list_append(il, g_strdup(newname));
+ } while (!done);
+
+ return(il);
+}
+#endif
static void
free_if_cb(gpointer data, gpointer user_data)