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
This commit is contained in:
Gilbert Ramirez 1999-07-07 22:52:57 +00:00
parent fba49cfe85
commit 07f42b5b31
102 changed files with 5498 additions and 5474 deletions

View File

@ -4,6 +4,8 @@ man_MANS = ethereal.1
sysconf_DATA = manuf
YFLAGS=-d
ethereal_SOURCES = \
alignment.h \
capture.c \
@ -11,6 +13,9 @@ ethereal_SOURCES = \
column.c \
column.h \
config.h \
dfilter-grammar.y \
dfilter.c \
dfilter.h \
display.c \
display.h \
ethereal.c \
@ -87,15 +92,17 @@ ethereal_SOURCES = \
prefs.h \
print.c \
print.h \
proto.c \
proto.h \
ps.c \
ps.h \
resolv.c \
resolv.h \
smb.h \
summary.h \
summary.c \
timestamp.h \
util.c \
summary.c \
summary.h \
util.h
EXTRA_ethereal_SOURCES = \
@ -106,8 +113,8 @@ EXTRA_ethereal_SOURCES = \
strerror.c \
strerror.h
ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ @LIBWIRETAP_A@
ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ @LIBWIRETAP_A@ @SNMP_A@
ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a
ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a @SNMP_A@
ps.c: print.ps rdps
./rdps print.ps ps.c
@ -134,7 +141,7 @@ EXTRA_DIST = \
ylwrap \
VERSION
SUBDIRS = @SUBDIRS@
SUBDIRS = wiretap @SUBDIRS@
ethereal.1: doc/ethereal.pod VERSION
(cd doc ; \

View File

@ -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 = :
@ -64,7 +65,6 @@ DATAFILE_DIR = @DATAFILE_DIR@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_CONFIG = @GTK_CONFIG@
GTK_LIBS = @GTK_LIBS@
LIBWIRETAP_A = @LIBWIRETAP_A@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@ -75,6 +75,7 @@ SNPRINTF_O = @SNPRINTF_O@
STRERROR_C = @STRERROR_C@
STRERROR_O = @STRERROR_O@
VERSION = @VERSION@
YACC = @YACC@
bin_PROGRAMS = ethereal
@ -82,14 +83,16 @@ man_MANS = ethereal.1
sysconf_DATA = manuf
ethereal_SOURCES = alignment.h capture.c capture.h column.c column.h config.h display.c display.h ethereal.c ethereal.h ethertype.c etypes.h file.c file.h filter.c filter.h follow.c follow.h gtkpacket.c gtkpacket.h menu.c menu.h packet-aarp.c packet-arp.c packet-atalk.c packet-bootp.c packet-cdp.c packet-data.c packet-dns.c packet-dns.h packet-eth.c packet-fddi.c packet-ftp.c packet-giop.c packet-gre.c packet-http.c packet-icmpv6.c packet-ip.c packet-ip.h packet-ipsec.c packet-ipv6.c packet-ipv6.h packet-ipx.c packet-ipx.h packet-isakmp.c packet-llc.c packet-lpd.c packet-nbipx.c packet-nbns.c packet-ncp.c packet-ncp.h packet-nntp.c packet-null.c packet-osi.c packet-ospf.c packet-ospf.h packet-pop.c packet-ppp.c packet-pppoe.c packet-pptp.c packet-raw.c packet-rip.c packet-rip.h packet-rsvp.c packet-rsvp.h packet-rtsp.c packet-sdp.c packet-smb.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tr.c packet-trmac.c packet-udp.c packet-vines.c packet-vines.h packet.c packet.h prefs.c prefs.h print.c print.h ps.c ps.h resolv.c resolv.h smb.h summary.h summary.c timestamp.h util.c util.h
YFLAGS = -d
ethereal_SOURCES = alignment.h capture.c capture.h column.c column.h config.h dfilter-grammar.y dfilter.c dfilter.h display.c display.h ethereal.c ethereal.h ethertype.c etypes.h file.c file.h filter.c filter.h follow.c follow.h gtkpacket.c gtkpacket.h menu.c menu.h packet-aarp.c packet-arp.c packet-atalk.c packet-bootp.c packet-cdp.c packet-data.c packet-dns.c packet-dns.h packet-eth.c packet-fddi.c packet-ftp.c packet-giop.c packet-gre.c packet-http.c packet-icmpv6.c packet-ip.c packet-ip.h packet-ipsec.c packet-ipv6.c packet-ipv6.h packet-ipx.c packet-ipx.h packet-isakmp.c packet-llc.c packet-lpd.c packet-nbipx.c packet-nbns.c packet-ncp.c packet-ncp.h packet-nntp.c packet-null.c packet-osi.c packet-ospf.c packet-ospf.h packet-pop.c packet-ppp.c packet-pppoe.c packet-pptp.c packet-raw.c packet-rip.c packet-rip.h packet-rsvp.c packet-rsvp.h packet-rtsp.c packet-sdp.c packet-smb.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tr.c packet-trmac.c packet-udp.c packet-vines.c packet-vines.h packet.c packet.h prefs.c prefs.h print.c print.h proto.c proto.h ps.c ps.h resolv.c resolv.h smb.h timestamp.h util.c summary.c summary.h util.h
EXTRA_ethereal_SOURCES = packet-snmp.c snprintf.c snprintf.h snprintf-imp.h strerror.c strerror.h
ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ @LIBWIRETAP_A@
ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ @LIBWIRETAP_A@ @SNMP_A@
ethereal_DEPENDENCIES = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a
ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a @SNMP_A@
DISTCLEANFILES = rdps ps.c *~
@ -97,7 +100,7 @@ DISTCLEANFILES = rdps ps.c *~
EXTRA_DIST = doc/Makefile doc/ethereal.pod ethereal.1 ethereal.spec image/icon-excl.xpm image/icon-ethereal.xpm manuf print.ps README.tru64 rdps.c ylwrap VERSION
SUBDIRS = @SUBDIRS@
SUBDIRS = wiretap @SUBDIRS@
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
@ -109,18 +112,19 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
ethereal_OBJECTS = capture.o column.o display.o ethereal.o ethertype.o \
file.o filter.o follow.o gtkpacket.o menu.o packet-aarp.o packet-arp.o \
packet-atalk.o packet-bootp.o packet-cdp.o packet-data.o packet-dns.o \
packet-eth.o packet-fddi.o packet-ftp.o packet-giop.o packet-gre.o \
packet-http.o packet-icmpv6.o packet-ip.o packet-ipsec.o packet-ipv6.o \
packet-ipx.o packet-isakmp.o packet-llc.o packet-lpd.o packet-nbipx.o \
packet-nbns.o packet-ncp.o packet-nntp.o packet-null.o packet-osi.o \
packet-ospf.o packet-pop.o packet-ppp.o packet-pppoe.o packet-pptp.o \
packet-raw.o packet-rip.o packet-rsvp.o packet-rtsp.o packet-sdp.o \
packet-smb.o packet-tcp.o packet-telnet.o packet-tftp.o packet-tr.o \
packet-trmac.o packet-udp.o packet-vines.o packet.o prefs.o print.o \
ps.o resolv.o summary.o util.o
ethereal_OBJECTS = capture.o column.o dfilter-grammar.o dfilter.o \
display.o ethereal.o ethertype.o file.o filter.o follow.o gtkpacket.o \
menu.o packet-aarp.o packet-arp.o packet-atalk.o packet-bootp.o \
packet-cdp.o packet-data.o packet-dns.o packet-eth.o packet-fddi.o \
packet-ftp.o packet-giop.o packet-gre.o packet-http.o packet-icmpv6.o \
packet-ip.o packet-ipsec.o packet-ipv6.o packet-ipx.o packet-isakmp.o \
packet-llc.o packet-lpd.o packet-nbipx.o packet-nbns.o packet-ncp.o \
packet-nntp.o packet-null.o packet-osi.o packet-ospf.o packet-pop.o \
packet-ppp.o packet-pppoe.o packet-pptp.o packet-raw.o packet-rip.o \
packet-rsvp.o packet-rtsp.o packet-sdp.o packet-smb.o packet-tcp.o \
packet-telnet.o packet-tftp.o packet-tr.o packet-trmac.o packet-udp.o \
packet-vines.o packet.o prefs.o print.o proto.o ps.o resolv.o util.o \
summary.o
ethereal_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -134,40 +138,41 @@ DATA = $(sysconf_DATA)
DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
Makefile.am Makefile.in NEWS acconfig.h acinclude.m4 aclocal.m4 \
config.guess config.h.in config.sub configure configure.in install-sh \
missing mkinstalldirs ylwrap
config.guess config.h.in config.sub configure configure.in \
dfilter-grammar.c install-sh missing mkinstalldirs ylwrap
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/capture.P .deps/column.P .deps/display.P \
.deps/ethereal.P .deps/ethertype.P .deps/file.P .deps/filter.P \
.deps/follow.P .deps/gtkpacket.P .deps/menu.P .deps/packet-aarp.P \
.deps/packet-arp.P .deps/packet-atalk.P .deps/packet-bootp.P \
.deps/packet-cdp.P .deps/packet-data.P .deps/packet-dns.P \
.deps/packet-eth.P .deps/packet-fddi.P .deps/packet-ftp.P \
.deps/packet-giop.P .deps/packet-gre.P .deps/packet-http.P \
.deps/packet-icmpv6.P .deps/packet-ip.P .deps/packet-ipsec.P \
.deps/packet-ipv6.P .deps/packet-ipx.P .deps/packet-isakmp.P \
.deps/packet-llc.P .deps/packet-lpd.P .deps/packet-nbipx.P \
.deps/packet-nbns.P .deps/packet-ncp.P .deps/packet-nntp.P \
.deps/packet-null.P .deps/packet-osi.P .deps/packet-ospf.P \
.deps/packet-pop.P .deps/packet-ppp.P .deps/packet-pppoe.P \
.deps/packet-pptp.P .deps/packet-raw.P .deps/packet-rip.P \
.deps/packet-rsvp.P .deps/packet-rtsp.P .deps/packet-sdp.P \
.deps/packet-smb.P .deps/packet-snmp.P .deps/packet-tcp.P \
.deps/packet-telnet.P .deps/packet-tftp.P .deps/packet-tr.P \
.deps/packet-trmac.P .deps/packet-udp.P .deps/packet-vines.P \
.deps/packet.P .deps/prefs.P .deps/print.P .deps/ps.P .deps/resolv.P \
.deps/snprintf.P .deps/strerror.P .deps/summary.P .deps/util.P
DEP_FILES = .deps/capture.P .deps/column.P .deps/dfilter-grammar.P \
.deps/dfilter.P .deps/display.P .deps/ethereal.P .deps/ethertype.P \
.deps/file.P .deps/filter.P .deps/follow.P .deps/gtkpacket.P \
.deps/menu.P .deps/packet-aarp.P .deps/packet-arp.P \
.deps/packet-atalk.P .deps/packet-bootp.P .deps/packet-cdp.P \
.deps/packet-data.P .deps/packet-dns.P .deps/packet-eth.P \
.deps/packet-fddi.P .deps/packet-ftp.P .deps/packet-giop.P \
.deps/packet-gre.P .deps/packet-http.P .deps/packet-icmpv6.P \
.deps/packet-ip.P .deps/packet-ipsec.P .deps/packet-ipv6.P \
.deps/packet-ipx.P .deps/packet-isakmp.P .deps/packet-llc.P \
.deps/packet-lpd.P .deps/packet-nbipx.P .deps/packet-nbns.P \
.deps/packet-ncp.P .deps/packet-nntp.P .deps/packet-null.P \
.deps/packet-osi.P .deps/packet-ospf.P .deps/packet-pop.P \
.deps/packet-ppp.P .deps/packet-pppoe.P .deps/packet-pptp.P \
.deps/packet-raw.P .deps/packet-rip.P .deps/packet-rsvp.P \
.deps/packet-rtsp.P .deps/packet-sdp.P .deps/packet-smb.P \
.deps/packet-snmp.P .deps/packet-tcp.P .deps/packet-telnet.P \
.deps/packet-tftp.P .deps/packet-tr.P .deps/packet-trmac.P \
.deps/packet-udp.P .deps/packet-vines.P .deps/packet.P .deps/prefs.P \
.deps/print.P .deps/proto.P .deps/ps.P .deps/resolv.P .deps/snprintf.P \
.deps/strerror.P .deps/summary.P .deps/util.P
SOURCES = $(ethereal_SOURCES) $(EXTRA_ethereal_SOURCES)
OBJECTS = $(ethereal_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
.SUFFIXES: .S .c .o .s .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
@ -225,8 +230,8 @@ install-binPROGRAMS: $(bin_PROGRAMS)
$(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)/'`; \
echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
@ -255,6 +260,13 @@ maintainer-clean-compile:
ethereal: $(ethereal_OBJECTS) $(ethereal_DEPENDENCIES)
@rm -f ethereal
$(LINK) $(ethereal_LDFLAGS) $(ethereal_OBJECTS) $(ethereal_LDADD) $(LIBS)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
dfilter-grammar.h: dfilter-grammar.c
install-man1:
$(mkinstalldirs) $(DESTDIR)$(man1dir)
@ -450,7 +462,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 \
@ -524,7 +536,7 @@ uninstall: uninstall-recursive
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) config.h
all-redirect: all-recursive-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs: installdirs-recursive
installdirs-am:
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 \
@ -541,6 +553,7 @@ distclean-generic:
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
-test -z "dfilter-grammarhdfilter-grammarc" || rm -f dfilter-grammarh dfilter-grammarc
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-compile mostlyclean-tags mostlyclean-depend \
mostlyclean-generic

13
README
View File

@ -31,19 +31,6 @@ Ethereal is known to compile and run on the following systems:
It should run on other systems without too much trouble.
NOTE: the Makefile appears to depend on GNU "make"; it doesn't appear to
work with the "make" that comes with Solaris 7 nor the BSD "make".
In addition, wiretap (see below) requires "flex" - it cannot be built
with vanilla "lex" - and either "bison" or the Berkeley "yacc"; whilst
the "yacc" that comes with Solaris 7 has a "-p" flag to replace "yy" in
various variable names with a specified prefix, to allow multiple
yacc-built parsers in the same program, it doesn't replace "yy" in the
"y.tab.h" file, so the lexical analyzer has no clue that "yylval" has
been renamed to "wtap_lval". (What *were* they thinking?)
You must therefore install GNU "make", "flex", and either "bison" or
Berkeley "yacc" on systems that lack them.
Full installation instructions can be found in the INSTALL file.

View File

@ -10,5 +10,3 @@
#undef NEED_STRERROR_H
/* Define this to use the wiretap library */
#undef WITH_WIRETAP

4
aclocal.m4 vendored
View File

@ -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
@ -183,6 +183,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]

View File

@ -15,9 +15,6 @@
#undef NEED_STRERROR_H
/* Define this to use the wiretap library */
#undef WITH_WIRETAP
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H

271
configure vendored
View File

@ -17,9 +17,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)"
ac_help="$ac_help
--enable-ipv6 use ipv6 name resolution, if available. [default=yes]"
ac_help="$ac_help
@ -566,7 +563,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:570: checking for a BSD compatible install" >&5
echo "configure:567: 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
@ -619,7 +616,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:623: checking whether build environment is sane" >&5
echo "configure:620: checking whether build environment is sane" >&5
# Just in case
sleep 1
echo timestamp > conftestfile
@ -676,7 +673,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:680: checking whether ${MAKE-make} sets \${MAKE}" >&5
echo "configure:677: 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
@ -703,6 +700,7 @@ else
fi
PACKAGE=ethereal
VERSION=0.6.3
@ -722,7 +720,7 @@ EOF
missing_dir=`cd $ac_aux_dir && pwd`
echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
echo "configure:726: checking for working aclocal" >&5
echo "configure:724: 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.
@ -735,7 +733,7 @@ else
fi
echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
echo "configure:739: checking for working autoconf" >&5
echo "configure:737: 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.
@ -748,7 +746,7 @@ else
fi
echo $ac_n "checking for working automake""... $ac_c" 1>&6
echo "configure:752: checking for working automake" >&5
echo "configure:750: 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.
@ -761,7 +759,7 @@ else
fi
echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
echo "configure:765: checking for working autoheader" >&5
echo "configure:763: 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.
@ -774,7 +772,7 @@ else
fi
echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
echo "configure:778: checking for working makeinfo" >&5
echo "configure:776: 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 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:799: checking host system type" >&5
echo "configure:797: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@ -819,7 +817,7 @@ echo "$ac_t""$host" 1>&6
# 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:823: checking for $ac_word" >&5
echo "configure:821: 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
@ -849,7 +847,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:853: checking for $ac_word" >&5
echo "configure:851: 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
@ -900,7 +898,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:904: checking for $ac_word" >&5
echo "configure:902: 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
@ -932,7 +930,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:936: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
echo "configure:934: 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.
@ -943,12 +941,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 947 "configure"
#line 945 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:950: \"$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
@ -974,12 +972,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:978: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:976: 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:983: checking whether we are using GNU C" >&5
echo "configure:981: 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
@ -988,7 +986,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:992: \"$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:990: \"$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
@ -1007,7 +1005,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:1011: checking whether ${CC-cc} accepts -g" >&5
echo "configure:1009: 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
@ -1041,7 +1039,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:1045: checking for $ac_word" >&5
echo "configure:1043: 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
@ -1068,10 +1066,45 @@ else
echo "$ac_t""no" 1>&6
fi
for ac_prog in 'bison -y' byacc
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:1075: 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
if test -n "$YACC"; then
ac_cv_prog_YACC="$YACC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_YACC="$ac_prog"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
YACC="$ac_cv_prog_YACC"
if test -n "$YACC"; then
echo "$ac_t""$YACC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
test -n "$YACC" && break
done
test -n "$YACC" || YACC="yacc"
# 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:1075: checking to see if we can add '-Wall' to CFLAGS" >&5
echo "configure:1108: 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
@ -1079,6 +1112,8 @@ else
echo "$ac_t""no" 1>&6
fi
CFLAGS="$CFLAGS -Iwiretap"
# Create DATAFILE_DIR #define for config.h
DATAFILE_DIR=$sysconfdir
DATAFILE_DIR=`(
@ -1097,7 +1132,7 @@ EOF
case "$host_os" in
solaris*)
echo $ac_n "checking for LD_LIBRARY_PATH""... $ac_c" 1>&6
echo "configure:1101: checking for LD_LIBRARY_PATH" >&5
echo "configure:1136: checking for LD_LIBRARY_PATH" >&5
if test x$LD_LIBRARY_PATH != x ; then
LIBS="$LIBS -R$LD_LIBRARY_PATH"
echo "$ac_t""yes -- added LD_LIBRARY_PATH to run-time linker path" 1>&6
@ -1158,7 +1193,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:1162: checking for $ac_word" >&5
echo "configure:1197: 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
@ -1191,9 +1226,9 @@ else
echo "$ac_t""no" 1>&6
fi
min_gtk_version=1.0.0
min_gtk_version=1.2.0
echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6
echo "configure:1197: checking for GTK - version >= $min_gtk_version" >&5
echo "configure:1232: checking for GTK - version >= $min_gtk_version" >&5
no_gtk=""
if test "$GTK_CONFIG" = "no" ; then
no_gtk=yes
@ -1216,7 +1251,7 @@ echo "configure:1197: checking for GTK - version >= $min_gtk_version" >&5
echo $ac_n "cross compiling; assumed OK... $ac_c"
else
cat > conftest.$ac_ext <<EOF
#line 1220 "configure"
#line 1255 "configure"
#include "confdefs.h"
#include <gtk/gtk.h>
@ -1294,7 +1329,7 @@ main ()
}
EOF
if { (eval echo configure:1298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@ -1328,7 +1363,7 @@ fi
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
cat > conftest.$ac_ext <<EOF
#line 1332 "configure"
#line 1367 "configure"
#include "confdefs.h"
#include <gtk/gtk.h>
@ -1338,7 +1373,7 @@ int main() {
return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version));
; return 0; }
EOF
if { (eval echo configure:1342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1377: \"$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"
@ -1379,7 +1414,7 @@ rm -f conftest*
# Evidently, some systems have pcap.h, etc. in */include/pcap
echo $ac_n "checking for extraneous pcap header directories""... $ac_c" 1>&6
echo "configure:1383: checking for extraneous pcap header directories" >&5
echo "configure:1418: checking for extraneous pcap header directories" >&5
found_pcap_dir=""
for pcap_dir in /usr/include/pcap /usr/local/include/pcap
do
@ -1399,7 +1434,7 @@ fi
# Pcap checks
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1403: checking how to run the C preprocessor" >&5
echo "configure:1438: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1414,13 +1449,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 1418 "configure"
#line 1453 "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:1424: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1459: \"$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
:
@ -1431,13 +1466,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1435 "configure"
#line 1470 "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:1441: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1476: \"$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
:
@ -1448,13 +1483,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 1452 "configure"
#line 1487 "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:1458: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1493: \"$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
:
@ -1480,17 +1515,17 @@ echo "$ac_t""$CPP" 1>&6
ac_safe=`echo "net/bpf.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for net/bpf.h""... $ac_c" 1>&6
echo "configure:1484: checking for net/bpf.h" >&5
echo "configure:1519: checking for net/bpf.h" >&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 1489 "configure"
#line 1524 "configure"
#include "confdefs.h"
#include <net/bpf.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1494: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1529: \"$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*
@ -1514,17 +1549,17 @@ fi
ac_safe=`echo "pcap.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for pcap.h""... $ac_c" 1>&6
echo "configure:1518: checking for pcap.h" >&5
echo "configure:1553: checking for pcap.h" >&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 1523 "configure"
#line 1558 "configure"
#include "confdefs.h"
#include <pcap.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1528: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1563: \"$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*
@ -1547,7 +1582,7 @@ else
fi
echo $ac_n "checking for pcap_open_offline in -lpcap""... $ac_c" 1>&6
echo "configure:1551: checking for pcap_open_offline in -lpcap" >&5
echo "configure:1586: checking for pcap_open_offline in -lpcap" >&5
ac_lib_var=`echo pcap'_'pcap_open_offline | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1555,7 +1590,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1559 "configure"
#line 1594 "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
@ -1566,7 +1601,7 @@ int main() {
pcap_open_offline()
; return 0; }
EOF
if { (eval echo configure:1570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1605: \"$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
@ -1595,38 +1630,6 @@ else
fi
# Wiretap check
echo $ac_n "checking whether to include wiretap library""... $ac_c" 1>&6
echo "configure:1601: 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
cat >> confdefs.h <<\EOF
#define WITH_WIRETAP 1
EOF
WIRETAP_DIR="wiretap"
if test x$WIRETAP_DIR != x ; then
CFLAGS="$CFLAGS -Iwiretap"
LIBWIRETAP_A="wiretap/libwiretap.a"
SUBDIRS="$SUBDIRS wiretap"
fi
;;
*)
echo "$ac_t""no" 1>&6
LIBWIRETAP_A=""
WIRETAP_DIR=""
;;
esac
else
echo "$ac_t""no" 1>&6
fi
# Check whether --enable-ipv6 or --disable-ipv6 was given.
@ -1639,7 +1642,7 @@ fi
echo $ac_n "checking whether to enable ipv6 name resolution if available""... $ac_c" 1>&6
echo "configure:1643: checking whether to enable ipv6 name resolution if available" >&5
echo "configure:1646: checking whether to enable ipv6 name resolution if available" >&5
if test "x$enable_ipv6" = "xno" ; then
echo "$ac_t""no" 1>&6
else
@ -1649,12 +1652,12 @@ else
v6lib=none
echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6
echo "configure:1653: checking ipv6 stack type" >&5
echo "configure:1656: checking ipv6 stack type" >&5
for i in v6d toshiba kame inria zeta linux; do
case $i in
v6d)
cat > conftest.$ac_ext <<EOF
#line 1658 "configure"
#line 1661 "configure"
#include "confdefs.h"
dnl
#include </usr/local/v6/include/sys/types.h>
@ -1674,7 +1677,7 @@ rm -f conftest*
;;
toshiba)
cat > conftest.$ac_ext <<EOF
#line 1678 "configure"
#line 1681 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@ -1694,7 +1697,7 @@ rm -f conftest*
;;
kame)
cat > conftest.$ac_ext <<EOF
#line 1698 "configure"
#line 1701 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@ -1714,7 +1717,7 @@ rm -f conftest*
;;
inria)
cat > conftest.$ac_ext <<EOF
#line 1718 "configure"
#line 1721 "configure"
#include "confdefs.h"
dnl
#include <netinet/in.h>
@ -1732,7 +1735,7 @@ rm -f conftest*
;;
zeta)
cat > conftest.$ac_ext <<EOF
#line 1736 "configure"
#line 1739 "configure"
#include "confdefs.h"
dnl
#include <sys/param.h>
@ -1781,12 +1784,12 @@ fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:1785: checking for ANSI C header files" >&5
echo "configure:1788: 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 1790 "configure"
#line 1793 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -1794,7 +1797,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1798: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1801: \"$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*
@ -1811,7 +1814,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 1815 "configure"
#line 1818 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -1829,7 +1832,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 1833 "configure"
#line 1836 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -1850,7 +1853,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 1854 "configure"
#line 1857 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -1861,7 +1864,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@ -1888,17 +1891,17 @@ for ac_hdr in fcntl.h sys/ioctl.h sys/time.h unistd.h stdarg.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1892: checking for $ac_hdr" >&5
echo "configure:1895: 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 1897 "configure"
#line 1900 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1905: \"$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*
@ -1929,17 +1932,17 @@ for ac_hdr in sys/sockio.h sys/types.h netinet/in.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1933: checking for $ac_hdr" >&5
echo "configure:1936: 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 1938 "configure"
#line 1941 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1946: \"$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*
@ -1979,7 +1982,7 @@ fi
SNMP_A=''
SNMP_O=''
echo $ac_n "checking whether to use SNMP library if available""... $ac_c" 1>&6
echo "configure:1983: checking whether to use SNMP library if available" >&5
echo "configure:1986: checking whether to use SNMP library if available" >&5
if test "x$enable_snmp" = "xno" ; then
echo "$ac_t""no" 1>&6
else
@ -1988,17 +1991,17 @@ else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1992: checking for $ac_hdr" >&5
echo "configure:1995: 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 1997 "configure"
#line 2000 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2002: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2005: \"$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*
@ -2025,7 +2028,7 @@ fi
done
echo $ac_n "checking for asn_parse_header in -lsnmp""... $ac_c" 1>&6
echo "configure:2029: checking for asn_parse_header in -lsnmp" >&5
echo "configure:2032: checking for asn_parse_header in -lsnmp" >&5
ac_lib_var=`echo snmp'_'asn_parse_header | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -2033,7 +2036,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsnmp $LIBS"
cat > conftest.$ac_ext <<EOF
#line 2037 "configure"
#line 2040 "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
@ -2044,7 +2047,7 @@ int main() {
asn_parse_header()
; return 0; }
EOF
if { (eval echo configure:2048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2051: \"$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
@ -2077,12 +2080,12 @@ fi
# for get_interface_list().
echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
echo "configure:2081: checking for sa_len in struct sockaddr" >&5
echo "configure:2084: checking for sa_len in struct sockaddr" >&5
if eval "test \"`echo '$''{'ac_cv_ethereal_struct_sa_len'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2086 "configure"
#line 2089 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@ -2090,7 +2093,7 @@ int main() {
struct sockaddr s; s.sa_len;
; return 0; }
EOF
if { (eval echo configure:2094: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2097: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_ethereal_struct_sa_len=yes
else
@ -2113,14 +2116,14 @@ fi
# We must know our byte order
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
echo "configure:2117: checking whether byte ordering is bigendian" >&5
echo "configure:2120: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
#line 2124 "configure"
#line 2127 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@ -2131,11 +2134,11 @@ int main() {
#endif
; return 0; }
EOF
if { (eval echo configure:2135: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2138: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
#line 2139 "configure"
#line 2142 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@ -2146,7 +2149,7 @@ int main() {
#endif
; return 0; }
EOF
if { (eval echo configure:2150: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2153: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@ -2166,7 +2169,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
#line 2170 "configure"
#line 2173 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@ -2179,7 +2182,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
if { (eval echo configure:2183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@ -2205,13 +2208,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
echo "configure:2209: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:2212: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
#line 2215 "configure"
#line 2218 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -2229,7 +2232,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 2233 "configure"
#line 2236 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -2251,12 +2254,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
fi
echo $ac_n "checking for socket""... $ac_c" 1>&6
echo "configure:2255: checking for socket" >&5
echo "configure:2258: checking for socket" >&5
if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2260 "configure"
#line 2263 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char socket(); below. */
@ -2279,7 +2282,7 @@ socket();
; return 0; }
EOF
if { (eval echo configure:2283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_socket=yes"
else
@ -2305,12 +2308,12 @@ fi
SNPRINTF_C=""
SNPRINTF_O=""
echo $ac_n "checking for snprintf""... $ac_c" 1>&6
echo "configure:2309: checking for snprintf" >&5
echo "configure:2312: checking for snprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2314 "configure"
#line 2317 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char snprintf(); below. */
@ -2333,7 +2336,7 @@ snprintf();
; return 0; }
EOF
if { (eval echo configure:2337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_snprintf=yes"
else
@ -2364,12 +2367,12 @@ fi
echo $ac_n "checking for strerror""... $ac_c" 1>&6
echo "configure:2368: checking for strerror" >&5
echo "configure:2371: checking for strerror" >&5
if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2373 "configure"
#line 2376 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char strerror(); below. */
@ -2392,7 +2395,7 @@ strerror();
; return 0; }
EOF
if { (eval echo configure:2396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_strerror=yes"
else
@ -2425,10 +2428,8 @@ fi
if test x$WIRETAP_DIR != x ; then
subdirs="$WIRETAP_DIR"
subdirs="wiretap"
fi
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
@ -2580,12 +2581,12 @@ s%@host_vendor@%$host_vendor%g
s%@host_os@%$host_os%g
s%@CC@%$CC%g
s%@RANLIB@%$RANLIB%g
s%@YACC@%$YACC%g
s%@DATAFILE_DIR@%$DATAFILE_DIR%g
s%@GTK_CONFIG@%$GTK_CONFIG%g
s%@GTK_CFLAGS@%$GTK_CFLAGS%g
s%@GTK_LIBS@%$GTK_LIBS%g
s%@CPP@%$CPP%g
s%@LIBWIRETAP_A@%$LIBWIRETAP_A%g
s%@SUBDIRS@%$SUBDIRS%g
s%@SNMP_A@%$SNMP_A%g
s%@SNMP_O@%$SNMP_O%g
@ -2840,7 +2841,7 @@ if test "$no_recursion" != yes; then
esac
done
for ac_config_dir in $WIRETAP_DIR; do
for ac_config_dir in wiretap; do
# Do not complain, so a configure script can configure whichever
# parts of a large source tree are present.

View File

@ -1,4 +1,4 @@
# $Id: configure.in,v 1.27 1999/06/24 16:25:58 gram Exp $
# $Id: configure.in,v 1.28 1999/07/07 22:51:36 gram Exp $
dnl Process this file with autoconf to produce a configure script.
AC_INIT(etypes.h)
@ -10,6 +10,7 @@ AC_CANONICAL_HOST
dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_YACC
# If we're running gcc, add '-Wall' to CFLAGS.
AC_MSG_CHECKING(to see if we can add '-Wall' to CFLAGS)
@ -20,6 +21,8 @@ else
AC_MSG_RESULT(no)
fi
CFLAGS="$CFLAGS -Iwiretap"
# Create DATAFILE_DIR #define for config.h
DATAFILE_DIR=$sysconfdir
DATAFILE_DIR=`(
@ -45,7 +48,7 @@ case "$host_os" in
esac
# GTK checks
AM_PATH_GTK(1.0.0, CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS",
AM_PATH_GTK(1.2.0, CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS",
AC_MSG_ERROR(GTK+ distribution not found.))
# Evidently, some systems have pcap.h, etc. in */include/pcap
@ -72,31 +75,6 @@ AC_CHECK_HEADER(net/bpf.h,, AC_MSG_ERROR(Header file net/bpf.h not found.))
AC_CHECK_HEADER(pcap.h,, AC_MSG_ERROR(Header file pcap.h not found.))
AC_CHECK_LIB(pcap, pcap_open_offline,, AC_MSG_ERROR(Library libpcap not found.))
# Wiretap check
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)
AC_DEFINE(WITH_WIRETAP)
WIRETAP_DIR="wiretap"
if test x$WIRETAP_DIR != x ; then
CFLAGS="$CFLAGS -Iwiretap"
LIBWIRETAP_A="wiretap/libwiretap.a"
SUBDIRS="$SUBDIRS wiretap"
fi
;;
*)
AC_MSG_RESULT(no)
LIBWIRETAP_A=""
WIRETAP_DIR=""
;;
esac ],
AC_MSG_RESULT(no)
)
AC_SUBST(LIBWIRETAP_A)
AC_SUBST(SUBDIRS)
dnl ipv6 check
@ -178,7 +156,5 @@ AC_SUBST(STRERROR_C)
AC_SUBST(STRERROR_O)
AM_CONFIG_HEADER(config.h)
if test x$WIRETAP_DIR != x ; then
AC_CONFIG_SUBDIRS($WIRETAP_DIR)
fi
AC_CONFIG_SUBDIRS(wiretap)
AC_OUTPUT(Makefile)

640
dfilter-grammar.y Normal file
View File

@ -0,0 +1,640 @@
%{
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifndef __GLIB_H__
#include <glib.h>
#endif
#include <string.h> /* during testing */
#ifndef _STDLIB_H
#include <stdlib.h>
#endif
#ifndef __PROTO_H__
#include "proto.h"
#endif
#ifndef __PACKET_H__
#include "packet.h"
#endif
#ifndef __DFILTER_H__
#include "dfilter.h"
#endif
#ifndef __RESOLV_H__
#include "resolv.h"
#endif
void dfilter_yacc_init(void);
static void dfilter_print_parse_tree(GNode *gnode);
static GNode* dfilter_mknode_join(GNode *n1, enum node_type ntype, int operand, GNode *n2);
static GNode* dfilter_mknode_unary(int operand, GNode *n2);
static GNode* dfilter_mknode_numeric_variable(gint id);
static GNode* dfilter_mknode_numeric_value(guint32 val);
static GNode* dfilter_mknode_ether_value(char *a, char *b, char *c, char *d, char *e, char *f);
static GNode* dfilter_mknode_ether_variable(gint id);
static GNode* dfilter_mknode_ipv4_value(char *host);
static GNode* dfilter_mknode_ipv4_variable(gint id);
static GNode* dfilter_mknode_existence(gint id);
static GNode* dfilter_mknode_bytes_value(GByteArray *barray);
static GNode* dfilter_mknode_bytes_variable(gint id, gint offset, gint length);
static GNode* dfilter_mknode_boolean_value(gint truth_value);
static GNode* dfilter_mknode_boolean_variable(gint id);
static guint32 string_to_value(char *s);
/* space for dfilter_nodes */
GMemChunk *gmc_dfilter_nodes = NULL;
/* this is how we pass display filter tree (dfcode) back to calling routine */
GNode *dfilter_tree = NULL;
/* list of byte arrays we allocate during parse. We can traverse this list
* faster than the tree when we go back and free the byte arrays */
GSList *dfilter_list_byte_arrays = NULL;
%}
%union {
gint operand; /* logical, relation, alternation */
gint variable;
GNode* node;
gchar* id;
GByteArray* bytes;
}
%type <node> statement expression relation
%type <node> numeric_value numeric_variable
%type <node> ether_value ether_variable
%type <node> ipv4_value ipv4_variable
%type <node> protocol_name
%type <node> bytes_value bytes_variable
%type <node> boolean_value boolean_variable
%type <operand> numeric_relation
%type <operand> ether_relation
%type <operand> bytes_relation
%type <operand> boolean_relation
%type <bytes> byte_range
%type <variable> any_variable_type
%type <operand> exists_operand
%token <variable> T_FT_UINT8
%token <variable> T_FT_UINT16
%token <variable> T_FT_UINT32
%token <variable> T_FT_ETHER
%token <variable> T_FT_IPv4
%token <variable> T_FT_NONE
%token <variable> T_FT_BYTES
%token <variable> T_FT_BOOLEAN
%token <variable> T_FT_STRING
%token <id> T_VAL_ID
%token <operand> TOK_AND TOK_OR TOK_NOT TOK_XOR
%token <operand> TOK_EQ TOK_NE TOK_GT TOK_GE TOK_LT TOK_LE
%token <operand> TOK_EXIST TOK_EXISTS
%token <operand> TOK_TRUE TOK_FALSE
%type <operand> type_eq
%type <operand> type_ne
%type <operand> type_gt
%type <operand> type_ge
%type <operand> type_lt
%type <operand> type_le
%left TOK_AND
%left TOK_OR
%left TOK_XOR
%nonassoc TOK_NOT
%%
statement: expression
{
dfilter_tree = $1;
}
| /* NULL */ { dfilter_tree = NULL; }
;
expression: '(' expression ')' { $$ = $2; }
| expression TOK_AND expression { $$ = dfilter_mknode_join($1, logical, $2, $3); }
| expression TOK_OR expression { $$ = dfilter_mknode_join($1, logical, $2, $3); }
| TOK_NOT expression { $$ = dfilter_mknode_unary(TOK_NOT, $2); }
| relation { $$ = $1; }
| protocol_name { $$ = $1; }
;
relation: numeric_variable numeric_relation numeric_value
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| numeric_value numeric_relation numeric_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| numeric_variable numeric_relation numeric_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ether_variable ether_relation ether_value
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ether_value ether_relation ether_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ether_variable ether_relation ether_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ipv4_variable numeric_relation ipv4_value
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ipv4_value numeric_relation ipv4_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| ipv4_variable numeric_relation ipv4_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| bytes_variable bytes_relation bytes_value
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| bytes_value bytes_relation bytes_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| bytes_variable bytes_relation bytes_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| boolean_variable boolean_relation boolean_value
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| boolean_value boolean_relation boolean_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| boolean_variable boolean_relation boolean_variable
{
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
| exists_operand any_variable_type { $$ = dfilter_mknode_existence($2); }
;
numeric_value: T_VAL_ID { $$ = dfilter_mknode_numeric_value(string_to_value($1)); }
;
ether_value: T_VAL_ID ':' T_VAL_ID ':' T_VAL_ID ':' T_VAL_ID ':' T_VAL_ID ':' T_VAL_ID
{
$$ = dfilter_mknode_ether_value($1, $3, $5, $7, $9, $11);
g_free($1);
g_free($3);
g_free($5);
g_free($7);
g_free($9);
g_free($11);
}
;
ipv4_value: T_VAL_ID { $$ = dfilter_mknode_ipv4_value($1); }
;
bytes_value: numeric_variable
| byte_range { $$ = dfilter_mknode_bytes_value($1); }
;
byte_range: T_VAL_ID ':' T_VAL_ID
{
GByteArray *barray = g_byte_array_new();
guint8 val;
char *endptr;
dfilter_list_byte_arrays = g_slist_append(dfilter_list_byte_arrays, barray);
val = (guint8) strtoul($1, &endptr, 16);
g_byte_array_append(barray, &val, 1);
val = (guint8) strtoul($3, &endptr, 16);
$$ = g_byte_array_append(barray, &val, 1);
}
| byte_range ':' T_VAL_ID
{
guint8 val;
char *endptr;
val = (guint8) strtoul($3, &endptr, 16);
$$ = g_byte_array_append($1, &val, 1);
}
;
boolean_value: TOK_TRUE { $$ = dfilter_mknode_boolean_value($1); }
| TOK_FALSE { $$ = dfilter_mknode_boolean_value($1); }
;
numeric_variable: T_FT_UINT8 { $$ = dfilter_mknode_numeric_variable($1); }
| T_FT_UINT16 { $$ = dfilter_mknode_numeric_variable($1); }
| T_FT_UINT32 { $$ = dfilter_mknode_numeric_variable($1); }
;
ether_variable: T_FT_ETHER { $$ = dfilter_mknode_ether_variable($1); }
;
ipv4_variable: T_FT_IPv4 { $$ = dfilter_mknode_ipv4_variable($1); }
;
protocol_name: T_FT_NONE { $$ = dfilter_mknode_existence($1); }
;
bytes_variable: any_variable_type '[' T_VAL_ID ':' T_VAL_ID ']'
{
$$ = dfilter_mknode_bytes_variable($1, string_to_value($3), string_to_value($5));
}
| any_variable_type '[' T_VAL_ID ']'
{
$$ = dfilter_mknode_bytes_variable($1, string_to_value($3), 0);
}
;
boolean_variable: T_FT_BOOLEAN { $$ = dfilter_mknode_boolean_variable($1); }
;
any_variable_type: T_FT_UINT8 { $$ = $1; }
| T_FT_UINT16 { $$ = $1; }
| T_FT_UINT32 { $$ = $1; }
| T_FT_ETHER { $$ = $1; }
| T_FT_IPv4 { $$ = $1; }
| T_FT_NONE { $$ = $1; }
| T_FT_BYTES { $$ = $1; }
| T_FT_BOOLEAN { $$ = $1; }
| T_FT_STRING { $$ = $1; }
;
numeric_relation: type_eq { $$ = $1; }
| type_ne { $$ = $1; }
| type_gt { $$ = $1; }
| type_ge { $$ = $1; }
| type_lt { $$ = $1; }
| type_le { $$ = $1; }
;
ether_relation: type_eq { $$ = $1; }
| type_ne { $$ = $1; }
;
bytes_relation: type_eq { $$ = $1; }
| type_ne { $$ = $1; }
| type_gt { $$ = $1; }
| type_lt { $$ = $1; }
;
boolean_relation: type_eq { $$ = $1; }
| type_ne { $$ = $1; }
;
exists_operand: TOK_EXIST { $$ = $1; }
| TOK_EXISTS { $$ = $1; }
| '?' { $$ = TOK_EXIST; }
;
type_eq: TOK_EQ { $$ = $1; }
| '=' '=' { $$ = TOK_EQ; }
;
type_ne: TOK_NE { $$ = $1; }
| '!' '=' { $$ = TOK_NE; }
;
type_gt: TOK_GT { $$ = $1; }
| '>' { $$ = TOK_GT; }
;
type_ge: TOK_GE { $$ = $1; }
| '>' '=' { $$ = TOK_GE; }
;
type_lt: TOK_LT { $$ = $1; }
| '<' { $$ = TOK_LT; }
;
type_le: TOK_LE { $$ = $1; }
| '<' '=' { $$ = TOK_LE; }
;
%%
void
dfilter_yacc_init(void)
{
if (gmc_dfilter_nodes)
g_mem_chunk_destroy(gmc_dfilter_nodes);
gmc_dfilter_nodes = g_mem_chunk_new("gmc_dfilter_nodes",
sizeof(dfilter_node), 50 * sizeof(dfilter_node),
G_ALLOC_ONLY);
if (dfilter_list_byte_arrays) {
/* clear the byte arrays */
g_slist_free(dfilter_list_byte_arrays);
}
}
void
dfilter_yacc_cleanup(void)
{
if (gmc_dfilter_nodes)
g_mem_chunk_destroy(gmc_dfilter_nodes);
}
static GNode*
dfilter_mknode_join(GNode *n1, enum node_type ntype, int operand, GNode *n2)
{
dfilter_node *node_root;
GNode *gnode_root;
node_root = g_mem_chunk_alloc(gmc_dfilter_nodes);
node_root->ntype = ntype;
node_root->elem_size = 0;
node_root->fill_array_func = NULL;
node_root->check_relation_func = NULL;
if (ntype == relation) {
node_root->value.relation = operand;
}
else if (ntype == logical) {
node_root->value.logical = operand;
}
else {
g_assert_not_reached();
}
gnode_root = g_node_new(node_root);
g_node_append(gnode_root, n1);
g_node_append(gnode_root, n2);
return gnode_root;
}
static GNode*
dfilter_mknode_unary(int operand, GNode *n2)
{
dfilter_node *node_root;
GNode *gnode_root;
node_root = g_mem_chunk_alloc(gmc_dfilter_nodes);
node_root->ntype = logical;
node_root->value.logical = operand;
node_root->elem_size = 0;
node_root->fill_array_func = NULL;
node_root->check_relation_func = NULL;
gnode_root = g_node_new(node_root);
g_node_append(gnode_root, n2);
return gnode_root;
}
static GNode*
dfilter_mknode_numeric_variable(gint id)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = variable;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_numeric_variable;
node->check_relation_func = check_relation_numeric;
node->value.variable = id;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_ether_variable(gint id)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = variable;
node->elem_size = sizeof(guint8) * 6;
node->fill_array_func = fill_array_ether_variable;
node->check_relation_func = check_relation_ether;
node->value.variable = id;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_ipv4_variable(gint id)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = variable;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_numeric_variable; /* cheating ! */
node->check_relation_func = check_relation_numeric; /* cheating ! */
node->value.variable = id;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_bytes_variable(gint id, gint offset, gint length)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = variable;
/*node->elem_size = length * sizeof(guint8);*/
node->elem_size = sizeof(GByteArray*);
node->fill_array_func = fill_array_bytes_variable;
node->check_relation_func = check_relation_bytes;
node->value.variable = id;
node->offset = offset;
node->length = length;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_boolean_variable(gint id)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = variable;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_boolean_variable; /* cheating ! */
node->check_relation_func = check_relation_boolean; /* cheating ! */
node->value.variable = id;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_numeric_value(guint32 val)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = numeric;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_numeric_value;
node->check_relation_func = check_relation_numeric;
node->value.numeric = val;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_ether_value(char *a, char *b, char *c, char *d, char *e, char *f)
{
dfilter_node *node;
GNode *gnode;
char *endptr;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = ether;
node->elem_size = sizeof(guint8) * 6;
node->fill_array_func = fill_array_ether_value;
node->check_relation_func = check_relation_ether;
node->value.ether[0] = (guint8) strtoul(a, &endptr, 16);
node->value.ether[1] = (guint8) strtoul(b, &endptr, 16);
node->value.ether[2] = (guint8) strtoul(c, &endptr, 16);
node->value.ether[3] = (guint8) strtoul(d, &endptr, 16);
node->value.ether[4] = (guint8) strtoul(e, &endptr, 16);
node->value.ether[5] = (guint8) strtoul(f, &endptr, 16);
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_ipv4_value(char *host)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = numeric;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_numeric_value; /* cheating ! */
node->check_relation_func = check_relation_numeric; /* cheating ! */
node->value.numeric = get_host_ipaddr(host);
node->value.numeric = htonl(node->value.numeric);
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_bytes_value(GByteArray *barray)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = bytes;
/*node->elem_size = barray->len * sizeof(guint8);*/
node->elem_size = sizeof(GByteArray*);
node->fill_array_func = fill_array_bytes_value;
node->check_relation_func = check_relation_bytes;
node->value.bytes = barray;
node->offset = G_MAXINT;
node->length = barray->len;
gnode = g_node_new(node);
return gnode;
}
static GNode*
dfilter_mknode_boolean_value(gint truth_value)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = numeric;
node->elem_size = sizeof(guint32);
node->fill_array_func = fill_array_boolean_value;
node->check_relation_func = check_relation_boolean;
node->value.boolean = truth_value == TOK_TRUE ? TRUE : FALSE;
gnode = g_node_new(node);
return gnode;
}
static guint32
string_to_value(char *s)
{
char *endptr;
guint32 val;
val = strtoul(s, &endptr, 0);
/* I should probably check errno here */
return (guint32)val;
}
static GNode*
dfilter_mknode_existence(gint id)
{
dfilter_node *node;
GNode *gnode;
node = g_mem_chunk_alloc(gmc_dfilter_nodes);
node->ntype = existence;
node->elem_size = sizeof(guint32);
node->fill_array_func = NULL;
node->check_relation_func = NULL;
node->value.variable = id;
gnode = g_node_new(node);
return gnode;
}

806
dfilter.c Normal file
View File

@ -0,0 +1,806 @@
/* dfilter.c
* Routines for display filters
*
* $Id: dfilter.c,v 1.1 1999/07/07 22:51:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifndef _STDIO_H
#include <stdio.h>
#endif
#ifndef _STRING_H
#include <string.h>
#endif
#ifndef __G_LIB_H__
#include <glib.h>
#endif
#ifndef __PROTO_H__
#include "proto.h"
#endif
#ifndef __DFILTER_H__
#include "dfilter.h"
#endif
#include "dfilter-grammar.h"
int yyparse(void); /* yacc entry-point */
#define DFILTER_LEX_SYMBOL_OFFSET 1000
#define DFILTER_LEX_ABBREV_OFFSET 2000
#define DFILTER_LEX_SCOPE_ANY 0
GScanner *scanner;
/* Silly global variables used to pass parameter to check_relation_bytes() */
int bytes_offset = 0;
int bytes_length = 0;
YYSTYPE yylval;
/* in dfilter-grammar.y */
extern GMemChunk *gmc_dfilter_nodes;
extern GNode *dfilter_tree;
extern GSList *dfilter_list_byte_arrays;
static gboolean dfilter_apply_node(GNode *gnode, proto_tree *ptree, guint8 *pd);
static gboolean check_relation(gint operand, GNode *a, GNode *b, proto_tree *ptree, guint8 *pd);
static gboolean check_logical(gint operand, GNode *a, GNode *b, proto_tree *ptree, guint8 *pd);
static GArray* get_values_from_ptree(dfilter_node *dnode, proto_tree *ptree, guint8 *pd);
static GArray* get_values_from_dfilter(dfilter_node *dnode, GNode *gnode);
static gboolean check_existence_in_ptree(dfilter_node *dnode, proto_tree *ptree);
static void clear_byte_array(gpointer data, gpointer user_data);
/* this is not so pretty. I need my own g_array "function" (macro) to
* retreive the pointer to the data stored in an array cell. I need this
* for type ether.. GArray makes it easy for me to store 6 bytes inside an array
* cell, but hard to retrieve it.
*/
#define g_array_index_ptr(a,s,i) (((guint8*) (a)->data) + (i*s))
static const GScannerConfig dfilter_scanner_config =
{
(
" \t\n"
) /* cset_skip_characters */,
/* I wish I didn't have to start strings with numeric
digits, but if I don't, strings like MAC and IPv4
addresses get really hard to handle */
(
G_CSET_a_2_z
"_0123456789"
G_CSET_A_2_Z
) /* cset_identifier_first */,
(
G_CSET_a_2_z
".-_0123456789"
G_CSET_A_2_Z
) /* cset_identifier_nth */,
( "#\n" ) /* cpair_comment_single */,
FALSE /* case_sensitive */,
FALSE /* skip_comment_multi */,
FALSE /* skip_comment_single */,
TRUE /* scan_comment_multi */,
TRUE /* scan_identifier */,
TRUE /* scan_identifier_1char */,
FALSE /* scan_identifier_NULL */,
TRUE /* scan_symbols */,
TRUE /* scan_binary */,
TRUE /* scan_octal */,
TRUE /* scan_float */,
TRUE /* scan_hex */,
TRUE /* scan_hex_dollar */,
TRUE /* scan_string_sq */,
FALSE /* scan_string_dq */,
TRUE /* numbers_2_int */,
FALSE /* int_2_float */,
FALSE /* identifier_2_string */,
TRUE /* char_2_token */,
TRUE /* symbol_2_token */,
FALSE /* scope_0_fallback */,
};
typedef struct symtab_record {
int id;
char *token;
} symtab_record;
symtab_record operator_symtab[] = {
{ TOK_AND, "and" },
{ TOK_OR, "or" },
{ TOK_NOT, "not" },
{ TOK_XOR, "xor" },
{ TOK_EQ, "eq" },
{ TOK_NE, "ne" },
{ TOK_GT, "gt" },
{ TOK_GE, "ge" },
{ TOK_LT, "lt" },
{ TOK_LE, "le" },
{ TOK_EXIST, "exist" },
{ TOK_EXISTS, "exists" },
{ TOK_TRUE, "true" },
{ TOK_FALSE, "false" },
{ 0, NULL }
};
void
dfilter_init(void)
{
int num_symbols, i, symbol;
char *s;
symtab_record *symrec;
scanner = g_scanner_new(&dfilter_scanner_config);
scanner->input_name = "Ethereal Display Filter";
g_scanner_freeze_symbol_table(scanner);
/* Add the header field and protocol abbrevs to the symbol table */
num_symbols = proto_registrar_n();
for (i=0; i < num_symbols; i++) {
s = proto_registrar_get_abbrev(i);
if (s) {
symbol = DFILTER_LEX_ABBREV_OFFSET + i;
g_scanner_scope_add_symbol(scanner,
DFILTER_LEX_SCOPE_ANY, s, GINT_TO_POINTER(symbol));
}
}
/* Add the operators to the symbol table */
for (symrec=operator_symtab; symrec->token != NULL; symrec++) {
symbol = DFILTER_LEX_SYMBOL_OFFSET + symrec->id;
g_scanner_scope_add_symbol(scanner, DFILTER_LEX_SCOPE_ANY,
symrec->token, GINT_TO_POINTER(symbol));
}
g_scanner_thaw_symbol_table(scanner);
}
int
dfilter_compile(char *dfilter_text, GNode **p_dfcode)
{
int retval;
g_assert(dfilter_text != NULL);
g_scanner_input_text(scanner, dfilter_text, strlen(dfilter_text));
if (dfilter_tree) {
/* clear tree */
dfilter_tree = NULL;
}
g_mem_chunk_reset(gmc_dfilter_nodes);
if (dfilter_list_byte_arrays) {
g_slist_foreach(dfilter_list_byte_arrays, clear_byte_array, NULL);
g_slist_free(dfilter_list_byte_arrays);
dfilter_list_byte_arrays = NULL;
}
retval = yyparse();
*p_dfcode = dfilter_tree;
return retval;
}
static void
clear_byte_array(gpointer data, gpointer user_data)
{
GByteArray *barray = data;
g_byte_array_free(barray, TRUE);
}
int
yylex(void)
{
guint token;
if (g_scanner_peek_next_token(scanner) == G_TOKEN_EOF) {
return 0;
}
else {
token = g_scanner_get_next_token(scanner);
}
/* Set the yacc-defined tokens back to their yacc-defined values */
if (token >= DFILTER_LEX_SYMBOL_OFFSET && token <= DFILTER_LEX_ABBREV_OFFSET) {
token -= DFILTER_LEX_SYMBOL_OFFSET;
yylval.operand = token;
}
/* Handle our dynamically-created list of header field abbrevs */
else if (token >= DFILTER_LEX_ABBREV_OFFSET) {
yylval.variable = token;
switch (proto_registrar_get_ftype(token - DFILTER_LEX_ABBREV_OFFSET)) {
case FT_UINT8:
case FT_VALS_UINT8:
token = T_FT_UINT8;
break;
case FT_UINT16:
case FT_VALS_UINT16:
token = T_FT_UINT16;
break;
case FT_UINT32:
case FT_VALS_UINT32:
case FT_VALS_UINT24:
token = T_FT_UINT32;
break;
case FT_ETHER:
token = T_FT_ETHER;
break;
case FT_IPv4:
token = T_FT_IPv4;
break;
case FT_NONE:
token = T_FT_NONE;
break;
case FT_BYTES:
token = T_FT_BYTES;
break;
case FT_BOOLEAN:
token = T_FT_BOOLEAN;
break;
default:
token = 0;
break;
}
}
/* unidentified strings. that's how I make numbers come in! */
else if (token == G_TOKEN_IDENTIFIER || token == G_TOKEN_IDENTIFIER_NULL) {
token = T_VAL_ID;
yylval.id = g_strdup(scanner->value.v_identifier);
}
else {
printf("(unknown) token = %d\n", token);
}
return token;
}
void
yyerror(char *s)
{
fprintf(stderr, "%s\n", s);
}
void
dfilter_yyerror(char *fmt, ...)
{
dfilter_tree = NULL;
yyerror(fmt);
}
gboolean
dfilter_apply(GNode *dfcode, proto_tree *ptree, guint8* pd)
{
gboolean retval;
retval = dfilter_apply_node(dfcode, ptree, pd);
return retval;
}
static gboolean
dfilter_apply_node(GNode *gnode, proto_tree *ptree, guint8* pd)
{
GNode *gnode_a, *gnode_b;
dfilter_node *dnode = (dfilter_node*) (gnode->data);
/* We'll get 2 NULLs if we don't have children */
gnode_a = g_node_nth_child(gnode, 0);
gnode_b = g_node_nth_child(gnode, 1);
switch(dnode->ntype) {
case variable:
/* the only time we'll see a 'variable' at this point is if the display filter
* checks the value of a single field: "tr.sr", for example. Inside a relation,
* the relation code will retrieve the value of the variable
*/
g_assert(!gnode_a && !gnode_b);
g_assert_not_reached();
/*return check_single_variable(gnode, ptree, pd);*/
case logical:
return check_logical(dnode->value.logical, gnode_a, gnode_b, ptree, pd);
case relation:
g_assert(gnode_a && gnode_b);
return check_relation(dnode->value.relation, gnode_a, gnode_b, ptree, pd);
case alternation:
g_assert_not_reached();
/* not coded yet */
case numeric:
case ipv4:
case boolean:
case ether:
case ether_vendor:
case string:
case abs_time:
case bytes:
/* the only time we'll see these at this point is if the display filter
* is really wacky. Just return TRUE */
g_assert(!gnode_a && !gnode_b);
return TRUE;
case existence: /* checking the existence of a protocol or hf*/
g_assert(!gnode_a && !gnode_b);
return check_existence_in_ptree(dnode, ptree);
}
g_assert_not_reached();
return FALSE;
}
static gboolean
check_logical(gint operand, GNode *a, GNode *b, proto_tree *ptree, guint8 *pd)
{
switch(operand) {
case TOK_AND:
return (dfilter_apply_node(a, ptree, pd) && dfilter_apply_node(b, ptree, pd));
case TOK_OR:
return (dfilter_apply_node(a, ptree, pd) || dfilter_apply_node(b, ptree, pd));
case TOK_XOR:
return (dfilter_apply_node(a, ptree, pd) || dfilter_apply_node(b, ptree, pd));
case TOK_NOT:
return (!dfilter_apply_node(a, ptree, pd));
default:
g_assert_not_reached();
}
g_assert_not_reached();
return FALSE;
}
/* this is inefficient. I get arrays for both a and b that represent all the values present. That is,
* if a is bootp.option, e.g., i'll get an array showing all the bootp.option values in the protocol
* tree. Then I'll get an array for b, which more than likely is a single int, and then I'll compare
* them all. It makes my coding easier in the beginning, but I should change this to make it run
* faster.
*/
static gboolean
check_relation(gint operand, GNode *a, GNode *b, proto_tree *ptree, guint8* pd)
{
dfilter_node *node_a = (dfilter_node*) (a->data);
dfilter_node *node_b = (dfilter_node*) (b->data);
GArray *vals_a, *vals_b;
gboolean retval;
bytes_length = MIN(node_a->length, node_b->length);
bytes_offset = MIN(node_a->offset, node_b->offset);
if (node_a->ntype == variable)
vals_a = get_values_from_ptree(node_a, ptree, pd);
else
vals_a = get_values_from_dfilter(node_a, a);
if (node_b->ntype == variable)
vals_b = get_values_from_ptree(node_b, ptree, pd);
else
vals_b = get_values_from_dfilter(node_b, b);
retval = node_a->check_relation_func(operand, vals_a, vals_b);
g_array_free(vals_a, FALSE);
g_array_free(vals_b, FALSE);
return retval;
}
#if 0
static gboolean
check_single_variable(GNode *gnode, proto_tree *ptree, guint8* pd)
{
dfilter_node *node = (dfilter_node*) (gnode->data);
GArray *vals;
gboolean retval;
bytes_length = node->length;
bytes_offset = node->offset;
vals = get_values_from_ptree(node, ptree, pd);
retval = node_a->check_relation_func(operand, vals_a, vals_b);
g_array_free(vals, FALSE);
return retval;
}
#endif
static gboolean
check_existence_in_ptree(dfilter_node *dnode, proto_tree *ptree)
{
int target_field;
proto_tree *subtree;
target_field = dnode->value.variable - DFILTER_LEX_ABBREV_OFFSET;
/*subtree = proto_find_protocol(ptree, target_field);*/
subtree = proto_find_field(ptree, target_field);
if (subtree)
return TRUE;
else
return FALSE;
}
static GArray*
get_values_from_ptree(dfilter_node *dnode, proto_tree *ptree, guint8 *pd)
{
GArray *array;
int parent_protocol;
int target_field;
proto_tree *subtree = NULL; /* where the parent protocol's sub-tree starts */
proto_tree_search_info sinfo;
g_assert(dnode->elem_size > 0);
array = g_array_new(FALSE, FALSE, dnode->elem_size);
target_field = dnode->value.variable - DFILTER_LEX_ABBREV_OFFSET;
/* Find the proto_tree subtree where we should start searching.*/
if (proto_registrar_is_protocol(target_field)) {
subtree = proto_find_protocol(ptree, target_field);
}
else {
parent_protocol = proto_registrar_get_parent(target_field);
if (parent_protocol >= 0) {
subtree = proto_find_protocol(ptree, parent_protocol);
}
}
if (subtree) {
sinfo.target_field = target_field;
sinfo.result_array = array;
sinfo.packet_data = pd;
proto_get_field_values(subtree, dnode->fill_array_func, &sinfo);
}
return array;
}
static GArray*
get_values_from_dfilter(dfilter_node *dnode, GNode *gnode)
{
GArray *array;
g_assert(dnode->elem_size > 0);
array = g_array_new(FALSE, FALSE, dnode->elem_size);
g_node_traverse(gnode, G_IN_ORDER, G_TRAVERSE_ALL, -1, dnode->fill_array_func, array);
/* dnode->fill_array_func(gnode, array);*/
return array;
}
gboolean fill_array_numeric_variable(GNode *gnode, gpointer data)
{
proto_tree_search_info *sinfo = (proto_tree_search_info*)data;
field_info *fi = (field_info*) (gnode->data);
if (fi->hfinfo->id == sinfo->target_field) {
g_array_append_val(sinfo->result_array, fi->value.numeric);
}
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_ether_variable(GNode *gnode, gpointer data)
{
proto_tree_search_info *sinfo = (proto_tree_search_info*)data;
field_info *fi = (field_info*) (gnode->data);
if (fi->hfinfo->id == sinfo->target_field) {
g_array_append_val(sinfo->result_array, fi->value.ether);
}
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_bytes_variable(GNode *gnode, gpointer data)
{
proto_tree_search_info *sinfo = (proto_tree_search_info*)data;
field_info *fi = (field_info*) (gnode->data);
GByteArray *barray;
if (fi->hfinfo->id == sinfo->target_field) {
barray = g_byte_array_new();
/*dfilter_list_byte_arrays = g_slist_append(dfilter_list_byte_arrays, barray);*/
g_byte_array_append(barray, sinfo->packet_data + fi->start + bytes_offset, bytes_length);
g_array_append_val(sinfo->result_array, barray);
}
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_boolean_variable(GNode *gnode, gpointer data)
{
proto_tree_search_info *sinfo = (proto_tree_search_info*)data;
field_info *fi = (field_info*) (gnode->data);
if (fi->hfinfo->id == sinfo->target_field) {
g_array_append_val(sinfo->result_array, fi->value.boolean);
}
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_numeric_value(GNode *gnode, gpointer data)
{
GArray *array = (GArray*)data;
dfilter_node *dnode = (dfilter_node*) (gnode->data);
g_array_append_val(array, dnode->value.numeric);
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_ether_value(GNode *gnode, gpointer data)
{
GArray *array = (GArray*)data;
dfilter_node *dnode = (dfilter_node*) (gnode->data);
g_array_append_val(array, dnode->value.ether);
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_bytes_value(GNode *gnode, gpointer data)
{
GArray *array = (GArray*)data;
dfilter_node *dnode = (dfilter_node*) (gnode->data);
GByteArray *barray = dnode->value.bytes;
g_array_append_val(array, barray);
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean fill_array_boolean_value(GNode *gnode, gpointer data)
{
GArray *array = (GArray*)data;
dfilter_node *dnode = (dfilter_node*) (gnode->data);
g_array_append_val(array, dnode->value.boolean);
return FALSE; /* FALSE = do not end traversal of GNode tree */
}
gboolean check_relation_numeric(gint operand, GArray *a, GArray *b)
{
int i, j, len_a, len_b;
guint32 val_a;
len_a = a->len;
len_b = b->len;
switch(operand) {
case TOK_EQ:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a == g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_NE:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a != g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_GT:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a > g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_GE:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a >= g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_LT:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a < g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_LE:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a <= g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
default:
g_assert_not_reached();
}
g_assert_not_reached();
return FALSE;
}
gboolean check_relation_ether(gint operand, GArray *a, GArray *b)
{
int i, j, len_a, len_b;
guint8* ptr_a;
len_a = a->len;
len_b = b->len;
switch(operand) {
case TOK_EQ:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index_ptr(a, 6, i);
for (j = 0; j < len_b; j++) {
if (memcmp(ptr_a, g_array_index_ptr(b, 6, j), 6) == 0)
return TRUE;
}
}
return FALSE;
case TOK_NE:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index_ptr(a, 6, i);
for (j = 0; j < len_b; j++) {
if (memcmp(ptr_a, g_array_index_ptr(b, 6, j), 6) != 0)
return TRUE;
}
}
return FALSE;
}
g_assert_not_reached();
return FALSE;
}
gboolean check_relation_bytes(gint operand, GArray *a, GArray *b)
{
int i, j, len_a, len_b;
GByteArray *ptr_a,*ptr_b;
len_a = a->len;
len_b = b->len;
switch(operand) {
case TOK_EQ:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index(a, GByteArray*, i);
for (j = 0; j < len_b; j++) {
ptr_b = g_array_index(b, GByteArray*, j);
if (memcmp(ptr_a->data, ptr_b->data, bytes_length) == 0)
return TRUE;
}
}
return FALSE;
case TOK_NE:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index(a, GByteArray*, i);
for (j = 0; j < len_b; j++) {
ptr_b = g_array_index(b, GByteArray*, j);
if (memcmp(ptr_a->data, ptr_b->data, bytes_length) != 0)
return TRUE;
}
}
return FALSE;
case TOK_GT:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index(a, GByteArray*, i);
for (j = 0; j < len_b; j++) {
ptr_b = g_array_index(b, GByteArray*, j);
if (memcmp(ptr_a->data, ptr_b->data, bytes_length) > 0)
return TRUE;
}
}
return FALSE;
case TOK_LT:
for(i = 0; i < len_a; i++) {
ptr_a = g_array_index(a, GByteArray*, i);
for (j = 0; j < len_b; j++) {
ptr_b = g_array_index(b, GByteArray*, j);
if (memcmp(ptr_a->data, ptr_b->data, bytes_length) < 0)
return TRUE;
}
}
return FALSE;
}
g_assert_not_reached();
return FALSE;
}
gboolean check_relation_boolean(gint operand, GArray *a, GArray *b)
{
int i, j, len_a, len_b;
guint32 val_a;
len_a = a->len;
len_b = b->len;
switch(operand) {
case TOK_EQ:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a == g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
case TOK_NE:
for(i = 0; i < len_a; i++) {
val_a = g_array_index(a, guint32, i);
for (j = 0; j < len_b; j++) {
if (val_a != g_array_index(b, guint32, j))
return TRUE;
}
}
return FALSE;
default:
g_assert_not_reached();
}
g_assert_not_reached();
return FALSE;
}

105
dfilter.h Normal file
View File

@ -0,0 +1,105 @@
/* dfilter.h
* Definitions for display filters
*
* $Id: dfilter.h,v 1.1 1999/07/07 22:51:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __DFILTER_H__
#define __DFILTER_H__
void dfilter_init(void);
void dfilter_cleanup(void);
int dfilter_compile(char* dfilter_text, GNode** p_dfcode);
gboolean dfilter_apply(GNode *dfcode, proto_tree *ptree, guint8* pd);
/* Here we provide interfaces to make our scanner act and look like lex */
int yylex(void);
void yyerror(char *s);
void dfilter_yyerror(char *fmt, ...);
/* functions that dfilter-grammar.y needs during parsing*/
gboolean check_relation_numeric(gint operand, GArray *a, GArray *b);
gboolean check_relation_ether(gint operand, GArray *a, GArray *b);
gboolean check_relation_bytes(gint operand, GArray *a, GArray *b);
gboolean check_relation_boolean(gint operand, GArray *a, GArray *b);
gboolean fill_array_numeric_value(GNode *gnode, gpointer data);
gboolean fill_array_numeric_variable(GNode *gnode, gpointer data);
gboolean fill_array_ether_value(GNode *gnode, gpointer data);
gboolean fill_array_ether_variable(GNode *gnode, gpointer data);
gboolean fill_array_bytes_value(GNode *gnode, gpointer data);
gboolean fill_array_bytes_variable(GNode *gnode, gpointer data);
gboolean fill_array_boolean_value(GNode *gnode, gpointer data);
gboolean fill_array_boolean_variable(GNode *gnode, gpointer data);
enum node_type {
relation, /* eq, ne, gt, ge, lt, le */
logical, /* and, or, not, xor */
variable, /* protocol or header field id */
existence, /* existence of a variable (protocol or hf) */
alternation, /* &, | */
boolean, /* true, false */
numeric, /* uint8, uint16, or uint32 value */
abs_time,
string,
ether,
ether_vendor,
bytes,
ipv4
};
typedef gboolean(*CheckRelationFunc) (gint operand, GArray *a, GArray *b);
/* This struct is the parse tree node created by this grammary and used
* directly in the display filter routines to filter packets.
*/
typedef struct dfilter_node {
enum node_type ntype; /* from dfilter-grammar.h */
int elem_size; /* computed at dfilter parse time rather than
when finding elements for each packet. Saves time
in get_values_from_ptree() */
CheckRelationFunc check_relation_func;
GNodeTraverseFunc fill_array_func;
/* copied from proto.h */
union {
gint relation; /* if type == relation (eq, ne, gt, ge, lt, le) */
gint logical; /* if type == logical (and, or, not, xor) */
gint variable; /* if type == variable (protocol or header field abbrev) */
gint alternation; /* if type == alternation (& or |) */
gboolean boolean;
guint32 numeric;
struct timeval abs_time; /* the whole struct, not a pointer */
gchar *string;
guint8 ether[6];
GByteArray *bytes;
} value;
/* used for byte-ranges */
int offset;
int length;
} dfilter_node;
#endif /* ! __DFILTER_H__ */

235
doc/proto_tree Normal file
View File

@ -0,0 +1,235 @@
The Ethereal Protocol Tree
==========================
Up until version 0.6.3 of ethereal, the protocol tree that is displayed
in the middle pane of the ethereal GUI had been created by having the
protocol dissection routines add strings to a GTK+ tree. This GUI
container was not easily manipulated; the print routines had to reach
inside what should be an opaque structure and pull out the data. The
tree of strings also did not lend itself to filtering on the data
available in the tree.
Mostly to solve the display filter problem, I decided to have the
protocol dissection routines put their data into a logical tree instead
of a GUI tree. This tree structure would provide a generic way for
multiple routines, like the dissection routines, the display filter
routines, and the print routines, to retrieve data about the protocol
fields. The GUI routines would then be modified to draw the GUI tree
based on the data in the logical tree. By structuring this logical tree
well, with well-defined field types, ethereal can have a very powerful
display filter option. No longer would display filters be limited to the
ability of the BPF compiler (libpcap or wiretap), but would have access to the
full range of C field types available within ethereal.
The dissection routines are still passed a proto_tree pointer, but a
proto_tree is no longer the same as a GtkTree. Now a proto_tree is a
GNode, the N-way tree structure available within GLIB. Of course the
protocol dissectors don't care what a proto_tree really is; they just
pass the proto_tree pointer as an argument to the routines which allow
them to add items and new branches to the tree.
In packet_list_select_cb() you'll now find this:
if (protocol_tree)
proto_tree_free(protocol_tree);
protocol_tree = proto_tree_create_root();
dissect_packet(cf.pd, fd, protocol_tree);
proto_tree_draw(protocol_tree, tree_view);
When a packet is selected in the packet-list pane, a new logical
protocol tree (proto_tree) is created. The pointer to the proto_tree (in
this case, 'protocol tree'), is passed to the top-level protocol
dissector, and then the GUI tree is drawn via proto_tree_draw().
Programming for the proto_tree
==============================
The logical proto_tree now needs to know detail information about the
protocols and fields about which information will be collected from the
dissection routines. No longer will is the data just a bunch of strings.
Now the data will be typed so that searching and filtering on protocol
header fields will be possible. This means that the for every protocol
and field (which I also call "header fields", since they are fields in
the protocol headers) which might be attached to a tree, some
information is needed.
Every dissector routine will need to register its protocols and fields
with the central protocol routines (in proto.c). At first I thought I
might keep all the protocol and field information about all the
dissectors in one file, but decentralization seemed like a better idea.
That one file would have gotten very large; one small change would have
required a re-compilation of the entire file. Also, by allowing
registration of protocols and fields at run-time, loadable modules of
protocol dissectors (perhaps even user-supplied) is feasible.
For every protocol or field that a dissector wants to register, a variable of
type int needs to be used to keep track of the protocol. The IDs are
needed for establishing parent/child relationships between protocols and
fields, as well as associating data with a particular field so that it
can be stored in the logical tree and displayed in the GUI protocol
tree.
Some dissectors will need to create branches within their tree to help
organize header fields. These branches should be registered as header
fields. Only true protocols should be registered as protocols. This is
so that a display filter user interface knows how to distinguish
protocols from fields.
A protocol is registered with the name of the protocol and its
abbreviation.
Here is how the frame "protocol" is registered.
int proto_frame;
proto_frame = proto_register_protocol (
/* name */ "Frame",
/* abbrev */ "frame" );
A header field is also registered with its name and abbreviation, but
information about the its data type is needed. Some fields will use
value_strings to represent their values, so the value_string
is also passed. And of course the parent protocol for the field is indicated
during registration.
int hf_frame_arrival_time;
hf_frame_arrival_time = proto_register_field (
/* name */ "Arrival Time",
/* abbrev */ "frame.time",
/* ftype */ FT_ABSOLUTE_TIME,
/* parent */ proto_frame,
/* vals[] */ NULL );
The name can be used in any type of display, either in the GUI tree, or
in a display filter UI. The abbreviation is used when representing a
display filter as a string. For example, the following strings could be a
valid display filter, depending upon the implementation of the display
filter parser and engine.
frame[20:1] = 0x0a
frame.time > 'May 21, 1999 13:15:00'
The field type come from an enum. Currently, enum ftenum is comprised
of:
/* field types */
enum ftenum {
FT_NONE, /* used for protocol labels (thus no field type) */
FT_UINT8,
FT_UINT16,
FT_UINT32,
FT_ABSOLUTE_TIME,
FT_RELATIVE_TIME,
FT_STRING,
FT_ETHER,
FT_BYTES,
FT_IPv4,
FT_IPv6,
FT_IPXSERVER,
FT_VALS_UINT8,
FT_VALS_UINT16,
FT_VALS_UINT24,
FT_VALS_UINT32,
NUM_FIELD_TYPES /* last item number plus one */
};
Previously, the sequence needed within a dissector to add a new branch
to the GUI tree was this:
item = proto_tree_add_item(....);
new_tree = proto_tree_new();
proto_item_add_subtree(item, new_tree, tree_type);
With the new system, the call to proto_tree_new() is no longer needed,
as proto_item_add_subtree creates the new tree for you. The change was
necessary so that the proto_tree routines could maintain the
parent/child relationship within the logical tree. But it has a nice
side-effect of cleaning up the dissector code. The new method is like
this:
item = proto_tree_add_item(....);
new_tree = proto_item_add_subtree(item, tree_type);
There are now 4 functions that the programmer can use to add either
protocol or field labels to the proto_tree:
proto_item*
proto_tree_add_item(tree, id, start, length, value);
proto_item*
proto_tree_add_item_format(tree, id, start, length,
value, format, ...);
proto_item*
proto_tree_add_item_hidden(tree, id, start, length, value);
proto_item*
proto_tree_add_text(tree, start, length, format, ...);
The first function, proto_tree_add_item, is used when you wish to do no
special formatting. The item added to the GUI tree will contain the name
(as passed in the proto_register_*() function) and any value. If your
field does have a value, it is passed after the length variable (notice
the ellipsis in the function prototype).
The second function, proto_tree_add_free_format(), is used when the
dissector routines wants complete control over how the field and value
will be represented on the GUI tree. The caller must pass include the
name of the protocol or field; it is not added automatically as in
proto_tree_add_item().
The third function is used to add fields and values to a tree, but not
show them on a GUI tree. The caller may want a value to be included in a
tree so that the packet can be filtered on this field, but the
representation of that field in the tree is not appropriate. An example
is the token-ring routing information field (RIF). The best way to show the
RIF in a GUI is by a sequence of ring and bridge numbers. Rings are
3-digit hex numbers, and bridges are single hex digits:
RIF: 001-A-013-9-C0F-B-555
In the case of RIF, the programmer should use a field with no value and
use proto_tree_add_item_format() to build the above representation. The
programmer can then add the ring and bridge values, one-by-one, with
proto_tree_add_item_hidden() so that the user can then filter on or
search for a particular ring or bridge. Here's a skeleton of how the
programmer might code this.
char *rif;
rif = create_rif_string(...);
proto_tree_add_item_format(tree, hf_tr_rif_label,..., "RIF: %s", rif);
for(i = 0; i < num_rings; i++) {
proto_tree_add_item_hidden(tree, hf_tr_rif_ring, ..., ring[i]);
}
for(i = 0; i < num_rings - 1; i++) {
proto_tree_add_item_hidden(tree, hf_tr_rif_ring, ..., bridge[i]);
}
The logical tree has these items:
hf_tr_rif_label, text="RIF: 001-A-013-9-C0F-B-555", value = NONE
hf_tr_rif_ring, hidden, value=0x001
hf_tr_rif_bridge, hidden, value=0xA
hf_tr_rif_ring, hidden, value=0x013
hf_tr_rif_bridge, hidden, value=0x9
hf_tr_rif_ring, hidden, value=0xC0F
hf_tr_rif_bridge, hidden, value=0xB
hf_tr_rif_ring, hidden, value=0x555
GUI or print code will not display the hidden fields, but a display
filter or "packet grep" routine will still see the values. The possible
filter is then possible:
tr.rif_ring eq 0x013
The fourth function, proto_tree_add_text(), is used to add a label to the GUI tree.
It will contain no value, so it is not searchable in the display filter process.
This function was needed in the transition from the old-style proto_tree to this
new-style proto_tree so that ethereal would still decode all protocols w/o being
able to filter on all protocols and fields. Otherwise we would have had to
cripple ethereal's functionality while we converted all the old-style proto_tree
calls to the new-style proto_tree calls.

View File

@ -1,6 +1,6 @@
/* ethereal.c
*
* $Id: ethereal.c,v 1.47 1999/07/07 00:34:57 guy Exp $
* $Id: ethereal.c,v 1.48 1999/07/07 22:51:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -86,6 +86,7 @@
#include "follow.h"
#include "util.h"
#include "gtkpacket.h"
#include "dfilter.h"
static void file_save_ok_cb(GtkWidget *w, GtkFileSelection *fs);
static void file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs);
@ -93,6 +94,7 @@ static void file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs);
FILE *data_out_file = NULL;
packet_info pi;
capture_file cf;
proto_tree *protocol_tree = NULL;
GtkWidget *file_sel, *packet_list, *tree_view, *byte_view, *prog_bar,
*info_bar;
GdkFont *m_r_font, *m_b_font;
@ -303,14 +305,7 @@ follow_stream_cb( GtkWidget *w, gpointer data ) {
void
match_selected_cb(GtkWidget *w, gpointer data)
{
#ifndef WITH_WIRETAP
int i;
unsigned char *c;
#endif
char *buf = malloc(1024);
#ifndef WITH_WIRETAP
char *ptr;
#endif
GtkWidget *filter_te = NULL;
if (w)
@ -323,12 +318,7 @@ match_selected_cb(GtkWidget *w, gpointer data)
"view to be matched.");
return;
}
#ifdef WITH_WIRETAP
simple_dialog(ESD_TYPE_WARN, NULL,
"This functionality currently unsupported with Wiretap");
return;
#else
#if 0
switch (cf.lnk_t) {
case DLT_EN10MB :
c="ether";
@ -337,10 +327,12 @@ match_selected_cb(GtkWidget *w, gpointer data)
c="fddi";
break;
default :
#endif
simple_dialog(ESD_TYPE_WARN, NULL,
"Unsupported frame type format. Only Ethernet and FDDI\n"
"frame formats are supported.");
return;
#if 0
}
sprintf(buf, "("); ptr = buf+strlen(buf);
@ -364,7 +356,6 @@ match_selected_cb(GtkWidget *w, gpointer data)
}
sprintf(ptr, "))");
#endif
if( cf.dfilter != NULL ) {
/* get rid of this one */
@ -382,6 +373,7 @@ match_selected_cb(GtkWidget *w, gpointer data)
g_free( cf.dfilter );
cf.dfilter = NULL;
}
#endif
}
/* Open a file */
@ -549,28 +541,30 @@ file_print_cmd_cb(GtkWidget *widget, gpointer data) {
/* What to do when a list item is selected/unselected */
void
packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
GList *l;
if (!sync_mode) {
#ifdef WITH_WIRETAP
if (cf.wth) return;
#else
if (cf.pfh) return;
#endif
}
blank_packetinfo();
gtk_text_freeze(GTK_TEXT(byte_view));
gtk_text_set_point(GTK_TEXT(byte_view), 0);
gtk_text_forward_delete(GTK_TEXT(byte_view),
gtk_text_get_length(GTK_TEXT(byte_view)));
l = g_list_nth(cf.plist, row);
if (l) {
fd = (frame_data *) l->data;
fseek(cf.fh, fd->file_off, SEEK_SET);
fread(cf.pd, sizeof(guint8), fd->cap_len, cf.fh);
dissect_packet(cf.pd, fd, (proto_tree*)tree_view);
packet_hex_print(GTK_TEXT(byte_view), cf.pd, fd->cap_len, -1, -1);
}
gtk_text_get_length(GTK_TEXT(byte_view)));
/* get the frame data struct pointer for this frame */
fd = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(w), row);
fseek(cf.fh, fd->file_off, SEEK_SET);
fread(cf.pd, sizeof(guint8), fd->cap_len, cf.fh);
/* create the logical protocol tree */
if (protocol_tree)
proto_tree_free(protocol_tree);
protocol_tree = proto_tree_create_root();
dissect_packet(cf.pd, fd, protocol_tree);
/* display the GUI protocol tree and hex dump */
proto_tree_draw(protocol_tree, tree_view);
packet_hex_print(GTK_TEXT(byte_view), cf.pd, fd->cap_len, -1, -1);
gtk_text_thaw(GTK_TEXT(byte_view));
}
@ -642,11 +636,12 @@ sigusr2_handler(int sig) {
signal(SIGUSR2, sigusr2_handler);
}
/* call initialization routines at program startup time */
static void
ethereal_proto_init(void) {
proto_init();
init_dissect_udp();
dfilter_init();
}
static void
@ -703,14 +698,11 @@ main(int argc, char *argv[])
/* Initialize the capture file struct */
cf.plist = NULL;
#ifdef WITH_WIRETAP
cf.wth = NULL;
#else
cf.pfh = NULL;
#endif
cf.fh = NULL;
cf.dfilter = NULL;
cf.cfilter = NULL;
cf.dfcode = NULL;
cf.iface = NULL;
cf.save_file = NULL;
cf.user_saved = 0;
@ -725,16 +717,12 @@ main(int argc, char *argv[])
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,
#ifdef GTK_MAJOR_VERSION
"GTK+ %d.%d.%d and %s", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
GTK_MICRO_VERSION,
"GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
GTK_MICRO_VERSION
#else
"GTK+ (version unknown) and %s",
#endif
#ifdef WITH_WIRETAP
"wiretap");
#else
"libpcap");
"GTK+ (version unknown)"
#endif
);
/* Now get our args */
while ((opt = getopt(argc, argv, "b:B:c:f:Fhi:km:nP:Qr:Ss:t:T:w:v")) != EOF) {

View File

@ -2,7 +2,7 @@
* Routines for calling the right protocol for the ethertype.
* This is called by both packet-eth.c (Ethernet II) and packet-llc.c (SNAP)
*
* $Id: ethertype.c,v 1.15 1999/06/22 22:02:11 gram Exp $
* $Id: ethertype.c,v 1.16 1999/07/07 22:51:38 gram Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@ -38,10 +38,7 @@
#include "packet.h"
#include "etypes.h"
gchar *
ethertype_to_str(guint16 etype, const char *fmt)
{
static const value_string etype_vals[] = {
const value_string etype_vals[] = {
{ETHERTYPE_IP, "IP" },
{ETHERTYPE_IPv6, "IPv6" },
{ETHERTYPE_ARP, "ARP" },
@ -53,13 +50,10 @@ ethertype_to_str(guint16 etype, const char *fmt)
{ETHERTYPE_CDP, "CDP" }, /* Cisco Discovery Protocol */
{ETHERTYPE_TRAIN, "Netmon Train" },
{ETHERTYPE_LOOP, "Loopback" }, /* Ethernet Loopback */
{ETHERTYPE_PPPOED, "PPPoE Discovery"},
{ETHERTYPE_PPPOES, "PPPoE Session" },
{ETHERTYPE_PPPOED, "PPPoE Discovery"},
{ETHERTYPE_PPPOES, "PPPoE Session" },
{0, NULL } };
return val_to_str(etype, etype_vals, fmt);
}
void
capture_ethertype(guint16 etype, int offset,
const u_char *pd, guint32 cap_len, packet_counts *ld)
@ -77,11 +71,10 @@ capture_ethertype(guint16 etype, int offset,
void
ethertype(guint16 etype, int offset,
const u_char *pd, frame_data *fd, proto_tree *tree, proto_tree
*fh_tree)
*fh_tree, int item_id)
{
if (tree) {
proto_tree_add_item(fh_tree, offset - 2, 2, "Type: %s (0x%04x)",
ethertype_to_str(etype, "Unknown"), etype);
proto_tree_add_item(fh_tree, item_id, offset - 2, 2, etype);
}
switch (etype) {
case ETHERTYPE_IP:
@ -115,12 +108,12 @@ ethertype(guint16 etype, int offset,
dissect_data(pd, offset, fd, tree);
if (check_col(fd, COL_PROTOCOL)) { col_add_fstr(fd, COL_PROTOCOL, "LOOP"); }
break;
case ETHERTYPE_PPPOED:
dissect_pppoed(pd, offset, fd, tree);
break;
case ETHERTYPE_PPPOES:
dissect_pppoes(pd, offset, fd, tree);
break;
case ETHERTYPE_PPPOED:
dissect_pppoed(pd, offset, fd, tree);
break;
case ETHERTYPE_PPPOES:
dissect_pppoes(pd, offset, fd, tree);
break;
default:
dissect_data(pd, offset, fd, tree);
if (check_col(fd, COL_PROTOCOL)) { col_add_fstr(fd, COL_PROTOCOL, "0x%04x", etype); }

189
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.33 1999/06/22 22:02:11 gram Exp $
* $Id: file.c,v 1.34 1999/07/07 22:51:38 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -29,9 +29,7 @@
#include <gtk/gtk.h>
#ifdef WITH_WIRETAP
#include <pcap.h>
#endif
#include <stdio.h>
#include <unistd.h>
@ -67,6 +65,7 @@
#include "packet.h"
#include "file.h"
#include "util.h"
#include "dfilter.h"
#include "packet-ncp.h"
@ -83,13 +82,11 @@ guint cap_input_id, tail_timeout_id;
static guint32 firstsec, firstusec;
static guint32 lastsec, lastusec;
#ifdef WITH_WIRETAP
/* Used when applying a display filter */
static proto_tree *dfilter_proto_tree = NULL;
static void wtap_dispatch_cb(u_char *, const struct wtap_pkthdr *, int,
const u_char *);
#else
static void pcap_dispatch_cb(u_char *, const struct pcap_pkthdr *,
const u_char *);
#endif
static void init_col_widths(capture_file *);
static void set_col_widths(capture_file *);
@ -98,10 +95,6 @@ static gint tail_timeout_cb(gpointer);
int
open_cap_file(char *fname, capture_file *cf) {
#ifndef WITH_WIRETAP
guint32 magic[2];
char err_str[PCAP_ERRBUF_SIZE];
#endif
struct stat cf_stat;
/* First, make sure the file is valid */
@ -117,24 +110,13 @@ open_cap_file(char *fname, capture_file *cf) {
fseek(cf->fh, 0L, SEEK_END);
cf->f_len = ftell(cf->fh);
#ifndef WITH_WIRETAP
fseek(cf->fh, 0L, SEEK_SET);
fread(magic, sizeof(guint32), 2, cf->fh);
fseek(cf->fh, 0L, SEEK_SET);
#endif
fclose(cf->fh);
cf->fh = NULL;
/* set the file name beacuse we need it to set the follow stream filter */
cf->filename = g_strdup( fname );
/* Next, find out what type of file we're dealing with */
#ifdef WITH_WIRETAP
cf->cd_t = WTAP_FILE_UNKNOWN;
#else
cf->cd_t = CD_UNKNOWN;
cf->lnk_t = DLT_NULL;
cf->swap = 0;
#endif
cf->count = 0;
cf->drops = 0;
cf->esec = 0;
@ -143,16 +125,8 @@ open_cap_file(char *fname, capture_file *cf) {
firstsec = 0, firstusec = 0;
lastsec = 0, lastusec = 0;
#ifndef WITH_WIRETAP
if (magic[0] == PCAP_MAGIC || magic[0] == SWAP32(PCAP_MAGIC)) {
/* Pcap/Tcpdump file */
cf->pfh = pcap_open_offline(fname, err_str);
if (cf->pfh == NULL) {
#else
cf->wth = wtap_open_offline(fname);
if (cf->wth == NULL) {
#endif
/* XXX - we assume that, because we were able to open it above,
this must have failed because it's not a capture file in
@ -160,47 +134,16 @@ open_cap_file(char *fname, capture_file *cf) {
return (OPEN_CAP_FILE_UNKNOWN_FORMAT);
}
#ifndef WITH_WIRETAP
if (cf->dfilter) {
if (pcap_compile(cf->pfh, &cf->fcode, cf->dfilter, 1, 0) < 0) {
dfilter_compile(cf->dfilter, &cf->dfcode);
/* if (wtap_offline_filter(cf->wth, cf->dfilter) < 0) {
simple_dialog(ESD_TYPE_WARN, NULL, "Unable to parse filter string "
"\"%s\".", cf->dfilter);
} else if (pcap_setfilter(cf->pfh, &cf->fcode) < 0) {
simple_dialog(ESD_TYPE_WARN, NULL, "Can't install filter.");
}
}
cf->fh = pcap_file(cf->pfh);
cf->swap = pcap_is_swapped(cf->pfh);
if ((cf->swap && BYTE_ORDER == BIG_ENDIAN) ||
(!cf->swap && BYTE_ORDER == LITTLE_ENDIAN)) {
/* Data is big-endian */
cf->cd_t = CD_PCAP_BE;
} else {
cf->cd_t = CD_PCAP_LE;
}
cf->vers = ( ((pcap_major_version(cf->pfh) & 0x0000ffff) << 16) |
pcap_minor_version(cf->pfh) );
cf->snap = pcap_snapshot(cf->pfh);
cf->lnk_t = pcap_datalink(cf->pfh);
} else if (ntohl(magic[0]) == SNOOP_MAGIC_1 && ntohl(magic[1]) == SNOOP_MAGIC_2) {
return (OPEN_CAP_FILE_UNKNOWN_FORMAT);
}
if (cf->cd_t == CD_UNKNOWN)
return (OPEN_CAP_FILE_UNKNOWN_FORMAT);
#else
if (cf->dfilter) {
if (wtap_offline_filter(cf->wth, cf->dfilter) < 0) {
simple_dialog(ESD_TYPE_WARN, NULL, "Unable to parse filter string "
"\"%s\".", cf->dfilter);
}
}*/
}
cf->fh = wtap_file(cf->wth);
cf->cd_t = wtap_file_type(cf->wth);
cf->snap = wtap_snapshot_length(cf->wth);
#endif
return (0);
}
@ -217,17 +160,10 @@ close_cap_file(capture_file *cf, void *w, guint context) {
fclose(cf->fh);
cf->fh = NULL;
}
#ifdef WITH_WIRETAP
if (cf->wth) {
wtap_close(cf->wth);
cf->wth = NULL;
}
#else
if (cf->pfh) {
pcap_close(cf->pfh);
cf->pfh = NULL;
}
#endif
if (cf->plist) {
g_list_foreach(cf->plist, free_packets_cb, NULL);
g_list_free(cf->plist);
@ -258,7 +194,7 @@ load_cap_file(char *fname, capture_file *cf) {
close_cap_file(cf, info_bar, file_ctx);
/* Initialize protocol-specific variables */
/* Initialize protocol-speficic variables */
ncp_init_protocol();
if ((name_ptr = (gchar *) strrchr(fname, '/')) == NULL)
@ -272,22 +208,15 @@ load_cap_file(char *fname, capture_file *cf) {
timeout = gtk_timeout_add(250, file_progress_cb, (gpointer) &cf);
err = open_cap_file(fname, cf);
#ifdef WITH_WIRETAP
if ((err == 0) && (cf->cd_t != WTAP_FILE_UNKNOWN)) {
#else
if ((err == 0) && (cf->cd_t != CD_UNKNOWN)) {
#endif
if (dfilter_proto_tree)
gtk_clist_freeze(GTK_CLIST(packet_list));
init_col_widths(cf);
#ifdef WITH_WIRETAP
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
wtap_close(cf->wth);
cf->wth = NULL;
#else
pcap_loop(cf->pfh, 0, pcap_dispatch_cb, (u_char *) cf);
pcap_close(cf->pfh);
cf->pfh = NULL;
#endif
cf->fh = fopen(fname, "r");
set_col_widths(cf);
@ -360,22 +289,13 @@ cap_file_input_cb (gpointer data, gint source, GdkInputCondition condition) {
/* process data until end of file and stop capture (restore menu items) */
gtk_clist_freeze(GTK_CLIST(packet_list));
init_col_widths(cf);
#ifdef WITH_WIRETAP
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
#else
pcap_loop(cf->pfh, 0, pcap_dispatch_cb, (u_char *) cf);
#endif
set_col_widths(cf);
gtk_clist_thaw(GTK_CLIST(packet_list));
#ifdef WITH_WIRETAP
wtap_close(cf->wth);
cf->wth = NULL;
#else
pcap_close(cf->pfh);
cf->pfh = NULL;
#endif
#ifdef USE_ITEM
set_menu_sensitivity("/File/Open...", TRUE);
set_menu_sensitivity("/File/Close", TRUE);
@ -400,11 +320,7 @@ cap_file_input_cb (gpointer data, gint source, GdkInputCondition condition) {
gtk_clist_freeze(GTK_CLIST(packet_list));
init_col_widths(cf);
#ifdef WITH_WIRETAP
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
#else
pcap_loop(cf->pfh, 0, pcap_dispatch_cb, (u_char *) cf);
#endif
set_col_widths(cf);
gtk_clist_thaw(GTK_CLIST(packet_list));
@ -432,11 +348,7 @@ tail_timeout_cb(gpointer data) {
gtk_clist_freeze(GTK_CLIST(packet_list));
init_col_widths(cf);
#ifdef WITH_WIRETAP
wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
#else
pcap_loop(cf->pfh, 0, pcap_dispatch_cb, (u_char *) cf);
#endif
set_col_widths(cf);
gtk_clist_thaw(GTK_CLIST(packet_list));
@ -459,13 +371,9 @@ tail_cap_file(char *fname, capture_file *cf) {
/* Initialize protocol-speficic variables */
ncp_init_protocol();
err = open_cap_file(fname, cf);
#ifdef WITH_WIRETAP
if ((err == 0) && (cf->cd_t != WTAP_FILE_UNKNOWN)) {
#else
if ((err == 0) && (cf->cd_t != CD_UNKNOWN)) {
#endif
#ifdef USE_ITEM
set_menu_sensitivity("/File/Open...", FALSE);
@ -593,7 +501,7 @@ change_time_format_in_packet_list(frame_data *fdata, capture_file *cf)
static void
add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf)
{
gint i, row, col_width;
gint i, col_width, row;
compute_time_stamps(fdata, cf);
@ -609,19 +517,19 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
if (col_width > fdata->cinfo->col_width[i])
fdata->cinfo->col_width[i] = col_width;
}
row = gtk_clist_append(GTK_CLIST(packet_list), fdata->cinfo->col_data);
if (fdata->passed_dfilter) {
row = gtk_clist_append(GTK_CLIST(packet_list), fdata->cinfo->col_data);
gtk_clist_set_row_data(GTK_CLIST(packet_list), row, fdata);
}
fdata->cinfo = NULL;
}
static void
#ifdef WITH_WIRETAP
wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset,
#else
pcap_dispatch_cb(u_char *user, const struct pcap_pkthdr *phdr,
#endif
const u_char *buf) {
frame_data *fdata;
capture_file *cf = (capture_file *) user;
proto_tree *protocol_tree = NULL;
while (gtk_events_pending())
gtk_main_iteration();
@ -635,62 +543,25 @@ pcap_dispatch_cb(u_char *user, const struct pcap_pkthdr *phdr,
fdata->pkt_len = phdr->len;
fdata->cap_len = phdr->caplen;
#ifdef WITH_WIRETAP
fdata->file_off = offset;
fdata->lnk_t = phdr->pkt_encap;
#else
fdata->file_off = ftell(pcap_file(cf->pfh)) - phdr->caplen;
#endif
fdata->abs_secs = phdr->ts.tv_sec;
fdata->abs_usecs = phdr->ts.tv_usec;
fdata->cinfo = NULL;
/* Apply the display filter */
if (cf->dfcode) {
protocol_tree = proto_tree_create_root();
dissect_packet(buf, fdata, protocol_tree);
fdata->passed_dfilter = dfilter_apply(cf->dfcode, protocol_tree, buf);
}
else {
fdata->passed_dfilter = TRUE;
}
add_packet_to_packet_list(fdata, cf, buf);
}
static void
filter_packets_cb(gpointer data, gpointer user_data)
{
frame_data *fd = data;
capture_file *cf = user_data;
cf->cur = fd;
cf->count++;
fseek(cf->fh, fd->file_off, SEEK_SET);
fread(cf->pd, sizeof(guint8), fd->cap_len, cf->fh);
add_packet_to_packet_list(fd, cf, cf->pd);
}
void
filter_packets(capture_file *cf)
{
/* Freeze the packet list while we redo it, so we don't get any
screen updates while it happens. */
gtk_clist_freeze(GTK_CLIST(packet_list));
/* Clear it out. */
gtk_clist_clear(GTK_CLIST(packet_list));
/*
* Iterate through the list of packets, calling a routine
* to run the filter on the packet, see if it matches, and
* put it in the display list if so.
*
* XXX - we don't yet have anything to run a filter on a packet;
* this code awaits the arrival of display filter code.
*/
firstsec = 0;
firstusec = 0;
lastsec = 0;
lastusec = 0;
cf->count = 0;
g_list_foreach(cf->plist, filter_packets_cb, cf);
/* Unfreeze the packet list. */
gtk_clist_thaw(GTK_CLIST(packet_list));
}
static void
change_time_formats_cb(gpointer data, gpointer user_data)
{

63
file.h
View File

@ -1,7 +1,7 @@
/* file.h
* Definitions for file structures and routines
*
* $Id: file.h,v 1.17 1999/06/22 22:02:12 gram Exp $
* $Id: file.h,v 1.18 1999/07/07 22:51:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -29,31 +29,8 @@
#include <sys/types.h>
#include <sys/time.h>
#ifdef WITH_WIRETAP
#include <wtap.h>
#include <pcap.h>
#else
#include <pcap.h>
/* Data file formats */
#define CD_UNKNOWN 0
#define CD_WIRE 1
#define CD_SNOOP 2
#define CD_PCAP_BE 3
#define CD_PCAP_LE 4
#define CD_NA_UNCOMPR 5
/* Data file magic info */
#define SNOOP_MAGIC_1 0x736e6f6f /* 'snoop' in ASCII */
#define SNOOP_MAGIC_2 0x70000000
#define PCAP_MAGIC 0xa1b2c3d4
/* Data file format versions we can handle */
#define SNOOP_MIN_VERSION 2
#define SNOOP_MAX_VERSION 2
/* Link types (removed in favor of the DLT_* defines from bpf.h */
#endif
#include <wtap.h>
#include <pcap.h>
typedef struct bpf_program bpf_prog;
@ -61,14 +38,8 @@ typedef struct _capture_file {
FILE *fh; /* Capture file */
gchar *filename; /* filename */
long f_len; /* File length */
#ifndef WITH_WIRETAP
int swap; /* Swap data bytes? */
#endif
guint16 cd_t; /* Capture data type */
guint32 vers; /* Version. For tcpdump minor is appended to major */
#ifndef WITH_WIRETAP
guint32 lnk_t; /* Network link type */
#endif
guint32 count; /* Packet count */
guint32 drops; /* Dropped packets */
guint32 esec; /* Elapsed seconds */
@ -77,14 +48,11 @@ typedef struct _capture_file {
gchar *iface; /* Interface */
gchar *save_file; /* File that user saved capture to */
gint user_saved;/* Was capture file saved by user yet? */
#ifdef WITH_WIRETAP
wtap *wth; /* Wiretap session */
#else
pcap_t *pfh; /* Pcap session */
#endif
wtap *wth; /* Wiretap session */
gchar *dfilter; /* Display filter string */
gchar *cfilter; /* Capture filter string */
bpf_prog fcode; /* Compiled filter program */
bpf_prog fcode; /* Compiled capture filter program */
GNode *dfcode; /* Compiled display filter program */
/* XXX - I'm cheating for now. I'll hardcode 65536 here until I re-arrange
* more header files so that ethereal.h is split up into two files, a
* generic header and a gtk+-speficic header (or the gtk+ definitions are
@ -97,25 +65,6 @@ typedef struct _capture_file {
column_info cinfo; /* Column formatting information */
} capture_file;
/* Taken from RFC 1761 */
#ifndef WITH_WIRETAP
typedef struct _snoop_file_hdr {
guint32 magic1;
guint32 magic2;
guint32 vers;
guint32 s_lnk_t;
} snoop_file_hdr;
typedef struct _snoop_frame_hdr {
guint32 orig_len;
guint32 inc_len;
guint32 pr_len;
guint32 drops;
guint32 secs;
guint32 usecs;
} snoop_frame_hdr;
#endif
/*
* "open_cap_file()" can return:

View File

@ -1,6 +1,6 @@
/* follow.c
*
* $Id: follow.c,v 1.9 1999/07/07 01:41:15 guy Exp $
* $Id: follow.c,v 1.10 1999/07/07 22:51:39 gram Exp $
*
* Copyright 1998 Mike Hall <mlh@io.com>
*
@ -39,6 +39,7 @@
# include <sys/types.h>
#endif
#include <glib.h>
#include "ethereal.h"
#include "packet.h"
#include "follow.h"

View File

@ -1,7 +1,7 @@
/* gtkpacket.c
* Routines for GTK+ packet display
*
* $Id: gtkpacket.c,v 1.5 1999/05/01 05:39:06 gram Exp $
* $Id: gtkpacket.c,v 1.6 1999/07/07 22:51:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -54,6 +54,9 @@
extern GtkWidget *byte_view;
extern GdkFont *m_r_font, *m_b_font;
static void
proto_tree_draw_node(GNode *node, gpointer data);
void
packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen) {
gint i = 0, j, k, cur;
@ -136,49 +139,53 @@ set_item_style(GtkWidget *widget, gpointer dummy)
gtk_widget_set_style(widget, item_style);
}
proto_item *
proto_tree_add_item(proto_tree *tree, gint start, gint len,
gchar *format, ...) {
GtkWidget *ti;
va_list ap;
gchar label_str[256];
if (!tree)
return(NULL);
va_start(ap, format);
vsnprintf(label_str, 256, format, ap);
ti = gtk_tree_item_new_with_label(label_str);
gtk_container_foreach(GTK_CONTAINER(ti), set_item_style, NULL);
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_START_KEY, (gpointer) start);
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len);
gtk_tree_append(GTK_TREE(tree), ti);
gtk_widget_show(ti);
return (proto_item*) ti;
}
void
proto_item_set_len(proto_item *ti, gint len)
proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view)
{
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len);
g_node_children_foreach((GNode*) protocol_tree, G_TRAVERSE_ALL,
proto_tree_draw_node, tree_view);
}
void
proto_item_add_subtree(proto_item *ti, proto_tree *subtree, gint idx) {
static gint tree_type[NUM_TREE_TYPES];
gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), GTK_WIDGET(subtree));
if (tree_type[idx])
gtk_tree_item_expand(GTK_TREE_ITEM(ti));
gtk_signal_connect(GTK_OBJECT(ti), "expand", (GtkSignalFunc) expand_tree,
(gpointer) &tree_type[idx]);
gtk_signal_connect(GTK_OBJECT(ti), "collapse", (GtkSignalFunc) collapse_tree,
(gpointer) &tree_type[idx]);
}
proto_tree*
proto_tree_new(void)
static void
proto_tree_draw_node(GNode *node, gpointer data)
{
return (proto_tree*) gtk_tree_new();
GtkWidget *tree_view = (GtkWidget*) data;
field_info *fi = (field_info*) (node->data);
GtkWidget *ti, *subtree;
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
static gint tree_type[NUM_TREE_TYPES];
if (!fi->visible)
return;
/* was a free format label produced? */
if (fi->representation) {
label_ptr = fi->representation;
}
else { /* no, make a generic label */
label_ptr = label_str;
proto_item_fill_label(fi, label_str);
}
ti = gtk_tree_item_new_with_label(label_ptr);
gtk_container_foreach(GTK_CONTAINER(ti), set_item_style, NULL);
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_START_KEY, (gpointer) fi->start);
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) fi->length);
gtk_tree_append(GTK_TREE(tree_view), ti);
gtk_widget_show(ti);
if (g_node_n_children(node) > 0) {
subtree = gtk_tree_new();
gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), GTK_WIDGET(subtree));
if (tree_type[fi->tree_type])
gtk_tree_item_expand(GTK_TREE_ITEM(ti));
gtk_signal_connect(GTK_OBJECT(ti), "expand", (GtkSignalFunc) expand_tree,
(gpointer) &tree_type[fi->tree_type]);
gtk_signal_connect(GTK_OBJECT(ti), "collapse", (GtkSignalFunc) collapse_tree,
(gpointer) &tree_type[fi->tree_type]);
g_node_children_foreach(node, G_TRAVERSE_ALL,
proto_tree_draw_node, subtree);
}
}

View File

@ -1,7 +1,7 @@
/* gtkpacket.h
* Definitions for GTK+ packet display structures and routines
*
* $Id: gtkpacket.h,v 1.1 1999/03/23 03:14:35 gram Exp $
* $Id: gtkpacket.h,v 1.2 1999/07/07 22:51:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -32,4 +32,6 @@ void packet_hex_print(GtkText *, guint8 *, gint, gint, gint);
#define E_TREEINFO_START_KEY "tree_info_start"
#define E_TREEINFO_LEN_KEY "tree_info_len"
void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view);
#endif

9
menu.c
View File

@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
* $Id: menu.c,v 1.22 1999/06/24 16:25:59 gram Exp $
* $Id: menu.c,v 1.23 1999/07/07 22:51:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -213,10 +213,9 @@ menus_init(void) {
set_menu_sensitivity("/Edit/Find", FALSE);
set_menu_sensitivity("/Tools/Graph", FALSE);
set_menu_sensitivity("/Tools/Summary", FALSE);
#ifdef WITH_WIRETAP
set_menu_sensitivity("/Tools/Follow TCP Stream", FALSE);
set_menu_sensitivity("/Display/Match Selected", FALSE);
#endif
#else
factory = gtk_menu_factory_new(GTK_MENU_FACTORY_MENU_BAR);
@ -235,10 +234,10 @@ menus_init(void) {
set_menu_sensitivity("<Main>/Edit/Find", FALSE);
set_menu_sensitivity("<Main>/Tools/Graph", FALSE);
set_menu_sensitivity("<Main>/Tools/Summary", FALSE);
#ifdef WITH_WIRETAP
set_menu_sensitivity("<Main>/Tools/Follow TCP Stream", FALSE);
set_menu_sensitivity("<Main>/Display/Match Selected", FALSE);
#endif
if ((mp = gtk_menu_factory_find(factory, "<Main>/Help")) != NULL) {
gtk_menu_item_right_justify((GtkMenuItem *) mp->widget);
}

View File

@ -96,29 +96,28 @@ dissect_aarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (tree) {
if ((op_str = match_strval(ea.op, op_vals)))
ti = proto_tree_add_item(tree, offset, 28, op_str);
ti = proto_tree_add_text(tree, offset, 28, op_str);
else
ti = proto_tree_add_item(tree, offset, 28,
ti = proto_tree_add_text(tree, offset, 28,
"Unknown AARP (opcode 0x%04x)", ea.op);
aarp_tree = proto_tree_new();
proto_item_add_subtree(ti, aarp_tree, ETT_AARP);
proto_tree_add_item(aarp_tree, offset, 2,
aarp_tree = proto_item_add_subtree(ti, ETT_AARP);
proto_tree_add_text(aarp_tree, offset, 2,
"Hardware type: 0x%04x", ea.htype);
proto_tree_add_item(aarp_tree, offset + 2, 2,
proto_tree_add_text(aarp_tree, offset + 2, 2,
"Protocol type: 0x%04x", ea.ptype);
proto_tree_add_item(aarp_tree, offset + 4, 1,
proto_tree_add_text(aarp_tree, offset + 4, 1,
"Hardware size: 0x%02x", ea.halen);
proto_tree_add_item(aarp_tree, offset + 5, 1,
proto_tree_add_text(aarp_tree, offset + 5, 1,
"Protocol size: 0x%02x", ea.palen);
proto_tree_add_item(aarp_tree, offset + 6, 2,
proto_tree_add_text(aarp_tree, offset + 6, 2,
"Opcode: 0x%04x (%s)", ea.op, op_str ? op_str : "Unknown");
proto_tree_add_item(aarp_tree, offset + 8, 6,
proto_tree_add_text(aarp_tree, offset + 8, 6,
"Sender ether: %s", ether_to_str((guint8 *) ea.hsaddr));
proto_tree_add_item(aarp_tree, offset + 14, 4,
proto_tree_add_text(aarp_tree, offset + 14, 4,
"Sender ID: %s", atalkid_to_str((guint8 *) ea.psaddr));
proto_tree_add_item(aarp_tree, offset + 18, 6,
proto_tree_add_text(aarp_tree, offset + 18, 6,
"Target ether: %s", ether_to_str((guint8 *) ea.hdaddr));
proto_tree_add_item(aarp_tree, offset + 24, 4,
proto_tree_add_text(aarp_tree, offset + 24, 4,
"Target ID: %s", atalkid_to_str((guint8 *) ea.pdaddr));
}

View File

@ -1,7 +1,7 @@
/* packet-arp.c
* Routines for ARP packet disassembly
*
* $Id: packet-arp.c,v 1.13 1999/05/11 08:21:39 guy Exp $
* $Id: packet-arp.c,v 1.14 1999/07/07 22:51:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -216,30 +216,29 @@ dissect_arp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (tree) {
if ((op_str = match_strval(ar_op, op_vals)))
ti = proto_tree_add_item(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
ti = proto_tree_add_text(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
op_str);
else
ti = proto_tree_add_item(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
ti = proto_tree_add_text(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
"Unknown ARP (opcode 0x%04x)", ar_op);
arp_tree = proto_tree_new();
proto_item_add_subtree(ti, arp_tree, ETT_ARP);
proto_tree_add_item(arp_tree, offset + AR_HRD, 2,
arp_tree = proto_item_add_subtree(ti, ETT_ARP);
proto_tree_add_text(arp_tree, offset + AR_HRD, 2,
"Hardware type: %s", arphrdtype_to_str(ar_hrd, "Unknown (0x%04x)"));
proto_tree_add_item(arp_tree, offset + AR_PRO, 2,
"Protocol type: %s", ethertype_to_str(ar_pro, "Unknown (0x%04x)"));
proto_tree_add_item(arp_tree, offset + AR_HLN, 1,
proto_tree_add_text(arp_tree, offset + AR_PRO, 2,
"Protocol type: %s", val_to_str(ar_pro, etype_vals, "Unknown (0x%04x)"));
proto_tree_add_text(arp_tree, offset + AR_HLN, 1,
"Hardware size: %d", ar_hln);
proto_tree_add_item(arp_tree, offset + AR_PLN, 1,
proto_tree_add_text(arp_tree, offset + AR_PLN, 1,
"Protocol size: %d", ar_pln);
proto_tree_add_item(arp_tree, offset + AR_OP, 2,
proto_tree_add_text(arp_tree, offset + AR_OP, 2,
"Opcode: 0x%04x (%s)", ar_op, op_str ? op_str : "Unknown");
proto_tree_add_item(arp_tree, sha_offset, ar_hln,
proto_tree_add_text(arp_tree, sha_offset, ar_hln,
"Sender hardware address: %s", sha_str);
proto_tree_add_item(arp_tree, spa_offset, ar_pln,
proto_tree_add_text(arp_tree, spa_offset, ar_pln,
"Sender protocol address: %s", spa_str);
proto_tree_add_item(arp_tree, tha_offset, ar_hln,
proto_tree_add_text(arp_tree, tha_offset, ar_hln,
"Target hardware address: %s", tha_str);
proto_tree_add_item(arp_tree, tpa_offset, ar_pln,
proto_tree_add_text(arp_tree, tpa_offset, ar_pln,
"Target protocol address: %s", tpa_str);
}
}

View File

@ -91,19 +91,18 @@ dissect_ddp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
val_to_str(ddp.type, op_vals, "Unknown DDP protocol (%02x)"));
if (tree) {
ti = proto_tree_add_item(tree, offset, 13, "Datagram Delivery Protocol");
ddp_tree = proto_tree_new();
proto_item_add_subtree(ti, ddp_tree, ETT_IP);
proto_tree_add_item(ddp_tree, offset, 1, "Hop count: %d", ddp_hops(ddp.hops_len));
proto_tree_add_item(ddp_tree, offset, 2, "Datagram length: %d", ddp_len(ddp.hops_len));
proto_tree_add_item(ddp_tree, offset + 2, 2, "Checksum: %d",ddp.sum);
proto_tree_add_item(ddp_tree, offset + 4, 2, "Destination Net: %d",ddp.dnet);
proto_tree_add_item(ddp_tree, offset + 6, 2, "Source Net: %d",ddp.snet);
proto_tree_add_item(ddp_tree, offset + 8, 1, "Destination Node: %d",ddp.dnode);
proto_tree_add_item(ddp_tree, offset + 9, 1, "Source Node: %d",ddp.snode);
proto_tree_add_item(ddp_tree, offset + 10, 1, "Destination Socket: %d",ddp.dport);
proto_tree_add_item(ddp_tree, offset + 11, 1, "Source Socket: %d",ddp.sport);
proto_tree_add_item(ddp_tree, offset + 12, 1, "Type: %d",ddp.type);
ti = proto_tree_add_text(tree, offset, 13, "Datagram Delivery Protocol");
ddp_tree = proto_item_add_subtree(ti, ETT_IP);
proto_tree_add_text(ddp_tree, offset, 1, "Hop count: %d", ddp_hops(ddp.hops_len));
proto_tree_add_text(ddp_tree, offset, 2, "Datagram length: %d", ddp_len(ddp.hops_len));
proto_tree_add_text(ddp_tree, offset + 2, 2, "Checksum: %d",ddp.sum);
proto_tree_add_text(ddp_tree, offset + 4, 2, "Destination Net: %d",ddp.dnet);
proto_tree_add_text(ddp_tree, offset + 6, 2, "Source Net: %d",ddp.snet);
proto_tree_add_text(ddp_tree, offset + 8, 1, "Destination Node: %d",ddp.dnode);
proto_tree_add_text(ddp_tree, offset + 9, 1, "Source Node: %d",ddp.snode);
proto_tree_add_text(ddp_tree, offset + 10, 1, "Destination Socket: %d",ddp.dport);
proto_tree_add_text(ddp_tree, offset + 11, 1, "Source Socket: %d",ddp.sport);
proto_tree_add_text(ddp_tree, offset + 12, 1, "Type: %d",ddp.type);
}
offset += 13;

View File

@ -2,7 +2,7 @@
* Routines for BOOTP/DHCP packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-bootp.c,v 1.16 1999/03/23 03:14:35 gram Exp $
* $Id: packet-bootp.c,v 1.17 1999/07/07 22:51:40 gram Exp $
*
* The information used comes from:
* RFC 2132: DHCP Options and BOOTP Vendor Extensions
@ -174,7 +174,7 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
}
}
i = i - voff;
proto_tree_add_item(bp_tree, voff, i, "Padding");
proto_tree_add_text(bp_tree, voff, i, "Padding");
consumed = i;
return consumed;
@ -182,7 +182,7 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case 21:
/* one IP address pair */
if (vlen == 8) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s/%s", code, text,
ip_to_str((guint8*)&pd[voff+2]),
ip_to_str((guint8*)&pd[voff+6]));
@ -190,12 +190,11 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
/* > 1 IP address pair. Let's make a sub-tree */
else {
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 8) {
proto_tree_add_item(v_tree, i, 8, "IP Address/Mask: %s/%s",
proto_tree_add_text(v_tree, i, 8, "IP Address/Mask: %s/%s",
ip_to_str((guint8*)&pd[i]),
ip_to_str((guint8*)&pd[i+4]));
}
@ -206,7 +205,7 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case 33:
/* one IP address pair */
if (vlen == 8) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s/%s", code, text,
ip_to_str((guint8*)&pd[voff+2]),
ip_to_str((guint8*)&pd[voff+6]));
@ -214,12 +213,11 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
/* > 1 IP address pair. Let's make a sub-tree */
else {
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 8) {
proto_tree_add_item(v_tree, i, 8,
proto_tree_add_text(v_tree, i, 8,
"Destination IP Address/Router: %s/%s",
ip_to_str((guint8*)&pd[i]),
ip_to_str((guint8*)&pd[i+4]));
@ -229,14 +227,14 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
/* Vendor-Specific Info */
case 43:
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s", code, text);
break;
/* NetBIOS-over-TCP/IP Node Type */
case 46:
byte = pd[voff+2];
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
val_to_str(byte, nbnt_vals,
"Unknown (0x%02x)"));
@ -251,24 +249,23 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
else {
i = 0;
}
proto_tree_add_item(bp_tree, voff, 3, "Option %d: %s = DHCP %s",
proto_tree_add_text(bp_tree, voff, 3, "Option %d: %s = DHCP %s",
code, text, opt53_text[i]);
break;
/* Parameter Request List */
case 55:
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
vlen + 2, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
for (i = 0; i < vlen; i++) {
byte = pd[voff+2+i];
if (byte < NUM_OPT_INFOS) {
proto_tree_add_item(v_tree, voff+2+i, 1, "%d = %s",
proto_tree_add_text(v_tree, voff+2+i, 1, "%d = %s",
byte, opt[byte].text);
}
else {
proto_tree_add_item(vti, voff+2+i, 1,
proto_tree_add_text(vti, voff+2+i, 1,
"Unknown Option Code: %d", byte);
}
}
@ -280,29 +277,28 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
guess that the first is the hwtype, and the last 6 are
the hw addr */
if (vlen == 7) {
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
proto_tree_add_item(v_tree, voff+2, 1,
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
proto_tree_add_text(v_tree, voff+2, 1,
"Hardware type: %s",
arphrdtype_to_str(pd[voff+2],
"Unknown (0x%02x)"));
proto_tree_add_item(v_tree, voff+3, 6,
proto_tree_add_text(v_tree, voff+3, 6,
"Client hardware address: %s",
arphrdaddr_to_str((guint8*)&pd[voff+3],
6, pd[voff+2]));
}
/* otherwise, it's opaque data */
else {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)", code, text, vlen);
}
break;
/* End Option */
case 255:
proto_tree_add_item(bp_tree, voff, 1, "End Option");
proto_tree_add_text(bp_tree, voff, 1, "End Option");
consumed = 1;
return consumed;
@ -323,19 +319,18 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case ipv4:
/* one IP address */
if (vlen == 4) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
ip_to_str((guint8*)&pd[voff+2]));
}
/* > 1 IP addresses. Let's make a sub-tree */
else {
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 4) {
proto_tree_add_item(v_tree, i, 4, "IP Address: %s",
proto_tree_add_text(v_tree, i, 4, "IP Address: %s",
ip_to_str((guint8*)&pd[i]));
}
}
@ -345,12 +340,12 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
/* Fix for non null-terminated string supplied by
* John Lines <John.Lines@aeat.co.uk>
*/
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %.*s", code, text, vlen, &pd[voff+2]);
break;
case opaque:
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)",
code, text, vlen);
break;
@ -358,43 +353,42 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case val_u_short:
/* one IP address */
if (vlen == 2) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %d", code, text,
pntohs(&pd[voff+2]));
}
/* > 1 u_short */
else {
vti = proto_tree_add_item(bp_tree, voff,
vti = proto_tree_add_text(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_item_add_subtree(vti, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 2) {
proto_tree_add_item(v_tree, i, 4, "Value: %d",
proto_tree_add_text(v_tree, i, 4, "Value: %d",
pntohs(&pd[i]));
}
}
break;
case val_u_long:
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %d", code, text,
pntohl(&pd[voff+2]));
break;
case val_u_byte:
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %d", code, text, pd[voff+2]);
break;
case toggle:
i = pd[voff+2];
if (i != 0 && i != 1) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = Invalid Value %d", code, text,
pd[voff+2]);
}
else {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
pd[voff+2] == 0 ? "Disabled" : "Enabled");
}
@ -403,12 +397,12 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case yes_no:
i = pd[voff+2];
if (i != 0 && i != 1) {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = Invalid Value %d", code, text,
pd[voff+2]);
}
else {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
pd[voff+2] == 0 ? "No" : "Yes");
}
@ -416,7 +410,7 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
case time_in_secs:
time_secs = pntohl(&pd[voff+2]);
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
((time_secs == 0xffffffff) ?
"infinity" :
@ -424,12 +418,12 @@ bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
break;
default:
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)", code, text, vlen);
}
}
else {
proto_tree_add_item(bp_tree, voff, consumed,
proto_tree_add_text(bp_tree, voff, consumed,
"Unknown Option Code: %d (%d bytes)", code, vlen);
}
@ -458,66 +452,65 @@ dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Bootstrap Protocol");
bp_tree = proto_tree_new();
proto_item_add_subtree(ti, bp_tree, ETT_BOOTP);
bp_tree = proto_item_add_subtree(ti, ETT_BOOTP);
proto_tree_add_item(bp_tree, offset, 1, pd[offset] == 1 ?
proto_tree_add_text(bp_tree, offset, 1, pd[offset] == 1 ?
"Boot Request" : "Boot Reply");
proto_tree_add_item(bp_tree, offset + 1, 1,
proto_tree_add_text(bp_tree, offset + 1, 1,
"Hardware type: %s",
arphrdtype_to_str(pd[offset+1], "Unknown (0x%02x)"));
proto_tree_add_item(bp_tree, offset + 2, 1,
proto_tree_add_text(bp_tree, offset + 2, 1,
"Hardware address length: %d", pd[offset+2]);
proto_tree_add_item(bp_tree, offset + 3, 1,
proto_tree_add_text(bp_tree, offset + 3, 1,
"Hops: %d", pd[offset+3]);
proto_tree_add_item(bp_tree, offset + 4, 4,
proto_tree_add_text(bp_tree, offset + 4, 4,
"Transaction ID: 0x%08x", pntohl(&pd[offset+4]));
proto_tree_add_item(bp_tree, offset + 8, 2,
proto_tree_add_text(bp_tree, offset + 8, 2,
"Seconds elapsed: %d", pntohs(&pd[offset+8]));
proto_tree_add_item(bp_tree, offset + 10, 2,
proto_tree_add_text(bp_tree, offset + 10, 2,
"Broadcast flag: %d", pd[offset+10] & 1);
proto_tree_add_item(bp_tree, offset + 12, 4,
proto_tree_add_text(bp_tree, offset + 12, 4,
"Client IP address: %s", ip_to_str((guint8*)&pd[offset+12]));
proto_tree_add_item(bp_tree, offset + 16, 4,
proto_tree_add_text(bp_tree, offset + 16, 4,
"Your (client) IP address: %s", ip_to_str((guint8*)&pd[offset+16]));
proto_tree_add_item(bp_tree, offset + 20, 4,
proto_tree_add_text(bp_tree, offset + 20, 4,
"Next server IP address: %s", ip_to_str((guint8*)&pd[offset+20]));
proto_tree_add_item(bp_tree, offset + 24, 4,
proto_tree_add_text(bp_tree, offset + 24, 4,
"Relay agent IP address: %s", ip_to_str((guint8*)&pd[offset+24]));
proto_tree_add_item(bp_tree, offset + 28, pd[offset+2],
proto_tree_add_text(bp_tree, offset + 28, pd[offset+2],
"Client hardware address: %s",
arphrdaddr_to_str((guint8*)&pd[offset+28],
pd[offset+2], pd[offset+1]));
/* The server host name is optional */
if (pd[offset+44]) {
proto_tree_add_item(bp_tree, offset + 44, 64,
proto_tree_add_text(bp_tree, offset + 44, 64,
"Server host name: %s", &pd[offset+44]);
}
else {
proto_tree_add_item(bp_tree, offset + 44, 64,
proto_tree_add_text(bp_tree, offset + 44, 64,
"Server host name not given");
}
/* Boot file */
if (pd[offset+108]) {
proto_tree_add_item(bp_tree, offset + 108, 128,
proto_tree_add_text(bp_tree, offset + 108, 128,
"Boot file name: %s", &pd[offset+108]);
}
else {
proto_tree_add_item(bp_tree, offset + 108, 128,
proto_tree_add_text(bp_tree, offset + 108, 128,
"Boot file name not given");
}
if (pntohl(&pd[offset+236]) == 0x63825363) {
proto_tree_add_item(bp_tree, offset + 236, 4,
proto_tree_add_text(bp_tree, offset + 236, 4,
"Magic cookie: (OK)");
}
else {
proto_tree_add_item(bp_tree, offset + 236, 4,
proto_tree_add_text(bp_tree, offset + 236, 4,
"Magic cookie: %s",
ip_to_str((guint8*)&pd[offset+236]));
}

View File

@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-cdp.c,v 1.8 1999/03/23 03:14:36 gram Exp $
* $Id: packet-cdp.c,v 1.9 1999/07/07 22:51:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -66,16 +66,15 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_INFO, "Cisco Discovery Protocol");
if(tree){
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset),
ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset),
"Cisco Discovery Protocol");
cdp_tree = proto_tree_new();
proto_item_add_subtree(ti, cdp_tree, ETT_CDP);
cdp_tree = proto_item_add_subtree(ti, ETT_CDP);
/* CDP header */
cdp_hdr = (e_cdp_hdr *) &pd[offset];
proto_tree_add_item(cdp_tree, offset, 1, "Version: %d", cdp_hdr->version);
proto_tree_add_item(cdp_tree, offset+1, 1, "Flags (unknown)");
proto_tree_add_item(cdp_tree, offset+2, 2, "TTL (unknown)");
proto_tree_add_text(cdp_tree, offset, 1, "Version: %d", cdp_hdr->version);
proto_tree_add_text(cdp_tree, offset+1, 1, "Flags (unknown)");
proto_tree_add_text(cdp_tree, offset+2, 2, "TTL (unknown)");
offset+=4;
/* CVS -> exit here
@ -91,7 +90,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
offset+=length + 4;
break;
case 1: /* ??? Chassis ID */
proto_tree_add_item(cdp_tree, offset + 4,
proto_tree_add_text(cdp_tree, offset + 4,
length - 4, "Chassis ID: %s", &pd[offset+4] );
offset+=length;
break;
@ -102,7 +101,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
offset+=4;
break;
case 3: /* ??? Port */
proto_tree_add_item(cdp_tree, offset + 4,
proto_tree_add_text(cdp_tree, offset + 4,
length - 4, "Sent through Interface: %s", &pd[offset+4] );
offset+=length;
break;
@ -117,13 +116,13 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
stringmem = malloc(length);
memset(stringmem, '\0', length);
memcpy(stringmem, &pd[offset+4], length - 4 );
proto_tree_add_item(cdp_tree, offset + 4, length - 4,
proto_tree_add_text(cdp_tree, offset + 4, length - 4,
"Platform: %s", stringmem );
free(stringmem);
offset+=length;
break;
case 0x01cc: /* ??? Mgmt Addr */
proto_tree_add_item(cdp_tree, offset + 4, length,
proto_tree_add_text(cdp_tree, offset + 4, length,
"Mgmt IP: %s",
ip_to_str(&pd[offset+4]) );
offset+=length + 4;
@ -136,11 +135,11 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
*/
/*
proto_tree_add_item(cdp_tree, offset + TLV_TYPE,
proto_tree_add_text(cdp_tree, offset + TLV_TYPE,
2, "Type: %d", type);
proto_tree_add_item(cdp_tree, offset + TLV_LENGTH,
proto_tree_add_text(cdp_tree, offset + TLV_LENGTH,
2, "Length: %d", length);
proto_tree_add_item(cdp_tree, offset + 4,
proto_tree_add_text(cdp_tree, offset + 4,
length - 4, "Data");
*/
@ -179,7 +178,7 @@ add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
line_len = strlen(p);
data_len = line_len;
}
proto_tree_add_item(tree, start, data_len, "%s%.*s", prefix,
proto_tree_add_text(tree, start, data_len, "%s%.*s", prefix,
line_len, p);
if (q == NULL)
break;

View File

@ -2,7 +2,7 @@
* Routines for raw data (default case)
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-data.c,v 1.8 1999/03/23 03:14:36 gram Exp $
* $Id: packet-data.c,v 1.9 1999/07/07 22:51:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -35,12 +35,21 @@
#include <glib.h>
#include "packet.h"
int proto_data = -1;
void
dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (fd->cap_len > offset && tree) {
proto_tree_add_item(tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
proto_tree_add_item_format(tree, proto_data, offset,
END_OF_FRAME, NULL, "Data (%d bytes)", END_OF_FRAME);
}
}
void
proto_register_data(void)
{
proto_data = proto_register_protocol (
/* name */ "Data",
/* abbrev */ "data" );
}

View File

@ -1,7 +1,7 @@
/* packet-dns.c
* Routines for DNS packet disassembly
*
* $Id: packet-dns.c,v 1.18 1999/05/27 05:35:07 guy Exp $
* $Id: packet-dns.c,v 1.19 1999/07/07 22:51:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -416,18 +416,17 @@ dissect_dns_query(const u_char *dns_data_ptr, const u_char *pd, int offset,
class_name = dns_class_name(class);
long_type_name = dns_long_type_name(type);
tq = proto_tree_add_item(dns_tree, offset, len, "%s: type %s, class %s",
tq = proto_tree_add_text(dns_tree, offset, len, "%s: type %s, class %s",
name, type_name, class_name);
q_tree = proto_tree_new();
proto_item_add_subtree(tq, q_tree, ETT_DNS_QD);
q_tree = proto_item_add_subtree(tq, ETT_DNS_QD);
proto_tree_add_item(q_tree, offset, name_len, "Name: %s", name);
proto_tree_add_text(q_tree, offset, name_len, "Name: %s", name);
offset += name_len;
proto_tree_add_item(q_tree, offset, 2, "Type: %s", long_type_name);
proto_tree_add_text(q_tree, offset, 2, "Type: %s", long_type_name);
offset += 2;
proto_tree_add_item(q_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_text(q_tree, offset, 2, "Class: %s", class_name);
offset += 2;
return dptr - data_start;
@ -441,18 +440,17 @@ add_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
{
proto_tree *rr_tree;
rr_tree = proto_tree_new();
proto_item_add_subtree(trr, rr_tree, rr_type);
proto_tree_add_item(rr_tree, offset, namelen, "Name: %s", name);
rr_tree = proto_item_add_subtree(trr, rr_type);
proto_tree_add_text(rr_tree, offset, namelen, "Name: %s", name);
offset += namelen;
proto_tree_add_item(rr_tree, offset, 2, "Type: %s", type_name);
proto_tree_add_text(rr_tree, offset, 2, "Type: %s", type_name);
offset += 2;
proto_tree_add_item(rr_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_text(rr_tree, offset, 2, "Class: %s", class_name);
offset += 2;
proto_tree_add_item(rr_tree, offset, 4, "Time to live: %s",
proto_tree_add_text(rr_tree, offset, 4, "Time to live: %s",
time_secs_to_str(ttl));
offset += 4;
proto_tree_add_item(rr_tree, offset, 2, "Data length: %u", data_len);
proto_tree_add_text(rr_tree, offset, 2, "Data length: %u", data_len);
return rr_tree;
}
@ -494,14 +492,14 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
switch (type) {
case T_A:
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, addr %s",
name, type_name, class_name,
ip_to_str((guint8 *)dptr));
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, 4, "Addr: %s",
proto_tree_add_text(rr_tree, offset, 4, "Addr: %s",
ip_to_str((guint8 *)dptr));
break;
@ -511,13 +509,13 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
int ns_name_len;
ns_name_len = get_dns_name(dns_data_ptr, dptr, ns_name, sizeof(ns_name));
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, ns %s",
name, type_name, class_name, ns_name);
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, ns_name_len, "Name server: %s", ns_name);
proto_tree_add_text(rr_tree, offset, ns_name_len, "Name server: %s", ns_name);
}
break;
@ -527,13 +525,13 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
int cname_len;
cname_len = get_dns_name(dns_data_ptr, dptr, cname, sizeof(cname));
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, cname %s",
name, type_name, class_name, cname);
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, cname_len, "Primary name: %s", cname);
proto_tree_add_text(rr_tree, offset, cname_len, "Primary name: %s", cname);
}
break;
@ -552,42 +550,42 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
rrptr = dptr;
mname_len = get_dns_name(dns_data_ptr, rrptr, mname, sizeof(mname));
rrptr += mname_len;
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, mname %s",
name, type_name, class_name, mname);
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, mname_len, "Primary name server: %s",
proto_tree_add_text(rr_tree, offset, mname_len, "Primary name server: %s",
mname);
offset += mname_len;
rname_len = get_dns_name(dns_data_ptr, rrptr, rname, sizeof(rname));
proto_tree_add_item(rr_tree, offset, rname_len, "Responsible authority's mailbox: %s",
proto_tree_add_text(rr_tree, offset, rname_len, "Responsible authority's mailbox: %s",
rname);
rrptr += rname_len;
offset += rname_len;
serial = pntohl(rrptr);
proto_tree_add_item(rr_tree, offset, 4, "Serial number: %u",
proto_tree_add_text(rr_tree, offset, 4, "Serial number: %u",
serial);
rrptr += 4;
offset += 4;
refresh = pntohl(rrptr);
proto_tree_add_item(rr_tree, offset, 4, "Refresh interval: %s",
proto_tree_add_text(rr_tree, offset, 4, "Refresh interval: %s",
time_secs_to_str(refresh));
rrptr += 4;
offset += 4;
retry = pntohl(rrptr);
proto_tree_add_item(rr_tree, offset, 4, "Retry interval: %s",
proto_tree_add_text(rr_tree, offset, 4, "Retry interval: %s",
time_secs_to_str(retry));
rrptr += 4;
offset += 4;
expire = pntohl(rrptr);
proto_tree_add_item(rr_tree, offset, 4, "Expiration limit: %s",
proto_tree_add_text(rr_tree, offset, 4, "Expiration limit: %s",
time_secs_to_str(expire));
rrptr += 4;
offset += 4;
minimum = pntohl(rrptr);
proto_tree_add_item(rr_tree, offset, 4, "Minimum TTL: %s",
proto_tree_add_text(rr_tree, offset, 4, "Minimum TTL: %s",
time_secs_to_str(minimum));
}
break;
@ -598,13 +596,13 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
int pname_len;
pname_len = get_dns_name(dns_data_ptr, dptr, pname, sizeof(pname));
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s, ptr %s",
name, type_name, class_name, pname);
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, pname_len, "Domain name: %s", pname);
proto_tree_add_text(rr_tree, offset, pname_len, "Domain name: %s", pname);
break;
}
break;
@ -612,13 +610,13 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
/* TODO: parse more record types */
default:
trr = proto_tree_add_item(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_text(dns_tree, offset, (dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
rr_tree = add_rr_to_tree(trr, ETT_DNS_RR, offset, name, name_len,
long_type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, data_len, "Data");
proto_tree_add_text(rr_tree, offset, data_len, "Data");
}
dptr += data_len;
@ -635,9 +633,8 @@ dissect_query_records(const u_char *dns_data_ptr, int count, const u_char *pd,
proto_item *ti;
start_off = cur_off;
ti = proto_tree_add_item(dns_tree, start_off, 0, "Queries");
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_DNS_QRY);
ti = proto_tree_add_text(dns_tree, start_off, 0, "Queries");
qatree = proto_item_add_subtree(ti, ETT_DNS_QRY);
while (count-- > 0)
cur_off += dissect_dns_query(dns_data_ptr, pd, cur_off, qatree);
proto_item_set_len(ti, cur_off - start_off);
@ -657,9 +654,8 @@ dissect_answer_records(const u_char *dns_data_ptr, int count,
proto_item *ti;
start_off = cur_off;
ti = proto_tree_add_item(dns_tree, start_off, 0, name);
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_DNS_ANS);
ti = proto_tree_add_text(dns_tree, start_off, 0, name);
qatree = proto_item_add_subtree(ti, ETT_DNS_ANS);
while (count-- > 0)
cur_off += dissect_dns_answer(dns_data_ptr, pd, cur_off, qatree);
proto_item_set_len(ti, cur_off - start_off);
@ -710,13 +706,12 @@ dissect_dns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree, offset, 4,
ti = proto_tree_add_text(tree, offset, 4,
(flags & F_RESPONSE) ? "DNS response" : "DNS query");
dns_tree = proto_tree_new();
proto_item_add_subtree(ti, dns_tree, ETT_DNS);
dns_tree = proto_item_add_subtree(ti, ETT_DNS);
proto_tree_add_item(dns_tree, offset + DNS_ID, 2, "Transaction ID: 0x%04x",
proto_tree_add_text(dns_tree, offset + DNS_ID, 2, "Transaction ID: 0x%04x",
id);
strcpy(buf, val_to_str(flags & F_OPCODE, opcode_vals, "Unknown operation"));
@ -726,47 +721,46 @@ dissect_dns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
"Unknown error"));
}
tf = proto_tree_add_item(dns_tree, offset + DNS_FLAGS, 2, "Flags: 0x%04x (%s)",
tf = proto_tree_add_text(dns_tree, offset + DNS_FLAGS, 2, "Flags: 0x%04x (%s)",
flags, buf);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_DNS_FLAGS);
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
field_tree = proto_item_add_subtree(tf, ETT_DNS_FLAGS);
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_RESPONSE,
2*8, "Response", "Query"));
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_enumerated_bitfield(flags, F_OPCODE,
2*8, opcode_vals, "%s"));
if (flags & F_RESPONSE) {
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_AUTHORITATIVE,
2*8,
"Server is an authority for domain",
"Server isn't an authority for domain"));
}
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_TRUNCATED,
2*8,
"Message is truncated",
"Message is not truncated"));
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_RECDESIRED,
2*8,
"Do query recursively",
"Don't do query recursively"));
if (flags & F_RESPONSE) {
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_RECAVAIL,
2*8,
"Server can do recursive queries",
"Server can't do recursive queries"));
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_enumerated_bitfield(flags, F_RCODE,
2*8, rcode_vals, "%s"));
}
proto_tree_add_item(dns_tree, offset + DNS_QUEST, 2, "Questions: %d", quest);
proto_tree_add_item(dns_tree, offset + DNS_ANS, 2, "Answer RRs: %d", ans);
proto_tree_add_item(dns_tree, offset + DNS_AUTH, 2, "Authority RRs: %d", auth);
proto_tree_add_item(dns_tree, offset + DNS_ADD, 2, "Additional RRs: %d", add);
proto_tree_add_text(dns_tree, offset + DNS_QUEST, 2, "Questions: %d", quest);
proto_tree_add_text(dns_tree, offset + DNS_ANS, 2, "Answer RRs: %d", ans);
proto_tree_add_text(dns_tree, offset + DNS_AUTH, 2, "Authority RRs: %d", auth);
proto_tree_add_text(dns_tree, offset + DNS_ADD, 2, "Additional RRs: %d", add);
cur_off = offset + DNS_HDRLEN;

View File

@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
* $Id: packet-eth.c,v 1.9 1999/03/23 03:14:37 gram Exp $
* $Id: packet-eth.c,v 1.10 1999/07/07 22:51:42 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -36,6 +36,17 @@
#include "etypes.h"
#include "resolv.h"
extern const value_string etype_vals[];
/* protocols and header fields */
int proto_eth = -1;
int hf_eth_dst = -1;
int hf_eth_dst_vendor = -1;
int hf_eth_src = -1;
int hf_eth_src_vendor = -1;
int hf_eth_len = -1;
int hf_eth_type = -1;
#define IEEE_802_3_MAX_LEN 1500
/* These are the Netware-ish names for the different Ethernet frame types.
@ -135,32 +146,36 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
if (check_col(fd, COL_INFO))
col_add_str(fd, COL_INFO, "802.3");
if (tree) {
ti = proto_tree_add_item(tree, 0, offset,
"IEEE 802.3 %s", (ethhdr_type == ETHERNET_802_3 ? "Raw " : ""));
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_IEEE8023);
proto_tree_add_item(fh_tree, 0, 6, "Destination: %s (%s)",
ether_to_str((guint8 *) &pd[0]),
get_ether_name((u_char *) &pd[0]));
proto_tree_add_item(fh_tree, 6, 6, "Source: %s (%s)",
ether_to_str((guint8 *) &pd[6]),
get_ether_name((u_char *)&pd[6]));
proto_tree_add_item(fh_tree, 12, 2, "Length: %d", length);
ti = proto_tree_add_item_format(tree, proto_eth, 0, offset,
NULL, "IEEE 802.3 %s", (ethhdr_type == ETHERNET_802_3 ? "Raw " : ""));
fh_tree = proto_item_add_subtree(ti, ETT_IEEE8023);
proto_tree_add_item(fh_tree, hf_eth_dst, 0, 6, &pd[0]);
proto_tree_add_item_hidden(fh_tree, hf_eth_dst_vendor, 0, 3, &pd[0]);
proto_tree_add_item(fh_tree, hf_eth_src, 6, 6, &pd[6]);
proto_tree_add_item_hidden(fh_tree, hf_eth_src_vendor, 6, 3, &pd[6]);
proto_tree_add_item(fh_tree, hf_eth_len, 12, 2, length);
}
} else {
ethhdr_type = ETHERNET_II;
if (tree) {
ti = proto_tree_add_item(tree, 0, 14, "Ethernet II");
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_ETHER2);
proto_tree_add_item(fh_tree, 0, 6, "Destination: %s (%s)",
ether_to_str((guint8 *) &pd[0]),
get_ether_name((u_char *)&pd[0]));
proto_tree_add_item(fh_tree, 6, 6, "Source: %s (%s)",
ether_to_str((guint8 *) &pd[6]),
get_ether_name((u_char *)&pd[6]));
ti = proto_tree_add_item_format(tree, proto_eth, 0, 14, NULL,
"Ethernet II");
fh_tree = proto_item_add_subtree(ti, ETT_ETHER2);
proto_tree_add_item_format(fh_tree, hf_eth_dst, 0, 6, &pd[0],
"Destination: %s (%s)", ether_to_str((guint8 *) &pd[0]),
get_ether_name((u_char *) &pd[0]));
proto_tree_add_item_format(fh_tree, hf_eth_src, 6, 6, &pd[6],
"Source: %s (%s)", ether_to_str((guint8 *) &pd[6]),
get_ether_name((u_char *) &pd[6]));
}
}
@ -172,8 +187,58 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
dissect_llc(pd, offset, fd, tree);
break;
case ETHERNET_II:
ethertype(etype, offset, pd, fd, tree, fh_tree);
ethertype(etype, offset, pd, fd, tree, fh_tree, hf_eth_type);
break;
}
}
void
proto_register_eth(void)
{
proto_eth = proto_register_protocol (
/* name */ "Ethernet",
/* abbrev */ "eth" );
hf_eth_dst = proto_register_field (
/* name */ "Destination",
/* abbrev */ "eth.dst",
/* ftype */ FT_ETHER,
/* parent */ proto_eth,
/* vals[] */ NULL );
hf_eth_src = proto_register_field (
/* name */ "Source",
/* abbrev */ "eth.src",
/* ftype */ FT_ETHER,
/* parent */ proto_eth,
/* vals[] */ NULL );
hf_eth_dst_vendor = proto_register_field (
/* name */ "Destination Hardware Vendor",
/* abbrev */ "eth.dst_vendor",
/* ftype */ FT_ETHER_VENDOR,
/* parent */ proto_eth,
/* vals[] */ NULL );
hf_eth_src_vendor = proto_register_field (
/* name */ "Source Hardware Vendor",
/* abbrev */ "eth.src_vendor",
/* ftype */ FT_ETHER_VENDOR,
/* parent */ proto_eth,
/* vals[] */ NULL );
hf_eth_len = proto_register_field (
/* name */ "Length",
/* abbrev */ "eth.len",
/* ftype */ FT_UINT16,
/* parent */ proto_eth,
/* vals[] */ NULL );
/* registered here but handled in ethertype.c */
hf_eth_type = proto_register_field (
/* name */ "Type",
/* abbrev */ "eth.type",
/* ftype */ FT_VALS_UINT16,
/* parent */ proto_eth,
/* vals[] */ VALS(etype_vals) );
}

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
* $Id: packet-fddi.c,v 1.11 1999/03/23 03:14:37 gram Exp $
* $Id: packet-fddi.c,v 1.12 1999/07/07 22:51:42 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -37,6 +37,13 @@
#include "packet.h"
#include "resolv.h"
int proto_fddi = -1;
int hf_fddi_fc = -1;
int hf_fddi_dst = -1;
int hf_fddi_dst_vendor = -1;
int hf_fddi_src = -1;
int hf_fddi_src_vendor = -1;
/* FDDI Frame Control values */
#define FDDI_FC_VOID 0x00 /* Void frame */
@ -128,6 +135,17 @@ static void get_mac_addr(u_char *swapped_addr, const u_char *addr)
}
}
static void
swap_mac_addr(u_char *swapped_addr, const u_char *orig_addr)
{
int i;
for (i = 0; i < 6; i++) {
swapped_addr[i] = swaptab[orig_addr[i]];
}
}
void
capture_fddi(const u_char *pd, guint32 cap_len, packet_counts *ld) {
int offset = 0, fc;
@ -162,7 +180,6 @@ capture_fddi(const u_char *pd, guint32 cap_len, packet_counts *ld) {
case FDDI_FC_LLC_ASYNC + 15 :
capture_llc(pd, offset, cap_len, ld);
return;
default :
ld->other++;
return;
@ -177,6 +194,7 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
proto_tree *fh_tree;
proto_item *ti;
u_char src[6], dst[6];
u_char src_swapped[6], dst_swapped[6];
if (fd->cap_len < FDDI_HEADER_SIZE) {
dissect_data(pd, offset, fd, tree);
@ -206,20 +224,28 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
offset = FDDI_HEADER_SIZE;
if (tree) {
ti = proto_tree_add_item(tree, 0, offset,
"FDDI %s",
(fc >= FDDI_FC_LLC_ASYNC_MIN && fc <= FDDI_FC_LLC_ASYNC_MAX) ?
ti = proto_tree_add_item_format(tree, proto_fddi, 0, offset, NULL,
"Fiber Distributed Data Interface, %s",
(fc >= FDDI_FC_LLC_ASYNC_MIN && fc <= FDDI_FC_LLC_ASYNC_MAX) ?
"Async LLC" : "unsupported FC");
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_FDDI);
proto_tree_add_item(fh_tree, FDDI_P_FC, 1, "Frame Control: 0x%02x", fc);
proto_tree_add_item(fh_tree, FDDI_P_DHOST, 6, "Destination: %s (%s)",
ether_to_str(dst), get_ether_name(dst));
proto_tree_add_item(fh_tree, FDDI_P_SHOST, 6, "Source: %s (%s)",
ether_to_str(src), get_ether_name(src));
}
swap_mac_addr(dst_swapped, (u_char*)&pd[FDDI_P_DHOST]);
swap_mac_addr(src_swapped, (u_char*)&pd[FDDI_P_SHOST]);
fh_tree = proto_item_add_subtree(ti, ETT_FDDI);
proto_tree_add_item(fh_tree, hf_fddi_fc, FDDI_P_FC, 1, fc);
proto_tree_add_item(fh_tree, hf_fddi_dst, FDDI_P_DHOST, 6, dst);
proto_tree_add_item_hidden(fh_tree, hf_fddi_dst_vendor, FDDI_P_DHOST, 3, dst);
proto_tree_add_item(fh_tree, hf_fddi_src, FDDI_P_SHOST, 6, src);
proto_tree_add_item_hidden(fh_tree, hf_fddi_src_vendor, FDDI_P_SHOST, 3, src);
/* hide some bit-swapped mac address fields in the proto_tree, just in case */
proto_tree_add_item_hidden(fh_tree, hf_fddi_dst, FDDI_P_DHOST, 6, dst_swapped);
proto_tree_add_item_hidden(fh_tree, hf_fddi_dst, FDDI_P_SHOST, 6, src_swapped);
proto_tree_add_item_hidden(fh_tree, hf_fddi_dst_vendor, FDDI_P_DHOST, 3, dst_swapped);
proto_tree_add_item_hidden(fh_tree, hf_fddi_src_vendor, FDDI_P_SHOST, 3, src_swapped);
}
switch (fc) {
/* From now, only 802.2 SNAP (Async. LCC frame) is supported */
@ -248,5 +274,47 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
return;
} /* fc */
} /* dissect_fddi */
void
proto_register_fddi(void)
{
proto_fddi = proto_register_protocol (
/* name */ "Fiber Distributed Data Interface",
/* abbrev */ "fddi" );
hf_fddi_fc = proto_register_field (
/* name */ "Frame Control",
/* abbrev */ "fddi.fc",
/* ftype */ FT_UINT8,
/* parent */ proto_fddi,
/* vals[] */ NULL );
hf_fddi_dst = proto_register_field (
/* name */ "Destination",
/* abbrev */ "fddi.dst",
/* ftype */ FT_ETHER,
/* parent */ proto_fddi,
/* vals[] */ NULL );
hf_fddi_src = proto_register_field (
/* name */ "Source",
/* abbrev */ "fddi.src",
/* ftype */ FT_ETHER,
/* parent */ proto_fddi,
/* vals[] */ NULL );
hf_fddi_dst_vendor = proto_register_field (
/* name */ "Destination Hardware Vendor",
/* abbrev */ "fddi.dst_vendor",
/* ftype */ FT_ETHER_VENDOR,
/* parent */ proto_fddi,
/* vals[] */ NULL );
hf_fddi_src_vendor = proto_register_field (
/* name */ "Source Hardware Vendor",
/* abbrev */ "fddi.src_vendor",
/* ftype */ FT_ETHER_VENDOR,
/* parent */ proto_fddi,
/* vals[] */ NULL );
}

View File

@ -2,7 +2,7 @@
* Routines for ftp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-ftp.c,v 1.3 1999/05/13 01:05:11 sharpe Exp $
* $Id: packet-ftp.c,v 1.4 1999/07/07 22:51:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -92,23 +92,22 @@ dissect_ftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"File Transfer Protocol");
ftp_tree = proto_tree_new();
proto_item_add_subtree(ti, ftp_tree, ETT_FTP);
ftp_tree = proto_item_add_subtree(ti, ETT_FTP);
if (pi.match_port == pi.destport) { /* Request */
proto_tree_add_item(ftp_tree, offset, i1, "Request: %s", rr);
proto_tree_add_text(ftp_tree, offset, i1, "Request: %s", rr);
proto_tree_add_item(ftp_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
proto_tree_add_text(ftp_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
}
else {
proto_tree_add_item(ftp_tree, offset, i1, "Response: %s", rr);
proto_tree_add_text(ftp_tree, offset, i1, "Response: %s", rr);
proto_tree_add_item(ftp_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
proto_tree_add_text(ftp_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
}
}
@ -130,7 +129,7 @@ dissect_ftpdata(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"File Transfer Protocol Data");
}

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
* $Id: packet-giop.c,v 1.2 1999/03/23 03:14:37 gram Exp $
* $Id: packet-giop.c,v 1.3 1999/07/07 22:51:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -258,27 +258,26 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
ti = proto_tree_add_item(tree, offset,
ti = proto_tree_add_text(tree, offset,
GIOP_HEADER_SIZE + message_size,
"General Inter-ORB Protocol");
clnp_tree = proto_tree_new();
proto_item_add_subtree(ti, clnp_tree, ETT_GIOP);
proto_tree_add_item(clnp_tree, offset, 4,
clnp_tree = proto_item_add_subtree(ti, ETT_GIOP);
proto_tree_add_text(clnp_tree, offset, 4,
"Magic number: %s", GIOP_MAGIC);
proto_tree_add_item(clnp_tree, offset + 4, 2,
proto_tree_add_text(clnp_tree, offset + 4, 2,
"Version: %d.%d",
header.GIOP_version.major,
header.GIOP_version.minor);
switch(minor_version) {
case 1 :
proto_tree_add_item(clnp_tree, offset + 6, 1,
proto_tree_add_text(clnp_tree, offset + 6, 1,
"Flags: 0x%02x (%s%s)",
header.flags,
(big_endian) ? "little" : "big",
(header.flags & 0x02) ? " fragment" : "");
break;
case 0 :
proto_tree_add_item(clnp_tree, offset + 6, 1,
proto_tree_add_text(clnp_tree, offset + 6, 1,
"Byte ordering: %s endian",
(big_endian) ? "little" : "big");
break;
@ -286,7 +285,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
break;
} /* minor_version */
proto_tree_add_item(clnp_tree, offset + 7, 1,
proto_tree_add_text(clnp_tree, offset + 7, 1,
"Message type: %s",
(header.message_type == Request) ? "Request" :
(header.message_type == Reply) ? "Reply" :
@ -297,7 +296,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
(header.message_type == MessageError) ? "MessageError" :
(header.message_type == Fragment) ? "Fragment" : "?");
proto_tree_add_item(clnp_tree, offset + 8, 4,
proto_tree_add_text(clnp_tree, offset + 8, 4,
"Message size: %d", message_size);
} /* tree */
@ -332,12 +331,12 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(context_id),
proto_tree_add_text(clnp_tree, offset, sizeof(context_id),
"Context id: %d", context_id);
proto_tree_add_item(clnp_tree, offset + sizeof(context_id),
proto_tree_add_text(clnp_tree, offset + sizeof(context_id),
sizeof(sequence_length),
"Sequence length: %d", sequence_length);
proto_tree_add_item(clnp_tree,
proto_tree_add_text(clnp_tree,
offset +
sizeof(context_id) + sizeof(sequence_length),
sequence_length,
@ -367,13 +366,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
request_id = (big_endian)? pntohl(&request_1_1.request_id) :
pletohl(&request_1_1.request_id);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
proto_tree_add_text(clnp_tree, offset + sizeof(request_id),
sizeof(request_1_1.response_expected),
"Response expected: %d",
response_expected);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id) +
proto_tree_add_text(clnp_tree, offset + sizeof(request_id) +
sizeof(request_1_1.response_expected),
3,
"Reserved");
@ -387,9 +386,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
request_id = (big_endian)? pntohl(&request_1_0.request_id) :
pletohl(&request_1_0.request_id);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
proto_tree_add_text(clnp_tree, offset + sizeof(request_id),
sizeof(request_1_0.response_expected),
"Response expected: %d",
response_expected);
@ -412,9 +411,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pntohl(&pd[offset]) : pletohl(&pd[offset]);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset, sizeof(sequence_length),
"Object key length: %d", sequence_length);
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Object key: %s",
print_object_key(sequence_length,
@ -435,13 +434,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset, sizeof(sequence_length),
"Operation length: %d", sequence_length);
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Operation: %s",
&pd[offset+sizeof(sequence_length)]);
proto_tree_add_item(clnp_tree, offset +
proto_tree_add_text(clnp_tree, offset +
sizeof(sequence_length)+ sequence_length,
message_size - END_OF_GIOP_MESSAGE -
sizeof(sequence_length) - sequence_length,
@ -466,9 +465,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pntohl(&reply.reply_status) : pletohl(&reply.reply_status);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
proto_tree_add_text(clnp_tree, offset + sizeof(request_id),
sizeof(reply_status),
"Reply status: %s",
reply_status == NO_EXCEPTION ? "no exception" :
@ -504,9 +503,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset, sizeof(sequence_length),
"Exception length: %d", sequence_length);
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception id: %s",
&pd[offset+sizeof(sequence_length)]);
@ -522,9 +521,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pletohl(&pd[offset+sizeof(minor_code_value)]);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(minor_code_value),
proto_tree_add_text(clnp_tree, offset, sizeof(minor_code_value),
"Minor code value: %d", minor_code_value);
proto_tree_add_item(clnp_tree, offset + sizeof(minor_code_value),
proto_tree_add_text(clnp_tree, offset + sizeof(minor_code_value),
sizeof(completion_status),
"Completion Status: %d",
completion_status);
@ -543,9 +542,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset, sizeof(sequence_length),
"Exception length: %d", sequence_length);
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception id: %s",
&pd[offset+sizeof(sequence_length)]);
@ -563,9 +562,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree && sequence_length) {
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset, sizeof(sequence_length),
"Exception member length: %d", sequence_length);
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_text(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception member: %s",
&pd[offset+sizeof(sequence_length)]);
@ -577,7 +576,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
else {
if (tree) {
proto_tree_add_item(clnp_tree, offset,
proto_tree_add_text(clnp_tree, offset,
message_size - END_OF_GIOP_MESSAGE,
"Reply body: <not shown>");
}
@ -597,13 +596,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pletohl(&pd[offset+sizeof(request_id)]);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
proto_tree_add_text(clnp_tree, offset + sizeof(request_id),
sizeof(sequence_length),
"Object key length: %d", sequence_length);
offset += sizeof(request_id) + sizeof(sequence_length);
proto_tree_add_item(clnp_tree,
proto_tree_add_text(clnp_tree,
offset,
sequence_length,
"Object key: %s",
@ -626,14 +625,14 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pntohl(&locate_rep.locate_status) : pletohl(&locate_rep.locate_status);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
proto_tree_add_text(clnp_tree, offset + sizeof(request_id),
sizeof(locate_status),
"Locate status: %d", locate_status);
offset += sizeof(request_id) + sizeof(locate_status);
if (locate_status == OBJECT_FORWARD) {
proto_tree_add_item(clnp_tree, offset,
proto_tree_add_text(clnp_tree, offset,
message_size - END_OF_GIOP_MESSAGE,
"Locate reply body: <not shown>");
}
@ -655,7 +654,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
pntohl(&pd[offset]) : pletohl(&pd[offset]);
if (tree) {
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
proto_tree_add_text(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
}

View File

@ -2,7 +2,7 @@
* Routines for the Generic Routing Encapsulation (GRE) protocol
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-gre.c,v 1.1 1999/06/11 15:30:37 gram Exp $
* $Id: packet-gre.c,v 1.2 1999/07/07 22:51:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -80,38 +80,36 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (type == GRE_PPP) {
is_ppp = 1;
ti = proto_tree_add_item(tree, offset, calc_len(flags_and_ver, 1),
ti = proto_tree_add_text(tree, offset, calc_len(flags_and_ver, 1),
"Generic Routing Encapsulation (PPP)");
gre_tree = proto_tree_new();
proto_item_add_subtree(ti, gre_tree, ETT_GRE);
gre_tree = proto_item_add_subtree(ti, ETT_GRE);
add_flags_and_ver(gre_tree, flags_and_ver, offset, 1);
}
else {
is_ppp = 0;
ti = proto_tree_add_item(tree, offset, calc_len(flags_and_ver, 1),
ti = proto_tree_add_text(tree, offset, calc_len(flags_and_ver, 1),
"Generic Routing Encapsulation");
gre_tree = proto_tree_new();
proto_item_add_subtree(ti, gre_tree, ETT_GRE);
gre_tree = proto_item_add_subtree(ti, ETT_GRE);
add_flags_and_ver(gre_tree, flags_and_ver, offset, 0);
}
offset += sizeof(flags_and_ver);
proto_tree_add_item(gre_tree, offset, sizeof(type),
proto_tree_add_text(gre_tree, offset, sizeof(type),
"Protocol Type: %s (%#04x)",
val_to_str(type, typevals, "Unknown"), type);
offset += sizeof(type);
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
guint16 checksum = pntohs(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(checksum),
proto_tree_add_text(gre_tree, offset, sizeof(checksum),
"Checksum: %u", checksum);
offset += sizeof(checksum);
}
if (flags_and_ver & GH_B_C || flags_and_ver & GH_B_R) {
guint16 rtoffset = pntohs(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(rtoffset),
proto_tree_add_text(gre_tree, offset, sizeof(rtoffset),
"Offset: %u", rtoffset);
offset += sizeof(rtoffset);
}
@ -122,18 +120,18 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 callid;
paylen = pntohs(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(paylen),
proto_tree_add_text(gre_tree, offset, sizeof(paylen),
"Payload length: %u", paylen);
offset += sizeof(paylen);
callid = pntohs(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(callid),
proto_tree_add_text(gre_tree, offset, sizeof(callid),
"Call ID: %u", callid);
offset += sizeof(callid);
}
else {
guint32 key = pntohl(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(key),
proto_tree_add_text(gre_tree, offset, sizeof(key),
"Key: %u", key);
offset += sizeof(key);
}
@ -141,25 +139,25 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (flags_and_ver & GH_B_S) {
guint32 seqnum = pntohl(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(seqnum),
proto_tree_add_text(gre_tree, offset, sizeof(seqnum),
"Sequence number: %u", seqnum);
offset += sizeof(seqnum);
}
if (is_ppp && flags_and_ver & GH_P_A) {
guint32 acknum = pntohl(pd + offset);
proto_tree_add_item(gre_tree, offset, sizeof(acknum),
proto_tree_add_text(gre_tree, offset, sizeof(acknum),
"Acknowledgement number: %u", acknum);
offset += sizeof(acknum);
}
if (flags_and_ver & GH_B_R) {
proto_tree_add_item(gre_tree, offset, sizeof(guint16),
proto_tree_add_text(gre_tree, offset, sizeof(guint16),
"Address family: %u", pntohs(pd + offset));
offset += sizeof(guint16);
proto_tree_add_item(gre_tree, offset, 1,
proto_tree_add_text(gre_tree, offset, 1,
"SRE offset: %u", pd[offset++]);
proto_tree_add_item(gre_tree, offset, 1,
proto_tree_add_text(gre_tree, offset, 1,
"SRE length: %u", pd[offset++]);
}
@ -193,44 +191,43 @@ add_flags_and_ver(proto_tree *tree, guint16 flags_and_ver, int offset, int is_pp
proto_tree * fv_tree;
int nbits = sizeof(flags_and_ver) * 8;
ti = proto_tree_add_item(tree, offset, 2,
ti = proto_tree_add_text(tree, offset, 2,
"Flags and version: %#08x", flags_and_ver);
fv_tree = proto_tree_new();
proto_item_add_subtree(ti, fv_tree, ETT_GRE_FLAGS);
fv_tree = proto_item_add_subtree(ti, ETT_GRE_FLAGS);
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_B_C, nbits,
"Checksum", "No checksum"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_B_R, nbits,
"Routing", "No routing"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_B_K, nbits,
"Key", "No key"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_B_S, nbits,
"Sequence number", "No sequence number"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_B_s, nbits,
"Strict source route", "No strict source route"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_numeric_bitfield(flags_and_ver, GH_B_RECUR, nbits,
"Recursion control: %u"));
if (is_ppp) {
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_boolean_bitfield(flags_and_ver, GH_P_A, nbits,
"Acknowledgment number", "No acknowledgment number"));
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_numeric_bitfield(flags_and_ver, GH_P_FLAGS, nbits,
"Flags: %u"));
}
else {
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_numeric_bitfield(flags_and_ver, GH_R_FLAGS, nbits,
"Flags: %u"));
}
proto_tree_add_item(fv_tree, offset, sizeof(flags_and_ver), "%s",
proto_tree_add_text(fv_tree, offset, sizeof(flags_and_ver), "%s",
decode_numeric_bitfield(flags_and_ver, GH_B_VER, nbits,
"Version: %u"));
}

View File

@ -3,7 +3,7 @@
*
* Guy Harris <guy@netapp.com>
*
* $Id: packet-http.c,v 1.3 1999/03/30 04:41:01 guy Exp $
* $Id: packet-http.c,v 1.4 1999/07/07 22:51:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -70,10 +70,9 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Hypertext Transfer Protocol");
http_tree = proto_tree_new();
proto_item_add_subtree(ti, http_tree, ETT_HTTP);
http_tree = proto_item_add_subtree(ti, ETT_HTTP);
while (data < dataend) {
/*
@ -160,14 +159,14 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
/*
* Put this line.
*/
proto_tree_add_item(http_tree, offset, linelen, "%s",
proto_tree_add_text(http_tree, offset, linelen, "%s",
format_text(data, linelen));
offset += linelen;
data = lineend;
}
if (data < dataend) {
proto_tree_add_item(http_tree, offset, END_OF_FRAME,
proto_tree_add_text(http_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
}
}

View File

@ -1,7 +1,7 @@
/* packet-icmpv6.c
* Routines for ICMPv6 packet disassembly
*
* $Id: packet-icmpv6.c,v 1.2 1999/03/29 02:24:29 gram Exp $
* $Id: packet-icmpv6.c,v 1.3 1999/07/07 22:51:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -79,9 +79,8 @@ again:
len = opt->nd_opt_len << 3;
/* !!! specify length */
ti = proto_tree_add_item(tree, offset, len, "ICMPv6 options");
icmp6opt_tree = proto_tree_new();
proto_item_add_subtree(ti, icmp6opt_tree, ETT_ICMPv6OPT);
ti = proto_tree_add_text(tree, offset, len, "ICMPv6 options");
icmp6opt_tree = proto_item_add_subtree(ti, ETT_ICMPv6OPT);
switch (opt->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
@ -104,10 +103,10 @@ again:
break;
}
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_hdr, nd_opt_type), 1,
"Type: 0x%02x (%s)", opt->nd_opt_type, typename);
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_hdr, nd_opt_len), 1,
"Length: %d bytes (0x%02x)", opt->nd_opt_len << 3, opt->nd_opt_len);
@ -128,7 +127,7 @@ again:
t[i * 3 - 1] = ':';
sprintf(&t[i * 3], "%02x", p[i] & 0xff);
}
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + sizeof(*opt), len, "Link-layer address: %s", t);
break;
}
@ -136,37 +135,36 @@ again:
{
struct nd_opt_prefix_info *pi = (struct nd_opt_prefix_info *)opt;
int flagoff;
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_prefix_len),
1, "Prefix length: %d", pi->nd_opt_pi_prefix_len);
flagoff = offsetof(struct nd_opt_prefix_info, nd_opt_pi_flags_reserved);
tf = proto_tree_add_item(icmp6opt_tree, flagoff, 1, "Flags: 0x%02x",
tf = proto_tree_add_text(icmp6opt_tree, flagoff, 1, "Flags: 0x%02x",
pntohl(&pi->nd_opt_pi_flags_reserved));
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_ICMPv6FLAG);
proto_tree_add_item(field_tree, flagoff, 1, "%s",
field_tree = proto_item_add_subtree(tf, ETT_ICMPv6FLAG);
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pi->nd_opt_pi_flags_reserved,
0x80, 8, "Onlink", "Not onlink"));
proto_tree_add_item(field_tree, flagoff, 1, "%s",
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pi->nd_opt_pi_flags_reserved,
0x40, 8, "Auto", "Not auto"));
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_valid_time),
4, "Valid lifetime: 0x%08x",
pntohl(&pi->nd_opt_pi_valid_time));
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_preferred_time),
4, "Preferred lifetime: 0x%08x",
pntohl(&pi->nd_opt_pi_preferred_time));
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_prefix),
16, "Prefix: %s", ip6_to_str(&pi->nd_opt_pi_prefix));
break;
}
case ND_OPT_REDIRECTED_HEADER:
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + 8, (opt->nd_opt_len << 3) - 8, "Redirected packet");
/* tiny sanity check */
if ((pd[offset + 8] & 0xf0) == 0x60)
@ -177,7 +175,7 @@ again:
case ND_OPT_MTU:
{
struct nd_opt_mtu *pi = (struct nd_opt_mtu *)opt;
proto_tree_add_item(icmp6opt_tree,
proto_tree_add_text(icmp6opt_tree,
offset + offsetof(struct nd_opt_mtu, nd_opt_mtu_mtu), 4,
"MTU: %d", pi->nd_opt_mtu_mtu);
break;
@ -332,20 +330,19 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (tree) {
/* !!! specify length */
ti = proto_tree_add_item(tree, offset, len,
ti = proto_tree_add_text(tree, offset, len,
"ICMPv6");
icmp6_tree = proto_tree_new();
proto_item_add_subtree(ti, icmp6_tree, ETT_ICMPv6);
icmp6_tree = proto_item_add_subtree(ti, ETT_ICMPv6);
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_type), 1,
"Type: 0x%02x (%s)", dp->icmp6_type, typename);
if (codename) {
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_code), 1,
"Code: 0x%02x (%s)", dp->icmp6_code, codename);
}
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_cksum), 2,
"Checksum: 0x%04x", (guint16)htons(dp->icmp6_cksum));
@ -361,7 +358,7 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
break;
case ICMP6_PACKET_TOO_BIG:
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_mtu), 4,
"MTU: %d", pntohl(&dp->icmp6_mtu));
/* tiny sanity check */
@ -372,7 +369,7 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
break;
case ICMP6_PARAM_PROB:
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_pptr), 4,
"Problem pointer: 0x%04x", pntohl(&dp->icmp6_pptr));
/* tiny sanity check */
@ -384,10 +381,10 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
break;
case ICMP6_ECHO_REQUEST:
case ICMP6_ECHO_REPLY:
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_id), 2,
"ID: 0x%04x", (guint16)ntohs(dp->icmp6_id));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_seq), 2,
"Sequence: 0x%04x", (guint16)ntohs(dp->icmp6_seq));
dissect_data(pd, offset + sizeof(*dp), fd, icmp6_tree);
@ -395,11 +392,11 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case ICMP6_MEMBERSHIP_QUERY:
case ICMP6_MEMBERSHIP_REPORT:
case ICMP6_MEMBERSHIP_REDUCTION:
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_hdr, icmp6_maxdelay), 2,
"Maximum response delay: %d",
(guint16)ntohs(dp->icmp6_maxdelay));
proto_tree_add_item(icmp6_tree, offset + sizeof(*dp), 16,
proto_tree_add_text(icmp6_tree, offset + sizeof(*dp), 16,
"Multicast Address: %s",
ip6_to_str((struct e_in6_addr *)(dp + 1)));
break;
@ -412,30 +409,29 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
int flagoff;
guint32 ra_flags;
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_router_advert, nd_ra_curhoplimit),
1, "Cur hop limit: %d", ra->nd_ra_curhoplimit);
flagoff = offset + offsetof(struct nd_router_advert, nd_ra_flags_reserved);
ra_flags = pntohl(&pd[flagoff]);
tf = proto_tree_add_item(icmp6_tree, flagoff, 4, "Flags: 0x%08x", ra_flags);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_ICMPv6FLAG);
proto_tree_add_item(field_tree, flagoff, 4, "%s",
tf = proto_tree_add_text(icmp6_tree, flagoff, 4, "Flags: 0x%08x", ra_flags);
field_tree = proto_item_add_subtree(tf, ETT_ICMPv6FLAG);
proto_tree_add_text(field_tree, flagoff, 4, "%s",
decode_boolean_bitfield(ra_flags,
0x80000000, 32, "Managed", "Not managed"));
proto_tree_add_item(field_tree, flagoff, 4, "%s",
proto_tree_add_text(field_tree, flagoff, 4, "%s",
decode_boolean_bitfield(ra_flags,
0x40000000, 32, "Other", "Not other"));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_router_advert, nd_ra_router_lifetime),
2, "Router lifetime: %d",
(guint16)ntohs(ra->nd_ra_router_lifetime));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_router_advert, nd_ra_reachable), 4,
"Reachable time: %d", pntohl(&ra->nd_ra_reachable));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_router_advert, nd_ra_retransmit), 4,
"Retrans time: %d", pntohl(&ra->nd_ra_retransmit));
dissect_icmpv6opt(pd, offset + sizeof(struct nd_router_advert), fd, icmp6_tree);
@ -445,7 +441,7 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
struct nd_neighbor_solicit *ns = (struct nd_neighbor_solicit *)dp;
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_neighbor_solicit, nd_ns_target), 16,
#ifdef INET6
"Target: %s (%s)",
@ -467,22 +463,21 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
flagoff = offset + offsetof(struct nd_neighbor_advert, nd_na_flags_reserved);
na_flags = pntohl(&pd[flagoff]);
tf = proto_tree_add_item(icmp6_tree, flagoff, 4, "Flags: 0x%08x", na_flags);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_ICMPv6FLAG);
proto_tree_add_item(field_tree, flagoff, 4, "%s",
tf = proto_tree_add_text(icmp6_tree, flagoff, 4, "Flags: 0x%08x", na_flags);
field_tree = proto_item_add_subtree(tf, ETT_ICMPv6FLAG);
proto_tree_add_text(field_tree, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x80000000, 32, "Router", "Not router"));
proto_tree_add_item(field_tree, flagoff, 4, "%s",
proto_tree_add_text(field_tree, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x40000000, 32, "Solicited", "Not adverted"));
proto_tree_add_item(field_tree, flagoff, 4, "%s",
proto_tree_add_text(field_tree, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x20000000, 32, "Override", "Not override"));
targetoff = offset + offsetof(struct nd_neighbor_advert, nd_na_target);
na_target_p = (struct e_in6_addr*) &pd[targetoff];
proto_tree_add_item(icmp6_tree, targetoff, 16,
proto_tree_add_text(icmp6_tree, targetoff, 16,
#ifdef INET6
"Target: %s (%s)",
get_hostname6(na_target_p),
@ -498,7 +493,7 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
struct nd_redirect *rd = (struct nd_redirect *)dp;
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_redirect, nd_rd_target), 16,
#ifdef INET6
"Target: %s (%s)",
@ -508,7 +503,7 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
#endif
ip6_to_str(&rd->nd_rd_target));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct nd_redirect, nd_rd_dst), 16,
#ifdef INET6
"Destination: %s (%s)",
@ -525,36 +520,35 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
struct icmp6_router_renum *rr = (struct icmp6_router_renum *)dp;
int flagoff;
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_router_renum, rr_seqnum), 4,
/*"Sequence number: 0x%08x", (u_int32_t)htonl(rr->rr_seqnum));*/
"Sequence number: 0x%08x", pntohl(&rr->rr_seqnum));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_router_renum, rr_segnum), 1,
"Segment number: 0x%02x", rr->rr_segnum);
flagoff = offset + offsetof(struct icmp6_router_renum, rr_segnum) + 1;
tf = proto_tree_add_item(icmp6_tree, flagoff, 4, "Flags: 0x%08x",
tf = proto_tree_add_text(icmp6_tree, flagoff, 4, "Flags: 0x%08x",
pd[flagoff]);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_ICMPv6FLAG);
proto_tree_add_item(field_tree, flagoff, 1, "%s",
field_tree = proto_item_add_subtree(tf, ETT_ICMPv6FLAG);
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pd[flagoff], 0x80, 8,
"Test command", "Not test command"));
proto_tree_add_item(field_tree, flagoff, 1, "%s",
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pd[flagoff], 0x40, 8,
"Result requested", "Result not requested"));
proto_tree_add_item(field_tree, flagoff, 1, "%s",
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pd[flagoff], 0x20, 8,
"All interfaces", "Not all interfaces"));
proto_tree_add_item(field_tree, flagoff, 1, "%s",
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pd[flagoff], 0x10, 8,
"Site specific", "Not site specific"));
proto_tree_add_item(field_tree, flagoff, 1, "%s",
proto_tree_add_text(field_tree, flagoff, 1, "%s",
decode_boolean_bitfield(pd[flagoff], 0x08, 8,
"Processed previously", "Complete result"));
proto_tree_add_item(icmp6_tree,
proto_tree_add_text(icmp6_tree,
offset + offsetof(struct icmp6_router_renum, rr_segnum), 2,
"Max delay: 0x%04x", pntohs(&rr->rr_maxdelay));
dissect_data(pd, offset + sizeof(*rr), fd, tree); /*XXX*/

View File

@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
* $Id: packet-ip.c,v 1.26 1999/06/21 16:20:18 gram Exp $
* $Id: packet-ip.c,v 1.27 1999/07/07 22:51:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -47,6 +47,14 @@
#endif
extern packet_info pi;
int proto_ip = -1;
int hf_ip_version = -1;
int hf_ip_hdr_len = -1;
int hf_ip_tos = -1;
int hf_ip_tos_precedence = -1;
int hf_ip_dst = -1;
int hf_ip_src = -1;
/* ICMP structs and definitions */
typedef struct _e_icmp {
@ -236,29 +244,28 @@ dissect_ipopt_security(proto_tree *opt_tree, const char *name,
{IPSEC_RESERVED8, "Reserved" },
{0, NULL } };
tf = proto_tree_add_item(opt_tree, offset, optlen, "%s:", name);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTION_SEC);
tf = proto_tree_add_text(opt_tree, offset, optlen, "%s:", name);
field_tree = proto_item_add_subtree(tf, ETT_IP_OPTION_SEC);
offset += 2;
val = pntohs(opd);
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"Security: %s", val_to_str(val, secl_vals, "Unknown (0x%x)"));
offset += 2;
opd += 2;
val = pntohs(opd);
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"Compartments: %d", val);
offset += 2;
opd += 2;
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"Handling restrictions: %c%c", opd[0], opd[1]);
offset += 2;
opd += 2;
proto_tree_add_item(field_tree, offset, 3,
proto_tree_add_text(field_tree, offset, 3,
"Transmission control code: %c%c%c", opd[0], opd[1], opd[2]);
}
@ -272,16 +279,15 @@ dissect_ipopt_route(proto_tree *opt_tree, const char *name,
int optoffset = 0;
struct in_addr addr;
tf = proto_tree_add_item(opt_tree, offset, optlen, "%s (%d bytes)", name,
tf = proto_tree_add_text(opt_tree, offset, optlen, "%s (%d bytes)", name,
optlen);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTION_ROUTE);
field_tree = proto_item_add_subtree(tf, ETT_IP_OPTION_ROUTE);
optoffset += 2; /* skip past type and length */
optlen -= 2; /* subtract size of type and length */
ptr = *opd;
proto_tree_add_item(field_tree, offset + optoffset, 1,
proto_tree_add_text(field_tree, offset + optoffset, 1,
"Pointer: %d%s", ptr,
((ptr < 4) ? " (points before first address)" :
((ptr & 3) ? " (points to middle of address)" : "")));
@ -292,7 +298,7 @@ dissect_ipopt_route(proto_tree *opt_tree, const char *name,
while (optlen > 0) {
if (optlen < 4) {
proto_tree_add_item(field_tree, offset, optlen,
proto_tree_add_text(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -300,7 +306,7 @@ dissect_ipopt_route(proto_tree *opt_tree, const char *name,
/* Avoids alignment problems on many architectures. */
memcpy((char *)&addr, (char *)opd, sizeof(addr));
proto_tree_add_item(field_tree, offset + optoffset, 4,
proto_tree_add_text(field_tree, offset + optoffset, 4,
"%s%s",
((addr.s_addr == 0) ? "-" : (char *)get_hostname(addr.s_addr)),
((optoffset == ptr) ? " <- (current)" : ""));
@ -314,7 +320,7 @@ static void
dissect_ipopt_sid(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: %d", name, pntohs(opd));
return;
}
@ -337,15 +343,14 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
struct in_addr addr;
guint ts;
tf = proto_tree_add_item(opt_tree, offset, optlen, "%s:", name);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTION_TIMESTAMP);
tf = proto_tree_add_text(opt_tree, offset, optlen, "%s:", name);
field_tree = proto_item_add_subtree(tf, ETT_IP_OPTION_TIMESTAMP);
optoffset += 2; /* skip past type and length */
optlen -= 2; /* subtract size of type and length */
ptr = *opd;
proto_tree_add_item(field_tree, offset + optoffset, 1,
proto_tree_add_text(field_tree, offset + optoffset, 1,
"Pointer: %d%s", ptr,
((ptr < 5) ? " (points before first address)" :
(((ptr - 1) & 3) ? " (points to middle of address)" : "")));
@ -355,10 +360,10 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
ptr--; /* ptr is 1-origin */
flg = *opd;
proto_tree_add_item(field_tree, offset + optoffset, 1,
proto_tree_add_text(field_tree, offset + optoffset, 1,
"Overflow: %d", flg >> 4);
flg &= 0xF;
proto_tree_add_item(field_tree, offset + optoffset, 1,
proto_tree_add_text(field_tree, offset + optoffset, 1,
"Flag: %s", val_to_str(flg, flag_vals, "Unknown (0x%x)"));
optoffset++;
opd++;
@ -367,7 +372,7 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
while (optlen > 0) {
if (flg == IPOPT_TS_TSANDADDR) {
if (optlen < 4) {
proto_tree_add_item(field_tree, offset + optoffset, optlen,
proto_tree_add_text(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -376,7 +381,7 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
opd += 4;
optlen -= 4;
if (optlen < 4) {
proto_tree_add_item(field_tree, offset + optoffset, optlen,
proto_tree_add_text(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -384,14 +389,14 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
memcpy((char *)&addr, (char *)opd, sizeof(addr));
opd += 4;
optlen -= 4;
proto_tree_add_item(field_tree, offset, 8,
proto_tree_add_text(field_tree, offset, 8,
"Address = %s, time stamp = %u",
((addr.s_addr == 0) ? "-" : (char *)get_hostname(addr.s_addr)),
ts);
optoffset += 8;
} else {
if (optlen < 4) {
proto_tree_add_item(field_tree, offset + optoffset, optlen,
proto_tree_add_text(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -399,7 +404,7 @@ dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *op
ts = pntohl(opd);
opd += 4;
optlen -= 4;
proto_tree_add_item(field_tree, offset + optoffset, 4,
proto_tree_add_text(field_tree, offset + optoffset, 4,
"Time stamp = %u", ts);
optoffset += 4;
}
@ -483,7 +488,7 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
break;
}
if (optp == &opttab[nopts]) {
proto_tree_add_item(opt_tree, offset, 1, "Unknown");
proto_tree_add_text(opt_tree, offset, 1, "Unknown");
/* We don't know how long this option is, so we don't know how much
of it to skip, so we just bail. */
return;
@ -494,7 +499,7 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
if (length == 0) {
/* Bogus - packet must at least include option code byte and
length byte! */
proto_tree_add_item(opt_tree, offset, 1,
proto_tree_add_text(opt_tree, offset, 1,
"%s (length byte past end of header)", optp->name);
return;
}
@ -503,25 +508,25 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
if (len < 2) {
/* Bogus - option length is too short to include option code and
option length. */
proto_tree_add_item(opt_tree, offset, 2,
proto_tree_add_text(opt_tree, offset, 2,
"%s (with too-short option length = %u bytes)", optp->name, 2);
return;
} else if (len - 2 > length) {
/* Bogus - option goes past the end of the header. */
proto_tree_add_item(opt_tree, offset, length,
proto_tree_add_text(opt_tree, offset, length,
"%s (option goes past end of header)", optp->name);
return;
} else if (optp->len_type == FIXED_LENGTH && len != optp->optlen) {
/* Bogus - option length isn't what it's supposed to be for this
option. */
proto_tree_add_item(opt_tree, offset, len,
proto_tree_add_text(opt_tree, offset, len,
"%s (with option length = %u bytes; should be %u)", optp->name,
len, optp->optlen);
return;
} else if (optp->len_type == VARIABLE_LENGTH && len < optp->optlen) {
/* Bogus - option length is less than what it's supposed to be for
this option. */
proto_tree_add_item(opt_tree, offset, len,
proto_tree_add_text(opt_tree, offset, len,
"%s (with option length = %u bytes; should be >= %u)", optp->name,
len, optp->optlen);
return;
@ -531,7 +536,7 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
(*optp->dissect)(opt_tree, optp->name, opd, offset, len);
} else {
/* Option has no data, hence no dissector. */
proto_tree_add_item(opt_tree, offset, len, "%s", optp->name);
proto_tree_add_text(opt_tree, offset, len, "%s", optp->name);
}
len -= 2; /* subtract size of type and length */
offset += 2 + len;
@ -539,7 +544,7 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
opd += len;
length -= len;
} else {
proto_tree_add_item(opt_tree, offset, 1, "%s", optp->name);
proto_tree_add_text(opt_tree, offset, 1, "%s", optp->name);
offset += 1;
}
if (opt == eol)
@ -547,20 +552,14 @@ dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
}
}
void
dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ip iph;
proto_tree *ip_tree, *field_tree;
proto_item *ti, *tf;
gchar tos_str[32];
guint hlen, optlen;
static const value_string proto_vals[] = { {IP_PROTO_ICMP, "ICMP"},
{IP_PROTO_IGMP, "IGMP"},
{IP_PROTO_TCP, "TCP" },
{IP_PROTO_UDP, "UDP" },
{IP_PROTO_OSPF, "OSPF"},
{0, NULL } };
static const value_string precedence_vals[] = {
static const value_string proto_vals[] = { {IP_PROTO_ICMP, "ICMP"},
{IP_PROTO_IGMP, "IGMP"},
{IP_PROTO_TCP, "TCP" },
{IP_PROTO_UDP, "UDP" },
{IP_PROTO_OSPF, "OSPF"},
{0, NULL } };
static const value_string precedence_vals[] = {
{ IPTOS_PREC_ROUTINE, "routine" },
{ IPTOS_PREC_PRIORITY, "priority" },
{ IPTOS_PREC_IMMEDIATE, "immediate" },
@ -570,6 +569,24 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
{ IPTOS_PREC_INTERNETCONTROL, "internetwork control" },
{ IPTOS_PREC_NETCONTROL, "network control" },
{ 0, NULL } };
static const value_string iptos_vals[] = {
{ IPTOS_NONE, "None" },
{ IPTOS_LOWCOST, "Minimize cost" },
{ IPTOS_RELIABILITY, "Maximize reliability" },
{ IPTOS_THROUGHPUT, "Maximize throughput" },
{ IPTOS_LOWDELAY, "Minimize delay" },
{ IPTOS_SECURITY, "Maximize security" },
{ 0, NULL }
};
void
dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ip iph;
proto_tree *ip_tree, *field_tree;
proto_item *ti, *tf;
gchar tos_str[32];
guint hlen, optlen;
int advance;
guint8 nxt;
@ -637,68 +654,65 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
break;
}
ti = proto_tree_add_item(tree, offset, hlen, "Internet Protocol");
ip_tree = proto_tree_new();
proto_item_add_subtree(ti, ip_tree, ETT_IP);
proto_tree_add_item(ip_tree, offset, 1, "Version: %d", hi_nibble(iph.ip_v_hl));
proto_tree_add_item(ip_tree, offset, 1, "Header length: %d bytes", hlen);
tf = proto_tree_add_item(ip_tree, offset + 1, 1, "Type of service: 0x%02x (%s)",
iph.ip_tos, tos_str);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_TOS);
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
decode_enumerated_bitfield(iph.ip_tos, IPTOS_PREC_MASK,
sizeof (iph.ip_tos)*8, precedence_vals,
"%s precedence"));
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
ti = proto_tree_add_item(tree, proto_ip, offset, hlen, NULL);
ip_tree = proto_item_add_subtree(ti, ETT_IP);
proto_tree_add_item(ip_tree, hf_ip_version, offset, 1, hi_nibble(iph.ip_v_hl));
proto_tree_add_item_format(ip_tree, hf_ip_hdr_len, offset, 1, hlen,
"Header length: %d bytes", hlen);
tf = proto_tree_add_item_format(ip_tree, hf_ip_tos, offset + 1, 1, iph.ip_tos,
"Type of service: 0x%02x (%s)", iph.ip_tos,
val_to_str( IPTOS_TOS(iph.ip_tos), iptos_vals, "Unknown") );
field_tree = proto_item_add_subtree(tf, ETT_IP_TOS);
proto_tree_add_item_format(field_tree, hf_ip_tos_precedence, offset + 1, 1,
iph.ip_tos & IPTOS_PREC_MASK, decode_enumerated_bitfield(iph.ip_tos, IPTOS_PREC_MASK,
sizeof (iph.ip_tos)*8, precedence_vals, "%s precedence"));
proto_tree_add_text(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_LOWDELAY,
sizeof (iph.ip_tos)*8, "low delay", "normal delay"));
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
proto_tree_add_text(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_THROUGHPUT,
sizeof (iph.ip_tos)*8, "high throughput", "normal throughput"));
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
proto_tree_add_text(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_RELIABILITY,
sizeof (iph.ip_tos)*8, "high reliability", "normal reliability"));
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
proto_tree_add_text(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_LOWCOST,
sizeof (iph.ip_tos)*8, "low cost", "normal cost"));
proto_tree_add_item(ip_tree, offset + 2, 2, "Total length: %d", iph.ip_len);
proto_tree_add_item(ip_tree, offset + 4, 2, "Identification: 0x%04x",
proto_tree_add_text(ip_tree, offset + 2, 2, "Total length: %d", iph.ip_len);
proto_tree_add_text(ip_tree, offset + 4, 2, "Identification: 0x%04x",
iph.ip_id);
tf = proto_tree_add_item(ip_tree, offset + 6, 2, "Flags: 0x%x",
tf = proto_tree_add_text(ip_tree, offset + 6, 2, "Flags: 0x%x",
(iph.ip_off & (IP_DF|IP_MF)) >> 12);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OFF);
proto_tree_add_item(field_tree, offset + 6, 2, "%s",
field_tree = proto_item_add_subtree(tf, ETT_IP_OFF);
proto_tree_add_text(field_tree, offset + 6, 2, "%s",
decode_boolean_bitfield(iph.ip_off >> 8, IP_DF >> 8, 8, "don't fragment",
"may fragment"));
proto_tree_add_item(field_tree, offset + 6, 2, "%s",
proto_tree_add_text(field_tree, offset + 6, 2, "%s",
decode_boolean_bitfield(iph.ip_off >> 8, IP_MF >> 8, 8, "more fragments",
"last fragment"));
proto_tree_add_item(ip_tree, offset + 6, 2, "Fragment offset: %d",
proto_tree_add_text(ip_tree, offset + 6, 2, "Fragment offset: %d",
iph.ip_off & IP_OFFSET);
proto_tree_add_item(ip_tree, offset + 8, 1, "Time to live: %d",
proto_tree_add_text(ip_tree, offset + 8, 1, "Time to live: %d",
iph.ip_ttl);
proto_tree_add_item(ip_tree, offset + 9, 1, "Protocol: %s",
proto_tree_add_text(ip_tree, offset + 9, 1, "Protocol: %s",
val_to_str(iph.ip_p, proto_vals, "Unknown (0x%x)"));
proto_tree_add_item(ip_tree, offset + 10, 2, "Header checksum: 0x%04x",
proto_tree_add_text(ip_tree, offset + 10, 2, "Header checksum: 0x%04x",
iph.ip_sum);
proto_tree_add_item(ip_tree, offset + 12, 4, "Source address: %s (%s)",
get_hostname(iph.ip_src),
ip_to_str((guint8 *) &iph.ip_src));
proto_tree_add_item(ip_tree, offset + 16, 4, "Destination address: %s (%s)",
get_hostname(iph.ip_dst),
ip_to_str((guint8 *) &iph.ip_dst));
proto_tree_add_item(ip_tree, hf_ip_src, offset + 12, 4, iph.ip_src);
proto_tree_add_item(ip_tree, hf_ip_dst, offset + 16, 4, iph.ip_dst);
/* Decode IP options, if any. */
if (hlen > sizeof (e_ip)) {
/* There's more than just the fixed-length header. Decode the
options. */
optlen = hlen - sizeof (e_ip); /* length of options, in bytes */
tf = proto_tree_add_item(ip_tree, offset + 20, optlen,
tf = proto_tree_add_text(ip_tree, offset + 20, optlen,
"Options: (%d bytes)", optlen);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTIONS);
field_tree = proto_item_add_subtree(tf, ETT_IP_OPTIONS);
dissect_ip_tcp_options(field_tree, &pd[offset + 20], offset + 20, optlen,
ipopts, N_IP_OPTS, IPOPT_END);
}
@ -882,17 +896,16 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_PROTOCOL, "ICMP");
if (check_col(fd, COL_INFO))
col_add_str(fd, COL_INFO, type_str);
if (tree) {
ti = proto_tree_add_item(tree, offset, 4,
ti = proto_tree_add_text(tree, offset, 4,
"Internet Control Message Protocol");
icmp_tree = proto_tree_new();
proto_item_add_subtree(ti, icmp_tree, ETT_ICMP);
proto_tree_add_item(icmp_tree, offset, 1, "Type: %d (%s)",
icmp_tree = proto_item_add_subtree(ti, ETT_ICMP);
proto_tree_add_text(icmp_tree, offset, 1, "Type: %d (%s)",
ih.icmp_type, type_str);
proto_tree_add_item(icmp_tree, offset + 1, 1, "Code: %d %s",
proto_tree_add_text(icmp_tree, offset + 1, 1, "Code: %d %s",
ih.icmp_code, code_str);
proto_tree_add_item(icmp_tree, offset + 2, 2, "Checksum: 0x%04x",
proto_tree_add_text(icmp_tree, offset + 2, 2, "Checksum: 0x%04x",
ih.icmp_cksum);
/* Decode the second 4 bytes of the packet. */
@ -905,30 +918,30 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
case ICMP_IREQREPLY:
case ICMP_MASKREQ:
case ICMP_MASKREPLY:
proto_tree_add_item(icmp_tree, offset + 4, 2, "Identifier: 0x%04x",
proto_tree_add_text(icmp_tree, offset + 4, 2, "Identifier: 0x%04x",
pntohs(&pd[offset + 4]));
proto_tree_add_item(icmp_tree, offset + 6, 2, "Sequence number: %u",
proto_tree_add_text(icmp_tree, offset + 6, 2, "Sequence number: %u",
pntohs(&pd[offset + 6]));
break;
case ICMP_RTRADVERT:
num_addrs = pd[offset + 4];
proto_tree_add_item(icmp_tree, offset + 4, 1, "Number of addresses: %u",
proto_tree_add_text(icmp_tree, offset + 4, 1, "Number of addresses: %u",
num_addrs);
addr_entry_size = pd[offset + 5];
proto_tree_add_item(icmp_tree, offset + 5, 1, "Address entry size: %u",
proto_tree_add_text(icmp_tree, offset + 5, 1, "Address entry size: %u",
addr_entry_size);
proto_tree_add_item(icmp_tree, offset + 6, 2, "Lifetime: %s",
proto_tree_add_text(icmp_tree, offset + 6, 2, "Lifetime: %s",
time_secs_to_str(pntohs(&pd[offset + 6])));
break;
case ICMP_PARAMPROB:
proto_tree_add_item(icmp_tree, offset + 4, 1, "Pointer: %u",
proto_tree_add_text(icmp_tree, offset + 4, 1, "Pointer: %u",
pd[offset + 4]);
break;
case ICMP_REDIRECT:
proto_tree_add_item(icmp_tree, offset + 4, 4, "Gateway address: %s",
proto_tree_add_text(icmp_tree, offset + 4, 4, "Gateway address: %s",
ip_to_str((guint8 *)&pd[offset + 4]));
break;
}
@ -956,10 +969,10 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
case ICMP_RTRADVERT:
if (addr_entry_size == 2) {
for (i = 0; i < num_addrs; i++) {
proto_tree_add_item(icmp_tree, offset + 8 + (i*8), 4,
proto_tree_add_text(icmp_tree, offset + 8 + (i*8), 4,
"Router address: %s",
ip_to_str((guint8 *)&pd[offset + 8 + (i*8)]));
proto_tree_add_item(icmp_tree, offset + 12 + (i*8), 4,
proto_tree_add_text(icmp_tree, offset + 12 + (i*8), 4,
"Preference level: %d", pntohl(&pd[offset + 12 + (i*8)]));
}
} else
@ -968,19 +981,19 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
case ICMP_TSTAMP:
case ICMP_TSTAMPREPLY:
proto_tree_add_item(icmp_tree, offset + 8, 4, "Originate timestamp: %u",
proto_tree_add_text(icmp_tree, offset + 8, 4, "Originate timestamp: %u",
pntohl(&pd[offset + 8]));
proto_tree_add_item(icmp_tree, offset + 12, 4, "Originate timestamp: %u",
proto_tree_add_text(icmp_tree, offset + 12, 4, "Originate timestamp: %u",
pntohl(&pd[offset + 12]));
proto_tree_add_item(icmp_tree, offset + 16, 4, "Receive timestamp: %u",
proto_tree_add_text(icmp_tree, offset + 16, 4, "Receive timestamp: %u",
pntohl(&pd[offset + 16]));
proto_tree_add_item(icmp_tree, offset + 20, 4, "Transmit timestamp: %u",
proto_tree_add_text(icmp_tree, offset + 20, 4, "Transmit timestamp: %u",
pntohl(&pd[offset + 20]));
break;
case ICMP_MASKREQ:
case ICMP_MASKREPLY:
proto_tree_add_item(icmp_tree, offset + 8, 4, "Address mask: %s (0x%8x)",
proto_tree_add_text(icmp_tree, offset + 8, 4, "Address mask: %s (0x%8x)",
ip_to_str((guint8 *)&pd[offset + 8]), pntohl(&pd[offset + 8]));
break;
}
@ -1033,21 +1046,69 @@ dissect_igmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_PROTOCOL, "IGMP");
if (check_col(fd, COL_INFO))
col_add_str(fd, COL_INFO, type_str);
if (tree) {
ti = proto_tree_add_item(tree, offset, 4,
ti = proto_tree_add_text(tree, offset, 4,
"Internet Group Management Protocol");
igmp_tree = proto_tree_new();
proto_item_add_subtree(ti, igmp_tree, ETT_IGMP);
proto_tree_add_item(igmp_tree, offset, 1, "Version: %d",
igmp_tree = proto_item_add_subtree(ti, ETT_IGMP);
proto_tree_add_text(igmp_tree, offset, 1, "Version: %d",
hi_nibble(ih.igmp_v_t));
proto_tree_add_item(igmp_tree, offset , 1, "Type: %d (%s)",
proto_tree_add_text(igmp_tree, offset , 1, "Type: %d (%s)",
lo_nibble(ih.igmp_v_t), type_str);
proto_tree_add_item(igmp_tree, offset + 1, 1, "Unused: 0x%02x",
proto_tree_add_text(igmp_tree, offset + 1, 1, "Unused: 0x%02x",
ih.igmp_unused);
proto_tree_add_item(igmp_tree, offset + 2, 2, "Checksum: 0x%04x",
proto_tree_add_text(igmp_tree, offset + 2, 2, "Checksum: 0x%04x",
ih.igmp_cksum);
proto_tree_add_item(igmp_tree, offset + 4, 4, "Group address: %s",
proto_tree_add_text(igmp_tree, offset + 4, 4, "Group address: %s",
ip_to_str((guint8 *) &ih.igmp_gaddr));
}
}
void
proto_register_ip(void)
{
proto_ip = proto_register_protocol (
/* name */ "Internet Protocol",
/* abbrev */ "ip" );
hf_ip_version = proto_register_field (
/* name */ "Version",
/* abbrev */ "ip.version",
/* ftype */ FT_UINT8,
/* parent */ proto_ip,
/* vals[] */ NULL );
hf_ip_hdr_len = proto_register_field (
/* name */ "Header Length",
/* abbrev */ "ip.hdr_len",
/* ftype */ FT_UINT8,
/* parent */ proto_ip,
/* vals[] */ NULL );
hf_ip_tos = proto_register_field (
/* name */ "Type of Service",
/* abbrev */ "ip.tos",
/* ftype */ FT_UINT8,
/* parent */ proto_ip,
/* vals[] */ NULL );
hf_ip_tos_precedence = proto_register_field (
/* name */ "Precedence",
/* abbrev */ "ip.tos_precedence",
/* ftype */ FT_VALS_UINT8,
/* parent */ proto_ip,
/* vals[] */ VALS(precedence_vals) );
hf_ip_dst = proto_register_field (
/* name */ "Destination",
/* abbrev */ "ip.dst",
/* ftype */ FT_IPv4,
/* parent */ proto_ip,
/* vals[] */ NULL );
hf_ip_src = proto_register_field (
/* name */ "Source",
/* abbrev */ "ip.src",
/* ftype */ FT_IPv4,
/* parent */ proto_ip,
/* vals[] */ NULL );
}

View File

@ -1,7 +1,7 @@
/* packet-ipsec.c
* Routines for IPsec packet disassembly
*
* $Id: packet-ipsec.c,v 1.1 1999/03/29 02:21:34 gram Exp $
* $Id: packet-ipsec.c,v 1.2 1999/07/07 22:51:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -85,19 +85,18 @@ dissect_ah(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (tree) {
/* !!! specify length */
ti = proto_tree_add_item(tree, offset, advance, "Authentication Header");
ah_tree = proto_tree_new();
proto_item_add_subtree(ti, ah_tree, ETT_AH);
ti = proto_tree_add_text(tree, offset, advance, "Authentication Header");
ah_tree = proto_item_add_subtree(ti, ETT_AH);
proto_tree_add_item(ah_tree, offset + offsetof(struct newah, ah_nxt), 1,
proto_tree_add_text(ah_tree, offset + offsetof(struct newah, ah_nxt), 1,
"Next Header: %d", ah.ah_nxt);
proto_tree_add_item(ah_tree, offset + offsetof(struct newah, ah_len), 1,
proto_tree_add_text(ah_tree, offset + offsetof(struct newah, ah_len), 1,
"Length: %d", ah.ah_len << 2);
proto_tree_add_item(ah_tree, offset + offsetof(struct newah, ah_spi), 4,
proto_tree_add_text(ah_tree, offset + offsetof(struct newah, ah_spi), 4,
"SPI: %08x", (guint32)ntohl(ah.ah_spi));
proto_tree_add_item(ah_tree, offset + offsetof(struct newah, ah_seq), 4,
proto_tree_add_text(ah_tree, offset + offsetof(struct newah, ah_seq), 4,
"Sequence?: %08x", (guint32)ntohl(ah.ah_seq));
proto_tree_add_item(ah_tree, offset + sizeof(ah), (ah.ah_len - 1) << 2,
proto_tree_add_text(ah_tree, offset + sizeof(ah), (ah.ah_len - 1) << 2,
"ICV");
}
@ -130,12 +129,11 @@ dissect_esp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
* (ie none)
*/
if(tree) {
ti = proto_tree_add_item(tree, 0, 0, "Encapsulated Security Payload");
esp_tree = proto_tree_new();
proto_item_add_subtree(ti, esp_tree, ETT_ESP);
proto_tree_add_item(esp_tree, offset + offsetof(struct newesp, esp_spi), 4,
ti = proto_tree_add_text(tree, 0, 0, "Encapsulated Security Payload");
esp_tree = proto_item_add_subtree(ti, ETT_ESP);
proto_tree_add_text(esp_tree, offset + offsetof(struct newesp, esp_spi), 4,
"SPI: %08x", (guint32)ntohl(esp.esp_spi));
proto_tree_add_item(esp_tree, offset + offsetof(struct newesp, esp_seq), 4,
proto_tree_add_text(esp_tree, offset + offsetof(struct newesp, esp_seq), 4,
"Sequence?: %08x", (guint32)ntohl(esp.esp_seq));
}
}

View File

@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
* $Id: packet-ipv6.c,v 1.8 1999/04/09 13:32:31 gram Exp $
* $Id: packet-ipv6.c,v 1.9 1999/07/07 22:51:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -85,12 +85,11 @@ dissect_dstopts(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (tree) {
/* !!! specify length */
ti = proto_tree_add_item(tree, offset, len,
ti = proto_tree_add_text(tree, offset, len,
"Destination Option Header");
dstopt_tree = proto_tree_new();
proto_item_add_subtree(ti, dstopt_tree, ETT_IPv6);
dstopt_tree = proto_item_add_subtree(ti, ETT_IPv6);
proto_tree_add_item(dstopt_tree,
proto_tree_add_text(dstopt_tree,
offset + offsetof(struct ip6_dest, ip6d_len), 1,
"Length: %d (%d bytes)", dstopt.ip6d_len, len);
@ -125,38 +124,37 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (tree) {
/* !!! specify length */
ti = proto_tree_add_item(tree, offset, 40, "Internet Protocol Version 6");
ipv6_tree = proto_tree_new();
proto_item_add_subtree(ti, ipv6_tree, ETT_IPv6);
ti = proto_tree_add_text(tree, offset, 40, "Internet Protocol Version 6");
ipv6_tree = proto_item_add_subtree(ti, ETT_IPv6);
/* !!! warning: version also contains 4 Bit priority */
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_vfc), 1,
"Version: %d", ipv6.ip6_vfc >> 4);
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_flow), 4,
"Traffic class: 0x%02x", (ntohl(ipv6.ip6_flow) >> 20) & 0xff);
/* there should be no alignment problems for ip6_flow, since it's the first
guint32 in the ipv6 struct */
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_flow), 4,
"Flowlabel: 0x%05x", ntohl(ipv6.ip6_flow & IPV6_FLOWLABEL_MASK));
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_plen), 2,
"Payload Length: %d", ntohs(ipv6.ip6_plen));
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_nxt), 1,
"Next Header: %d", ipv6.ip6_nxt);
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_hlim), 1,
"Hop limit: %d", ipv6.ip6_hlim);
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_src), 16,
#ifdef INET6
"Source address: %s (%s)",
@ -166,7 +164,7 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
#endif
ip6_to_str(&ipv6.ip6_src));
proto_tree_add_item(ipv6_tree,
proto_tree_add_text(ipv6_tree,
offset + offsetof(struct ip6_hdr, ip6_dst), 16,
#ifdef INET6
"Destination address: %s (%s)",

View File

@ -2,7 +2,7 @@
* Routines for NetWare's IPX
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-ipx.c,v 1.20 1999/05/10 20:51:36 gram Exp $
* $Id: packet-ipx.c,v 1.21 1999/07/07 22:51:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -223,30 +223,29 @@ dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
ipx_checksum = pntohs(&pd[offset]);
ipx_hops = pd[offset+4];
ti = proto_tree_add_item(tree, offset, 30,
ti = proto_tree_add_text(tree, offset, 30,
"Internetwork Packet Exchange");
ipx_tree = proto_tree_new();
proto_item_add_subtree(ti, ipx_tree, ETT_IPX);
proto_tree_add_item(ipx_tree, offset, 2, "Checksum: 0x%04x",
ipx_tree = proto_item_add_subtree(ti, ETT_IPX);
proto_tree_add_text(ipx_tree, offset, 2, "Checksum: 0x%04x",
ipx_checksum);
proto_tree_add_item(ipx_tree, offset+2, 2, "Length: %d bytes",
proto_tree_add_text(ipx_tree, offset+2, 2, "Length: %d bytes",
ipx_length);
proto_tree_add_item(ipx_tree, offset+4, 1, "Transport Control: %d hops",
proto_tree_add_text(ipx_tree, offset+4, 1, "Transport Control: %d hops",
ipx_hops);
proto_tree_add_item(ipx_tree, offset+5, 1, "Packet Type: %s",
proto_tree_add_text(ipx_tree, offset+5, 1, "Packet Type: %s",
ipx_packet_type(ipx_type));
proto_tree_add_item(ipx_tree, offset+6, 4, "Destination Network: %s",
proto_tree_add_text(ipx_tree, offset+6, 4, "Destination Network: %s",
str_dnet);
proto_tree_add_item(ipx_tree, offset+10, 6, "Destination Node: %s",
proto_tree_add_text(ipx_tree, offset+10, 6, "Destination Node: %s",
ether_to_str(ipx_dnode));
proto_tree_add_item(ipx_tree, offset+16, 2,
proto_tree_add_text(ipx_tree, offset+16, 2,
"Destination Socket: %s (0x%04X)", port_text(ipx_dsocket),
ipx_dsocket);
proto_tree_add_item(ipx_tree, offset+18, 4, "Source Network: %s",
proto_tree_add_text(ipx_tree, offset+18, 4, "Source Network: %s",
str_snet);
proto_tree_add_item(ipx_tree, offset+22, 6, "Source Node: %s",
proto_tree_add_text(ipx_tree, offset+22, 6, "Source Node: %s",
ether_to_str(ipx_snode));
proto_tree_add_item(ipx_tree, offset+28, 2,
proto_tree_add_text(ipx_tree, offset+28, 2,
"Source Socket: %s (0x%04X)", port_text(ipx_ssocket), ipx_ssocket);
}
offset += 30;
@ -257,8 +256,11 @@ dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
break;
case 17: /* NCP */
/* Is the destination node 00:00:00:00:00:01 ? */
if (pntohl(ipx_dnode) == 0 && pntohs(ipx_dnode + 4) == 1)
nw_server_address = pntohl(ipx_dnet);
/* Is the source node 00:00:00:00:00:01 ? */
else if (pntohl(ipx_snode) == 0 && pntohs(ipx_snode + 4) == 1)
nw_server_address = pntohl(ipx_snet);
else
@ -344,31 +346,30 @@ dissect_spx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
col_add_str(fd, COL_INFO, "SPX");
if (tree) {
ti = proto_tree_add_item(tree, offset, 12, "Sequenced Packet Exchange");
spx_tree = proto_tree_new();
proto_item_add_subtree(ti, spx_tree, ETT_SPX);
ti = proto_tree_add_text(tree, offset, 12, "Sequenced Packet Exchange");
spx_tree = proto_item_add_subtree(ti, ETT_SPX);
proto_tree_add_item(spx_tree, offset, 1,
proto_tree_add_text(spx_tree, offset, 1,
"Connection Control: %s (0x%02X)",
spx_conn_ctrl(pd[offset]), pd[offset]);
proto_tree_add_item(spx_tree, offset+1, 1,
proto_tree_add_text(spx_tree, offset+1, 1,
"Datastream Type: %s (0x%02X)",
spx_datastream(pd[offset+1]), pd[offset+1]);
proto_tree_add_item(spx_tree, offset+2, 2,
proto_tree_add_text(spx_tree, offset+2, 2,
"Source Connection ID: %d", pntohs( &pd[offset+2] ) );
proto_tree_add_item(spx_tree, offset+4, 2,
proto_tree_add_text(spx_tree, offset+4, 2,
"Destination Connection ID: %d", pntohs( &pd[offset+4] ) );
proto_tree_add_item(spx_tree, offset+6, 2,
proto_tree_add_text(spx_tree, offset+6, 2,
"Sequence Number: %d", pntohs( &pd[offset+6] ) );
proto_tree_add_item(spx_tree, offset+8, 2,
proto_tree_add_text(spx_tree, offset+8, 2,
"Acknowledgment Number: %d", pntohs( &pd[offset+8] ) );
proto_tree_add_item(spx_tree, offset+10, 2,
proto_tree_add_text(spx_tree, offset+10, 2,
"Allocation Number: %d", pntohs( &pd[offset+10] ) );
offset += 12;
@ -405,17 +406,16 @@ dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
}
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"IPX Routing Information Protocol");
rip_tree = proto_tree_new();
proto_item_add_subtree(ti, rip_tree, ETT_IPXRIP);
rip_tree = proto_item_add_subtree(ti, ETT_IPXRIP);
if (operation < 2) {
proto_tree_add_item(rip_tree, offset, 2,
proto_tree_add_text(rip_tree, offset, 2,
"RIP packet type: %s", rip_type[operation]);
}
else {
proto_tree_add_item(rip_tree, offset, 2, "Unknown RIP packet type");
proto_tree_add_text(rip_tree, offset, 2, "Unknown RIP packet type");
}
for (cursor = offset + 2; cursor < fd->cap_len; cursor += 8) {
@ -424,14 +424,14 @@ dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
route.ticks = pntohs(&pd[cursor+6]);
if (operation == IPX_RIP_REQUEST - 1) {
proto_tree_add_item(rip_tree, cursor, 8,
proto_tree_add_text(rip_tree, cursor, 8,
"Route Vector: %s, %d hop%s, %d tick%s",
ipxnet_to_string((guint8*)&route.network),
route.hops, route.hops == 1 ? "" : "s",
route.ticks, route.ticks == 1 ? "" : "s");
}
else {
proto_tree_add_item(rip_tree, cursor, 8,
proto_tree_add_text(rip_tree, cursor, 8,
"Route Vector: %s, %d hop%s, %d tick%s (%d ms)",
ipxnet_to_string((guint8*)&route.network),
route.hops, route.hops == 1 ? "" : "s",
@ -527,16 +527,15 @@ dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
}
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Service Advertising Protocol");
sap_tree = proto_tree_new();
proto_item_add_subtree(ti, sap_tree, ETT_IPXSAP);
sap_tree = proto_item_add_subtree(ti, ETT_IPXSAP);
if (query.query_type < 4) {
proto_tree_add_item(sap_tree, offset, 2, sap_type[query.query_type - 1]);
proto_tree_add_text(sap_tree, offset, 2, sap_type[query.query_type - 1]);
}
else {
proto_tree_add_item(sap_tree, offset, 2,
proto_tree_add_text(sap_tree, offset, 2,
"Unknown SAP Packet Type %d", query.query_type);
}
@ -551,26 +550,25 @@ dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
server.server_port = pntohs(&pd[cursor+60]);
server.intermediate_network = pntohs(&pd[cursor+62]);
ti = proto_tree_add_item(sap_tree, cursor+2, 48,
ti = proto_tree_add_text(sap_tree, cursor+2, 48,
"Server Name: %s", server.server_name);
s_tree = proto_tree_new();
proto_item_add_subtree(ti, s_tree, ETT_IPXSAP_SERVER);
s_tree = proto_item_add_subtree(ti, ETT_IPXSAP_SERVER);
proto_tree_add_item(s_tree, cursor, 2, "Server Type: %s (0x%04X)",
proto_tree_add_text(s_tree, cursor, 2, "Server Type: %s (0x%04X)",
server_type(server.server_type), server.server_type);
proto_tree_add_item(s_tree, cursor+50, 4, "Network: %s",
proto_tree_add_text(s_tree, cursor+50, 4, "Network: %s",
ipxnet_to_string((guint8*)&pd[cursor+50]));
proto_tree_add_item(s_tree, cursor+54, 6, "Node: %s",
proto_tree_add_text(s_tree, cursor+54, 6, "Node: %s",
ether_to_str((guint8*)&pd[cursor+54]));
proto_tree_add_item(s_tree, cursor+60, 2, "Socket: %s (0x%04X)",
proto_tree_add_text(s_tree, cursor+60, 2, "Socket: %s (0x%04X)",
port_text(server.server_port), server.server_port);
proto_tree_add_item(s_tree, cursor+62, 2,
proto_tree_add_text(s_tree, cursor+62, 2,
"Intermediate Networks: %d",
server.intermediate_network);
}
}
else { /* queries */
proto_tree_add_item(sap_tree, offset+2, 2, "Server Type: %s (0x%04X)",
proto_tree_add_text(sap_tree, offset+2, 2, "Server Type: %s (0x%04X)",
server_type(query.server_type), query.server_type);
}
}

View File

@ -2,7 +2,7 @@
* Routines for the Internet Security Association and Key Management Protocol (ISAKMP)
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-isakmp.c,v 1.3 1999/07/06 06:10:31 guy Exp $
* $Id: packet-isakmp.c,v 1.4 1999/07/07 22:51:46 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -287,30 +287,29 @@ void dissect_isakmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
proto_item * ti;
proto_tree * isakmp_tree;
ti = proto_tree_add_item(tree, offset, len,
ti = proto_tree_add_text(tree, offset, len,
"Internet Security Association and Key Management Protocol");
isakmp_tree = proto_tree_new();
proto_item_add_subtree(ti, isakmp_tree, ETT_ISAKMP);
isakmp_tree = proto_item_add_subtree(ti, ETT_ISAKMP);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->icookie),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->icookie),
"Initiator cookie");
offset += sizeof(hdr->icookie);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->rcookie),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->rcookie),
"Responder cookie");
offset += sizeof(hdr->rcookie);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->version),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->version),
"Version: %u.%u",
hi_nibble(hdr->version), lo_nibble(hdr->version));
offset += sizeof(hdr->version);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->exch_type),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->exch_type),
"Exchange type: %s (%u)",
exchtype2str(hdr->exch_type), hdr->exch_type);
offset += sizeof(hdr->exch_type);
@ -319,26 +318,25 @@ void dissect_isakmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
proto_item * fti;
proto_tree * ftree;
fti = proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->flags), "Flags");
ftree = proto_tree_new();
proto_item_add_subtree(fti, ftree, ETT_ISAKMP_FLAGS);
fti = proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->flags), "Flags");
ftree = proto_item_add_subtree(fti, ETT_ISAKMP_FLAGS);
proto_tree_add_item(ftree, offset, 1, "%s",
proto_tree_add_text(ftree, offset, 1, "%s",
decode_boolean_bitfield(hdr->flags, E_FLAG, sizeof(hdr->flags)*8,
"Encryption", "No encryption"));
proto_tree_add_item(ftree, offset, 1, "%s",
proto_tree_add_text(ftree, offset, 1, "%s",
decode_boolean_bitfield(hdr->flags, C_FLAG, sizeof(hdr->flags)*8,
"Commit", "No commit"));
proto_tree_add_item(ftree, offset, 1, "%s",
proto_tree_add_text(ftree, offset, 1, "%s",
decode_boolean_bitfield(hdr->flags, A_FLAG, sizeof(hdr->flags)*8,
"Authentication", "No authentication"));
offset += sizeof(hdr->flags);
}
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->message_id), "Message ID");
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->message_id), "Message ID");
offset += sizeof(hdr->message_id);
proto_tree_add_item(isakmp_tree, offset, sizeof(hdr->length),
proto_tree_add_text(isakmp_tree, offset, sizeof(hdr->length),
"Length: %u", len);
offset += sizeof(hdr->length);
@ -360,26 +358,26 @@ dissect_sa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 length = pntohs(&hdr->length);
guint32 doi = pntohl(&hdr->doi);
guint32 situation = pntohl(&hdr->situation);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Security Association payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Security Association payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(doi),
proto_tree_add_text(ntree, offset, sizeof(doi),
"Domain of interpretation: %s (%u)",
doitype2str(doi), doi);
offset += sizeof(doi);
proto_tree_add_item(ntree, offset, sizeof(situation),
proto_tree_add_text(ntree, offset, sizeof(situation),
"Situation: %s (%u)",
situation2str(situation), situation);
offset += sizeof(situation);
@ -398,40 +396,40 @@ dissect_proposal(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
struct proposal_hdr * hdr = (struct proposal_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Proposal payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Proposal payload");
proto_tree * ntree;
guint8 i;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(hdr->proposal_num),
proto_tree_add_text(ntree, offset, sizeof(hdr->proposal_num),
"Proposal number: %u", hdr->proposal_num);
offset += sizeof(hdr->proposal_num);
proto_tree_add_item(ntree, offset, sizeof(hdr->protocol_id),
proto_tree_add_text(ntree, offset, sizeof(hdr->protocol_id),
"Protocol ID: %s (%u)",
proto2str(hdr->protocol_id), hdr->protocol_id);
offset += sizeof(hdr->protocol_id);
proto_tree_add_item(ntree, offset, sizeof(hdr->spi_size),
proto_tree_add_text(ntree, offset, sizeof(hdr->spi_size),
"SPI size: %u", hdr->spi_size);
offset += sizeof(hdr->spi_size);
if (hdr->spi_size) {
proto_tree_add_item(ntree, offset, hdr->spi_size, "SPI");
proto_tree_add_text(ntree, offset, hdr->spi_size, "SPI");
offset += hdr->spi_size;
}
proto_tree_add_item(ntree, offset, sizeof(hdr->num_transforms),
proto_tree_add_text(ntree, offset, sizeof(hdr->num_transforms),
"Number of transforms: %u", hdr->num_transforms);
offset += sizeof(hdr->num_transforms);
@ -451,25 +449,25 @@ dissect_transform(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
struct trans_hdr * hdr = (struct trans_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Transform payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Transform payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(hdr->transform_num),
proto_tree_add_text(ntree, offset, sizeof(hdr->transform_num),
"Transform number: %u", hdr->transform_num);
offset += sizeof(hdr->transform_num);
proto_tree_add_item(ntree, offset, sizeof(hdr->transform_id),
proto_tree_add_text(ntree, offset, sizeof(hdr->transform_id),
"Transform ID: %s (%u)",
trans2str(hdr->transform_id), hdr->transform_id);
offset += sizeof(hdr->transform_id) + sizeof(hdr->reserved2);
@ -480,7 +478,7 @@ dissect_transform(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
guint16 val_len = pntohs(pd + offset + 2);
if (pd[offset] & 0xf0) {
proto_tree_add_item(ntree, offset, 4,
proto_tree_add_text(ntree, offset, 4,
"%s (%u): %s (%u)",
atttype2str(type), type,
value2str(type, val_len), val_len);
@ -490,7 +488,7 @@ dissect_transform(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
else {
guint16 pack_len = 4 + val_len;
proto_tree_add_item(ntree, offset, pack_len,
proto_tree_add_text(ntree, offset, pack_len,
"%s (%u): %s",
atttype2str(type), type,
num2str(pd + offset + 4, val_len));
@ -510,21 +508,21 @@ dissect_key_exch(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
struct ke_hdr * hdr = (struct ke_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Key Exchange payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Key Exchange payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Key Exchange Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Key Exchange Data");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -538,45 +536,45 @@ dissect_id(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct id_hdr * hdr = (struct id_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Identification payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Identification payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(hdr->id_type),
proto_tree_add_text(ntree, offset, sizeof(hdr->id_type),
"ID type: %s (%u)", id2str(hdr->id_type), hdr->id_type);
offset += sizeof(hdr->id_type);
proto_tree_add_item(ntree, offset, sizeof(hdr->protocol_id),
proto_tree_add_text(ntree, offset, sizeof(hdr->protocol_id),
"Protocol ID: %u", hdr->protocol_id);
offset += sizeof(hdr->protocol_id);
proto_tree_add_item(ntree, offset, sizeof(hdr->port),
proto_tree_add_text(ntree, offset, sizeof(hdr->port),
"Port: %u", pntohs(&hdr->port));
offset += sizeof(hdr->port);
switch (hdr->id_type) {
case 1:
case 4:
proto_tree_add_item(ntree, offset, length-sizeof(*hdr),
proto_tree_add_text(ntree, offset, length-sizeof(*hdr),
"Identification data: %s", ip_to_str(pd+offset));
break;
case 2:
case 3:
proto_tree_add_item(ntree, offset, length-sizeof(*hdr),
proto_tree_add_text(ntree, offset, length-sizeof(*hdr),
"Identification data: %s", (char *)(pd+offset));
break;
default:
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Identification Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Identification Data");
}
offset += (length - sizeof(*hdr));
@ -591,25 +589,25 @@ dissect_cert(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct cert_hdr * hdr = (struct cert_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Certificate payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Certificate payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(hdr->cert_enc),
proto_tree_add_text(ntree, offset, sizeof(hdr->cert_enc),
"Certificate encoding: %u", hdr->cert_enc);
offset += sizeof(hdr->cert_enc);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Certificate Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Certificate Data");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -623,25 +621,25 @@ dissect_certreq(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
struct certreq_hdr * hdr = (struct certreq_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Certificate Request payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Certificate Request payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(hdr->cert_type),
proto_tree_add_text(ntree, offset, sizeof(hdr->cert_type),
"Certificate type: %u", hdr->cert_type);
offset += sizeof(hdr->cert_type);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Certificate Authority");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Certificate Authority");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -655,21 +653,21 @@ dissect_hash(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct hash_hdr * hdr = (struct hash_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Hash payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Hash payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Hash Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Hash Data");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -683,21 +681,21 @@ dissect_sig(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct sig_hdr * hdr = (struct sig_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Signature payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Signature payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Signature Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Signature Data");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -711,21 +709,21 @@ dissect_nonce(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct nonce_hdr * hdr = (struct nonce_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Nonce payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Nonce payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Nonce Data");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Nonce Data");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -741,44 +739,44 @@ dissect_notif(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 length = pntohs(&hdr->length);
guint32 doi = pntohl(&hdr->doi);
guint16 msgtype = pntohs(&hdr->msgtype);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Notification payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Notification payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(doi),
proto_tree_add_text(ntree, offset, sizeof(doi),
"Domain of Interpretation: %s (%u)", doitype2str(doi), doi);
offset += sizeof(doi);
proto_tree_add_item(ntree, offset, sizeof(hdr->protocol_id),
proto_tree_add_text(ntree, offset, sizeof(hdr->protocol_id),
"Protocol ID: %s (%u)",
proto2str(hdr->protocol_id), hdr->protocol_id);
offset += sizeof(hdr->protocol_id);
proto_tree_add_item(ntree, offset, sizeof(hdr->spi_size),
proto_tree_add_text(ntree, offset, sizeof(hdr->spi_size),
"SPI size: %u", hdr->spi_size);
offset += sizeof(hdr->spi_size);
proto_tree_add_item(ntree, offset, sizeof(msgtype),
proto_tree_add_text(ntree, offset, sizeof(msgtype),
"Message type: %s (%u)", msgtype2str(msgtype), msgtype);
offset += sizeof(msgtype);
if (hdr->spi_size) {
proto_tree_add_item(ntree, offset, hdr->spi_size, "Security Parameter Index");
proto_tree_add_text(ntree, offset, hdr->spi_size, "Security Parameter Index");
offset += hdr->spi_size;
}
if (length - sizeof(*hdr)) {
proto_tree_add_item(ntree, offset, length - sizeof(*hdr) - hdr->spi_size,
proto_tree_add_text(ntree, offset, length - sizeof(*hdr) - hdr->spi_size,
"Notification Data");
offset += (length - sizeof(*hdr) - hdr->spi_size);
}
@ -796,40 +794,40 @@ dissect_delete(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 length = pntohs(&hdr->length);
guint32 doi = pntohl(&hdr->doi);
guint16 num_spis = pntohs(&hdr->num_spis);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Delete payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Delete payload");
proto_tree * ntree;
guint16 i;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, sizeof(doi),
proto_tree_add_text(ntree, offset, sizeof(doi),
"Domain of Interpretation: %s (%u)", doitype2str(doi), doi);
offset += sizeof(doi);
proto_tree_add_item(ntree, offset, sizeof(hdr->protocol_id),
proto_tree_add_text(ntree, offset, sizeof(hdr->protocol_id),
"Protocol ID: %s (%u)",
proto2str(hdr->protocol_id), hdr->protocol_id);
offset += sizeof(hdr->protocol_id);
proto_tree_add_item(ntree, offset, sizeof(hdr->spi_size),
proto_tree_add_text(ntree, offset, sizeof(hdr->spi_size),
"SPI size: %u", hdr->spi_size);
offset += sizeof(hdr->spi_size);
proto_tree_add_item(ntree, offset, num_spis,
proto_tree_add_text(ntree, offset, num_spis,
"Number of SPIs: %u", num_spis);
offset += sizeof(hdr->num_spis);
for (i = 0; i < num_spis; ++i) {
proto_tree_add_item(ntree, offset, hdr->spi_size,
proto_tree_add_text(ntree, offset, hdr->spi_size,
"SPI (%d)", i);
offset += hdr->spi_size;
}
@ -845,21 +843,21 @@ dissect_vid(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct vid_hdr * hdr = (struct vid_hdr *)(pd + offset);
guint16 length = pntohs(&hdr->length);
proto_item * ti = proto_tree_add_item(tree, offset, length, "Vendor ID payload");
proto_tree * ntree = proto_tree_new();
proto_item * ti = proto_tree_add_text(tree, offset, length, "Vendor ID payload");
proto_tree * ntree;
proto_item_add_subtree(ti, ntree, ETT_ISAKMP_PAYLOAD);
ntree = proto_item_add_subtree(ti, ETT_ISAKMP_PAYLOAD);
proto_tree_add_item(ntree, offset, sizeof(hdr->next_payload),
proto_tree_add_text(ntree, offset, sizeof(hdr->next_payload),
"Next payload: %s (%u)",
payloadtype2str(hdr->next_payload), hdr->next_payload);
offset += sizeof(hdr->next_payload) * 2;
proto_tree_add_item(ntree, offset, sizeof(length),
proto_tree_add_text(ntree, offset, sizeof(length),
"Length: %u", length);
offset += sizeof(length);
proto_tree_add_item(ntree, offset, length - sizeof(*hdr), "Vendor ID");
proto_tree_add_text(ntree, offset, length - sizeof(*hdr), "Vendor ID");
offset += (length - sizeof(*hdr));
if (hdr->next_payload < NUM_LOAD_TYPES)
@ -1035,10 +1033,10 @@ num2str(const guint8 *pd, guint16 len) {
snprintf(numstr, NUMSTR_LEN, "%u", pntohs(pd));
break;
case 3:
snprintf(numstr, NUMSTR_LEN, "%u", pntohl(pd) & 0x0fff);
snprintf(numstr, NUMSTR_LEN, "%lu", pntohl(pd) & 0x0fff);
break;
case 4:
snprintf(numstr, NUMSTR_LEN, "%u", pntohl(pd));
snprintf(numstr, NUMSTR_LEN, "%lu", pntohl(pd));
break;
default:
snprintf(numstr, NUMSTR_LEN, "<too big>");

View File

@ -1,8 +1,8 @@
/* packet-llc.c
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
* Gilbert Ramirez <gramirez@tivoli.com>
*
* $Id: packet-llc.c,v 1.14 1999/03/23 03:14:39 gram Exp $
* $Id: packet-llc.c,v 1.15 1999/07/07 22:51:46 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -34,64 +34,105 @@
#include <glib.h>
#include "packet.h"
int proto_llc = -1;
int hf_llc_dsap = -1;
int hf_llc_ssap = -1;
int hf_llc_ctrl = -1;
int hf_llc_type = -1;
int hf_llc_oui = -1;
typedef void (capture_func_t)(const u_char *, int, guint32, packet_counts *);
typedef void (dissect_func_t)(const u_char *, int, frame_data *, proto_tree *);
/* The SAP info is split into two tables, one value_string table and one table of sap_info. This is
* so that the value_string can be used in the header field registration.
*/
struct sap_info {
guint8 sap;
capture_func_t *capture_func;
dissect_func_t *dissect_func;
char *text;
};
static const value_string sap_vals[] = {
{ 0x00, "NULL LSAP" },
{ 0x02, "LLC Sub-Layer Management Individual" },
{ 0x03, "LLC Sub-Layer Management Group" },
{ 0x04, "SNA Path Control Individual" },
{ 0x05, "SNA Path Control Group" },
{ 0x06, "TCP/IP" },
{ 0x08, "SNA" },
{ 0x0C, "SNA" },
{ 0x42, "Spanning Tree BPDU" },
{ 0x7F, "ISO 802.2" },
{ 0x80, "XNS" },
{ 0xAA, "SNAP" },
{ 0xBA, "Banyan Vines" },
{ 0xBC, "Banyan Vines" },
{ 0xE0, "NetWare" },
{ 0xF0, "NetBIOS" },
{ 0xF4, "IBM Net Management Individual" },
{ 0xF5, "IBM Net Management Group" },
{ 0xF8, "Remote Program Load" },
{ 0xFC, "Remote Program Load" },
{ 0xFE, "ISO Network Layer" },
{ 0xFF, "Global LSAP" },
{ 0x00, NULL }
};
static struct sap_info saps[] = {
{ 0x00, NULL, NULL, "NULL LSAP" },
{ 0x02, NULL, NULL, "LLC Sub-Layer Management Individual" },
{ 0x03, NULL, NULL, "LLC Sub-Layer Management Group" },
{ 0x04, NULL, NULL, "SNA Path Control Individual" },
{ 0x05, NULL, NULL, "SNA Path Control Group" },
{ 0x06, capture_ip, dissect_ip, "TCP/IP" },
{ 0x08, NULL, NULL, "SNA" },
{ 0x0C, NULL, NULL, "SNA" },
{ 0x42, NULL, NULL, "Spanning Tree BPDU" },
{ 0x7F, NULL, NULL, "ISO 802.2" },
{ 0x80, NULL, NULL, "XNS" },
{ 0xAA, NULL, NULL, "SNAP" },
/*{ 0xBA, NULL, dissect_vines, "Banyan Vines" },
{ 0xBC, NULL, dissect_vines, "Banyan Vines" },*/
{ 0xBA, NULL, NULL, "Banyan Vines" },
{ 0xBC, NULL, NULL, "Banyan Vines" },
{ 0xE0, NULL, dissect_ipx, "NetWare" },
{ 0xF0, NULL, NULL, "NetBIOS" },
{ 0xF4, NULL, NULL, "IBM Net Management Individual" },
{ 0xF5, NULL, NULL, "IBM Net Management Group" },
{ 0xF8, NULL, NULL, "Remote Program Load" },
{ 0xFC, NULL, NULL, "Remote Program Load" },
{ 0xFE, NULL, dissect_osi, "ISO Network Layer" },
{ 0xFF, NULL, NULL, "Global LSAP" },
{ 0x00, NULL, NULL, NULL }
{ 0x00, NULL, NULL },
{ 0x02, NULL, NULL },
{ 0x03, NULL, NULL },
{ 0x04, NULL, NULL },
{ 0x05, NULL, NULL },
{ 0x06, capture_ip, dissect_ip },
{ 0x08, NULL, NULL },
{ 0x0C, NULL, NULL },
{ 0x42, NULL, NULL },
{ 0x7F, NULL, NULL },
{ 0x80, NULL, NULL },
{ 0xAA, NULL, NULL },
{ 0xBA, NULL, NULL },
{ 0xBC, NULL, NULL },
{ 0xE0, NULL, dissect_ipx },
{ 0xF0, NULL, NULL },
{ 0xF4, NULL, NULL },
{ 0xF5, NULL, NULL },
{ 0xF8, NULL, NULL },
{ 0xFC, NULL, NULL },
{ 0xFE, NULL, dissect_osi },
{ 0xFF, NULL, NULL },
{ 0x00, NULL, NULL}
};
static const value_string llc_ctrl_vals[] = {
{ 0, "Information Transfer" },
{ 1, "Supervisory" },
{ 2, "Unknown" },
{ 3, "Unnumbered Information" },
{ 0, NULL }
};
static char*
sap_text(u_char sap) {
int i=0;
while (saps[i].text != NULL) {
if (saps[i].sap == sap) {
return saps[i].text;
}
i++;
}
return "Unknown";
}
static const value_string llc_oui_vals[] = {
{ 0x000000, "Encapsulated Ethernet" },
/*
http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r/brprt1/brsrb.htm
*/
{ 0x0000f8, "Cisco 90-Compatible" },
{ 0x0000c0, "Cisco" },
{ 0x0080c2, "Bridged Frame-Relay" }, /* RFC 2427 */
{ 0, NULL }
};
static capture_func_t *
sap_capture_func(u_char sap) {
int i=0;
while (saps[i].text != NULL) {
/* look for the second record where sap == 0, which should
* be the last record
*/
while (saps[i].sap > 0 || i == 0) {
if (saps[i].sap == sap) {
return saps[i].capture_func;
}
@ -104,7 +145,10 @@ static dissect_func_t *
sap_dissect_func(u_char sap) {
int i=0;
while (saps[i].text != NULL) {
/* look for the second record where sap == 0, which should
* be the last record
*/
while (saps[i].sap > 0 || i == 0) {
if (saps[i].sap == sap) {
return saps[i].dissect_func;
}
@ -113,20 +157,6 @@ sap_dissect_func(u_char sap) {
return dissect_data;
}
static char*
llc_org(const u_char *ptr) {
unsigned long org = (ptr[0] << 16) | (ptr[1] << 8) | ptr[2];
char *llc_org[1] = {
"Encapsulated Ethernet"};
if (org > 0) {
return "Unknown";
}
else {
return llc_org[org];
}
}
void
capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
@ -166,11 +196,6 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
int is_snap;
dissect_func_t *dissect;
/* LLC Strings */
char *llc_ctrl[4] = {
"Information Transfer", "Supervisory",
"", "Unnumbered Information" };
is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
if (check_col(fd, COL_PROTOCOL)) {
@ -178,16 +203,11 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree, offset, (is_snap ? 8 : 3),
"Logical-Link Control");
llc_tree = proto_tree_new();
proto_item_add_subtree(ti, llc_tree, ETT_LLC);
proto_tree_add_item(llc_tree, offset, 1, "DSAP: %s (0x%02X)",
sap_text(pd[offset]), pd[offset]);
proto_tree_add_item(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
sap_text(pd[offset+1]), pd[offset+1]);
proto_tree_add_item(llc_tree, offset+2, 1, "Control: %s",
llc_ctrl[pd[offset+2] & 3]);
ti = proto_tree_add_item(tree, proto_llc, offset, (is_snap ? 8 : 3), NULL);
llc_tree = proto_item_add_subtree(ti, ETT_LLC);
proto_tree_add_item(llc_tree, hf_llc_dsap, offset, 1, pd[offset]);
proto_tree_add_item(llc_tree, hf_llc_ssap, offset+1, 1, pd[offset+1]);
proto_tree_add_item(llc_tree, hf_llc_ctrl, offset+2, 1, pd[offset+2] & 3);
}
if (is_snap) {
@ -195,18 +215,18 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_INFO, "802.2 LLC (SNAP)");
}
if (tree) {
proto_tree_add_item(llc_tree, offset+3, 3,
"Organization Code: %s (%02X-%02X-%02X)",
llc_org(&pd[offset+3]),
pd[offset+3], pd[offset+4], pd[offset+5]);
proto_tree_add_item(llc_tree, hf_llc_oui, offset+3, 3,
pd[offset+3] << 16 | pd[offset+4] << 8 | pd[offset+5]);
}
etype = (pd[offset+6] << 8) | pd[offset+7];
etype = pntohs(&pd[offset+6]);
offset += 8;
ethertype(etype, offset, pd, fd, tree, llc_tree);
/* w/o even checking, assume OUI is ethertype */
ethertype(etype, offset, pd, fd, tree, llc_tree, hf_llc_type);
}
else {
if (check_col(fd, COL_INFO)) {
col_add_fstr(fd, COL_INFO, "802.2 LLC (%s)", sap_text(pd[offset]));
col_add_fstr(fd, COL_INFO, "802.2 LLC (%s)",
val_to_str(pd[offset], sap_vals, "%02x"));
}
dissect = sap_dissect_func(pd[offset]);
@ -223,3 +243,21 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
}
void
proto_register_llc(void)
{
const hf_register_info hf[] = {
{ "DSAP", "llc.dsap", &hf_llc_dsap, FT_VALS_UINT8, VALS(sap_vals) },
{ "SSAP", "llc.ssap", &hf_llc_ssap, FT_VALS_UINT8, VALS(sap_vals) },
{ "Control", "llc.control", &hf_llc_ctrl, FT_VALS_UINT8, VALS(llc_ctrl_vals) },
/* registered here but handled in ethertype.c */
{ "Type", "llc.type", &hf_llc_type, FT_VALS_UINT16, VALS(etype_vals) },
{ "Organization Code", "llc.oui", &hf_llc_oui, FT_VALS_UINT24, VALS(llc_oui_vals) }
};
proto_llc = proto_register_protocol ("Logical-Link Control", "llc" );
proto_register_field_array(proto_llc, hf, array_length(hf));
}

View File

@ -2,7 +2,7 @@
* Routines for LPR and LPRng packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-lpd.c,v 1.7 1999/03/23 03:14:39 gram Exp $
* $Id: packet-lpd.c,v 1.8 1999/07/07 22:51:47 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -93,18 +93,17 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
if (tree) {
ti = proto_tree_add_item(tree, offset, fd->cap_len - offset,
ti = proto_tree_add_text(tree, offset, fd->cap_len - offset,
"Line Printer Daemon Protocol");
lpd_tree = proto_tree_new();
proto_item_add_subtree(ti, lpd_tree, ETT_LPD);
lpd_tree = proto_item_add_subtree(ti, ETT_LPD);
if (lpr_packet_type == request) {
if (pd[offset] <= 9) {
proto_tree_add_item(lpd_tree, offset, 1,
proto_tree_add_text(lpd_tree, offset, 1,
lpd_client_code[pd[offset]]);
}
else {
proto_tree_add_item(lpd_tree, offset, 1,
proto_tree_add_text(lpd_tree, offset, 1,
lpd_client_code[0]);
}
printer = g_strdup(&pd[offset+1]);
@ -113,14 +112,14 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (printer[fd->cap_len - offset - 2] == 0x0a) {
printer[fd->cap_len - offset - 2] = 0;
}
proto_tree_add_item(lpd_tree, offset+1, fd->cap_len - (offset+1),
proto_tree_add_text(lpd_tree, offset+1, fd->cap_len - (offset+1),
/*"Printer/options: %s", &pd[offset+1]);*/
"Printer/options: %s", printer);
g_free(printer);
}
else {
if (pd[offset] <= 3) {
proto_tree_add_item(lpd_tree, offset, 2, "Response: %s",
proto_tree_add_text(lpd_tree, offset, 2, "Response: %s",
lpd_server_code[pd[offset]]);
}
else {
@ -130,13 +129,13 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
while (fd->cap_len > curr_offset) {
newline = strchr(line_pos, '\n');
if (!newline) {
proto_tree_add_item(lpd_tree, curr_offset,
proto_tree_add_text(lpd_tree, curr_offset,
fd->cap_len - offset, "Text: %s", line_pos);
break;
}
*newline = 0;
substr_len = strlen(line_pos);
proto_tree_add_item(lpd_tree, curr_offset, substr_len + 1,
proto_tree_add_text(lpd_tree, curr_offset, substr_len + 1,
"Text: %s", line_pos);
curr_offset += substr_len + 1;
line_pos = newline + 1;

View File

@ -2,7 +2,7 @@
* Routines for NetBIOS over IPX packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-nbipx.c,v 1.7 1999/05/10 19:01:32 gram Exp $
* $Id: packet-nbipx.c,v 1.8 1999/07/07 22:51:47 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -141,18 +141,17 @@ nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
}
if (tree) {
ti = proto_tree_add_item(tree, offset, 68,
ti = proto_tree_add_text(tree, offset, 68,
"NetBIOS over IPX");
nbipx_tree = proto_tree_new();
proto_item_add_subtree(ti, nbipx_tree, ETT_NBIPX);
nbipx_tree = proto_item_add_subtree(ti, ETT_NBIPX);
if (header.packet_type <= 1) {
proto_tree_add_item(nbipx_tree, offset+33, 1,
proto_tree_add_text(nbipx_tree, offset+33, 1,
"Packet Type: %s (%02X)", packet_type[header.packet_type],
header.packet_type);
}
else {
proto_tree_add_item(nbipx_tree, offset+33, 1,
proto_tree_add_text(nbipx_tree, offset+33, 1,
"Packet Type: Unknown (%02X)", header.packet_type);
}
@ -161,22 +160,22 @@ nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
rtr_offset = offset + (i << 2);
memcpy(&header.router[i], &pd[rtr_offset], 4);
if (header.router[i] != 0) {
proto_tree_add_item(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
proto_tree_add_text(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
ipxnet_to_string((guint8*)&header.router[i]));
}
}
proto_tree_add_item(nbipx_tree, offset+32, 1, "Name Type: %02X",
proto_tree_add_text(nbipx_tree, offset+32, 1, "Name Type: %02X",
header.name_type);
if (nbipx == NETBIOS_NETWARE) {
proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
proto_tree_add_text(nbipx_tree, offset+name_offset, 16,
"Name String: %s", header.name);
}
else {
proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
proto_tree_add_text(nbipx_tree, offset+name_offset, 16,
"Group Name String: %s", header.name);
proto_tree_add_item(nbipx_tree, offset+52, 16,
proto_tree_add_text(nbipx_tree, offset+52, 16,
"Node Name String: %s", header.node_name);
}

View File

@ -4,7 +4,7 @@
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
* Much stuff added by Guy Harris <guy@netapp.com>
*
* $Id: packet-nbns.c,v 1.21 1999/06/01 20:40:34 guy Exp $
* $Id: packet-nbns.c,v 1.22 1999/07/07 22:51:47 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -303,18 +303,17 @@ dissect_nbns_query(const u_char *nbns_data_ptr, const u_char *pd, int offset,
type_name = nbns_type_name(type);
class_name = dns_class_name(class);
tq = proto_tree_add_item(nbns_tree, offset, len, "%s: type %s, class %s",
tq = proto_tree_add_text(nbns_tree, offset, len, "%s: type %s, class %s",
name, type_name, class_name);
q_tree = proto_tree_new();
proto_item_add_subtree(tq, q_tree, ETT_NBNS_QD);
q_tree = proto_item_add_subtree(tq, ETT_NBNS_QD);
proto_tree_add_item(q_tree, offset, name_len, "Name: %s", name);
proto_tree_add_text(q_tree, offset, name_len, "Name: %s", name);
offset += name_len;
proto_tree_add_item(q_tree, offset, 2, "Type: %s", type_name);
proto_tree_add_text(q_tree, offset, 2, "Type: %s", type_name);
offset += 2;
proto_tree_add_item(q_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_text(q_tree, offset, 2, "Class: %s", class_name);
offset += 2;
return dptr - data_start;
@ -347,49 +346,48 @@ nbns_add_nbns_flags(proto_tree *nbns_tree, int offset, u_short flags,
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
"Unknown error"));
}
tf = proto_tree_add_item(nbns_tree, offset, 2,
tf = proto_tree_add_text(nbns_tree, offset, 2,
"Flags: 0x%04x (%s)", flags, buf);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_NBNS_FLAGS);
proto_tree_add_item(field_tree, offset, 2, "%s",
field_tree = proto_item_add_subtree(tf, ETT_NBNS_FLAGS);
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_RESPONSE,
2*8, "Response", "Query"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, F_OPCODE,
2*8, opcode_vals, "%s"));
if (flags & F_RESPONSE) {
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"%s",
decode_boolean_bitfield(flags, F_AUTHORITATIVE,
2*8,
"Server is an authority for domain",
"Server isn't an authority for domain"));
}
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_TRUNCATED,
2*8,
"Message is truncated",
"Message is not truncated"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_RECDESIRED,
2*8,
"Do query recursively",
"Don't do query recursively"));
if (flags & F_RESPONSE) {
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"%s",
decode_boolean_bitfield(flags, F_RECAVAIL,
2*8,
"Server can do recursive queries",
"Server can't do recursive queries"));
}
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_BROADCAST,
2*8,
"Broadcast packet",
"Not a broadcast packet"));
if (flags & F_RESPONSE && !is_wack) {
proto_tree_add_item(field_tree, offset, 2,
proto_tree_add_text(field_tree, offset, 2,
"%s",
decode_enumerated_bitfield(flags, F_RCODE,
2*8,
@ -418,16 +416,15 @@ nbns_add_nb_flags(proto_tree *rr_tree, int offset, u_short flags)
strcat(buf, "group");
else
strcat(buf, "unique");
tf = proto_tree_add_item(rr_tree, offset, 2, "Flags: 0x%x (%s)", flags,
tf = proto_tree_add_text(rr_tree, offset, 2, "Flags: 0x%x (%s)", flags,
buf);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_NBNS_NB_FLAGS);
proto_tree_add_item(field_tree, offset, 2, "%s",
field_tree = proto_item_add_subtree(tf, ETT_NBNS_NB_FLAGS);
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NB_FLAGS_G,
2*8,
"Group name",
"Unique name"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, NB_FLAGS_ONT,
2*8, nb_flags_ont_vals, "%s"));
}
@ -460,34 +457,33 @@ nbns_add_name_flags(proto_tree *rr_tree, int offset, u_short flags)
strcat(buf, ", active");
if (flags & NAME_FLAGS_PRM)
strcat(buf, ", permanent node name");
tf = proto_tree_add_item(rr_tree, offset, 2, "Name flags: 0x%x (%s)",
tf = proto_tree_add_text(rr_tree, offset, 2, "Name flags: 0x%x (%s)",
flags, buf);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_NBNS_NAME_FLAGS);
proto_tree_add_item(field_tree, offset, 2, "%s",
field_tree = proto_item_add_subtree(tf, ETT_NBNS_NAME_FLAGS);
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_G,
2*8,
"Group name",
"Unique name"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, NAME_FLAGS_ONT,
2*8, name_flags_ont_vals, "%s"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_DRG,
2*8,
"Name is being deregistered",
"Name is not being deregistered"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_CNF,
2*8,
"Name is in conflict",
"Name is not in conflict"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_ACT,
2*8,
"Name is active",
"Name is not active"));
proto_tree_add_item(field_tree, offset, 2, "%s",
proto_tree_add_text(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_PRM,
2*8,
"Permanent node name",
@ -530,7 +526,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
switch (type) {
case T_NB: /* "NB" record */
trr = proto_tree_add_item(nbns_tree, offset,
trr = proto_tree_add_text(nbns_tree, offset,
(dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
@ -543,7 +539,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
* same type of RR data as other T_NB
* responses. */
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
@ -554,7 +550,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 2;
} else {
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
@ -565,11 +561,11 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 2;
if (data_len < 4) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 4,
proto_tree_add_text(rr_tree, offset, 4,
"Addr: %s",
ip_to_str((guint8 *)dptr));
dptr += 4;
@ -585,7 +581,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
char nbname[16+4+1]; /* 4 for [<last char>] */
u_short name_flags;
trr = proto_tree_add_item(nbns_tree, offset,
trr = proto_tree_add_text(nbns_tree, offset,
(dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
@ -593,32 +589,32 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
name_len, type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
if (data_len < 1) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
num_names = *dptr;
dptr += 1;
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of names: %u", num_names);
offset += 1;
while (num_names != 0) {
if (data_len < 16) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
goto out;
}
memcpy(nbname, dptr, 16);
dptr += 16;
canonicalize_netbios_name(nbname);
proto_tree_add_item(rr_tree, offset, 16,
proto_tree_add_text(rr_tree, offset, 16,
"Name: %s", nbname);
offset += 16;
data_len -= 16;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
goto out;
}
@ -632,11 +628,11 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
}
if (data_len < 6) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 6,
proto_tree_add_text(rr_tree, offset, 6,
"Unit ID: %s",
ether_to_str((guint8 *)dptr));
dptr += 6;
@ -644,181 +640,181 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 6;
if (data_len < 1) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 1,
proto_tree_add_text(rr_tree, offset, 1,
"Jumpers: 0x%x", *dptr);
dptr += 1;
offset += 1;
data_len -= 1;
if (data_len < 1) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 1,
proto_tree_add_text(rr_tree, offset, 1,
"Test result: 0x%x", *dptr);
dptr += 1;
offset += 1;
data_len -= 1;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Version number: 0x%x", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Period of statistics: 0x%x", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of CRCs: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of alignment errors: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of collisions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of send aborts: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 4) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 4,
proto_tree_add_text(rr_tree, offset, 4,
"Number of good sends: %u", pntohl(dptr));
dptr += 4;
offset += 4;
data_len -= 4;
if (data_len < 4) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 4,
proto_tree_add_text(rr_tree, offset, 4,
"Number of good receives: %u", pntohl(dptr));
dptr += 4;
offset += 4;
data_len -= 4;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of retransmits: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of no resource conditions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of command blocks: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Number of pending sessions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Max number of pending sessions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Max total sessions possible: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
proto_tree_add_item(rr_tree, offset,
proto_tree_add_text(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
proto_tree_add_item(rr_tree, offset, 2,
proto_tree_add_text(rr_tree, offset, 2,
"Session data packet size: %u", pntohs(dptr));
dptr += 2;
offset += 2;
@ -828,14 +824,14 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
break;
default:
trr = proto_tree_add_item(nbns_tree, offset,
trr = proto_tree_add_text(nbns_tree, offset,
(dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
rr_tree = add_rr_to_tree(trr, ETT_NBNS_RR, offset, name,
name_len, type_name, class_name, ttl, data_len);
offset += (dptr - data_start);
proto_tree_add_item(rr_tree, offset, data_len, "Data");
proto_tree_add_text(rr_tree, offset, data_len, "Data");
break;
}
dptr += data_len;
@ -852,9 +848,8 @@ dissect_query_records(const u_char *nbns_data_ptr, int count, const u_char *pd,
proto_item *ti;
start_off = cur_off;
ti = proto_tree_add_item(nbns_tree, start_off, 0, "Queries");
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_NBNS_QRY);
ti = proto_tree_add_text(nbns_tree, start_off, 0, "Queries");
qatree = proto_item_add_subtree(ti, ETT_NBNS_QRY);
while (count-- > 0)
cur_off += dissect_nbns_query(nbns_data_ptr, pd, cur_off, qatree);
proto_item_set_len(ti, cur_off - start_off);
@ -873,9 +868,8 @@ dissect_answer_records(const u_char *nbns_data_ptr, int count,
proto_item *ti;
start_off = cur_off;
ti = proto_tree_add_item(nbns_tree, start_off, 0, name);
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_NBNS_ANS);
ti = proto_tree_add_text(nbns_tree, start_off, 0, name);
qatree = proto_item_add_subtree(ti, ETT_NBNS_ANS);
while (count-- > 0)
cur_off += dissect_nbns_answer(nbns_data_ptr, pd, cur_off,
qatree, opcode);
@ -912,25 +906,24 @@ dissect_nbns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"NetBIOS Name Service");
nbns_tree = proto_tree_new();
proto_item_add_subtree(ti, nbns_tree, ETT_NBNS);
nbns_tree = proto_item_add_subtree(ti, ETT_NBNS);
proto_tree_add_item(nbns_tree, offset + NBNS_ID, 2,
proto_tree_add_text(nbns_tree, offset + NBNS_ID, 2,
"Transaction ID: 0x%04X", id);
nbns_add_nbns_flags(nbns_tree, offset + NBNS_FLAGS, flags, 0);
proto_tree_add_item(nbns_tree, offset + NBNS_QUEST, 2,
proto_tree_add_text(nbns_tree, offset + NBNS_QUEST, 2,
"Questions: %d",
quest);
proto_tree_add_item(nbns_tree, offset + NBNS_ANS, 2,
proto_tree_add_text(nbns_tree, offset + NBNS_ANS, 2,
"Answer RRs: %d",
ans);
proto_tree_add_item(nbns_tree, offset + NBNS_AUTH, 2,
proto_tree_add_text(nbns_tree, offset + NBNS_AUTH, 2,
"Authority RRs: %d",
auth);
proto_tree_add_item(nbns_tree, offset + NBNS_ADD, 2,
proto_tree_add_text(nbns_tree, offset + NBNS_ADD, 2,
"Additional RRs: %d",
add);
@ -1052,25 +1045,24 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
}
if (tree) {
ti = proto_tree_add_item(tree, offset, header.dgm_length,
ti = proto_tree_add_text(tree, offset, header.dgm_length,
"NetBIOS Datagram Service");
nbdgm_tree = proto_tree_new();
proto_item_add_subtree(ti, nbdgm_tree, ETT_NBDGM);
nbdgm_tree = proto_item_add_subtree(ti, ETT_NBDGM);
proto_tree_add_item(nbdgm_tree, offset, 1, "Message Type: %s",
proto_tree_add_text(nbdgm_tree, offset, 1, "Message Type: %s",
message[message_index]);
proto_tree_add_item(nbdgm_tree, offset+1, 1, "More fragments follow: %s",
proto_tree_add_text(nbdgm_tree, offset+1, 1, "More fragments follow: %s",
yesno[header.flags.more]);
proto_tree_add_item(nbdgm_tree, offset+1, 1, "This is first fragment: %s",
proto_tree_add_text(nbdgm_tree, offset+1, 1, "This is first fragment: %s",
yesno[header.flags.first]);
proto_tree_add_item(nbdgm_tree, offset+1, 1, "Node Type: %s",
proto_tree_add_text(nbdgm_tree, offset+1, 1, "Node Type: %s",
node[header.flags.node_type]);
proto_tree_add_item(nbdgm_tree, offset+2, 2, "Datagram ID: 0x%04X",
proto_tree_add_text(nbdgm_tree, offset+2, 2, "Datagram ID: 0x%04X",
header.dgm_id);
proto_tree_add_item(nbdgm_tree, offset+4, 4, "Source IP: %s",
proto_tree_add_text(nbdgm_tree, offset+4, 4, "Source IP: %s",
ip_to_str((guint8 *)&header.src_ip));
proto_tree_add_item(nbdgm_tree, offset+8, 2, "Source Port: %d",
proto_tree_add_text(nbdgm_tree, offset+8, 2, "Source Port: %d",
header.src_port);
}
@ -1081,9 +1073,9 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
header.msg_type == 0x11 || header.msg_type == 0x12) {
if (tree) {
proto_tree_add_item(nbdgm_tree, offset, 2,
proto_tree_add_text(nbdgm_tree, offset, 2,
"Datagram length: %d bytes", header.dgm_length);
proto_tree_add_item(nbdgm_tree, offset+2, 2,
proto_tree_add_text(nbdgm_tree, offset+2, 2,
"Packet offset: %d bytes", header.pkt_offset);
}
@ -1094,7 +1086,7 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
len = get_nbns_name(&pd[offset], pd, offset, name);
if (tree) {
proto_tree_add_item(nbdgm_tree, offset, len, "Source name: %s",
proto_tree_add_text(nbdgm_tree, offset, len, "Source name: %s",
name);
}
offset += len;
@ -1104,7 +1096,7 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
len = get_nbns_name(&pd[offset], pd, offset, name);
if (tree) {
proto_tree_add_item(nbdgm_tree, offset, len, "Destination name: %s",
proto_tree_add_text(nbdgm_tree, offset, len, "Destination name: %s",
name);
}
offset += len;
@ -1115,7 +1107,7 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
}
else if (header.msg_type == 0x13) {
if (tree) {
proto_tree_add_item(nbdgm_tree, offset, 1, "Error code: %s",
proto_tree_add_text(nbdgm_tree, offset, 1, "Error code: %s",
val_to_str(header.error_code, error_codes, "Unknown (0x%x)"));
}
}
@ -1125,7 +1117,7 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
len = get_nbns_name(&pd[offset], pd, offset, name);
if (tree) {
proto_tree_add_item(nbdgm_tree, offset, len, "Destination name: %s",
proto_tree_add_text(nbdgm_tree, offset, len, "Destination name: %s",
name);
}
}
@ -1192,22 +1184,20 @@ dissect_nbss_packet(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
length += 65536;
if (tree) {
ti = proto_tree_add_item(tree, offset, length + 4,
ti = proto_tree_add_text(tree, offset, length + 4,
"NetBIOS Session Service");
nbss_tree = proto_tree_new();
proto_item_add_subtree(ti, nbss_tree, ETT_NBSS);
nbss_tree = proto_item_add_subtree(ti, ETT_NBSS);
proto_tree_add_item(nbss_tree, offset, 1, "Message Type: %s",
proto_tree_add_text(nbss_tree, offset, 1, "Message Type: %s",
val_to_str(msg_type, message_types, "Unknown (%x)"));
}
offset += 1;
if (tree) {
tf = proto_tree_add_item(nbss_tree, offset, 1, "Flags: 0x%04x", flags);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_NBSS_FLAGS);
proto_tree_add_item(field_tree, offset, 1, "%s",
tf = proto_tree_add_text(nbss_tree, offset, 1, "Flags: 0x%04x", flags);
field_tree = proto_item_add_subtree(tf, ETT_NBSS_FLAGS);
proto_tree_add_text(field_tree, offset, 1, "%s",
decode_boolean_bitfield(flags, NBSS_FLAGS_E,
8, "Add 65536 to length", "Add 0 to length"));
}
@ -1215,7 +1205,7 @@ dissect_nbss_packet(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
offset += 1;
if (tree) {
proto_tree_add_item(nbss_tree, offset, 2, "Length: %u", length);
proto_tree_add_text(nbss_tree, offset, 2, "Length: %u", length);
}
offset += 2;
@ -1225,35 +1215,35 @@ dissect_nbss_packet(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
case SESSION_REQUEST:
len = get_nbns_name(&pd[offset], pd, offset, name);
if (tree)
proto_tree_add_item(nbss_tree, offset, len,
proto_tree_add_text(nbss_tree, offset, len,
"Called name: %s", name);
offset += len;
len = get_nbns_name(&pd[offset], pd, offset, name);
if (tree)
proto_tree_add_item(nbss_tree, offset, len,
proto_tree_add_text(nbss_tree, offset, len,
"Calling name: %s", name);
break;
case NEGATIVE_SESSION_RESPONSE:
if (tree)
proto_tree_add_item(nbss_tree, offset, 1,
proto_tree_add_text(nbss_tree, offset, 1,
"Error code: %s",
val_to_str(pd[offset], error_codes, "Unknown (%x)"));
break;
case RETARGET_SESSION_RESPONSE:
if (tree)
proto_tree_add_item(nbss_tree, offset, 4,
proto_tree_add_text(nbss_tree, offset, 4,
"Retarget IP address: %s",
ip_to_str((guint8 *)&pd[offset]));
offset += 4;
if (tree)
proto_tree_add_item(nbss_tree, offset, 2,
proto_tree_add_text(nbss_tree, offset, 2,
"Retarget port: %u", pntohs(&pd[offset]));
break;

View File

@ -2,7 +2,7 @@
* Routines for NetWare Core Protocol
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-ncp.c,v 1.15 1999/05/26 21:46:07 gram Exp $
* $Id: packet-ncp.c,v 1.16 1999/07/07 22:51:48 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -60,9 +60,10 @@ parse_ncp_svc_fields(const u_char *pd, proto_tree *ncp_tree, int offset,
/* Hash functions */
gint ncp_equal (const gpointer v, const gpointer v2);
guint ncp_hash (const gpointer v);
gint ncp_equal (gconstpointer v, gconstpointer v2);
guint ncp_hash (gconstpointer v);
int ncp_packet_init_count = 200;
/* The information in this module comes from:
NetWare LAN Analysis, Second Edition
@ -343,7 +344,7 @@ GMemChunk *ncp_request_keys = NULL;
GMemChunk *ncp_request_records = NULL;
/* Hash Functions */
gint ncp_equal (const gpointer v, const gpointer v2)
gint ncp_equal (gconstpointer v, gconstpointer v2)
{
struct ncp_request_key *val1 = (struct ncp_request_key*)v;
struct ncp_request_key *val2 = (struct ncp_request_key*)v2;
@ -362,7 +363,7 @@ gint ncp_equal (const gpointer v, const gpointer v2)
return 0;
}
guint ncp_hash (const gpointer v)
guint ncp_hash (gconstpointer v)
{
struct ncp_request_key *ncp_key = (struct ncp_request_key*)v;
#if defined(DEBUG_NCP_HASH)
@ -393,10 +394,10 @@ ncp_init_protocol(void)
ncp_request_hash = g_hash_table_new(ncp_hash, ncp_equal);
ncp_request_keys = g_mem_chunk_new("ncp_request_keys",
sizeof(struct ncp_request_key),
1000 * sizeof(struct ncp_request_key), G_ALLOC_AND_FREE);
ncp_packet_init_count * sizeof(struct ncp_request_key), G_ALLOC_AND_FREE);
ncp_request_records = g_mem_chunk_new("ncp_request_records",
sizeof(struct ncp_request_val),
1000 * sizeof(struct ncp_request_val), G_ALLOC_AND_FREE);
ncp_packet_init_count * sizeof(struct ncp_request_val), G_ALLOC_AND_FREE);
}
static struct ncp2222_record *
@ -448,22 +449,21 @@ dissect_ncp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
nw_ncp_type = header.type;
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"NetWare Core Protocol");
ncp_tree = proto_tree_new();
proto_item_add_subtree(ti, ncp_tree, ETT_NCP);
ncp_tree = proto_item_add_subtree(ti, ETT_NCP);
proto_tree_add_item(ncp_tree, offset, 2,
proto_tree_add_text(ncp_tree, offset, 2,
"Type: %s", val_to_str( header.type,
request_reply_values, "Unknown (%04X)"));
proto_tree_add_item(ncp_tree, offset+2, 1,
proto_tree_add_text(ncp_tree, offset+2, 1,
"Sequence Number: %d", header.sequence);
proto_tree_add_item(ncp_tree, offset+3, 3,
proto_tree_add_text(ncp_tree, offset+3, 3,
"Connection Number: %d", nw_connection);
proto_tree_add_item(ncp_tree, offset+4, 1,
proto_tree_add_text(ncp_tree, offset+4, 1,
"Task Number: %d", header.task);
}
@ -508,16 +508,16 @@ dissect_ncp_request(const u_char *pd, int offset, frame_data *fd,
}
if (ncp_tree) {
proto_tree_add_item(ncp_tree, offset+6, 1,
proto_tree_add_text(ncp_tree, offset+6, 1,
"Function Code: 0x%02X (%s)",
request.function, description);
if (ncp_request) {
if (ncp_request->submask == SUBFUNC) {
proto_tree_add_item(ncp_tree, offset+7, 2,
proto_tree_add_text(ncp_tree, offset+7, 2,
"Packet Length: %d bytes", pntohs(&pd[offset+7]));
proto_tree_add_item(ncp_tree, offset+9, 1,
proto_tree_add_text(ncp_tree, offset+9, 1,
"Subfunction Code: 0x%02x", pd[offset+9]);
offset += 7 + 3;
}
@ -526,10 +526,9 @@ dissect_ncp_request(const u_char *pd, int offset, frame_data *fd,
}
if (ncp_request->req) {
ti = proto_tree_add_item(ncp_tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(ncp_tree, offset, END_OF_FRAME,
"NCP Request Packet");
field_tree = proto_tree_new();
proto_item_add_subtree(ti, field_tree, ETT_NCP_REQUEST_FIELDS);
field_tree = proto_item_add_subtree(ti, ETT_NCP_REQUEST_FIELDS);
parse_ncp_svc_fields(pd, field_tree, offset, ncp_request->req);
}
@ -596,26 +595,25 @@ dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd,
/* A completion code of 0 always means OK. Other values have different
* meanings */
if (ncp_request) {
proto_tree_add_item(ncp_tree, offset+6, 1,
proto_tree_add_text(ncp_tree, offset+6, 1,
"Completion Code: 0x%02x (%s)", reply.completion_code,
ncp_completion_code(reply.completion_code, ncp_request->family));
}
else {
proto_tree_add_item(ncp_tree, offset+6, 1,
proto_tree_add_text(ncp_tree, offset+6, 1,
"Completion Code: 0x%02x (%s)", reply.completion_code,
reply.completion_code == 0 ? "OK" : "Unknown");
}
proto_tree_add_item(ncp_tree, offset+7, 1,
proto_tree_add_text(ncp_tree, offset+7, 1,
"Connection Status: %d", reply.connection_state);
if (ncp_request) {
if (ncp_request->rep) {
ti = proto_tree_add_item(ncp_tree, offset+8, END_OF_FRAME,
ti = proto_tree_add_text(ncp_tree, offset+8, END_OF_FRAME,
"NCP Reply Packet");
field_tree = proto_tree_new();
proto_item_add_subtree(ti, field_tree, ETT_NCP_REPLY_FIELDS);
field_tree = proto_item_add_subtree(ti, ETT_NCP_REPLY_FIELDS);
parse_ncp_svc_fields(pd, field_tree, offset+8, ncp_request->rep);
}
@ -637,20 +635,20 @@ parse_ncp_svc_fields(const u_char *pd, proto_tree *ncp_tree, int offset,
switch(rec->type) {
case nbeshort:
field_length = 2;
proto_tree_add_item(ncp_tree, field_offset,
proto_tree_add_text(ncp_tree, field_offset,
field_length, rec->description, pntohs(&pd[field_offset]));
break;
case nasciile:
field_length = pd[field_offset];
proto_tree_add_item(ncp_tree, field_offset,
proto_tree_add_text(ncp_tree, field_offset,
field_length + 1, rec->description, field_length,
&pd[field_offset+1]);
break;
case nhex:
field_length = rec->length;
proto_tree_add_item(ncp_tree, field_offset,
proto_tree_add_text(ncp_tree, field_offset,
field_length, rec->description);
break;

View File

@ -2,7 +2,7 @@
* Routines for nntp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-nntp.c,v 1.1 1999/04/06 02:02:11 guy Exp $
* $Id: packet-nntp.c,v 1.2 1999/07/07 22:51:49 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -77,10 +77,9 @@ dissect_nntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Network News Transfer Protocol");
nntp_tree = proto_tree_new();
proto_item_add_subtree(ti, nntp_tree, ETT_NNTP);
nntp_tree = proto_item_add_subtree(ti, ETT_NNTP);
/*
* Show the request or response as text, a line at a time.
@ -100,7 +99,7 @@ dissect_nntp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
/*
* Put this line.
*/
proto_tree_add_item(nntp_tree, offset, linelen, "%s",
proto_tree_add_text(nntp_tree, offset, linelen, "%s",
format_text(data, linelen));
offset += linelen;
data = lineend;

View File

@ -1,7 +1,7 @@
/* packet-null.c
* Routines for null packet disassembly
*
* $Id: packet-null.c,v 1.7 1999/03/23 03:14:41 gram Exp $
* $Id: packet-null.c,v 1.8 1999/07/07 22:51:49 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -36,6 +36,11 @@
#include <sys/socket.h>
#include "packet.h"
int proto_null = -1;
int hf_null_next = -1;
int hf_null_len = -1;
int hf_null_family = -1;
/* Null/loopback structs and definitions */
@ -100,12 +105,11 @@ dissect_null( const u_char *pd, frame_data *fd, proto_tree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = proto_tree_add_item(tree, 0, 4, "Null/Loopback" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_NULL);
proto_tree_add_item(fh_tree, 0, 1, "Next: %02x", nh.null_next);
proto_tree_add_item(fh_tree, 1, 1, "Length: %02x", nh.null_len);
proto_tree_add_item(fh_tree, 2, 2, "Family: %04x", nh.null_family);
ti = proto_tree_add_item(tree, proto_null, 0, 4, NULL);
fh_tree = proto_item_add_subtree(ti, ETT_NULL);
proto_tree_add_item(fh_tree, hf_null_next, 0, 1, nh.null_next);
proto_tree_add_item(fh_tree, hf_null_len, 1, 1, nh.null_len);
proto_tree_add_item(fh_tree, hf_null_family, 2, 2, nh.null_family);
}
/*
@ -132,3 +136,32 @@ dissect_null( const u_char *pd, frame_data *fd, proto_tree *tree ) {
break;
}
}
void
proto_register_null(void)
{
proto_null = proto_register_protocol (
/* name */ "Null/Loopback",
/* abbrev */ "null" );
hf_null_next = proto_register_field (
/* name */ "Next",
/* abbrev */ "null.next",
/* ftype */ FT_UINT8,
/* parent */ proto_null,
/* vals[] */ NULL );
hf_null_len = proto_register_field (
/* name */ "Length",
/* abbrev */ "null.len",
/* ftype */ FT_UINT8,
/* parent */ proto_null,
/* vals[] */ NULL );
hf_null_family = proto_register_field (
/* name */ "Family",
/* abbrev */ "null.family",
/* ftype */ FT_UINT16,
/* parent */ proto_null,
/* vals[] */ NULL );
}

View File

@ -1,7 +1,7 @@
/* packet-osi.c
* Routines for ISO/OSI network and transport protocol packet disassembly
*
* $Id: packet-osi.c,v 1.6 1999/03/23 03:14:41 gram Exp $
* $Id: packet-osi.c,v 1.7 1999/07/07 22:51:49 gram Exp $
* Laurent Deniel <deniel@worldnet.fr>
*
* Ethereal - Network traffic analyzer
@ -245,18 +245,17 @@ static int osi_decode_DR(const u_char *pd, int offset,
src_ref, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (DR)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 2,
proto_tree_add_text(cotp_tree, offset + 4, 2,
"Source reference: 0x%04x", src_ref);
proto_tree_add_item(cotp_tree, offset + 6, 1,
proto_tree_add_text(cotp_tree, offset + 6, 1,
"Cause: %s", str);
}
@ -338,63 +337,62 @@ static int osi_decode_DT(const u_char *pd, int offset,
(fragment)? "(fragment)" : "");
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (DT)", tpdu);
if (li != LI_NORMAL_DT_CLASS_01)
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
switch (li) {
case LI_NORMAL_DT_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"TPDU number: 0x%02x (%s)",
tpdu_nr,
(fragment)? "fragment":"complete");
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT + 2, length,
"Checksum: 0x%04x", checksum);
break;
case LI_NORMAL_DT_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"TPDU number: 0x%02x (%s)",
tpdu_nr,
(fragment)? "fragment":"complete");
break;
case LI_EXTENDED_DT_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"TPDU number: 0x%08x (%s)",
tpdu_nr,
(fragment)? "fragment":"complete");
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT + 2, length,
"Checksum: 0x%04x", checksum);
break;
case LI_EXTENDED_DT_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"TPDU number: 0x%08x (%s)",
tpdu_nr,
(fragment)? "fragment":"complete");
break;
case LI_NORMAL_DT_CLASS_01 :
proto_tree_add_item(cotp_tree, offset + 2, 1,
proto_tree_add_text(cotp_tree, offset + 2, 1,
"TPDU number: 0x%02x (%s)",
tpdu_nr,
(fragment)? "fragment":"complete");
@ -473,49 +471,48 @@ static int osi_decode_ED(const u_char *pd, int offset,
col_add_fstr(fd, COL_INFO, "ED TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (ED)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
switch (li) {
case LI_NORMAL_DT_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"TPDU number: 0x%02x", tpdu_nr);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NDT + 2, length,
"Checksum: 0x%04x", checksum);
break;
case LI_NORMAL_DT_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"TPDU number: 0x%02x", tpdu_nr);
break;
case LI_EXTENDED_DT_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"TPDU number: 0x%02x", tpdu_nr);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EDT + 2, length,
"Checksum: 0x%04x", checksum);
break;
case LI_EXTENDED_DT_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"TPDU number: 0x%02x", tpdu_nr);
break;
}
@ -556,25 +553,24 @@ static int osi_decode_RJ(const u_char *pd, int offset,
col_add_fstr(fd, COL_INFO, "RJ TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (RJ)", tpdu);
if (li == LI_NORMAL_RJ)
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"Credit: %d", cdt);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
if (li == LI_NORMAL_RJ)
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"Your TPDU number: 0x%02x", tpdu_nr);
else {
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"Your TPDU number: 0x%02x", tpdu_nr);
proto_tree_add_item(cotp_tree, offset + 8, 2,
proto_tree_add_text(cotp_tree, offset + 8, 2,
"Credit: 0x%02x", credit);
}
}
@ -645,19 +641,18 @@ static int osi_decode_CC(const u_char *pd, int offset,
dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (%s)", tpdu,
(tpdu == CR_TPDU) ? "CR" : "CC");
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 2,
proto_tree_add_text(cotp_tree, offset + 4, 2,
"Source reference: 0x%04x", src_ref);
proto_tree_add_item(cotp_tree, offset + 6, 1,
proto_tree_add_text(cotp_tree, offset + 6, 1,
"Class option: 0x%02x", class_option);
}
@ -672,26 +667,26 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_CHECKSUM :
length = pd[offset + P_VAR_PART_CC + i + 1];
checksum = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 2]);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Checksum: 0x%04x", checksum);
i += length + 2;
break;
case VP_SRC_TSAP :
length = pd[offset + P_VAR_PART_CC + i + 1];
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (src-tsap)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Calling TSAP: 0x%s",
print_tsap(&pd[offset + P_VAR_PART_CC + i + 2],
@ -700,13 +695,13 @@ static int osi_decode_CC(const u_char *pd, int offset,
break;
case VP_DST_TSAP :
length = pd[offset + P_VAR_PART_CC + i + 1];
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (dst-tsap)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Called TSAP: 0x%s",
print_tsap(&pd[offset + P_VAR_PART_CC + i + 2],
@ -716,13 +711,13 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_TPDU_SIZE :
length = pd[offset + P_VAR_PART_CC + i + 1];
c1 = pd[offset + P_VAR_PART_CC + i + 2] & 0x0F;
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (tpdu-size)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"TPDU size: %d", 2 << c1);
i += length + 2;
@ -730,45 +725,45 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_OPT_SEL :
length = pd[offset + P_VAR_PART_CC + i + 1];
c1 = pd[offset + P_VAR_PART_CC + i + 2] & 0x0F;
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (options)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
if (class_option == 1) {
if (c1 & 0x8)
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Use of network expedited data");
else
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Non use of network expedited data");
if (c1 & 0x4)
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Use of Receipt confirmation");
else
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Use of explicit AK variant");
} else if (class_option == 4) {
if (c1 & 0x2)
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Use 16 bit checksum ");
else
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Non-use 16 bit checksum in class 4");
}
if (c1 & 0x1)
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Use of transport expedited data transfer\n");
else
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 1,
"Non-use of transport expedited data transfer");
i += length + 2;
@ -776,13 +771,13 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_ACK_TIME :
length = pd[offset + P_VAR_PART_CC + i + 1];
s = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 2]);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (ack time)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Ack time (ms): %d", s);
i += length + 2;
@ -793,22 +788,22 @@ static int osi_decode_CC(const u_char *pd, int offset,
t2 = EXTRACT_LONG(&pd[offset + P_VAR_PART_CC + i + 4]);
t3 = EXTRACT_LONG(&pd[offset + P_VAR_PART_CC + i + 7]);
t4 = EXTRACT_LONG(&pd[offset + P_VAR_PART_CC + i + 10]);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (throughput)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 4,
"Target value / calling-called: %d o/s", t1);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 6, 4,
"Minimum / calling-called: %d o/s", t2);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 10, 4,
"Target value / called-calling: %d o/s", t3);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 14, 4,
"Minimum / called-calling: %d o/s", t4);
i += length + 2;
@ -819,22 +814,22 @@ static int osi_decode_CC(const u_char *pd, int offset,
s2 = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 4]);
s3 = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 6]);
s4 = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 8]);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (transit delay)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, 2,
"Target value / calling-called: %d ms", s1);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 4, 2,
"Minimum / calling-called: %d ms", s2);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 6, 2,
"Target value / called-calling: %d ms", s3);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 8, 2,
"Minimum / called-calling: %d ms", s4);
i += length + 2;
@ -842,13 +837,13 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_PRIORITY :
length = pd[offset + P_VAR_PART_CC + i + 1];
s = EXTRACT_SHORT(&pd[offset + P_VAR_PART_CC + i + 2]);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i, 1,
"Parameter code: 0x%02x (priority)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Priority: %d", s);
i += length + 2;
@ -861,13 +856,13 @@ static int osi_decode_CC(const u_char *pd, int offset,
case VP_PROTO_CLASS :
default : /* no decoding */
length = pd[offset + P_VAR_PART_CC + i + 1];
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 0, 1,
"Parameter code: 0x%02x", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_CC + i + 2, length,
"Parameter value: <not shown>");
i += length + 2;
@ -918,25 +913,24 @@ static int osi_decode_DC(const u_char *pd, int offset,
dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (DC)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 2,
proto_tree_add_text(cotp_tree, offset + 4, 2,
"Source reference: 0x%04x", src_ref);
if (code) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_DC + 0, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_DC + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_DC + 2, 2,
"Checksum: 0x%04x", checksum);
}
@ -972,18 +966,17 @@ static int osi_decode_AK(const u_char *pd, int offset,
tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (AK)", tpdu);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"Credit: %d", cdt);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"Your TPDU number: 0x%02x", tpdu_nr);
}
@ -993,13 +986,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
length = pd[offset + P_VAR_PART_NAK + i + 1];
checksum = EXTRACT_SHORT(&pd[offset + P_VAR_PART_NAK + i + 2]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 0, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 2, 2,
"Checksum: 0x%04x", checksum);
}
@ -1012,22 +1005,22 @@ static int osi_decode_AK(const u_char *pd, int offset,
r_seq_nr = EXTRACT_SHORT(&pd[offset + P_VAR_PART_NAK + i + 6]);
r_cdt = EXTRACT_SHORT(&pd[offset + P_VAR_PART_NAK + i + 8]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 0, 1,
"Parameter code: 0x%02x (flow control)",
code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 2, 4,
"Lower window edge: 0x%08x",
r_lower_window_edge);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 6, 2,
"Sequence number: 0x%04x",
r_seq_nr);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 8, 2,
"Credit: 0x%04x",
r_cdt);
@ -1038,13 +1031,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
length = pd[offset + P_VAR_PART_NAK + i + 1];
seq_nr = EXTRACT_SHORT(&pd[offset + P_VAR_PART_NAK + i + 2]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 0, 1,
"Parameter code: 0x%02x (seq number)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 2, 2,
"Sequence number: 0x%04x", seq_nr);
}
@ -1053,13 +1046,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
default :
length = pd[offset + P_VAR_PART_NAK + i + 1];
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 0, 1,
"Parameter code: 0x%02x (unknown)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_NAK + i + 2, length,
"Parameter value: <not shown>");
}
@ -1079,18 +1072,17 @@ static int osi_decode_AK(const u_char *pd, int offset,
tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (AK)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"Your TPDU number: 0x%08x", tpdu_nr);
proto_tree_add_item(cotp_tree, offset + 8, 2,
proto_tree_add_text(cotp_tree, offset + 8, 2,
"Credit: 0x%04x", cdt_in_ak);
}
@ -1100,13 +1092,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
length = pd[offset + P_VAR_PART_EAK + i + 1];
checksum = EXTRACT_SHORT(&pd[offset + P_VAR_PART_EAK + i + 2]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 0, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 2, 2,
"Checksum: 0x%04x", checksum);
}
@ -1119,22 +1111,22 @@ static int osi_decode_AK(const u_char *pd, int offset,
r_seq_nr = EXTRACT_SHORT(&pd[offset + P_VAR_PART_EAK + i + 6]);
r_cdt = EXTRACT_SHORT(&pd[offset + P_VAR_PART_EAK + i + 8]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 0, 1,
"Parameter code: 0x%02x (flow control)",
code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 2, 4,
"Lower window edge: 0x%08x",
r_lower_window_edge);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 6, 2,
"Sequence number: 0x%04x",
r_seq_nr);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 8, 2,
"Credit: 0x%04x",
r_cdt);
@ -1145,13 +1137,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
length = pd[offset + P_VAR_PART_EAK + i + 1];
seq_nr = EXTRACT_SHORT(&pd[offset + P_VAR_PART_EAK + i + 2]);
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 0, 1,
"Parameter code: 0x%02x (seq number)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 2, 2,
"Sequence number: 0x%04x", seq_nr);
}
@ -1160,13 +1152,13 @@ static int osi_decode_AK(const u_char *pd, int offset,
default :
length = pd[offset + P_VAR_PART_EAK + i + 1];
if (tree) {
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 0, 1,
"Parameter code: 0x%02x (unknown)", code);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 1, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree,
proto_tree_add_text(cotp_tree,
offset + P_VAR_PART_EAK + i + 2, length,
"Parameter value: <not shown>");
}
@ -1232,43 +1224,42 @@ static int osi_decode_EA(const u_char *pd, int offset,
col_add_fstr(fd, COL_INFO, "EA TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (EA)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
switch (li) {
case LI_NORMAL_EA_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"Your TPDU number: 0x%02x", tpdu_nr);
proto_tree_add_item(cotp_tree, offset + 5, 1,
proto_tree_add_text(cotp_tree, offset + 5, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree, offset + 6, 1,
proto_tree_add_text(cotp_tree, offset + 6, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree, offset + 7, 2,
proto_tree_add_text(cotp_tree, offset + 7, 2,
"Checksum: 0x%04x", checksum);
break;
case LI_NORMAL_EA_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"Your TPDU number: 0x%02x", tpdu_nr);
break;
case LI_EXTENDED_EA_WITH_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"Your TPDU number: 0x%08x", tpdu_nr);
proto_tree_add_item(cotp_tree, offset + 8, 1,
proto_tree_add_text(cotp_tree, offset + 8, 1,
"Parameter code: 0x%02x (checksum)", code);
proto_tree_add_item(cotp_tree, offset + 9, 1,
proto_tree_add_text(cotp_tree, offset + 9, 1,
"Parameter length: 0x%02x", length);
proto_tree_add_item(cotp_tree, offset + 10, 2,
proto_tree_add_text(cotp_tree, offset + 10, 2,
"Checksum: 0x%04x", checksum);
break;
case LI_EXTENDED_EA_WITHOUT_CHECKSUM :
proto_tree_add_item(cotp_tree, offset + 4, 4,
proto_tree_add_text(cotp_tree, offset + 4, 4,
"Your TPDU number: 0x%08x", tpdu_nr);
break;
default :
@ -1318,16 +1309,15 @@ static int osi_decode_ER(const u_char *pd, int offset,
col_add_fstr(fd, COL_INFO, "ER TPDU dst-ref: 0x%04x", dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_tree_new();
proto_item_add_subtree(ti, cotp_tree, ETT_COTP);
proto_tree_add_item(cotp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, li + 1, "ISO COTP");
cotp_tree = proto_item_add_subtree(ti, ETT_COTP);
proto_tree_add_text(cotp_tree, offset, 1,
"Length indicator: %d", li);
proto_tree_add_item(cotp_tree, offset + 1, 1,
proto_tree_add_text(cotp_tree, offset + 1, 1,
"TPDU code: Ox%x (ER)", tpdu);
proto_tree_add_item(cotp_tree, offset + 2, 2,
proto_tree_add_text(cotp_tree, offset + 2, 2,
"Destination reference: 0x%04x", dst_ref);
proto_tree_add_item(cotp_tree, offset + 4, 1,
proto_tree_add_text(cotp_tree, offset + 4, 1,
"Reject cause: %s", str);
}
@ -1456,29 +1446,28 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
/* fixed part decoding */
if (tree) {
ti = proto_tree_add_item(tree, offset, clnp.cnf_hdr_len, "ISO CLNP");
clnp_tree = proto_tree_new();
proto_item_add_subtree(ti, clnp_tree, ETT_CLNP);
proto_tree_add_item(clnp_tree, offset, 1,
ti = proto_tree_add_text(tree, offset, clnp.cnf_hdr_len, "ISO CLNP");
clnp_tree = proto_item_add_subtree(ti, ETT_CLNP);
proto_tree_add_text(clnp_tree, offset, 1,
"Protocol identifier: 0x%02x", clnp.cnf_proto_id);
proto_tree_add_item(clnp_tree, offset + 1, 1,
proto_tree_add_text(clnp_tree, offset + 1, 1,
"Length: %d", clnp.cnf_hdr_len);
proto_tree_add_item(clnp_tree, offset + 2, 1,
proto_tree_add_text(clnp_tree, offset + 2, 1,
"Version: %d", clnp.cnf_vers);
proto_tree_add_item(clnp_tree, offset + 3, 1,
proto_tree_add_text(clnp_tree, offset + 3, 1,
"TTL: %d (%d secs)",
clnp.cnf_ttl, clnp.cnf_ttl / 2);
proto_tree_add_item(clnp_tree, offset + 4, 1,
proto_tree_add_text(clnp_tree, offset + 4, 1,
"Type code: 0x%02x (%s%s%s%s)",
clnp.cnf_type,
(clnp.cnf_type & CNF_SEG_OK) ? "S " : "",
(clnp.cnf_type & CNF_MORE_SEGS) ? "M " : "",
(clnp.cnf_type & CNF_ERR_OK) ? "E " : "",
(clnp.cnf_type & CNF_TYPE) == DT_NPDU ? "DT" : "ER");
proto_tree_add_item(clnp_tree, offset + 5, 2,
proto_tree_add_text(clnp_tree, offset + 5, 2,
"PDU segment length: %d",
EXTRACT_SHORT(&clnp.cnf_seglen_msb));
proto_tree_add_item(clnp_tree, offset + 7, 2,
proto_tree_add_text(clnp_tree, offset + 7, 2,
"Checksum: 0x%04x",
EXTRACT_SHORT(&clnp.cnf_cksum_msb));
} /* tree */
@ -1498,14 +1487,14 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
src_len = pd[offset + dst_len + 1];
if (tree) {
proto_tree_add_item(clnp_tree, offset, 1,
proto_tree_add_text(clnp_tree, offset, 1,
"Destination address length: 0x%02x", dst_len);
proto_tree_add_item(clnp_tree, offset + 1 , dst_len,
proto_tree_add_text(clnp_tree, offset + 1 , dst_len,
"Destination address: %s",
print_nsap(&pd[offset + 1], dst_len));
proto_tree_add_item(clnp_tree, offset + 1 + dst_len, 1,
proto_tree_add_text(clnp_tree, offset + 1 + dst_len, 1,
"Source address length: 0x%02x", src_len);
proto_tree_add_item(clnp_tree, offset + dst_len + 2, src_len,
proto_tree_add_text(clnp_tree, offset + dst_len + 2, src_len,
"Source address: %s",
print_nsap(&pd[offset + dst_len + 2], src_len));
}
@ -1525,13 +1514,13 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
struct clnp_segment seg;
memcpy(&seg, &pd[offset], sizeof(seg));
proto_tree_add_item(clnp_tree, offset, 2,
proto_tree_add_text(clnp_tree, offset, 2,
"Data unit identifier: 0x%04x",
EXTRACT_SHORT(&pd[offset]));
proto_tree_add_item(clnp_tree, offset + 2 , 2,
proto_tree_add_text(clnp_tree, offset + 2 , 2,
"Segment offset: 0x%04x",
EXTRACT_SHORT(&pd[offset + 2]));
proto_tree_add_item(clnp_tree, offset + 4 , 2,
proto_tree_add_text(clnp_tree, offset + 4 , 2,
"Total length: 0x%04x",
EXTRACT_SHORT(&pd[offset + 4]));
@ -1541,7 +1530,7 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
if (tree) {
/* To do : decode options */
proto_tree_add_item(clnp_tree, offset,
proto_tree_add_text(clnp_tree, offset,
clnp.cnf_hdr_len + first_offset - offset,
"Options/Data: <not shown>");
}

View File

@ -2,7 +2,7 @@
* Routines for OSPF packet disassembly
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-ospf.c,v 1.10 1999/03/23 03:14:42 gram Exp $
* $Id: packet-ospf.c,v 1.11 1999/07/07 22:51:50 gram Exp $
*
* At this time, this module is able to analyze OSPF
* packets as specified in RFC2328. MOSPF (RFC1584) and other
@ -80,49 +80,47 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree, offset, ntohs(ospfh.length), "Open Shortest Path First");
ospf_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_tree, ETT_OSPF);
ti = proto_tree_add_text(tree, offset, ntohs(ospfh.length), "Open Shortest Path First");
ospf_tree = proto_item_add_subtree(ti, ETT_OSPF);
ti = proto_tree_add_item(ospf_tree, offset, OSPF_HEADER_LENGTH, "OSPF Header");
ospf_header_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_header_tree, ETT_OSPF_HDR);
ti = proto_tree_add_text(ospf_tree, offset, OSPF_HEADER_LENGTH, "OSPF Header");
ospf_header_tree = proto_item_add_subtree(ti, ETT_OSPF_HDR);
proto_tree_add_item(ospf_header_tree, offset, 1, "OSPF Version: %d", ospfh.version);
proto_tree_add_item(ospf_header_tree, offset + 1 , 1, "OSPF Packet Type: %d (%s)",
proto_tree_add_text(ospf_header_tree, offset, 1, "OSPF Version: %d", ospfh.version);
proto_tree_add_text(ospf_header_tree, offset + 1 , 1, "OSPF Packet Type: %d (%s)",
ospfh.packet_type,
(packet_type != NULL ?
packet_type :
"Unknown"));
proto_tree_add_item(ospf_header_tree, offset + 2 , 2, "Packet Length: %d",
proto_tree_add_text(ospf_header_tree, offset + 2 , 2, "Packet Length: %d",
ntohs(ospfh.length));
proto_tree_add_item(ospf_header_tree, offset + 4 , 4, "Source OSPF Router ID: %s",
proto_tree_add_text(ospf_header_tree, offset + 4 , 4, "Source OSPF Router ID: %s",
ip_to_str((guint8 *) &(ospfh.routerid)));
if (!(ospfh.area)) {
proto_tree_add_item(ospf_header_tree, offset + 8 , 4, "Area ID: Backbone");
proto_tree_add_text(ospf_header_tree, offset + 8 , 4, "Area ID: Backbone");
} else {
proto_tree_add_item(ospf_header_tree, offset + 8 , 4, "Area ID: %s", ip_to_str((guint8 *) &(ospfh.area)));
proto_tree_add_text(ospf_header_tree, offset + 8 , 4, "Area ID: %s", ip_to_str((guint8 *) &(ospfh.area)));
}
proto_tree_add_item(ospf_header_tree, offset + 12 , 2, "Packet Checksum: 0x%x",
proto_tree_add_text(ospf_header_tree, offset + 12 , 2, "Packet Checksum: 0x%x",
ntohs(ospfh.checksum));
switch( ntohs(ospfh.auth_type) ) {
case OSPF_AUTH_NONE:
proto_tree_add_item(ospf_header_tree, offset + 14 , 2, "Auth Type: none");
proto_tree_add_item(ospf_header_tree, offset + 16 , 8, "Auth Data (none)");
proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: none");
proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (none)");
break;
case OSPF_AUTH_SIMPLE:
proto_tree_add_item(ospf_header_tree, offset + 14 , 2, "Auth Type: simple");
proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: simple");
strncpy(auth_data, (char *) &ospfh.auth_data, 8);
proto_tree_add_item(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
break;
case OSPF_AUTH_CRYPT:
proto_tree_add_item(ospf_header_tree, offset + 14 , 2, "Auth Type: crypt");
proto_tree_add_item(ospf_header_tree, offset + 16 , 8, "Auth Data (crypt)");
proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: crypt");
proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (crypt)");
break;
default:
proto_tree_add_item(ospf_header_tree, offset + 14 , 2, "Auth Type (unknown)");
proto_tree_add_item(ospf_header_tree, offset + 16 , 8, "Auth Data (unknown)");
proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type (unknown)");
proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (unknown)");
}
}
@ -163,13 +161,12 @@ dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
memcpy(&ospfhello, &pd[offset], sizeof(e_ospf_hello));
if (tree) {
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset) , "OSPF Hello Packet");
ospf_hello_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_hello_tree, ETT_OSPF_HELLO);
ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "OSPF Hello Packet");
ospf_hello_tree = proto_item_add_subtree(ti, ETT_OSPF_HELLO);
proto_tree_add_item(ospf_hello_tree, offset , 4, "Network Mask: %s", ip_to_str((guint8 *) &ospfhello.network_mask));
proto_tree_add_item(ospf_hello_tree, offset + 4, 2, "Hello Interval: %d seconds", ntohs(ospfhello.hellointervall));
proto_tree_add_text(ospf_hello_tree, offset , 4, "Network Mask: %s", ip_to_str((guint8 *) &ospfhello.network_mask));
proto_tree_add_text(ospf_hello_tree, offset + 4, 2, "Hello Interval: %d seconds", ntohs(ospfhello.hellointervall));
/* ATTENTION !!! no check for length of options string */
options_offset=0;
@ -194,18 +191,18 @@ dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
options_offset+=3;
}
proto_tree_add_item(ospf_hello_tree, offset + 6, 1, "Options: %d (%s)", ospfhello.options, options);
proto_tree_add_item(ospf_hello_tree, offset + 7, 1, "Router Priority: %d", ospfhello.priority);
proto_tree_add_item(ospf_hello_tree, offset + 8, 4, "Router Dead Interval: %ld seconds", (long)ntohl(ospfhello.dead_interval));
proto_tree_add_item(ospf_hello_tree, offset + 12, 4, "Designated Router: %s", ip_to_str((guint8 *) &ospfhello.drouter));
proto_tree_add_item(ospf_hello_tree, offset + 16, 4, "Backup Designated Router: %s", ip_to_str((guint8 *) &ospfhello.bdrouter));
proto_tree_add_text(ospf_hello_tree, offset + 6, 1, "Options: %d (%s)", ospfhello.options, options);
proto_tree_add_text(ospf_hello_tree, offset + 7, 1, "Router Priority: %d", ospfhello.priority);
proto_tree_add_text(ospf_hello_tree, offset + 8, 4, "Router Dead Interval: %ld seconds", (long)ntohl(ospfhello.dead_interval));
proto_tree_add_text(ospf_hello_tree, offset + 12, 4, "Designated Router: %s", ip_to_str((guint8 *) &ospfhello.drouter));
proto_tree_add_text(ospf_hello_tree, offset + 16, 4, "Backup Designated Router: %s", ip_to_str((guint8 *) &ospfhello.bdrouter));
offset+=20;
while(((int)(fd->cap_len - offset)) >= 4){
printf("%d", fd->cap_len - offset);
ospfneighbor=(guint32 *) &pd[offset];
proto_tree_add_item(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor));
proto_tree_add_text(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor));
offset+=4;
}
}
@ -225,11 +222,10 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *t
memcpy(&ospf_dbd, &pd[offset], sizeof(e_ospf_dbd));
if (tree) {
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset) , "OSPF DB Description");
ospf_db_desc_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_db_desc_tree, ETT_OSPF_DESC);
ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "OSPF DB Description");
ospf_db_desc_tree = proto_item_add_subtree(ti, ETT_OSPF_DESC);
proto_tree_add_item(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) );
proto_tree_add_text(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) );
options_offset=0;
@ -254,7 +250,7 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *t
options_offset+=3;
}
proto_tree_add_item(ospf_db_desc_tree, offset + 2 , 1, "Options: %d (%s)", ospf_dbd.options, options );
proto_tree_add_text(ospf_db_desc_tree, offset + 2 , 1, "Options: %d (%s)", ospf_dbd.options, options );
flags_offset=0;
@ -271,8 +267,8 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *t
flags_offset+=3;
}
proto_tree_add_item(ospf_db_desc_tree, offset + 3 , 1, "Flags: %d (%s)", ospf_dbd.flags, flags );
proto_tree_add_item(ospf_db_desc_tree, offset + 4 , 4, "DD Sequence: %ld", (long)ntohl(ospf_dbd.dd_sequence) );
proto_tree_add_text(ospf_db_desc_tree, offset + 3 , 1, "Flags: %d (%s)", ospf_dbd.flags, flags );
proto_tree_add_text(ospf_db_desc_tree, offset + 4 , 4, "DD Sequence: %ld", (long)ntohl(ospf_dbd.dd_sequence) );
}
/* LS Headers will be processed here */
/* skip to the end of DB-Desc header */
@ -296,39 +292,38 @@ dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
if (tree) {
while( ((int) ( fd->cap_len - offset)) >= OSPF_LS_REQ_LENGTH ){
memcpy(&ospf_lsr, &pd[offset], sizeof(e_ospf_ls_req));
ti = proto_tree_add_item(tree, offset, OSPF_LS_REQ_LENGTH, "Link State Request");
ospf_lsr_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_lsr_tree, ETT_OSPF_LSR);
ti = proto_tree_add_text(tree, offset, OSPF_LS_REQ_LENGTH, "Link State Request");
ospf_lsr_tree = proto_item_add_subtree(ti, ETT_OSPF_LSR);
switch( ntohl( ospf_lsr.ls_type ) ){
case OSPF_LSTYPE_ROUTER:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Router-LSA (%ld)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Router-LSA (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_NETWORK:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Network-LSA (%ld)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Network-LSA (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_SUMMERY:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (IP network) (%ld)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (IP network) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_ASBR:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (ASBR) (%ld)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (ASBR) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_ASEXT:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: AS-External-LSA (ASBR) (%ld)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: AS-External-LSA (ASBR) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
default:
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: %ld (unknown)",
proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: %ld (unknown)",
(long)ntohl( ospf_lsr.ls_type ) );
}
proto_tree_add_item(ospf_lsr_tree, offset + 4, 4, "Link State ID : %s",
proto_tree_add_text(ospf_lsr_tree, offset + 4, 4, "Link State ID : %s",
ip_to_str((guint8 *) &(ospf_lsr.ls_id)));
proto_tree_add_item(ospf_lsr_tree, offset + 8, 4, "Advertising Router : %s",
proto_tree_add_text(ospf_lsr_tree, offset + 8, 4, "Advertising Router : %s",
ip_to_str((guint8 *) &(ospf_lsr.adv_router)));
offset+=12;
@ -346,11 +341,10 @@ dissect_ospf_ls_upd(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
memcpy(&upd_hdr, &pd[offset], sizeof(e_ospf_lsa_upd_hdr));
if (tree) {
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset) , "LS Update Packet");
ospf_lsa_upd_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_lsa_upd_tree, ETT_OSPF_LSA_UPD);
ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset) , "LS Update Packet");
ospf_lsa_upd_tree = proto_item_add_subtree(ti, ETT_OSPF_LSA_UPD);
proto_tree_add_item(ospf_lsa_upd_tree, offset, 4, "Nr oF LSAs: %ld", (long)ntohl(upd_hdr.lsa_nr) );
proto_tree_add_text(ospf_lsa_upd_tree, offset, 4, "Nr oF LSAs: %ld", (long)ntohl(upd_hdr.lsa_nr) );
}
/* skip to the beginning of the first LSA */
offset+=4; /* the LS Upd PAcket contains only a 32 bit #LSAs field */
@ -427,29 +421,28 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
if (tree) {
if(disassemble_body){
ti = proto_tree_add_item(tree, offset, ntohs(lsa_hdr.length),
ti = proto_tree_add_text(tree, offset, ntohs(lsa_hdr.length),
"%s (Type: %d)", lsa_type, lsa_hdr.ls_type);
} else {
ti = proto_tree_add_item(tree, offset, OSPF_LSA_HEADER_LENGTH, "LSA Header");
ti = proto_tree_add_text(tree, offset, OSPF_LSA_HEADER_LENGTH, "LSA Header");
}
ospf_lsa_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_lsa_tree, ETT_OSPF_LSA);
ospf_lsa_tree = proto_item_add_subtree(ti, ETT_OSPF_LSA);
proto_tree_add_item(ospf_lsa_tree, offset, 2, "LS Age: %d seconds", ntohs(lsa_hdr.ls_age));
proto_tree_add_item(ospf_lsa_tree, offset + 2, 1, "Options: %d ", lsa_hdr.options);
proto_tree_add_item(ospf_lsa_tree, offset + 3, 1, "LSA Type: %d (%s)", lsa_hdr.ls_type, lsa_type);
proto_tree_add_text(ospf_lsa_tree, offset, 2, "LS Age: %d seconds", ntohs(lsa_hdr.ls_age));
proto_tree_add_text(ospf_lsa_tree, offset + 2, 1, "Options: %d ", lsa_hdr.options);
proto_tree_add_text(ospf_lsa_tree, offset + 3, 1, "LSA Type: %d (%s)", lsa_hdr.ls_type, lsa_type);
proto_tree_add_item(ospf_lsa_tree, offset + 4, 4, "Linke State ID: %s ",
proto_tree_add_text(ospf_lsa_tree, offset + 4, 4, "Linke State ID: %s ",
ip_to_str((guint8 *) &(lsa_hdr.ls_id)));
proto_tree_add_item(ospf_lsa_tree, offset + 8, 4, "Advertising Router: %s ",
proto_tree_add_text(ospf_lsa_tree, offset + 8, 4, "Advertising Router: %s ",
ip_to_str((guint8 *) &(lsa_hdr.adv_router)));
proto_tree_add_item(ospf_lsa_tree, offset + 12, 4, "LS Sequence Number: 0x%04lx ",
proto_tree_add_text(ospf_lsa_tree, offset + 12, 4, "LS Sequence Number: 0x%04lx ",
(unsigned long)ntohl(lsa_hdr.ls_seq));
proto_tree_add_item(ospf_lsa_tree, offset + 16, 2, "LS Checksum: %d ", ntohs(lsa_hdr.ls_checksum));
proto_tree_add_text(ospf_lsa_tree, offset + 16, 2, "LS Checksum: %d ", ntohs(lsa_hdr.ls_checksum));
proto_tree_add_item(ospf_lsa_tree, offset + 18, 2, "Length: %d ", ntohs(lsa_hdr.length));
proto_tree_add_text(ospf_lsa_tree, offset + 18, 2, "Length: %d ", ntohs(lsa_hdr.length));
if(!disassemble_body){
return OSPF_LSA_HEADER_LENGTH;
@ -463,8 +456,8 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
memcpy(&router_lsa, &pd[offset], sizeof(e_ospf_router_lsa));
/* again: flags should be secified in detail */
proto_tree_add_item(ospf_lsa_tree, offset, 1, "Flags: 0x%02x ", router_lsa.flags);
proto_tree_add_item(ospf_lsa_tree, offset + 2, 2, "Nr. of Links: %d ",
proto_tree_add_text(ospf_lsa_tree, offset, 1, "Flags: 0x%02x ", router_lsa.flags);
proto_tree_add_text(ospf_lsa_tree, offset + 2, 2, "Nr. of Links: %d ",
ntohs(router_lsa.nr_links));
offset += 4;
/* router_lsa.nr_links links follow
@ -496,17 +489,17 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
link_id="unknown link id";
}
proto_tree_add_item(ospf_lsa_tree, offset, 4, "%s: %s", link_id,
proto_tree_add_text(ospf_lsa_tree, offset, 4, "%s: %s", link_id,
ip_to_str((guint8 *) &(router_data.link_id)));
/* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
proto_tree_add_item(ospf_lsa_tree, offset + 4, 4, "Link Data: %s",
proto_tree_add_text(ospf_lsa_tree, offset + 4, 4, "Link Data: %s",
ip_to_str((guint8 *) &(router_data.link_data)));
proto_tree_add_item(ospf_lsa_tree, offset + 8, 1, "Link Type: %d - %s",
proto_tree_add_text(ospf_lsa_tree, offset + 8, 1, "Link Type: %d - %s",
router_data.link_type, link_type);
proto_tree_add_item(ospf_lsa_tree, offset + 9, 1, "Nr. of TOS metrics: %d", router_data.nr_tos);
proto_tree_add_item(ospf_lsa_tree, offset + 10, 2, "TOS 0 metric: %d", ntohs( router_data.tos0_metric ));
proto_tree_add_text(ospf_lsa_tree, offset + 9, 1, "Nr. of TOS metrics: %d", router_data.nr_tos);
proto_tree_add_text(ospf_lsa_tree, offset + 10, 2, "TOS 0 metric: %d", ntohs( router_data.tos0_metric ));
offset += 12;
@ -517,7 +510,7 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
for(tos_counter = 1 ; link_counter <= ntohs(router_data.nr_tos); tos_counter++){
memcpy(&tos_data, &pd[offset], sizeof(e_ospf_router_metric));
proto_tree_add_item(ospf_lsa_tree, offset, 1, "TOS: %d, Metric: %d",
proto_tree_add_text(ospf_lsa_tree, offset, 1, "TOS: %d, Metric: %d",
tos_data.tos, ntohs(tos_data.metric));
offset += 4;
}
@ -525,13 +518,13 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
break;
case(OSPF_LSTYPE_NETWORK):
memcpy(&network_lsa, &pd[offset], sizeof(e_ospf_network_lsa));
proto_tree_add_item(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
ip_to_str((guint8 *) &(network_lsa.network_mask)));
offset += 4;
while( ((int) (fd->cap_len - offset)) >= 4){
attached_router = (guint32 *) &pd[offset];
proto_tree_add_item(ospf_lsa_tree, offset, 4, "Attached Router: %s",
proto_tree_add_text(ospf_lsa_tree, offset, 4, "Attached Router: %s",
ip_to_str((guint8 *) attached_router));
offset += 4;
}
@ -540,22 +533,22 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
/* Type 3 and 4 LSAs have the same format */
case(OSPF_LSTYPE_ASBR):
memcpy(&summary_lsa, &pd[offset], sizeof(e_ospf_summary_lsa));
proto_tree_add_item(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
ip_to_str((guint8 *) &(summary_lsa.network_mask)));
/* returns only the TOS 0 metric (even if there are more TOS metrics) */
break;
case(OSPF_LSTYPE_ASEXT):
memcpy(&summary_lsa, &pd[offset], sizeof(e_ospf_summary_lsa));
proto_tree_add_item(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
ip_to_str((guint8 *) &(summary_lsa.network_mask)));
/* asext_lsa = (e_ospf_asexternal_lsa *) &pd[offset + 4]; */
memcpy(&asext_lsa, &pd[offset + 4], sizeof(asext_lsa));
if( (asext_lsa.options & 128) == 128 ) { /* check wether or not E bit is set */
proto_tree_add_item(ospf_lsa_tree, offset, 1,
proto_tree_add_text(ospf_lsa_tree, offset, 1,
"External Type: Type 2 (metric is larger than any other link state path)");
} else {
proto_tree_add_item(ospf_lsa_tree, offset + 4, 1,
proto_tree_add_text(ospf_lsa_tree, offset + 4, 1,
"External Type: Type 1 (metric is specified in the same units as interface cost)");
}
/* the metric field of a AS-external LAS is specified in 3 bytes -> not well aligned */
@ -565,15 +558,15 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
/* erase the leading 8 bits (the dont belong to the metric */
asext_metric = ntohl(asext_metric) & 0x00ffffff ;
proto_tree_add_item(ospf_lsa_tree, offset + 5, 3,"Metric: %d", asext_metric);
proto_tree_add_item(ospf_lsa_tree, offset + 8, 4,"Forwarding Address: %s",
proto_tree_add_text(ospf_lsa_tree, offset + 5, 3,"Metric: %d", asext_metric);
proto_tree_add_text(ospf_lsa_tree, offset + 8, 4,"Forwarding Address: %s",
ip_to_str((guint8 *) &(asext_lsa.gateway)));
proto_tree_add_item(ospf_lsa_tree, offset + 12, 4,"External Route Tag: %ld", (long)ntohl(asext_lsa.external_tag));
proto_tree_add_text(ospf_lsa_tree, offset + 12, 4,"External Route Tag: %ld", (long)ntohl(asext_lsa.external_tag));
break;
default:
/* unknown LSA type */
proto_tree_add_item(ospf_lsa_tree, offset, (fd->cap_len - offset), "Unknown LSA Type");
proto_tree_add_text(ospf_lsa_tree, offset, (fd->cap_len - offset), "Unknown LSA Type");
}
}
/* return the length of this LSA */

View File

@ -2,7 +2,7 @@
* Routines for pop packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-pop.c,v 1.3 1999/05/13 01:05:11 sharpe Exp $
* $Id: packet-pop.c,v 1.4 1999/07/07 22:51:50 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -81,23 +81,22 @@ dissect_pop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Post Office Protocol");
pop_tree = proto_tree_new();
proto_item_add_subtree(ti, pop_tree, ETT_POP);
pop_tree = proto_item_add_subtree(ti, ETT_POP);
if (pi.match_port == pi.destport) { /* Request */
proto_tree_add_item(pop_tree, offset, i1, "Request: %s", rr);
proto_tree_add_text(pop_tree, offset, i1, "Request: %s", rr);
proto_tree_add_item(pop_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Request Arg: %s", rd);
}
else {
proto_tree_add_item(pop_tree, offset, i1, "Response: %s", rr);
proto_tree_add_text(pop_tree, offset, i1, "Response: %s", rr);
proto_tree_add_item(pop_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
proto_tree_add_text(pop_tree, offset + i1 + 1, END_OF_FRAME, "Response Arg: %s", rd);
}
}

View File

@ -1,7 +1,7 @@
/* packet-ppp.c
* Routines for ppp packet disassembly
*
* $Id: packet-ppp.c,v 1.11 1999/06/11 15:30:39 gram Exp $
* $Id: packet-ppp.c,v 1.12 1999/07/07 22:51:50 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -207,14 +207,13 @@ dissect_ipcp( const u_char *pd, int offset, frame_data *fd, proto_tree *tree ) {
val_to_str(ipcpcode, cp_vals, "Unknown"));
if(tree) {
ti = proto_tree_add_item(tree, 0+offset, 4, "IP Control Protocol" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_IPCP);
proto_tree_add_item(fh_tree, 0+offset, 1, "Code: %s (0x%02x)",
ti = proto_tree_add_text(tree, 0+offset, 4, "IP Control Protocol" );
fh_tree = proto_item_add_subtree(ti, ETT_IPCP);
proto_tree_add_text(fh_tree, 0+offset, 1, "Code: %s (0x%02x)",
val_to_str(ipcpcode, cp_vals, "Unknown"), ipcpcode);
proto_tree_add_item(fh_tree, 1+offset, 1, "Identifier: 0x%02x",
proto_tree_add_text(fh_tree, 1+offset, 1, "Identifier: 0x%02x",
ipcpid);
proto_tree_add_item(fh_tree, 2+offset, 2, "Length: %d",
proto_tree_add_text(fh_tree, 2+offset, 2, "Length: %d",
optionslength);
}
@ -244,14 +243,13 @@ dissect_lcp( const u_char *pd, int offset, frame_data *fd, proto_tree *tree ) {
val_to_str(lcpcode, lcp_vals, "Unknown"));
if(tree) {
ti = proto_tree_add_item(tree, 0+offset, 4, "Link Control Protocol" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_LCP);
proto_tree_add_item(fh_tree, 0+offset, 1, "Code: %s (0x%02x)",
ti = proto_tree_add_text(tree, 0+offset, 4, "Link Control Protocol" );
fh_tree = proto_item_add_subtree(ti, ETT_LCP);
proto_tree_add_text(fh_tree, 0+offset, 1, "Code: %s (0x%02x)",
val_to_str(lcpcode, lcp_vals, "Unknown"), lcpcode);
proto_tree_add_item(fh_tree, 1+offset, 1, "Identifier: 0x%02x",
proto_tree_add_text(fh_tree, 1+offset, 1, "Identifier: 0x%02x",
lcpid);
proto_tree_add_item(fh_tree, 2+offset, 2, "Length: %d",
proto_tree_add_text(fh_tree, 2+offset, 2, "Length: %d",
optionslength);
}
@ -276,10 +274,9 @@ dissect_payload_ppp( const u_char *pd, int offset, frame_data *fd, proto_tree *t
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = proto_tree_add_item(tree, 0+offset, 2, "Point-to-Point Protocol" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_PPP);
proto_tree_add_item(fh_tree, 0+offset, 2, "Protocol: %s (0x%04x)",
ti = proto_tree_add_text(tree, 0+offset, 2, "Point-to-Point Protocol" );
fh_tree = proto_item_add_subtree(ti, ETT_PPP);
proto_tree_add_text(fh_tree, 0+offset, 2, "Protocol: %s (0x%04x)",
val_to_str(ph.ppp_prot, ppp_vals, "Unknown"), ph.ppp_prot);
}
@ -347,12 +344,11 @@ dissect_ppp( const u_char *pd, frame_data *fd, proto_tree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = proto_tree_add_item(tree, 0, 4, "Point-to-Point Protocol" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_PPP);
proto_tree_add_item(fh_tree, 0, 1, "Address: %02x", ph.ppp_addr);
proto_tree_add_item(fh_tree, 1, 1, "Control: %02x", ph.ppp_ctl);
proto_tree_add_item(fh_tree, 2, 2, "Protocol: %s (0x%04x)",
ti = proto_tree_add_text(tree, 0, 4, "Point-to-Point Protocol" );
fh_tree = proto_item_add_subtree(ti, ETT_PPP);
proto_tree_add_text(fh_tree, 0, 1, "Address: %02x", ph.ppp_addr);
proto_tree_add_text(fh_tree, 1, 1, "Control: %02x", ph.ppp_ctl);
proto_tree_add_text(fh_tree, 2, 2, "Protocol: %s (0x%04x)",
val_to_str(ph.ppp_prot, ppp_vals, "Unknown"), ph.ppp_prot);
}

View File

@ -1,7 +1,7 @@
/* packet-arp.c
* Routines for ARP packet disassembly
*
* $Id: packet-pppoe.c,v 1.1 1999/06/11 15:30:39 gram Exp $
* $Id: packet-pppoe.c,v 1.2 1999/07/07 22:51:51 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -101,9 +101,8 @@ dissect_pppoe_tags(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
/* Start Decoding Here. */
if (tree) {
ti = proto_tree_add_item(tree,offset,payload_length,"PPPoE Tags");
pppoe_tree = proto_tree_new();
proto_item_add_subtree(ti, pppoe_tree, ETT_PPPOED_TAGS);
ti = proto_tree_add_text(tree,offset,payload_length,"PPPoE Tags");
pppoe_tree = proto_item_add_subtree(ti, ETT_PPPOED_TAGS);
tagstart = offset;
while(tagstart <= payload_length-2 ) {
@ -111,7 +110,7 @@ dissect_pppoe_tags(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
poe_tag = pntohs(&pd[tagstart]);
poe_tag_length = pntohs(&pd[tagstart + 2]);
proto_tree_add_item(pppoe_tree,tagstart,4,
proto_tree_add_text(pppoe_tree,tagstart,4,
"Tag: %s", pppoetag_to_str(poe_tag,"Unknown (0x%02x)"));
switch(poe_tag) {
@ -123,13 +122,13 @@ dissect_pppoe_tags(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
/* tag value should be interpreted as a utf-8 unterminated string.*/
if(poe_tag_length > 0 ) {
/* really should do some limit checking here. :( */
proto_tree_add_item(pppoe_tree,tagstart+4,poe_tag_length,
proto_tree_add_text(pppoe_tree,tagstart+4,poe_tag_length,
" String Data: %s", format_text(&pd[tagstart+4],poe_tag_length ));
}
break;
default:
if(poe_tag_length > 0 ) {
proto_tree_add_item(pppoe_tree,tagstart+4,poe_tag_length,
proto_tree_add_text(pppoe_tree,tagstart+4,poe_tag_length,
" Binary Data: (%d bytes)", poe_tag_length );
}
}
@ -168,18 +167,17 @@ dissect_pppoed(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree,offset,pppoe_length+6,"PPPoE Discovery");
pppoe_tree = proto_tree_new();
proto_item_add_subtree(ti, pppoe_tree, ETT_PPPOED);
proto_tree_add_item(pppoe_tree,offset,1,
ti = proto_tree_add_text(tree,offset,pppoe_length+6,"PPPoE Discovery");
pppoe_tree = proto_item_add_subtree(ti, ETT_PPPOED);
proto_tree_add_text(pppoe_tree,offset,1,
"Version: %d", pppoe_ver);
proto_tree_add_item(pppoe_tree,offset,1,
proto_tree_add_text(pppoe_tree,offset,1,
"Type: %d", pppoe_type);
proto_tree_add_item(pppoe_tree,offset+1,1,
proto_tree_add_text(pppoe_tree,offset+1,1,
"Code: %s", pppoecode_to_str(pppoe_code,"Unknown (0x%02x)"));
proto_tree_add_item(pppoe_tree,offset+2,2,
proto_tree_add_text(pppoe_tree,offset+2,2,
"Session ID: %04x", pppoe_session_id);
proto_tree_add_item(pppoe_tree,offset+4,2,
proto_tree_add_text(pppoe_tree,offset+4,2,
"Payload Length: %d", pppoe_length);
}
dissect_pppoe_tags(pd,offset+6,fd,tree,offset+6+pppoe_length);
@ -213,18 +211,17 @@ dissect_pppoes(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree,offset,pppoe_length+6,"PPPoE Session");
pppoe_tree = proto_tree_new();
proto_item_add_subtree(ti, pppoe_tree, ETT_PPPOED);
proto_tree_add_item(pppoe_tree,offset,1,
ti = proto_tree_add_text(tree,offset,pppoe_length+6,"PPPoE Session");
pppoe_tree = proto_item_add_subtree(ti, ETT_PPPOED);
proto_tree_add_text(pppoe_tree,offset,1,
"Version: %d", pppoe_ver);
proto_tree_add_item(pppoe_tree,offset,1,
proto_tree_add_text(pppoe_tree,offset,1,
"Type: %d", pppoe_type);
proto_tree_add_item(pppoe_tree,offset+1,1,
proto_tree_add_text(pppoe_tree,offset+1,1,
"Code: %s", pppoecode_to_str(pppoe_code,"Unknown (0x%02x)"));
proto_tree_add_item(pppoe_tree,offset+2,2,
proto_tree_add_text(pppoe_tree,offset+2,2,
"Session ID: %04x", pppoe_session_id);
proto_tree_add_item(pppoe_tree,offset+4,2,
proto_tree_add_text(pppoe_tree,offset+4,2,
"Payload Length: %d", pppoe_length);
}
/* dissect_ppp is apparently done as a 'top level' dissector,

View File

@ -2,7 +2,7 @@
* Routines for the Point-to-Point Tunnelling Protocol (PPTP)
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-pptp.c,v 1.1 1999/06/11 15:30:39 gram Exp $
* $Id: packet-pptp.c,v 1.2 1999/07/07 22:51:51 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -391,28 +391,27 @@ dissect_pptp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_item * ti;
proto_tree * pptp_tree;
ti = proto_tree_add_item(tree, offset, len, "PPTP Control Channel");
pptp_tree = proto_tree_new();
proto_item_add_subtree(ti, pptp_tree, ETT_PPTP);
ti = proto_tree_add_text(tree, offset, len, "PPTP Control Channel");
pptp_tree = proto_item_add_subtree(ti, ETT_PPTP);
proto_tree_add_item(pptp_tree, offset, sizeof(hdr->len),
proto_tree_add_text(pptp_tree, offset, sizeof(hdr->len),
"Length: %u", len);
offset += sizeof(hdr->len);
msg_type = pntohs(&hdr->type);
proto_tree_add_item(pptp_tree, offset, sizeof(hdr->type),
proto_tree_add_text(pptp_tree, offset, sizeof(hdr->type),
"Message type: %s (%u)", msgtype2str(msg_type), msg_type);
offset += sizeof(hdr->type);
proto_tree_add_item(pptp_tree, offset, sizeof(hdr->cookie),
proto_tree_add_text(pptp_tree, offset, sizeof(hdr->cookie),
"Cookie: %#08x", pntohl(&hdr->cookie));
offset += sizeof(hdr->cookie);
proto_tree_add_item(pptp_tree, offset, sizeof(hdr->cntrl_type),
proto_tree_add_text(pptp_tree, offset, sizeof(hdr->cntrl_type),
"Control type: %s (%u)", cntrltype2str(cntrl_type), cntrl_type);
offset += sizeof(hdr->cntrl_type);
proto_tree_add_item(pptp_tree, offset, sizeof(hdr->resv),
proto_tree_add_text(pptp_tree, offset, sizeof(hdr->resv),
"Reserved: %u", pntohs(&hdr->resv));
offset += sizeof(hdr->resv);
@ -435,37 +434,37 @@ dissect_cntrl_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
guint32 frame;
guint32 bearer;
proto_tree_add_item(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver),
proto_tree_add_text(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver),
"Protocol version: %u.%u", hdr->major_ver, hdr->minor_ver );
offset += sizeof(hdr->major_ver) + sizeof(hdr->minor_ver);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
frame = pntohl(&hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->frame),
proto_tree_add_text(tree, offset, sizeof(hdr->frame),
"Framing capabilities: %s (%u)", frametype2str(frame), frame);
offset += sizeof(hdr->frame);
bearer = pntohl(&hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->bearer),
proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
"Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
offset += sizeof(hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->max_chan),
proto_tree_add_text(tree, offset, sizeof(hdr->max_chan),
"Maximum channels: %u", hdr->max_chan);
offset += sizeof(hdr->max_chan);
proto_tree_add_item(tree, offset, sizeof(hdr->firm_rev),
proto_tree_add_text(tree, offset, sizeof(hdr->firm_rev),
"Firmware revision: %u", hdr->firm_rev);
offset += sizeof(hdr->firm_rev);
proto_tree_add_item(tree, offset, sizeof(hdr->host),
proto_tree_add_text(tree, offset, sizeof(hdr->host),
"Hostname: %s", hdr->host);
offset += sizeof(hdr->host);
proto_tree_add_item(tree, offset, sizeof(hdr->vendor),
proto_tree_add_text(tree, offset, sizeof(hdr->vendor),
"Vendor: %s", hdr->vendor);
}
@ -475,41 +474,41 @@ dissect_cntrl_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
guint32 frame;
guint32 bearer;
proto_tree_add_item(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver),
proto_tree_add_text(tree, offset, sizeof(hdr->major_ver) + sizeof(hdr->minor_ver),
"Protocol version: %u.%u", hdr->major_ver, hdr->minor_ver );
offset += sizeof(hdr->major_ver) + sizeof(hdr->minor_ver);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", cntrlresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
frame = pntohl(&hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->frame),
proto_tree_add_text(tree, offset, sizeof(hdr->frame),
"Framing capabilities: %s (%u)", frametype2str(frame), frame);
offset += sizeof(hdr->frame);
bearer = pntohl(&hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->bearer),
proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
"Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
offset += sizeof(hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->max_chan),
proto_tree_add_text(tree, offset, sizeof(hdr->max_chan),
"Maximum channels: %u", hdr->max_chan);
offset += sizeof(hdr->max_chan);
proto_tree_add_item(tree, offset, sizeof(hdr->firm_rev),
proto_tree_add_text(tree, offset, sizeof(hdr->firm_rev),
"Firmware revision: %u", hdr->firm_rev);
offset += sizeof(hdr->firm_rev);
proto_tree_add_item(tree, offset, sizeof(hdr->host),
proto_tree_add_text(tree, offset, sizeof(hdr->host),
"Hostname: %s", hdr->host);
offset += sizeof(hdr->host);
proto_tree_add_item(tree, offset, sizeof(hdr->vendor),
proto_tree_add_text(tree, offset, sizeof(hdr->vendor),
"Vendor: %s", hdr->vendor);
}
@ -517,15 +516,15 @@ static void
dissect_stop_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct stop_req * hdr = (struct stop_req *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->reason),
proto_tree_add_text(tree, offset, sizeof(hdr->reason),
"Reason: %s (%u)", reasontype2str(hdr->reason), hdr->reason);
offset += sizeof(hdr->reason);
proto_tree_add_item(tree, offset, sizeof(hdr->resv0),
proto_tree_add_text(tree, offset, sizeof(hdr->resv0),
"Reserved: %u", hdr->resv0);
offset += sizeof(hdr->resv0);
proto_tree_add_item(tree, offset, sizeof(hdr->resv1),
proto_tree_add_text(tree, offset, sizeof(hdr->resv1),
"Reserved: %u", hdr->resv1);
offset += sizeof(hdr->resv1);
}
@ -534,15 +533,15 @@ static void
dissect_stop_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct stop_reply * hdr = (struct stop_reply *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", stopresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
}
@ -551,7 +550,7 @@ static void
dissect_echo_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct echo_req * hdr = (struct echo_req *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->ident),
proto_tree_add_text(tree, offset, sizeof(hdr->ident),
"Identifier: %u", hdr->ident);
offset += sizeof(hdr->ident);
}
@ -560,19 +559,19 @@ static void
dissect_echo_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct echo_reply * hdr = (struct echo_reply *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->ident),
proto_tree_add_text(tree, offset, sizeof(hdr->ident),
"Identifier: %u", hdr->ident);
offset += sizeof(hdr->ident);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", echoresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
}
@ -583,53 +582,53 @@ dissect_out_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
guint32 bearer;
guint32 frame;
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->call_serial),
proto_tree_add_text(tree, offset, sizeof(hdr->call_serial),
"Call Serial Number: %u", hdr->call_serial);
offset += sizeof(hdr->call_serial);
proto_tree_add_item(tree, offset, sizeof(hdr->min_bps),
proto_tree_add_text(tree, offset, sizeof(hdr->min_bps),
"Minimum BPS: %u", hdr->min_bps);
offset += sizeof(hdr->min_bps);
proto_tree_add_item(tree, offset, sizeof(hdr->max_bps),
proto_tree_add_text(tree, offset, sizeof(hdr->max_bps),
"Maximum BPS: %u", hdr->max_bps);
offset += sizeof(hdr->max_bps);
bearer = pntohl(&hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->bearer),
proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
"Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
offset += sizeof(hdr->bearer);
frame = pntohl(&hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->frame),
proto_tree_add_text(tree, offset, sizeof(hdr->frame),
"Framing capabilities: %s (%u)", frametype2str(frame), frame);
offset += sizeof(hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->win_size),
proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
"Receive window size: %u", hdr->win_size);
offset += sizeof(hdr->win_size);
proto_tree_add_item(tree, offset, sizeof(hdr->delay),
proto_tree_add_text(tree, offset, sizeof(hdr->delay),
"Processing delay: %u", hdr->delay);
offset += sizeof(hdr->delay);
proto_tree_add_item(tree, offset, sizeof(hdr->phone_len),
proto_tree_add_text(tree, offset, sizeof(hdr->phone_len),
"Phone number length: %u", hdr->phone_len);
offset += sizeof(hdr->phone_len);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
proto_tree_add_item(tree, offset, sizeof(hdr->phone),
proto_tree_add_text(tree, offset, sizeof(hdr->phone),
"Phone number: %s", hdr->phone);
offset += sizeof(hdr->phone);
proto_tree_add_item(tree, offset, sizeof(hdr->subaddr),
proto_tree_add_text(tree, offset, sizeof(hdr->subaddr),
"Subaddress: %s", hdr->subaddr);
offset += sizeof(hdr->subaddr);
}
@ -638,39 +637,39 @@ static void
dissect_out_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct out_reply * hdr = (struct out_reply *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->peer_id),
proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
"Peer's call ID: %u", hdr->peer_id);
offset += sizeof(hdr->peer_id);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", outresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
proto_tree_add_item(tree, offset, sizeof(hdr->cause),
proto_tree_add_text(tree, offset, sizeof(hdr->cause),
"Cause code: %u", hdr->cause);
offset += sizeof(hdr->cause);
proto_tree_add_item(tree, offset, sizeof(hdr->speed),
proto_tree_add_text(tree, offset, sizeof(hdr->speed),
"Connect speed: %u", hdr->speed);
offset += sizeof(hdr->speed);
proto_tree_add_item(tree, offset, sizeof(hdr->win_size),
proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
"Receive window size: %u", hdr->win_size);
offset += sizeof(hdr->win_size);
proto_tree_add_item(tree, offset, sizeof(hdr->delay),
proto_tree_add_text(tree, offset, sizeof(hdr->delay),
"Processing delay: %u", hdr->delay);
offset += sizeof(hdr->delay);
proto_tree_add_item(tree, offset, sizeof(hdr->channel_id),
proto_tree_add_text(tree, offset, sizeof(hdr->channel_id),
"Physical channel ID: %u", hdr->channel_id);
offset += sizeof(hdr->channel_id);
}
@ -681,40 +680,40 @@ dissect_in_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct in_req * hdr = (struct in_req *)(pd + offset);
guint32 bearer;
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->call_serial),
proto_tree_add_text(tree, offset, sizeof(hdr->call_serial),
"Call serial number: %u", hdr->call_serial);
offset += sizeof(hdr->call_serial);
bearer = pntohl(&hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->bearer),
proto_tree_add_text(tree, offset, sizeof(hdr->bearer),
"Bearer capabilities: %s (%u)", bearertype2str(bearer), bearer);
offset += sizeof(hdr->bearer);
proto_tree_add_item(tree, offset, sizeof(hdr->channel_id),
proto_tree_add_text(tree, offset, sizeof(hdr->channel_id),
"Physical channel ID: %u", hdr->channel_id);
offset += sizeof(hdr->channel_id);
proto_tree_add_item(tree, offset, sizeof(hdr->dialed_len),
proto_tree_add_text(tree, offset, sizeof(hdr->dialed_len),
"Dialed number length: %u", hdr->dialed_len);
offset += sizeof(hdr->dialed_len);
proto_tree_add_item(tree, offset, sizeof(hdr->dialing_len),
proto_tree_add_text(tree, offset, sizeof(hdr->dialing_len),
"Dialing number length: %u", hdr->dialing_len);
offset += sizeof(hdr->dialing_len);
proto_tree_add_item(tree, offset, sizeof(hdr->dialed),
proto_tree_add_text(tree, offset, sizeof(hdr->dialed),
"Dialed number: %s", hdr->dialed);
offset += sizeof(hdr->dialed);
proto_tree_add_item(tree, offset, sizeof(hdr->dialing),
proto_tree_add_text(tree, offset, sizeof(hdr->dialing),
"Dialing number: %s", hdr->dialing);
offset += sizeof(hdr->dialing);
proto_tree_add_item(tree, offset, sizeof(hdr->subaddr),
proto_tree_add_text(tree, offset, sizeof(hdr->subaddr),
"Subaddress: %s", hdr->subaddr);
offset += sizeof(hdr->subaddr);
}
@ -723,31 +722,31 @@ static void
dissect_in_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct in_reply * hdr = (struct in_reply *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->peer_id),
proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
"Peer's call ID: %u", hdr->peer_id);
offset += sizeof(hdr->peer_id);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", inresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
proto_tree_add_item(tree, offset, sizeof(hdr->win_size),
proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
"Receive window size: %u", hdr->win_size);
offset += sizeof(hdr->win_size);
proto_tree_add_item(tree, offset, sizeof(hdr->delay),
proto_tree_add_text(tree, offset, sizeof(hdr->delay),
"Processing delay: %u", hdr->delay);
offset += sizeof(hdr->delay);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
}
@ -757,28 +756,28 @@ dissect_in_connected(const u_char *pd, int offset, frame_data *fd, proto_tree *t
struct in_connected * hdr = (struct in_connected *)(pd + offset);
guint32 frame;
proto_tree_add_item(tree, offset, sizeof(hdr->peer_id),
proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
"Peer's call ID: %u", hdr->peer_id);
offset += sizeof(hdr->peer_id);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
proto_tree_add_item(tree, offset, sizeof(hdr->speed),
proto_tree_add_text(tree, offset, sizeof(hdr->speed),
"Connect speed: %u", hdr->speed);
offset += sizeof(hdr->speed);
proto_tree_add_item(tree, offset, sizeof(hdr->win_size),
proto_tree_add_text(tree, offset, sizeof(hdr->win_size),
"Receive window size: %u", hdr->win_size);
offset += sizeof(hdr->win_size);
proto_tree_add_item(tree, offset, sizeof(hdr->delay),
proto_tree_add_text(tree, offset, sizeof(hdr->delay),
"Processing delay: %u", hdr->delay);
offset += sizeof(hdr->delay);
frame = pntohl(&hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->frame),
proto_tree_add_text(tree, offset, sizeof(hdr->frame),
"Framing capabilities: %s (%u)", frametype2str(frame), frame);
offset += sizeof(hdr->frame);
}
@ -787,11 +786,11 @@ static void
dissect_clear_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct clear_req * hdr = (struct clear_req *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
}
@ -800,27 +799,27 @@ static void
dissect_disc_notify(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct disc_notify * hdr = (struct disc_notify *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->call_id),
proto_tree_add_text(tree, offset, sizeof(hdr->call_id),
"Call ID: %u", hdr->call_id);
offset += sizeof(hdr->call_id);
proto_tree_add_item(tree, offset, sizeof(hdr->result),
proto_tree_add_text(tree, offset, sizeof(hdr->result),
"Result: %s (%u)", discresulttype2str(hdr->result), hdr->result);
offset += sizeof(hdr->result);
proto_tree_add_item(tree, offset, sizeof(hdr->error),
proto_tree_add_text(tree, offset, sizeof(hdr->error),
"Error: %s (%u)", errortype2str(hdr->error), hdr->error);
offset += sizeof(hdr->error);
proto_tree_add_item(tree, offset, sizeof(hdr->cause),
proto_tree_add_text(tree, offset, sizeof(hdr->cause),
"Cause code: %u", hdr->cause);
offset += sizeof(hdr->cause);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
proto_tree_add_item(tree, offset, sizeof(hdr->stats),
proto_tree_add_text(tree, offset, sizeof(hdr->stats),
"Call statistics: %s", hdr->stats);
offset += sizeof(hdr->stats);
}
@ -829,35 +828,35 @@ static void
dissect_error_notify(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct error_notify * hdr = (struct error_notify *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->peer_id),
proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
"Peer's call ID: %u", hdr->peer_id);
offset += sizeof(hdr->peer_id);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
proto_tree_add_item(tree, offset, sizeof(hdr->crc),
proto_tree_add_text(tree, offset, sizeof(hdr->crc),
"CRC errors: %u", hdr->crc);
offset += sizeof(hdr->crc);
proto_tree_add_item(tree, offset, sizeof(hdr->frame),
proto_tree_add_text(tree, offset, sizeof(hdr->frame),
"Framing errors: %u", hdr->frame);
offset += sizeof(hdr->frame);
proto_tree_add_item(tree, offset, sizeof(hdr->hardware),
proto_tree_add_text(tree, offset, sizeof(hdr->hardware),
"Hardware overruns: %u", hdr->hardware);
offset += sizeof(hdr->hardware);
proto_tree_add_item(tree, offset, sizeof(hdr->buffer),
proto_tree_add_text(tree, offset, sizeof(hdr->buffer),
"Buffer overruns: %u", hdr->buffer);
offset += sizeof(hdr->buffer);
proto_tree_add_item(tree, offset, sizeof(hdr->timeout),
proto_tree_add_text(tree, offset, sizeof(hdr->timeout),
"Time-out errors: %u", hdr->timeout);
offset += sizeof(hdr->timeout);
proto_tree_add_item(tree, offset, sizeof(hdr->alignment),
proto_tree_add_text(tree, offset, sizeof(hdr->alignment),
"Alignment errors: %u", hdr->alignment);
offset += sizeof(hdr->alignment);
}
@ -866,19 +865,19 @@ static void
dissect_set_link(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
struct set_link * hdr = (struct set_link *)(pd + offset);
proto_tree_add_item(tree, offset, sizeof(hdr->peer_id),
proto_tree_add_text(tree, offset, sizeof(hdr->peer_id),
"Peer's call ID: %u", hdr->peer_id);
offset += sizeof(hdr->peer_id);
proto_tree_add_item(tree, offset, sizeof(hdr->resv),
proto_tree_add_text(tree, offset, sizeof(hdr->resv),
"Reserved: %u", hdr->resv);
offset += sizeof(hdr->resv);
proto_tree_add_item(tree, offset, sizeof(hdr->send_acm),
proto_tree_add_text(tree, offset, sizeof(hdr->send_acm),
"Send ACCM: %#08x", hdr->send_acm);
offset += sizeof(hdr->send_acm);
proto_tree_add_item(tree, offset, sizeof(hdr->recv_acm),
proto_tree_add_text(tree, offset, sizeof(hdr->recv_acm),
"Recv ACCM: %#08x", hdr->recv_acm);
offset += sizeof(hdr->recv_acm);
}

View File

@ -1,7 +1,7 @@
/* packet-raw.c
* Routines for raw packet disassembly
*
* $Id: packet-raw.c,v 1.9 1999/03/23 03:14:43 gram Exp $
* $Id: packet-raw.c,v 1.10 1999/07/07 22:51:52 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -71,10 +71,9 @@ dissect_raw( const u_char *pd, frame_data *fd, proto_tree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = proto_tree_add_item(tree, 0, 0, "Raw packet data" );
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_RAW);
proto_tree_add_item(fh_tree, 0, 0, "No link information available");
ti = proto_tree_add_text(tree, 0, 0, "Raw packet data" );
fh_tree = proto_item_add_subtree(ti, ETT_RAW);
proto_tree_add_text(fh_tree, 0, 0, "No link information available");
}
/* So far, the only time we get raw connection types are with Linux and

View File

@ -2,7 +2,7 @@
* Routines for RIPv1 and RIPv2 packet disassembly
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-rip.c,v 1.8 1999/03/23 03:14:43 gram Exp $
* $Id: packet-rip.c,v 1.9 1999/07/07 22:51:52 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -90,14 +90,13 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_INFO, packet_type[rip_header.command]);
if (tree) {
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset), "Routing Information Protocol");
rip_tree = proto_tree_new();
proto_item_add_subtree(ti, rip_tree, ETT_RIP);
ti = proto_tree_add_text(tree, offset, (fd->cap_len - offset), "Routing Information Protocol");
rip_tree = proto_item_add_subtree(ti, ETT_RIP);
proto_tree_add_item(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]);
proto_tree_add_item(rip_tree, offset + 1, 1, "Version: %d", rip_header.version);
proto_tree_add_text(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]);
proto_tree_add_text(rip_tree, offset + 1, 1, "Version: %d", rip_header.version);
if(rip_header.version == RIPv2)
proto_tree_add_item(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
proto_tree_add_text(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
/* skip header */
offset += RIP_HEADER_LENGTH;
@ -109,7 +108,7 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
family = ntohs(rip_entry.vektor.family);
switch (family) {
case 2: /* IP */
ti = proto_tree_add_item(rip_tree, offset,
ti = proto_tree_add_text(rip_tree, offset,
RIP_ENTRY_LENGTH, "IP Address: %s, Metric: %ld",
ip_to_str((guint8 *) &(rip_entry.vektor.ip)),
(long)ntohl(rip_entry.vektor.metric));
@ -117,13 +116,13 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
offset, ti);
break;
case 0xFFFF:
proto_tree_add_item(rip_tree, offset,
proto_tree_add_text(rip_tree, offset,
RIP_ENTRY_LENGTH, "Authentication");
dissect_rip_authentication(&rip_entry.authentication,
offset, ti);
break;
default:
proto_tree_add_item(rip_tree, offset,
proto_tree_add_text(rip_tree, offset,
RIP_ENTRY_LENGTH, "Unknown address family %u",
family);
break;
@ -140,22 +139,21 @@ dissect_ip_rip_vektor(guint8 version, const e_rip_vektor *rip_vektor,
{
proto_tree *rip_vektor_tree;
rip_vektor_tree = proto_tree_new();
proto_item_add_subtree(tree, rip_vektor_tree, ETT_RIP_VEC);
rip_vektor_tree = proto_item_add_subtree(tree, ETT_RIP_VEC);
proto_tree_add_item(rip_vektor_tree, offset, 2, "Address Family ID: IP");
proto_tree_add_text(rip_vektor_tree, offset, 2, "Address Family ID: IP");
if(version == RIPv2)
proto_tree_add_item(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
proto_tree_add_text(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
ntohs(rip_vektor->tag));
proto_tree_add_item(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
proto_tree_add_text(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
ip_to_str((guint8 *) &(rip_vektor->ip)));
if(version == RIPv2) {
proto_tree_add_item(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
proto_tree_add_text(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
ip_to_str((guint8 *) &(rip_vektor->mask)));
proto_tree_add_item(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
proto_tree_add_text(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
ip_to_str((guint8 *) &(rip_vektor->next_hop)));
}
proto_tree_add_item(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
proto_tree_add_text(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
(long)ntohl(rip_vektor->metric));
}
@ -166,14 +164,13 @@ dissect_rip_authentication(const e_rip_authentication *rip_authentication,
proto_tree *rip_authentication_tree;
guint16 authtype;
rip_authentication_tree = proto_tree_new();
proto_item_add_subtree(tree, rip_authentication_tree, ETT_RIP_VEC);
rip_authentication_tree = proto_item_add_subtree(tree, ETT_RIP_VEC);
authtype = ntohs(rip_authentication->authtype);
proto_tree_add_item(rip_authentication_tree, offset + 2, 2,
proto_tree_add_text(rip_authentication_tree, offset + 2, 2,
"Authentication type: %u", authtype);
if (authtype == 2)
proto_tree_add_item(rip_authentication_tree, offset + 4 , 16,
proto_tree_add_text(rip_authentication_tree, offset + 4 , 16,
"Password: %.16s",
rip_authentication->authentication);
}

View File

@ -3,7 +3,7 @@
*
* (c) Copyright Ashok Narayanan <ashokn@cisco.com>
*
* $Id: packet-rsvp.c,v 1.1 1999/06/11 16:44:51 gram Exp $
* $Id: packet-rsvp.c,v 1.2 1999/07/07 22:51:52 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -160,27 +160,25 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (tree) {
msg_length = pntohs(pd+offset+6);
ti = proto_tree_add_item(tree, offset, msg_length,
ti = proto_tree_add_text(tree, offset, msg_length,
"Resource ReserVation Protocol (RSVP)");
rsvp_tree = proto_tree_new();
proto_item_add_subtree(ti, rsvp_tree, ETT_RSVP);
rsvp_tree = proto_item_add_subtree(ti, ETT_RSVP);
ti = proto_tree_add_item(rsvp_tree, offset,
ti = proto_tree_add_text(rsvp_tree, offset,
sizeof(rsvp_header), "RSVP Header");
rsvp_header_tree = proto_tree_new();
proto_item_add_subtree(ti, rsvp_header_tree, ETT_RSVP_HDR);
rsvp_header_tree = proto_item_add_subtree(ti, ETT_RSVP_HDR);
proto_tree_add_item(rsvp_header_tree, offset, 1, "RSVP Version: %d",
proto_tree_add_text(rsvp_header_tree, offset, 1, "RSVP Version: %d",
(hdr->ver_flags & 0xf0)>>4);
proto_tree_add_item(rsvp_header_tree, offset, 1, "Flags: %02X",
proto_tree_add_text(rsvp_header_tree, offset, 1, "Flags: %02X",
hdr->ver_flags & 0xf);
proto_tree_add_item(rsvp_header_tree, offset+1, 1, "Message Type: %d - %s",
proto_tree_add_text(rsvp_header_tree, offset+1, 1, "Message Type: %d - %s",
hdr->message_type,
packet_type?packet_type:"Unknown");
proto_tree_add_item(rsvp_header_tree, offset + 2 , 2, "Message Checksum");
proto_tree_add_item(rsvp_header_tree, offset + 4 , 1, "Sending TTL: %d",
proto_tree_add_text(rsvp_header_tree, offset + 2 , 2, "Message Checksum");
proto_tree_add_text(rsvp_header_tree, offset + 4 , 1, "Sending TTL: %d",
hdr->sending_ttl);
proto_tree_add_item(rsvp_header_tree, offset + 6 , 2, "Message length: %d",
proto_tree_add_text(rsvp_header_tree, offset + 6 , 2, "Message length: %d",
msg_length);
offset += sizeof(rsvp_header);
@ -189,42 +187,41 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
obj = (rsvp_object *)&pd[offset];
obj_length = pntohs(pd+offset);
if (offset + obj_length > fd->cap_len) {
proto_tree_add_item(rsvp_tree, offset, 1,
proto_tree_add_text(rsvp_tree, offset, 1,
"Further data not captured");
break;
}
object_type = match_strval(obj->class, rsvp_class_vals);
if (!object_type) object_type = "Unknown";
ti = proto_tree_add_item(rsvp_tree, offset,
ti = proto_tree_add_text(rsvp_tree, offset,
obj_length,
"%s (%d)", object_type, obj->class);
rsvp_object_tree = proto_tree_new();
offset2 = offset + sizeof(rsvp_object);
switch(obj->class) {
case RSVP_CLASS_SESSION :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_SESSION);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_SESSION);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
case 1: {
rsvp_session_ipv4 *sess = (rsvp_session_ipv4 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Destination address: %s",
ip_to_str((guint8 *) &(sess->destination)));
proto_tree_add_item(rsvp_object_tree, offset2+4, 1,
proto_tree_add_text(rsvp_object_tree, offset2+4, 1,
"Protocol: %d", sess->protocol);
proto_tree_add_item(rsvp_object_tree, offset2+5, 1,
proto_tree_add_text(rsvp_object_tree, offset2+5, 1,
"Flags: %d", sess->flags);
proto_tree_add_item(rsvp_object_tree, offset2+6, 2,
proto_tree_add_text(rsvp_object_tree, offset2+6, 2,
"Destination port: %d",
pntohs(pd+offset2+6));
break;
@ -232,48 +229,48 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 2: {
rsvp_session_ipv6 *sess = (rsvp_session_ipv6 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Destination address: %s",
ip6_to_str(&(sess->destination)));
proto_tree_add_item(rsvp_object_tree, offset2+16, 1,
proto_tree_add_text(rsvp_object_tree, offset2+16, 1,
"Protocol: %d", sess->protocol);
proto_tree_add_item(rsvp_object_tree, offset2+17, 1,
proto_tree_add_text(rsvp_object_tree, offset2+17, 1,
"Flags: %d", sess->flags);
proto_tree_add_item(rsvp_object_tree, offset2+18, 2,
proto_tree_add_text(rsvp_object_tree, offset2+18, 2,
"Destination port: %d",
pntohs(pd+offset2+18));
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
break;
case RSVP_CLASS_HOP :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_HOP);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_HOP);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
case 1: {
rsvp_hop_ipv4 *hop = (rsvp_hop_ipv4 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Neighbor address: %s",
ip_to_str((guint8 *) &(hop->neighbor)));
proto_tree_add_item(rsvp_object_tree, offset2+4, 4,
proto_tree_add_text(rsvp_object_tree, offset2+4, 4,
"Logical interface: %0x",
pntohl(pd+offset2+4));
break;
@ -281,40 +278,40 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 2: {
rsvp_hop_ipv6 *hop = (rsvp_hop_ipv6 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Neighbor address: %s",
ip6_to_str(&(hop->neighbor)));
proto_tree_add_item(rsvp_object_tree, offset2+16, 4,
proto_tree_add_text(rsvp_object_tree, offset2+16, 4,
"Logical interface: %0x",
pntohl(pd+offset2+16));
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
break;
case RSVP_CLASS_TIME_VALUES :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_TIME_VALUES);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_TIME_VALUES);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
case 1: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Refresh interval: %u ms (%u seconds)",
pntohl(pd+offset2),
pntohl(pd+offset2)/1000);
@ -322,11 +319,11 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
break;
}
@ -334,10 +331,10 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
break;
case RSVP_CLASS_ERROR :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_ERROR);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_ERROR);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
@ -346,17 +343,17 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
char *err_str = match_strval(err->error_code, rsvp_error_vals);
if (!err_str) err_str = "Unknown";
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Error node: %s",
ip_to_str((guint8 *) &(err->error_node)));
proto_tree_add_item(rsvp_object_tree, offset2+4, 1,
proto_tree_add_text(rsvp_object_tree, offset2+4, 1,
"Flags: %02x", err->flags);
proto_tree_add_item(rsvp_object_tree, offset2+5, 1,
proto_tree_add_text(rsvp_object_tree, offset2+5, 1,
"Error code: %d - %s", err->error_code,
err_str);
proto_tree_add_item(rsvp_object_tree, offset2+6, 2,
proto_tree_add_text(rsvp_object_tree, offset2+6, 2,
"Error value: %d", pntohs(pd+offset2+6));
break;
@ -366,28 +363,28 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
rsvp_error_ipv6 *err = (rsvp_error_ipv6 *)obj;
char *err_str = match_strval(err->error_code, rsvp_error_vals);
if (!err_str) err_str = "Unknown";
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Error node: %s",
ip6_to_str(&(err->error_node)));
proto_tree_add_item(rsvp_object_tree, offset2+16, 1,
proto_tree_add_text(rsvp_object_tree, offset2+16, 1,
"Flags: %02x", err->flags);
proto_tree_add_item(rsvp_object_tree, offset2+17, 1,
proto_tree_add_text(rsvp_object_tree, offset2+17, 1,
"Error code: %d - %s", err->error_code,
err_str);
proto_tree_add_item(rsvp_object_tree, offset2+18, 2,
proto_tree_add_text(rsvp_object_tree, offset2+18, 2,
"Error value: %d", pntohs(pd+offset2+18));
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
@ -396,20 +393,20 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case RSVP_CLASS_SCOPE :
mylen = obj_length;
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_SCOPE);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_SCOPE);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
case 1: {
unsigned long ip;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
while (mylen > sizeof(rsvp_object)) {
ip = pntohl(pd+offset2);
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"IPv4 Address: %s",
ip_to_str((guint8 *) &ip));
offset2 += 4;
@ -420,11 +417,11 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 2: {
struct e_in6_addr *ip;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
while (mylen>sizeof(rsvp_object)) {
ip = (struct e_in6_addr *)pd+offset2;
proto_tree_add_item(rsvp_object_tree, offset2, 16,
proto_tree_add_text(rsvp_object_tree, offset2, 16,
"IPv6 Address: %s",
ip6_to_str(ip));
offset2 += 16;
@ -434,21 +431,21 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
break;
case RSVP_CLASS_STYLE :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_STYLE);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_STYLE);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
@ -456,19 +453,19 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
unsigned long ip = pntohl(pd+offset2);
char *style_str = match_strval(ip, style_vals);
if (!style_str) style_str = "Unknown";
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1");
proto_tree_add_item(rsvp_object_tree, offset2+5, 1,
proto_tree_add_text(rsvp_object_tree, offset2+5, 1,
"Style: %ld - %s", ip, style_str);
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
break;
}
@ -476,18 +473,18 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
break;
case RSVP_CLASS_CONFIRM :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_CONFIRM);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_CONFIRM);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
switch(obj->type) {
case 1: {
rsvp_confirm_ipv4 *confirm = (rsvp_confirm_ipv4 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Receiver address: %s",
ip_to_str((guint8 *) &(confirm->receiver)));
break;
@ -495,72 +492,72 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 2: {
rsvp_confirm_ipv6 *confirm = (rsvp_confirm_ipv6 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
proto_tree_add_item(rsvp_object_tree, offset2, 16,
proto_tree_add_text(rsvp_object_tree, offset2, 16,
"Receiver address: %s",
ip6_to_str(&(confirm->receiver)));
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
break;
case RSVP_CLASS_SENDER_TEMPLATE :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_SENDER_TEMPLATE);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_SENDER_TEMPLATE);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
goto common_template;
case RSVP_CLASS_FILTER_SPEC :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_FILTER_SPEC);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_FILTER_SPEC);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
common_template:
switch(obj->type) {
case 1: {
rsvp_template_ipv4 *tem = (rsvp_template_ipv4 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, offset2, 4,
proto_tree_add_text(rsvp_object_tree, offset2, 4,
"Source address: %s",
ip_to_str((guint8 *) &(tem->source)));
proto_tree_add_item(rsvp_object_tree, offset2+6, 2,
proto_tree_add_text(rsvp_object_tree, offset2+6, 2,
"Source port: %d", pntohs(pd+offset2+6));
break;
}
case 2: {
rsvp_template_ipv6 *tem = (rsvp_template_ipv6 *)obj;
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 2 - IPv6");
proto_tree_add_item(rsvp_object_tree, offset2, 16,
proto_tree_add_text(rsvp_object_tree, offset2, 16,
"Source address: %s",
ip6_to_str(&(tem->source)));
proto_tree_add_item(rsvp_object_tree, offset2+18, 2,
proto_tree_add_text(rsvp_object_tree, offset2+18, 2,
"Source port: %d", pntohs(pd+offset2+18));
break;
}
default: {
proto_tree_add_item(rsvp_object_tree, offset+3, 1,
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: Unknown (%d)",
obj->type);
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
}
}
@ -569,59 +566,58 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case RSVP_CLASS_SENDER_TSPEC : {
IS_tspec *tspec = (IS_tspec *)obj;
proto_item_add_subtree(ti, rsvp_object_tree,
ETT_RSVP_SENDER_TSPEC);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_SENDER_TSPEC);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
proto_tree_add_item(rsvp_object_tree, offset2, 1,
proto_tree_add_text(rsvp_object_tree, offset2, 1,
"Message format version: %d",
tspec->version>>4);
proto_tree_add_item(rsvp_object_tree, offset2+2, 2,
proto_tree_add_text(rsvp_object_tree, offset2+2, 2,
"Data length: %d words, not including header",
pntohs(pd+offset2+2));
proto_tree_add_item(rsvp_object_tree, offset2+4, 1,
proto_tree_add_text(rsvp_object_tree, offset2+4, 1,
"Service header: %d - %s",
tspec->service_header,
tspec->service_header==1 ?
"Default/global information (INTSRV_GENERAL)" :
"Unknown");
proto_tree_add_item(rsvp_object_tree, offset2+6, 2,
proto_tree_add_text(rsvp_object_tree, offset2+6, 2,
"Length of service %d data: %d words, "
"not including header",
tspec->service_header,
pntohs(pd+offset2+6)>>12);
/* Token bucket TSPEC */
proto_tree_add_item(rsvp_object_tree, offset2+8, 1,
proto_tree_add_text(rsvp_object_tree, offset2+8, 1,
"Parameter ID: %d - %s",
tspec->param_id,
tspec->param_id==127 ? "Token Bucket TSpec" :
"Unknown");
proto_tree_add_item(rsvp_object_tree, offset2+9, 1,
proto_tree_add_text(rsvp_object_tree, offset2+9, 1,
"Parameter %d flags: %d",
tspec->param_id, tspec->flags_tspec);
proto_tree_add_item(rsvp_object_tree, offset2+10, 2,
proto_tree_add_text(rsvp_object_tree, offset2+10, 2,
"Length of parameter %d data: %d words, "
"not including header",
tspec->param_id,
pntohs(pd+offset2+10));
proto_tree_add_item(rsvp_object_tree, offset2+12, 4,
proto_tree_add_text(rsvp_object_tree, offset2+12, 4,
"Token bucket rate: %ld",
ieee_to_long(pd+offset2+12));
proto_tree_add_item(rsvp_object_tree, offset2+16, 4,
proto_tree_add_text(rsvp_object_tree, offset2+16, 4,
"Token bucket size: %ld",
ieee_to_long(pd+offset2+16));
proto_tree_add_item(rsvp_object_tree, offset2+20, 4,
proto_tree_add_text(rsvp_object_tree, offset2+20, 4,
"Peak data rate: %ld",
ieee_to_long(pd+offset2+20));
proto_tree_add_item(rsvp_object_tree, offset2+24, 4,
proto_tree_add_text(rsvp_object_tree, offset2+24, 4,
"Minimum policed unit: %d",
pntohl(pd+offset2+24));
proto_tree_add_item(rsvp_object_tree, offset2+28, 4,
proto_tree_add_text(rsvp_object_tree, offset2+28, 4,
"Maximum policed unit: %d",
pntohl(pd+offset2+28));
@ -633,54 +629,53 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
char *qos_str = match_strval(flowspec->service_header, qos_vals);
char *is_param_str = match_strval(flowspec->param_id, svc_vals);
proto_item_add_subtree(ti, rsvp_object_tree,
ETT_RSVP_FLOWSPEC);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_FLOWSPEC);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
if (!qos_str) qos_str = "Unknown";
if (!is_param_str) is_param_str="Unknown";
proto_tree_add_item(rsvp_object_tree, offset2, 1,
proto_tree_add_text(rsvp_object_tree, offset2, 1,
"Message format version: %d",
flowspec->version>>4);
proto_tree_add_item(rsvp_object_tree, offset2+2, 2,
proto_tree_add_text(rsvp_object_tree, offset2+2, 2,
"Data length: %d words, not including header",
pntohs(pd+offset2+2));
proto_tree_add_item(rsvp_object_tree, offset2+4, 1,
proto_tree_add_text(rsvp_object_tree, offset2+4, 1,
"Service header: %d - %s",
flowspec->service_header, qos_str);
proto_tree_add_item(rsvp_object_tree, offset2+6, 2,
proto_tree_add_text(rsvp_object_tree, offset2+6, 2,
"Length of service %d data: %d words, "
"not including header",
flowspec->service_header,
pntohs(pd+offset2+6)>>12);
proto_tree_add_item(rsvp_object_tree, offset2+8, 1,
proto_tree_add_text(rsvp_object_tree, offset2+8, 1,
"Parameter ID: %d - %s",
flowspec->param_id, is_param_str);
proto_tree_add_item(rsvp_object_tree, offset2+9, 1,
proto_tree_add_text(rsvp_object_tree, offset2+9, 1,
"Parameter %d flags: %d",
flowspec->param_id, flowspec->flags_tspec);
proto_tree_add_item(rsvp_object_tree, offset2+10, 2,
proto_tree_add_text(rsvp_object_tree, offset2+10, 2,
"Length of parameter %d data: %d words, "
"not including header",
flowspec->param_id,
pntohs(pd+offset2+10));
proto_tree_add_item(rsvp_object_tree, offset2+12, 4,
proto_tree_add_text(rsvp_object_tree, offset2+12, 4,
"Token bucket rate: %ld",
ieee_to_long(pd+offset2+12));
proto_tree_add_item(rsvp_object_tree, offset2+16, 4,
proto_tree_add_text(rsvp_object_tree, offset2+16, 4,
"Token bucket size: %ld",
ieee_to_long(pd+offset2+16));
proto_tree_add_item(rsvp_object_tree, offset2+20, 4,
proto_tree_add_text(rsvp_object_tree, offset2+20, 4,
"Peak data rate: %ld",
ieee_to_long(pd+offset2+20));
proto_tree_add_item(rsvp_object_tree, offset2+24, 4,
proto_tree_add_text(rsvp_object_tree, offset2+24, 4,
"Minimum policed unit: %d",
pntohl(pd+offset2+24));
proto_tree_add_item(rsvp_object_tree, offset2+28, 4,
proto_tree_add_text(rsvp_object_tree, offset2+28, 4,
"Maximum policed unit: %d",
pntohl(pd+offset2+28));
if (flowspec->service_header!=QOS_GUARANTEED)
@ -689,21 +684,21 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
/* Guaranteed-rate RSpec */
is_param_str = match_strval(flowspec->param_id_rspec, svc_vals);
if (!is_param_str) is_param_str="Unknown";
proto_tree_add_item(rsvp_object_tree, offset2+32, 1,
proto_tree_add_text(rsvp_object_tree, offset2+32, 1,
"Parameter ID: %d - %s",
flowspec->param_id, is_param_str);
proto_tree_add_item(rsvp_object_tree, offset2+33, 1,
proto_tree_add_text(rsvp_object_tree, offset2+33, 1,
"Parameter %d flags: %d",
flowspec->param_id, flowspec->flags_rspec);
proto_tree_add_item(rsvp_object_tree, offset2+34, 2,
proto_tree_add_text(rsvp_object_tree, offset2+34, 2,
"Length of parameter %d data: %d words, "
"not including header",
flowspec->param_id,
pntohs(pd+offset2+34));
proto_tree_add_item(rsvp_object_tree, offset2+36, 4,
proto_tree_add_text(rsvp_object_tree, offset2+36, 4,
"Rate: %ld",
ieee_to_long(pd+offset2+36));
proto_tree_add_item(rsvp_object_tree, offset2+40, 4,
proto_tree_add_text(rsvp_object_tree, offset2+40, 4,
"Slack term: %d",
pntohl(pd+offset2+40));
@ -719,17 +714,17 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
int tree_num;
mylen = obj_length;
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_ADSPEC);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_ADSPEC);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
proto_tree_add_item(rsvp_object_tree, offset2, 1,
proto_tree_add_text(rsvp_object_tree, offset2, 1,
"Message format version: %d",
(*((unsigned char *)pd+offset2))>>4);
proto_tree_add_item(rsvp_object_tree, offset2+2, 2,
proto_tree_add_text(rsvp_object_tree, offset2+2, 2,
"Data length: %d words, not including header",
pntohs(pd+offset2+2));
offset2+=4;
@ -739,18 +734,17 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
shdr = (service_hdr *)(pd + offset2);
str = match_strval(shdr->service_num, adspec_services);
ti = proto_tree_add_item(rsvp_object_tree, offset2,
ti = proto_tree_add_text(rsvp_object_tree, offset2,
(pntohs(&shdr->length)+1)<<2,
str?str:"Unknown");
adspec_tree = proto_tree_new();
proto_item_add_subtree(ti, adspec_tree, tree_num++);
proto_tree_add_item(adspec_tree, offset2, 1,
adspec_tree = proto_item_add_subtree(ti, tree_num++);
proto_tree_add_text(adspec_tree, offset2, 1,
"Service header %d - %s",
shdr->service_num, str);
proto_tree_add_item(adspec_tree, offset2+1, 1,
proto_tree_add_text(adspec_tree, offset2+1, 1,
(shdr->break_bit&0x80)?
"Break bit set":"Break bit not set");
proto_tree_add_item(adspec_tree, offset2+2, 2,
proto_tree_add_text(adspec_tree, offset2+2, 2,
"Data length: %d words, not including header",
pntohs(&shdr->length));
offset2+=4; i=(pntohs(&shdr->length)+1)<<2; mylen-=4;
@ -767,7 +761,7 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 135:
case 136:
/* 32-bit unsigned integer */
proto_tree_add_item(adspec_tree, offset2,
proto_tree_add_text(adspec_tree, offset2,
(pntohs(&phdr->length)+1)<<2,
"%s - %lu (type %d, length %d)",
str,
@ -777,7 +771,7 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case 6:
/* IEEE float */
proto_tree_add_item(adspec_tree, offset2,
proto_tree_add_text(adspec_tree, offset2,
(pntohs(&phdr->length)+1)<<2,
"%s - %lu (type %d, length %d)",
str,
@ -785,14 +779,14 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
phdr->id, pntohs(&phdr->length));
break;
default:
proto_tree_add_item(adspec_tree, offset2,
proto_tree_add_text(adspec_tree, offset2,
(pntohs(&phdr->length)+1)<<2,
"%s (type %d, length %d)",
str,
phdr->id, pntohs(&phdr->length));
}
} else {
proto_tree_add_item(adspec_tree, offset2,
proto_tree_add_text(adspec_tree, offset2,
(pntohs(&phdr->length)+1)<<2,
"Unknown (type %d, length %d)",
phdr->id, pntohs(&phdr->length));
@ -806,33 +800,33 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
case RSVP_CLASS_INTEGRITY :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_INTEGRITY);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_INTEGRITY);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
goto default_class;
case RSVP_CLASS_POLICY :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_POLICY);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_POLICY);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
goto default_class;
default :
proto_item_add_subtree(ti, rsvp_object_tree, ETT_RSVP_UNKNOWN_CLASS);
proto_tree_add_item(rsvp_object_tree, offset, 2, "Length: %d",
rsvp_object_tree = proto_item_add_subtree(ti, ETT_RSVP_UNKNOWN_CLASS);
proto_tree_add_text(rsvp_object_tree, offset, 2, "Length: %d",
obj_length);
proto_tree_add_item(rsvp_object_tree, offset+2, 1,
proto_tree_add_text(rsvp_object_tree, offset+2, 1,
"Class number: %d - %s",
obj->class, object_type);
default_class:
i = obj_length - sizeof(rsvp_object);
proto_tree_add_item(rsvp_object_tree, offset2, i,
proto_tree_add_text(rsvp_object_tree, offset2, i,
"Data (%d bytes)", i);
break;

View File

@ -4,7 +4,7 @@
* Jason Lango <jal@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@netapp.com>
*
* $Id: packet-rtsp.c,v 1.1 1999/07/07 00:34:56 guy Exp $
* $Id: packet-rtsp.c,v 1.2 1999/07/07 22:51:53 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -104,10 +104,9 @@ void dissect_rtsp(const u_char *pd, int offset, frame_data *fd,
rtsp_tree = NULL;
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Real Time Streaming Protocol");
rtsp_tree = proto_tree_new();
proto_item_add_subtree(ti, rtsp_tree, ETT_RTSP);
rtsp_tree = proto_item_add_subtree(ti, ETT_RTSP);
}
while (data < dataend) {
@ -195,7 +194,7 @@ void dissect_rtsp(const u_char *pd, int offset, frame_data *fd,
* Put this line.
*/
if (rtsp_tree) {
proto_tree_add_item(rtsp_tree, offset, linelen, "%s",
proto_tree_add_text(rtsp_tree, offset, linelen, "%s",
format_text(data, linelen));
}
offset += linelen;
@ -208,7 +207,7 @@ void dissect_rtsp(const u_char *pd, int offset, frame_data *fd,
col_add_str(fd, COL_PROTOCOL, "RTSP/SDP");
}
else if (rtsp_tree && data < dataend) {
proto_tree_add_item(rtsp_tree, offset, END_OF_FRAME,
proto_tree_add_text(rtsp_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
}
}

View File

@ -4,7 +4,7 @@
* Jason Lango <jal@netapp.com>
* Liberally copied from packet-http.c, by Guy Harris <guy@netapp.com>
*
* $Id: packet-sdp.c,v 1.1 1999/07/07 00:34:56 guy Exp $
* $Id: packet-sdp.c,v 1.2 1999/07/07 22:51:53 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -68,10 +68,9 @@ void dissect_sdp(const u_char *pd, int offset, frame_data *fd,
if (!tree)
return;
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Session Description Protocol");
sdp_tree = proto_tree_new();
proto_item_add_subtree(ti, sdp_tree, ETT_SDP);
sdp_tree = proto_item_add_subtree(ti, ETT_SDP);
section = 0;
for (; data < dataend; offset += linelen, data = lineend) {
@ -89,7 +88,7 @@ void dissect_sdp(const u_char *pd, int offset, frame_data *fd,
type = data[0];
if (data[1] != '=') {
proto_tree_add_item(sdp_tree, offset, linelen,
proto_tree_add_text(sdp_tree, offset, linelen,
"Invalid line: %s",
format_text(data, linelen));
continue;
@ -164,13 +163,13 @@ void dissect_sdp(const u_char *pd, int offset, frame_data *fd,
break;
}
proto_tree_add_item(sdp_tree, offset, linelen,
proto_tree_add_text(sdp_tree, offset, linelen,
"%s (%c): %s", typename, type,
format_text(value, valuelen));
}
if (data < dataend) {
proto_tree_add_item(sdp_tree, offset, END_OF_FRAME,
proto_tree_add_text(sdp_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
* Routines for SNMP (simple network management protocol)
* D.Jorand (c) 1998
*
* $Id: packet-snmp.c,v 1.3 1999/06/12 04:17:19 guy Exp $
* $Id: packet-snmp.c,v 1.4 1999/07/07 22:51:54 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -452,18 +452,17 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if(tree) {
/* all_length=header_length+pdu_type_length+request_id_length+error_status_length+error_index_length; */
all_length=fd->pkt_len-offset;
item = proto_tree_add_item(tree, offset, all_length, "Simple Network Management Protocol");
snmp_tree = proto_tree_new();
proto_item_add_subtree(item, snmp_tree, ETT_SNMP);
proto_tree_add_item(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
item = proto_tree_add_text(tree, offset, all_length, "Simple Network Management Protocol");
snmp_tree = proto_item_add_subtree(item, ETT_SNMP);
proto_tree_add_text(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
offset+=header_length;
proto_tree_add_item(snmp_tree, offset, pdu_type_length, "%s", pdu_type_string);
proto_tree_add_text(snmp_tree, offset, pdu_type_length, "%s", pdu_type_string);
offset+=pdu_type_length;
proto_tree_add_item(snmp_tree, offset, request_id_length, "Request Id.: %#x", (unsigned int)request_id);
proto_tree_add_text(snmp_tree, offset, request_id_length, "Request Id.: %#x", (unsigned int)request_id);
offset+=request_id_length;
proto_tree_add_item(snmp_tree, offset, error_status_length, "Error Status: %s", val_to_str(error_status, error_statuses, "Unknown (%d)"));
proto_tree_add_text(snmp_tree, offset, error_status_length, "Error Status: %s", val_to_str(error_status, error_statuses, "Unknown (%d)"));
offset+=error_status_length;
proto_tree_add_item(snmp_tree, offset, error_index_length, "Error Index: %d", (int)error_index);
proto_tree_add_text(snmp_tree, offset, error_index_length, "Error Index: %d", (int)error_index);
offset+=error_index_length;
} else {
offset+=header_length;
@ -481,12 +480,11 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
col_add_str(fd, COL_INFO, pdu_type_string);
if(tree) {
all_length=fd->pkt_len-offset;
item = proto_tree_add_item(tree, offset, all_length, "Simple Network Management Protocol");
snmp_tree = proto_tree_new();
proto_item_add_subtree(item, snmp_tree, ETT_SNMP);
proto_tree_add_item(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
item = proto_tree_add_text(tree, offset, all_length, "Simple Network Management Protocol");
snmp_tree = proto_item_add_subtree(item, ETT_SNMP);
proto_tree_add_text(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, val_to_str(version, versions, "Unknown version %#x"));
offset+=header_length;
proto_tree_add_item(snmp_tree, offset, pdu_type_length, "Pdu type: %s", pdu_type_string);
proto_tree_add_text(snmp_tree, offset, pdu_type_length, "Pdu type: %s", pdu_type_string);
offset+=pdu_type_length;
} else {
offset+=header_length;
@ -510,7 +508,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
strcat(vb_string,tmp_string);
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Enterprise: %s", vb_string);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Enterprise: %s", vb_string);
}
offset+=tmp_length;
@ -525,7 +523,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
tmp_length-=length;
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Agent address: %d.%d.%d.%d",
proto_tree_add_text(snmp_tree, offset, tmp_length, "Agent address: %d.%d.%d.%d",
vb_string_value[0],vb_string_value[1],vb_string_value[2],vb_string_value[3]);
}
offset+=tmp_length;
@ -540,7 +538,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
tmp_length-=length;
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Trap type: %s", val_to_str(trap_type, trap_types, "Unknown (%d)"));
proto_tree_add_text(snmp_tree, offset, tmp_length, "Trap type: %s", val_to_str(trap_type, trap_types, "Unknown (%d)"));
}
offset+=tmp_length;
@ -554,7 +552,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
tmp_length-=length;
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Specific trap type: %ld (%#lx)", (long)specific_type, (long)specific_type);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Specific trap type: %ld (%#lx)", (long)specific_type, (long)specific_type);
}
offset+=tmp_length;
@ -568,7 +566,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
}
tmp_length-=length;
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Timestamp: %lu", (unsigned long)timestamp);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Timestamp: %lu", (unsigned long)timestamp);
}
offset+=tmp_length;
}
@ -640,7 +638,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
sprint_objid(vb_string2, vb_name, vb_name_length);
proto_tree_add_item(snmp_tree, offset, tmp_length, "Object identifier %d: %s (%s)", vb_index, vb_string, vb_string2);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Object identifier %d: %s (%s)", vb_index, vb_string, vb_string2);
}
offset+=tmp_length;
@ -664,7 +662,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: NULL");
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: NULL");
}
offset+=tmp_length;
break;
@ -679,7 +677,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i> %ld (%#lx)", (long)vb_integer_value, (long)vb_integer_value);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i> %ld (%#lx)", (long)vb_integer_value, (long)vb_integer_value);
}
offset+=tmp_length;
break;
@ -697,7 +695,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <u> %lu (%#lx)", (unsigned long)vb_unsigned_value, (unsigned long)vb_unsigned_value);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <u> %lu (%#lx)", (unsigned long)vb_unsigned_value, (unsigned long)vb_unsigned_value);
}
offset+=tmp_length;
break;
@ -718,7 +716,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i64> %lu:%lu (%#lx:%lx)",
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i64> %lu:%lu (%#lx:%lx)",
vb_counter64_value.high,
vb_counter64_value.low,
vb_counter64_value.high,
@ -744,7 +742,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
sprintf(tmp_string, OID_FORMAT_STRING1, vb_oid_value[i]);
strcat(vb_string,tmp_string);
}
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <oid> %s", vb_string);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <oid> %s", vb_string);
}
offset+=tmp_length;
break;
@ -774,9 +772,9 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
sprintf(tmp_string, ".%03d", (int)vb_string_value[i]);
strcat(vb_string,tmp_string);
}
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string);
}else {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string_value);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string_value);
}
}
offset+=tmp_length;
@ -793,7 +791,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i64> %ld:%lu (%#lx:%lx)",
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <i64> %ld:%lu (%#lx:%lx)",
vb_counter64_value.high,
vb_counter64_value.low,
vb_counter64_value.high,
@ -813,7 +811,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <f> %f", (double)vb_float_value);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <f> %f", (double)vb_float_value);
}
offset+=tmp_length;
break;
@ -828,7 +826,7 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
return;
}
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <d> %f", vb_double_value);
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <d> %f", vb_double_value);
}
offset+=tmp_length;
break;
@ -836,17 +834,17 @@ dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case SNMP_NOSUCHOBJECT:
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> no such object");
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> no such object");
}
break;
case SNMP_NOSUCHINSTANCE:
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> no such instance");
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> no such instance");
}
break;
case SNMP_ENDOFMIBVIEW:
if(tree) {
proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> end of mib view");
proto_tree_add_text(snmp_tree, offset, tmp_length, "Value: <err> end of mib view");
}
break;

View File

@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
* $Id: packet-tcp.c,v 1.25 1999/07/07 00:34:57 guy Exp $
* $Id: packet-tcp.c,v 1.26 1999/07/07 22:51:55 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -144,7 +144,7 @@ static void
dissect_tcpopt_maxseg(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: %u bytes", name, pntohs(opd));
tcp_info_append_uint("MSS", pntohs(opd));
}
@ -153,7 +153,7 @@ static void
dissect_tcpopt_wscale(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: %u bytes", name, *opd);
tcp_info_append_uint("WS", *opd);
}
@ -166,17 +166,16 @@ dissect_tcpopt_sack(proto_tree *opt_tree, const char *name, const u_char *opd,
proto_item *tf;
guint leftedge, rightedge;
tf = proto_tree_add_item(opt_tree, offset, optlen, "%s:", name);
tf = proto_tree_add_text(opt_tree, offset, optlen, "%s:", name);
offset += 2; /* skip past type and length */
optlen -= 2; /* subtract size of type and length */
while (optlen > 0) {
if (field_tree == NULL) {
/* Haven't yet made a subtree out of this option. Do so. */
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_TCP_OPTION_SACK);
field_tree = proto_item_add_subtree(tf, ETT_TCP_OPTION_SACK);
}
if (optlen < 4) {
proto_tree_add_item(field_tree, offset, optlen,
proto_tree_add_text(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -185,7 +184,7 @@ dissect_tcpopt_sack(proto_tree *opt_tree, const char *name, const u_char *opd,
opd += 4;
optlen -= 4;
if (optlen < 4) {
proto_tree_add_item(field_tree, offset, optlen,
proto_tree_add_text(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -193,7 +192,7 @@ dissect_tcpopt_sack(proto_tree *opt_tree, const char *name, const u_char *opd,
rightedge = pntohl(opd);
opd += 4;
optlen -= 4;
proto_tree_add_item(field_tree, offset, 8,
proto_tree_add_text(field_tree, offset, 8,
"left edge = %u, right edge = %u", leftedge, rightedge);
tcp_info_append_uint("SLE", leftedge);
tcp_info_append_uint("SRE", rightedge);
@ -205,7 +204,7 @@ static void
dissect_tcpopt_echo(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: %u", name, pntohl(opd));
tcp_info_append_uint("ECHO", pntohl(opd));
}
@ -214,7 +213,7 @@ static void
dissect_tcpopt_timestamp(proto_tree *opt_tree, const char *name,
const u_char *opd, int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: tsval %u, tsecr %u", name, pntohl(opd), pntohl(opd + 4));
tcp_info_append_uint("TSV", pntohl(opd));
tcp_info_append_uint("TSER", pntohl(opd + 4));
@ -224,7 +223,7 @@ static void
dissect_tcpopt_cc(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
proto_tree_add_item(opt_tree, offset, optlen,
proto_tree_add_text(opt_tree, offset, optlen,
"%s: %u", name, pntohl(opd));
tcp_info_append_uint("CC", pntohl(opd));
}
@ -389,45 +388,43 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
}
if (tree) {
ti = proto_tree_add_item(tree, offset, hlen,
ti = proto_tree_add_text(tree, offset, hlen,
"Transmission Control Protocol");
tcp_tree = proto_tree_new();
proto_item_add_subtree(ti, tcp_tree, ETT_TCP);
proto_tree_add_item(tcp_tree, offset, 2, "Source port: %s (%u)",
tcp_tree = proto_item_add_subtree(ti, ETT_TCP);
proto_tree_add_text(tcp_tree, offset, 2, "Source port: %s (%u)",
get_tcp_port(th.th_sport), th.th_sport);
proto_tree_add_item(tcp_tree, offset + 2, 2, "Destination port: %s (%u)",
proto_tree_add_text(tcp_tree, offset + 2, 2, "Destination port: %s (%u)",
get_tcp_port(th.th_dport), th.th_dport);
proto_tree_add_item(tcp_tree, offset + 4, 4, "Sequence number: %u",
proto_tree_add_text(tcp_tree, offset + 4, 4, "Sequence number: %u",
th.th_seq);
if (th.th_flags & TH_ACK)
proto_tree_add_item(tcp_tree, offset + 8, 4, "Acknowledgement number: %u",
proto_tree_add_text(tcp_tree, offset + 8, 4, "Acknowledgement number: %u",
th.th_ack);
proto_tree_add_item(tcp_tree, offset + 12, 1, "Header length: %u bytes", hlen);
tf = proto_tree_add_item(tcp_tree, offset + 13, 1, "Flags: 0x%x", th.th_flags);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_TCP_FLAGS);
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(tcp_tree, offset + 12, 1, "Header length: %u bytes", hlen);
tf = proto_tree_add_text(tcp_tree, offset + 13, 1, "Flags: 0x%x", th.th_flags);
field_tree = proto_item_add_subtree(tf, ETT_TCP_FLAGS);
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_URG, sizeof (th.th_flags)*8,
"Urgent pointer", "No urgent pointer"));
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_ACK, sizeof (th.th_flags)*8,
"Acknowledgment", "No acknowledgment"));
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_PUSH, sizeof (th.th_flags)*8,
"Push", "No push"));
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_RST, sizeof (th.th_flags)*8,
"Reset", "No reset"));
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_SYN, sizeof (th.th_flags)*8,
"Syn", "No Syn"));
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
proto_tree_add_text(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_FIN, sizeof (th.th_flags)*8,
"Fin", "No Fin"));
proto_tree_add_item(tcp_tree, offset + 14, 2, "Window size: %u", th.th_win);
proto_tree_add_item(tcp_tree, offset + 16, 2, "Checksum: 0x%04x", th.th_sum);
proto_tree_add_text(tcp_tree, offset + 14, 2, "Window size: %u", th.th_win);
proto_tree_add_text(tcp_tree, offset + 16, 2, "Checksum: 0x%04x", th.th_sum);
if (th.th_flags & TH_URG)
proto_tree_add_item(tcp_tree, offset + 18, 2, "Urgent pointer: 0x%04x",
proto_tree_add_text(tcp_tree, offset + 18, 2, "Urgent pointer: 0x%04x",
th.th_urp);
}
@ -436,10 +433,9 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
/* There's more than just the fixed-length header. Decode the
options. */
optlen = hlen - sizeof (e_tcphdr); /* length of options, in bytes */
tf = proto_tree_add_item(tcp_tree, offset + 20, optlen,
tf = proto_tree_add_text(tcp_tree, offset + 20, optlen,
"Options: (%d bytes)", optlen);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_TCP_OPTIONS);
field_tree = proto_item_add_subtree(tf, ETT_TCP_OPTIONS);
dissect_ip_tcp_options(field_tree, &pd[offset + 20], offset + 20, optlen,
tcpopts, N_TCP_OPTS, TCPOPT_EOL);
}

View File

@ -2,7 +2,7 @@
* Routines for telnet packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-telnet.c,v 1.2 1999/04/05 23:39:51 guy Exp $
* $Id: packet-telnet.c,v 1.3 1999/07/07 22:51:55 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -139,18 +139,16 @@ void telnet_sub_option(proto_tree *telnet_tree, char *rr, int *i, int offset, in
subneg_len = i1 - *i + 2;
ti = proto_tree_add_item(telnet_tree, offset, subneg_len, "Suboption Begin: %s", opt);
ti = proto_tree_add_text(telnet_tree, offset, subneg_len, "Suboption Begin: %s", opt);
option_tree = proto_tree_new();
option_tree = proto_item_add_subtree(ti, ETT_TELNET_SUBOPT);
proto_item_add_subtree(ti, option_tree, ETT_TELNET_SUBOPT);
proto_tree_add_item(option_tree, offset + 2, subneg_len - 2, "%s %s", (req ? "Send your" : "Here's my"), opt);
proto_tree_add_text(option_tree, offset + 2, subneg_len - 2, "%s %s", (req ? "Send your" : "Here's my"), opt);
if (req == 0) { /* Add the value */
memcpy(sub_opt_data, rr + *i + 2, subneg_len - 2);
proto_tree_add_item(option_tree, offset + 4, subneg_len - 4, "Value: %s", format_text(sub_opt_data, subneg_len - 4));
proto_tree_add_text(option_tree, offset + 4, subneg_len - 4, "Value: %s", format_text(sub_opt_data, subneg_len - 4));
*i += subneg_len - 2;
}
@ -169,85 +167,85 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
case TN_EOF:
proto_tree_add_item(telnet_tree, offset, 2, "Command: End of File");
proto_tree_add_text(telnet_tree, offset, 2, "Command: End of File");
(*i)++;
break;
case TN_SUSP:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Suspend Current Process");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Suspend Current Process");
(*i)++;
break;
case TN_ABORT:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Abort Process");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Abort Process");
(*i)++;
break;
case TN_EOR:
proto_tree_add_item(telnet_tree, offset, 2, "Command: End of Record");
proto_tree_add_text(telnet_tree, offset, 2, "Command: End of Record");
(*i)++;
break;
case TN_SE:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Suboption End");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Suboption End");
(*i)++;
break;
case TN_NOP:
proto_tree_add_item(telnet_tree, offset, 2, "Command: No Operation");
proto_tree_add_text(telnet_tree, offset, 2, "Command: No Operation");
(*i)++;
break;
case TN_DM:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Data Mark");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Data Mark");
(*i)++;
break;
case TN_BRK:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Break");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Break");
(*i)++;
break;
case TN_IP:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Interrupt Process");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Interrupt Process");
(*i)++;
break;
case TN_AO:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Abort Output");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Abort Output");
(*i)++;
break;
case TN_AYT:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Are You There?");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Are You There?");
(*i)++;
break;
case TN_EC:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Escape Character");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Escape Character");
(*i)++;
break;
case TN_EL:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Erase Line");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Erase Line");
(*i)++;
break;
case TN_GA:
proto_tree_add_item(telnet_tree, offset, 2, "Command: Go Ahead");
proto_tree_add_text(telnet_tree, offset, 2, "Command: Go Ahead");
(*i)++;
break;
@ -264,7 +262,7 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
else
opt = options[(unsigned int)rr[*i + 1]];
proto_tree_add_item(telnet_tree, offset, 3, "Command: Will %s", opt);
proto_tree_add_text(telnet_tree, offset, 3, "Command: Will %s", opt);
*i += 2; /* skip two chars */
break;
@ -275,7 +273,7 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
else
opt = options[(unsigned int)rr[*i + 1]];
proto_tree_add_item(telnet_tree, offset, 3, "Command: Won't %s", opt);
proto_tree_add_text(telnet_tree, offset, 3, "Command: Won't %s", opt);
*i += 2; /* skip two chars */
break;
@ -286,7 +284,7 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
else
opt = options[(unsigned int)rr[*i + 1]];
proto_tree_add_item(telnet_tree, offset, 3, "Command: Do %s", opt);
proto_tree_add_text(telnet_tree, offset, 3, "Command: Do %s", opt);
*i += 2; /* skip two chars */
break;
@ -297,7 +295,7 @@ void telnet_command(proto_tree *telnet_tree, char *rr, int *i, int offset, int m
else
opt = options[(unsigned int)rr[*i + 1]];
proto_tree_add_item(telnet_tree, offset, 3, "Command: Don't %s", opt);
proto_tree_add_text(telnet_tree, offset, 3, "Command: Don't %s", opt);
*i += 2; /* skip two chars */
break;
@ -333,10 +331,9 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, i
memcpy(rr, pd + offset, max_data);
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Telnet Protocol");
telnet_tree = proto_tree_new();
proto_item_add_subtree(ti, telnet_tree, ETT_TELNET);
telnet_tree = proto_item_add_subtree(ti, ETT_TELNET);
i1 = i2 = i3 = 0;
@ -346,7 +343,7 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, i
if (strlen(data) > 0) {
proto_tree_add_item(telnet_tree, offset + i2, strlen(data), "Data: %s", format_text(data, strlen(data)));
proto_tree_add_text(telnet_tree, offset + i2, strlen(data), "Data: %s", format_text(data, strlen(data)));
memset(data, '\0', sizeof(data));
i3 = 0;
@ -369,7 +366,7 @@ dissect_telnet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, i
if (strlen(data) > 0) { /* Still some data to add */
proto_tree_add_item(telnet_tree, offset + i2, strlen(data), "Data: %s", format_text(data, strlen(data)));
proto_tree_add_text(telnet_tree, offset + i2, strlen(data), "Data: %s", format_text(data, strlen(data)));
}

View File

@ -3,7 +3,7 @@
*
* Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-tftp.c,v 1.3 1999/05/13 05:46:04 guy Exp $
* $Id: packet-tftp.c,v 1.4 1999/07/07 22:51:56 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -88,55 +88,54 @@ dissect_tftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
if (tree) {
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
ti = proto_tree_add_text(tree, offset, END_OF_FRAME,
"Trivial File Transfer Protocol");
tftp_tree = proto_tree_new();
proto_item_add_subtree(ti, tftp_tree, ETT_TFTP);
tftp_tree = proto_item_add_subtree(ti, ETT_TFTP);
switch (i1 = pntohs(pd+offset)) {
case RRQ:
proto_tree_add_item(tftp_tree, offset, 2, "Read Request");
proto_tree_add_text(tftp_tree, offset, 2, "Read Request");
offset += 2;
i1 = strlen(pd+offset);
proto_tree_add_item(tftp_tree, offset, i1+1, "Source File: %s", pd+offset);
proto_tree_add_text(tftp_tree, offset, i1+1, "Source File: %s", pd+offset);
offset += i1 + 1;
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Type: %s",pd+offset);
proto_tree_add_text(tftp_tree, offset, END_OF_FRAME, "Type: %s",pd+offset);
break;
case WRQ:
proto_tree_add_item(tftp_tree, offset, 2, "Write Request");
proto_tree_add_text(tftp_tree, offset, 2, "Write Request");
offset += 2;
i1 = strlen(pd+offset);
proto_tree_add_item(tftp_tree, offset, i1+1, "Destination File: %s", pd+offset);
proto_tree_add_text(tftp_tree, offset, i1+1, "Destination File: %s", pd+offset);
offset += i1 + 1;
proto_tree_add_item(tftp_tree, offset+2, END_OF_FRAME, "Type: %s",pd+offset);
proto_tree_add_text(tftp_tree, offset+2, END_OF_FRAME, "Type: %s",pd+offset);
break;
case DATA:
proto_tree_add_item(tftp_tree, offset, 2, "Data Packet");
proto_tree_add_text(tftp_tree, offset, 2, "Data Packet");
offset += 2;
i1 = pntohs(pd+offset);
proto_tree_add_item(tftp_tree, offset, 2, "Block = %u", i1);
proto_tree_add_text(tftp_tree, offset, 2, "Block = %u", i1);
offset += 2;
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME,
proto_tree_add_text(tftp_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
break;
case ACK:
proto_tree_add_item(tftp_tree, offset, 2, "Acknowledgement");
proto_tree_add_text(tftp_tree, offset, 2, "Acknowledgement");
offset += 2;
i1 = pntohs(pd+offset);
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Block = %u", i1);
proto_tree_add_text(tftp_tree, offset, END_OF_FRAME, "Block = %u", i1);
break;
case ERROR:
proto_tree_add_item(tftp_tree, offset, 2, "Error Code");
proto_tree_add_text(tftp_tree, offset, 2, "Error Code");
offset += 2;
i1 = pntohs(pd+offset);
proto_tree_add_item(tftp_tree, offset, 2, "Code = %s", tftp_errors[i1 % 8]);
proto_tree_add_text(tftp_tree, offset, 2, "Code = %s", tftp_errors[i1 % 8]);
offset += 2;
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Error Message: %s", pd + offset);
proto_tree_add_text(tftp_tree, offset, END_OF_FRAME, "Error Message: %s", pd + offset);
break;
default:
proto_tree_add_item(tftp_tree, offset, 2, "Unknown TFTP Request: %0X.", i1);
proto_tree_add_text(tftp_tree, offset, 2, "Unknown TFTP Request: %0X.", i1);
offset += 2;
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME,
proto_tree_add_text(tftp_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
break;
}

View File

@ -2,7 +2,7 @@
* Routines for Token-Ring packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-tr.c,v 1.14 1999/06/16 20:14:51 gram Exp $
* $Id: packet-tr.c,v 1.15 1999/07/07 22:51:56 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -36,36 +36,85 @@
#include <glib.h>
#include "packet.h"
#include "etypes.h"
int proto_tr = -1;
int hf_tr_dst = -1;
int hf_tr_src = -1;
int hf_tr_dst_vendor = -1;
int hf_tr_src_vendor = -1;
int hf_tr_sr = -1;
int hf_tr_ac = -1;
int hf_tr_priority = -1;
int hf_tr_frame = -1;
int hf_tr_monitor_cnt = -1;
int hf_tr_priority_reservation = -1;
int hf_tr_fc = -1;
int hf_tr_fc_type = -1;
int hf_tr_fc_pcf = -1;
int hf_tr_rif_bytes = -1;
int hf_tr_broadcast = -1;
int hf_tr_max_frame_size = -1;
int hf_tr_direction = -1;
int hf_tr_rif = -1;
int hf_tr_rif_ring = -1;
int hf_tr_rif_bridge = -1;
static const value_string ac_vals[] = {
{ 0, "Token" },
{ 0x10, "Frame" },
{ 0, NULL }
};
static const value_string pcf_vals[] = {
{ 0, "Normal buffer" },
{ 1, "Express buffer" },
{ 2, "Purge" },
{ 3, "Claim Token" },
{ 4, "Beacon" },
{ 5, "Active Monitor Present" },
{ 6, "Standby Monitor Present" },
{ 0, NULL },
};
static const value_string frame_vals[] = {
{ 0, "MAC" },
{ 64, "LLC" },
{ 128, "Reserved" },
{ 0, NULL },
};
static const value_string broadcast_vals[] = {
{ 0 << 5, "Non-broadcast" },
{ 1 << 5, "Non-broadcast" },
{ 2 << 5, "Non-broadcast" },
{ 3 << 5, "Non-broadcast" },
{ 4 << 5, "All-routes broadcast" },
{ 5 << 5, "All-routes broadcast" },
{ 6 << 5, "Single-route broadcast" },
{ 7 << 5, "Single-route broadcast" },
{ 0, NULL }
};
static const value_string max_frame_size_vals[] = {
{ 0, "516" },
{ 1, "1500" },
{ 2, "2052" },
{ 3, "4472" },
{ 4, "8144" },
{ 5, "11407" },
{ 6, "17800" },
{ 0, NULL }
};
static const value_string direction_vals[] = {
{ 0, "From originating station (-->)" },
{ 128, "To originating station (<--)" },
{ 0, NULL }
};
static void
add_ring_bridge_pairs(int rcf_len, const u_char *pd, proto_tree *tree);
static char*
sr_broadcast(u_char val) {
if (val < 4) {
return "Non-broadcast";
}
else if (val < 6) {
return "All-routes broadcast";
}
else {
return "Single-route broadcast";
}
}
static int
sr_frame(u_char val) {
int rc_frame[7] = { 516, 1500, 2052, 4472, 8144, 11407, 17800 };
if (val > 6) {
return -1;
}
else return rc_frame[val];
}
void
capture_tr(const u_char *pd, guint32 cap_len, packet_counts *ld) {
@ -115,10 +164,6 @@ capture_tr(const u_char *pd, guint32 cap_len, packet_counts *ld) {
source_routed = 1;
}
/* else {
printf("0e+%d = %02X 0f+%d = %02X\n", trn_rif_bytes, pd[0x0e + trn_rif_bytes],
trn_rif_bytes, pd[0x0f + trn_rif_bytes]);
} */
}
@ -163,7 +208,7 @@ capture_tr(const u_char *pd, guint32 cap_len, packet_counts *ld) {
void
dissect_tr(const u_char *pd, frame_data *fd, proto_tree *tree) {
proto_tree *fh_tree, *bf_tree;
proto_tree *tr_tree, *bf_tree;
proto_item *ti;
int offset = 14;
@ -184,35 +229,9 @@ dissect_tr(const u_char *pd, frame_data *fd, proto_tree *tree) {
guint8 trn_shost_nonsr[6];
static const value_string ac_vals[] = {
{ 0, "Token" },
{ 0x10, "Frame" },
{ 0, NULL }
};
static const value_string pcf_vals[] = {
{ 0, "Normal buffer" },
{ 1, "Express buffer" },
{ 2, "Purge" },
{ 3, "Claim Token" },
{ 4, "Beacon" },
{ 5, "Active Monitor Present" },
{ 6, "Standby Monitor Present" },
{ 0, NULL },
};
static const value_string frame_vals[] = {
{ 0, "MAC" },
{ 64, "LLC" },
{ 128, "Reserved" },
{ 0, NULL },
};
/* Token-Ring Strings */
char *fc[] = { "MAC", "LLC", "Reserved", "Unknown" };
char *rc_arrow[] = { "-->", "<--" };
char *rc_direction[] = { "From originating station",
"To originating station" };
/* get the data */
memcpy(&trn_ac, &pd[0], sizeof(guint8));
@ -296,60 +315,61 @@ dissect_tr(const u_char *pd, frame_data *fd, proto_tree *tree) {
/* protocol analysis tree */
if (tree) {
ti = proto_tree_add_item(tree, 0, 14 + actual_rif_bytes, "Token-Ring");
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_TOKEN_RING);
/* Create Token-Ring Tree */
ti = proto_tree_add_item(tree, proto_tr, 0, 14 + actual_rif_bytes, NULL);
tr_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING);
ti = proto_tree_add_item(fh_tree, 0, 1, "Access Control (0x%02x)", trn_ac);
bf_tree = proto_tree_new();
proto_item_add_subtree(ti, bf_tree, ETT_TOKEN_RING_AC);
/* Create the Access Control bitfield tree */
ti = proto_tree_add_item_format(tr_tree, hf_tr_ac, 0, 1, trn_ac,
"Access Control (0x%02x)", trn_ac);
bf_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING_AC);
proto_tree_add_item(bf_tree, 0, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_priority, 0, 1, trn_ac & 0xe0,
decode_numeric_bitfield(trn_ac, 0xe0, 8, "Priority = %d"));
proto_tree_add_item(bf_tree, 0, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_frame, 0, 1, trn_ac & 0x10,
decode_enumerated_bitfield(trn_ac, 0x10, 8, ac_vals, "%s"));
proto_tree_add_item(bf_tree, 0, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_monitor_cnt, 0, 1, trn_ac & 0x08,
decode_numeric_bitfield(trn_ac, 0x08, 8, "Monitor Count"));
proto_tree_add_item(bf_tree, 0, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_priority_reservation, 0, 1, trn_ac & 0x07,
decode_numeric_bitfield(trn_ac, 0x07, 8, "Priority Reservation = %d"));
/* Create the Frame Control bitfield tree */
ti = proto_tree_add_item_format(tr_tree, hf_tr_fc, 1, 1, trn_fc,
"Frame Control (0x%02x)", trn_fc);
bf_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING_FC);
ti = proto_tree_add_item(fh_tree, 1, 1, "Frame Control (0x%02x)", trn_fc);
bf_tree = proto_tree_new();
proto_item_add_subtree(ti, bf_tree, ETT_TOKEN_RING_FC);
proto_tree_add_item(bf_tree, 1, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_fc_type, 1, 1, trn_fc & 0xc0,
decode_enumerated_bitfield(trn_fc, 0xc0, 8, frame_vals, "%s"));
proto_tree_add_item(bf_tree, 1, 1, "%s",
proto_tree_add_item_format(bf_tree, hf_tr_fc_pcf, 1, 1, trn_fc & 0x0f,
decode_enumerated_bitfield(trn_fc, 0x0f, 8, pcf_vals, "%s"));
proto_tree_add_item(fh_tree, 2, 6, "Destination: %s",
ether_to_str((guint8 *) trn_dhost));
proto_tree_add_item(fh_tree, 8, 6, "Source: %s",
ether_to_str((guint8 *) trn_shost));
proto_tree_add_item(tr_tree, hf_tr_dst, 2, 6, trn_dhost);
proto_tree_add_item_hidden(tr_tree, hf_tr_dst_vendor, 2, 3, trn_dhost);
proto_tree_add_item(tr_tree, hf_tr_src, 8, 6, trn_shost);
proto_tree_add_item_hidden(tr_tree, hf_tr_src_vendor, 8, 3, trn_shost);
proto_tree_add_item_hidden(tr_tree, hf_tr_sr, 8, 1, source_routed);
/* non-source-routed version of src addr */
proto_tree_add_item_hidden(tr_tree, hf_tr_src, 8, 6, trn_shost_nonsr);
proto_tree_add_item_hidden(tr_tree, hf_tr_src_vendor, 8, 3, trn_shost_nonsr);
if (source_routed) {
proto_tree_add_item(fh_tree, 14, 1, "RIF length: %d bytes", trn_rif_bytes);
/* RCF Byte 1 */
proto_tree_add_item(tr_tree, hf_tr_rif_bytes, 14, 1, trn_rif_bytes);
proto_tree_add_item(tr_tree, hf_tr_broadcast, 14, 1, pd[14] & 224);
proto_tree_add_item(fh_tree, 15, 1,
"%s, up to %d bytes in frame (LF=%d)",
sr_broadcast((pd[14] & 224) >> 5),
sr_frame((pd[15] & 112) >> 4),
(pd[15] & 112) >> 4);
proto_tree_add_item(fh_tree, 15, 1,
"Direction: %s (%s)",
rc_direction[(pd[15] & 128) >> 7],
rc_arrow[(pd[15] & 128) >> 7]);
/* RCF Byte 2 */
proto_tree_add_item(tr_tree, hf_tr_max_frame_size, 15, 1, pd[15] & 112);
proto_tree_add_item(tr_tree, hf_tr_direction, 15, 1, pd[15] & 128);
/* if we have more than 2 bytes of RIF, then we have
ring/bridge pairs */
if (trn_rif_bytes > 2) {
add_ring_bridge_pairs(trn_rif_bytes, pd, fh_tree);
add_ring_bridge_pairs(trn_rif_bytes, pd, tr_tree);
}
}
@ -363,24 +383,11 @@ dissect_tr(const u_char *pd, frame_data *fd, proto_tree *tree) {
tcpdump. W/o that, however, I'm guessing that DSAP == SSAP if the
frame type is LLC. It's very much a hack. -- Gilbert Ramirez */
if (actual_rif_bytes > trn_rif_bytes) {
/*printf("trn_rif %d actual_rif %d\n", trn_rif_bytes, actual_rif_bytes);*/
proto_tree_add_item(fh_tree, 14 + trn_rif_bytes, actual_rif_bytes - trn_rif_bytes,
proto_tree_add_text(tr_tree, 14 + trn_rif_bytes, actual_rif_bytes - trn_rif_bytes,
"Empty RIF from Linux 2.0.x driver. The sniffing NIC "
"is also running a protocol stack.");
}
/*
if (source_routed && (trn_rif_bytes == 2) && silly_linux) {
proto_tree_add_item(fh_tree, 14 + trn_rif_bytes, 18 - actual_rif_bytes,
"Empty RIF from Linux 2.0.x driver. The sniffing NIC "
"is also running a protocol stack.");
}
else if ((!source_routed) && silly_linux ) {
proto_tree_add_item(fh_tree, 14, 18,
"Empty RIF from Linux 2.0.x driver. The sniffing NIC "
"is also running a protocol stack.");
}*/
}
/* The package is either MAC or LLC */
switch (frame_type) {
/* MAC */
@ -416,17 +423,46 @@ add_ring_bridge_pairs(int rcf_len, const u_char *pd, proto_tree *tree)
if (j==1) {
segment=pntohs(&pd[16]) >> 4;
size = sprintf(buffer, "%03X",segment);
proto_tree_add_item_hidden(tree, hf_tr_rif_ring, 16, 2, segment);
buff_offset += size;
}
segment=pntohs(&pd[17+j]) >> 4;
brdgnmb=pd[16+j] & 0x0f;
size = sprintf(buffer+buff_offset, "-%01X-%03X",brdgnmb,segment);
proto_tree_add_item_hidden(tree, hf_tr_rif_ring, 17+j, 2, segment);
proto_tree_add_item_hidden(tree, hf_tr_rif_bridge, 16+j, 1, brdgnmb);
buff_offset += size;
}
proto_tree_add_item(tree, 16, rcf_len << 1,
"Ring-Bridge Pairs: %s",
buffer);
proto_tree_add_item(tree, hf_tr_rif, 16, rcf_len << 1, buffer);
}
void
proto_register_tr(void)
{
const hf_register_info hf[] = {
{ "Access Control", "tr.ac", &hf_tr_ac, FT_UINT8, NULL },
{ "Priority", "tr.priority", &hf_tr_priority, FT_UINT8, NULL },
{ "Frame", "tr.frame", &hf_tr_frame, FT_VALS_UINT8, VALS(ac_vals) },
{ "Monitor Count", "tr.monitor_cnt", &hf_tr_monitor_cnt, FT_UINT8, NULL },
{ "Priority Reservation","tr.priority_reservation", &hf_tr_priority_reservation, FT_UINT8, NULL },
{ "Frame Control", "tr.fc", &hf_tr_fc, FT_UINT8, NULL },
{ "Frame Type", "tr.frame_type", &hf_tr_fc_type, FT_VALS_UINT8, VALS(frame_vals) },
{ "Frame PCF", "tr.frame_pcf", &hf_tr_fc_pcf, FT_VALS_UINT8, VALS(pcf_vals) },
{ "Destination", "tr.dst", &hf_tr_dst, FT_ETHER, NULL },
{ "Source", "tr.src", &hf_tr_src, FT_ETHER, NULL },
{ "Destination Hardware Vendor", "tr.dst_vendor", &hf_tr_dst_vendor, FT_ETHER_VENDOR, NULL },
{ "Source Hardware Vendor", "tr.src_vendor", &hf_tr_src_vendor, FT_ETHER_VENDOR, NULL },
{ "Source Routed", "tr.sr", &hf_tr_sr, FT_BOOLEAN, NULL },
{ "RIF Bytes", "tr.rif_bytes", &hf_tr_rif_bytes, FT_UINT8, NULL },
{ "Broadcast Type", "tr.broadcast", &hf_tr_broadcast, FT_VALS_UINT8, VALS(broadcast_vals) },
{ "Maximum Frame Size", "tr.max_frame_size", &hf_tr_max_frame_size, FT_VALS_UINT8, VALS(max_frame_size_vals) },
{ "Direction", "tr.direction", &hf_tr_direction, FT_VALS_UINT8, VALS(direction_vals) },
{ "Ring-Bridge Pairs", "tr.rif", &hf_tr_rif, FT_STRING, NULL },
{ "RIF Ring", "tr.rif_ring", &hf_tr_rif_ring, FT_UINT16, NULL },
{ "RIF Bridge", "tr.rif_bridge", &hf_tr_rif_bridge, FT_UINT8, NULL },
};
proto_tr = proto_register_protocol("Token-Ring", "tr");
proto_register_field_array(proto_tr, hf, array_length(hf));
}

View File

@ -2,7 +2,7 @@
* Routines for Token-Ring Media Access Control
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-trmac.c,v 1.11 1999/03/23 03:14:44 gram Exp $
* $Id: packet-trmac.c,v 1.12 1999/07/07 22:51:56 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -81,161 +81,159 @@ sv_text(const u_char *pd, int pkt_offset, proto_tree *tree)
u_char errors[6]; /* isolating or non-isolating */
/* this just adds to the clutter on the screen...
proto_tree_add_item(tree, pkt_offset, 1,
proto_tree_add_text(tree, pkt_offset, 1,
"Subvector Length: %d bytes", sv_length);*/
switch(pd[1]) {
case 0x01: /* Beacon Type */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Beacon Type: %s", beacon[ pntohs( &pd[2] ) ] );
break;
case 0x02: /* NAUN */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"NAUN: %s", ether_to_str((guint8*)&pd[2]));
break;
case 0x03: /* Local Ring Number */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Local Ring Number: 0x%04X (%d)",
pntohs( &pd[2] ), pntohs( &pd[2] ));
break;
case 0x04: /* Assign Physical Location */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Assign Physical Location: 0x%08X", pntohl( &pd[2] ) );
break;
case 0x05: /* Soft Error Report Value */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Soft Error Report Value: %d ms", 10 * pntohs( &pd[2] ) );
break;
case 0x06: /* Enabled Function Classes */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Enabled Function Classes: %04X", pntohs( &pd[2] ) );
break;
case 0x07: /* Allowed Access Priority */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Allowed Access Priority: %04X", pntohs( &pd[2] ) );
break;
case 0x09: /* Correlator */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Correlator: %04X", pntohs( &pd[2] ) );
break;
case 0x0A: /* Address of last neighbor notification */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Address of Last Neighbor Notification: %s",
ether_to_str((guint8*)&pd[2]));
break;
case 0x0B: /* Physical Location */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Physical Location: 0x%08X", pntohl( &pd[2] ) );
break;
case 0x20: /* Response Code */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Response Code: 0x%04X 0x%04X", pntohl( &pd[2] ),
pntohl( &pd[4] ) );
break;
case 0x21: /* Reserved */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Reserved: 0x%04X", pntohs( &pd[2] ) );
break;
case 0x22: /* Product Instance ID */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Product Instance ID: ...");
break;
case 0x23: /* Ring Station Microcode Level */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Ring Station Microcode Level: ...");
break;
case 0x26: /* Wrap data */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Wrap Data: ... (%d bytes)", sv_length - 2);
break;
case 0x27: /* Frame Forward */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Frame Forward: ... (%d bytes)", sv_length - 2);
break;
case 0x29: /* Ring Station Status Subvector */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Ring Station Status Subvector: ...");
break;
case 0x2A: /* Transmit Status Code */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Transmit Status Code: %04X", pntohs( &pd[2] ) );
break;
case 0x2B: /* Group Address */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Group Address: %08X", pntohl( &pd[2] ) );
break;
case 0x2C: /* Functional Address */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Functional Address: %08X", pntohl( &pd[2] ) );
break;
case 0x2D: /* Isolating Error Counts */
memcpy(errors, &pd[2], 6);
ti = proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
ti = proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Isolating Error Counts (%d total)",
errors[0] + errors[1] + errors[2] + errors[3] + errors[4]);
sv_tree = proto_tree_new();
proto_item_add_subtree(ti, sv_tree, ETT_TR_IERR_CNT);
sv_tree = proto_item_add_subtree(ti, ETT_TR_IERR_CNT);
proto_tree_add_item(sv_tree, pkt_offset+2, 1,
proto_tree_add_text(sv_tree, pkt_offset+2, 1,
"Line Errors: %d", errors[0]);
proto_tree_add_item(sv_tree, pkt_offset+3, 1,
proto_tree_add_text(sv_tree, pkt_offset+3, 1,
"Internal Errors: %d", errors[1]);
proto_tree_add_item(sv_tree, pkt_offset+4, 1,
proto_tree_add_text(sv_tree, pkt_offset+4, 1,
"Burst Errors: %d", errors[2]);
proto_tree_add_item(sv_tree, pkt_offset+5, 1,
proto_tree_add_text(sv_tree, pkt_offset+5, 1,
"A/C Errors: %d", errors[3]);
proto_tree_add_item(sv_tree, pkt_offset+6, 1,
proto_tree_add_text(sv_tree, pkt_offset+6, 1,
"Abort delimiter transmitted: %d", errors[4]);
break;
case 0x2E: /* Non-Isolating Error Counts */
memcpy(errors, &pd[2], 6);
ti = proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
ti = proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Non-Isolating Error Counts (%d total)",
errors[0] + errors[1] + errors[2] + errors[3] + errors[4]);
sv_tree = proto_tree_new();
proto_item_add_subtree(ti, sv_tree, ETT_TR_NERR_CNT);
sv_tree = proto_item_add_subtree(ti, ETT_TR_NERR_CNT);
proto_tree_add_item(sv_tree, pkt_offset+2, 1,
proto_tree_add_text(sv_tree, pkt_offset+2, 1,
"Lost Frame Errors: %d", errors[0]);
proto_tree_add_item(sv_tree, pkt_offset+3, 1,
proto_tree_add_text(sv_tree, pkt_offset+3, 1,
"Receiver Congestion: %d", errors[1]);
proto_tree_add_item(sv_tree, pkt_offset+4, 1,
proto_tree_add_text(sv_tree, pkt_offset+4, 1,
"Frame-Copied Congestion: %d", errors[2]);
proto_tree_add_item(sv_tree, pkt_offset+5, 1,
proto_tree_add_text(sv_tree, pkt_offset+5, 1,
"Frequency Errors: %d", errors[3]);
proto_tree_add_item(sv_tree, pkt_offset+6, 1,
proto_tree_add_text(sv_tree, pkt_offset+6, 1,
"Token Errors: %d", errors[4]);
break;
case 0x30: /* Error Code */
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
proto_tree_add_text(tree, pkt_offset+1, sv_length-1,
"Error Code: %04X", pntohs( &pd[2] ) );
break;
default: /* Unknown */
proto_tree_add_item(tree, pkt_offset+1, 1,
proto_tree_add_text(tree, pkt_offset+1, 1,
"Unknown Sub-Vector: 0x%02X", pd[1]);
}
return sv_length;
@ -255,10 +253,9 @@ dissect_trmac(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
mv_length = pntohs(&pd[offset]);
if (tree) {
ti = proto_tree_add_item(tree, offset, mv_length,
ti = proto_tree_add_text(tree, offset, mv_length,
"Media Access Control");
mac_tree = proto_tree_new();
proto_item_add_subtree(ti, mac_tree, ETT_TR_MAC);
mac_tree = proto_item_add_subtree(ti, ETT_TR_MAC);
}
/* Interpret the major vector */
@ -272,16 +269,16 @@ dissect_trmac(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (tree) {
if (mv_text)
proto_tree_add_item(mac_tree, offset+3, 1, "Major Vector Command: %s",
proto_tree_add_text(mac_tree, offset+3, 1, "Major Vector Command: %s",
mv_text);
else
proto_tree_add_item(mac_tree, offset+3, 1, "Major Vector Command: %02X (Unknown)",
proto_tree_add_text(mac_tree, offset+3, 1, "Major Vector Command: %02X (Unknown)",
pd[offset+3]);
proto_tree_add_item(mac_tree, offset, 2, "Total Length: %d bytes",
proto_tree_add_text(mac_tree, offset, 2, "Total Length: %d bytes",
mv_length);
proto_tree_add_item(mac_tree, offset+2, 1, "Source Class: %s",
proto_tree_add_text(mac_tree, offset+2, 1, "Source Class: %s",
class[ pd[offset+2] & 0x0f ]);
proto_tree_add_item(mac_tree, offset+2, 1, "Destination Class: %s",
proto_tree_add_text(mac_tree, offset+2, 1, "Destination Class: %s",
class[ pd[offset+2] >> 4 ]);
/* interpret the subvectors */

View File

@ -1,7 +1,7 @@
/* packet-udp.c
* Routines for UDP packet disassembly
*
* $Id: packet-udp.c,v 1.18 1999/06/25 07:15:02 guy Exp $
* $Id: packet-udp.c,v 1.19 1999/07/07 22:51:57 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -191,15 +191,14 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_fstr(fd, COL_UNRES_DST_PORT, "%u", uh_dport);
if (tree) {
ti = proto_tree_add_item(tree, offset, 8, "User Datagram Protocol");
udp_tree = proto_tree_new();
proto_item_add_subtree(ti, udp_tree, ETT_UDP);
proto_tree_add_item(udp_tree, offset, 2, "Source port: %s (%u)",
ti = proto_tree_add_text(tree, offset, 8, "User Datagram Protocol");
udp_tree = proto_item_add_subtree(ti, ETT_UDP);
proto_tree_add_text(udp_tree, offset, 2, "Source port: %s (%u)",
get_udp_port(uh_sport), uh_sport);
proto_tree_add_item(udp_tree, offset + 2, 2, "Destination port: %s (%u)",
proto_tree_add_text(udp_tree, offset + 2, 2, "Destination port: %s (%u)",
get_udp_port(uh_dport), uh_dport);
proto_tree_add_item(udp_tree, offset + 4, 2, "Length: %u", uh_ulen);
proto_tree_add_item(udp_tree, offset + 6, 2, "Checksum: 0x%04x", uh_sum);
proto_tree_add_text(udp_tree, offset + 4, 2, "Length: %u", uh_ulen);
proto_tree_add_text(udp_tree, offset + 6, 2, "Checksum: 0x%04x", uh_sum);
}
/* Skip over header */

View File

@ -1,7 +1,7 @@
/* packet-vines.c
* Routines for Banyan VINES protocol packet disassembly
*
* $Id: packet-vines.c,v 1.6 1999/03/23 03:14:45 gram Exp $
* $Id: packet-vines.c,v 1.7 1999/07/07 22:51:57 gram Exp $
*
* Don Lafontaine <lafont02@cn.ca>
*
@ -84,11 +84,10 @@ dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
}
if (tree) {
ti = proto_tree_add_item(tree, offset, 2, "Vines Fragmentation Protocol");
vines_frp_tree = proto_tree_new();
proto_item_add_subtree(ti, vines_frp_tree, ETT_VINES_FRP);
proto_tree_add_item(vines_frp_tree, offset, 1, "Control Flags: 0x%02x = %s fragment", vines_frp_ctrl, frp_flags_str);
proto_tree_add_item(vines_frp_tree, offset + 1, 1, "Sequence Number: 0x%02x", vines_frp_seqno);
ti = proto_tree_add_text(tree, offset, 2, "Vines Fragmentation Protocol");
vines_frp_tree = proto_item_add_subtree(ti, ETT_VINES_FRP);
proto_tree_add_text(vines_frp_tree, offset, 1, "Control Flags: 0x%02x = %s fragment", vines_frp_ctrl, frp_flags_str);
proto_tree_add_text(vines_frp_tree, offset + 1, 1, "Sequence Number: 0x%02x", vines_frp_seqno);
}
/* Skip over header */
@ -195,14 +194,13 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
*/
if (tree)
{
ti = proto_tree_add_item(tree, offset, (viph.vip_pktlen), "Vines IP");
vip_tree = proto_tree_new();
proto_item_add_subtree(ti, vip_tree, ETT_VINES);
proto_tree_add_item(vip_tree, offset, 2, "Packet checksum: 0x%04x", viph.vip_chksum);
proto_tree_add_item(vip_tree, offset + 2, 2, "Packet length: 0x%04x (%d)", viph.vip_pktlen, viph.vip_pktlen);
proto_tree_add_item(vip_tree, offset + 4, 1, "Transport control: 0x%02x",
ti = proto_tree_add_text(tree, offset, (viph.vip_pktlen), "Vines IP");
vip_tree = proto_item_add_subtree(ti, ETT_VINES);
proto_tree_add_text(vip_tree, offset, 2, "Packet checksum: 0x%04x", viph.vip_chksum);
proto_tree_add_text(vip_tree, offset + 2, 2, "Packet length: 0x%04x (%d)", viph.vip_pktlen, viph.vip_pktlen);
proto_tree_add_text(vip_tree, offset + 4, 1, "Transport control: 0x%02x",
viph.vip_tctl);
proto_tree_add_item(vip_tree, offset + 5, 1, "Protocol: 0x%02x", viph.vip_proto);
proto_tree_add_text(vip_tree, offset + 5, 1, "Protocol: 0x%02x", viph.vip_proto);
}
@ -283,18 +281,17 @@ void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree
*/
if (tree)
{
ti = proto_tree_add_item(tree, offset, sizeof(viph), "Vines SPP");
vspp_tree = proto_tree_new();
proto_item_add_subtree(ti, vspp_tree, ETT_VINES_SPP);
proto_tree_add_item(vspp_tree, offset, 2, "Source port: 0x%04x", viph.vspp_sport);
proto_tree_add_item(vspp_tree, offset+2, 2, "Destination port: 0x%04x", viph.vspp_dport);
proto_tree_add_item(vspp_tree, offset+4, 1, "Packet type: 0x%02x", viph.vspp_pkttype);
proto_tree_add_item(vspp_tree, offset+5, 1, "Control: 0x%02x", viph.vspp_control);
proto_tree_add_item(vspp_tree, offset+6, 2, "Local Connection ID: 0x%04x", viph.vspp_lclid);
proto_tree_add_item(vspp_tree, offset+8, 2, "Remote Connection ID: 0x%04x", viph.vspp_rmtid);
proto_tree_add_item(vspp_tree, offset+10, 2, "Sequence number: 0x%04x", viph.vspp_seqno);
proto_tree_add_item(vspp_tree, offset+12, 2, "Ack number: 0x%04x", viph.vspp_ack);
proto_tree_add_item(vspp_tree, offset+14, 2, "Window: 0x%04x", viph.vspp_win);
ti = proto_tree_add_text(tree, offset, sizeof(viph), "Vines SPP");
vspp_tree = proto_item_add_subtree(ti, ETT_VINES_SPP);
proto_tree_add_text(vspp_tree, offset, 2, "Source port: 0x%04x", viph.vspp_sport);
proto_tree_add_text(vspp_tree, offset+2, 2, "Destination port: 0x%04x", viph.vspp_dport);
proto_tree_add_text(vspp_tree, offset+4, 1, "Packet type: 0x%02x", viph.vspp_pkttype);
proto_tree_add_text(vspp_tree, offset+5, 1, "Control: 0x%02x", viph.vspp_control);
proto_tree_add_text(vspp_tree, offset+6, 2, "Local Connection ID: 0x%04x", viph.vspp_lclid);
proto_tree_add_text(vspp_tree, offset+8, 2, "Remote Connection ID: 0x%04x", viph.vspp_rmtid);
proto_tree_add_text(vspp_tree, offset+10, 2, "Sequence number: 0x%04x", viph.vspp_seqno);
proto_tree_add_text(vspp_tree, offset+12, 2, "Ack number: 0x%04x", viph.vspp_ack);
proto_tree_add_text(vspp_tree, offset+14, 2, "Window: 0x%04x", viph.vspp_win);
}
}

161
packet.c
View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.28 1999/06/22 03:39:06 guy Exp $
* $Id: packet.c,v 1.29 1999/07/07 22:51:57 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -54,6 +54,11 @@
extern capture_file cf;
int proto_frame = -1;
int hf_frame_arrival_time = -1;
int hf_frame_packet_len = -1;
int hf_frame_capture_len = -1;
gchar *
ether_to_str(const guint8 *ad) {
static gchar str[3][18];
@ -176,6 +181,50 @@ bytes_to_str(const guint8 *bd, int bd_len) {
return cur;
}
static const char *mon_names[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
gchar *
abs_time_to_str(struct timeval *abs_time)
{
struct tm *tmp;
static gchar *cur;
static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+4+1 + 5 /* extra */];
if (cur == &str[0][0]) {
cur = &str[1][0];
} else if (cur == &str[1][0]) {
cur = &str[2][0];
} else {
cur = &str[0][0];
}
tmp = localtime(&abs_time->tv_sec);
sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%04ld",
mon_names[tmp->tm_mon],
tmp->tm_mday,
tmp->tm_year + 1900,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)abs_time->tv_usec/100);
return cur;
}
/*
* Given a pointer into a data buffer, and to the end of the buffer,
* find the end of the (putative) line at that position in the data
@ -396,7 +445,7 @@ match_strval(guint32 val, const value_string *vs) {
return(vs[i].strptr);
i++;
}
return(NULL);
}
@ -485,7 +534,7 @@ decode_numeric_bitfield(guint32 val, guint32 mask, int width,
gint
check_col(frame_data *fd, gint el) {
int i;
if (fd->cinfo) {
for (i = 0; i < fd->cinfo->num_cols; i++) {
if (fd->cinfo->fmt_matx[i][el])
@ -568,29 +617,13 @@ col_add_str(frame_data *fd, gint el, const gchar* str) {
}
}
static const char *mon_names[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
/* this routine checks the frame type from the cf structure */
void
dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
{
proto_tree *fh_tree;
proto_item *ti;
struct tm *tmp;
time_t then;
struct timeval tv;
/* Put in frame header information. */
if (check_col(fd, COL_CLS_TIME))
@ -603,31 +636,26 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
col_add_delta_time(fd, COL_DELTA_TIME);
if (tree) {
ti = proto_tree_add_item(tree, 0, fd->cap_len,
"Frame (%d on wire, %d captured)",
fd->pkt_len, fd->cap_len);
ti = proto_tree_add_item_format(tree, proto_frame, 0, fd->cap_len,
NULL, "Frame (%d on wire, %d captured)", fd->pkt_len, fd->cap_len);
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_FRAME);
then = fd->abs_secs;
tmp = localtime(&then);
proto_tree_add_item(fh_tree, 0, 0,
"Frame arrived on %s %2d, %d %02d:%02d:%02d.%04ld",
mon_names[tmp->tm_mon],
tmp->tm_mday,
tmp->tm_year + 1900,
tmp->tm_hour,
tmp->tm_min,
tmp->tm_sec,
(long)fd->abs_usecs/100);
fh_tree = proto_item_add_subtree(ti, ETT_FRAME);
proto_tree_add_item(fh_tree, 0, 0, "Total frame length: %d bytes",
fd->pkt_len);
proto_tree_add_item(fh_tree, 0, 0, "Capture frame length: %d bytes",
fd->cap_len);
tv.tv_sec = fd->abs_secs;
tv.tv_usec = fd->abs_usecs;
proto_tree_add_item(fh_tree, hf_frame_arrival_time,
0, 0, &tv);
proto_tree_add_item_format(fh_tree, hf_frame_packet_len,
0, 0, fd->pkt_len, "Packet Length: %d byte%s", fd->pkt_len,
plurality(fd->pkt_len, "", "s"));
proto_tree_add_item_format(fh_tree, hf_frame_capture_len,
0, 0, fd->cap_len, "Capture Length: %d byte%s", fd->cap_len,
plurality(fd->cap_len, "", "s"));
}
#ifdef WITH_WIRETAP
switch (fd->lnk_t) {
case WTAP_ENCAP_ETHERNET :
dissect_eth(pd, fd, tree);
@ -648,26 +676,33 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
dissect_raw(pd, fd, tree);
break;
}
#else
switch (cf.lnk_t) {
case DLT_EN10MB :
dissect_eth(pd, fd, tree);
break;
case DLT_FDDI :
dissect_fddi(pd, fd, tree);
break;
case DLT_IEEE802 :
dissect_tr(pd, fd, tree);
break;
case DLT_NULL :
dissect_null(pd, fd, tree);
break;
case DLT_PPP :
dissect_ppp(pd, fd, tree);
break;
case DLT_RAW :
dissect_raw(pd, fd, tree);
break;
}
#endif
}
void
proto_register_frame(void)
{
proto_frame = proto_register_protocol (
/* name */ "Frame",
/* abbrev */ "frame");
hf_frame_arrival_time = proto_register_field (
/* name */ "Arrival Time",
/* abbrev */ "frame.time",
/* ftype */ FT_ABSOLUTE_TIME,
/* parent */ proto_frame,
/* vals[] */ NULL );
hf_frame_packet_len = proto_register_field(
/* name */ "Total Frame Length",
/* abbrev */ "frame.frame_len",
/* ftype */ FT_UINT32,
/* parent */ proto_frame,
/* vals[] */ NULL );
hf_frame_capture_len = proto_register_field(
/* name */ "Capture Frame Length",
/* abbrev */ "frame.cap_len",
/* ftype */ FT_UINT32,
/* parent */ proto_frame,
/* vals[] */ NULL );
}

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.64 1999/07/07 00:34:58 guy Exp $
* $Id: packet.h,v 1.65 1999/07/07 22:51:58 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,6 +27,10 @@
#ifndef __PACKET_H__
#define __PACKET_H__
#ifndef __PROTO_H__
#include "proto.h"
#endif
/* Pointer versions of ntohs and ntohl. Given a pointer to a member of a
* byte array, returns the value of the two or four bytes at the pointer.
* The pletoh[sl] versions return the little-endian representation.
@ -65,12 +69,18 @@
#endif
#endif
/* Useful when you have an array whose size you can tell at compile-time */
#define array_length(x) (sizeof x / sizeof x[0])
/* Useful when highlighting regions inside a dissect_*() function. With this
* macro, you can highlight from an arbitrary offset to the end of the
* frame. See dissect_data() for an example.
*/
#define END_OF_FRAME (fd->cap_len - offset)
/* To pass one of two strings, singular or plural */
#define plurality(d,s,p) ((d) == 1 ? (s) : (p))
typedef struct _column_info {
gint num_cols; /* Number of columns */
@ -102,9 +112,8 @@ typedef struct _frame_data {
guint32 del_usecs; /* Delta microseconds */
long file_off; /* File offset */
column_info *cinfo; /* Column formatting information */
#ifdef WITH_WIRETAP
int lnk_t; /* Per-packet encapsulation/data-link type */
#endif
int lnk_t; /* Per-packet encapsulation/data-link type */
gboolean passed_dfilter; /* TRUE = display, FALSE = no display */
} frame_data;
typedef struct _packet_info {
@ -140,6 +149,7 @@ typedef struct tcp_extra_data {
add_subtree() call. */
enum {
ETT_NONE,
ETT_FRAME,
ETT_IEEE8023,
ETT_ETHER2,
@ -298,6 +308,7 @@ enum {
/* Utility routines used by packet*.c */
gchar* ether_to_str(const guint8 *);
gchar* ip_to_str(const guint8 *);
gchar* abs_time_to_str(struct timeval*);
gchar* time_secs_to_str(guint32);
gchar* bytes_to_str(const guint8 *, int);
const u_char *find_line_end(const u_char *data, const u_char *dataend,
@ -327,25 +338,6 @@ void col_append_fstr(frame_data *, gint, gchar *, ...);
void col_add_str(frame_data *, gint, const gchar *);
void col_append_str(frame_data *, gint, gchar *);
/* Routines in packet.c */
typedef struct GtkWidget proto_tree;
typedef struct GtkWidget proto_item;
struct GtkWidget;
void proto_item_set_len(proto_item *ti, gint len);
proto_tree* proto_tree_new(void);
void proto_item_add_subtree(proto_item *ti, proto_tree *subtree, gint idx);
#if __GNUC__ == 2
proto_item* proto_tree_add_item(proto_tree *tree, gint start, gint len,
gchar *format, ...)
__attribute__((format (printf, 4, 5)));
#else
proto_item* proto_tree_add_item(proto_tree *tree, gint start, gint len,
gchar *format, ...);
#endif
void dissect_packet(const u_char *, frame_data *, proto_tree *);
/*
@ -448,12 +440,12 @@ void dissect_gre(const u_char *, int, frame_data *, proto_tree *);
void init_dissect_udp(void);
/* These functions are in ethertype.c */
gchar *ethertype_to_str(guint16 etype, const char *fmt);
void capture_ethertype(guint16 etype, int offset,
const u_char *pd, guint32 cap_len, packet_counts *ld);
void ethertype(guint16 etype, int offset,
const u_char *pd, frame_data *fd, proto_tree *tree,
proto_tree *fh_tree);
proto_tree *fh_tree, int item_id);
extern const value_string etype_vals[];
/* These functions are in packet-arp.c */
gchar *arphrdaddr_to_str(guint8 *ad, int ad_len, guint16 type);

View File

@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
* $Id: print.c,v 1.10 1999/06/21 19:04:35 gram Exp $
* $Id: print.c,v 1.11 1999/07/07 22:51:58 gram Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@ -38,8 +38,8 @@
#endif
#include "ethereal.h"
#include "gtkpacket.h"
#include "packet.h"
#include "gtkpacket.h"
#include "prefs.h"
#include "print.h"
#include "ps.h"

620
proto.c Normal file
View File

@ -0,0 +1,620 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.1 1999/07/07 22:51:59 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifndef _STDIO_H
#include <stdio.h>
#endif
#include <stdarg.h>
#ifndef _STRING_H
#include <string.h>
#endif
#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
#ifndef __G_LIB_H__
#include <glib.h>
#endif
#ifndef __PROTO_H__
#include "proto.h"
#endif
#ifndef __PACKET_H__
#include "packet.h"
#endif
#ifndef __RESOLV_H__
#include "resolv.h"
#endif
#define cVALS(x) (const value_string*)(x)
static void
proto_tree_free_node(GNode *node, gpointer data);
static struct header_field_info*
find_hfinfo_record(int hfindex);
static proto_item *
proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
gint length, int include_format, int visible, va_list ap);
static gboolean proto_check_id(GNode *node, gpointer data);
void dfilter_yacc_init(void);
/* centralization of registration functions */
void proto_register_data(void);
void proto_register_eth(void);
void proto_register_fddi(void);
void proto_register_frame(void);
void proto_register_ip(void);
void proto_register_llc(void);
void proto_register_null(void);
void proto_register_tr(void);
int hf_text_only = 1;
/* Contains information about protocols and header fields. Used when
* dissectors register their data */
GMemChunk *gmc_hfinfo = NULL;
/* Contains information about a field when a dissector calls
* proto_tree_add_item. */
GMemChunk *gmc_field_info = NULL;
/* String space for protocol and field items for the GUI */
GMemChunk *gmc_item_labels = NULL;
/* List which stores protocols and fields that have been registered */
GPtrArray *gpa_hfinfo = NULL;
/* initialize data structures and register protocols and fields */
void
proto_init(void)
{
if (gmc_hfinfo)
g_mem_chunk_destroy(gmc_hfinfo);
if (gmc_field_info)
g_mem_chunk_destroy(gmc_field_info);
if (gmc_item_labels)
g_mem_chunk_destroy(gmc_item_labels);
if (gpa_hfinfo)
g_ptr_array_free(gpa_hfinfo, FALSE); /* ever needs to be TRUE? */
gmc_hfinfo = g_mem_chunk_new("gmc_hfinfo",
sizeof(struct header_field_info), 50 * sizeof(struct
header_field_info), G_ALLOC_ONLY);
gmc_field_info = g_mem_chunk_new("gmc_field_info",
sizeof(struct field_info), 200 * sizeof(struct field_info),
G_ALLOC_AND_FREE);
gmc_item_labels = g_mem_chunk_new("gmc_item_labels",
ITEM_LABEL_LENGTH, 20 * ITEM_LABEL_LENGTH,
G_ALLOC_AND_FREE);
gpa_hfinfo = g_ptr_array_new();
/* Have each dissector register its protocols and fields. The
* order doesn't matter. Put the calls in alphabetical order
* just to make it easy. */
proto_register_data();
proto_register_eth();
proto_register_fddi();
proto_register_frame();
proto_register_ip();
proto_register_llc();
proto_register_null();
proto_register_tr();
/* Register one special-case FT_TEXT_ONLY field for use when
converting ethereal to new-style proto_tree. These fields
are merely strings on the GUI tree; they are not filterable */
hf_text_only = proto_register_field (
/* name */ "Text",
/* abbrev */ "text",
/* ftype */ FT_TEXT_ONLY,
/* parent */ -1,
/* vals[] */ NULL );
dfilter_yacc_init();
}
/* frees the resources that the dissection a proto_tree uses */
void
proto_tree_free(proto_tree *tree)
{
g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, -1,
(GNodeTraverseFunc)proto_tree_free_node, NULL);
}
static void
proto_tree_free_node(GNode *node, gpointer data)
{
field_info *fi = (field_info*) (node->data);
if (fi->representation)
g_mem_chunk_free(gmc_item_labels, fi->representation);
if (fi->hfinfo->type == FT_STRING)
g_free(fi->value.string);
g_mem_chunk_free(gmc_field_info, fi);
}
/* Finds a record in the hf_info_records array. */
static struct header_field_info*
find_hfinfo_record(int hfindex)
{
g_assert(hfindex >= 0 && hfindex < gpa_hfinfo->len);
return g_ptr_array_index(gpa_hfinfo, hfindex);
}
proto_item *
proto_tree_add_item(proto_tree *tree, int hfindex, gint start, gint length, ...)
{
proto_item *pi;
va_list ap;
va_start(ap, length);
pi = proto_tree_add_item_value(tree, hfindex, start, length, 0, 1, ap);
va_end(ap);
return pi;
}
proto_item *
proto_tree_add_item_hidden(proto_tree *tree, int hfindex, gint start, gint length, ...)
{
proto_item *pi;
va_list ap;
va_start(ap, length);
pi = proto_tree_add_item_value(tree, hfindex, start, length, 0, 0, ap);
va_end(ap);
return pi;
}
proto_item *
proto_tree_add_item_format(proto_tree *tree, int hfindex, gint start, gint length, ...)
{
proto_item *pi;
va_list ap;
va_start(ap, length);
pi = proto_tree_add_item_value(tree, hfindex, start, length, 1, 1, ap);
va_end(ap);
return pi;
}
proto_item *
proto_tree_add_text(proto_tree *tree, gint start, gint length, ...)
{
proto_item *pi;
va_list ap;
va_start(ap, length);
pi = proto_tree_add_item_value(tree, hf_text_only, start, length, 1, 1, ap);
va_end(ap);
return pi;
}
static proto_item *
proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
gint length, int include_format, int visible, va_list ap)
{
proto_item *pi;
field_info *fi;
char *junk, *format;
if (!tree)
return(NULL);
fi = g_mem_chunk_alloc(gmc_field_info);
fi->hfinfo = find_hfinfo_record(hfindex);
g_assert(fi->hfinfo != NULL);
fi->start = start;
fi->length = length;
fi->tree_type = ETT_NONE;
fi->visible = visible;
/* from the stdarg man page on Solaris 2.6:
NOTES
It is up to the calling routine to specify in some manner
how many arguments there are, since it is not always possi-
ble to determine the number of arguments from the stack
frame. For example, execl is passed a zero pointer to sig-
nal the end of the list. printf can tell how many arguments
there are by the format. It is non-portable to specify a
second argument of char, short, or float to va_arg, because
arguments seen by the called function are not char, short,
or float. C converts char and short arguments to int and
converts float arguments to double before passing them to a
function.
*/
switch(fi->hfinfo->type) {
case FT_NONE:
junk = va_arg(ap, guint8*);
break;
case FT_BOOLEAN:
fi->value.boolean = va_arg(ap, unsigned int) ? TRUE : FALSE;
break;
case FT_UINT8:
case FT_VALS_UINT8:
fi->value.numeric = va_arg(ap, unsigned int);
break;
case FT_UINT16:
case FT_VALS_UINT16:
fi->value.numeric = va_arg(ap, unsigned int);
break;
case FT_UINT32:
case FT_VALS_UINT24:
case FT_VALS_UINT32:
case FT_RELATIVE_TIME:
case FT_IPv4:
case FT_IPXSERVER:
fi->value.numeric = va_arg(ap, guint32);
break;
case FT_ETHER:
case FT_ETHER_VENDOR:
/* fi->value.ether = va_arg(ap, guint8*);*/
memcpy(fi->value.ether, va_arg(ap, guint8*), 6);
break;
case FT_ABSOLUTE_TIME:
memcpy(&fi->value.abs_time, va_arg(ap, struct timeval*),
sizeof(struct timeval));
break;
case FT_STRING:
fi->value.string = g_strdup(va_arg(ap, char*)); /* XXX */
break;
case FT_TEXT_ONLY:
; /* nothing */
break;
default:
g_error("hfinfo->type %d not handled\n", fi->hfinfo->type);
break;
}
pi = (proto_item*) g_node_new(fi);
g_node_append((GNode*)tree, (GNode*)pi);
/* are there any formatting arguments? */
if (visible && include_format) {
fi->representation = g_mem_chunk_alloc(gmc_item_labels);
format = va_arg(ap, char*);
vsnprintf(fi->representation, ITEM_LABEL_LENGTH,
format, ap);
}
else {
fi->representation = NULL;
}
return pi;
}
void
proto_item_set_len(proto_item *pi, gint length)
{
field_info *fi = (field_info*) (((GNode*)pi)->data);
fi->length = length;
}
proto_tree*
proto_tree_create_root(void)
{
return (proto_tree*) g_node_new(NULL);
}
proto_tree*
proto_item_add_subtree(proto_item *pi, gint idx) {
field_info *fi = (field_info*) (((GNode*)pi)->data);
fi->tree_type = idx;
return (proto_tree*) pi;
}
int
proto_register_protocol(char *name, char *abbrev)
{
return proto_register_field(name, abbrev, FT_NONE, -1, NULL);
}
void
proto_register_field_array(int parent, const hf_register_info *hf, int num_records)
{
int field_id, i;
const hf_register_info *ptr = hf;
for (i = 0; i < num_records; i++, ptr++) {
field_id = proto_register_field(ptr->name, ptr->abbrev,
ptr->type, parent, ptr->vals);
*ptr->p_id = field_id;
}
}
int
proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
struct value_string* vals)
{
struct header_field_info *hfinfo;
hfinfo = g_mem_chunk_alloc(gmc_hfinfo);
hfinfo->name = name; /* should I g_strdup? */
hfinfo->abbrev = abbrev; /* should I g_strdup? */
hfinfo->type = type;
hfinfo->parent = parent; /* this field differentiates protos and fields */
hfinfo->vals = vals;
g_assert((vals == NULL) || (type == FT_VALS_UINT8 || type == FT_VALS_UINT16 ||
type == FT_VALS_UINT24 || type == FT_VALS_UINT32));
/* if we always add and never delete, then id == len - 1 is correct */
g_ptr_array_add(gpa_hfinfo, hfinfo);
hfinfo->id = gpa_hfinfo->len - 1;
return hfinfo->id;
}
void
proto_item_fill_label(field_info *fi, gchar *label_str)
{
char *s;
switch(fi->hfinfo->type) {
case FT_NONE:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s", fi->hfinfo->name);
break;
case FT_BOOLEAN:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", fi->hfinfo->name,
fi->value.boolean == TRUE ? "True" : "False");
break;
case FT_UINT8:
case FT_UINT16:
case FT_UINT32:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %d", fi->hfinfo->name,
fi->value.numeric);
break;
case FT_ABSOLUTE_TIME:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", fi->hfinfo->name,
abs_time_to_str(&fi->value.abs_time));
break;
case FT_VALS_UINT8:
s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (0x%02x)", fi->hfinfo->name,
(s ? s : "Unknown"), fi->value.numeric);
break;
case FT_VALS_UINT16:
s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (0x%04x)", fi->hfinfo->name,
(s ? s : "Unknown"), fi->value.numeric);
break;
case FT_VALS_UINT24:
s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (0x%06x)", fi->hfinfo->name,
(s ? s : "Unknown"), fi->value.numeric);
break;
case FT_VALS_UINT32:
s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (0x%08x)", fi->hfinfo->name,
(s ? s : "Unknown"), fi->value.numeric);
break;
case FT_ETHER:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", fi->hfinfo->name,
ether_to_str(fi->value.ether),
get_ether_name(fi->value.ether));
break;
case FT_ETHER_VENDOR:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %02x:%02x:%02x (%s)", fi->hfinfo->name,
fi->value.ether[0],
fi->value.ether[1],
fi->value.ether[2],
get_manuf_name(fi->value.ether));
break;
case FT_IPv4:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", fi->hfinfo->name,
get_hostname(fi->value.numeric),
ip_to_str((guint8*)&fi->value.numeric));
break;
case FT_STRING:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", fi->hfinfo->name, fi->value.string);
break;
default:
g_error("hfinfo->type %d not handled\n", fi->hfinfo->type);
break;
}
}
int
proto_registrar_n(void)
{
return gpa_hfinfo->len;
}
char*
proto_registrar_get_abbrev(int n)
{
struct header_field_info *hfinfo;
hfinfo = find_hfinfo_record(n);
if (hfinfo)
return hfinfo->abbrev;
else
return NULL;
}
int
proto_registrar_get_ftype(int n)
{
struct header_field_info *hfinfo;
hfinfo = find_hfinfo_record(n);
if (hfinfo)
return hfinfo->type;
else
return -1;
}
int
proto_registrar_get_parent(int n)
{
struct header_field_info *hfinfo;
hfinfo = find_hfinfo_record(n);
if (hfinfo)
return hfinfo->parent;
else
return -2;
}
gboolean
proto_registrar_is_protocol(int n)
{
struct header_field_info *hfinfo;
hfinfo = find_hfinfo_record(n);
if (hfinfo)
return (hfinfo->parent == -1 ? TRUE : FALSE);
else
return FALSE;
}
typedef struct find_id_info {
int target;
GNode *result;
} find_id_info;
/* looks for a protocol or a header field in a proto_tree. Assumes that protocols
* are at the top level, and header fields only occur underneath their parent's
* subtree. Returns NULL if field not found
*/
proto_item*
proto_find_field(proto_tree* tree, int id)
{
find_id_info fiinfo;
int parent_protocol;
proto_tree *subtree;
fiinfo.target = id;
fiinfo.result = NULL;
/* do a quicker check if field is a protocol */
if (proto_registrar_is_protocol(id) == TRUE) {
return proto_find_protocol(tree, id);
}
/* find the field's parent protocol */
parent_protocol = proto_registrar_get_parent(id);
subtree = proto_find_protocol(tree, parent_protocol);
/* if there is a tree with that protocol, search it for the field */
if (subtree)
g_node_traverse((GNode*)subtree, G_IN_ORDER, G_TRAVERSE_ALL, -1, proto_check_id, &fiinfo);
return (proto_item*) fiinfo.result;
}
/* Looks for a protocol at the top layer of the tree.
* Assumption: a protocol can occur only once in a proto_tree.
*/
proto_item*
proto_find_protocol(proto_tree* tree, int protocol_id)
{
find_id_info fiinfo;
fiinfo.target = protocol_id;
fiinfo.result = NULL;
g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, 2, proto_check_id, &fiinfo);
return (proto_item*) fiinfo.result;
}
static gboolean
proto_check_id(GNode *node, gpointer data)
{
field_info *fi = (field_info*) (node->data);
find_id_info *fiinfo = (find_id_info*) data;
if (fi) { /* !fi == the top most container node which holds nothing */
if (fi->hfinfo->id == fiinfo->target) {
fiinfo->result = node;
return TRUE; /* halt traversal */
}
}
return FALSE; /* keep traversing */
}
void
proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func, proto_tree_search_info *sinfo)
{
g_node_traverse((GNode*)subtree, G_IN_ORDER, G_TRAVERSE_ALL, -1, fill_array_func, sinfo);
}

165
proto.h Normal file
View File

@ -0,0 +1,165 @@
/* proto.h
* Definitions for protocol display
*
* $Id: proto.h,v 1.1 1999/07/07 22:51:59 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PROTO_H__
#define __PROTO_H__
#ifdef HAVE_SYS_TIME_H
#ifndef _SYS_TIME_H
#include <sys/time.h>
#endif
#endif
/* needs glib.h */
typedef struct GNode proto_tree;
typedef struct GNode proto_item;
struct value_string;
#define ITEM_LABEL_LENGTH 240
/* In order to make a const value_string[] look like a value_string*, I
* need this macro */
#define VALS(x) (struct value_string*)(x)
/* field types */
enum ftenum {
FT_NONE, /* used for protocol labels (thus no field type) */
FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */
FT_UINT8,
FT_UINT16,
FT_UINT32,
FT_ABSOLUTE_TIME,
FT_RELATIVE_TIME,
FT_STRING,
FT_ETHER,
FT_ETHER_VENDOR,
FT_BYTES,
FT_IPv4,
FT_IPv6,
FT_IPXSERVER,
FT_VALS_UINT8,
FT_VALS_UINT16,
FT_VALS_UINT24,
FT_VALS_UINT32,
FT_TEXT_ONLY, /* non-filterable, used when converting ethereal
from old-style proto_tree to new-style proto_tree */
NUM_FIELD_TYPES /* last item number plus one */
};
typedef struct header_field_info {
char *name;
char *abbrev;
enum ftenum type;
int parent;
struct value_string *vals;
int id; /* assigned by order of registration */
/* int color; for use by GUI code */
} header_field_info;
/*extern struct header_field_info hfinfo[];*/
/* Used when registering many fields at once */
typedef struct hf_register_info {
char *name;
char *abbrev;
int *p_id; /* pointer to int; written to by register() function */
enum ftenum type;
struct value_string *vals;
} hf_register_info;
/* Info stored in each proto_item GNode */
typedef struct field_info {
struct header_field_info *hfinfo;
gint start;
gint length;
gint tree_type; /* ETT_* */
char *representation; /* for GUI tree */
int visible;
union {
gboolean boolean;
guint32 numeric;
struct timeval abs_time; /* the whole struct, not a pointer */
gchar *string;
guint8 ether[6];
} value;
} field_info;
typedef struct proto_tree_search_info {
int target_field;
GArray *result_array;
guint8 *packet_data;
} proto_tree_search_info;
void proto_init(void);
void proto_item_set_len(proto_item *ti, gint length);
proto_tree* proto_tree_create_root(void);
void proto_tree_free(proto_tree *tree);
proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
int
proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
struct value_string* vals);
int
proto_register_protocol(char *name, char *abbrev);
void
proto_register_field_array(int parent, const hf_register_info *hf, int num_records);
proto_item *
proto_tree_add_item(proto_tree *tree, int hfindex, gint start,
gint length, ...);
proto_item *
proto_tree_add_item_hidden(proto_tree *tree, int hfindex, gint start,
gint length, ...);
proto_item *
proto_tree_add_item_format(proto_tree *tree, int hfindex, gint start,
gint length, ...);
proto_item *
proto_tree_add_text(proto_tree *tree, gint start, gint length, ...);
void
proto_item_fill_label(field_info *fi, gchar *label_str);
/* useful functions for external routines to get info about registered protos and fields */
int proto_registrar_n(void);
char* proto_registrar_get_abbrev(int n);
int proto_registrar_get_ftype(int n);
int proto_registrar_get_parent(int n);
gboolean proto_registrar_is_protocol(int n);
proto_item* proto_find_field(proto_tree* tree, int id);
proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func,
proto_tree_search_info *sinfo);
#endif /* proto.h */

View File

@ -1,7 +1,7 @@
/* resolv.c
* Routines for network object lookup
*
* $Id: resolv.c,v 1.6 1999/03/28 18:32:00 gram Exp $
* $Id: resolv.c,v 1.7 1999/07/07 22:51:59 gram Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -284,7 +284,6 @@ static u_char *host_name_lookup6(struct e_in6_addr *addr)
/* unknown host or DNS timeout */
#endif /* INET6 */
sprintf(name, "%s", ip6_to_str(addr));
return (name);
}
@ -834,3 +833,25 @@ extern u_char *get_manuf_name(u_char *addr)
return manufp->name;
} /* get_manuf_name */
/* return IP address of either hostname or IP address in text format.
* Used more in the dfilter parser rather than in packet dissectors */
unsigned long get_host_ipaddr(const char *host)
{
struct hostent *hp = NULL;
unsigned long ipaddr;
hp = gethostbyname(host);
if (hp == NULL) {
hp = gethostbyaddr(host, strlen(host), AF_INET);
if (hp == NULL) {
return 0;
}
}
memcpy(&ipaddr, hp->h_addr, hp->h_length);
return ntohl(ipaddr);
}

View File

@ -1,7 +1,7 @@
/* resolv.h
* Definitions for network object lookup
*
* $Id: resolv.h,v 1.4 1999/03/28 18:32:01 gram Exp $
* $Id: resolv.h,v 1.5 1999/07/07 22:51:59 gram Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -72,4 +72,7 @@ extern u_char *get_ether_addr(u_char *name);
/* adds a hostname/IP in the hash table */
extern void add_host_name(u_int addr, u_char *name);
/* Returns IP address for a string representing the hostname or dotted-decial IP address */
unsigned long get_host_ipaddr(const char *host);
#endif /* __RESOLV_H__ */

View File

@ -1,7 +1,7 @@
/* summary.c
* Routines for capture file summary window
*
* $Id: summary.c,v 1.2 1999/07/04 06:41:19 guy Exp $
* $Id: summary.c,v 1.3 1999/07/07 22:52:00 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -83,7 +83,6 @@ extern capture_file cf;
char * string_for_format(guint16 cd_t){
switch (cd_t) {
#ifdef WITH_WIRETAP
case WTAP_FILE_WTAP:
return "wiretap";
case WTAP_FILE_PCAP:
@ -100,18 +99,6 @@ char * string_for_format(guint16 cd_t){
return "Network Monitor";
case WTAP_FILE_NETXRAY:
return "NetXray/Sniffer Pro";
#else
case CD_WIRE:
return "wiretap";
case CD_SNOOP:
return "snoop";
case CD_PCAP_BE:
return "pcap-be";
case CD_PCAP_LE:
return "pcap-le";
case CD_NA_UNCOMPR:
return "network-associates";
#endif
default:
return "unknown";
}
@ -136,7 +123,8 @@ tally_frame_data(gpointer cf, gpointer st) {
sum_tally->stop_time = cur_time;
}
sum_tally->bytes += cur_frame->pkt_len;
sum_tally->count++;
if (cur_frame->passed_dfilter)
sum_tally->filtered_count++;
}
void
@ -171,7 +159,7 @@ summary_prep_cb(GtkWidget *w, gpointer d) {
st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs)
;
st->bytes = 0;
st->count = 0;
st->filtered_count = 0;
cur_glist = cf.plist;
for (i = 0; i < cf.count; i++){
@ -238,6 +226,10 @@ seconds", seconds);
snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", cf.count);
add_string_to_box(string_buff, data_box);
/* Filtered Packet count */
snprintf(string_buff, SUM_STR_MAX, "Filtered packet count: %i", st->filtered_count);
add_string_to_box(string_buff, data_box);
/* Packets per second */
if (seconds > 0){
snprintf(string_buff, SUM_STR_MAX, "Avg. packets/sec: %.3f",
@ -279,15 +271,15 @@ traffic_bytes/seconds);
}
add_string_to_box(string_buff, capture_box);
/* Display filter */
if (cf.dfilter) {
/* Display filter. The situation where cf.dfilter="" and cf.dfcode=NULL can exist,
so I'll check for both */
if (cf.dfilter && cf.dfcode) {
snprintf(string_buff, SUM_STR_MAX, "Display filter: %s", cf.dfilter);
} else {
sprintf(string_buff, "Display filter: none");
}
add_string_to_box(string_buff, capture_box);
/* Capture filter */
if (cf.cfilter) {
snprintf(string_buff, SUM_STR_MAX, "Capture filter: %s", cf.cfilter);
@ -295,11 +287,7 @@ traffic_bytes/seconds);
sprintf(string_buff, "Capture filter: none");
}
add_string_to_box(string_buff, capture_box);
#if (GTK_MINOR_VERSION > 1) || ((GTK_MICRO_VERSION > 1) && (GTK_MINOR_VERSION > 0))
gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE);
#else
gtk_window_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE);
#endif
gtk_widget_show(sum_open_w);
}

View File

@ -1,7 +1,7 @@
/* summary.h
* Definitions for capture file summary windows
*
* $Id: summary.h,v 1.1 1999/06/22 22:02:12 gram Exp $
* $Id: summary.h,v 1.2 1999/07/07 22:52:00 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -30,7 +30,7 @@ typedef struct _summary_tally {
guint32 bytes;
double start_time;
double stop_time;
guint32 count;
guint32 filtered_count;
} summary_tally;

View File

@ -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

View File

@ -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

View File

@ -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:

4
wiretap/aclocal.m4 vendored
View File

@ -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]

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);

146
wiretap/configure vendored
View File

@ -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

View File

@ -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)

View File

@ -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++;
}

View File

@ -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);

View File

@ -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);
}
;

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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);

View File

@ -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
#}

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

Some files were not shown because too many files have changed in this diff Show More