diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-07-07 22:52:57 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-07-07 22:52:57 +0000 |
commit | 07f42b5b31f9523deeb147226521f77a2c8dd797 (patch) | |
tree | c720d2a42f11c9d14ac1a161eb785b438c2c4b14 /wiretap | |
parent | fba49cfe85d4b23ebbffa97fae126a379e913ecd (diff) | |
download | wireshark-07f42b5b31f9523deeb147226521f77a2c8dd797.tar.gz wireshark-07f42b5b31f9523deeb147226521f77a2c8dd797.tar.bz2 wireshark-07f42b5b31f9523deeb147226521f77a2c8dd797.zip |
Created a new protocol tree implementation and a new display filter
mechanism that is built into ethereal. Wiretap is now used to read all
file formats. Libpcap is used only for capturing.
svn path=/trunk/; revision=342
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ChangeLog | 4 | ||||
-rw-r--r-- | wiretap/Makefile.am | 71 | ||||
-rw-r--r-- | wiretap/Makefile.in | 166 | ||||
-rw-r--r-- | wiretap/aclocal.m4 | 4 | ||||
-rw-r--r-- | wiretap/bpf-engine.c | 318 | ||||
-rw-r--r-- | wiretap/bpf-engine.h | 120 | ||||
-rw-r--r-- | wiretap/bpf.c | 373 | ||||
-rw-r--r-- | wiretap/bpf.h | 22 | ||||
-rwxr-xr-x | wiretap/configure | 146 | ||||
-rw-r--r-- | wiretap/configure.in | 21 | ||||
-rw-r--r-- | wiretap/ct-compile.c | 487 | ||||
-rw-r--r-- | wiretap/ct-compile.h | 104 | ||||
-rw-r--r-- | wiretap/ct-grammar.y | 149 | ||||
-rw-r--r-- | wiretap/ct-main.c | 24 | ||||
-rw-r--r-- | wiretap/ct-scanner.l | 74 | ||||
-rw-r--r-- | wiretap/file.c | 6 | ||||
-rw-r--r-- | wiretap/filter-eth | 38 | ||||
-rw-r--r-- | wiretap/filter-tr | 57 | ||||
-rw-r--r-- | wiretap/glib-new.c | 105 | ||||
-rw-r--r-- | wiretap/glib-new.h | 30 | ||||
-rw-r--r-- | wiretap/rt-compile.c | 82 | ||||
-rw-r--r-- | wiretap/rt-compile.h | 29 | ||||
-rw-r--r-- | wiretap/rt-global.h | 23 | ||||
-rw-r--r-- | wiretap/rt-grammar-skel.y | 134 | ||||
-rw-r--r-- | wiretap/rt-scanner-skel.l | 160 | ||||
-rw-r--r-- | wiretap/wtap.c | 32 | ||||
-rw-r--r-- | wiretap/wtap.h | 14 |
27 files changed, 112 insertions, 2681 deletions
diff --git a/wiretap/ChangeLog b/wiretap/ChangeLog index 34dc54b7c4..9b7f7681cd 100644 --- a/wiretap/ChangeLog +++ b/wiretap/ChangeLog @@ -1,3 +1,6 @@ +July 7, 1999 + Removed display filter support. + May 12, 1999 Guy added support for Netmon 2.0 files. @@ -26,3 +29,4 @@ January 1, 1999 December 10, 1998 Proper timestamp calculations added to ngsniffer.c and lanalyzer.c + diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am index 60bb34af84..77c3e73398 100644 --- a/wiretap/Makefile.am +++ b/wiretap/Makefile.am @@ -1,35 +1,12 @@ -bin_PROGRAMS = wiretap -noinst_LIBRARIES = @LIBWIRETAP_A@ +noinst_LIBRARIES = libwiretap.a -EXTRA_PROGRAMS = filterc -EXTRA_LIBRARIES = libwiretap.a - -EXTRA_DIST = \ - rt-grammar-skel.y \ - rt-scanner-skel.l \ - ct-grammar.y \ - ct-scanner.l \ - filter-eth \ - filter-tr +#EXTRA_LIBRARIES = libwiretap.a CLEANFILES = \ libwiretap.a \ - filterc \ - *~ \ - ct-grammar.c \ - ct-scanner.c \ - ct-grammar.h \ - rt-grammar.c \ - rt-grammar.y \ - rt-scanner.c \ - rt-scanner.l \ - rt-grammar.h + *~ libwiretap_a_SOURCES = \ - bpf.h \ - bpf.c \ - bpf-engine.c \ - bpf-engine.h \ buffer.c \ buffer.h \ config.h \ @@ -46,49 +23,7 @@ libwiretap_a_SOURCES = \ netxray.h \ ngsniffer.c \ ngsniffer.h \ - rt-compile.h \ - rt-compile.c \ - rt-global.h \ - rt-grammar.h \ - rt-grammar.y \ - rt-scanner.l \ snoop.c \ snoop.h \ wtap.c \ wtap.h - - -filterc_SOURCES = \ - ct-compile.c \ - ct-compile.h \ - ct-grammar.h \ - ct-grammar.y \ - ct-scanner.l \ - ct-main.c \ - glib-new.h \ - glib-new.c - -FILTERS = \ - filter-eth \ - filter-tr - -YFLAGS=-d -p wtap_ -LFLAGS=-i -Pwtap_ - -ct-scanner.c : ct-scanner.l - @rm -f $@ - $(LEX) $(LFLAGS) -t $< > $@ - -rt-grammar.y rt-scanner.l : rt-grammar-skel.y rt-scanner-skel.l $(FILTERS) - $(MAKE) filterc - cat $(FILTERS) | ./filterc > /dev/null - -rt-scanner.c : rt-scanner.l rt-grammar.c - @rm -f $@ - $(LEX) $(LFLAGS) -t $< > $@ - -wiretap_SOURCES = \ - wiretap.c \ - glib-new.c - -wiretap_LDADD = libwiretap.a diff --git a/wiretap/Makefile.in b/wiretap/Makefile.in index 1dfc16c40e..ac64d08b57 100644 --- a/wiretap/Makefile.in +++ b/wiretap/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4a from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -46,9 +46,10 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -65,41 +66,21 @@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_CONFIG = @GTK_CONFIG@ GTK_LIBS = @GTK_LIBS@ LEX = @LEX@ -LIBWIRETAP_A = @LIBWIRETAP_A@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ YACC = @YACC@ -bin_PROGRAMS = wiretap -noinst_LIBRARIES = @LIBWIRETAP_A@ +noinst_LIBRARIES = libwiretap.a -EXTRA_PROGRAMS = filterc -EXTRA_LIBRARIES = libwiretap.a +#EXTRA_LIBRARIES = libwiretap.a -EXTRA_DIST = rt-grammar-skel.y rt-scanner-skel.l ct-grammar.y ct-scanner.l filter-eth filter-tr +CLEANFILES = libwiretap.a *~ -CLEANFILES = libwiretap.a filterc *~ ct-grammar.c ct-scanner.c ct-grammar.h rt-grammar.c rt-grammar.y rt-scanner.c rt-scanner.l rt-grammar.h +libwiretap_a_SOURCES = buffer.c buffer.h config.h file.c iptrace.c iptrace.h lanalyzer.c lanalyzer.h libpcap.c libpcap.h netmon.c netmon.h netxray.c netxray.h ngsniffer.c ngsniffer.h snoop.c snoop.h wtap.c wtap.h - -libwiretap_a_SOURCES = bpf.h bpf.c bpf-engine.c bpf-engine.h buffer.c buffer.h config.h file.c iptrace.c iptrace.h lanalyzer.c lanalyzer.h libpcap.c libpcap.h netmon.c netmon.h netxray.c netxray.h ngsniffer.c ngsniffer.h rt-compile.h rt-compile.c rt-global.h rt-grammar.h rt-grammar.y rt-scanner.l snoop.c snoop.h wtap.c wtap.h - - -filterc_SOURCES = ct-compile.c ct-compile.h ct-grammar.h ct-grammar.y ct-scanner.l ct-main.c glib-new.h glib-new.c - - -FILTERS = filter-eth filter-tr - - -YFLAGS = -d -p wtap_ -LFLAGS = -i -Pwtap_ - -wiretap_SOURCES = wiretap.c glib-new.c - - -wiretap_LDADD = libwiretap.a ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_HEADER = config.h @@ -112,49 +93,31 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ libwiretap_a_LIBADD = -libwiretap_a_OBJECTS = bpf.o bpf-engine.o buffer.o file.o iptrace.o \ -lanalyzer.o libpcap.o netmon.o netxray.o ngsniffer.o rt-compile.o \ -rt-grammar.o rt-scanner.o snoop.o wtap.o +libwiretap_a_OBJECTS = buffer.o file.o iptrace.o lanalyzer.o libpcap.o \ +netmon.o netxray.o ngsniffer.o snoop.o wtap.o AR = ar -PROGRAMS = $(bin_PROGRAMS) - -filterc_OBJECTS = ct-compile.o ct-grammar.o ct-scanner.o ct-main.o \ -glib-new.o -filterc_LDADD = $(LDADD) -filterc_DEPENDENCIES = -filterc_LDFLAGS = -wiretap_OBJECTS = wiretap.o glib-new.o -wiretap_DEPENDENCIES = libwiretap.a -wiretap_LDFLAGS = -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LEXLIB = @LEXLIB@ -YLWRAP = $(top_srcdir)/../ylwrap CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS acconfig.h acinclude.m4 aclocal.m4 \ -config.h.in configure configure.in ct-grammar.c ct-scanner.c \ -rt-grammar.c rt-scanner.c +config.h.in configure configure.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best -DEP_FILES = .deps/bpf-engine.P .deps/bpf.P .deps/buffer.P \ -.deps/ct-compile.P .deps/ct-grammar.P .deps/ct-main.P \ -.deps/ct-scanner.P .deps/file.P .deps/glib-new.P .deps/iptrace.P \ +DEP_FILES = .deps/buffer.P .deps/file.P .deps/iptrace.P \ .deps/lanalyzer.P .deps/libpcap.P .deps/netmon.P .deps/netxray.P \ -.deps/ngsniffer.P .deps/rt-compile.P .deps/rt-grammar.P \ -.deps/rt-scanner.P .deps/snoop.P .deps/wiretap.P .deps/wtap.P -SOURCES = $(libwiretap_a_SOURCES) $(filterc_SOURCES) $(wiretap_SOURCES) -OBJECTS = $(libwiretap_a_OBJECTS) $(filterc_OBJECTS) $(wiretap_OBJECTS) +.deps/ngsniffer.P .deps/snoop.P .deps/wtap.P +SOURCES = $(libwiretap_a_SOURCES) +OBJECTS = $(libwiretap_a_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .l .o .s .y +.SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile @@ -228,46 +191,6 @@ libwiretap.a: $(libwiretap_a_OBJECTS) $(libwiretap_a_DEPENDENCIES) $(AR) cru libwiretap.a $(libwiretap_a_OBJECTS) $(libwiretap_a_LIBADD) $(RANLIB) libwiretap.a -mostlyclean-binPROGRAMS: - -clean-binPROGRAMS: - -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) - -distclean-binPROGRAMS: - -maintainer-clean-binPROGRAMS: - -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(bindir) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - if test -f $$p; then \ - echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - list='$(bin_PROGRAMS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ - done - -filterc: $(filterc_OBJECTS) $(filterc_DEPENDENCIES) - @rm -f filterc - $(LINK) $(filterc_LDFLAGS) $(filterc_OBJECTS) $(filterc_LDADD) $(LIBS) - -wiretap: $(wiretap_OBJECTS) $(wiretap_DEPENDENCIES) - @rm -f wiretap - $(LINK) $(wiretap_LDFLAGS) $(wiretap_OBJECTS) $(wiretap_LDADD) $(LIBS) -.l.c: - $(SHELL) $(YLWRAP) "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS) -.y.c: - $(SHELL) $(YLWRAP) "$(YACC)" $< y.tab.c $*.c y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS) -ct-grammar.h: ct-grammar.c -rt-grammar.h: rt-grammar.c - - tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) @@ -343,7 +266,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -393,7 +316,7 @@ installcheck: installcheck-am all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive -install-exec-am: install-binPROGRAMS +install-exec-am: install-exec: install-exec-am install-data-am: @@ -402,14 +325,13 @@ install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am -uninstall-am: uninstall-binPROGRAMS +uninstall-am: uninstall: uninstall-am -all-am: Makefile $(LIBRARIES) $(PROGRAMS) config.h +all-am: Makefile $(LIBRARIES) config.h all-redirect: all-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: - $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: @@ -422,31 +344,29 @@ distclean-generic: -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: - -test -z "ct-scannerlrt-scannerlct-grammarhct-grammarcrt-grammarhrt-grammarc" || rm -f ct-scannerl rt-scannerl ct-grammarh ct-grammarc rt-grammarh rt-grammarc mostlyclean-am: mostlyclean-hdr mostlyclean-noinstLIBRARIES \ - mostlyclean-compile mostlyclean-binPROGRAMS \ - mostlyclean-tags mostlyclean-depend mostlyclean-generic + mostlyclean-compile mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic mostlyclean: mostlyclean-am -clean-am: clean-hdr clean-noinstLIBRARIES clean-compile \ - clean-binPROGRAMS clean-tags clean-depend clean-generic \ - mostlyclean-am +clean-am: clean-hdr clean-noinstLIBRARIES clean-compile clean-tags \ + clean-depend clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-hdr distclean-noinstLIBRARIES distclean-compile \ - distclean-binPROGRAMS distclean-tags distclean-depend \ - distclean-generic clean-am + distclean-tags distclean-depend distclean-generic \ + clean-am distclean: distclean-am -rm -f config.status maintainer-clean-am: maintainer-clean-hdr \ maintainer-clean-noinstLIBRARIES \ - maintainer-clean-compile maintainer-clean-binPROGRAMS \ - maintainer-clean-tags maintainer-clean-depend \ - maintainer-clean-generic distclean-am + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @@ -457,30 +377,16 @@ maintainer-clean: maintainer-clean-am mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ mostlyclean-compile distclean-compile clean-compile \ -maintainer-clean-compile mostlyclean-binPROGRAMS distclean-binPROGRAMS \ -clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \ -install-binPROGRAMS tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags distdir mostlyclean-depend distclean-depend \ -clean-depend maintainer-clean-depend info-am info dvi-am dvi check \ -check-am installcheck-am installcheck all-recursive-am install-exec-am \ -install-exec install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all installdirs \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean -ct-scanner.c : ct-scanner.l - @rm -f $@ - $(LEX) $(LFLAGS) -t $< > $@ - -rt-grammar.y rt-scanner.l : rt-grammar-skel.y rt-scanner-skel.l $(FILTERS) - $(MAKE) filterc - cat $(FILTERS) | ./filterc > /dev/null - -rt-scanner.c : rt-scanner.l rt-grammar.c - @rm -f $@ - $(LEX) $(LFLAGS) -t $< > $@ - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/wiretap/aclocal.m4 b/wiretap/aclocal.m4 index f9344e6d59..6b96f7217a 100644 --- a/wiretap/aclocal.m4 +++ b/wiretap/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4a dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -218,6 +218,8 @@ dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) +dnl We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] diff --git a/wiretap/bpf-engine.c b/wiretap/bpf-engine.c deleted file mode 100644 index d1bff53587..0000000000 --- a/wiretap/bpf-engine.c +++ /dev/null @@ -1,318 +0,0 @@ -/* bpf-engine.c - * ------------ - * The BPF engine used for offline ("display") filters in wiretap. - * The code is taken from the Linux Socket Filter, and only slightly - * modified for use in wiretap. - * - * Gilbert Ramirez <gram@verdict.uthscsa.edu> - */ - -/* - * Linux Socket Filter - Kernel level socket filtering - * - * Author: - * Jay Schulist <Jay.Schulist@spacs.k12.wi.us> - * - * Based on the design of: - * - The Berkeley Packet Filter - * - * 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. - */ - -#include <glib.h> -#include "wtap.h" -#include "bpf-engine.h" - - -/* - * Decode and apply filter instructions to the skb->data. - * Return length to keep, 0 for none. skb is the data we are - * filtering, filter is the array of filter instructions, and - * len is the number of filter blocks in the array. - */ - -int bpf_run_filter(unsigned char *data, int len, struct bpf_instruction *filter, int flen) -{ - struct bpf_instruction *fentry; /* We walk down these */ - guint32 A = 0; /* Accumulator */ - guint32 X = 0; /* Index Register */ - guint32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */ - int k; - int pc; - int *t; - - /* - * Process array of filter instructions. - */ - - for(pc = 0; pc < flen; pc++) - { - fentry = &filter[pc]; - if(fentry->code & BPF_X) - t=&X; - else - t=&fentry->k; - - switch(fentry->code) - { - case BPF_ALU|BPF_ADD|BPF_X: - case BPF_ALU|BPF_ADD|BPF_K: - A += *t; - continue; - - case BPF_ALU|BPF_SUB|BPF_X: - case BPF_ALU|BPF_SUB|BPF_K: - A -= *t; - continue; - - case BPF_ALU|BPF_MUL|BPF_X: - case BPF_ALU|BPF_MUL|BPF_K: - A *= *t; - continue; - - case BPF_ALU|BPF_DIV|BPF_X: - case BPF_ALU|BPF_DIV|BPF_K: - if(*t == 0) - return (0); - A /= *t; - continue; - - case BPF_ALU|BPF_AND|BPF_X: - case BPF_ALU|BPF_AND|BPF_K: - A &= *t; - continue; - - case BPF_ALU|BPF_OR|BPF_X: - case BPF_ALU|BPF_OR|BPF_K: - A |= *t; - continue; - - case BPF_ALU|BPF_LSH|BPF_X: - case BPF_ALU|BPF_LSH|BPF_K: - A <<= *t; - continue; - - case BPF_ALU|BPF_RSH|BPF_X: - case BPF_ALU|BPF_RSH|BPF_K: - A >>= *t; - continue; - - case BPF_ALU|BPF_NEG: - A = -A; - continue; - - case BPF_JMP|BPF_JA: - pc += fentry->k; - continue; - - case BPF_JMP|BPF_JGT|BPF_K: - pc += (A > fentry->k) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JGE|BPF_K: - pc += (A >= fentry->k) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JEQ|BPF_K: - pc += (A == fentry->k) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JSET|BPF_K: - pc += (A & fentry->k) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JGT|BPF_X: - pc += (A > X) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JGE|BPF_X: - pc += (A >= X) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JEQ|BPF_X: - pc += (A == X) ? fentry->jt : fentry->jf; - continue; - - case BPF_JMP|BPF_JSET|BPF_X: - pc += (A & X) ? fentry->jt : fentry->jf; - continue; - case BPF_LD|BPF_W|BPF_ABS: - k = fentry->k; - if(k + sizeof(long) > len) - return (0); - A = pntohl(&data[k]); - continue; - - case BPF_LD|BPF_H|BPF_ABS: - k = fentry->k; - if(k + sizeof(short) > len) - return (0); - A = pntohs(&data[k]); - continue; - - case BPF_LD|BPF_B|BPF_ABS: - k = fentry->k; - if(k >= len) - return (0); - A = data[k]; - continue; - - case BPF_LD|BPF_W|BPF_LEN: - A = len; - continue; - - case BPF_LDX|BPF_W|BPF_LEN: - X = len; - continue; - - case BPF_LD|BPF_W|BPF_IND: - k = X + fentry->k; - if(k + sizeof(guint32) > len) - return (0); - A = pntohl(&data[k]); - continue; - - case BPF_LD|BPF_H|BPF_IND: - k = X + fentry->k; - if(k + sizeof(guint16) > len) - return (0); - A = pntohs(&data[k]); - continue; - - case BPF_LD|BPF_B|BPF_IND: - k = X + fentry->k; - if(k >= len) - return (0); - A = data[k]; - continue; - - case BPF_LDX|BPF_B|BPF_MSH: - /* - * Hack for BPF to handle TOS etc - */ - k = fentry->k; - if(k >= len) - return (0); - X = (data[fentry->k] & 0xf) << 2; - continue; - - case BPF_LD|BPF_IMM: - A = fentry->k; - continue; - - case BPF_LDX|BPF_IMM: - X = fentry->k; - continue; - - case BPF_LD|BPF_MEM: - A = mem[fentry->k]; - continue; - - case BPF_LDX|BPF_MEM: - X = mem[fentry->k]; - continue; - - case BPF_MISC|BPF_TAX: - X = A; - continue; - - case BPF_MISC|BPF_TXA: - A = X; - continue; - - case BPF_RET|BPF_K: - return ((unsigned int)fentry->k); - - case BPF_RET|BPF_A: - return ((unsigned int)A); - - case BPF_ST: - mem[fentry->k] = A; - continue; - - case BPF_STX: - mem[fentry->k] = X; - continue; - - - - default: - /* Invalid instruction counts as RET */ - return (0); - } - } - - g_error("Filter ruleset ran off the end.\n"); - return (0); -} - -/* - * Check the user's filter code. If we let some ugly - * filter code slip through kaboom! - */ - -int bpf_chk_filter(struct bpf_instruction *filter, int flen) -{ - struct bpf_instruction *ftest; - int pc; - - /* - * Check the filter code now. - */ - for(pc = 0; pc < flen; pc++) - { - /* - * All jumps are forward as they are not signed - */ - - ftest = &filter[pc]; - if(BPF_CLASS(ftest->code) == BPF_JMP) - { - /* - * But they mustn't jump off the end. - */ - if(BPF_OP(ftest->code) == BPF_JA) - { - if(pc + ftest->k + 1>= (unsigned)flen) - return (-1); - } - else - { - /* - * For conditionals both must be safe - */ - if(pc + ftest->jt +1 >= flen || pc + ftest->jf +1 >= flen) - return (-1); - } - } - - /* - * Check that memory operations use valid addresses. - */ - - if(ftest->k <0 || ftest->k >= BPF_MEMWORDS) - { - /* - * But it might not be a memory operation... - */ - - if (BPF_CLASS(ftest->code) == BPF_ST) - return -1; - if((BPF_CLASS(ftest->code) == BPF_LD) && - (BPF_MODE(ftest->code) == BPF_MEM)) - return (-1); - } - } - - /* - * The program must end with a return. We don't care where they - * jumped within the script (its always forwards) but in the - * end they _will_ hit this. - */ - - return (BPF_CLASS(filter[flen - 1].code) == BPF_RET)?0:-1; -} - diff --git a/wiretap/bpf-engine.h b/wiretap/bpf-engine.h deleted file mode 100644 index 24f87ae30a..0000000000 --- a/wiretap/bpf-engine.h +++ /dev/null @@ -1,120 +0,0 @@ -/* bpf-engine.h - * ------------ - * The BPF engine used for offline ("display") filters in wiretap. - * The code is taken from the Linux Socket Filter, and only slightly - * modified for use in wiretap. - * - * Gilbert Ramirez <gram@verdict.uthscsa.edu> - */ - -/* - * Linux Socket Filter - Kernel level socket filtering - * - * Author: - * Jay Schulist <Jay.Schulist@spacs.k12.wi.us> - * - * Based on the design of: - * - The Berkeley Packet Filter - * - * 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. - */ - -/* - * Linux Socket Filter Data Structures - */ - -/* - * Current version of the filter code architecture. - */ -#define BPF_MAJOR_VERSION 1 -#define BPF_MINOR_VERSION 1 - -/* each BPF instruction is a block of 8 bytes */ -struct bpf_instruction { - guint16 code; /* Actual filter code */ - guint8 jt; /* Jump true */ - guint8 jf; /* Jump false */ - guint32 k; /* Generic multiuse field */ - -}; - -struct bpf_code_unit { - int line_label; - struct bpf_instruction bpf; -}; - -int bpf_run_filter(unsigned char *data, int len, struct bpf_instruction *filter, int flen); -int bpf_chk_filter(struct bpf_instruction *filter, int flen); - -/* - * Instruction classes - */ - -#define BPF_CLASS(code) ((code) & 0x07) -#define BPF_LD 0x00 -#define BPF_LDX 0x01 -#define BPF_ST 0x02 -#define BPF_STX 0x03 -#define BPF_ALU 0x04 -#define BPF_JMP 0x05 -#define BPF_RET 0x06 -#define BPF_MISC 0x07 - -/* ld/ldx fields */ -#define BPF_SIZE(code) ((code) & 0x18) -#define BPF_W 0x00 -#define BPF_H 0x08 -#define BPF_B 0x10 -#define BPF_MODE(code) ((code) & 0xe0) -#define BPF_IMM 0x00 -#define BPF_ABS 0x20 -#define BPF_IND 0x40 -#define BPF_MEM 0x60 -#define BPF_LEN 0x80 -#define BPF_MSH 0xa0 - -/* alu/jmp fields */ -#define BPF_OP(code) ((code) & 0xf0) -#define BPF_ADD 0x00 -#define BPF_SUB 0x10 -#define BPF_MUL 0x20 -#define BPF_DIV 0x30 -#define BPF_OR 0x40 -#define BPF_AND 0x50 -#define BPF_LSH 0x60 -#define BPF_RSH 0x70 -#define BPF_NEG 0x80 -#define BPF_JA 0x00 -#define BPF_JEQ 0x10 -#define BPF_JGT 0x20 -#define BPF_JGE 0x30 -#define BPF_JSET 0x40 -#define BPF_SRC(code) ((code) & 0x08) -#define BPF_K 0x00 -#define BPF_X 0x08 - -/* ret - BPF_K and BPF_X also apply */ -#define BPF_RVAL(code) ((code) & 0x18) -#define BPF_A 0x10 - -/* misc */ -#define BPF_MISCOP(code) ((code) & 0xf8) -#define BPF_TAX 0x00 -#define BPF_TXA 0x80 - -#define BPF_MAXINSNS 512 - -/* - * Macros for filter block array initializers. - */ -#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k } -#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k } - -/* - * Number of scratch memory words for: BPF_ST and BPF_STX - */ -#define BPF_MEMWORDS 16 - diff --git a/wiretap/bpf.c b/wiretap/bpf.c deleted file mode 100644 index 3f02859d13..0000000000 --- a/wiretap/bpf.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * bpf.c - * ----- - * Creates and handles the BPF code produced by wiretap. - * - * Gilbert Ramirez - */ - -#ifndef __G_LIB_H__ -#include <glib.h> -#endif - -#include <sys/types.h> -#include <netinet/in.h> - -#include "wtap.h" -#include "rt-compile.h" -#include "rt-global.h" -#include "bpf-engine.h" -#include "bpf.h" - - -static GList *bpf_code_just_parsed = NULL; -static struct bpf_instruction *bpf_record = NULL; - -static int -bpf_clean_jump(GList *L, int i_this, int jmp, int num_bpf_instructions, - int i_ret_success, int i_ret_failure); -static void -bpf_pass1(GList *L); - -static GList* -bpf_mk_bytecmp(int ftype, int rel_opcode, guint8 *bytes); - -static void -bpf_optimize(GList *L); - -static int -bpf_attach(wtap *wth); - -static void -bpf_attach_record(gpointer bpf_code, gpointer junk); - -static int -offline_attach(wtap *wth); - - -/* sets function pointers in rt-grammar.y to point to the BPF-related - * functions */ -void -wtap_filter_bpf_init(void) -{ - mk_bytecmp = bpf_mk_bytecmp; - mk_optimize = bpf_optimize; - mk_attach = bpf_attach; -} - -/* almost the same as bpf_init... */ -void -wtap_filter_offline_init(wtap *wth) -{ - int fi; /* filter index */ - - mk_bytecmp = bpf_mk_bytecmp; - mk_optimize = bpf_optimize; - mk_attach = offline_attach; - - wtap_filter_offline_clear(wth); - - /* make the offline filter array */ - wth->filter.offline = g_malloc(sizeof(int*) * WTAP_NUM_ENCAP_TYPES); - wth->filter_type = WTAP_FILTER_OFFLINE; - wth->offline_filter_lengths = g_malloc(sizeof(int) * WTAP_NUM_ENCAP_TYPES); - - for (fi = 0; fi < WTAP_NUM_ENCAP_TYPES; fi++) { - wth->filter.offline[fi] = NULL; - } -} - -/* Removes an offline filter from a wtap struct, and frees memory used - * by that filter */ -void -wtap_filter_offline_clear(wtap *wth) -{ - int fi; /* filter index */ - - if (wth->filter.offline) { - for (fi = 0; fi < WTAP_NUM_ENCAP_TYPES; fi++) { - if (wth->filter.offline[fi]) - g_free(wth->filter.offline[fi]); - } - g_free(wth->filter.offline); - g_free(wth->offline_filter_lengths); - } - wth->filter_type = WTAP_FILTER_NONE; -} - -/* Allocate a new bpf_code_unit structure and initialize the BPF instruction - * codes to the values passed by the caller. */ -static struct bpf_code_unit * -bpf_code_unit_alloc(guint8 label, guint16 code, guint8 jt, guint8 jf, guint32 k) -{ - struct bpf_code_unit *bpf; - - bpf = g_malloc(sizeof(struct bpf_code_unit)); - bpf->line_label = label; - bpf->bpf.code = code; - bpf->bpf.jt = jt; - bpf->bpf.jf = jf; - bpf->bpf.k = k; - - /*g_print("{ %d { 0x%02x, %d, %d, 0x%08x }},\n", - label, code, jt, jf, k);*/ - return bpf; -} - - -/* Finds ftype in the bytecmp_table, the relation, and the n-string -byte array, and creates BPF that will check those bytes */ -static GList* -bpf_mk_bytecmp(int ftype, int rel_opcode, guint8 *bytes) -{ - GList *L; - struct bpf_code_unit *bpf; - int len_to_cmp, offset, endpoint, label; - bytecmp_info *b; - - L = g_list_alloc(); - - /* find the field in the table */ - b = lookup_bytecmp(ftype); - - /* How many bytes do we have to compare, and where? */ - len_to_cmp = b->length; - offset = b->offset; - endpoint = len_to_cmp + offset; - /*g_print("len_to_cmp=%d, offset=%d, endpoint=%d\n", - len_to_cmp, offset, endpoint); - g_print("bytes: (%d) %02X:%02X:%02X\n", - bytes[0], bytes[1], bytes[2], bytes[3]);*/ - - label = NEXT_BLOCK; - /* loop until we have written instructions to compare - all bytes */ - while (len_to_cmp) { - - if (len_to_cmp >= 4) { - bpf = bpf_code_unit_alloc(label, - BPF_LD|BPF_W|BPF_ABS, - 0, 0, endpoint - 4); - g_list_append(L, bpf); - label = NO_LABEL; - - endpoint -= 4; - bpf = bpf_code_unit_alloc(NO_LABEL, - BPF_JMP|BPF_JEQ, - (len_to_cmp == 4 ? END_OF_PROGRAM_SUCCESS : 0), - NEXT_BLOCK, - phtonl(&bytes[len_to_cmp-3])); - g_list_append(L, bpf); - - len_to_cmp -= 4; - } - else if (len_to_cmp == 3) { - bpf = bpf_code_unit_alloc(label, - BPF_LD|BPF_W|BPF_ABS, - 0, 0, endpoint - 3); - g_list_append(L, bpf); - label = NO_LABEL; - endpoint -= 3; - - bpf = bpf_code_unit_alloc(NO_LABEL, - BPF_ALU|BPF_AND, - 0, 0, 0xffffff); - /*htonl(0xffffff));*/ - g_list_append(L, bpf); - - bpf = bpf_code_unit_alloc(NO_LABEL, - BPF_JMP|BPF_JEQ, - (len_to_cmp == 3 ? END_OF_PROGRAM_SUCCESS : 0), - NEXT_BLOCK, - phtonl(&bytes[len_to_cmp-2]) & 0xffffff00); - g_list_append(L, bpf); - - len_to_cmp -= 3; - } - else if (len_to_cmp == 2) { - bpf = bpf_code_unit_alloc(label, - BPF_LD|BPF_H|BPF_ABS, - 0, 0, endpoint - 2); - g_list_append(L, bpf); - label = NO_LABEL; - - endpoint -= 2; - bpf = bpf_code_unit_alloc(NO_LABEL, - BPF_JMP|BPF_JEQ, - (len_to_cmp == 2 ? END_OF_PROGRAM_SUCCESS : 0), - NEXT_BLOCK, - (guint32)phtons(&bytes[len_to_cmp-1])); - g_list_append(L, bpf); - - len_to_cmp -= 2; - } - else if (len_to_cmp == 1) { - bpf = bpf_code_unit_alloc(label, - BPF_LD|BPF_B|BPF_ABS, - 0, 0, endpoint - 1); - g_list_append(L, bpf); - label = NO_LABEL; - - endpoint--; - bpf = bpf_code_unit_alloc(NO_LABEL, - BPF_JMP|BPF_JEQ, - END_OF_PROGRAM_SUCCESS, NEXT_BLOCK, - bytes[len_to_cmp]); - g_list_append(L, bpf); - len_to_cmp--; - } - } - - - L = g_list_remove(L, 0); - return L; -} - - -static void -bpf_optimize(GList *L) -{ - bpf_pass1(L); - bpf_code_just_parsed = L; -} - -/* after the BPF code is constructed from the parser, this step is run. During - * pass1 we: - * - * 1. Clean up the jump variables - */ -static void -bpf_pass1(GList *L) -{ - struct bpf_code_unit *bpf; - int num_bpf_instructions; - int i_ret_success; - int i_ret_failure; - int i; - - /* Attach a SUCCESS return to the end of the BPF code */ - bpf = bpf_code_unit_alloc(END_OF_PROGRAM_SUCCESS, BPF_RET, 0, 0, 0xffff); - g_list_append(L, bpf); - - /* Attach a FAILURE return to the end of the BPF code */ - bpf = bpf_code_unit_alloc(END_OF_PROGRAM_FAILURE, BPF_RET, 0, 0, 0); - g_list_append(L, bpf); - - num_bpf_instructions = g_list_length(L); - i_ret_success = num_bpf_instructions - 2; - i_ret_failure = num_bpf_instructions - 1; - - for(i = 0; i < num_bpf_instructions; i++) { - bpf = (struct bpf_code_unit*) g_list_nth_data(L, i); - if (!bpf) - continue; - - /* Check for Jump to end failure/success */ - if (bpf->bpf.code & BPF_JMP) { - - bpf->bpf.jt = bpf_clean_jump(L, i, bpf->bpf.jt, num_bpf_instructions, - i_ret_success, i_ret_failure); - - bpf->bpf.jf = bpf_clean_jump(L, i, bpf->bpf.jf, num_bpf_instructions, - i_ret_success, i_ret_failure); - } - } -} - -static int -bpf_clean_jump(GList *L, int i_this, int jmp, int num_bpf_instructions, - int i_ret_success, int i_ret_failure) -{ - int i; - struct bpf_code_unit *bpf; - - switch(jmp) { - case END_OF_PROGRAM_SUCCESS: - return i_ret_success - i_this - 1; - - case END_OF_PROGRAM_FAILURE: - return i_ret_failure - i_this - 1; - - case NEXT_BLOCK: - for (i = i_this + 1; i < num_bpf_instructions; i++) { - bpf = (struct bpf_code_unit*) g_list_nth_data(L, i); - if (!bpf) - continue; - if (bpf->line_label == NEXT_BLOCK) { - return i - i_this - 1; - } - } - /* failed to find NEXT_BLOCK.... chose FAILURE */ - return i_ret_failure - i_this - 1; - - /* default: nothing */ - } - return jmp; -} - - - -/* Takes code from bpf_code_just_parsed and attaches it to wth - * returns 1 if sucessfull, 0 if not */ -static int bpf_attach(wtap *wth) -{ - if (wth->filter.bpf) - g_free(wth->filter.bpf); - - /* filter_length will be number of bpf_block records */ - wth->filter_length = g_list_length(bpf_code_just_parsed) - 1; - - wth->filter.bpf = g_malloc(wth->filter_length * - sizeof(struct bpf_instruction)); - wth->filter_type = WTAP_FILTER_BPF; - - bpf_record = wth->filter.bpf; - - g_list_foreach(bpf_code_just_parsed, bpf_attach_record, NULL); - - if (bpf_chk_filter(wth->filter.bpf, wth->filter_length) == 0) - return 1; - else - return 0; - -} - -void bpf_attach_record(gpointer bpf_code, gpointer junk) -{ - struct bpf_code_unit *bpf_c = (struct bpf_code_unit*) bpf_code; - - struct bpf_instruction *bpf_i; - - if (!bpf_c) - return; - - bpf_i = &(bpf_c->bpf); - memcpy(bpf_record, bpf_i, sizeof(struct bpf_instruction)); - bpf_record++; -} - - -/* Takes code from bpf_code_just_parsed and attachs it to wth. - * returns 1 if sucessfull, 0 if not */ -static int offline_attach(wtap *wth) -{ - /* filter_length will be number of bpf_instruction records */ - wth->offline_filter_lengths[comp_encap_type] = - g_list_length(bpf_code_just_parsed); - - /* Make space for this filter */ - wth->filter.offline[comp_encap_type] = - g_malloc(wth->offline_filter_lengths[comp_encap_type] - * sizeof(struct bpf_instruction)); - - bpf_record = wth->filter.offline[comp_encap_type]; - - g_list_foreach(bpf_code_just_parsed, bpf_attach_record, NULL); - - if (bpf_chk_filter(wth->filter.offline[comp_encap_type], - wth->offline_filter_lengths[comp_encap_type]) == 0) - return 1; - else - return 0; -} - diff --git a/wiretap/bpf.h b/wiretap/bpf.h deleted file mode 100644 index 81b8572873..0000000000 --- a/wiretap/bpf.h +++ /dev/null @@ -1,22 +0,0 @@ - -/* we limit the number of BPF records a jmp can take by using a few of the - * jmp values as special identifiers during the compilation process. Many - * pieces of code need to jump to the end of the entire BPF block, returing - * either a successful value or a failure value (either the number of bytes - * to read, or 0). The code creator uses these 4 variables to represent - * the retval of failure or success, then the code cleaner fills in the - * true value for these variables. - */ -#define NO_LABEL 255 -#define END_OF_PROGRAM_FAILURE 254 -#define END_OF_PROGRAM_SUCCESS 253 -#define NEXT_BLOCK 252 - -void -wtap_filter_bpf_init(void); - -void -wtap_filter_offline_init(wtap *wth); - -void -wtap_filter_offline_clear(wtap *wth); diff --git a/wiretap/configure b/wiretap/configure index 45010c7b50..5f52b5ff45 100755 --- a/wiretap/configure +++ b/wiretap/configure @@ -23,9 +23,6 @@ ac_help="$ac_help --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)" ac_help="$ac_help --disable-gtktest Do not try to compile and run a test GTK program" -ac_help="$ac_help - --with-wiretap Include wiretap library. - --without-wiretap Don't include wiretap library (default)" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -567,7 +564,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:571: checking for a BSD compatible install" >&5 +echo "configure:568: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -620,7 +617,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:624: checking whether build environment is sane" >&5 +echo "configure:621: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -677,7 +674,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:681: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:678: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -704,6 +701,7 @@ else fi + PACKAGE=libwtap.a VERSION=0.0.0 @@ -723,7 +721,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:727: checking for working aclocal" >&5 +echo "configure:725: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -736,7 +734,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:740: checking for working autoconf" >&5 +echo "configure:738: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -749,7 +747,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:753: checking for working automake" >&5 +echo "configure:751: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -762,7 +760,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:766: checking for working autoheader" >&5 +echo "configure:764: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -775,7 +773,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:779: checking for working makeinfo" >&5 +echo "configure:777: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -795,7 +793,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:799: checking for $ac_word" >&5 +echo "configure:797: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -825,7 +823,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:829: checking for $ac_word" >&5 +echo "configure:827: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -876,7 +874,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:880: checking for $ac_word" >&5 +echo "configure:878: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -908,7 +906,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:912: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:910: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -919,12 +917,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 923 "configure" +#line 921 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -950,12 +948,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:954: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:952: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:959: checking whether we are using GNU C" >&5 +echo "configure:957: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -964,7 +962,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:968: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:966: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -983,7 +981,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:987: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:985: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1017,7 +1015,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1021: checking for $ac_word" >&5 +echo "configure:1019: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1049,7 +1047,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1053: checking for $ac_word" >&5 +echo "configure:1051: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1080,7 +1078,7 @@ done test -n "$YACC" || YACC="yacc" echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1084: checking how to run the C preprocessor" >&5 +echo "configure:1082: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1095,13 +1093,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 1099 "configure" +#line 1097 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1103: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1112,13 +1110,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 1116 "configure" +#line 1114 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1122: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1129,13 +1127,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 1133 "configure" +#line 1131 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1165,7 +1163,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1169: checking for $ac_word" >&5 +echo "configure:1167: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1198,7 +1196,7 @@ test -n "$LEX" || LEX=""$missing_dir/missing flex"" # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1202: checking for $ac_word" >&5 +echo "configure:1200: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1232,7 +1230,7 @@ then *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:1236: checking for yywrap in -l$ac_lib" >&5 +echo "configure:1234: checking for yywrap in -l$ac_lib" >&5 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1240,7 +1238,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <<EOF -#line 1244 "configure" +#line 1242 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1251,7 +1249,7 @@ int main() { yywrap() ; return 0; } EOF -if { (eval echo configure:1255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1274,7 +1272,7 @@ fi fi echo $ac_n "checking lex output file root""... $ac_c" 1>&6 -echo "configure:1278: checking lex output file root" >&5 +echo "configure:1276: checking lex output file root" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1295,7 +1293,7 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 -echo "configure:1299: checking whether yytext is a pointer" >&5 +echo "configure:1297: checking whether yytext is a pointer" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1307,14 +1305,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c ac_save_LIBS="$LIBS" LIBS="$LIBS $LEXLIB" cat > conftest.$ac_ext <<EOF -#line 1311 "configure" +#line 1309 "configure" #include "confdefs.h" `cat $LEX_OUTPUT_ROOT.c` int main() { ; return 0; } EOF -if { (eval echo configure:1318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_prog_lex_yytext_pointer=yes else @@ -1338,7 +1336,7 @@ fi # If we're running gcc, add '-Wall' to CFLAGS. echo $ac_n "checking to see if we can add '-Wall' to CFLAGS""... $ac_c" 1>&6 -echo "configure:1342: checking to see if we can add '-Wall' to CFLAGS" >&5 +echo "configure:1340: checking to see if we can add '-Wall' to CFLAGS" >&5 if test x$GCC != x ; then CFLAGS="-Wall $CFLAGS" echo "$ac_t""yes" 1>&6 @@ -1400,7 +1398,7 @@ fi # Extract the first word of "glib-config", so it can be a program name with args. set dummy glib-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1404: checking for $ac_word" >&5 +echo "configure:1402: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GLIB_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1435,7 +1433,7 @@ fi min_glib_version=1.1.0 echo $ac_n "checking for GLIB - version >= $min_glib_version""... $ac_c" 1>&6 -echo "configure:1439: checking for GLIB - version >= $min_glib_version" >&5 +echo "configure:1437: checking for GLIB - version >= $min_glib_version" >&5 no_glib="" if test "$GLIB_CONFIG" = "no" ; then no_glib=yes @@ -1458,7 +1456,7 @@ echo "configure:1439: checking for GLIB - version >= $min_glib_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext <<EOF -#line 1462 "configure" +#line 1460 "configure" #include "confdefs.h" #include <glib.h> @@ -1534,7 +1532,7 @@ main () } EOF -if { (eval echo configure:1538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1568,7 +1566,7 @@ fi CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS" cat > conftest.$ac_ext <<EOF -#line 1572 "configure" +#line 1570 "configure" #include "confdefs.h" #include <glib.h> @@ -1578,7 +1576,7 @@ int main() { return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ; return 0; } EOF -if { (eval echo configure:1582: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GLIB or finding the wrong" @@ -1668,7 +1666,7 @@ fi # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1672: checking for $ac_word" >&5 +echo "configure:1670: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1703,7 +1701,7 @@ fi min_gtk_version=1.0.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:1707: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:1705: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes @@ -1726,7 +1724,7 @@ echo "configure:1707: checking for GTK - version >= $min_gtk_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext <<EOF -#line 1730 "configure" +#line 1728 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -1804,7 +1802,7 @@ main () } EOF -if { (eval echo configure:1808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1838,7 +1836,7 @@ fi CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat > conftest.$ac_ext <<EOF -#line 1842 "configure" +#line 1840 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -1848,7 +1846,7 @@ int main() { return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } EOF -if { (eval echo configure:1852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" @@ -1892,36 +1890,13 @@ EOF fi -# Wiretap check (copied and modified from ethereal) -echo $ac_n "checking whether to include wiretap library""... $ac_c" 1>&6 -echo "configure:1898: checking whether to include wiretap library" >&5 -# Check whether --with-wiretap or --without-wiretap was given. -if test "${with_wiretap+set}" = set; then - withval="$with_wiretap" - case "$withval" in - yes) - echo "$ac_t""yes" 1>&6 - LIBWIRETAP_A="libwiretap.a" - ;; - *) - echo "$ac_t""no" 1>&6 - LIBWIRETAP_A="" - ;; - esac -else - echo "$ac_t""no" 1>&6 - -fi - - - echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1920: checking for ANSI C header files" >&5 +echo "configure:1895: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1925 "configure" +#line 1900 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -1929,7 +1904,7 @@ else #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1933: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1946,7 +1921,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1950 "configure" +#line 1925 "configure" #include "confdefs.h" #include <string.h> EOF @@ -1964,7 +1939,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1968 "configure" +#line 1943 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -1985,7 +1960,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <<EOF -#line 1989 "configure" +#line 1964 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1996,7 +1971,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2023,17 +1998,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2027: checking for $ac_hdr" >&5 +echo "configure:2002: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2032 "configure" +#line 2007 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2012: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2217,7 +2192,6 @@ s%@GLIB_LIBS@%$GLIB_LIBS%g s%@GTK_CONFIG@%$GTK_CONFIG%g s%@GTK_CFLAGS@%$GTK_CFLAGS%g s%@GTK_LIBS@%$GTK_LIBS%g -s%@LIBWIRETAP_A@%$LIBWIRETAP_A%g CEOF EOF diff --git a/wiretap/configure.in b/wiretap/configure.in index ddadbef14d..15b9e90e37 100644 --- a/wiretap/configure.in +++ b/wiretap/configure.in @@ -1,4 +1,4 @@ -# $Id: configure.in,v 1.9 1999/03/28 18:32:02 gram Exp $ +# $Id: configure.in,v 1.10 1999/07/07 22:52:53 gram Exp $ dnl Process this file with autoconf to produce a configure script. AC_INIT(wtap.c) AM_INIT_AUTOMAKE(libwtap.a, 0.0.0) @@ -28,25 +28,6 @@ if test "x$GLIB_CFLAGS" = x ; then AC_DEFINE(HAVE_GLIB10) fi -# Wiretap check (copied and modified from ethereal) -AC_MSG_CHECKING(whether to include wiretap library) -AC_ARG_WITH(wiretap, -[ --with-wiretap Include wiretap library. - --without-wiretap Don't include wiretap library (default)], - [ case "$withval" in - yes) - AC_MSG_RESULT(yes) - LIBWIRETAP_A="libwiretap.a" - ;; - *) - AC_MSG_RESULT(no) - LIBWIRETAP_A="" - ;; - esac ], - AC_MSG_RESULT(no) -) -AC_SUBST(LIBWIRETAP_A) - dnl Checks for header files AC_HEADER_STDC AC_CHECK_HEADERS(unistd.h) diff --git a/wiretap/ct-compile.c b/wiretap/ct-compile.c deleted file mode 100644 index eea612b9e8..0000000000 --- a/wiretap/ct-compile.c +++ /dev/null @@ -1,487 +0,0 @@ -/* ct-compile.c - ------------ - Compile-time filter-compiler for Wiretap - -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "config.h" -#include "ct-compile.h" - -#ifdef HAVE_GLIB10 -#include "glib-new.h" -#endif - -#define LINE_SIZE 1024 - -GHashTable *field_hash; -GHashTable *protocol_hash; -char *protocol_name = NULL; -int rt_iteration; - -extern struct field_info working_field; /* in ct-grammar.y */ - -char *ftype_text[] = { - "NONE", - "BOOLEAN", - "ETHER", - "IPv4ADDR", - "UINT8", - "UINT16", - "UINT32", - "BYTE" -}; - -char *ctype_text[] = { - "NONE", - "ANDMASK", - "BYTECMP", - "EITHEROF" -}; - -static -int many_list_subtype(struct field_info *val); - -/* Called by main() to initialize the global variables that ct-compile.c - * worries about. */ -void compiler_init(void) -{ - field_hash = g_hash_table_new(g_str_hash, g_str_equal); - protocol_hash = g_hash_table_new(g_str_hash, g_str_equal); - field_info_init(&working_field); -} - -/* takes a pointer to a field_info struct that the parser built, - * makes a copy of the struct, and adds it to our list of fields */ -void field_info_add(struct field_info *fi, char *protocol) -{ - struct field_info *new_fi; - - /* Make a duplicate of the field_info struct, destroying - * the pointers of the old struct in the process. */ - new_fi = g_memdup(fi, sizeof(struct field_info)); - new_fi->name = fi->name; - new_fi->short_name = fi->short_name; - new_fi->description = fi->description; - new_fi->many_list = fi->many_list; - new_fi->aliases = fi->aliases; - fi->name = NULL; - fi->short_name = NULL; - fi->description = NULL; - fi->many_list = NULL; - fi->aliases = NULL; - - /* Find the parent */ - new_fi->parent = g_hash_table_lookup(protocol_hash, protocol); - if (!new_fi) - g_print("Cannot find parent protocol %s for field %s\n", - protocol, new_fi->name); - - g_hash_table_insert(field_hash, new_fi->name, new_fi); - - g_print("field_info_add added %s (%s) \n\t" - "ftype=%s, off=%d, len=%d, val=%d, ctype=%s\n", - new_fi->name, - new_fi->description, - ftype_text[new_fi->field_type], new_fi->offset, - new_fi->length, new_fi->value, - ctype_text[new_fi->computation_type]); -} - -/* initialize a field_info struct */ -void field_info_init(struct field_info *fi) -{ - /* put NULLs in the fields that field_info_zero assumes - * that a non-NULL value corresponds to allocated memory. */ - fi->name = NULL; - fi->description = NULL; - fi->aliases = NULL; - fi->many_list = NULL; - - field_info_zero(fi); -} - -/* zero out the values of an existing field_info struct */ -void field_info_zero(struct field_info *fi) -{ - if (fi->name) - free(fi->name); - if (fi->short_name) - free(fi->short_name); - if (fi->description) - free(fi->description); - - fi->field_type = 0; - fi->computation_type = CTYPE_NONE; - fi->offset = 0; - fi->length = 0; - fi->value = 0; - fi->parent = NULL; - - if (fi->aliases) - g_slist_free(fi->aliases); - if (fi->many_list) - g_slist_free(fi->many_list); - - fi->aliases = g_slist_alloc(); - fi->many_list = g_slist_alloc(); -} - -void show_aliases(gpointer alias, gpointer field) -{ - if (alias) - g_print("%s ", ((GString*)alias)->str); - -} -/* add alias(es) to this field */ -void field_info_add_alias(char *field_name, GSList *aliases) -{ - struct field_info *fi; - - fi = g_hash_table_lookup(field_hash, field_name); - - if (!fi) { - g_print("Could not find field %s to alias.\n", field_name); - return; - } - - g_slist_concat(fi->aliases, aliases); - g_print("(%s) added aliases: ", fi->name); - g_slist_foreach(fi->aliases, show_aliases, NULL); - g_print("\n"); -} - -/* Given a list of GStrings of field_names, return a list of field_info - * pointers */ -GSList* field_info_list(GSList *field_names, char *protocol) -{ - GSList *new_list; - char *protocol_dot; - - protocol_dot = g_strjoin("", protocol, ".", NULL); - g_slist_foreach(field_names, field_info_list_func1, protocol_dot); - - new_list = g_slist_alloc(); - g_slist_foreach(field_names, field_info_list_func2, new_list); - - return new_list; -} - -void field_info_list_func1(gpointer node, gpointer protocol) -{ - if(node) - g_string_prepend((GString*)node, (char*)protocol); -} - - -void field_info_list_func2(gpointer node, gpointer new_list) -{ - if (node) - g_slist_append(new_list, - g_hash_table_lookup(field_hash, - ((GString*)node)->str)); -/* if (node) - g_print("info_list added %s\n", ((GString*)node)->str);*/ -} - - -/* add a protocol to the hash */ -void protocol_layer_add(char *name, char *description) -{ - struct protocol_layer *new_pr; - - new_pr = g_malloc(sizeof(struct protocol_layer)); - - new_pr->name = g_strdup(name); - new_pr->description = g_strdup(description); - - g_hash_table_insert(protocol_hash, new_pr->name, new_pr); - - g_print("protocol_layer_add added %s (%s)\n", - new_pr->name, - new_pr->description); -} - -/* Creates rt-scanner.l from rt-scanner-skel.l */ -void write_rt_lex(void) -{ - char buf[LINE_SIZE]; - FILE *in, *out; - - if (!(in = fopen("rt-scanner-skel.l", "r"))) { - g_error("Could not open rt-scanner-skel.l for reading."); - exit(1); - } - - if (!(out = fopen("rt-scanner.l", "w"))) { - g_error("Could not open rt-scanner.l for writing."); - exit(1); - } - - while(fgets(buf, LINE_SIZE, in)) { - if (strcmp(buf, "/* ct-compile: lex tokens */\n") == 0) { - write_rt_lex_tokens(out); - continue; - } - else { - fprintf(out, "%s", buf); - } - } - fclose(in); - fclose(out); -} - - -void write_rt_lex_tokens(FILE *out) -{ - g_hash_table_foreach(field_hash, rt_lex_tokens, out); -} - -void rt_lex_tokens(gpointer key, gpointer value, gpointer out) -{ - char *upcase; - - if (!value) { - g_print("key %s has no value.\n", (char*)key); - return; - } - - protocol_name = ((struct field_info*) value)->parent->name; - if (((struct field_info*) value)->aliases) { - g_slist_foreach(((struct field_info*) value)->aliases, - rt_lex_tokens_aliases, out); - } - upcase = rt_lex_token_upcase(((struct field_info*)value)->name); - fprintf((FILE*)out, "%s\\.%s\t return %s;\n", protocol_name, - ((struct field_info*) value)->short_name, - upcase); - - free(upcase); -} - -char* rt_lex_token_upcase(char *text) -{ - char *new_text; - char *p; - new_text = g_strdup(text); - g_strup(new_text); - - /* s/\./_/g */ - for (p = new_text; *p; p++) { - if (*p == '.') { - *p = '_'; - } - } - return new_text; -} - - -void rt_lex_tokens_aliases(gpointer node, gpointer out) -{ - if (node) { - fprintf((FILE*)out, "%s\\.%s\t|\n", - protocol_name, - ((GString*) node)->str); - } -} - -/* Creates rt-grammar.y from rt-grammar-skel.y */ -void write_rt_yacc(void) -{ - char buf[LINE_SIZE]; - FILE *in, *out; - - if (!(in = fopen("rt-grammar-skel.y", "r"))) { - g_error("Could not open rt-grammar-skel.y for reading."); - exit(1); - } - - if (!(out = fopen("rt-grammar.y", "w"))) { - g_error("Could not open rt-scanner.l for writing."); - exit(1); - } - - while(fgets(buf, LINE_SIZE, in)) { - if (strcmp(buf, "/* ct-compile: bytecmp_table */\n") == 0) { - write_rt_bytecmp_table(out); - continue; - } - else if (strcmp(buf, "/* ct-compile: eitherof_table */\n") == 0) { - write_rt_eitherof_table(out); - continue; - } - else if (strcmp(buf, "/* ct-compile: yacc tokens */\n") == 0) { - write_rt_yacc_tokens(out); - continue; - } - else if (strcmp(buf, "/* ct-compile: bytecmp_lval */\n") == 0) { - write_rt_bytecmp_lval(out); - continue; - } - else { - fprintf(out, "%s", buf); - } - } - fclose(in); - fclose(out); -} - -/* ------------------------- BYTECMP_TABLE -------------------- */ -void write_rt_bytecmp_table(FILE *out) -{ - fprintf(out, "bytecmp_info bytecmp_table[] = {\n"); - g_hash_table_foreach(field_hash, rt_bytecmp_table, out); - fprintf(out, "\t{ 0, 0, 0, 0 }\n};\n"); -} - -void rt_bytecmp_table(gpointer key, gpointer value, gpointer out) -{ - char *upcase; - struct field_info *val = (struct field_info*) value; - - if (!val) { - g_print("key %s has no value.\n", (char*)key); - return; - } - - /* return now if we're not dealing with a bytecmp field */ - if (val->computation_type == CTYPE_EITHEROF) { - if (many_list_subtype(val) != CTYPE_BYTECMP) - return; - } - else if (val->computation_type != CTYPE_BYTECMP) { - return; - } - - upcase = rt_lex_token_upcase(((struct field_info*)value)->name); - fprintf((FILE*)out, "\t{ %s, %d, %d, %d },\n", - upcase, val->computation_type, val->offset, val->length); - free(upcase); -} - -static -int many_list_subtype(struct field_info *val) -{ - struct field_info *fi; - gchar *field1; - - if (!val->many_list) - return 0; - - field1 = ((GString*)g_slist_nth_data(val->many_list, 1))->str; - fi = g_hash_table_lookup(field_hash, field1); - - if (!fi) - return 0; - - return fi->computation_type;; -} - -/* ------------------- EITHEROF_TABLE ------------------------ */ -void write_rt_eitherof_table(FILE *out) -{ - fprintf(out, "eitherof_info eitherof_table[] = {\n"); - g_hash_table_foreach(field_hash, rt_eitherof_table, out); - fprintf(out, "\t{ 0, 0, 0, 0 }\n};\n"); -} - -void rt_eitherof_table(gpointer key, gpointer value, gpointer out) -{ - char *upcase_field, *upcase_field1, *upcase_field2; - struct field_info *val = (struct field_info*) value; - - if (!val) { - g_print("key %s has no value.\n", (char*)key); - return; - } - - if (val->computation_type != CTYPE_EITHEROF) { - return; - } - - upcase_field = rt_lex_token_upcase(((struct field_info*)value)->name); - g_print("EITHEROF checking %s\n", upcase_field); - if (val->many_list) { - g_print("getting fields\n"); - upcase_field1 = ((GString*)g_slist_nth_data(val->many_list, 1))->str; - g_print("got field1 %s\n", upcase_field1); - upcase_field2 = ((GString*)g_slist_nth_data(val->many_list, 2))->str; - g_print("got field2 %s\n", upcase_field2); - upcase_field1 = rt_lex_token_upcase(upcase_field1); - g_print("got field1 %s\n", upcase_field1); - upcase_field2 = rt_lex_token_upcase(upcase_field2); - g_print("got field2 %s\n", upcase_field2); - } - else - return; - - fprintf((FILE*)out, "\t{ %s, %d, %s, %s },\n", - upcase_field, val->computation_type, - upcase_field1, upcase_field2); - free(upcase_field); - free(upcase_field1); - free(upcase_field2); -} - -/* ---------------------- YACC_TOKENS ---------------------------- */ -void write_rt_yacc_tokens(FILE *out) -{ - g_hash_table_foreach(field_hash, rt_yacc_tokens, out); -} - -void rt_yacc_tokens(gpointer key, gpointer value, gpointer out) -{ - char *upcase; - struct field_info *val = (struct field_info*) value; - - if (!val) { - g_print("key %s has no value.\n", (char*)key); - return; - } - - upcase = rt_lex_token_upcase(((struct field_info*)value)->name); - fprintf((FILE*)out, "%%token <d>\t%s\n", upcase); - free(upcase); -} - -/* ------------------------ BYTECMP_LVAL -------------------------- */ -void write_rt_bytecmp_lval(FILE *out) -{ - rt_iteration = 0; - g_hash_table_foreach(field_hash, rt_bytecmp_lval, out); - fprintf(out, "\t;\n"); -} - -void rt_bytecmp_lval(gpointer key, gpointer value, gpointer out) -{ - char *upcase; - struct field_info *val = (struct field_info*) value; - - if (!val) { - g_print("key %s has no value.\n", (char*)key); - return; - } - - if (val->computation_type == CTYPE_EITHEROF) { - if (many_list_subtype(val) != CTYPE_BYTECMP) - return; - } - else if (val->computation_type != CTYPE_BYTECMP) { - return; - } - - if (rt_iteration == 0) { - fprintf(out, "bytecmp_lval:\t"); - } - else { - fprintf(out,"\t|\t"); - } - - upcase = rt_lex_token_upcase(((struct field_info*)value)->name); - fprintf((FILE*)out, "\t%s { $$ = %s; }\n", - upcase, upcase); - free(upcase); - rt_iteration++; -} diff --git a/wiretap/ct-compile.h b/wiretap/ct-compile.h deleted file mode 100644 index d76a5e5ce9..0000000000 --- a/wiretap/ct-compile.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ct-compile.h - ------------ - Compile-time filter-compiler for Wiretap - -*/ - -#ifndef __G_LIB_H__ -#include <glib.h> -#endif - -/* field type IDs */ -#define FTYPE_BOOLEAN 1 -#define FTYPE_ETHER 2 -#define FTYPE_IPv4ADDR 3 -#define FTYPE_UINT8 4 -#define FTYPE_UINT16 5 -#define FTYPE_UINT32 6 -#define FTYPE_BYTE 7 - -/* field lengths */ -#define FLEN_BOOLEAN 1 -#define FLEN_ETHER 6 -#define FLEN_IPv4ADDR 4 -#define FLEN_UINT8 1 -#define FLEN_UINT16 2 -#define FLEN_UINT32 4 -/* FLEN_BYTE doesn't get a fixed length, of course */ - -/* computation types */ -#define CTYPE_NONE 0 -#define CTYPE_ANDMASK 1 -#define CTYPE_BYTECMP 2 -#define CTYPE_EITHEROF 3 - -/* Protocol-layer information */ -struct protocol_layer { - char *name; - char *description; - GSList *parents; -}; - -/* Fields */ -struct field_info { - char *name; - char *short_name; - char *description; - int field_type; - int computation_type; - int offset; - int value; - int length; - - GSList *aliases; - GSList *many_list; - - struct protocol_layer *parent; -}; - -/* Add a field-info struct to the compiler's list of fields */ -void field_info_add(struct field_info *fi, char *protocol); - -/* Initialize values in a field_info struct. This can only be run once per - * structure, as it would cause a memory leak if used multiple times. */ -void field_info_init(struct field_info *fi); - -/* Zero-out the values in a field_info struct. This can be used more than once - * per structure, as it avoids a memory leak. But call field_info_init the - * first time, and field_info_zero for all other times */ -void field_info_zero(struct field_info *fi); - -/* add alias(es) to this field */ -void field_info_add_alias(char *field_name, GSList *aliases); - -/* add a protocol to the hash */ -void protocol_layer_add(char *name, char *description); - -/* Given a list of GStrings of field names, returns a list of pointers - * to field_info structs */ -GSList* field_info_list(GSList *field_names, char *protocol); - -/* used by field_info_list() */ -void field_info_list_func1(gpointer node, gpointer protocol); -void field_info_list_func2(gpointer node, gpointer new_list); - -void compiler_init(void); -void write_rt_lex(void); -void write_rt_lex_tokens(FILE *out); -void rt_lex_tokens(gpointer key, gpointer value, gpointer out); -void rt_lex_tokens_aliases(gpointer node, gpointer out); -char* rt_lex_token_upcase(char *text); - -void write_rt_yacc(void); -void write_rt_bytecmp_table(FILE *out); -void rt_bytecmp_table(gpointer key, gpointer value, gpointer out); -void write_rt_eitherof_table(FILE *out); -void rt_eitherof_table(gpointer key, gpointer value, gpointer out); -void write_rt_yacc_tokens(FILE *out); -void rt_yacc_tokens(gpointer key, gpointer value, gpointer out); -void write_rt_bytecmp_lval(FILE *out); -void rt_bytecmp_lval(gpointer key, gpointer value, gpointer out); - -int wtap_lex(void); -int wtap_parse(void); -void wtap_error(char *string); diff --git a/wiretap/ct-grammar.y b/wiretap/ct-grammar.y deleted file mode 100644 index 5841e5c737..0000000000 --- a/wiretap/ct-grammar.y +++ /dev/null @@ -1,149 +0,0 @@ -%{ - -#include <stdlib.h> -#include <stdio.h> -#include "ct-compile.h" - -#include "config.h" - -#ifdef HAVE_GLIB10 -#include "glib-new.h" -#endif - -struct field_info working_field; -gchar *current_protocol = NULL; -char *full_field_name = NULL; - -%} - -%union { - gint d; - GString *s; - GSList *a; -} - -%type <s> sentence protocol -%type <a> parents text_list - -%token <s> TEXT PROTOCOL PARENTS QUOTED -%token <d> NUMBER BOOLEAN ETHER UINT8 UINT16 UINT32 BYTE -%token FIELD ALIAS -%token AND_MASK BYTE_OFFSET EITHER_OF - -%% - -paragraph: /* EMPTY */ - | paragraph sentence - ; - -sentence: protocol -{ - if (current_protocol) - free(current_protocol); - current_protocol = g_strdup($1->str); -} - | parents -{ - g_print("sentence Got parents %d\n", g_slist_length($1)); -} - | alias { } - | field { } - ; - -protocol: PROTOCOL TEXT QUOTED ';' -{ - protocol_layer_add($2->str, $3->str); - $$ = $2; -} - ; - -parents: PARENTS text_list ';' -{ - $$ = $2; - g_slist_free($2); -} - ; - -alias: ALIAS TEXT text_list ';' -{ - full_field_name = g_strjoin(".", current_protocol, $2->str, NULL); - field_info_add_alias(full_field_name, $3); - g_free(full_field_name); -} - - -field: FIELD TEXT QUOTED ',' field_type ',' field_location ';' -{ - working_field.name = g_strjoin(".", current_protocol, $2->str, NULL); - working_field.short_name = g_strdup($2->str); - working_field.description = g_strdup($3->str); - - field_info_add(&working_field, current_protocol); - field_info_zero(&working_field); -} - - -field_type: BOOLEAN -{ - working_field.field_type = FTYPE_BOOLEAN; - working_field.length = FLEN_BOOLEAN; -} - | ETHER -{ - working_field.field_type = FTYPE_ETHER; - working_field.length = FLEN_ETHER; -} - | UINT8 -{ - working_field.field_type = FTYPE_UINT8; - working_field.length = FLEN_UINT8; -} - | UINT16 -{ - working_field.field_type = FTYPE_UINT16; - working_field.length = FLEN_UINT16; -} - | UINT32 -{ - working_field.field_type = FTYPE_UINT32; - working_field.length = FLEN_UINT32; -} - | BYTE '[' NUMBER ']' -{ - working_field.field_type = FTYPE_BYTE; - working_field.length = $3; -} - ; - -field_location: AND_MASK '(' NUMBER '@' NUMBER ')' -{ - working_field.computation_type = CTYPE_ANDMASK; - working_field.value = $3; - working_field.offset = $5; -} - | BYTE_OFFSET '(' NUMBER ')' -{ - working_field.computation_type = CTYPE_BYTECMP; - working_field.offset = $3; -} - | EITHER_OF '(' text_list ')' -{ - working_field.computation_type = CTYPE_EITHEROF; - working_field.many_list = field_info_list($3, current_protocol); - g_slist_free($3); -} - - ; - -text_list: TEXT -{ - $$ = g_slist_alloc(); - g_slist_append($$, $1); -} - | text_list ',' TEXT -{ - $$ = $1; - g_slist_append($$, $3); -} - - ; diff --git a/wiretap/ct-main.c b/wiretap/ct-main.c deleted file mode 100644 index 7e7bb9fbd8..0000000000 --- a/wiretap/ct-main.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ct-main.c - * --------- - * Wiretap filter compilter - */ - - -#include <stdio.h> - -#include "ct-compile.h" - - -int main(void) -{ - FILE *yyin; - - yyin = stdin; - - compiler_init(); - wtap_parse(); - write_rt_lex(); - write_rt_yacc(); - - return 0; -} diff --git a/wiretap/ct-scanner.l b/wiretap/ct-scanner.l deleted file mode 100644 index 7e33ad0313..0000000000 --- a/wiretap/ct-scanner.l +++ /dev/null @@ -1,74 +0,0 @@ -%{ -#include <glib.h> -#include <stdio.h> -#include "ct-grammar.h" -int lex_line_number = 1; -%} - -N ([0-9]+|(0X|0x)[0-9A-Fa-f]+) -B [0-9A-Fa-f][0-9A-Fa-f]? -W [A-Za-z_] -quoted \"[^"\n]*["\n] - -%% - -\n lex_line_number++; -[\t ]+ /* eat whitespace */ -#.* /* one-line shell-style comments */ - -{quoted} { - wtap_lval.s = g_string_new(wtap_text + 1); - g_string_truncate(wtap_lval.s, strlen(wtap_text) - 2); -/* g_print("lex made QUOTED (%s)\n", wtap_lval.s->str);*/ - return QUOTED; -} - -";" return ';'; -"," return ','; -"(" return '('; -")" return ')'; -"@" return '@'; -"[" return '['; -"]" return ']'; - -protocol return PROTOCOL; -parents return PARENTS; -field return FIELD; -alias return ALIAS; - -boolean return BOOLEAN; -ether return ETHER; -uint8 return UINT8; -uint16 return UINT16; -uint32 return UINT32; -byte return BYTE; - -and_mask return AND_MASK; -byte_offset return BYTE_OFFSET; -either_of return EITHER_OF; - - -{N} { - wtap_lval.d = atoi(wtap_text); - return NUMBER; -} - -{W}+ { - wtap_lval.s = g_string_new(wtap_text); -/* g_print("lex made TEXT (%s)\n", wtap_lval.s->str);*/ - return TEXT; - } - -%% - -int -wtap_wrap() -{ - return 1; -} - -void wtap_error(char *string) -{ - fprintf(stderr,"%s on line %d\n",string, lex_line_number); - exit(0); -} diff --git a/wiretap/file.c b/wiretap/file.c index 5a13761002..0c9f760da5 100644 --- a/wiretap/file.c +++ b/wiretap/file.c @@ -1,6 +1,6 @@ /* file.c * - * $Id: file.c,v 1.9 1999/03/01 18:57:04 gram Exp $ + * $Id: file.c,v 1.10 1999/07/07 22:52:54 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -53,10 +53,6 @@ wtap* wtap_open_offline(char *filename) /* initialization */ wth->file_encap = WTAP_ENCAP_NONE; - wth->filter.offline = NULL; - wth->filter_type = WTAP_FILTER_NONE; - wth->filter_length = 0; - wth->offline_filter_lengths = NULL; /* Try all file types */ diff --git a/wiretap/filter-eth b/wiretap/filter-eth deleted file mode 100644 index 4bed0033cd..0000000000 --- a/wiretap/filter-eth +++ /dev/null @@ -1,38 +0,0 @@ -# filter-eth -# -# Ethernet Filter -# - -protocol eth "Ethernet"; -#length variable; -parents none; - -field src "Source Hardware Address", - ether, - byte_offset(6); - -field dst "Destination Hardware Address", - ether, - byte_offset(0); - -field srcvendor "Vendor of Source Hardware Address", - byte[3], - byte_offset(6); - -field dstvendor "Vendor of Destination Hardware Address", - byte[3], - byte_offset(0); - -alias src srcaddr; -alias dst dest, dstaddr, destaddr; - -field addr "Hardware Address", - ether, - either_of(src, dst); - -alias addr hwaddr; - -field vendor "Hardware Vendor", - byte[3], - either_of(srcvendor, dstvendor); - diff --git a/wiretap/filter-tr b/wiretap/filter-tr deleted file mode 100644 index bfc704754e..0000000000 --- a/wiretap/filter-tr +++ /dev/null @@ -1,57 +0,0 @@ -# filter-tr -# -# Token-Ring Filter -# - -protocol tr "Token-Ring"; -#length variable; -parents none; - -field sr "Source-Routed Flag", - boolean, - and_mask(127 @ 8); - -field src "Source Hardware Address", - ether, - byte_offset(8); - -field dst "Destination Hardware Address", - ether, - byte_offset(2); - -field srcvendor "Vendor of Source Hardware Address", - byte[3], - byte_offset(8); - -field dstvendor "Vendor of Destination Hardware Address", - byte[3], - byte_offset(2); - -field _next "Next protocol layer", - uint8, - and_mask(192 @ 1); - -alias src srcaddr; -alias dst dest, dstaddr, destaddr; -alias dstvendor destvendor; - -field addr "Hardware Address", - ether, - either_of(src, dst); - -alias addr hwaddr; - -field vendor "Hardware Vendor", - byte[3], - either_of(srcvendor, dstvendor); - - -#next_protocol { -# 64 : trmac -# 128 : llc -#} - -#next_offset { -# ldx -# df -#} diff --git a/wiretap/glib-new.c b/wiretap/glib-new.c deleted file mode 100644 index d8f6ee6d1c..0000000000 --- a/wiretap/glib-new.c +++ /dev/null @@ -1,105 +0,0 @@ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#ifdef HAVE_GLIB10 - -#include <glib.h> -#include <stdarg.h> -#include <string.h> - -gpointer -g_memdup (const gpointer mem, - guint byte_size) -{ - gpointer new_mem; - - if (mem) - { - new_mem = g_malloc (byte_size); - memcpy (new_mem, mem, byte_size); - } - else - new_mem = NULL; - - return new_mem; -} - -gchar* -g_strjoin (const gchar *separator, - ...) -{ - gchar *string, *s; - va_list args; - guint len; - guint separator_len; - - if(separator == NULL) - separator = ""; - - separator_len = strlen (separator); - - va_start(args, separator); - - s = va_arg(args, gchar *); - - if(s) { - len = strlen(s) + 1; - - while((s = va_arg(args, gchar*))) - { - len += separator_len + strlen(s); - } - va_end(args); - - string = g_new (gchar, len); - - va_start(args, separator); - - *string = 0; - s = va_arg(args, gchar*); - strcat (string, s); - - while((s = va_arg(args, gchar*))) - { - strcat(string, separator); - strcat(string, s); - } - - } else - string = g_strdup(""); - - va_end(args); - - return string; -} - -/* this was introduced sometime between glib-1.0.1 and glib-1.0.4 */ -gpointer -g_slist_nth_data (GSList *list, - guint n) -{ - while ((n-- > 0) && list) - list = list->next; - - return list ? list->data : NULL; -} - - -#endif diff --git a/wiretap/glib-new.h b/wiretap/glib-new.h deleted file mode 100644 index 562efdbbb2..0000000000 --- a/wiretap/glib-new.h +++ /dev/null @@ -1,30 +0,0 @@ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -gpointer -g_memdup (const gpointer mem, - guint byte_size); - -gchar* -g_strjoin (const gchar *separator, - ...); - -gpointer -g_slist_nth_data (GSList *list, - guint n); diff --git a/wiretap/rt-compile.c b/wiretap/rt-compile.c deleted file mode 100644 index d11fe4c62c..0000000000 --- a/wiretap/rt-compile.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * rt-compile.c - * ------------ - * - */ - -#include <glib.h> -#include "wtap.h" -#include "bpf.h" -#include "rt-compile.h" -#include "rt-global.h" - -int (*mk_attach) - (wtap *wth); - -/* Takes a string representing a display filter, compiles it, and -if the filter compiles successfully, attaches the filter to the wtap handle. -The tricky part comes from the fact that some display filters are -datalink-type-independent (they refer to layers 3 and above of the OSI -protocol stack), whereas others are datalink-type-dependent. Furthermore, some -trace files supported by wiretap can handle more than one datalink type. - -We rely on the user to use the proper logic for multiple datalink types. For -example, if the user has a trace file with ethernet and token-ring packets, -and wants to filter on the MAC-layer broadcast address, he should write: - - (eth.dst eq ff:ff:ff:ff:ff:ff or tr.dst eq ff:ff:ff:ff:ff:ff) - -That is, "eth.dst eq ...." fails for a token-ring interface, and -"tr.dst eq ...." fails for an ethernet device. A logical "or" is needed -to find MAC-level broadcast addresses in both datalink types. */ - -int wtap_offline_filter(wtap *wth, char *filter) -{ - int encap_type; - - if (!filter) - return 0; - - /* temporary hack */ - if (filter[0] == 0) { - wtap_filter_offline_clear(wth); - return 0; - } - - /* we use the BPF engine for offline filters */ - wtap_filter_offline_init(wth); - wth->filter_text = g_strdup(filter); - - /* if the file format we are using has a per-file encapsulation - * type, then we can go ahead and compile the display filter for - * that datalink type. Otherwise, we'll guess ethernet. - */ - if (wth->file_encap != WTAP_ENCAP_NONE) - encap_type = wth->file_encap; - else - encap_type = WTAP_ENCAP_ETHERNET; - - if (!wtap_offline_filter_compile(wth, encap_type)) { - wtap_filter_offline_clear(wth); - return -1; - } - - return 0; -} - -/* this function is called from within wiretap to recompile the same display - * filter for a different datalink type. This is needed for trace files that - * have more than one encapsulation type in the same file - */ -int wtap_offline_filter_compile(wtap *wth, int encap_type) -{ - comp_encap_type = encap_type; - filter_parsed = 0; - wtap_lex_init(wth->filter_text); - wtap_parse(); - - if (!filter_parsed) - return 0; - - return mk_attach(wth); -} diff --git a/wiretap/rt-compile.h b/wiretap/rt-compile.h deleted file mode 100644 index d7a27aba32..0000000000 --- a/wiretap/rt-compile.h +++ /dev/null @@ -1,29 +0,0 @@ - -#ifndef __WTAP_H_ -#include "wtap.h" -#endif - -/* Holds info for fields defined as bytecmp. */ -typedef struct { - int ftype; - int ctype; - int offset; - int length; -} bytecmp_info; - - -/* Holds info for fields defined as either_of */ -typedef struct { - int ftype; - int ctype; - int field1; - int field2; -} eitherof_info; - -int wtap_lex(void); -int wtap_parse(void); -void wtap_error(char *string); - -void wtap_lex_init(char *); - -int wtap_offline_filter_compile(wtap *wth, int encap_type); diff --git a/wiretap/rt-global.h b/wiretap/rt-global.h deleted file mode 100644 index 952acc939a..0000000000 --- a/wiretap/rt-global.h +++ /dev/null @@ -1,23 +0,0 @@ - - -extern GList* (*mk_bytecmp) - (int ftype, int rel_opcode, guint8 *bytes); - -extern void (*mk_optimize) - (GList *L); - - -/* for those modules that are interested in mk_attach, - * wtap.h will have already been included. - */ -#ifdef __WTAP_H__ -extern int (*mk_attach) - (wtap *wth); -#endif - -extern bytecmp_info bytecmp_table[]; -extern int comp_encap_type; -extern int filter_parsed; - -bytecmp_info* lookup_bytecmp(int ftype); -eitherof_info* lookup_eitherof(int ftype); diff --git a/wiretap/rt-grammar-skel.y b/wiretap/rt-grammar-skel.y deleted file mode 100644 index b14d7b31f1..0000000000 --- a/wiretap/rt-grammar-skel.y +++ /dev/null @@ -1,134 +0,0 @@ -%{ - -#ifndef __G_LIB_H__ -#include <glib.h> -#endif - -#include "rt-compile.h" -#include "rt-global.h" -#include "ct-compile.h" - -GList* (*mk_bytecmp) (int ftype, int rel_opcode, guint8 *bytes); -void (*mk_optimize) (GList *L); - -/* The encapsulation type for which we are compiling the filter */ -int comp_encap_type; -int filter_parsed = 0; - -bytecmp_info *bytecmp; -eitherof_info *either; -GList *L1, *L2; - -/* ct-compile: bytecmp_table */ -/*bytecmp_info bytecmp_table[] = { - { ETH_TYPE, 12, 2 }, - { TR_DST, 2, 6 }, - { TR_SRC, 8, 6 }, - { ETH_DSTVENDOR, 0, 3 }, - { 0, 0, 0 } -};*/ - -/* ct-compile: eitherof_table */ -/*eitherof_table[] = { - { TR_VENDOR, CTYPE_BYTECMP, TR_SRCVENDOR, TR_DSTVENDOR }, - { TR_ADDR, CTYPE_BYTECMP, TR_SRCADDR, TR_DSTADDR } -}; -*/ -%} - -%union { - gint d; - guint8 *b; - GString *s; - GList *L; -} - -%type <d> bytecmp_lval -%type <L> sentence bytecmp_relation -%type <d> bytecmp_test; - -%token <b> BYTES -%token <s> QUOTED TEXT -%token <d> NUMBER -%token <d> EQ NE - -/* ct-compile: yacc tokens */ - -%% - -paragraph: /* EMPTY */ - | paragraph sentence { mk_optimize($2); filter_parsed = 1; } - ; - -sentence: bytecmp_relation { $$ = $1 } - ; - - -bytecmp_relation: bytecmp_lval bytecmp_test BYTES -{ - bytecmp = lookup_bytecmp($1); - if (bytecmp->ctype == CTYPE_EITHEROF) { - either = lookup_eitherof($1); - L1 = mk_bytecmp(either->field1, $2, $3); - L2 = mk_bytecmp(either->field2, $2, $3); - $$ = g_list_concat(L1, L2); - } - else { - $$ = mk_bytecmp($1, $2, $3); - } -} - ; - -/* ct-compile: bytecmp_lval */ -/*bytecmp_lval: TR_DST { $$ = TR_DST; } - | TR_SRC { $$ = TR_SRC; } - | TR_SRCVENDOR { $$ = TR_SRCVENDOR; } - | TR_DSTVENDOR { $$ = TR_DSTVENDOR; } - ;*/ - -bytecmp_test: EQ { $$ = EQ; } - | NE { $$ = NE; } - ; - -%% - -bytecmp_info* -lookup_bytecmp(int ftype) -{ - bytecmp_info *b = &bytecmp_table[0]; - bytecmp_info *ret_val = NULL; - - /* find the field in the table */ - while (b->ftype != 0) { - if (b->ftype == ftype) { - ret_val = b; - break; - } - else { - b++; - } - } - - return ret_val; -} - - -eitherof_info* -lookup_eitherof(int ftype) -{ - eitherof_info *e = &eitherof_table[0]; - eitherof_info *ret_val = NULL; - - /* find the field in the table */ - while (e->ftype != 0) { - if (e->ftype == ftype) { - ret_val = e; - break; - } - else { - e++; - } - } - - return ret_val; -} diff --git a/wiretap/rt-scanner-skel.l b/wiretap/rt-scanner-skel.l deleted file mode 100644 index 6a14f8f343..0000000000 --- a/wiretap/rt-scanner-skel.l +++ /dev/null @@ -1,160 +0,0 @@ -%{ -#include <glib.h> -#include "rt-grammar.h" -guint8* parse_bytes(char *text); -enum nibble_t { high, low }; -static char *in_buffer; - -/* from libpcap */ -#ifdef FLEX_SCANNER -#define YY_NO_UNPUT -#undef YY_INPUT -#define YY_INPUT(buf, result, max)\ - {\ - char *src = in_buffer;\ - int i;\ -\ - if (*src == 0)\ - result = YY_NULL;\ - else {\ - for (i = 0; *src && i < max; ++i)\ - buf[i] = *src++;\ - in_buffer += i;\ - result = i;\ - }\ - } -#else -#undef getc -#define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++) -#endif - - -%} - -N ([0-9]+|(0X|0x)[0-9A-Fa-f]+) -B [0-9A-Fa-f][0-9A-Fa-f]?([-:.]?[0-9A-Fa-f][0-9A-Fa-f]?)* -W [A-Za-z_] -quoted \"[^"\n]*["\n] - -%% - -[\n\t ]+ /* eat whitespace */ - -{quoted} { - wtap_lval.s = g_string_new(wtap_text + 1); - g_string_truncate(wtap_lval.s, strlen(wtap_text) - 2); - return QUOTED; -} - -";" return ';'; -"," return ','; -"(" return '('; -")" return ')'; -"@" return '@'; - -/* ct-compile: lex tokens */ - -eq return EQ; -ne return NE; - -{B} { - wtap_lval.b = parse_bytes(wtap_text); - return BYTES; -} - -{N} { - wtap_lval.d = atoi(wtap_text); - return NUMBER; -} - -{W}+ { - wtap_lval.s = g_string_new(wtap_text); - return TEXT; - } - -%% - -guint8* -parse_bytes(char *text) -{ - guint8 buffer[256]; - guint8 index = 0; - char *cp; - char character; - guint8 byte_val=0; - gchar *dup_ptr; - enum nibble_t nibble = high; - - for (cp = text; (*cp != '\x0') && index < 256; cp++) { - character = *cp; - - if (nibble == high) { - /* assumes ASCII, not EBCDIC */ - if (character >= '0' && character <= '9') { - byte_val = (character - '0') << 4; - } - else if (character >= 'A' && character <= 'F') { - byte_val = (character - 'A' + 10) << 4; - } - else if (character >= 'a' && character <= 'f') { - byte_val = (character - 'a' + 10) << 4; - } - else { - continue; - } - nibble = low; - continue; - } - else { - /* assumes ASCII, not EBCDIC */ - if (character >= '0' && character <= '9') { - byte_val += (character - '0'); - } - else if (character >= 'A' && character <= 'F') { - byte_val += (character - 'A' + 10); - } - else if (character >= 'a' && character <= 'f') { - byte_val += (character - 'a' + 10); - } - else { - byte_val >>= 4; - } - nibble = high; - - buffer[index] = byte_val; - index++; - } - - } - - /* did we finish mid-nibble? */ - if (nibble == low) { - buffer[index] = byte_val >> 4; - index++; - } - - dup_ptr = g_malloc(index + 1); - dup_ptr[0] = index; - memcpy(dup_ptr + 1, buffer, index); - return dup_ptr; -} - - -void wtap_error(char *string) -{ - g_error("%s\n",string); - exit(0); -} - -void -wtap_lex_init(char *buf) -{ - in_buffer = buf; -} - -int -yywrap() -{ - return 1; -} - diff --git a/wiretap/wtap.c b/wiretap/wtap.c index e002d18e01..a88c3d70a4 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.7 1999/03/01 18:57:07 gram Exp $ + * $Id: wtap.c,v 1.8 1999/07/07 22:52:56 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -75,35 +75,9 @@ void wtap_close(wtap *wth) void wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user) { int data_offset; - int ret; - int pkt_encap; while ((data_offset = wth->subtype_read(wth)) > 0) { - /* offline filter? */ - if (wth->filter_type == WTAP_FILTER_OFFLINE) { - pkt_encap = wth->phdr.pkt_encap; - - /* do we have a compiled filter for this - * encapsulation type? */ - if (!wth->filter.offline[pkt_encap]) - wtap_offline_filter_compile(wth, pkt_encap); - - /* run the filter */ - ret = bpf_run_filter( - buffer_start_ptr(wth->frame_buffer), - wth->phdr.caplen, - wth->filter.offline[pkt_encap], - wth->offline_filter_lengths[pkt_encap] - ); - - /* if the packet made it through the filter, - * send the data to the user */ - if (ret > 0) - callback(user, &wth->phdr, data_offset, - buffer_start_ptr(wth->frame_buffer)); - } - else - callback(user, &wth->phdr, data_offset, - buffer_start_ptr(wth->frame_buffer)); + callback(user, &wth->phdr, data_offset, + buffer_start_ptr(wth->frame_buffer)); } } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 230e702a32..61c302e4e4 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.18 1999/05/12 21:40:07 guy Exp $ + * $Id: wtap.h,v 1.19 1999/07/07 22:52:57 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -136,23 +136,11 @@ typedef struct wtap { file formats that have per-file encapsulation types */ - union { - struct bpf_instruction *bpf; - struct bpf_instruction **offline; - } filter; - - gchar *filter_text; - int filter_type; - int filter_length; /* length in bytes or records, - depending upon filter_type */ - - int *offline_filter_lengths; } wtap; wtap* wtap_open_offline(char *filename); void wtap_loop(wtap *wth, int, wtap_handler, u_char*); -int wtap_offline_filter(wtap *wth, char *filter); FILE* wtap_file(wtap *wth); int wtap_snapshot_length(wtap *wth); /* per file */ |