Removed all references to gtk objects from packet*.[ch] files. They now

reference the protocol tree with struct proto_tree and struct proto_item
objects. That way, the packet decoding source code file can be used with
non-gtk packet decoders, like a curses-based ethereal, e.g. I also re-arranged
some of the information in packet.h to more appropriate places (like other
packet-*.[ch] files).

svn path=/trunk/; revision=223
This commit is contained in:
Gilbert Ramirez 1999-03-23 03:14:46 +00:00
parent e3db269e00
commit ef3dfe2077
50 changed files with 2099 additions and 2081 deletions

View File

@ -12,6 +12,7 @@ ethereal_SOURCES = \
file.c \
filter.c \
follow.c \
gtkpacket.c \
menu.c \
packet.c \
packet-aarp.c \

View File

@ -87,6 +87,7 @@ ethereal_SOURCES = \
file.c \
filter.c \
follow.c \
gtkpacket.c \
menu.c \
packet.c \
packet-aarp.c \
@ -184,14 +185,14 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
ethereal_OBJECTS = capture.o column.o ethereal.o ethertype.o file.o \
filter.o follow.o menu.o packet.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-giop.o packet-http.o packet-llc.o \
packet-lpd.o packet-ip.o packet-ipv6.o packet-ipx.o packet-nbipx.o \
packet-nbns.o packet-ncp.o packet-null.o packet-osi.o packet-ospf.o \
packet-ppp.o packet-raw.o packet-rip.o packet-tcp.o packet-tftp.o \
packet-tr.o packet-trmac.o packet-udp.o packet-vines.o prefs.o print.o \
ps.o resolv.o util.o
filter.o follow.o gtkpacket.o menu.o packet.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-giop.o packet-http.o \
packet-llc.o packet-lpd.o packet-ip.o packet-ipv6.o packet-ipx.o \
packet-nbipx.o packet-nbns.o packet-ncp.o packet-null.o packet-osi.o \
packet-ospf.o packet-ppp.o packet-raw.o packet-rip.o packet-tcp.o \
packet-tftp.o packet-tr.o packet-trmac.o packet-udp.o packet-vines.o \
prefs.o print.o ps.o resolv.o util.o
ethereal_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
@ -214,7 +215,7 @@ TAR = tar
GZIP = --best
DEP_FILES = .deps/capture.P .deps/column.P .deps/ethereal.P \
.deps/ethertype.P .deps/file.P .deps/filter.P .deps/follow.P \
.deps/menu.P .deps/packet-aarp.P .deps/packet-arp.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-giop.P .deps/packet-http.P \

View File

@ -1,7 +1,7 @@
/* column.c
* Routines for handling column preferences
*
* $Id: column.c,v 1.9 1999/03/05 06:09:39 gram Exp $
* $Id: column.c,v 1.10 1999/03/23 03:14:32 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -42,6 +42,7 @@
#include "ethereal.h"
#include "prefs.h"
#include "column.h"
#include "packet.h"
extern e_prefs prefs;

132
configure vendored
View File

@ -1288,9 +1288,29 @@ rm -f conftest*
rm -f conf.gtktest
# 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:1294: checking for extraneous pcap header directories" >&5
found_pcap_dir=""
for pcap_dir in /usr/include/pcap /usr/local/include/pcap
do
if test -d $pcap_dir ; then
LIBS="$LIBS -L$pcap_dir"
CFLAGS="$CFLAGS -I$pcap_dir"
CPPFLAGS="$CPPFLAGS -I$pcap_dir"
found_pcap_dir=" $found_pcap_dir -L$pcap_dir"
fi
done
if test "$found_pcap_dir" != "" ; then
echo "$ac_t""found --$found_pcap_dir added to LIBS" 1>&6
else
echo "$ac_t""not found" 1>&6
fi
# Pcap checks
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1294: checking how to run the C preprocessor" >&5
echo "configure:1314: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1305,13 +1325,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 1309 "configure"
#line 1329 "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:1315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1335: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -1322,13 +1342,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1326 "configure"
#line 1346 "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:1332: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1352: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@ -1352,17 +1372,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:1356: checking for net/bpf.h" >&5
echo "configure:1376: 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 1361 "configure"
#line 1381 "configure"
#include "confdefs.h"
#include <net/bpf.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1386: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1386,17 +1406,17 @@ fi
ac_safe=`echo "pcap.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for pcap.h""... $ac_c" 1>&6
echo "configure:1390: checking for pcap.h" >&5
echo "configure:1410: 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 1395 "configure"
#line 1415 "configure"
#include "confdefs.h"
#include <pcap.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1420: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1419,7 +1439,7 @@ else
fi
echo $ac_n "checking for pcap_open_offline in -lpcap""... $ac_c" 1>&6
echo "configure:1423: checking for pcap_open_offline in -lpcap" >&5
echo "configure:1443: 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
@ -1427,7 +1447,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1431 "configure"
#line 1451 "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
@ -1438,7 +1458,7 @@ int main() {
pcap_open_offline()
; return 0; }
EOF
if { (eval echo configure:1442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -1467,27 +1487,9 @@ else
fi
# 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:1473: checking for extraneous pcap header directories" >&5
found_pcap_dir=""
for pcap_dir in /usr/include/pcap /usr/local/include/pcap
do
if test -d $pcap_dir ; then
LIBS="$LIBS -L$pcap_dir"
found_pcap_dir=" $found_pcap_dir -L$pcap_dir"
fi
done
if test "$found_pcap_dir" != "" ; then
echo "$ac_t""found --$found_pcap_dir added to LIBS" 1>&6
else
echo "$ac_t""not found" 1>&6
fi
# Wiretap check
echo $ac_n "checking whether to include wiretap library""... $ac_c" 1>&6
echo "configure:1491: checking whether to include wiretap library" >&5
echo "configure:1493: 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"
@ -1517,12 +1519,12 @@ fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:1521: checking for ANSI C header files" >&5
echo "configure:1523: 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 1526 "configure"
#line 1528 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -1530,7 +1532,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1534: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1536: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1547,7 +1549,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 1551 "configure"
#line 1553 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -1565,7 +1567,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 1569 "configure"
#line 1571 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -1586,7 +1588,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 1590 "configure"
#line 1592 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -1597,7 +1599,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:1601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@ -1624,17 +1626,17 @@ for ac_hdr in fcntl.h strings.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:1628: checking for $ac_hdr" >&5
echo "configure:1630: 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 1633 "configure"
#line 1635 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1640: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1665,17 +1667,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:1669: checking for $ac_hdr" >&5
echo "configure:1671: 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 1674 "configure"
#line 1676 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1679: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1681: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1708,12 +1710,12 @@ done
# for get_interface_list().
echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
echo "configure:1712: checking for sa_len in struct sockaddr" >&5
echo "configure:1714: 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 1717 "configure"
#line 1719 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@ -1721,7 +1723,7 @@ int main() {
struct sockaddr s; s.sa_len;
; return 0; }
EOF
if { (eval echo configure:1725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1727: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_ethereal_struct_sa_len=yes
else
@ -1744,14 +1746,14 @@ fi
# We must know our byte order
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
echo "configure:1748: checking whether byte ordering is bigendian" >&5
echo "configure:1750: 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 1755 "configure"
#line 1757 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@ -1762,11 +1764,11 @@ int main() {
#endif
; return 0; }
EOF
if { (eval echo configure:1766: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1768: \"$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 1770 "configure"
#line 1772 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@ -1777,7 +1779,7 @@ int main() {
#endif
; return 0; }
EOF
if { (eval echo configure:1781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1783: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@ -1797,7 +1799,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 1801 "configure"
#line 1803 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@ -1810,7 +1812,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
if { (eval echo configure:1814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@ -1836,13 +1838,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:1840: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:1842: 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 1846 "configure"
#line 1848 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -1860,7 +1862,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 1864 "configure"
#line 1866 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -1882,12 +1884,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
fi
echo $ac_n "checking for socket""... $ac_c" 1>&6
echo "configure:1886: checking for socket" >&5
echo "configure:1888: 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 1891 "configure"
#line 1893 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char socket(); below. */
@ -1910,7 +1912,7 @@ socket();
; return 0; }
EOF
if { (eval echo configure:1914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_socket=yes"
else
@ -1936,12 +1938,12 @@ fi
SNPRINTF_C=""
SNPRINTF_O=""
echo $ac_n "checking for snprintf""... $ac_c" 1>&6
echo "configure:1940: checking for snprintf" >&5
echo "configure:1942: 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 1945 "configure"
#line 1947 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char snprintf(); below. */
@ -1964,7 +1966,7 @@ snprintf();
; return 0; }
EOF
if { (eval echo configure:1968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:1970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_snprintf=yes"
else

View File

@ -1,6 +1,6 @@
/* ethereal.c
*
* $Id: ethereal.c,v 1.24 1999/03/01 18:57:00 gram Exp $
* $Id: ethereal.c,v 1.25 1999/03/23 03:14:33 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -78,6 +78,7 @@
#include "resolv.h"
#include "follow.h"
#include "util.h"
#include "gtkpacket.h"
FILE *data_out_file = NULL;
packet_info pi;
@ -322,7 +323,7 @@ packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
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, GTK_TREE(tree_view));
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_thaw(GTK_TEXT(byte_view));

View File

@ -1,7 +1,7 @@
/* ethereal.h
* Global defines, etc.
*
* $Id: ethereal.h,v 1.11 1999/02/11 06:17:30 guy Exp $
* $Id: ethereal.h,v 1.12 1999/03/23 03:14:33 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -89,46 +89,6 @@ typedef struct _selection_info {
GtkWidget *text;
} selection_info;
/*
* All of the possible columns in summary listing.
*
* NOTE: The SRC and DST entries MUST remain in this order, or else you
* need to fix the offset #defines before get_column_format!
*/
enum {
COL_NUMBER, /* Packet list item number */
COL_CLS_TIME, /* Command line-specified time (default relative) */
COL_REL_TIME, /* Relative time */
COL_ABS_TIME, /* Absolute time */
COL_DELTA_TIME, /* Delta time */
COL_DEF_SRC, /* Source address */
COL_RES_SRC, /* Resolved source */
COL_UNRES_SRC, /* Unresolved source */
COL_DEF_DL_SRC, /* Data link layer source address */
COL_RES_DL_SRC, /* Resolved DL source */
COL_UNRES_DL_SRC, /* Unresolved DL source */
COL_DEF_NET_SRC, /* Network layer source address */
COL_RES_NET_SRC, /* Resolved net source */
COL_UNRES_NET_SRC, /* Unresolved net source */
COL_DEF_DST, /* Destination address */
COL_RES_DST, /* Resolved dest */
COL_UNRES_DST, /* Unresolved dest */
COL_DEF_DL_DST, /* Data link layer dest address */
COL_RES_DL_DST, /* Resolved DL dest */
COL_UNRES_DL_DST, /* Unresolved DL dest */
COL_DEF_NET_DST, /* Network layer dest address */
COL_RES_NET_DST, /* Resolved net dest */
COL_UNRES_NET_DST, /* Unresolved net dest */
COL_DEF_SRC_PORT, /* Source port */
COL_RES_SRC_PORT, /* Resolved source port */
COL_UNRES_SRC_PORT, /* Unresolved source port */
COL_DEF_DST_PORT, /* Destination port */
COL_RES_DST_PORT, /* Resolved dest port */
COL_UNRES_DST_PORT, /* Unresolved dest port */
COL_PROTOCOL, /* Protocol */
COL_INFO, /* Description */
NUM_COL_FMTS /* Should always be last */
};
/*
* Type of time-stamp shown in the summary display.

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.12 1999/02/09 00:35:36 guy Exp $
* $Id: ethertype.c,v 1.13 1999/03/23 03:14:34 gram Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@ -34,11 +34,7 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
@ -77,11 +73,11 @@ capture_ethertype(guint16 etype, int offset,
void
ethertype(guint16 etype, int offset,
const u_char *pd, frame_data *fd, GtkTree *tree, GtkWidget
const u_char *pd, frame_data *fd, proto_tree *tree, proto_tree
*fh_tree)
{
if (tree) {
add_item_to_tree(fh_tree, offset - 2, 2, "Type: %s (0x%04x)",
proto_tree_add_item(fh_tree, offset - 2, 2, "Type: %s (0x%04x)",
ethertype_to_str(etype, "Unknown"), etype);
}
switch (etype) {

4
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.21 1999/03/20 04:38:57 gram Exp $
* $Id: file.c,v 1.22 1999/03/23 03:14:34 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -199,7 +199,7 @@ open_cap_file(char *fname, capture_file *cf) {
/* Reset everything to a pristine state */
void
close_cap_file(capture_file *cf, GtkWidget *w, guint context) {
close_cap_file(capture_file *cf, void *w, guint context) {
if (cf->fh) {
fclose(cf->fh);
cf->fh = NULL;

12
file.h
View File

@ -1,7 +1,7 @@
/* file.h
* Definitions for file structures and routines
*
* $Id: file.h,v 1.10 1999/02/11 06:17:30 guy Exp $
* $Id: file.h,v 1.11 1999/03/23 03:14:34 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -82,7 +82,13 @@ typedef struct _capture_file {
gchar *dfilter; /* Display filter string */
gchar *cfilter; /* Capture filter string */
bpf_prog fcode; /* Compiled filter program */
guint8 pd[MAX_PACKET_SIZE]; /* Packet data */
/* 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
* moved to different header files) --gilbert
*/
/*guint8 pd[MAX_PACKET_SIZE];*/ /* Packet data */
guint8 pd[65536]; /* Packet data */
GList *plist; /* Packet list */
frame_data *cur; /* Current list item */
column_info cinfo; /* Column formatting information */
@ -109,7 +115,7 @@ typedef struct _snoop_frame_hdr {
#endif
int open_cap_file(char *, capture_file *);
void close_cap_file(capture_file *, GtkWidget *, guint);
void close_cap_file(capture_file *, void *, guint);
int load_cap_file(char *, capture_file *);
/* size_t read_frame_header(capture_file *); */

174
gtkpacket.c Normal file
View File

@ -0,0 +1,174 @@
/* gtkpacket.c
* Routines for GTK+ packet display
*
* $Id: gtkpacket.c,v 1.1 1999/03/23 03:14:34 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
#include <ctype.h>
#include <stdarg.h>
#include <gtk/gtk.h>
#include "ethereal.h"
#include "packet.h"
#ifndef __GTKPACKET_H__
#include "gtkpacket.h"
#endif
#define BYTE_VIEW_WIDTH 16
extern GtkWidget *byte_view;
extern GdkFont *m_r_font, *m_b_font;
void
packet_hex_print(GtkText *bv, guchar *pd, gint len, gint bstart, gint blen) {
gint i = 0, j, k, cur;
gchar line[128], hexchars[] = "0123456789abcdef";
GdkFont *cur_font, *new_font;
while (i < len) {
/* Print the line number */
sprintf(line, "%04x ", i);
gtk_text_insert(bv, m_r_font, NULL, NULL, line, -1);
/* Do we start in bold? */
cur_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
j = i;
k = i + BYTE_VIEW_WIDTH;
cur = 0;
/* Print the hex bit */
while (i < k) {
if (i < len) {
line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
line[cur++] = hexchars[pd[i] & 0x0f];
} else {
line[cur++] = ' '; line[cur++] = ' ';
}
line[cur++] = ' ';
i++;
/* Did we cross a bold/plain boundary? */
new_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
if (cur_font != new_font) {
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur_font = new_font;
cur = 0;
}
}
line[cur++] = ' ';
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur = 0;
i = j;
/* Print the ASCII bit */
cur_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
while (i < k) {
if (i < len) {
line[cur++] = (isgraph(pd[i])) ? pd[i] : '.';
} else {
line[cur++] = ' ';
}
i++;
/* Did we cross a bold/plain boundary? */
new_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
if (cur_font != new_font) {
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur_font = new_font;
cur = 0;
}
}
line[cur++] = '\n';
line[cur] = '\0';
gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
}
}
static void
expand_tree(GtkWidget *w, gpointer data) {
gint *val = (gint *) data;
*val = 1;
}
static void
collapse_tree(GtkWidget *w, gpointer data) {
gint *val = (gint *) data;
*val = 0;
}
static void
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)
{
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len);
}
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)
{
return (proto_tree*) gtk_tree_new();
}

35
gtkpacket.h Normal file
View File

@ -0,0 +1,35 @@
/* gtkpacket.h
* Definitions for GTK+ packet display structures and routines
*
* $Id: gtkpacket.h,v 1.1 1999/03/23 03:14:35 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 __GTKPACKET_H__
#define __GTKPACKET_H__
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"
#endif

View File

@ -22,19 +22,12 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <glib.h>
#include "packet.h"
#include "etypes.h"
@ -78,10 +71,11 @@ atalkid_to_str(guint8 *ad) {
}
void
dissect_aarp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_aarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ether_aarp ea;
GtkWidget *aarp_tree, *ti;
gchar *op_str;
proto_tree *aarp_tree;
proto_item *ti;
gchar *op_str;
value_string op_vals[] = { {AARP_REQUEST, "AARP request" },
{AARP_REPLY, "AARP reply" },
{AARP_PROBE, "AARP probe" },
@ -102,29 +96,29 @@ dissect_aarp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
if (tree) {
if ((op_str = match_strval(ea.op, op_vals)))
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 28, op_str);
ti = proto_tree_add_item(tree, offset, 28, op_str);
else
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 28,
ti = proto_tree_add_item(tree, offset, 28,
"Unknown AARP (opcode 0x%04x)", ea.op);
aarp_tree = gtk_tree_new();
add_subtree(ti, aarp_tree, ETT_AARP);
add_item_to_tree(aarp_tree, offset, 2,
aarp_tree = proto_tree_new();
proto_item_add_subtree(ti, aarp_tree, ETT_AARP);
proto_tree_add_item(aarp_tree, offset, 2,
"Hardware type: 0x%04x", ea.htype);
add_item_to_tree(aarp_tree, offset + 2, 2,
proto_tree_add_item(aarp_tree, offset + 2, 2,
"Protocol type: 0x%04x", ea.ptype);
add_item_to_tree(aarp_tree, offset + 4, 1,
proto_tree_add_item(aarp_tree, offset + 4, 1,
"Hardware size: 0x%02x", ea.halen);
add_item_to_tree(aarp_tree, offset + 5, 1,
proto_tree_add_item(aarp_tree, offset + 5, 1,
"Protocol size: 0x%02x", ea.palen);
add_item_to_tree(aarp_tree, offset + 6, 2,
proto_tree_add_item(aarp_tree, offset + 6, 2,
"Opcode: 0x%04x (%s)", ea.op, op_str ? op_str : "Unknown");
add_item_to_tree(aarp_tree, offset + 8, 6,
proto_tree_add_item(aarp_tree, offset + 8, 6,
"Sender ether: %s", ether_to_str((guint8 *) ea.hsaddr));
add_item_to_tree(aarp_tree, offset + 14, 4,
proto_tree_add_item(aarp_tree, offset + 14, 4,
"Sender ID: %s", atalkid_to_str((guint8 *) ea.psaddr));
add_item_to_tree(aarp_tree, offset + 18, 6,
proto_tree_add_item(aarp_tree, offset + 18, 6,
"Target ether: %s", ether_to_str((guint8 *) ea.hdaddr));
add_item_to_tree(aarp_tree, offset + 24, 4,
proto_tree_add_item(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.11 1999/01/28 21:29:34 gram Exp $
* $Id: packet-arp.c,v 1.12 1999/03/23 03:14:35 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,19 +27,11 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
@ -82,6 +74,21 @@
/* Max string length for displaying unknown type of ARP address. */
#define MAX_ADDR_STR_LEN 16
/* ARP / RARP structs and definitions */
#ifndef ARPOP_REQUEST
#define ARPOP_REQUEST 1 /* ARP request. */
#endif
#ifndef ARPOP_REPLY
#define ARPOP_REPLY 2 /* ARP reply. */
#endif
/* Some OSes have different names, or don't define these at all */
#ifndef ARPOP_RREQUEST
#define ARPOP_RREQUEST 3 /* RARP request. */
#endif
#ifndef ARPOP_RREPLY
#define ARPOP_RREPLY 4 /* RARP reply. */
#endif
static gchar *
arpaddr_to_str(guint8 *ad, int ad_len) {
static gchar str[3][MAX_ADDR_STR_LEN+3+1];
@ -181,13 +188,14 @@ arphrdtype_to_str(guint16 hwtype, const char *fmt) {
#define AR_OP 6
void
dissect_arp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_arp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 ar_hrd;
guint16 ar_pro;
guint8 ar_hln;
guint8 ar_pln;
guint16 ar_op;
GtkWidget *arp_tree, *ti;
proto_tree *arp_tree;
proto_item *ti;
gchar *op_str;
int sha_offset, spa_offset, tha_offset, tpa_offset;
gchar *sha_str, *spa_str, *tha_str, *tpa_str;
@ -246,30 +254,30 @@ dissect_arp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
if (tree) {
if ((op_str = match_strval(ar_op, op_vals)))
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 8 + 2*ar_hln + 2*ar_pln,
ti = proto_tree_add_item(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
op_str);
else
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 8 + 2*ar_hln + 2*ar_pln,
ti = proto_tree_add_item(tree, offset, 8 + 2*ar_hln + 2*ar_pln,
"Unknown ARP (opcode 0x%04x)", ar_op);
arp_tree = gtk_tree_new();
add_subtree(ti, arp_tree, ETT_ARP);
add_item_to_tree(arp_tree, offset + AR_HRD, 2,
arp_tree = proto_tree_new();
proto_item_add_subtree(ti, arp_tree, ETT_ARP);
proto_tree_add_item(arp_tree, offset + AR_HRD, 2,
"Hardware type: %s", arphrdtype_to_str(ar_hrd, "Unknown (0x%04x)"));
add_item_to_tree(arp_tree, offset + AR_PRO, 2,
proto_tree_add_item(arp_tree, offset + AR_PRO, 2,
"Protocol type: %s", ethertype_to_str(ar_pro, "Unknown (0x%04x)"));
add_item_to_tree(arp_tree, offset + AR_HLN, 1,
proto_tree_add_item(arp_tree, offset + AR_HLN, 1,
"Hardware size: %d", ar_hln);
add_item_to_tree(arp_tree, offset + AR_PLN, 1,
proto_tree_add_item(arp_tree, offset + AR_PLN, 1,
"Protocol size: %d", ar_pln);
add_item_to_tree(arp_tree, offset + AR_OP, 2,
proto_tree_add_item(arp_tree, offset + AR_OP, 2,
"Opcode: 0x%04x (%s)", ar_op, op_str ? op_str : "Unknown");
add_item_to_tree(arp_tree, sha_offset, ar_hln,
proto_tree_add_item(arp_tree, sha_offset, ar_hln,
"Sender hardware address: %s", sha_str);
add_item_to_tree(arp_tree, spa_offset, ar_pln,
proto_tree_add_item(arp_tree, spa_offset, ar_pln,
"Sender protocol address: %s", spa_str);
add_item_to_tree(arp_tree, tha_offset, ar_hln,
proto_tree_add_item(arp_tree, tha_offset, ar_hln,
"Target hardware address: %s", tha_str);
add_item_to_tree(arp_tree, tpa_offset, ar_pln,
proto_tree_add_item(arp_tree, tpa_offset, ar_pln,
"Target protocol address: %s", tpa_str);
}
}

View File

@ -22,22 +22,18 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include <glib.h>
#include "packet.h"
#if BYTE_ORDER == LITTLE_ENDIAN
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include "packet.h"
#include "etypes.h"
#include "resolv.h"
#endif
extern packet_info pi;
@ -68,9 +64,10 @@ typedef struct _e_ddp {
#define DDP_ADSP 0x07
void
dissect_ddp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ddp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ddp ddp;
GtkWidget *ddp_tree, *ti;
proto_tree *ddp_tree;
proto_item *ti;
value_string op_vals[] = { {DDP_RTMPDATA, "AppleTalk Routing Table response or data" },
{DDP_NBP, "AppleTalk Name Binding Protocol packet"},
{DDP_ATP, "AppleTalk Transaction Protocol packet"},
@ -96,20 +93,19 @@ dissect_ddp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
val_to_str(ddp.type, op_vals, "Unknown DDP protocol (%02x)"));
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 13,
"Datagram Delivery Protocol");
ddp_tree = gtk_tree_new();
add_subtree(ti, ddp_tree, ETT_IP);
add_item_to_tree(ddp_tree, offset, 1, "Hop count: %d", ddp_hops(ddp.hops_len));
add_item_to_tree(ddp_tree, offset, 2, "Datagram length: %d", ddp_len(ddp.hops_len));
add_item_to_tree(ddp_tree, offset + 2, 2, "Checksum: %d",ddp.sum);
add_item_to_tree(ddp_tree, offset + 4, 2, "Destination Net: %d",ddp.dnet);
add_item_to_tree(ddp_tree, offset + 6, 2, "Source Net: %d",ddp.snet);
add_item_to_tree(ddp_tree, offset + 8, 1, "Destination Node: %d",ddp.dnode);
add_item_to_tree(ddp_tree, offset + 9, 1, "Source Node: %d",ddp.snode);
add_item_to_tree(ddp_tree, offset + 10, 1, "Destination Socket: %d",ddp.dport);
add_item_to_tree(ddp_tree, offset + 11, 1, "Source Socket: %d",ddp.sport);
add_item_to_tree(ddp_tree, offset + 12, 1, "Type: %d",ddp.type);
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);
}
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.15 1999/01/28 21:29:35 gram Exp $
* $Id: packet-bootp.c,v 1.16 1999/03/23 03:14:35 gram Exp $
*
* The information used comes from:
* RFC 2132: DHCP Options and BOOTP Vendor Extensions
@ -33,22 +33,12 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
enum field_type { none, ipv4, string, toggle, yes_no, special, opaque,
time_in_secs,
@ -64,7 +54,7 @@ struct opt_info {
/* returns the number of bytes consumed by this option */
static int
bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
{
char *text;
enum field_type ftype;
@ -73,7 +63,8 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
u_char byte;
int i, consumed = vlen + 2;
u_long time_secs;
GtkWidget *vti, *v_tree;
proto_tree *v_tree;
proto_item *vti;
static const char *opt53_text[] = {
"Unknown Message Type",
@ -183,7 +174,7 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
}
}
i = i - voff;
add_item_to_tree(bp_tree, voff, i, "Padding");
proto_tree_add_item(bp_tree, voff, i, "Padding");
consumed = i;
return consumed;
@ -191,7 +182,7 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case 21:
/* one IP address pair */
if (vlen == 8) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(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]));
@ -199,12 +190,12 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
/* > 1 IP address pair. Let's make a sub-tree */
else {
vti = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 8) {
add_item_to_tree(v_tree, i, 8, "IP Address/Mask: %s/%s",
proto_tree_add_item(v_tree, i, 8, "IP Address/Mask: %s/%s",
ip_to_str((guint8*)&pd[i]),
ip_to_str((guint8*)&pd[i+4]));
}
@ -215,7 +206,7 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case 33:
/* one IP address pair */
if (vlen == 8) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(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]));
@ -223,12 +214,12 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
/* > 1 IP address pair. Let's make a sub-tree */
else {
vti = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 8) {
add_item_to_tree(v_tree, i, 8,
proto_tree_add_item(v_tree, i, 8,
"Destination IP Address/Router: %s/%s",
ip_to_str((guint8*)&pd[i]),
ip_to_str((guint8*)&pd[i+4]));
@ -238,14 +229,14 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
/* Vendor-Specific Info */
case 43:
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s", code, text);
break;
/* NetBIOS-over-TCP/IP Node Type */
case 46:
byte = pd[voff+2];
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
val_to_str(byte, nbnt_vals,
"Unknown (0x%02x)"));
@ -260,24 +251,24 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
else {
i = 0;
}
add_item_to_tree(bp_tree, voff, 3, "Option %d: %s = DHCP %s",
proto_tree_add_item(bp_tree, voff, 3, "Option %d: %s = DHCP %s",
code, text, opt53_text[i]);
break;
/* Parameter Request List */
case 55:
vti = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
vlen + 2, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
for (i = 0; i < vlen; i++) {
byte = pd[voff+2+i];
if (byte < NUM_OPT_INFOS) {
add_item_to_tree(v_tree, voff+2+i, 1, "%d = %s",
proto_tree_add_item(v_tree, voff+2+i, 1, "%d = %s",
byte, opt[byte].text);
}
else {
add_item_to_tree(vti, voff+2+i, 1,
proto_tree_add_item(vti, voff+2+i, 1,
"Unknown Option Code: %d", byte);
}
}
@ -289,29 +280,29 @@ bootp_option(const u_char *pd, GtkWidget *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 = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
add_item_to_tree(v_tree, voff+2, 1,
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
proto_tree_add_item(v_tree, voff+2, 1,
"Hardware type: %s",
arphrdtype_to_str(pd[voff+2],
"Unknown (0x%02x)"));
add_item_to_tree(v_tree, voff+3, 6,
proto_tree_add_item(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 {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)", code, text, vlen);
}
break;
/* End Option */
case 255:
add_item_to_tree(bp_tree, voff, 1, "End Option");
proto_tree_add_item(bp_tree, voff, 1, "End Option");
consumed = 1;
return consumed;
@ -332,19 +323,19 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case ipv4:
/* one IP address */
if (vlen == 4) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(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 = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 4) {
add_item_to_tree(v_tree, i, 4, "IP Address: %s",
proto_tree_add_item(v_tree, i, 4, "IP Address: %s",
ip_to_str((guint8*)&pd[i]));
}
}
@ -354,12 +345,12 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
/* Fix for non null-terminated string supplied by
* John Lines <John.Lines@aeat.co.uk>
*/
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %.*s", code, text, vlen, &pd[voff+2]);
break;
case opaque:
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)",
code, text, vlen);
break;
@ -367,43 +358,43 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case val_u_short:
/* one IP address */
if (vlen == 2) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %d", code, text,
pntohs(&pd[voff+2]));
}
/* > 1 u_short */
else {
vti = add_item_to_tree(GTK_WIDGET(bp_tree), voff,
vti = proto_tree_add_item(bp_tree, voff,
consumed, "Option %d: %s", code, text);
v_tree = gtk_tree_new();
add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
v_tree = proto_tree_new();
proto_item_add_subtree(vti, v_tree, ETT_BOOTP_OPTION);
for (i = voff + 2; i < voff + consumed; i += 2) {
add_item_to_tree(v_tree, i, 4, "Value: %d",
proto_tree_add_item(v_tree, i, 4, "Value: %d",
pntohs(&pd[i]));
}
}
break;
case val_u_long:
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %d", code, text,
pntohl(&pd[voff+2]));
break;
case val_u_byte:
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(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) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = Invalid Value %d", code, text,
pd[voff+2]);
}
else {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
pd[voff+2] == 0 ? "Disabled" : "Enabled");
}
@ -412,12 +403,12 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case yes_no:
i = pd[voff+2];
if (i != 0 && i != 1) {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = Invalid Value %d", code, text,
pd[voff+2]);
}
else {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
pd[voff+2] == 0 ? "No" : "Yes");
}
@ -425,7 +416,7 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
case time_in_secs:
time_secs = pntohl(&pd[voff+2]);
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s = %s", code, text,
((time_secs == 0xffffffff) ?
"infinity" :
@ -433,12 +424,12 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
break;
default:
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Option %d: %s (%d bytes)", code, text, vlen);
}
}
else {
add_item_to_tree(bp_tree, voff, consumed,
proto_tree_add_item(bp_tree, voff, consumed,
"Unknown Option Code: %d (%d bytes)", code, vlen);
}
@ -446,9 +437,10 @@ bootp_option(const u_char *pd, GtkWidget *bp_tree, int voff, int eoff)
}
void
dissect_bootp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
GtkWidget *bp_tree, *ti;
proto_tree *bp_tree;
proto_item *ti;
int voff, eoff; /* vender offset, end offset */
if (check_col(fd, COL_PROTOCOL))
@ -466,66 +458,66 @@ dissect_bootp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"Bootstrap Protocol");
bp_tree = gtk_tree_new();
add_subtree(ti, bp_tree, ETT_BOOTP);
bp_tree = proto_tree_new();
proto_item_add_subtree(ti, bp_tree, ETT_BOOTP);
add_item_to_tree(bp_tree, offset, 1, pd[offset] == 1 ?
proto_tree_add_item(bp_tree, offset, 1, pd[offset] == 1 ?
"Boot Request" : "Boot Reply");
add_item_to_tree(bp_tree, offset + 1, 1,
proto_tree_add_item(bp_tree, offset + 1, 1,
"Hardware type: %s",
arphrdtype_to_str(pd[offset+1], "Unknown (0x%02x)"));
add_item_to_tree(bp_tree, offset + 2, 1,
proto_tree_add_item(bp_tree, offset + 2, 1,
"Hardware address length: %d", pd[offset+2]);
add_item_to_tree(bp_tree, offset + 3, 1,
proto_tree_add_item(bp_tree, offset + 3, 1,
"Hops: %d", pd[offset+3]);
add_item_to_tree(bp_tree, offset + 4, 4,
proto_tree_add_item(bp_tree, offset + 4, 4,
"Transaction ID: 0x%08x", pntohl(&pd[offset+4]));
add_item_to_tree(bp_tree, offset + 8, 2,
proto_tree_add_item(bp_tree, offset + 8, 2,
"Seconds elapsed: %d", pntohs(&pd[offset+8]));
add_item_to_tree(bp_tree, offset + 10, 2,
proto_tree_add_item(bp_tree, offset + 10, 2,
"Broadcast flag: %d", pd[offset+10] & 1);
add_item_to_tree(bp_tree, offset + 12, 4,
proto_tree_add_item(bp_tree, offset + 12, 4,
"Client IP address: %s", ip_to_str((guint8*)&pd[offset+12]));
add_item_to_tree(bp_tree, offset + 16, 4,
proto_tree_add_item(bp_tree, offset + 16, 4,
"Your (client) IP address: %s", ip_to_str((guint8*)&pd[offset+16]));
add_item_to_tree(bp_tree, offset + 20, 4,
proto_tree_add_item(bp_tree, offset + 20, 4,
"Next server IP address: %s", ip_to_str((guint8*)&pd[offset+20]));
add_item_to_tree(bp_tree, offset + 24, 4,
proto_tree_add_item(bp_tree, offset + 24, 4,
"Relay agent IP address: %s", ip_to_str((guint8*)&pd[offset+24]));
add_item_to_tree(bp_tree, offset + 28, pd[offset+2],
proto_tree_add_item(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]) {
add_item_to_tree(bp_tree, offset + 44, 64,
proto_tree_add_item(bp_tree, offset + 44, 64,
"Server host name: %s", &pd[offset+44]);
}
else {
add_item_to_tree(bp_tree, offset + 44, 64,
proto_tree_add_item(bp_tree, offset + 44, 64,
"Server host name not given");
}
/* Boot file */
if (pd[offset+108]) {
add_item_to_tree(bp_tree, offset + 108, 128,
proto_tree_add_item(bp_tree, offset + 108, 128,
"Boot file name: %s", &pd[offset+108]);
}
else {
add_item_to_tree(bp_tree, offset + 108, 128,
proto_tree_add_item(bp_tree, offset + 108, 128,
"Boot file name not given");
}
if (pntohl(&pd[offset+236]) == 0x63825363) {
add_item_to_tree(bp_tree, offset + 236, 4,
proto_tree_add_item(bp_tree, offset + 236, 4,
"Magic cookie: (OK)");
}
else {
add_item_to_tree(bp_tree, offset + 236, 4,
proto_tree_add_item(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.7 1999/03/01 18:28:11 gram Exp $
* $Id: packet-cdp.c,v 1.8 1999/03/23 03:14:36 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -26,21 +26,14 @@
#include "config.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
/* Offsets in TLV structure. */
@ -48,12 +41,13 @@
#define TLV_LENGTH 2
static void
add_multi_line_string_to_tree(GtkWidget *tree, gint start, gint len,
add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
const gchar *prefix, const gchar *string);
void
dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
GtkWidget *cdp_tree = NULL, *ti;
dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree *cdp_tree = NULL;
proto_item *ti;
typedef struct _e_cdp_hdr{
char version;
@ -72,20 +66,20 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, "Cisco Discovery Protocol");
if(tree){
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset),
ti = proto_tree_add_item(tree, offset, (fd->cap_len - offset),
"Cisco Discovery Protocol");
cdp_tree = gtk_tree_new();
add_subtree(ti, cdp_tree, ETT_CDP);
cdp_tree = proto_tree_new();
proto_item_add_subtree(ti, cdp_tree, ETT_CDP);
/* CDP header */
cdp_hdr = (e_cdp_hdr *) &pd[offset];
add_item_to_tree(cdp_tree, offset, 1, "Version: %d", cdp_hdr->version);
add_item_to_tree(cdp_tree, offset+1, 1, "Flags (unknown)");
add_item_to_tree(cdp_tree, offset+2, 2, "TTL (unknown)");
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)");
offset+=4;
/* CVS -> exit here
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
dissect_data(pd, offset, fd, cdp_tree);
return;
*/
@ -97,7 +91,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
offset+=length + 4;
break;
case 1: /* ??? Chassis ID */
add_item_to_tree(cdp_tree, offset + 4,
proto_tree_add_item(cdp_tree, offset + 4,
length - 4, "Chassis ID: %s", &pd[offset+4] );
offset+=length;
break;
@ -108,7 +102,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
offset+=4;
break;
case 3: /* ??? Port */
add_item_to_tree(cdp_tree, offset + 4,
proto_tree_add_item(cdp_tree, offset + 4,
length - 4, "Sent through Interface: %s", &pd[offset+4] );
offset+=length;
break;
@ -123,13 +117,13 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
stringmem = malloc(length);
memset(stringmem, '\0', length);
memcpy(stringmem, &pd[offset+4], length - 4 );
add_item_to_tree(cdp_tree, offset + 4, length - 4,
proto_tree_add_item(cdp_tree, offset + 4, length - 4,
"Platform: %s", stringmem );
free(stringmem);
offset+=length;
break;
case 0x01cc: /* ??? Mgmt Addr */
add_item_to_tree(cdp_tree, offset + 4, length,
proto_tree_add_item(cdp_tree, offset + 4, length,
"Mgmt IP: %s",
ip_to_str(&pd[offset+4]) );
offset+=length + 4;
@ -137,16 +131,16 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
default:
/*
if( type > 512){
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
dissect_data(pd, offset, fd, cdp_tree);
return;
}
*/
/*
add_item_to_tree(cdp_tree, offset + TLV_TYPE,
proto_tree_add_item(cdp_tree, offset + TLV_TYPE,
2, "Type: %d", type);
add_item_to_tree(cdp_tree, offset + TLV_LENGTH,
proto_tree_add_item(cdp_tree, offset + TLV_LENGTH,
2, "Length: %d", length);
add_item_to_tree(cdp_tree, offset + 4,
proto_tree_add_item(cdp_tree, offset + 4,
length - 4, "Data");
*/
@ -154,12 +148,12 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
}
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
dissect_data(pd, offset, fd, cdp_tree);
}
}
static void
add_multi_line_string_to_tree(GtkWidget *tree, gint start, gint len,
add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
const gchar *prefix, const gchar *string)
{
int prefix_len;
@ -185,7 +179,7 @@ add_multi_line_string_to_tree(GtkWidget *tree, gint start, gint len,
line_len = strlen(p);
data_len = line_len;
}
add_item_to_tree(tree, start, data_len, "%s%.*s", prefix,
proto_tree_add_item(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.7 1999/03/22 03:56:33 guy Exp $
* $Id: packet-data.c,v 1.8 1999/03/23 03:14:36 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -28,23 +28,18 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
void
dissect_data(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (fd->cap_len > offset && tree) {
(void) add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
proto_tree_add_item(tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
}
}

View File

@ -1,7 +1,7 @@
/* packet-dns.c
* Routines for DNS packet disassembly
*
* $Id: packet-dns.c,v 1.16 1999/03/22 23:31:05 guy Exp $
* $Id: packet-dns.c,v 1.17 1999/03/23 03:14:36 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,21 +27,15 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include <stdio.h>
#include <string.h>
#include <memory.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "packet-dns.h"
#include "util.h"
@ -421,7 +415,7 @@ get_dns_name_type_class (const u_char *dns_data_ptr,
static int
dissect_dns_query(const u_char *dns_data_ptr, const u_char *pd, int offset,
GtkWidget *dns_tree)
proto_tree *dns_tree)
{
int len;
char name[MAXDNAME];
@ -433,7 +427,8 @@ dissect_dns_query(const u_char *dns_data_ptr, const u_char *pd, int offset,
char *long_type_name;
const u_char *dptr;
const u_char *data_start;
GtkWidget *q_tree, *tq;
proto_tree *q_tree;
proto_item *tq;
data_start = dptr = pd + offset;
@ -445,49 +440,49 @@ 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 = add_item_to_tree(dns_tree, offset, len, "%s: type %s, class %s",
tq = proto_tree_add_item(dns_tree, offset, len, "%s: type %s, class %s",
name, type_name, class_name);
q_tree = gtk_tree_new();
add_subtree(tq, q_tree, ETT_DNS_QD);
q_tree = proto_tree_new();
proto_item_add_subtree(tq, q_tree, ETT_DNS_QD);
add_item_to_tree(q_tree, offset, name_len, "Name: %s", name);
proto_tree_add_item(q_tree, offset, name_len, "Name: %s", name);
offset += name_len;
add_item_to_tree(q_tree, offset, 2, "Type: %s", long_type_name);
proto_tree_add_item(q_tree, offset, 2, "Type: %s", long_type_name);
offset += 2;
add_item_to_tree(q_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_item(q_tree, offset, 2, "Class: %s", class_name);
offset += 2;
return dptr - data_start;
}
GtkWidget *
add_rr_to_tree(GtkWidget *trr, int rr_type, int offset, const char *name,
proto_tree *
add_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
int namelen, const char *type_name, const char *class_name, u_int ttl,
u_short data_len)
{
GtkWidget *rr_tree;
proto_tree *rr_tree;
rr_tree = gtk_tree_new();
add_subtree(trr, rr_tree, rr_type);
add_item_to_tree(rr_tree, offset, namelen, "Name: %s", name);
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);
offset += namelen;
add_item_to_tree(rr_tree, offset, 2, "Type: %s", type_name);
proto_tree_add_item(rr_tree, offset, 2, "Type: %s", type_name);
offset += 2;
add_item_to_tree(rr_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_item(rr_tree, offset, 2, "Class: %s", class_name);
offset += 2;
add_item_to_tree(rr_tree, offset, 4, "Time to live: %s",
proto_tree_add_item(rr_tree, offset, 4, "Time to live: %s",
time_secs_to_str(ttl));
offset += 4;
add_item_to_tree(rr_tree, offset, 2, "Data length: %u", data_len);
proto_tree_add_item(rr_tree, offset, 2, "Data length: %u", data_len);
return rr_tree;
}
static int
dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
GtkWidget *dns_tree)
proto_tree *dns_tree)
{
int len;
char name[MAXDNAME];
@ -501,7 +496,8 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
const u_char *data_start;
u_int ttl;
u_short data_len;
GtkWidget *rr_tree, *trr;
proto_tree *rr_tree;
proto_item *trr;
data_start = dptr = pd + offset;
@ -521,14 +517,14 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
switch (type) {
case T_A: /* "A" record */
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, 4, "Addr: %s",
proto_tree_add_item(rr_tree, offset, 4, "Addr: %s",
ip_to_str((guint8 *)dptr));
break;
@ -538,13 +534,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, 0, ns_name, sizeof(ns_name));
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, ns_name_len, "Name server: %s", ns_name);
proto_tree_add_item(rr_tree, offset, ns_name_len, "Name server: %s", ns_name);
}
break;
@ -554,13 +550,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, 0, cname, sizeof(cname));
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, data_len, "Primary name: %s", cname);
proto_tree_add_item(rr_tree, offset, data_len, "Primary name: %s", cname);
}
break;
@ -570,13 +566,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, 0, pname, sizeof(pname));
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, data_len, "Domain name: %s", pname);
proto_tree_add_item(rr_tree, offset, data_len, "Domain name: %s", pname);
break;
}
break;
@ -584,13 +580,13 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
/* TODO: parse more record types */
default:
trr = add_item_to_tree(dns_tree, offset, (dptr - data_start) + data_len,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, data_len, "Data");
proto_tree_add_item(rr_tree, offset, data_len, "Data");
}
dptr += data_len;
@ -600,19 +596,19 @@ dissect_dns_answer(const u_char *dns_data_ptr, const u_char *pd, int offset,
static int
dissect_query_records(const u_char *dns_data_ptr, int count, const u_char *pd,
int cur_off, GtkWidget *dns_tree)
int cur_off, proto_tree *dns_tree)
{
int start_off;
GtkWidget *qatree, *ti;
proto_tree *qatree;
proto_item *ti;
start_off = cur_off;
ti = add_item_to_tree(GTK_WIDGET(dns_tree),
start_off, 0, "Queries");
qatree = gtk_tree_new();
add_subtree(ti, qatree, ETT_DNS_QRY);
ti = proto_tree_add_item(dns_tree, start_off, 0, "Queries");
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_DNS_QRY);
while (count-- > 0)
cur_off += dissect_dns_query(dns_data_ptr, pd, cur_off, qatree);
set_item_len(ti, cur_off - start_off);
proto_item_set_len(ti, cur_off - start_off);
return cur_off - start_off;
}
@ -621,29 +617,30 @@ dissect_query_records(const u_char *dns_data_ptr, int count, const u_char *pd,
static int
dissect_answer_records(const u_char *dns_data_ptr, int count,
const u_char *pd, int cur_off, GtkWidget *dns_tree,
const u_char *pd, int cur_off, proto_tree *dns_tree,
char *name)
{
int start_off;
GtkWidget *qatree, *ti;
proto_tree *qatree;
proto_item *ti;
start_off = cur_off;
ti = add_item_to_tree(GTK_WIDGET(dns_tree),
start_off, 0, name);
qatree = gtk_tree_new();
add_subtree(ti, qatree, ETT_DNS_ANS);
ti = proto_tree_add_item(dns_tree, start_off, 0, name);
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_DNS_ANS);
while (count-- > 0)
cur_off += dissect_dns_answer(dns_data_ptr, pd, cur_off, qatree);
set_item_len(ti, cur_off - start_off);
proto_item_set_len(ti, cur_off - start_off);
return cur_off - start_off;
}
void
dissect_dns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_dns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
const u_char *dns_data_ptr;
GtkWidget *dns_tree, *ti, *field_tree, *tf;
proto_tree *dns_tree, *field_tree;
proto_item *ti, *tf;
guint16 id, flags, quest, ans, auth, add;
char buf[128+1];
int cur_off;
@ -681,13 +678,13 @@ dissect_dns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 4,
ti = proto_tree_add_item(tree, offset, 4,
(flags & F_RESPONSE) ? "DNS response" : "DNS query");
dns_tree = gtk_tree_new();
add_subtree(ti, dns_tree, ETT_DNS);
dns_tree = proto_tree_new();
proto_item_add_subtree(ti, dns_tree, ETT_DNS);
add_item_to_tree(dns_tree, offset + DNS_ID, 2, "Transaction ID: 0x%04x",
proto_tree_add_item(dns_tree, offset + DNS_ID, 2, "Transaction ID: 0x%04x",
id);
strcpy(buf, val_to_str(flags & F_OPCODE, opcode_vals, "Unknown operation"));
@ -697,47 +694,47 @@ dissect_dns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
"Unknown error"));
}
tf = add_item_to_tree(dns_tree, offset + DNS_FLAGS, 2, "Flags: 0x%04x (%s)",
tf = proto_tree_add_item(dns_tree, offset + DNS_FLAGS, 2, "Flags: 0x%04x (%s)",
flags, buf);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_DNS_FLAGS);
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
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",
decode_boolean_bitfield(flags, F_RESPONSE,
2*8, "Response", "Query"));
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_enumerated_bitfield(flags, F_OPCODE,
2*8, opcode_vals, "%s"));
if (flags & F_RESPONSE) {
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(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"));
}
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_boolean_bitfield(flags, F_TRUNCATED,
2*8,
"Message is truncated",
"Message is not truncated"));
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(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) {
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(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"));
add_item_to_tree(field_tree, offset + DNS_FLAGS, 2, "%s",
proto_tree_add_item(field_tree, offset + DNS_FLAGS, 2, "%s",
decode_enumerated_bitfield(flags, F_RCODE,
2*8, rcode_vals, "%s"));
}
add_item_to_tree(dns_tree, offset + DNS_QUEST, 2, "Questions: %d", quest);
add_item_to_tree(dns_tree, offset + DNS_ANS, 2, "Answer RRs: %d", ans);
add_item_to_tree(dns_tree, offset + DNS_AUTH, 2, "Authority RRs: %d", auth);
add_item_to_tree(dns_tree, offset + DNS_ADD, 2, "Additional RRs: %d", add);
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);
cur_off = offset + DNS_HDRLEN;

View File

@ -2,7 +2,7 @@
* Definitions for packet disassembly structures and routines used both by
* DNS and NBNS.
*
* $Id: packet-dns.h,v 1.1 1998/10/14 20:03:03 gram Exp $
* $Id: packet-dns.h,v 1.2 1999/03/23 03:14:36 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -35,8 +35,8 @@ int get_dns_name(const u_char *dns_data_ptr, const u_char *pd, int offset,
#define MAXDNAME 1025 /* maximum domain name length */
GtkWidget *
add_rr_to_tree(GtkWidget *trr, int rr_type, int offset, const char *name,
proto_tree *
add_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
int namelen, const char *type_name, const char *class_name, u_int ttl,
u_short data_len);

View File

@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
* $Id: packet-eth.c,v 1.8 1999/02/09 00:35:36 guy Exp $
* $Id: packet-eth.c,v 1.9 1999/03/23 03:14:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,16 +31,13 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
#include "resolv.h"
#define IEEE_802_3_MAX_LEN 1500
/* These are the Netware-ish names for the different Ethernet frame types.
EthernetII: The ethernet with a Type field instead of a length field
Ethernet802.2: An 802.3 header followed by an 802.3 header
@ -96,10 +93,11 @@ capture_eth(const u_char *pd, guint32 cap_len, packet_counts *ld) {
}
void
dissect_eth(const u_char *pd, frame_data *fd, GtkTree *tree) {
dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
guint16 etype, length;
int offset = 14;
GtkWidget *fh_tree = NULL, *ti;
proto_tree *fh_tree = NULL;
proto_item *ti;
int ethhdr_type; /* the type of ethernet frame */
if (check_col(fd, COL_RES_DL_DST))
@ -137,30 +135,30 @@ dissect_eth(const u_char *pd, frame_data *fd, GtkTree *tree) {
if (check_col(fd, COL_INFO))
col_add_str(fd, COL_INFO, "802.3");
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), 0, offset,
ti = proto_tree_add_item(tree, 0, offset,
"IEEE 802.3 %s", (ethhdr_type == ETHERNET_802_3 ? "Raw " : ""));
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_IEEE8023);
add_item_to_tree(fh_tree, 0, 6, "Destination: %s (%s)",
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]));
add_item_to_tree(fh_tree, 6, 6, "Source: %s (%s)",
proto_tree_add_item(fh_tree, 6, 6, "Source: %s (%s)",
ether_to_str((guint8 *) &pd[6]),
get_ether_name((u_char *)&pd[6]));
add_item_to_tree(fh_tree, 12, 2, "Length: %d", length);
proto_tree_add_item(fh_tree, 12, 2, "Length: %d", length);
}
} else {
ethhdr_type = ETHERNET_II;
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), 0, 14, "Ethernet II");
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_ETHER2);
add_item_to_tree(fh_tree, 0, 6, "Destination: %s (%s)",
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]));
add_item_to_tree(fh_tree, 6, 6, "Source: %s (%s)",
proto_tree_add_item(fh_tree, 6, 6, "Source: %s (%s)",
ether_to_str((guint8 *) &pd[6]),
get_ether_name((u_char *)&pd[6]));
}

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
* $Id: packet-fddi.c,v 1.10 1999/03/02 20:50:05 gram Exp $
* $Id: packet-fddi.c,v 1.11 1999/03/23 03:14:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -33,12 +33,7 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "resolv.h"
@ -176,10 +171,11 @@ capture_fddi(const u_char *pd, guint32 cap_len, packet_counts *ld) {
} /* capture_fddi */
void dissect_fddi(const u_char *pd, frame_data *fd, GtkTree *tree)
void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
{
int offset = 0, fc;
GtkWidget *fh_tree, *ti;
proto_tree *fh_tree;
proto_item *ti;
u_char src[6], dst[6];
if (fd->cap_len < FDDI_HEADER_SIZE) {
@ -210,17 +206,17 @@ void dissect_fddi(const u_char *pd, frame_data *fd, GtkTree *tree)
offset = FDDI_HEADER_SIZE;
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), 0, offset,
ti = proto_tree_add_item(tree, 0, offset,
"FDDI %s",
(fc >= FDDI_FC_LLC_ASYNC_MIN && fc <= FDDI_FC_LLC_ASYNC_MAX) ?
"Async LLC" : "unsupported FC");
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_FDDI);
add_item_to_tree(fh_tree, FDDI_P_FC, 1, "Frame Control: 0x%02x", fc);
add_item_to_tree(fh_tree, FDDI_P_DHOST, 6, "Destination: %s (%s)",
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));
add_item_to_tree(fh_tree, FDDI_P_SHOST, 6, "Source: %s (%s)",
proto_tree_add_item(fh_tree, FDDI_P_SHOST, 6, "Source: %s (%s)",
ether_to_str(src), get_ether_name(src));
}

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
* $Id: packet-giop.c,v 1.1 1998/11/18 03:04:25 gerald Exp $
* $Id: packet-giop.c,v 1.2 1999/03/23 03:14:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,17 +31,13 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include "ethereal.h"
#include <string.h>
#include <ctype.h>
#include <glib.h>
#include "packet.h"
/*
@ -187,11 +183,12 @@ u_char *print_object_key(int length, u_char *from)
/* main entry point */
void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
MessageHeader header;
GtkWidget *clnp_tree = NULL, *ti;
proto_tree *clnp_tree = NULL;
proto_item *ti;
u_char response_expected = 0;
u_int first_offset = offset;
u_int big_endian = FALSE;
@ -261,27 +258,27 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset,
ti = proto_tree_add_item(tree, offset,
GIOP_HEADER_SIZE + message_size,
"General Inter-ORB Protocol");
clnp_tree = gtk_tree_new();
add_subtree(ti, clnp_tree, ETT_GIOP);
add_item_to_tree(clnp_tree, offset, 4,
clnp_tree = proto_tree_new();
proto_item_add_subtree(ti, clnp_tree, ETT_GIOP);
proto_tree_add_item(clnp_tree, offset, 4,
"Magic number: %s", GIOP_MAGIC);
add_item_to_tree(clnp_tree, offset + 4, 2,
proto_tree_add_item(clnp_tree, offset + 4, 2,
"Version: %d.%d",
header.GIOP_version.major,
header.GIOP_version.minor);
switch(minor_version) {
case 1 :
add_item_to_tree(clnp_tree, offset + 6, 1,
proto_tree_add_item(clnp_tree, offset + 6, 1,
"Flags: 0x%02x (%s%s)",
header.flags,
(big_endian) ? "little" : "big",
(header.flags & 0x02) ? " fragment" : "");
break;
case 0 :
add_item_to_tree(clnp_tree, offset + 6, 1,
proto_tree_add_item(clnp_tree, offset + 6, 1,
"Byte ordering: %s endian",
(big_endian) ? "little" : "big");
break;
@ -289,7 +286,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
break;
} /* minor_version */
add_item_to_tree(clnp_tree, offset + 7, 1,
proto_tree_add_item(clnp_tree, offset + 7, 1,
"Message type: %s",
(header.message_type == Request) ? "Request" :
(header.message_type == Reply) ? "Reply" :
@ -300,7 +297,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
(header.message_type == MessageError) ? "MessageError" :
(header.message_type == Fragment) ? "Fragment" : "?");
add_item_to_tree(clnp_tree, offset + 8, 4,
proto_tree_add_item(clnp_tree, offset + 8, 4,
"Message size: %d", message_size);
} /* tree */
@ -335,12 +332,12 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(context_id),
proto_tree_add_item(clnp_tree, offset, sizeof(context_id),
"Context id: %d", context_id);
add_item_to_tree(clnp_tree, offset + sizeof(context_id),
proto_tree_add_item(clnp_tree, offset + sizeof(context_id),
sizeof(sequence_length),
"Sequence length: %d", sequence_length);
add_item_to_tree(clnp_tree,
proto_tree_add_item(clnp_tree,
offset +
sizeof(context_id) + sizeof(sequence_length),
sequence_length,
@ -370,13 +367,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
request_id = (big_endian)? pntohl(&request_1_1.request_id) :
pletohl(&request_1_1.request_id);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
add_item_to_tree(clnp_tree, offset + sizeof(request_id),
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
sizeof(request_1_1.response_expected),
"Response expected: %d",
response_expected);
add_item_to_tree(clnp_tree, offset + sizeof(request_id) +
proto_tree_add_item(clnp_tree, offset + sizeof(request_id) +
sizeof(request_1_1.response_expected),
3,
"Reserved");
@ -390,9 +387,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
request_id = (big_endian)? pntohl(&request_1_0.request_id) :
pletohl(&request_1_0.request_id);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
add_item_to_tree(clnp_tree, offset + sizeof(request_id),
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
sizeof(request_1_0.response_expected),
"Response expected: %d",
response_expected);
@ -415,9 +412,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pntohl(&pd[offset]) : pletohl(&pd[offset]);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
"Object key length: %d", sequence_length);
add_item_to_tree(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Object key: %s",
print_object_key(sequence_length,
@ -438,13 +435,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
"Operation length: %d", sequence_length);
add_item_to_tree(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Operation: %s",
&pd[offset+sizeof(sequence_length)]);
add_item_to_tree(clnp_tree, offset +
proto_tree_add_item(clnp_tree, offset +
sizeof(sequence_length)+ sequence_length,
message_size - END_OF_GIOP_MESSAGE -
sizeof(sequence_length) - sequence_length,
@ -469,9 +466,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pntohl(&reply.reply_status) : pletohl(&reply.reply_status);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
add_item_to_tree(clnp_tree, offset + sizeof(request_id),
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
sizeof(reply_status),
"Reply status: %s",
reply_status == NO_EXCEPTION ? "no exception" :
@ -507,9 +504,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
"Exception length: %d", sequence_length);
add_item_to_tree(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception id: %s",
&pd[offset+sizeof(sequence_length)]);
@ -525,9 +522,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pletohl(&pd[offset+sizeof(minor_code_value)]);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(minor_code_value),
proto_tree_add_item(clnp_tree, offset, sizeof(minor_code_value),
"Minor code value: %d", minor_code_value);
add_item_to_tree(clnp_tree, offset + sizeof(minor_code_value),
proto_tree_add_item(clnp_tree, offset + sizeof(minor_code_value),
sizeof(completion_status),
"Completion Status: %d",
completion_status);
@ -546,9 +543,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
"Exception length: %d", sequence_length);
add_item_to_tree(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception id: %s",
&pd[offset+sizeof(sequence_length)]);
@ -566,9 +563,9 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree && sequence_length) {
add_item_to_tree(clnp_tree, offset, sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset, sizeof(sequence_length),
"Exception member length: %d", sequence_length);
add_item_to_tree(clnp_tree, offset + sizeof(sequence_length),
proto_tree_add_item(clnp_tree, offset + sizeof(sequence_length),
sequence_length,
"Exception member: %s",
&pd[offset+sizeof(sequence_length)]);
@ -580,7 +577,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
else {
if (tree) {
add_item_to_tree(clnp_tree, offset,
proto_tree_add_item(clnp_tree, offset,
message_size - END_OF_GIOP_MESSAGE,
"Reply body: <not shown>");
}
@ -600,13 +597,13 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pletohl(&pd[offset+sizeof(request_id)]);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
add_item_to_tree(clnp_tree, offset + sizeof(request_id),
proto_tree_add_item(clnp_tree, offset + sizeof(request_id),
sizeof(sequence_length),
"Object key length: %d", sequence_length);
offset += sizeof(request_id) + sizeof(sequence_length);
add_item_to_tree(clnp_tree,
proto_tree_add_item(clnp_tree,
offset,
sequence_length,
"Object key: %s",
@ -629,14 +626,14 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pntohl(&locate_rep.locate_status) : pletohl(&locate_rep.locate_status);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
add_item_to_tree(clnp_tree, offset + sizeof(request_id),
proto_tree_add_item(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) {
add_item_to_tree(clnp_tree, offset,
proto_tree_add_item(clnp_tree, offset,
message_size - END_OF_GIOP_MESSAGE,
"Locate reply body: <not shown>");
}
@ -658,7 +655,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
pntohl(&pd[offset]) : pletohl(&pd[offset]);
if (tree) {
add_item_to_tree(clnp_tree, offset, sizeof(request_id),
proto_tree_add_item(clnp_tree, offset, sizeof(request_id),
"Request id: %d", request_id);
}

View File

@ -3,7 +3,7 @@
*
* Guy Harris <guy@netapp.com>
*
* $Id: packet-http.c,v 1.1 1999/02/12 09:03:40 guy Exp $
* $Id: packet-http.c,v 1.2 1999/03/23 03:14:37 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -29,28 +29,22 @@
#include "config.h"
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include <string.h>
#include <ctype.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
static int is_http_request_or_reply(const u_char *data, int linelen);
void dissect_http(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
GtkWidget *http_tree, *ti;
proto_tree *http_tree;
proto_item *ti;
const u_char *data, *dataend;
const u_char *linep, *lineend;
int linelen;
@ -76,11 +70,10 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset,
END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"Hypertext Transfer Protocol");
http_tree = gtk_tree_new();
add_subtree(ti, http_tree, ETT_HTTP);
http_tree = proto_tree_new();
proto_item_add_subtree(ti, http_tree, ETT_HTTP);
while (data < dataend) {
/*
@ -167,14 +160,14 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
/*
* Put this line.
*/
add_item_to_tree(http_tree, offset, linelen, "%s",
proto_tree_add_item(http_tree, offset, linelen, "%s",
format_line(data, linelen));
offset += linelen;
data = lineend;
}
if (data < dataend) {
add_item_to_tree(http_tree, offset, END_OF_FRAME,
proto_tree_add_item(http_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
}
}

View File

@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
* $Id: packet-ip.c,v 1.17 1999/03/09 02:52:37 guy Exp $
* $Id: packet-ip.c,v 1.18 1999/03/23 03:14:38 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,10 +27,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -39,14 +35,160 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "packet.h"
#include "etypes.h"
#include "resolv.h"
#include "util.h"
#ifndef __PACKET_IP_H__
#include "packet-ip.h"
#endif
extern packet_info pi;
/* ICMP structs and definitions */
typedef struct _e_icmp {
guint8 icmp_type;
guint8 icmp_code;
guint16 icmp_cksum;
union {
struct { /* Address mask request/reply */
guint16 id;
guint16 seq;
guint32 sn_mask;
} am;
struct { /* Timestap request/reply */
guint16 id;
guint16 seq;
guint32 orig;
guint32 recv;
guint32 xmit;
} ts;
guint32 zero; /* Unreachable */
} opt;
} e_icmp;
#define ICMP_ECHOREPLY 0
#define ICMP_UNREACH 3
#define ICMP_SOURCEQUENCH 4
#define ICMP_REDIRECT 5
#define ICMP_ECHO 8
#define ICMP_TIMXCEED 11
#define ICMP_PARAMPROB 12
#define ICMP_TSTAMP 13
#define ICMP_TSTAMPREPLY 14
#define ICMP_IREQ 15
#define ICMP_IREQREPLY 16
#define ICMP_MASKREQ 17
#define ICMP_MASKREPLY 18
/* IGMP structs and definitions */
typedef struct _e_igmp {
guint8 igmp_v_t; /* combines igmp_v and igmp_t */
guint8 igmp_unused;
guint16 igmp_cksum;
guint32 igmp_gaddr;
} e_igmp;
#define IGMP_M_QRY 0x01
#define IGMP_V1_M_RPT 0x02
#define IGMP_V2_LV_GRP 0x07
#define IGMP_DVMRP 0x03
#define IGMP_PIM 0x04
#define IGMP_V2_M_RPT 0x06
#define IGMP_MTRC_RESP 0x1e
#define IGMP_MTRC 0x1f
/* IP structs and definitions */
typedef struct _e_ip {
guint8 ip_v_hl; /* combines ip_v and ip_hl */
guint8 ip_tos;
guint16 ip_len;
guint16 ip_id;
guint16 ip_off;
guint8 ip_ttl;
guint8 ip_p;
guint16 ip_sum;
guint32 ip_src;
guint32 ip_dst;
} e_ip;
/* IP flags. */
#define IP_CE 0x8000 /* Flag: "Congestion" */
#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
#define IP_MF 0x2000 /* Flag: "More Fragments" */
#define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_NONE 0x00
#define IPTOS_LOWCOST 0x02
#define IPTOS_RELIABILITY 0x04
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_LOWDELAY 0x10
#define IPTOS_SECURITY 0x1E
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/* IP options */
#define IPOPT_COPY 0x80
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_MEASUREMENT 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_END (0 |IPOPT_CONTROL)
#define IPOPT_NOOP (1 |IPOPT_CONTROL)
#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
#define IPOPT_RR (7 |IPOPT_CONTROL)
#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
/* IP option lengths */
#define IPOLEN_SEC 11
#define IPOLEN_LSRR_MIN 3
#define IPOLEN_TIMESTAMP_MIN 5
#define IPOLEN_RR_MIN 3
#define IPOLEN_SID 4
#define IPOLEN_SSRR_MIN 3
#define IPSEC_UNCLASSIFIED 0x0000
#define IPSEC_CONFIDENTIAL 0xF135
#define IPSEC_EFTO 0x789A
#define IPSEC_MMMM 0xBC4D
#define IPSEC_RESTRICTED 0xAF13
#define IPSEC_SECRET 0xD788
#define IPSEC_TOPSECRET 0x6BC5
#define IPSEC_RESERVED1 0x35E2
#define IPSEC_RESERVED2 0x9AF1
#define IPSEC_RESERVED3 0x4D78
#define IPSEC_RESERVED4 0x24BD
#define IPSEC_RESERVED5 0x135E
#define IPSEC_RESERVED6 0x89AF
#define IPSEC_RESERVED7 0xC4D6
#define IPSEC_RESERVED8 0xE26B
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
void
capture_ip(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
switch (pd[offset + 9]) {
@ -65,10 +207,11 @@ capture_ip(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
}
static void
dissect_ipopt_security(GtkWidget *opt_tree, const char *name,
dissect_ipopt_security(proto_tree *opt_tree, const char *name,
const u_char *opd, int offset, guint optlen)
{
GtkWidget *field_tree = NULL, *tf;
proto_tree *field_tree = NULL;
proto_item *tf;
guint val;
static const value_string secl_vals[] = {
{IPSEC_UNCLASSIFIED, "Unclassified"},
@ -88,51 +231,52 @@ dissect_ipopt_security(GtkWidget *opt_tree, const char *name,
{IPSEC_RESERVED8, "Reserved" },
{0, NULL } };
tf = add_item_to_tree(opt_tree, offset, optlen, "%s:", name);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_OPTION_SEC);
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);
offset += 2;
val = pntohs(opd);
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(field_tree, offset, 2,
"Security: %s", val_to_str(val, secl_vals, "Unknown (0x%x)"));
offset += 2;
opd += 2;
val = pntohs(opd);
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(field_tree, offset, 2,
"Compartments: %d", val);
offset += 2;
opd += 2;
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(field_tree, offset, 2,
"Handling restrictions: %c%c", opd[0], opd[1]);
offset += 2;
opd += 2;
add_item_to_tree(field_tree, offset, 3,
proto_tree_add_item(field_tree, offset, 3,
"Transmission control code: %c%c%c", opd[0], opd[1], opd[2]);
}
static void
dissect_ipopt_route(GtkWidget *opt_tree, const char *name,
dissect_ipopt_route(proto_tree *opt_tree, const char *name,
const u_char *opd, int offset, guint optlen)
{
GtkWidget *field_tree = NULL, *tf;
proto_tree *field_tree = NULL;
proto_item *tf;
int ptr;
int optoffset = 0;
struct in_addr addr;
tf = add_item_to_tree(opt_tree, offset, optlen, "%s (%d bytes)", name,
tf = proto_tree_add_item(opt_tree, offset, optlen, "%s (%d bytes)", name,
optlen);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_OPTION_ROUTE);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTION_ROUTE);
optoffset += 2; /* skip past type and length */
optlen -= 2; /* subtract size of type and length */
ptr = *opd;
add_item_to_tree(field_tree, offset + optoffset, 1,
proto_tree_add_item(field_tree, offset + optoffset, 1,
"Pointer: %d%s", ptr,
((ptr < 4) ? " (points before first address)" :
((ptr & 3) ? " (points to middle of address)" : "")));
@ -143,7 +287,7 @@ dissect_ipopt_route(GtkWidget *opt_tree, const char *name,
while (optlen > 0) {
if (optlen < 4) {
add_item_to_tree(field_tree, offset, optlen,
proto_tree_add_item(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -151,7 +295,7 @@ dissect_ipopt_route(GtkWidget *opt_tree, const char *name,
/* Avoids alignment problems on many architectures. */
memcpy((char *)&addr, (char *)opd, sizeof(addr));
add_item_to_tree(field_tree, offset + optoffset, 4,
proto_tree_add_item(field_tree, offset + optoffset, 4,
"%s%s",
((addr.s_addr == 0) ? "-" : (char *)get_hostname(addr.s_addr)),
((optoffset == ptr) ? " <- (current)" : ""));
@ -162,19 +306,20 @@ dissect_ipopt_route(GtkWidget *opt_tree, const char *name,
}
static void
dissect_ipopt_sid(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_ipopt_sid(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(opt_tree, offset, optlen,
"%s: %d", name, pntohs(opd));
return;
}
static void
dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_ipopt_timestamp(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
GtkWidget *field_tree = NULL, *tf;
proto_tree *field_tree = NULL;
proto_item *tf;
int ptr;
int optoffset = 0;
int flg;
@ -187,15 +332,15 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
struct in_addr addr;
guint ts;
tf = add_item_to_tree(opt_tree, offset, optlen, "%s:", name);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_OPTION_TIMESTAMP);
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);
optoffset += 2; /* skip past type and length */
optlen -= 2; /* subtract size of type and length */
ptr = *opd;
add_item_to_tree(field_tree, offset + optoffset, 1,
proto_tree_add_item(field_tree, offset + optoffset, 1,
"Pointer: %d%s", ptr,
((ptr < 5) ? " (points before first address)" :
(((ptr - 1) & 3) ? " (points to middle of address)" : "")));
@ -205,10 +350,10 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
ptr--; /* ptr is 1-origin */
flg = *opd;
add_item_to_tree(field_tree, offset + optoffset, 1,
proto_tree_add_item(field_tree, offset + optoffset, 1,
"Overflow: %d", flg >> 4);
flg &= 0xF;
add_item_to_tree(field_tree, offset + optoffset, 1,
proto_tree_add_item(field_tree, offset + optoffset, 1,
"Flag: %s", val_to_str(flg, flag_vals, "Unknown (0x%x)"));
optoffset++;
opd++;
@ -217,7 +362,7 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
while (optlen > 0) {
if (flg == IPOPT_TS_TSANDADDR) {
if (optlen < 4) {
add_item_to_tree(field_tree, offset + optoffset, optlen,
proto_tree_add_item(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -226,7 +371,7 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
opd += 4;
optlen -= 4;
if (optlen < 4) {
add_item_to_tree(field_tree, offset + optoffset, optlen,
proto_tree_add_item(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -234,14 +379,14 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
memcpy((char *)&addr, (char *)opd, sizeof(addr));
opd += 4;
optlen -= 4;
add_item_to_tree(field_tree, offset, 8,
proto_tree_add_item(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) {
add_item_to_tree(field_tree, offset + optoffset, optlen,
proto_tree_add_item(field_tree, offset + optoffset, optlen,
"(suboption would go past end of option)");
break;
}
@ -249,7 +394,7 @@ dissect_ipopt_timestamp(GtkWidget *opt_tree, const char *name, const u_char *opd
ts = pntohl(opd);
opd += 4;
optlen -= 4;
add_item_to_tree(field_tree, offset + optoffset, 4,
proto_tree_add_item(field_tree, offset + optoffset, 4,
"Time stamp = %u", ts);
optoffset += 4;
}
@ -319,7 +464,7 @@ static ip_tcp_opt ipopts[] = {
/* Dissect the IP or TCP options in a packet. */
void
dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
dissect_ip_tcp_options(proto_tree *opt_tree, const u_char *opd, int offset,
guint length, ip_tcp_opt *opttab, int nopts, int eol)
{
u_char opt;
@ -333,7 +478,7 @@ dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
break;
}
if (optp == &opttab[nopts]) {
add_item_to_tree(opt_tree, offset, 1, "Unknown");
proto_tree_add_item(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;
@ -344,7 +489,7 @@ dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
if (length == 0) {
/* Bogus - packet must at least include option code byte and
length byte! */
add_item_to_tree(opt_tree, offset, 1,
proto_tree_add_item(opt_tree, offset, 1,
"%s (length byte past end of header)", optp->name);
return;
}
@ -353,25 +498,25 @@ dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
if (len < 2) {
/* Bogus - option length is too short to include option code and
option length. */
add_item_to_tree(opt_tree, offset, 2,
proto_tree_add_item(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. */
add_item_to_tree(opt_tree, offset, length,
proto_tree_add_item(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. */
add_item_to_tree(opt_tree, offset, len,
proto_tree_add_item(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. */
add_item_to_tree(opt_tree, offset, len,
proto_tree_add_item(opt_tree, offset, len,
"%s (with option length = %u bytes; should be >= %u)", optp->name,
len, optp->optlen);
return;
@ -381,7 +526,7 @@ dissect_ip_tcp_options(GtkWidget *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. */
add_item_to_tree(opt_tree, offset, len, "%s", optp->name);
proto_tree_add_item(opt_tree, offset, len, "%s", optp->name);
}
len -= 2; /* subtract size of type and length */
offset += 2 + len;
@ -389,7 +534,7 @@ dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
opd += len;
length -= len;
} else {
add_item_to_tree(opt_tree, offset, 1, "%s", optp->name);
proto_tree_add_item(opt_tree, offset, 1, "%s", optp->name);
offset += 1;
}
if (opt == eol)
@ -398,9 +543,10 @@ dissect_ip_tcp_options(GtkWidget *opt_tree, const u_char *opd, int offset,
}
void
dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ip iph;
GtkWidget *ip_tree, *ti, *field_tree, *tf;
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"},
@ -480,56 +626,56 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, hlen, "Internet Protocol");
ip_tree = gtk_tree_new();
add_subtree(ti, ip_tree, ETT_IP);
add_item_to_tree(ip_tree, offset, 1, "Version: %d", hi_nibble(iph.ip_v_hl));
add_item_to_tree(ip_tree, offset, 1, "Header length: %d bytes", hlen);
tf = add_item_to_tree(ip_tree, offset + 1, 1, "Type of service: 0x%02x (%s)",
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 = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_TOS);
add_item_to_tree(field_tree, offset + 1, 1, "%s",
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"));
add_item_to_tree(field_tree, offset + 1, 1, "%s",
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_LOWDELAY,
sizeof (iph.ip_tos)*8, "low delay", "normal delay"));
add_item_to_tree(field_tree, offset + 1, 1, "%s",
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_THROUGHPUT,
sizeof (iph.ip_tos)*8, "high throughput", "normal throughput"));
add_item_to_tree(field_tree, offset + 1, 1, "%s",
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_RELIABILITY,
sizeof (iph.ip_tos)*8, "high reliability", "normal reliability"));
add_item_to_tree(field_tree, offset + 1, 1, "%s",
proto_tree_add_item(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_LOWCOST,
sizeof (iph.ip_tos)*8, "low cost", "normal cost"));
add_item_to_tree(ip_tree, offset + 2, 2, "Total length: %d", iph.ip_len);
add_item_to_tree(ip_tree, offset + 4, 2, "Identification: 0x%04x",
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",
iph.ip_id);
tf = add_item_to_tree(ip_tree, offset + 6, 2, "Flags: 0x%x",
tf = proto_tree_add_item(ip_tree, offset + 6, 2, "Flags: 0x%x",
(iph.ip_off & (IP_DF|IP_MF)) >> 12);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_OFF);
add_item_to_tree(field_tree, offset + 6, 2, "%s",
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",
decode_boolean_bitfield(iph.ip_off >> 8, IP_DF >> 8, 8, "don't fragment",
"may fragment"));
add_item_to_tree(field_tree, offset + 6, 2, "%s",
proto_tree_add_item(field_tree, offset + 6, 2, "%s",
decode_boolean_bitfield(iph.ip_off >> 8, IP_MF >> 8, 8, "more fragments",
"last fragment"));
add_item_to_tree(ip_tree, offset + 6, 2, "Fragment offset: %d",
proto_tree_add_item(ip_tree, offset + 6, 2, "Fragment offset: %d",
iph.ip_off & IP_OFFSET);
add_item_to_tree(ip_tree, offset + 8, 1, "Time to live: %d",
proto_tree_add_item(ip_tree, offset + 8, 1, "Time to live: %d",
iph.ip_ttl);
add_item_to_tree(ip_tree, offset + 9, 1, "Protocol: %s",
proto_tree_add_item(ip_tree, offset + 9, 1, "Protocol: %s",
val_to_str(iph.ip_p, proto_vals, "Unknown (%x)"));
add_item_to_tree(ip_tree, offset + 10, 2, "Header checksum: 0x%04x",
proto_tree_add_item(ip_tree, offset + 10, 2, "Header checksum: 0x%04x",
iph.ip_sum);
add_item_to_tree(ip_tree, offset + 12, 4, "Source address: %s (%s)",
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));
add_item_to_tree(ip_tree, offset + 16, 4, "Destination address: %s (%s)",
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));
@ -538,10 +684,10 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
/* There's more than just the fixed-length header. Decode the
options. */
optlen = hlen - sizeof (e_ip); /* length of options, in bytes */
tf = add_item_to_tree(ip_tree, offset + 20, optlen,
tf = proto_tree_add_item(ip_tree, offset + 20, optlen,
"Options: (%d bytes)", optlen);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_IP_OPTIONS);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_IP_OPTIONS);
dissect_ip_tcp_options(field_tree, &pd[offset + 20], offset + 20, optlen,
ipopts, N_IP_OPTS, IPOPT_END);
}
@ -607,9 +753,10 @@ static const gchar *par_str[] = {"IP header bad", "Required option missing"};
#define N_PARAMPROB (sizeof par_str / sizeof par_str[0])
void
dissect_icmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_icmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_icmp ih;
GtkWidget *icmp_tree, *ti;
proto_tree *icmp_tree;
proto_item *ti;
guint16 cksum;
gchar type_str[64], code_str[64] = "";
@ -688,15 +835,15 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, type_str);
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 4,
ti = proto_tree_add_item(tree, offset, 4,
"Internet Control Message Protocol");
icmp_tree = gtk_tree_new();
add_subtree(ti, icmp_tree, ETT_ICMP);
add_item_to_tree(icmp_tree, offset, 1, "Type: %d (%s)",
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)",
ih.icmp_type, type_str);
add_item_to_tree(icmp_tree, offset + 1, 1, "Code: %d %s",
proto_tree_add_item(icmp_tree, offset + 1, 1, "Code: %d %s",
ih.icmp_code, code_str);
add_item_to_tree(icmp_tree, offset + 2, 2, "Checksum: 0x%04x",
proto_tree_add_item(icmp_tree, offset + 2, 2, "Checksum: 0x%04x",
ih.icmp_cksum);
/* Decode the second 4 byte of the packet. */
@ -709,19 +856,19 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
case ICMP_IREQREPLY:
case ICMP_MASKREQ:
case ICMP_MASKREPLY:
add_item_to_tree(icmp_tree, offset + 4, 2, "Identifier: 0x%04x",
proto_tree_add_item(icmp_tree, offset + 4, 2, "Identifier: 0x%04x",
pntohs(&pd[offset + 4]));
add_item_to_tree(icmp_tree, offset + 6, 2, "Sequence number: %u",
proto_tree_add_item(icmp_tree, offset + 6, 2, "Sequence number: %u",
pntohs(&pd[offset + 6]));
break;
case ICMP_PARAMPROB:
add_item_to_tree(icmp_tree, offset + 4, 1, "Pointer: %u",
proto_tree_add_item(icmp_tree, offset + 4, 1, "Pointer: %u",
pd[offset + 4]);
break;
case ICMP_REDIRECT:
add_item_to_tree(icmp_tree, offset + 4, 4, "Gateway address: %s",
proto_tree_add_item(icmp_tree, offset + 4, 4, "Gateway address: %s",
ip_to_str((guint8 *)&pd[offset + 4]));
break;
}
@ -738,29 +885,29 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
XXX - for now, just display it as data; not all dissection
routines can handle a short packet without exploding. */
dissect_data(pd, offset + 8, fd, (GtkTree *)icmp_tree);
dissect_data(pd, offset + 8, fd, icmp_tree);
break;
case ICMP_ECHOREPLY:
case ICMP_ECHO:
dissect_data(pd, offset + 8, fd, (GtkTree *)icmp_tree);
dissect_data(pd, offset + 8, fd, icmp_tree);
break;
case ICMP_TSTAMP:
case ICMP_TSTAMPREPLY:
add_item_to_tree(icmp_tree, offset + 8, 4, "Originate timestamp: %u",
proto_tree_add_item(icmp_tree, offset + 8, 4, "Originate timestamp: %u",
pntohl(&pd[offset + 8]));
add_item_to_tree(icmp_tree, offset + 12, 4, "Originate timestamp: %u",
proto_tree_add_item(icmp_tree, offset + 12, 4, "Originate timestamp: %u",
pntohl(&pd[offset + 12]));
add_item_to_tree(icmp_tree, offset + 16, 4, "Receive timestamp: %u",
proto_tree_add_item(icmp_tree, offset + 16, 4, "Receive timestamp: %u",
pntohl(&pd[offset + 16]));
add_item_to_tree(icmp_tree, offset + 20, 4, "Transmit timestamp: %u",
proto_tree_add_item(icmp_tree, offset + 20, 4, "Transmit timestamp: %u",
pntohl(&pd[offset + 20]));
break;
case ICMP_MASKREQ:
case ICMP_MASKREPLY:
add_item_to_tree(icmp_tree, offset + 8, 4, "Address mask: %s (0x%8x)",
proto_tree_add_item(icmp_tree, offset + 8, 4, "Address mask: %s (0x%8x)",
ip_to_str((guint8 *)&pd[offset + 8]), pntohl(&pd[offset + 8]));
break;
}
@ -768,9 +915,10 @@ dissect_icmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
void
dissect_igmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_igmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_igmp ih;
GtkWidget *igmp_tree, *ti;
proto_tree *igmp_tree;
proto_item *ti;
guint16 cksum;
gchar type_str[64] = "";
@ -814,19 +962,19 @@ dissect_igmp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, type_str);
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 4,
ti = proto_tree_add_item(tree, offset, 4,
"Internet Group Management Protocol");
igmp_tree = gtk_tree_new();
add_subtree(ti, igmp_tree, ETT_IGMP);
add_item_to_tree(igmp_tree, offset, 1, "Version: %d",
igmp_tree = proto_tree_new();
proto_item_add_subtree(ti, igmp_tree, ETT_IGMP);
proto_tree_add_item(igmp_tree, offset, 1, "Version: %d",
hi_nibble(ih.igmp_v_t));
add_item_to_tree(igmp_tree, offset , 1, "Type: %d (%s)",
proto_tree_add_item(igmp_tree, offset , 1, "Type: %d (%s)",
lo_nibble(ih.igmp_v_t), type_str);
add_item_to_tree(igmp_tree, offset + 1, 1, "Unused: 0x%02x",
proto_tree_add_item(igmp_tree, offset + 1, 1, "Unused: 0x%02x",
ih.igmp_unused);
add_item_to_tree(igmp_tree, offset + 2, 2, "Checksum: 0x%04x",
proto_tree_add_item(igmp_tree, offset + 2, 2, "Checksum: 0x%04x",
ih.igmp_cksum);
add_item_to_tree(igmp_tree, offset + 4, 4, "Group address: %s",
proto_tree_add_item(igmp_tree, offset + 4, 4, "Group address: %s",
ip_to_str((guint8 *) &ih.igmp_gaddr));
}
}

56
packet-ip.h Normal file
View File

@ -0,0 +1,56 @@
/* packet-ip.h
* Definitions for IP packet disassembly structures and routines
*
* $Id: packet-ip.h,v 1.1 1999/03/23 03:14:38 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 __PACKET_IP_H__
#define __PACKET_IP_H__
#define IP_PROTO_ICMP 1
#define IP_PROTO_IGMP 2
#define IP_PROTO_TCP 6
#define IP_PROTO_UDP 17
#define IP_PROTO_OSPF 89
typedef enum {
NO_LENGTH, /* option has no data, hence no length */
FIXED_LENGTH, /* option always has the same length */
VARIABLE_LENGTH /* option is variable-length - optlen is minimum */
} opt_len_type;
/* Member of table of IP or TCP options. */
typedef struct {
int optcode; /* code for option */
char *name; /* name of option */
opt_len_type len_type; /* type of option length field */
int optlen; /* value length should be (minimum if VARIABLE) */
void (*dissect)(proto_tree *, const char *, const u_char *, int, guint);
/* routine to dissect option */
} ip_tcp_opt;
/* Routine to dissect IP or TCP options. */
void dissect_ip_tcp_options(proto_tree *, const u_char *, int, guint,
ip_tcp_opt *, int, int);
#endif

View File

@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
* $Id: packet-ipv6.c,v 1.5 1998/11/17 04:28:55 gerald Exp $
* $Id: packet-ipv6.c,v 1.6 1999/03/23 03:14:38 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,10 +27,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -39,14 +35,16 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "packet-ip.h"
#include "packet-ipv6.h"
#include "etypes.h"
void
dissect_ipv6(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
GtkWidget *ipv6_tree, *ti;
dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree *ipv6_tree;
proto_item *ti;
e_ipv6_header ipv6;
@ -71,15 +69,14 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
if (tree) {
/* !!! specify length */
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 40,
"Internet Protocol Version 6");
ipv6_tree = gtk_tree_new();
add_subtree(ti, ipv6_tree, ETT_IPv6);
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);
/* !!! warning: version also contains 4 Bit priority */
add_item_to_tree(ipv6_tree, offset, 1, "Version: %d Priority: %d", ipv6.version >> 4 , ipv6.version & 15);
add_item_to_tree(ipv6_tree, offset + 6, 1, "Next Header: %d", ipv6.next_header);
add_item_to_tree(ipv6_tree, offset + 4, 2, "Payload Length: %d", ntohs(ipv6.payload_length));
proto_tree_add_item(ipv6_tree, offset, 1, "Version: %d Priority: %d", ipv6.version >> 4 , ipv6.version & 15);
proto_tree_add_item(ipv6_tree, offset + 6, 1, "Next Header: %d", ipv6.next_header);
proto_tree_add_item(ipv6_tree, offset + 4, 2, "Payload Length: %d", ntohs(ipv6.payload_length));
}
/* start of the new header (could be a extension header) */

View File

@ -2,7 +2,7 @@
* Routines for NetWare's IPX
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-ipx.c,v 1.17 1999/03/20 04:38:56 gram Exp $
* $Id: packet-ipx.c,v 1.18 1999/03/23 03:14:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -28,15 +28,12 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <glib.h>
#include "packet.h"
#include "packet-ipx.h"
#include "packet-ncp.h"
@ -53,17 +50,17 @@
*/
static void
dissect_spx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree);
dissect_spx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
static void
dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree);
dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
static void
dissect_sap(const u_char *pd, int offset, frame_data *fd, GtkTree *tree);
dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
struct port_info {
guint16 port;
void (*func) (const u_char *, int, frame_data *, GtkTree *);
void (*func) (const u_char *, int, frame_data *, proto_tree *);
char *text;
};
@ -181,16 +178,17 @@ ipx_addr_to_str(guint32 net, const guint8 *ad)
}
void
dissect_ipx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *ipx_tree, *ti;
proto_tree *ipx_tree;
proto_item *ti;
guint8 ipx_type, ipx_hops;
guint16 ipx_checksum, ipx_length;
guint8 *ipx_snode, *ipx_dnode, *ipx_snet, *ipx_dnet;
gchar *str_dnet, *str_snet;
guint16 ipx_dsocket, ipx_ssocket;
void (*dissect) (const u_char *, int, frame_data *, GtkTree *);
void (*dissect) (const u_char *, int, frame_data *, proto_tree *);
/* Calculate here for use in pinfo and in tree */
ipx_dnet = (guint8*)&pd[offset+6];
@ -221,30 +219,30 @@ dissect_ipx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
ipx_length = pntohs(&pd[offset+2]);
ipx_hops = pd[offset+4];
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 30,
ti = proto_tree_add_item(tree, offset, 30,
"Internetwork Packet Exchange");
ipx_tree = gtk_tree_new();
add_subtree(ti, ipx_tree, ETT_IPX);
add_item_to_tree(ipx_tree, offset, 2, "Checksum: 0x%04x",
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_checksum);
add_item_to_tree(ipx_tree, offset+2, 2, "Length: %d bytes",
proto_tree_add_item(ipx_tree, offset+2, 2, "Length: %d bytes",
ipx_length);
add_item_to_tree(ipx_tree, offset+4, 1, "Transport Control: %d hops",
proto_tree_add_item(ipx_tree, offset+4, 1, "Transport Control: %d hops",
ipx_hops);
add_item_to_tree(ipx_tree, offset+5, 1, "Packet Type: %s",
proto_tree_add_item(ipx_tree, offset+5, 1, "Packet Type: %s",
ipx_packet_type(ipx_type));
add_item_to_tree(ipx_tree, offset+6, 4, "Destination Network: %s",
proto_tree_add_item(ipx_tree, offset+6, 4, "Destination Network: %s",
str_dnet);
add_item_to_tree(ipx_tree, offset+10, 6, "Destination Node: %s",
proto_tree_add_item(ipx_tree, offset+10, 6, "Destination Node: %s",
ether_to_str(ipx_dnode));
add_item_to_tree(ipx_tree, offset+16, 2,
proto_tree_add_item(ipx_tree, offset+16, 2,
"Destination Socket: %s (0x%04X)", port_text(ipx_dsocket),
ipx_dsocket);
add_item_to_tree(ipx_tree, offset+18, 4, "Source Network: %s",
proto_tree_add_item(ipx_tree, offset+18, 4, "Source Network: %s",
str_snet);
add_item_to_tree(ipx_tree, offset+22, 6, "Source Node: %s",
proto_tree_add_item(ipx_tree, offset+22, 6, "Source Node: %s",
ether_to_str(ipx_snode));
add_item_to_tree(ipx_tree, offset+28, 2,
proto_tree_add_item(ipx_tree, offset+28, 2,
"Source Socket: %s (0x%04X)", port_text(ipx_ssocket), ipx_ssocket);
}
offset += 30;
@ -330,9 +328,10 @@ spx_datastream(u_char type)
}
static void
dissect_spx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_spx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *spx_tree, *ti;
proto_tree *spx_tree;
proto_item *ti;
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "SPX");
@ -340,32 +339,31 @@ dissect_spx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, "SPX");
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 12,
"Sequenced Packet Exchange");
spx_tree = gtk_tree_new();
add_subtree(ti, spx_tree, ETT_SPX);
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);
add_item_to_tree(spx_tree, offset, 1,
proto_tree_add_item(spx_tree, offset, 1,
"Connection Control: %s (0x%02X)",
spx_conn_ctrl(pd[offset]), pd[offset]);
add_item_to_tree(spx_tree, offset+1, 1,
proto_tree_add_item(spx_tree, offset+1, 1,
"Datastream Type: %s (0x%02X)",
spx_datastream(pd[offset+1]), pd[offset+1]);
add_item_to_tree(spx_tree, offset+2, 2,
proto_tree_add_item(spx_tree, offset+2, 2,
"Source Connection ID: %d", pntohs( &pd[offset+2] ) );
add_item_to_tree(spx_tree, offset+4, 2,
proto_tree_add_item(spx_tree, offset+4, 2,
"Destination Connection ID: %d", pntohs( &pd[offset+4] ) );
add_item_to_tree(spx_tree, offset+6, 2,
proto_tree_add_item(spx_tree, offset+6, 2,
"Sequence Number: %d", pntohs( &pd[offset+6] ) );
add_item_to_tree(spx_tree, offset+8, 2,
proto_tree_add_item(spx_tree, offset+8, 2,
"Acknowledgment Number: %d", pntohs( &pd[offset+8] ) );
add_item_to_tree(spx_tree, offset+10, 2,
proto_tree_add_item(spx_tree, offset+10, 2,
"Allocation Number: %d", pntohs( &pd[offset+10] ) );
offset += 12;
@ -377,9 +375,10 @@ dissect_spx(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
/* IPX RIP */
/* ================================================================= */
static void
dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *rip_tree, *ti;
proto_tree *rip_tree;
proto_item *ti;
guint16 operation;
struct ipx_rt_def route;
int cursor;
@ -400,17 +399,17 @@ dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"IPX Routing Information Protocol");
rip_tree = gtk_tree_new();
add_subtree(ti, rip_tree, ETT_IPXRIP);
rip_tree = proto_tree_new();
proto_item_add_subtree(ti, rip_tree, ETT_IPXRIP);
if (operation < 2) {
add_item_to_tree(rip_tree, offset, 2,
proto_tree_add_item(rip_tree, offset, 2,
"RIP packet type: %s", rip_type[operation]);
}
else {
add_item_to_tree(rip_tree, offset, 2, "Unknown RIP packet type");
proto_tree_add_item(rip_tree, offset, 2, "Unknown RIP packet type");
}
for (cursor = offset + 2; cursor < fd->cap_len; cursor += 8) {
@ -419,14 +418,14 @@ dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
route.ticks = pntohs(&pd[cursor+6]);
if (operation == IPX_RIP_REQUEST - 1) {
add_item_to_tree(rip_tree, cursor, 8,
proto_tree_add_item(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 {
add_item_to_tree(rip_tree, cursor, 8,
proto_tree_add_item(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",
@ -495,9 +494,10 @@ server_type(guint16 type)
}
static void
dissect_sap(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *sap_tree, *s_tree, *ti;
proto_tree *sap_tree, *s_tree;
proto_item *ti;
int cursor;
struct sap_query query;
struct sap_server_ident server;
@ -520,16 +520,16 @@ dissect_sap(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"Service Advertising Protocol");
sap_tree = gtk_tree_new();
add_subtree(ti, sap_tree, ETT_IPXSAP);
sap_tree = proto_tree_new();
proto_item_add_subtree(ti, sap_tree, ETT_IPXSAP);
if (query.query_type < 4) {
add_item_to_tree(sap_tree, offset, 2, sap_type[query.query_type - 1]);
proto_tree_add_item(sap_tree, offset, 2, sap_type[query.query_type - 1]);
}
else {
add_item_to_tree(sap_tree, offset, 2,
proto_tree_add_item(sap_tree, offset, 2,
"Unknown SAP Packet Type %d", query.query_type);
}
@ -544,26 +544,26 @@ dissect_sap(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
server.server_port = pntohs(&pd[cursor+60]);
server.intermediate_network = pntohs(&pd[cursor+62]);
ti = add_item_to_tree(GTK_WIDGET(sap_tree), cursor+2, 48,
ti = proto_tree_add_item(sap_tree, cursor+2, 48,
"Server Name: %s", server.server_name);
s_tree = gtk_tree_new();
add_subtree(ti, s_tree, ETT_IPXSAP_SERVER);
s_tree = proto_tree_new();
proto_item_add_subtree(ti, s_tree, ETT_IPXSAP_SERVER);
add_item_to_tree(s_tree, cursor, 2, "Server Type: %s (0x%04X)",
proto_tree_add_item(s_tree, cursor, 2, "Server Type: %s (0x%04X)",
server_type(server.server_type), server.server_type);
add_item_to_tree(s_tree, cursor+50, 4, "Network: %s",
proto_tree_add_item(s_tree, cursor+50, 4, "Network: %s",
ipxnet_to_string((guint8*)&pd[cursor+50]));
add_item_to_tree(s_tree, cursor+54, 6, "Node: %s",
proto_tree_add_item(s_tree, cursor+54, 6, "Node: %s",
ether_to_str((guint8*)&pd[cursor+54]));
add_item_to_tree(s_tree, cursor+60, 2, "Socket: %s (0x%04X)",
proto_tree_add_item(s_tree, cursor+60, 2, "Socket: %s (0x%04X)",
port_text(server.server_port), server.server_port);
add_item_to_tree(s_tree, cursor+62, 2,
proto_tree_add_item(s_tree, cursor+62, 2,
"Intermediate Networks: %d",
server.intermediate_network);
}
}
else { /* queries */
add_item_to_tree(sap_tree, offset+2, 2, "Server Type: %s (0x%04X)",
proto_tree_add_item(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 IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-llc.c,v 1.13 1999/03/22 03:56:34 guy Exp $
* $Id: packet-llc.c,v 1.14 1999/03/23 03:14:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -32,17 +32,11 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
typedef void (capture_func_t)(const u_char *, int, guint32, packet_counts *);
typedef void (dissect_func_t)(const u_char *, int, frame_data *, GtkTree *);
typedef void (dissect_func_t)(const u_char *, int, frame_data *, proto_tree *);
struct sap_info {
guint8 sap;
@ -164,9 +158,10 @@ capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
}
void
dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *llc_tree = NULL, *ti;
proto_tree *llc_tree = NULL;
proto_item *ti;
guint16 etype;
int is_snap;
dissect_func_t *dissect;
@ -183,15 +178,15 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (is_snap ? 8 : 3),
ti = proto_tree_add_item(tree, offset, (is_snap ? 8 : 3),
"Logical-Link Control");
llc_tree = gtk_tree_new();
add_subtree(ti, llc_tree, ETT_LLC);
add_item_to_tree(llc_tree, offset, 1, "DSAP: %s (0x%02X)",
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]);
add_item_to_tree(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
proto_tree_add_item(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
sap_text(pd[offset+1]), pd[offset+1]);
add_item_to_tree(llc_tree, offset+2, 1, "Control: %s",
proto_tree_add_item(llc_tree, offset+2, 1, "Control: %s",
llc_ctrl[pd[offset+2] & 3]);
}
@ -200,7 +195,7 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, "802.2 LLC (SNAP)");
}
if (tree) {
add_item_to_tree(llc_tree, offset+3, 3,
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]);

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.6 1998/12/17 05:42:28 gram Exp $
* $Id: packet-lpd.c,v 1.7 1999/03/23 03:14:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -28,31 +28,22 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include <string.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
enum lpr_type { request, response };
void
dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
GtkWidget *lpd_tree, *ti;
proto_tree *lpd_tree;
proto_item *ti;
enum lpr_type lpr_packet_type;
char *newline, *printer, *line_pos;
int substr_len, curr_offset;
@ -102,34 +93,34 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, fd->cap_len - offset,
ti = proto_tree_add_item(tree, offset, fd->cap_len - offset,
"Line Printer Daemon Protocol");
lpd_tree = gtk_tree_new();
add_subtree(ti, lpd_tree, ETT_LPD);
lpd_tree = proto_tree_new();
proto_item_add_subtree(ti, lpd_tree, ETT_LPD);
if (lpr_packet_type == request) {
if (pd[offset] <= 9) {
add_item_to_tree(lpd_tree, offset, 1,
proto_tree_add_item(lpd_tree, offset, 1,
lpd_client_code[pd[offset]]);
}
else {
add_item_to_tree(lpd_tree, offset, 1,
proto_tree_add_item(lpd_tree, offset, 1,
lpd_client_code[0]);
}
printer = strdup(&pd[offset+1]);
printer = g_strdup(&pd[offset+1]);
/* get rid of the new-line so that the tree prints out nicely */
if (printer[fd->cap_len - offset - 2] == 0x0a) {
printer[fd->cap_len - offset - 2] = 0;
}
add_item_to_tree(lpd_tree, offset+1, fd->cap_len - (offset+1),
proto_tree_add_item(lpd_tree, offset+1, fd->cap_len - (offset+1),
/*"Printer/options: %s", &pd[offset+1]);*/
"Printer/options: %s", printer);
free(printer);
g_free(printer);
}
else {
if (pd[offset] <= 3) {
add_item_to_tree(lpd_tree, offset, 2, "Response: %s",
proto_tree_add_item(lpd_tree, offset, 2, "Response: %s",
lpd_server_code[pd[offset]]);
}
else {
@ -139,13 +130,13 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
while (fd->cap_len > curr_offset) {
newline = strchr(line_pos, '\n');
if (!newline) {
add_item_to_tree(lpd_tree, curr_offset,
proto_tree_add_item(lpd_tree, curr_offset,
fd->cap_len - offset, "Text: %s", line_pos);
break;
}
*newline = 0;
substr_len = strlen(line_pos);
add_item_to_tree(lpd_tree, curr_offset, substr_len + 1,
proto_tree_add_item(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.5 1998/11/17 04:28:57 gerald Exp $
* $Id: packet-nbipx.c,v 1.6 1999/03/23 03:14:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -28,20 +28,12 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <memory.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
/*#include <memory.h>*/
#include <glib.h>
#include "packet.h"
#include "packet-ipx.h" /* for ipxnet_to_string() */
@ -51,7 +43,7 @@ enum nbipx_protocol {
};
static void
nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
enum nbipx_protocol nbipx);
/* There is no RFC or public specification of Netware or Microsoft
@ -81,23 +73,24 @@ struct nbipx_header {
/* NetWare */
void
dissect_nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
nbipx_ns(pd, offset, fd, tree, NETBIOS_NETWARE);
}
void
dissect_nwlink_dg(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_nwlink_dg(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
nbipx_ns(pd, offset, fd, tree, NETBIOS_NWLINK);
}
static void
nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
enum nbipx_protocol nbipx)
{
GtkWidget *nbipx_tree, *ti;
proto_tree *nbipx_tree;
proto_item *ti;
struct nbipx_header header;
int i, rtr_offset;
int name_offset;
@ -141,18 +134,18 @@ nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"NetBIOS over IPX");
nbipx_tree = gtk_tree_new();
add_subtree(ti, nbipx_tree, ETT_NBIPX);
nbipx_tree = proto_tree_new();
proto_item_add_subtree(ti, nbipx_tree, ETT_NBIPX);
if (header.packet_type <= 1) {
add_item_to_tree(nbipx_tree, offset+33, 1,
proto_tree_add_item(nbipx_tree, offset+33, 1,
"Packet Type: %s (%02X)", packet_type[header.packet_type],
header.packet_type);
}
else {
add_item_to_tree(nbipx_tree, offset+33, 1,
proto_tree_add_item(nbipx_tree, offset+33, 1,
"Packet Type: Unknown (%02X)", header.packet_type);
}
@ -161,22 +154,22 @@ nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
rtr_offset = offset + (i << 2);
memcpy(&header.router[i], &pd[rtr_offset], 4);
if (header.router[i] != 0) {
add_item_to_tree(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
proto_tree_add_item(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
ipxnet_to_string((guint8*)&header.router[i]));
}
}
add_item_to_tree(nbipx_tree, offset+32, 1, "Name Type: %02X",
proto_tree_add_item(nbipx_tree, offset+32, 1, "Name Type: %02X",
header.name_type);
if (nbipx == NETBIOS_NETWARE) {
add_item_to_tree(nbipx_tree, offset+name_offset, 16,
proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
"Name String: %s", header.name);
}
else {
add_item_to_tree(nbipx_tree, offset+name_offset, 16,
proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
"Group Name String: %s", header.name);
add_item_to_tree(nbipx_tree, offset+52, 16,
proto_tree_add_item(nbipx_tree, offset+52, 16,
"Node Name String: %s", header.node_name);
}

View File

@ -3,7 +3,7 @@
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
* Much stuff added by Guy Harris <guy@netapp.com>
*
* $Id: packet-nbns.c,v 1.13 1999/01/05 09:01:42 guy Exp $
* $Id: packet-nbns.c,v 1.14 1999/03/23 03:14:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -29,21 +29,13 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "packet.h"
#include "packet-dns.h"
#include "util.h"
@ -307,7 +299,7 @@ get_nbns_name_type_class(const u_char *nbns_data_ptr, const u_char *pd,
static int
dissect_nbns_query(const u_char *nbns_data_ptr, const u_char *pd, int offset,
GtkWidget *nbns_tree)
proto_tree *nbns_tree)
{
int len;
char name[MAXDNAME];
@ -318,7 +310,8 @@ dissect_nbns_query(const u_char *nbns_data_ptr, const u_char *pd, int offset,
char *type_name;
const u_char *dptr;
const u_char *data_start;
GtkWidget *q_tree, *tq;
proto_tree *q_tree;
proto_item *tq;
data_start = dptr = pd + offset;
@ -329,29 +322,30 @@ 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 = add_item_to_tree(nbns_tree, offset, len, "%s: type %s, class %s",
tq = proto_tree_add_item(nbns_tree, offset, len, "%s: type %s, class %s",
name, type_name, class_name);
q_tree = gtk_tree_new();
add_subtree(tq, q_tree, ETT_NBNS_QD);
q_tree = proto_tree_new();
proto_item_add_subtree(tq, q_tree, ETT_NBNS_QD);
add_item_to_tree(q_tree, offset, name_len, "Name: %s", name);
proto_tree_add_item(q_tree, offset, name_len, "Name: %s", name);
offset += name_len;
add_item_to_tree(q_tree, offset, 2, "Type: %s", type_name);
proto_tree_add_item(q_tree, offset, 2, "Type: %s", type_name);
offset += 2;
add_item_to_tree(q_tree, offset, 2, "Class: %s", class_name);
proto_tree_add_item(q_tree, offset, 2, "Class: %s", class_name);
offset += 2;
return dptr - data_start;
}
static void
nbns_add_nbns_flags(GtkWidget *nbns_tree, int offset, u_short flags,
nbns_add_nbns_flags(proto_tree *nbns_tree, int offset, u_short flags,
int is_wack)
{
char buf[128+1];
GtkWidget *field_tree, *tf;
proto_tree *field_tree;
proto_item *tf;
static const value_string rcode_vals[] = {
{ RCODE_NOERROR, "No error" },
{ RCODE_FMTERROR, "Format error" },
@ -372,49 +366,49 @@ nbns_add_nbns_flags(GtkWidget *nbns_tree, int offset, u_short flags,
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
"Unknown error"));
}
tf = add_item_to_tree(nbns_tree, offset, 2,
tf = proto_tree_add_item(nbns_tree, offset, 2,
"Flags: 0x%04x (%s)", flags, buf);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_NBNS_FLAGS);
add_item_to_tree(field_tree, offset, 2, "%s",
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_NBNS_FLAGS);
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_RESPONSE,
2*8, "Response", "Query"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, F_OPCODE,
2*8, opcode_vals, "%s"));
if (flags & F_RESPONSE) {
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(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"));
}
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, F_TRUNCATED,
2*8,
"Message is truncated",
"Message is not truncated"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(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) {
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(field_tree, offset, 2,
"%s",
decode_boolean_bitfield(flags, F_RECAVAIL,
2*8,
"Server can do recursive queries",
"Server can't do recursive queries"));
}
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(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) {
add_item_to_tree(field_tree, offset, 2,
proto_tree_add_item(field_tree, offset, 2,
"%s",
decode_enumerated_bitfield(flags, F_RCODE,
2*8,
@ -423,10 +417,11 @@ nbns_add_nbns_flags(GtkWidget *nbns_tree, int offset, u_short flags,
}
static void
nbns_add_nb_flags(GtkWidget *rr_tree, int offset, u_short flags)
nbns_add_nb_flags(proto_tree *rr_tree, int offset, u_short flags)
{
char buf[128+1];
GtkWidget *field_tree, *tf;
proto_tree *field_tree;
proto_item *tf;
static const value_string nb_flags_ont_vals[] = {
{ NB_FLAGS_ONT_B_NODE, "B-node" },
{ NB_FLAGS_ONT_P_NODE, "P-node" },
@ -442,25 +437,26 @@ nbns_add_nb_flags(GtkWidget *rr_tree, int offset, u_short flags)
strcat(buf, "group");
else
strcat(buf, "unique");
tf = add_item_to_tree(rr_tree, offset, 2, "Flags: 0x%x (%s)", flags,
tf = proto_tree_add_item(rr_tree, offset, 2, "Flags: 0x%x (%s)", flags,
buf);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_NBNS_NB_FLAGS);
add_item_to_tree(field_tree, offset, 2, "%s",
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",
decode_boolean_bitfield(flags, NB_FLAGS_G,
2*8,
"Group name",
"Unique name"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, NB_FLAGS_ONT,
2*8, nb_flags_ont_vals, "%s"));
}
static void
nbns_add_name_flags(GtkWidget *rr_tree, int offset, u_short flags)
nbns_add_name_flags(proto_tree *rr_tree, int offset, u_short flags)
{
char buf[128+1];
GtkWidget *field_tree, *tf;
proto_item *field_tree;
proto_item *tf;
static const value_string name_flags_ont_vals[] = {
{ NAME_FLAGS_ONT_B_NODE, "B-node" },
{ NAME_FLAGS_ONT_P_NODE, "P-node" },
@ -483,34 +479,34 @@ nbns_add_name_flags(GtkWidget *rr_tree, int offset, u_short flags)
strcat(buf, ", active");
if (flags & NAME_FLAGS_PRM)
strcat(buf, ", permanent node name");
tf = add_item_to_tree(rr_tree, offset, 2, "Name flags: 0x%x (%s)",
tf = proto_tree_add_item(rr_tree, offset, 2, "Name flags: 0x%x (%s)",
flags, buf);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_NBNS_NAME_FLAGS);
add_item_to_tree(field_tree, offset, 2, "%s",
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",
decode_boolean_bitfield(flags, NAME_FLAGS_G,
2*8,
"Group name",
"Unique name"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_enumerated_bitfield(flags, NAME_FLAGS_ONT,
2*8, name_flags_ont_vals, "%s"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_DRG,
2*8,
"Name is being deregistered",
"Name is not being deregistered"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_CNF,
2*8,
"Name is in conflict",
"Name is not in conflict"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_ACT,
2*8,
"Name is active",
"Name is not active"));
add_item_to_tree(field_tree, offset, 2, "%s",
proto_tree_add_item(field_tree, offset, 2, "%s",
decode_boolean_bitfield(flags, NAME_FLAGS_PRM,
2*8,
"Permanent node name",
@ -519,7 +515,7 @@ nbns_add_name_flags(GtkWidget *rr_tree, int offset, u_short flags)
static int
dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
GtkWidget *nbns_tree, int opcode)
proto_tree *nbns_tree, int opcode)
{
int len;
char name[MAXDNAME];
@ -533,7 +529,8 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
u_int ttl;
u_short data_len;
u_short flags;
GtkWidget *rr_tree, *trr;
proto_tree *rr_tree;
proto_item *trr;
data_start = dptr = pd + offset;
@ -552,7 +549,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
switch (type) {
case T_NB: /* "NB" record */
trr = add_item_to_tree(nbns_tree, offset,
trr = proto_tree_add_item(nbns_tree, offset,
(dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
@ -565,7 +562,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) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
@ -576,7 +573,7 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 2;
} else {
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
@ -587,11 +584,11 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 2;
if (data_len < 4) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 4,
proto_tree_add_item(rr_tree, offset, 4,
"Addr: %s",
ip_to_str((guint8 *)dptr));
dptr += 4;
@ -607,7 +604,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 = add_item_to_tree(nbns_tree, offset,
trr = proto_tree_add_item(nbns_tree, offset,
(dptr - data_start) + data_len,
"%s: type %s, class %s",
name, type_name, class_name);
@ -615,32 +612,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) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
num_names = *dptr;
dptr += 1;
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of names: %u", num_names);
offset += 1;
while (num_names != 0) {
if (data_len < 16) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
goto out;
}
memcpy(nbname, dptr, 16);
dptr += 16;
canonicalize_netbios_name(nbname);
add_item_to_tree(rr_tree, offset, 16,
proto_tree_add_item(rr_tree, offset, 16,
"Name: %s", nbname);
offset += 16;
data_len -= 16;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
goto out;
}
@ -654,11 +651,11 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
}
if (data_len < 6) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 6,
proto_tree_add_item(rr_tree, offset, 6,
"Unit ID: %s",
ether_to_str((guint8 *)dptr));
dptr += 6;
@ -666,181 +663,181 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
data_len -= 6;
if (data_len < 1) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 1,
proto_tree_add_item(rr_tree, offset, 1,
"Jumpers: 0x%x", *dptr);
dptr += 1;
offset += 1;
data_len -= 1;
if (data_len < 1) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 1,
proto_tree_add_item(rr_tree, offset, 1,
"Test result: 0x%x", *dptr);
dptr += 1;
offset += 1;
data_len -= 1;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Version number: 0x%x", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Period of statistics: 0x%x", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of CRCs: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of alignment errors: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of collisions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of send aborts: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 4) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 4,
proto_tree_add_item(rr_tree, offset, 4,
"Number of good sends: %u", pntohl(dptr));
dptr += 4;
offset += 4;
data_len -= 4;
if (data_len < 4) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 4,
proto_tree_add_item(rr_tree, offset, 4,
"Number of good receives: %u", pntohl(dptr));
dptr += 4;
offset += 4;
data_len -= 4;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of retransmits: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of no resource conditions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of command blocks: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Number of pending sessions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Max number of pending sessions: %u", pntohs(dptr));
dptr += 2;
offset += 2;
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Max total sessions possible: %u", pntohs(dptr));
dptr += 2;
offset += 2;
data_len -= 2;
if (data_len < 2) {
add_item_to_tree(rr_tree, offset,
proto_tree_add_item(rr_tree, offset,
data_len, "(incomplete entry)");
break;
}
add_item_to_tree(rr_tree, offset, 2,
proto_tree_add_item(rr_tree, offset, 2,
"Session data packet size: %u", pntohs(dptr));
dptr += 2;
offset += 2;
@ -850,14 +847,14 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
break;
default:
trr = add_item_to_tree(nbns_tree, offset,
trr = proto_tree_add_item(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);
add_item_to_tree(rr_tree, offset, data_len, "Data");
proto_tree_add_item(rr_tree, offset, data_len, "Data");
break;
}
dptr += data_len;
@ -867,19 +864,19 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
static int
dissect_query_records(const u_char *nbns_data_ptr, int count, const u_char *pd,
int cur_off, GtkWidget *nbns_tree)
int cur_off, proto_tree *nbns_tree)
{
int start_off;
GtkWidget *qatree, *ti;
proto_tree *qatree;
proto_item *ti;
start_off = cur_off;
ti = add_item_to_tree(GTK_WIDGET(nbns_tree),
start_off, 0, "Queries");
qatree = gtk_tree_new();
add_subtree(ti, qatree, ETT_NBNS_QRY);
ti = proto_tree_add_item(nbns_tree, start_off, 0, "Queries");
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_NBNS_QRY);
while (count-- > 0)
cur_off += dissect_nbns_query(nbns_data_ptr, pd, cur_off, qatree);
set_item_len(ti, cur_off - start_off);
proto_item_set_len(ti, cur_off - start_off);
return cur_off - start_off;
}
@ -888,28 +885,29 @@ dissect_query_records(const u_char *nbns_data_ptr, int count, const u_char *pd,
static int
dissect_answer_records(const u_char *nbns_data_ptr, int count,
const u_char *pd, int cur_off, GtkWidget *nbns_tree, int opcode, char *name)
const u_char *pd, int cur_off, proto_tree *nbns_tree, int opcode, char *name)
{
int start_off;
GtkWidget *qatree, *ti;
proto_tree *qatree;
proto_item *ti;
start_off = cur_off;
ti = add_item_to_tree(GTK_WIDGET(nbns_tree),
start_off, 0, name);
qatree = gtk_tree_new();
add_subtree(ti, qatree, ETT_NBNS_ANS);
ti = proto_tree_add_item(nbns_tree, start_off, 0, name);
qatree = proto_tree_new();
proto_item_add_subtree(ti, qatree, ETT_NBNS_ANS);
while (count-- > 0)
cur_off += dissect_nbns_answer(nbns_data_ptr, pd, cur_off,
qatree, opcode);
set_item_len(ti, cur_off - start_off);
proto_item_set_len(ti, cur_off - start_off);
return cur_off - start_off;
}
void
dissect_nbns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_nbns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
const u_char *nbns_data_ptr;
GtkWidget *nbns_tree, *ti;
proto_tree *nbns_tree;
proto_item *ti;
guint16 id, flags, quest, ans, auth, add;
int cur_off;
@ -933,25 +931,25 @@ dissect_nbns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"NetBIOS Name Service");
nbns_tree = gtk_tree_new();
add_subtree(ti, nbns_tree, ETT_NBNS);
nbns_tree = proto_tree_new();
proto_item_add_subtree(ti, nbns_tree, ETT_NBNS);
add_item_to_tree(nbns_tree, offset + NBNS_ID, 2,
proto_tree_add_item(nbns_tree, offset + NBNS_ID, 2,
"Transaction ID: 0x%04X", id);
nbns_add_nbns_flags(nbns_tree, offset + NBNS_FLAGS, flags, 0);
add_item_to_tree(nbns_tree, offset + NBNS_QUEST, 2,
proto_tree_add_item(nbns_tree, offset + NBNS_QUEST, 2,
"Questions: %d",
quest);
add_item_to_tree(nbns_tree, offset + NBNS_ANS, 2,
proto_tree_add_item(nbns_tree, offset + NBNS_ANS, 2,
"Answer RRs: %d",
ans);
add_item_to_tree(nbns_tree, offset + NBNS_AUTH, 2,
proto_tree_add_item(nbns_tree, offset + NBNS_AUTH, 2,
"Authority RRs: %d",
auth);
add_item_to_tree(nbns_tree, offset + NBNS_ADD, 2,
proto_tree_add_item(nbns_tree, offset + NBNS_ADD, 2,
"Additional RRs: %d",
add);
@ -983,9 +981,10 @@ dissect_nbns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
void
dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
GtkWidget *nbdgm_tree, *ti;
proto_tree *nbdgm_tree;
proto_item *ti;
struct nbdgm_header header;
int flags;
int message_index;
@ -1052,25 +1051,25 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, header.dgm_length,
ti = proto_tree_add_item(tree, offset, header.dgm_length,
"NetBIOS Datagram Service");
nbdgm_tree = gtk_tree_new();
add_subtree(ti, nbdgm_tree, ETT_NBDGM);
nbdgm_tree = proto_tree_new();
proto_item_add_subtree(ti, nbdgm_tree, ETT_NBDGM);
add_item_to_tree(nbdgm_tree, offset, 1, "Message Type: %s",
proto_tree_add_item(nbdgm_tree, offset, 1, "Message Type: %s",
message[message_index]);
add_item_to_tree(nbdgm_tree, offset+1, 1, "More fragments follow: %s",
proto_tree_add_item(nbdgm_tree, offset+1, 1, "More fragments follow: %s",
yesno[header.flags.more]);
add_item_to_tree(nbdgm_tree, offset+1, 1, "This is first fragment: %s",
proto_tree_add_item(nbdgm_tree, offset+1, 1, "This is first fragment: %s",
yesno[header.flags.first]);
add_item_to_tree(nbdgm_tree, offset+1, 1, "Node Type: %s",
proto_tree_add_item(nbdgm_tree, offset+1, 1, "Node Type: %s",
node[header.flags.node_type]);
add_item_to_tree(nbdgm_tree, offset+2, 2, "Datagram ID: 0x%04X",
proto_tree_add_item(nbdgm_tree, offset+2, 2, "Datagram ID: 0x%04X",
header.dgm_id);
add_item_to_tree(nbdgm_tree, offset+4, 4, "Source IP: %s",
proto_tree_add_item(nbdgm_tree, offset+4, 4, "Source IP: %s",
ip_to_str((guint8 *)&header.src_ip));
add_item_to_tree(nbdgm_tree, offset+8, 2, "Source Port: %d",
proto_tree_add_item(nbdgm_tree, offset+8, 2, "Source Port: %d",
header.src_port);
offset += 10;
@ -1078,9 +1077,9 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
if (header.msg_type == 0x10 ||
header.msg_type == 0x11 || header.msg_type == 0x12) {
add_item_to_tree(nbdgm_tree, offset, 2,
proto_tree_add_item(nbdgm_tree, offset, 2,
"Datagram length: %d bytes", header.dgm_length);
add_item_to_tree(nbdgm_tree, offset+2, 2,
proto_tree_add_item(nbdgm_tree, offset+2, 2,
"Packet offset: %d bytes", header.pkt_offset);
offset += 4;
@ -1088,22 +1087,22 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
/* Source name */
len = get_nbns_name(&pd[offset], pd, offset, name);
add_item_to_tree(nbdgm_tree, offset, len, "Source name: %s",
proto_tree_add_item(nbdgm_tree, offset, len, "Source name: %s",
name);
offset += len;
/* Destination name */
len = get_nbns_name(&pd[offset], pd, offset, name);
add_item_to_tree(nbdgm_tree, offset, len, "Destination name: %s",
proto_tree_add_item(nbdgm_tree, offset, len, "Destination name: %s",
name);
offset += len;
/* here we can pass the packet off to the next protocol */
dissect_data(pd, offset, fd, GTK_TREE(nbdgm_tree));
dissect_data(pd, offset, fd, nbdgm_tree);
}
else if (header.msg_type == 0x13) {
add_item_to_tree(nbdgm_tree, offset, 1, "Error code: %s",
proto_tree_add_item(nbdgm_tree, offset, 1, "Error code: %s",
val_to_str(header.error_code, error_codes, "Unknown (0x%x)"));
}
else if (header.msg_type == 0x14 ||
@ -1111,7 +1110,7 @@ dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
/* Destination name */
len = get_nbns_name(&pd[offset], pd, offset, name);
add_item_to_tree(nbdgm_tree, offset, len, "Destination name: %s",
proto_tree_add_item(nbdgm_tree, offset, len, "Destination name: %s",
name);
}
}

View File

@ -2,7 +2,7 @@
* Routines for NetWare Core Protocol
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-ncp.c,v 1.9 1999/03/20 04:38:57 gram Exp $
* $Id: packet-ncp.c,v 1.10 1999/03/23 03:14:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -28,10 +28,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -40,16 +36,16 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "packet-ipx.h"
#include "packet-ncp.h"
static void
dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp_tree, GtkTree *tree);
dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, proto_tree *ncp_tree, proto_tree *tree);
static void
dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp_tree, GtkTree *tree);
dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *ncp_tree, proto_tree *tree);
static struct ncp2222_record *
ncp2222_find(guint8 func, guint8 subfunc);
@ -319,9 +315,10 @@ svc_record_byte_count(svc_record *sr)
}
void
dissect_ncp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ncp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *ncp_tree = NULL, *ti;
proto_tree *ncp_tree = NULL;
proto_item *ti;
int ncp_hdr_length = 0;
struct ncp_common_header header;
@ -345,22 +342,22 @@ dissect_ncp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
nw_ncp_type = header.type;
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"NetWare Core Protocol");
ncp_tree = gtk_tree_new();
add_subtree(ti, ncp_tree, ETT_NCP);
ncp_tree = proto_tree_new();
proto_item_add_subtree(ti, ncp_tree, ETT_NCP);
add_item_to_tree(ncp_tree, offset, 2,
proto_tree_add_item(ncp_tree, offset, 2,
"Type: %s", val_to_str( header.type,
request_reply_values, "Unknown (%04X)"));
add_item_to_tree(ncp_tree, offset+2, 1,
proto_tree_add_item(ncp_tree, offset+2, 1,
"Sequence Number: %d", header.sequence);
add_item_to_tree(ncp_tree, offset+3, 3,
proto_tree_add_item(ncp_tree, offset+3, 3,
"Connection Number: %d", nw_connection);
add_item_to_tree(ncp_tree, offset+4, 1,
proto_tree_add_item(ncp_tree, offset+4, 1,
"Task Number: %d", header.task);
}
@ -374,7 +371,7 @@ dissect_ncp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
void
dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp_tree, GtkTree *tree) {
dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, proto_tree *ncp_tree, proto_tree *tree) {
struct ncp_request_header request;
struct ncp2222_record *ncp_request;
@ -395,7 +392,7 @@ dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp
col_add_fstr(fd, COL_INFO, "C %s", description);
if (ncp_tree) {
add_item_to_tree(ncp_tree, offset+6, 1, "Function Code: 0x%02X (%s)",
proto_tree_add_item(ncp_tree, offset+6, 1, "Function Code: 0x%02X (%s)",
request.function, description);
if (ncp_request) {
offset += 10 + svc_record_byte_count(ncp_request->req);
@ -416,7 +413,7 @@ dissect_ncp_request(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp
}
void
dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp_tree, GtkTree *tree) {
dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *ncp_tree, proto_tree *tree) {
struct ncp_reply_header reply;
struct ncp2222_record *ncp_request = NULL;
struct ncp_request_val *request_val;
@ -443,10 +440,10 @@ dissect_ncp_reply(const u_char *pd, int offset, frame_data *fd, GtkWidget *ncp_t
col_add_fstr(fd, COL_INFO, "R %s", description);
if (ncp_tree) {
add_item_to_tree(ncp_tree, offset+6, 1,
proto_tree_add_item(ncp_tree, offset+6, 1,
"Completion Code: %d", reply.completion_code);
add_item_to_tree(ncp_tree, offset+7, 1,
proto_tree_add_item(ncp_tree, offset+7, 1,
"Connection Status: %d", reply.connection_state);
offset += 8;
dissect_data(pd, offset, fd, tree);

View File

@ -1,7 +1,7 @@
/* packet-null.c
* Routines for null packet disassembly
*
* $Id: packet-null.c,v 1.6 1999/02/09 00:35:38 guy Exp $
* $Id: packet-null.c,v 1.7 1999/03/23 03:14:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -32,13 +32,19 @@
#include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <glib.h>
#include <sys/socket.h>
#include "ethereal.h"
#include "packet.h"
/* Null/loopback structs and definitions */
typedef struct _e_nullhdr {
guint8 null_next;
guint8 null_len;
guint16 null_family;
} e_nullhdr;
void
capture_null( const u_char *pd, guint32 cap_len, packet_counts *ld ) {
e_nullhdr nh;
@ -71,9 +77,10 @@ capture_null( const u_char *pd, guint32 cap_len, packet_counts *ld ) {
}
void
dissect_null( const u_char *pd, frame_data *fd, GtkTree *tree ) {
dissect_null( const u_char *pd, frame_data *fd, proto_tree *tree ) {
e_nullhdr nh;
GtkWidget *ti, *fh_tree;
proto_tree *fh_tree;
proto_item *ti;
nh.null_next = pd[0];
nh.null_len = pd[1];
@ -93,13 +100,12 @@ dissect_null( const u_char *pd, frame_data *fd, GtkTree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = add_item_to_tree( GTK_WIDGET(tree), 0, 4,
"Null/Loopback" );
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_NULL);
add_item_to_tree(fh_tree, 0, 1, "Next: %02x", nh.null_next);
add_item_to_tree(fh_tree, 1, 1, "Length: %02x", nh.null_len);
add_item_to_tree(fh_tree, 2, 2, "Family: %04x", nh.null_family);
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);
}
/*

File diff suppressed because it is too large Load Diff

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.9 1999/01/17 09:30:05 guy Exp $
* $Id: packet-ospf.c,v 1.10 1999/03/23 03:14:42 gram Exp $
*
* At this time, this module is able to analyze OSPF
* packets as specified in RFC2328. MOSPF (RFC1584) and other
@ -35,11 +35,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -48,17 +43,21 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "packet.h"
#include "packet-ospf.h"
void
dissect_ospf(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ospfhdr ospfh;
GtkWidget *ospf_tree = NULL, *ti;
GtkWidget *ospf_header_tree;
proto_tree *ospf_tree = NULL;
proto_item *ti;
proto_tree *ospf_header_tree;
char auth_data[9]="";
char *packet_type;
static value_string pt_vals[] = { {OSPF_HELLO, "Hello Packet" },
@ -81,49 +80,49 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, ntohs(ospfh.length), "Open Shortest Path First");
ospf_tree = gtk_tree_new();
add_subtree(ti, ospf_tree, ETT_OSPF);
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 = add_item_to_tree(GTK_WIDGET(ospf_tree), offset, OSPF_HEADER_LENGTH, "OSPF Header");
ospf_header_tree = gtk_tree_new();
add_subtree(ti, ospf_header_tree, ETT_OSPF_HDR);
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);
add_item_to_tree(ospf_header_tree, offset, 1, "OSPF Version: %d", ospfh.version);
add_item_to_tree(ospf_header_tree, offset + 1 , 1, "OSPF Packet Type: %d (%s)",
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)",
ospfh.packet_type,
(packet_type != NULL ?
packet_type :
"Unknown"));
add_item_to_tree(ospf_header_tree, offset + 2 , 2, "Packet Length: %d",
proto_tree_add_item(ospf_header_tree, offset + 2 , 2, "Packet Length: %d",
ntohs(ospfh.length));
add_item_to_tree(ospf_header_tree, offset + 4 , 4, "Source OSPF Router ID: %s",
proto_tree_add_item(ospf_header_tree, offset + 4 , 4, "Source OSPF Router ID: %s",
ip_to_str((guint8 *) &(ospfh.routerid)));
if (!(ospfh.area)) {
add_item_to_tree(ospf_header_tree, offset + 8 , 4, "Area ID: Backbone");
proto_tree_add_item(ospf_header_tree, offset + 8 , 4, "Area ID: Backbone");
} else {
add_item_to_tree(ospf_header_tree, offset + 8 , 4, "Area ID: %s", ip_to_str((guint8 *) &(ospfh.area)));
proto_tree_add_item(ospf_header_tree, offset + 8 , 4, "Area ID: %s", ip_to_str((guint8 *) &(ospfh.area)));
}
add_item_to_tree(ospf_header_tree, offset + 12 , 2, "Packet Checksum: 0x%x",
proto_tree_add_item(ospf_header_tree, offset + 12 , 2, "Packet Checksum: 0x%x",
ntohs(ospfh.checksum));
switch( ntohs(ospfh.auth_type) ) {
case OSPF_AUTH_NONE:
add_item_to_tree(ospf_header_tree, offset + 14 , 2, "Auth Type: none");
add_item_to_tree(ospf_header_tree, offset + 16 , 8, "Auth Data (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)");
break;
case OSPF_AUTH_SIMPLE:
add_item_to_tree(ospf_header_tree, offset + 14 , 2, "Auth Type: simple");
proto_tree_add_item(ospf_header_tree, offset + 14 , 2, "Auth Type: simple");
strncpy(auth_data, (char *) &ospfh.auth_data, 8);
add_item_to_tree(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
proto_tree_add_item(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
break;
case OSPF_AUTH_CRYPT:
add_item_to_tree(ospf_header_tree, offset + 14 , 2, "Auth Type: crypt");
add_item_to_tree(ospf_header_tree, offset + 16 , 8, "Auth Data (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)");
break;
default:
add_item_to_tree(ospf_header_tree, offset + 14 , 2, "Auth Type (unknown)");
add_item_to_tree(ospf_header_tree, offset + 16 , 8, "Auth Data (unknown)");
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)");
}
}
@ -132,19 +131,19 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
offset += OSPF_HEADER_LENGTH;
switch(ospfh.packet_type){
case OSPF_HELLO:
dissect_ospf_hello(pd, offset, fd, (GtkTree *) ospf_tree);
dissect_ospf_hello(pd, offset, fd, ospf_tree);
break;
case OSPF_DB_DESC:
dissect_ospf_db_desc(pd, offset, fd, (GtkTree *) ospf_tree);
dissect_ospf_db_desc(pd, offset, fd, ospf_tree);
break;
case OSPF_LS_REQ:
dissect_ospf_ls_req(pd, offset, fd, (GtkTree *) ospf_tree);
dissect_ospf_ls_req(pd, offset, fd, ospf_tree);
break;
case OSPF_LS_UPD:
dissect_ospf_ls_upd(pd, offset, fd, (GtkTree *) ospf_tree);
dissect_ospf_ls_upd(pd, offset, fd, ospf_tree);
break;
case OSPF_LS_ACK:
dissect_ospf_ls_ack(pd, offset, fd, (GtkTree *) ospf_tree);
dissect_ospf_ls_ack(pd, offset, fd, ospf_tree);
break;
default:
dissect_data(pd, offset, fd, tree);
@ -152,24 +151,25 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
void
dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ospf_hello ospfhello;
guint32 *ospfneighbor;
char options[20]="";
int options_offset;
GtkWidget *ospf_hello_tree, *ti;
proto_tree *ospf_hello_tree;
proto_item *ti;
memcpy(&ospfhello, &pd[offset], sizeof(e_ospf_hello));
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset) , "OSPF Hello Packet");
ospf_hello_tree = gtk_tree_new();
add_subtree(ti, ospf_hello_tree, ETT_OSPF_HELLO);
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);
add_item_to_tree(ospf_hello_tree, offset , 4, "Network Mask: %s", ip_to_str((guint8 *) &ospfhello.network_mask));
add_item_to_tree(ospf_hello_tree, offset + 4, 2, "Hello Interval: %d seconds", ntohs(ospfhello.hellointervall));
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));
/* ATTENTION !!! no check for length of options string */
options_offset=0;
@ -194,41 +194,42 @@ dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
options_offset+=3;
}
add_item_to_tree(ospf_hello_tree, offset + 6, 1, "Options: %d (%s)", ospfhello.options, options);
add_item_to_tree(ospf_hello_tree, offset + 7, 1, "Router Priority: %d", ospfhello.priority);
add_item_to_tree(ospf_hello_tree, offset + 8, 4, "Router Dead Interval: %ld seconds", (long)ntohl(ospfhello.dead_interval));
add_item_to_tree(ospf_hello_tree, offset + 12, 4, "Designated Router: %s", ip_to_str((guint8 *) &ospfhello.drouter));
add_item_to_tree(ospf_hello_tree, offset + 16, 4, "Backup Designated Router: %s", ip_to_str((guint8 *) &ospfhello.bdrouter));
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));
offset+=20;
while(((int)(fd->cap_len - offset)) >= 4){
printf("%d", fd->cap_len - offset);
ospfneighbor=(guint32 *) &pd[offset];
add_item_to_tree(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor));
proto_tree_add_item(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor));
offset+=4;
}
}
}
void
dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ospf_dbd ospf_dbd;
char options[20]="";
int options_offset;
char flags[20]="";
int flags_offset;
GtkWidget *ospf_db_desc_tree=NULL, *ti;
proto_tree *ospf_db_desc_tree=NULL;
proto_item *ti;
memcpy(&ospf_dbd, &pd[offset], sizeof(e_ospf_dbd));
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset) , "OSPF DB Description");
ospf_db_desc_tree = gtk_tree_new();
add_subtree(ti, ospf_db_desc_tree, ETT_OSPF_DESC);
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);
add_item_to_tree(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) );
proto_tree_add_item(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) );
options_offset=0;
@ -253,7 +254,7 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree
options_offset+=3;
}
add_item_to_tree(ospf_db_desc_tree, offset + 2 , 1, "Options: %d (%s)", ospf_dbd.options, options );
proto_tree_add_item(ospf_db_desc_tree, offset + 2 , 1, "Options: %d (%s)", ospf_dbd.options, options );
flags_offset=0;
@ -270,23 +271,24 @@ dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree
flags_offset+=3;
}
add_item_to_tree(ospf_db_desc_tree, offset + 3 , 1, "Flags: %d (%s)", ospf_dbd.flags, flags );
add_item_to_tree(ospf_db_desc_tree, offset + 4 , 4, "DD Sequence: %ld", (long)ntohl(ospf_dbd.dd_sequence) );
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) );
}
/* LS Headers will be processed here */
/* skip to the end of DB-Desc header */
offset+=8;
while( ((int) (fd->cap_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) {
dissect_ospf_lsa(pd, offset, fd, (GtkTree *) tree, FALSE);
dissect_ospf_lsa(pd, offset, fd, tree, FALSE);
offset+=OSPF_LSA_HEADER_LENGTH;
}
}
void
dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ospf_ls_req ospf_lsr;
GtkWidget *ospf_lsr_tree, *ti;
proto_tree *ospf_lsr_tree;
proto_item *ti;
/* zero or more LS requests may be within a LS Request */
@ -294,39 +296,39 @@ dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
if (tree) {
while( ((int) ( fd->cap_len - offset)) >= OSPF_LS_REQ_LENGTH ){
memcpy(&ospf_lsr, &pd[offset], sizeof(e_ospf_ls_req));
ti = add_item_to_tree(GTK_WIDGET(tree), offset, OSPF_LS_REQ_LENGTH, "Link State Request");
ospf_lsr_tree = gtk_tree_new();
add_subtree(ti, ospf_lsr_tree, ETT_OSPF_LSR);
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);
switch( ntohl( ospf_lsr.ls_type ) ){
case OSPF_LSTYPE_ROUTER:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: Router-LSA (%ld)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Router-LSA (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_NETWORK:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: Network-LSA (%ld)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Network-LSA (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_SUMMERY:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (IP network) (%ld)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (IP network) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_ASBR:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (ASBR) (%ld)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (ASBR) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
case OSPF_LSTYPE_ASEXT:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: AS-External-LSA (ASBR) (%ld)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: AS-External-LSA (ASBR) (%ld)",
(long)ntohl( ospf_lsr.ls_type ) );
break;
default:
add_item_to_tree(ospf_lsr_tree, offset, 4, "LS Type: %ld (unknown)",
proto_tree_add_item(ospf_lsr_tree, offset, 4, "LS Type: %ld (unknown)",
(long)ntohl( ospf_lsr.ls_type ) );
}
add_item_to_tree(ospf_lsr_tree, offset + 4, 4, "Link State ID : %s",
proto_tree_add_item(ospf_lsr_tree, offset + 4, 4, "Link State ID : %s",
ip_to_str((guint8 *) &(ospf_lsr.ls_id)));
add_item_to_tree(ospf_lsr_tree, offset + 8, 4, "Advertising Router : %s",
proto_tree_add_item(ospf_lsr_tree, offset + 8, 4, "Advertising Router : %s",
ip_to_str((guint8 *) &(ospf_lsr.adv_router)));
offset+=12;
@ -334,44 +336,45 @@ dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
}
void
dissect_ospf_ls_upd(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf_ls_upd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_ospf_lsa_upd_hdr upd_hdr;
guint32 lsa_counter;
GtkWidget *ospf_lsa_upd_tree=NULL, *ti;
proto_tree *ospf_lsa_upd_tree=NULL;
proto_item *ti;
memcpy(&upd_hdr, &pd[offset], sizeof(e_ospf_lsa_upd_hdr));
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset) , "LS Update Packet");
ospf_lsa_upd_tree = gtk_tree_new();
add_subtree(ti, ospf_lsa_upd_tree, ETT_OSPF_LSA_UPD);
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);
add_item_to_tree(ospf_lsa_upd_tree, offset, 4, "Nr oF LSAs: %ld", (long)ntohl(upd_hdr.lsa_nr) );
proto_tree_add_item(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 */
lsa_counter = 0;
while(lsa_counter < ntohl(upd_hdr.lsa_nr)){
offset+=dissect_ospf_lsa(pd, offset, fd, (GtkTree *) ospf_lsa_upd_tree, TRUE);
offset+=dissect_ospf_lsa(pd, offset, fd, ospf_lsa_upd_tree, TRUE);
lsa_counter += 1;
}
}
void
dissect_ospf_ls_ack(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_ospf_ls_ack(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
/* the body of a LS Ack packet simply contains zero or more LSA Headers */
while( ((int)(fd->cap_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) {
dissect_ospf_lsa(pd, offset, fd, (GtkTree *) tree, FALSE);
dissect_ospf_lsa(pd, offset, fd, tree, FALSE);
offset+=OSPF_LSA_HEADER_LENGTH;
}
}
int
dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, int disassemble_body) {
dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int disassemble_body) {
e_ospf_lsa_hdr lsa_hdr;
char *lsa_type;
@ -395,7 +398,8 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
e_ospf_asexternal_lsa asext_lsa;
guint32 asext_metric;
GtkWidget *ospf_lsa_tree, *ti;
proto_tree *ospf_lsa_tree;
proto_item *ti;
memcpy(&lsa_hdr, &pd[offset], sizeof(e_ospf_lsa_hdr));
@ -423,29 +427,29 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
if (tree) {
if(disassemble_body){
ti = add_item_to_tree(GTK_WIDGET(tree), offset, ntohs(lsa_hdr.length),
ti = proto_tree_add_item(tree, offset, ntohs(lsa_hdr.length),
"%s (Type: %d)", lsa_type, lsa_hdr.ls_type);
} else {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, OSPF_LSA_HEADER_LENGTH, "LSA Header");
ti = proto_tree_add_item(tree, offset, OSPF_LSA_HEADER_LENGTH, "LSA Header");
}
ospf_lsa_tree = gtk_tree_new();
add_subtree(ti, ospf_lsa_tree, ETT_OSPF_LSA);
ospf_lsa_tree = proto_tree_new();
proto_item_add_subtree(ti, ospf_lsa_tree, ETT_OSPF_LSA);
add_item_to_tree(ospf_lsa_tree, offset, 2, "LS Age: %d seconds", ntohs(lsa_hdr.ls_age));
add_item_to_tree(ospf_lsa_tree, offset + 2, 1, "Options: %d ", lsa_hdr.options);
add_item_to_tree(ospf_lsa_tree, offset + 3, 1, "LSA Type: %d (%s)", lsa_hdr.ls_type, lsa_type);
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);
add_item_to_tree(ospf_lsa_tree, offset + 4, 4, "Linke State ID: %s ",
proto_tree_add_item(ospf_lsa_tree, offset + 4, 4, "Linke State ID: %s ",
ip_to_str((guint8 *) &(lsa_hdr.ls_id)));
add_item_to_tree(ospf_lsa_tree, offset + 8, 4, "Advertising Router: %s ",
proto_tree_add_item(ospf_lsa_tree, offset + 8, 4, "Advertising Router: %s ",
ip_to_str((guint8 *) &(lsa_hdr.adv_router)));
add_item_to_tree(ospf_lsa_tree, offset + 12, 4, "LS Sequence Number: 0x%04lx ",
proto_tree_add_item(ospf_lsa_tree, offset + 12, 4, "LS Sequence Number: 0x%04lx ",
(unsigned long)ntohl(lsa_hdr.ls_seq));
add_item_to_tree(ospf_lsa_tree, offset + 16, 2, "LS Checksum: %d ", ntohs(lsa_hdr.ls_checksum));
proto_tree_add_item(ospf_lsa_tree, offset + 16, 2, "LS Checksum: %d ", ntohs(lsa_hdr.ls_checksum));
add_item_to_tree(ospf_lsa_tree, offset + 18, 2, "Length: %d ", ntohs(lsa_hdr.length));
proto_tree_add_item(ospf_lsa_tree, offset + 18, 2, "Length: %d ", ntohs(lsa_hdr.length));
if(!disassemble_body){
return OSPF_LSA_HEADER_LENGTH;
@ -459,8 +463,8 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
memcpy(&router_lsa, &pd[offset], sizeof(e_ospf_router_lsa));
/* again: flags should be secified in detail */
add_item_to_tree(ospf_lsa_tree, offset, 1, "Flags: 0x%02x ", router_lsa.flags);
add_item_to_tree(ospf_lsa_tree, offset + 2, 2, "Nr. of Links: %d ",
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 ",
ntohs(router_lsa.nr_links));
offset += 4;
/* router_lsa.nr_links links follow
@ -492,17 +496,17 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
link_id="unknown link id";
}
add_item_to_tree(ospf_lsa_tree, offset, 4, "%s: %s", link_id,
proto_tree_add_item(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)*/
add_item_to_tree(ospf_lsa_tree, offset + 4, 4, "Link Data: %s",
proto_tree_add_item(ospf_lsa_tree, offset + 4, 4, "Link Data: %s",
ip_to_str((guint8 *) &(router_data.link_data)));
add_item_to_tree(ospf_lsa_tree, offset + 8, 1, "Link Type: %d - %s",
proto_tree_add_item(ospf_lsa_tree, offset + 8, 1, "Link Type: %d - %s",
router_data.link_type, link_type);
add_item_to_tree(ospf_lsa_tree, offset + 9, 1, "Nr. of TOS metrics: %d", router_data.nr_tos);
add_item_to_tree(ospf_lsa_tree, offset + 10, 2, "TOS 0 metric: %d", ntohs( router_data.tos0_metric ));
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 ));
offset += 12;
@ -513,7 +517,7 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
for(tos_counter = 1 ; link_counter <= ntohs(router_data.nr_tos); tos_counter++){
memcpy(&tos_data, &pd[offset], sizeof(e_ospf_router_metric));
add_item_to_tree(ospf_lsa_tree, offset, 1, "TOS: %d, Metric: %d",
proto_tree_add_item(ospf_lsa_tree, offset, 1, "TOS: %d, Metric: %d",
tos_data.tos, ntohs(tos_data.metric));
offset += 4;
}
@ -521,13 +525,13 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
break;
case(OSPF_LSTYPE_NETWORK):
memcpy(&network_lsa, &pd[offset], sizeof(e_ospf_network_lsa));
add_item_to_tree(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_item(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];
add_item_to_tree(ospf_lsa_tree, offset, 4, "Attached Router: %s",
proto_tree_add_item(ospf_lsa_tree, offset, 4, "Attached Router: %s",
ip_to_str((guint8 *) attached_router));
offset += 4;
}
@ -536,22 +540,22 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
/* Type 3 and 4 LSAs have the same format */
case(OSPF_LSTYPE_ASBR):
memcpy(&summary_lsa, &pd[offset], sizeof(e_ospf_summary_lsa));
add_item_to_tree(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_item(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));
add_item_to_tree(ospf_lsa_tree, offset, 4, "Netmask: %s",
proto_tree_add_item(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 */
add_item_to_tree(ospf_lsa_tree, offset, 1,
proto_tree_add_item(ospf_lsa_tree, offset, 1,
"External Type: Type 2 (metric is larger than any other link state path)");
} else {
add_item_to_tree(ospf_lsa_tree, offset + 4, 1,
proto_tree_add_item(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 */
@ -561,15 +565,15 @@ dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, GtkTree *tree, in
/* erase the leading 8 bits (the dont belong to the metric */
asext_metric = ntohl(asext_metric) & 0x00ffffff ;
add_item_to_tree(ospf_lsa_tree, offset + 5, 3,"Metric: %d", asext_metric);
add_item_to_tree(ospf_lsa_tree, offset + 8, 4,"Forwarding Address: %s",
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",
ip_to_str((guint8 *) &(asext_lsa.gateway)));
add_item_to_tree(ospf_lsa_tree, offset + 12, 4,"External Route Tag: %ld", (long)ntohl(asext_lsa.external_tag));
proto_tree_add_item(ospf_lsa_tree, offset + 12, 4,"External Route Tag: %ld", (long)ntohl(asext_lsa.external_tag));
break;
default:
/* unknown LSA type */
add_item_to_tree(ospf_lsa_tree, offset, (fd->cap_len - offset), "Unknown LSA Type");
proto_tree_add_item(ospf_lsa_tree, offset, (fd->cap_len - offset), "Unknown LSA Type");
}
}
/* return the length of this LSA */

View File

@ -122,14 +122,14 @@ typedef struct _e_ospf_asexternal_lsa {
} e_ospf_asexternal_lsa;
void dissect_ospf_hello(const u_char*, int, frame_data*, GtkTree*);
void dissect_ospf_db_desc(const u_char*, int, frame_data*, GtkTree*);
void dissect_ospf_ls_req(const u_char*, int, frame_data*, GtkTree*);
void dissect_ospf_ls_upd(const u_char*, int, frame_data*, GtkTree*);
void dissect_ospf_ls_ack(const u_char*, int, frame_data*, GtkTree*);
void dissect_ospf_hello(const u_char*, int, frame_data*, proto_tree*);
void dissect_ospf_db_desc(const u_char*, int, frame_data*, proto_tree*);
void dissect_ospf_ls_req(const u_char*, int, frame_data*, proto_tree*);
void dissect_ospf_ls_upd(const u_char*, int, frame_data*, proto_tree*);
void dissect_ospf_ls_ack(const u_char*, int, frame_data*, proto_tree*);
/* dissect_ospf_lsa returns the length of the LSA
* if disassemble_body is set to FALSE (e.g. in LSA ACK
* packets), the LSA-header length is returned (20)
*/
int dissect_ospf_lsa(const u_char*, int, frame_data*, GtkTree*, int disassemble_body);
int dissect_ospf_lsa(const u_char*, int, frame_data*, proto_tree*, int disassemble_body);

View File

@ -1,7 +1,7 @@
/* packet-ppp.c
* Routines for ppp packet disassembly
*
* $Id: packet-ppp.c,v 1.9 1999/02/09 00:35:38 guy Exp $
* $Id: packet-ppp.c,v 1.10 1999/03/23 03:14:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -32,12 +32,18 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
/* PPP structs and definitions */
typedef struct _e_ppphdr {
guint8 ppp_addr;
guint8 ppp_ctl;
guint16 ppp_prot;
} e_ppphdr;
/* Protocol types, from Linux "ppp_defs.h" and
http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
@ -74,9 +80,11 @@ capture_ppp( const u_char *pd, guint32 cap_len, packet_counts *ld ) {
}
void
dissect_ppp( const u_char *pd, frame_data *fd, GtkTree *tree ) {
dissect_ppp( const u_char *pd, frame_data *fd, proto_tree *tree ) {
e_ppphdr ph;
GtkWidget *ti, *fh_tree;
proto_tree *fh_tree;
proto_item *ti;
static const value_string ppp_vals[] = {
{PPP_IP, "IP" },
{PPP_AT, "Appletalk" },
@ -103,13 +111,12 @@ dissect_ppp( const u_char *pd, frame_data *fd, GtkTree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = add_item_to_tree( GTK_WIDGET(tree), 0, 4,
"Point-to-Point Protocol" );
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_PPP);
add_item_to_tree(fh_tree, 0, 1, "Address: %02x", ph.ppp_addr);
add_item_to_tree(fh_tree, 1, 1, "Control: %02x", ph.ppp_ctl);
add_item_to_tree(fh_tree, 2, 2, "Protocol: %s (0x%04x)",
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)",
val_to_str(ph.ppp_prot, ppp_vals, "Unknown"), ph.ppp_prot);
}

View File

@ -1,7 +1,7 @@
/* packet-raw.c
* Routines for raw packet disassembly
*
* $Id: packet-raw.c,v 1.8 1999/02/09 00:35:38 guy Exp $
* $Id: packet-raw.c,v 1.9 1999/03/23 03:14:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -32,10 +32,7 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
void
@ -56,8 +53,9 @@ capture_raw( const u_char *pd, guint32 cap_len, packet_counts *ld ) {
}
void
dissect_raw( const u_char *pd, frame_data *fd, GtkTree *tree ) {
GtkWidget *ti, *fh_tree;
dissect_raw( const u_char *pd, frame_data *fd, proto_tree *tree ) {
proto_tree *fh_tree;
proto_item *ti;
/* load the top pane info. This should be overwritten by
the next protocol in the stack */
@ -73,11 +71,10 @@ dissect_raw( const u_char *pd, frame_data *fd, GtkTree *tree ) {
/* populate a tree in the second pane with the status of the link
layer (ie none) */
if(tree) {
ti = add_item_to_tree( GTK_WIDGET(tree), 0, 0,
"Raw packet data" );
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_RAW);
add_item_to_tree(fh_tree, 0, 0, "No link information available");
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");
}
/* 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.7 1999/02/05 00:52:19 guy Exp $
* $Id: packet-rip.c,v 1.8 1999/03/23 03:14:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -26,10 +26,6 @@
#include "config.h"
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@ -38,21 +34,22 @@
#include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "packet-rip.h"
static void dissect_ip_rip_vektor(guint8 version,
const e_rip_vektor *rip_vektor, int offset, GtkWidget *tree);
const e_rip_vektor *rip_vektor, int offset, proto_tree *tree);
static void dissect_rip_authentication(const e_rip_authentication *rip_authentication,
int offset, GtkWidget *tree);
int offset, proto_tree *tree);
void
dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_rip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_riphdr rip_header;
e_rip_entry rip_entry;
guint16 family;
GtkWidget *rip_tree = NULL, *ti;
proto_tree *rip_tree = NULL;
proto_item *ti;
/* we do the range checking of the index when checking wether or not this is a RIP packet */
static char *packet_type[8] = { "never used", "Request", "Response",
@ -93,14 +90,14 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_str(fd, COL_INFO, packet_type[rip_header.command]);
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (fd->cap_len - offset), "Routing Information Protocol");
rip_tree = gtk_tree_new();
add_subtree(ti, rip_tree, ETT_RIP);
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);
add_item_to_tree(rip_tree, offset, 1, "Command: %d (%s)", rip_header.command, packet_type[rip_header.command]);
add_item_to_tree(rip_tree, offset + 1, 1, "Version: %d", rip_header.version);
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);
if(rip_header.version == RIPv2)
add_item_to_tree(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
proto_tree_add_item(rip_tree, offset + 2 , 2, "Routing Domain: %d", ntohs(rip_header.domain));
/* skip header */
offset += RIP_HEADER_LENGTH;
@ -112,7 +109,7 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
family = ntohs(rip_entry.vektor.family);
switch (family) {
case 2: /* IP */
ti = add_item_to_tree(GTK_WIDGET(rip_tree), offset,
ti = proto_tree_add_item(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));
@ -120,13 +117,13 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
offset, ti);
break;
case 0xFFFF:
add_item_to_tree(GTK_WIDGET(rip_tree), offset,
RIP_ENTRY_LENGTH, "Authention");
proto_tree_add_item(rip_tree, offset,
RIP_ENTRY_LENGTH, "Authentication");
dissect_rip_authentication(&rip_entry.authentication,
offset, ti);
break;
default:
add_item_to_tree(GTK_WIDGET(rip_tree), offset,
proto_tree_add_item(rip_tree, offset,
RIP_ENTRY_LENGTH, "Unknown address family %u",
family);
break;
@ -139,44 +136,44 @@ dissect_rip(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
static void
dissect_ip_rip_vektor(guint8 version, const e_rip_vektor *rip_vektor,
int offset, GtkWidget *tree)
int offset, proto_tree *tree)
{
GtkWidget *rip_vektor_tree;
proto_tree *rip_vektor_tree;
rip_vektor_tree = gtk_tree_new();
add_subtree(tree, rip_vektor_tree, ETT_RIP_VEC);
rip_vektor_tree = proto_tree_new();
proto_item_add_subtree(tree, rip_vektor_tree, ETT_RIP_VEC);
add_item_to_tree(rip_vektor_tree, offset, 2, "Address Family ID: IP");
proto_tree_add_item(rip_vektor_tree, offset, 2, "Address Family ID: IP");
if(version == RIPv2)
add_item_to_tree(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
proto_tree_add_item(rip_vektor_tree, offset + 2 , 2, "Route Tag: %d",
ntohs(rip_vektor->tag));
add_item_to_tree(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
proto_tree_add_item(rip_vektor_tree, offset + 4, 4, "IP Address: %s",
ip_to_str((guint8 *) &(rip_vektor->ip)));
if(version == RIPv2) {
add_item_to_tree(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
proto_tree_add_item(rip_vektor_tree, offset + 8 , 4, "Netmask: %s",
ip_to_str((guint8 *) &(rip_vektor->mask)));
add_item_to_tree(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
proto_tree_add_item(rip_vektor_tree, offset + 12, 4, "Next Hop: %s",
ip_to_str((guint8 *) &(rip_vektor->next_hop)));
}
add_item_to_tree(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
proto_tree_add_item(rip_vektor_tree, offset + 16, 4, "Metric: %ld",
(long)ntohl(rip_vektor->metric));
}
static void
dissect_rip_authentication(const e_rip_authentication *rip_authentication,
int offset, GtkWidget *tree)
int offset, proto_tree *tree)
{
GtkWidget *rip_authentication_tree;
proto_tree *rip_authentication_tree;
guint16 authtype;
rip_authentication_tree = gtk_tree_new();
add_subtree(tree, rip_authentication_tree, ETT_RIP_VEC);
rip_authentication_tree = proto_tree_new();
proto_item_add_subtree(tree, rip_authentication_tree, ETT_RIP_VEC);
authtype = ntohs(rip_authentication->authtype);
add_item_to_tree(rip_authentication_tree, offset + 2, 2,
proto_tree_add_item(rip_authentication_tree, offset + 2, 2,
"Authentication type: %u", authtype);
if (authtype == 2)
add_item_to_tree(rip_authentication_tree, offset + 4 , 16,
proto_tree_add_item(rip_authentication_tree, offset + 4 , 16,
"Password: %.16s",
rip_authentication->authentication);
}

View File

@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
* $Id: packet-tcp.c,v 1.15 1999/02/12 09:03:41 guy Exp $
* $Id: packet-tcp.c,v 1.16 1999/03/23 03:14:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -27,10 +27,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef NEED_SNPRINTF_H
# ifdef HAVE_STDARG_H
# include <stdarg.h>
@ -48,18 +44,81 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <glib.h>
#include "packet.h"
#include "resolv.h"
#include "follow.h"
#include "util.h"
#ifndef __PACKET_IP_H__
#include "packet-ip.h"
#endif
extern FILE* data_out_file;
extern packet_info pi;
static gchar info_str[COL_MAX_LEN];
static int info_len;
/* TCP Ports */
#define TCP_PORT_HTTP 80
#define TCP_PORT_PRINTER 515
#define TCP_ALT_PORT_HTTP 8080
/* TCP structs and definitions */
typedef struct _e_tcphdr {
guint16 th_sport;
guint16 th_dport;
guint32 th_seq;
guint32 th_ack;
guint8 th_off_x2; /* combines th_off and th_x2 */
guint8 th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
guint16 th_win;
guint16 th_sum;
guint16 th_urp;
} e_tcphdr;
/*
* TCP option
*/
#define TCPOPT_NOP 1 /* Padding */
#define TCPOPT_EOL 0 /* End of options */
#define TCPOPT_MSS 2 /* Segment size negotiating */
#define TCPOPT_WINDOW 3 /* Window scaling */
#define TCPOPT_SACK_PERM 4 /* SACK Permitted */
#define TCPOPT_SACK 5 /* SACK Block */
#define TCPOPT_ECHO 6
#define TCPOPT_ECHOREPLY 7
#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */
#define TCPOPT_CC 11
#define TCPOPT_CCNEW 12
#define TCPOPT_CCECHO 13
/*
* TCP option lengths
*/
#define TCPOLEN_MSS 4
#define TCPOLEN_WINDOW 3
#define TCPOLEN_SACK_PERM 2
#define TCPOLEN_SACK_MIN 2
#define TCPOLEN_ECHO 6
#define TCPOLEN_ECHOREPLY 6
#define TCPOLEN_TIMESTAMP 10
#define TCPOLEN_CC 6
#define TCPOLEN_CCNEW 6
#define TCPOLEN_CCECHO 6
static void
tcp_info_append_uint(const char *abbrev, guint32 val) {
int add_len = 0;
@ -73,41 +132,42 @@ tcp_info_append_uint(const char *abbrev, guint32 val) {
}
static void
dissect_tcpopt_maxseg(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_tcpopt_maxseg(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(opt_tree, offset, optlen,
"%s: %u bytes", name, pntohs(opd));
tcp_info_append_uint("MSS", pntohs(opd));
}
static void
dissect_tcpopt_wscale(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_tcpopt_wscale(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(opt_tree, offset, optlen,
"%s: %u bytes", name, *opd);
tcp_info_append_uint("WS", *opd);
}
static void
dissect_tcpopt_sack(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_tcpopt_sack(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
GtkWidget *field_tree = NULL, *tf;
proto_tree *field_tree = NULL;
proto_item *tf;
guint leftedge, rightedge;
tf = add_item_to_tree(opt_tree, offset, optlen, "%s:", name);
tf = proto_tree_add_item(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 = gtk_tree_new();
add_subtree(tf, field_tree, ETT_TCP_OPTION_SACK);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_TCP_OPTION_SACK);
}
if (optlen < 4) {
add_item_to_tree(field_tree, offset, optlen,
proto_tree_add_item(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -116,7 +176,7 @@ dissect_tcpopt_sack(GtkWidget *opt_tree, const char *name, const u_char *opd,
opd += 4;
optlen -= 4;
if (optlen < 4) {
add_item_to_tree(field_tree, offset, optlen,
proto_tree_add_item(field_tree, offset, optlen,
"(suboption would go past end of option)");
break;
}
@ -124,7 +184,7 @@ dissect_tcpopt_sack(GtkWidget *opt_tree, const char *name, const u_char *opd,
rightedge = pntohl(opd);
opd += 4;
optlen -= 4;
add_item_to_tree(field_tree, offset, 8,
proto_tree_add_item(field_tree, offset, 8,
"left edge = %u, right edge = %u", leftedge, rightedge);
tcp_info_append_uint("SLE", leftedge);
tcp_info_append_uint("SRE", rightedge);
@ -133,29 +193,29 @@ dissect_tcpopt_sack(GtkWidget *opt_tree, const char *name, const u_char *opd,
}
static void
dissect_tcpopt_echo(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_tcpopt_echo(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(opt_tree, offset, optlen,
"%s: %u", name, pntohl(opd));
tcp_info_append_uint("ECHO", pntohl(opd));
}
static void
dissect_tcpopt_timestamp(GtkWidget *opt_tree, const char *name,
dissect_tcpopt_timestamp(proto_tree *opt_tree, const char *name,
const u_char *opd, int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(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));
}
static void
dissect_tcpopt_cc(GtkWidget *opt_tree, const char *name, const u_char *opd,
dissect_tcpopt_cc(proto_tree *opt_tree, const char *name, const u_char *opd,
int offset, guint optlen)
{
add_item_to_tree(opt_tree, offset, optlen,
proto_tree_add_item(opt_tree, offset, optlen,
"%s: %u", name, pntohl(opd));
tcp_info_append_uint("CC", pntohl(opd));
}
@ -250,9 +310,10 @@ static ip_tcp_opt tcpopts[] = {
#define N_TCP_OPTS (sizeof tcpopts / sizeof tcpopts[0])
void
dissect_tcp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_tcphdr th;
GtkWidget *tcp_tree = NULL, *ti, *field_tree = NULL, *tf;
proto_tree *tcp_tree = NULL, *field_tree = NULL;
proto_item *ti, *tf;
gchar flags[64] = "<None>";
gchar *fstr[] = {"FIN", "SYN", "RST", "PSH", "ACK", "URG"};
gint fpos = 0, i;
@ -315,45 +376,45 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, hlen,
ti = proto_tree_add_item(tree, offset, hlen,
"Transmission Control Protocol");
tcp_tree = gtk_tree_new();
add_subtree(ti, tcp_tree, ETT_TCP);
add_item_to_tree(tcp_tree, offset, 2, "Source port: %s (%u)",
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)",
get_tcp_port(th.th_sport), th.th_sport);
add_item_to_tree(tcp_tree, offset + 2, 2, "Destination port: %s (%u)",
proto_tree_add_item(tcp_tree, offset + 2, 2, "Destination port: %s (%u)",
get_tcp_port(th.th_dport), th.th_dport);
add_item_to_tree(tcp_tree, offset + 4, 4, "Sequence number: %u",
proto_tree_add_item(tcp_tree, offset + 4, 4, "Sequence number: %u",
th.th_seq);
if (th.th_flags & TH_ACK)
add_item_to_tree(tcp_tree, offset + 8, 4, "Acknowledgement number: %u",
proto_tree_add_item(tcp_tree, offset + 8, 4, "Acknowledgement number: %u",
th.th_ack);
add_item_to_tree(tcp_tree, offset + 12, 1, "Header length: %u bytes", hlen);
tf = add_item_to_tree(tcp_tree, offset + 13, 1, "Flags: 0x%x", th.th_flags);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_TCP_FLAGS);
add_item_to_tree(field_tree, offset + 13, 1, "%s",
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",
decode_boolean_bitfield(th.th_flags, TH_URG, sizeof (th.th_flags)*8,
"Urgent pointer", "No urgent pointer"));
add_item_to_tree(field_tree, offset + 13, 1, "%s",
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_ACK, sizeof (th.th_flags)*8,
"Acknowledgment", "No acknowledgment"));
add_item_to_tree(field_tree, offset + 13, 1, "%s",
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_PUSH, sizeof (th.th_flags)*8,
"Push", "No push"));
add_item_to_tree(field_tree, offset + 13, 1, "%s",
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_RST, sizeof (th.th_flags)*8,
"Reset", "No reset"));
add_item_to_tree(field_tree, offset + 13, 1, "%s",
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_SYN, sizeof (th.th_flags)*8,
"Syn", "No Syn"));
add_item_to_tree(field_tree, offset + 13, 1, "%s",
proto_tree_add_item(field_tree, offset + 13, 1, "%s",
decode_boolean_bitfield(th.th_flags, TH_FIN, sizeof (th.th_flags)*8,
"Fin", "No Fin"));
add_item_to_tree(tcp_tree, offset + 14, 2, "Window size: %u", th.th_win);
add_item_to_tree(tcp_tree, offset + 16, 2, "Checksum: 0x%04x", th.th_sum);
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);
if (th.th_flags & TH_URG)
add_item_to_tree(tcp_tree, offset + 18, 2, "Urgent pointer: 0x%04x",
proto_tree_add_item(tcp_tree, offset + 18, 2, "Urgent pointer: 0x%04x",
th.th_urp);
}
@ -363,10 +424,10 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
options. */
optlen = hlen - sizeof (e_tcphdr); /* length of options, in bytes */
if (tree) {
tf = add_item_to_tree(tcp_tree, offset + 20, optlen,
tf = proto_tree_add_item(tcp_tree, offset + 20, optlen,
"Options: (%d bytes)", optlen);
field_tree = gtk_tree_new();
add_subtree(tf, field_tree, ETT_TCP_OPTIONS);
field_tree = proto_tree_new();
proto_item_add_subtree(tf, field_tree, ETT_TCP_OPTIONS);
}
dissect_ip_tcp_options(field_tree, &pd[offset + 20], offset + 20, optlen,
tcpopts, N_TCP_OPTS, TCPOPT_EOL);

View File

@ -3,7 +3,7 @@
*
* Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-tftp.c,v 1.1 1999/02/15 06:36:56 guy Exp $
* $Id: packet-tftp.c,v 1.2 1999/03/23 03:14:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -30,10 +30,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -44,9 +40,8 @@
#include <arpa/tftp.h>
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
char *tftp_opcodes[8] = {
"Unknown Request",
@ -71,9 +66,10 @@ char *tftp_errors[8] = {
};
void
dissect_tftp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_tftp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
GtkWidget *tftp_tree, *ti;
proto_tree *tftp_tree;
proto_item *ti;
struct tftphdr *tftp_pack = (struct tftphdr *)&pd[offset]; /* Want the hdr */
u_int i1;
@ -89,55 +85,55 @@ dissect_tftp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
ti = proto_tree_add_item(tree, offset, END_OF_FRAME,
"Trivial File Transfer Protocol");
tftp_tree = gtk_tree_new();
add_subtree(ti, tftp_tree, ETT_TFTP);
tftp_tree = proto_tree_new();
proto_item_add_subtree(ti, tftp_tree, ETT_TFTP);
switch (i1 = ntohs(tftp_pack -> th_opcode)) {
case RRQ:
add_item_to_tree(tftp_tree, offset, 2, "Read Request");
proto_tree_add_item(tftp_tree, offset, 2, "Read Request");
offset += 2;
i1 = strlen(pd+offset);
add_item_to_tree(tftp_tree, offset, i1+1, "Source File: %s", pd+offset);
proto_tree_add_item(tftp_tree, offset, i1+1, "Source File: %s", pd+offset);
offset += i1 + 1;
add_item_to_tree(tftp_tree, offset, END_OF_FRAME, "Type: %s",pd+offset);
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Type: %s",pd+offset);
break;
case WRQ:
add_item_to_tree(tftp_tree, offset, 2, "Write Request");
proto_tree_add_item(tftp_tree, offset, 2, "Write Request");
offset += 2;
i1 = strlen(pd+offset);
add_item_to_tree(tftp_tree, offset, i1+1, "Destination File: %s", pd+offset);
proto_tree_add_item(tftp_tree, offset, i1+1, "Destination File: %s", pd+offset);
offset += i1 + 1;
add_item_to_tree(tftp_tree, offset+2, END_OF_FRAME, "Type: %s",pd+offset);
proto_tree_add_item(tftp_tree, offset+2, END_OF_FRAME, "Type: %s",pd+offset);
break;
case DATA:
add_item_to_tree(tftp_tree, offset, 2, "Data Packet");
proto_tree_add_item(tftp_tree, offset, 2, "Data Packet");
offset += 2;
i1 = ntohs(*(short *)(pd + offset));
add_item_to_tree(tftp_tree, offset, 2, "Block = %u", i1);
proto_tree_add_item(tftp_tree, offset, 2, "Block = %u", i1);
offset += 2;
add_item_to_tree(tftp_tree, offset, END_OF_FRAME,
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME,
"Data (%d bytes)", END_OF_FRAME);
break;
case ACK:
add_item_to_tree(tftp_tree, offset, 2, "Acknowledgement");
proto_tree_add_item(tftp_tree, offset, 2, "Acknowledgement");
offset += 2;
i1 = ntohs(*(short *)(pd + offset));
add_item_to_tree(tftp_tree, offset, END_OF_FRAME, "Block = %u", i1);
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Block = %u", i1);
break;
case ERROR:
add_item_to_tree(tftp_tree, offset, 2, "Error Code");
proto_tree_add_item(tftp_tree, offset, 2, "Error Code");
offset += 2;
i1 = ntohs(*(short *)(pd + offset));
add_item_to_tree(tftp_tree, offset, 2, "Code = %s", tftp_errors[i1 % 8]);
proto_tree_add_item(tftp_tree, offset, 2, "Code = %s", tftp_errors[i1 % 8]);
offset += 2;
add_item_to_tree(tftp_tree, offset, END_OF_FRAME, "Error Message: %s", pd + offset);
proto_tree_add_item(tftp_tree, offset, END_OF_FRAME, "Error Message: %s", pd + offset);
break;
default:
add_item_to_tree(tftp_tree, offset, 2, "Unknown TFTP Request: %0X.", i1);
proto_tree_add_item(tftp_tree, offset, 2, "Unknown TFTP Request: %0X.", i1);
offset += 2;
add_item_to_tree(tftp_tree, offset, END_OF_FRAME,
proto_tree_add_item(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.11 1999/03/01 18:28:11 gram Exp $
* $Id: packet-tr.c,v 1.12 1999/03/23 03:14:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -28,25 +28,17 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <glib.h>
#include "packet.h"
#include "etypes.h"
static void
add_ring_bridge_pairs(int rcf_len, const u_char *pd, GtkWidget *tree);
add_ring_bridge_pairs(int rcf_len, const u_char *pd, proto_tree *tree);
static char*
sr_broadcast(u_char val) {
@ -169,15 +161,16 @@ capture_tr(const u_char *pd, guint32 cap_len, packet_counts *ld) {
void
dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
dissect_tr(const u_char *pd, frame_data *fd, proto_tree *tree) {
GtkWidget *fh_tree, *ti;
proto_tree *fh_tree;
proto_item *ti;
int offset = 14;
int source_routed = 0;
int frame_type;
guint8 trn_rif_bytes;
guint8 actual_rif_bytes;
guint8 trn_rif_bytes;
guint8 actual_rif_bytes;
/* The trn_hdr struct, as separate variables */
guint8 trn_ac; /* access control field */
@ -203,10 +196,6 @@ dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
/* Token-Ring Strings */
char *fc[] = { "MAC", "LLC", "Reserved", "Unknown" };
/* char *fc_pcf[] = {
"Normal buffer", "Express buffer", "Purge",
"Claim Token", "Beacon", "Active Monitor Present",
"Standby Monitor Present" };*/
char *rc_arrow[] = { "-->", "<--" };
char *rc_direction[] = { "From originating station",
"To originating station" };
@ -293,11 +282,10 @@ dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
/* protocol analysis tree */
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), 0, 14 + actual_rif_bytes,
"Token-Ring");
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_TOKEN_RING);
add_item_to_tree(fh_tree, 0, 1,
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);
proto_tree_add_item(fh_tree, 0, 1,
"Access Control: %s, Priority=%d, Monitor Count=%d, "
"Priority Reservation=%d",
((trn_ac & 16) >> 4) ? "Frame" : "Token", /* frame/token */
@ -305,26 +293,26 @@ dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
((trn_ac & 8) >> 3), /* monitor count */
((trn_ac & 7))); /* priority reserv. */
add_item_to_tree(fh_tree, 1, 1,
proto_tree_add_item(fh_tree, 1, 1,
"Frame Control: %s, Physical Control=%d (%s)",
fc[frame_type], (trn_fc & 15),
val_to_str((trn_fc & 15), fc_pcf, "Unknown"));
add_item_to_tree(fh_tree, 2, 6, "Destination: %s",
proto_tree_add_item(fh_tree, 2, 6, "Destination: %s",
ether_to_str((guint8 *) trn_dhost));
add_item_to_tree(fh_tree, 8, 6, "Source: %s",
proto_tree_add_item(fh_tree, 8, 6, "Source: %s",
ether_to_str((guint8 *) trn_shost));
if (source_routed) {
add_item_to_tree(fh_tree, 14, 1, "RIF length: %d bytes", trn_rif_bytes);
proto_tree_add_item(fh_tree, 14, 1, "RIF length: %d bytes", trn_rif_bytes);
add_item_to_tree(fh_tree, 15, 1,
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);
add_item_to_tree(fh_tree, 15, 1,
proto_tree_add_item(fh_tree, 15, 1,
"Direction: %s (%s)",
rc_direction[(pd[15] & 128) >> 7],
rc_arrow[(pd[15] & 128) >> 7]);
@ -347,18 +335,18 @@ dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
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);*/
add_item_to_tree(fh_tree, 14 + trn_rif_bytes, actual_rif_bytes - trn_rif_bytes,
proto_tree_add_item(fh_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) {
add_item_to_tree(fh_tree, 14 + trn_rif_bytes, 18 - actual_rif_bytes,
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 ) {
add_item_to_tree(fh_tree, 14, 18,
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.");
}*/
@ -383,7 +371,7 @@ dissect_tr(const u_char *pd, frame_data *fd, GtkTree *tree) {
/* this routine is taken from the Linux net/802/tr.c code, which shows
ring-bridge paires in the /proc/net/tr_rif virtual file. */
static void
add_ring_bridge_pairs(int rcf_len, const u_char *pd, GtkWidget *tree)
add_ring_bridge_pairs(int rcf_len, const u_char *pd, proto_tree *tree)
{
int j, size;
int segment, brdgnmb;
@ -398,16 +386,16 @@ add_ring_bridge_pairs(int rcf_len, const u_char *pd, GtkWidget *tree)
for(j = 1; j < rcf_len; j++) {
if (j==1) {
segment=pntohs(&pd[16]) >> 4;
size = sprintf(buffer,"%03X",segment);
size = sprintf(buffer, "%03X",segment);
buff_offset += size;
}
segment=pntohs(&pd[17+j]) >> 4;
brdgnmb=pd[16+j] & 0x0f;
size = sprintf(buffer+buff_offset,"-%01X-%03X",brdgnmb,segment);
size = sprintf(buffer+buff_offset, "-%01X-%03X",brdgnmb,segment);
buff_offset += size;
}
add_item_to_tree(tree, 16, rcf_len << 1,
proto_tree_add_item(tree, 16, rcf_len << 1,
"Ring-Bridge Pairs: %s",
buffer);

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.10 1999/03/01 18:28:11 gram Exp $
* $Id: packet-trmac.c,v 1.11 1999/03/23 03:14:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -32,22 +32,8 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
/* Major Vector */
static value_string major_vectors[] = {
@ -81,7 +67,7 @@ static value_string major_vectors[] = {
/* Sub-vectors */
static int
sv_text(const u_char *pd, int pkt_offset, GtkWidget *tree)
sv_text(const u_char *pd, int pkt_offset, proto_tree *tree)
{
int sv_length = pd[0];
@ -89,175 +75,177 @@ sv_text(const u_char *pd, int pkt_offset, GtkWidget *tree)
"Streaming signal not Claim Token MAC frame",
"Streaming signal, Claim Token MAC frame"};
GtkWidget *sv_tree, *ti;
proto_tree *sv_tree;
proto_item *ti;
u_char errors[6]; /* isolating or non-isolating */
/* this just adds to the clutter on the screen...
add_item_to_tree(tree, pkt_offset, 1,
proto_tree_add_item(tree, pkt_offset, 1,
"Subvector Length: %d bytes", sv_length);*/
switch(pd[1]) {
case 0x01: /* Beacon Type */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Beacon Type: %s", beacon[ pntohs( &pd[2] ) ] );
break;
case 0x02: /* NAUN */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"NAUN: %s", ether_to_str((guint8*)&pd[2]));
break;
case 0x03: /* Local Ring Number */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(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 */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Assign Physical Location: 0x%08X", pntohl( &pd[2] ) );
break;
case 0x05: /* Soft Error Report Value */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Soft Error Report Value: %d ms", 10 * pntohs( &pd[2] ) );
break;
case 0x06: /* Enabled Function Classes */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Enabled Function Classes: %04X", pntohs( &pd[2] ) );
break;
case 0x07: /* Allowed Access Priority */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Allowed Access Priority: %04X", pntohs( &pd[2] ) );
break;
case 0x09: /* Correlator */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Correlator: %04X", pntohs( &pd[2] ) );
break;
case 0x0A: /* Address of last neighbor notification */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Address of Last Neighbor Notification: %s",
ether_to_str((guint8*)&pd[2]));
break;
case 0x0B: /* Physical Location */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Physical Location: 0x%08X", pntohl( &pd[2] ) );
break;
case 0x20: /* Response Code */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Response Code: 0x%04X 0x%04X", pntohl( &pd[2] ),
pntohl( &pd[4] ) );
break;
case 0x21: /* Reserved */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Reserved: 0x%04X", pntohs( &pd[2] ) );
break;
case 0x22: /* Product Instance ID */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Product Instance ID: ...");
break;
case 0x23: /* Ring Station Microcode Level */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Ring Station Microcode Level: ...");
break;
case 0x26: /* Wrap data */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Wrap Data: ... (%d bytes)", sv_length - 2);
break;
case 0x27: /* Frame Forward */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Frame Forward: ... (%d bytes)", sv_length - 2);
break;
case 0x29: /* Ring Station Status Subvector */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Ring Station Status Subvector: ...");
break;
case 0x2A: /* Transmit Status Code */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Transmit Status Code: %04X", pntohs( &pd[2] ) );
break;
case 0x2B: /* Group Address */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Group Address: %08X", pntohl( &pd[2] ) );
break;
case 0x2C: /* Functional Address */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(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 = add_item_to_tree(GTK_WIDGET(tree), pkt_offset+1, sv_length-1,
ti = proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Isolating Error Counts (%d total)",
errors[0] + errors[1] + errors[2] + errors[3] + errors[4]);
sv_tree = gtk_tree_new();
add_subtree(ti, sv_tree, ETT_TR_IERR_CNT);
sv_tree = proto_tree_new();
proto_item_add_subtree(ti, sv_tree, ETT_TR_IERR_CNT);
add_item_to_tree(sv_tree, pkt_offset+2, 1,
proto_tree_add_item(sv_tree, pkt_offset+2, 1,
"Line Errors: %d", errors[0]);
add_item_to_tree(sv_tree, pkt_offset+3, 1,
proto_tree_add_item(sv_tree, pkt_offset+3, 1,
"Internal Errors: %d", errors[1]);
add_item_to_tree(sv_tree, pkt_offset+4, 1,
proto_tree_add_item(sv_tree, pkt_offset+4, 1,
"Burst Errors: %d", errors[2]);
add_item_to_tree(sv_tree, pkt_offset+5, 1,
proto_tree_add_item(sv_tree, pkt_offset+5, 1,
"A/C Errors: %d", errors[3]);
add_item_to_tree(sv_tree, pkt_offset+6, 1,
proto_tree_add_item(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 = add_item_to_tree(GTK_WIDGET(tree), pkt_offset+1, sv_length-1,
ti = proto_tree_add_item(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 = gtk_tree_new();
add_subtree(ti, sv_tree, ETT_TR_NERR_CNT);
sv_tree = proto_tree_new();
proto_item_add_subtree(ti, sv_tree, ETT_TR_NERR_CNT);
add_item_to_tree(sv_tree, pkt_offset+2, 1,
proto_tree_add_item(sv_tree, pkt_offset+2, 1,
"Lost Frame Errors: %d", errors[0]);
add_item_to_tree(sv_tree, pkt_offset+3, 1,
proto_tree_add_item(sv_tree, pkt_offset+3, 1,
"Receiver Congestion: %d", errors[1]);
add_item_to_tree(sv_tree, pkt_offset+4, 1,
proto_tree_add_item(sv_tree, pkt_offset+4, 1,
"Frame-Copied Congestion: %d", errors[2]);
add_item_to_tree(sv_tree, pkt_offset+5, 1,
proto_tree_add_item(sv_tree, pkt_offset+5, 1,
"Frequency Errors: %d", errors[3]);
add_item_to_tree(sv_tree, pkt_offset+6, 1,
proto_tree_add_item(sv_tree, pkt_offset+6, 1,
"Token Errors: %d", errors[4]);
break;
case 0x30: /* Error Code */
add_item_to_tree(tree, pkt_offset+1, sv_length-1,
proto_tree_add_item(tree, pkt_offset+1, sv_length-1,
"Error Code: %04X", pntohs( &pd[2] ) );
break;
default: /* Unknown */
add_item_to_tree(tree, pkt_offset+1, 1,
proto_tree_add_item(tree, pkt_offset+1, 1,
"Unknown Sub-Vector: 0x%02X", pd[1]);
}
return sv_length;
}
void
dissect_trmac(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_trmac(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
GtkWidget *mac_tree = NULL, *ti;
proto_tree *mac_tree = NULL;
proto_item *ti;
int mv_length, sv_length, sv_offset, sv_additional;
char *class[] = { "Ring Station", "LLC Manager", "", "",
"Configuration Report Server", "Ring Parameter Server",
@ -267,10 +255,10 @@ dissect_trmac(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
mv_length = pntohs(&pd[offset]);
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, mv_length,
ti = proto_tree_add_item(tree, offset, mv_length,
"Media Access Control");
mac_tree = gtk_tree_new();
add_subtree(ti, mac_tree, ETT_TR_MAC);
mac_tree = proto_tree_new();
proto_item_add_subtree(ti, mac_tree, ETT_TR_MAC);
}
/* Interpret the major vector */
@ -284,16 +272,16 @@ dissect_trmac(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
if (tree) {
if (mv_text)
add_item_to_tree(mac_tree, offset+3, 1, "Major Vector Command: %s",
proto_tree_add_item(mac_tree, offset+3, 1, "Major Vector Command: %s",
mv_text);
else
add_item_to_tree(mac_tree, offset+3, 1, "Major Vector Command: %02X (Unknown)",
proto_tree_add_item(mac_tree, offset+3, 1, "Major Vector Command: %02X (Unknown)",
pd[offset+3]);
add_item_to_tree(mac_tree, offset, 2, "Total Length: %d bytes",
proto_tree_add_item(mac_tree, offset, 2, "Total Length: %d bytes",
mv_length);
add_item_to_tree(mac_tree, offset+2, 1, "Source Class: %s",
proto_tree_add_item(mac_tree, offset+2, 1, "Source Class: %s",
class[ pd[offset+2] & 0x0f ]);
add_item_to_tree(mac_tree, offset+2, 1, "Destination Class: %s",
proto_tree_add_item(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.13 1999/03/01 18:28:12 gram Exp $
* $Id: packet-udp.c,v 1.14 1999/03/23 03:14:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -29,11 +29,6 @@
# include "config.h"
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@ -42,13 +37,37 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include "packet.h"
#include "resolv.h"
/* UDP structs and definitions */
typedef struct _e_udphdr {
guint16 uh_sport;
guint16 uh_dport;
guint16 uh_ulen;
guint16 uh_sum;
} e_udphdr;
/* UDP Ports -> should go in packet-udp.h */
#define UDP_PORT_DNS 53
#define UDP_PORT_BOOTPS 67
#define UDP_PORT_TFTP 69
#define UDP_PORT_IPX 213
#define UDP_PORT_NBNS 137
#define UDP_PORT_NBDGM 138
#define UDP_PORT_RIP 520
#define UDP_PORT_VINES 573
struct hash_struct {
guint16 proto;
void (*dissect)(const u_char *, int, frame_data *, GtkTree *);
void (*dissect)(const u_char *, int, frame_data *, proto_tree *);
struct hash_struct *next;
};
@ -83,7 +102,7 @@ struct hash_struct *udp_find_hash_ent(guint16 proto) {
}
void udp_hash_add(guint16 proto,
void (*dissect)(const u_char *, int, frame_data *, GtkTree *)) {
void (*dissect)(const u_char *, int, frame_data *, proto_tree *)) {
int idx = proto % 256; /* Simply take the remainder, hope for no collisions */
struct hash_struct *hash_ent = (struct hash_struct *)malloc(sizeof(struct hash_struct));
@ -135,11 +154,12 @@ void init_dissect_udp(void) {
}
void
dissect_udp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_udphdr uh;
guint16 uh_sport, uh_dport, uh_ulen, uh_sum;
struct hash_struct *dissect_routine = NULL;
GtkWidget *udp_tree, *ti;
proto_tree *udp_tree;
proto_item *ti;
/* To do: Check for {cap len,pkt len} < struct len */
/* Avoids alignment problems on many architectures. */
@ -164,16 +184,15 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
col_add_fstr(fd, COL_UNRES_DST_PORT, "%u", uh_dport);
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 8,
"User Datagram Protocol");
udp_tree = gtk_tree_new();
add_subtree(ti, udp_tree, ETT_UDP);
add_item_to_tree(udp_tree, offset, 2, "Source port: %s (%u)",
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)",
get_udp_port(uh_sport), uh_sport);
add_item_to_tree(udp_tree, offset + 2, 2, "Destination port: %s (%u)",
proto_tree_add_item(udp_tree, offset + 2, 2, "Destination port: %s (%u)",
get_udp_port(uh_dport), uh_dport);
add_item_to_tree(udp_tree, offset + 4, 2, "Length: %u", uh_ulen);
add_item_to_tree(udp_tree, offset + 6, 2, "Checksum: 0x%04x", uh_sum);
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);
}
/* 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.5 1998/12/29 04:05:36 gerald Exp $
* $Id: packet-vines.c,v 1.6 1999/03/23 03:14:45 gram Exp $
*
* Don Lafontaine <lafont02@cn.ca>
*
@ -28,10 +28,6 @@
#include "config.h"
#include <gtk/gtk.h>
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@ -40,9 +36,8 @@
#include <netinet/in.h>
#endif
#include "ethereal.h"
#include <glib.h>
#include "packet.h"
#include "etypes.h"
#include "packet-vines.h"
@ -52,9 +47,10 @@
*/
void
dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint8 vines_frp_ctrl, vines_frp_seqno;
GtkWidget *vines_frp_tree, *ti;
proto_tree *vines_frp_tree;
proto_item *ti;
gchar frp_flags_str[32];
/* To do: Check for {cap len,pkt len} < struct len */
@ -88,12 +84,11 @@ dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), offset, 2,
"Vines Fragmentation Protocol");
vines_frp_tree = gtk_tree_new();
add_subtree(ti, vines_frp_tree, ETT_VINES_FRP);
add_item_to_tree(vines_frp_tree, offset, 1, "Control Flags: 0x%02x = %s fragment", vines_frp_ctrl, frp_flags_str);
add_item_to_tree(vines_frp_tree, offset + 1, 1, "Sequence Number: 0x%02x", vines_frp_seqno);
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);
}
/* Skip over header */
@ -104,10 +99,11 @@ dissect_vines_frp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
}
void
dissect_vines(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
dissect_vines(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
e_vip viph;
GtkWidget *vip_tree, *ti;
proto_tree *vip_tree;
proto_item *ti;
/* gchar tos_str[32]; */
int is_broadcast = 0;
int hops = 0;
@ -199,15 +195,14 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
*/
if (tree)
{
ti = add_item_to_tree(GTK_WIDGET(tree), offset, (viph.vip_pktlen),
"Vines IP");
vip_tree = gtk_tree_new();
add_subtree(ti, vip_tree, ETT_VINES);
add_item_to_tree(vip_tree, offset, 2, "Packet checksum: 0x%04x", viph.vip_chksum);
add_item_to_tree(vip_tree, offset + 2, 2, "Packet length: 0x%04x (%d)", viph.vip_pktlen, viph.vip_pktlen);
add_item_to_tree(vip_tree, offset + 4, 1, "Transport control: 0x%02x",
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",
viph.vip_tctl);
add_item_to_tree(vip_tree, offset + 5, 1, "Protocol: 0x%02x", viph.vip_proto);
proto_tree_add_item(vip_tree, offset + 5, 1, "Protocol: 0x%02x", viph.vip_proto);
}
@ -221,10 +216,11 @@ dissect_vines(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
}
#define VINES_VSPP_DATA 1
#define VINES_VSPP_ACK 5
void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
e_vspp viph;
GtkWidget *vspp_tree, *ti;
proto_tree *vspp_tree;
proto_item *ti;
/* To do: check for runts, errs, etc. */
/* Avoids alignment problems on many architectures. */
@ -287,19 +283,18 @@ void dissect_vines_spp(const u_char *pd, int offset, frame_data *fd, GtkTree *tr
*/
if (tree)
{
ti = add_item_to_tree(GTK_WIDGET(tree), offset, sizeof(viph),
"Vines SPP");
vspp_tree = gtk_tree_new();
add_subtree(ti, vspp_tree, ETT_VINES_SPP);
add_item_to_tree(vspp_tree, offset, 2, "Source port: 0x%04x", viph.vspp_sport);
add_item_to_tree(vspp_tree, offset+2, 2, "Destination port: 0x%04x", viph.vspp_dport);
add_item_to_tree(vspp_tree, offset+4, 1, "Packet type: 0x%02x", viph.vspp_pkttype);
add_item_to_tree(vspp_tree, offset+5, 1, "Control: 0x%02x", viph.vspp_control);
add_item_to_tree(vspp_tree, offset+6, 2, "Local Connection ID: 0x%04x", viph.vspp_lclid);
add_item_to_tree(vspp_tree, offset+8, 2, "Remote Connection ID: 0x%04x", viph.vspp_rmtid);
add_item_to_tree(vspp_tree, offset+10, 2, "Sequence number: 0x%04x", viph.vspp_seqno);
add_item_to_tree(vspp_tree, offset+12, 2, "Ack number: 0x%04x", viph.vspp_ack);
add_item_to_tree(vspp_tree, offset+14, 2, "Window: 0x%04x", viph.vspp_win);
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);
}
}

141
packet.c
View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.20 1999/02/12 09:03:41 guy Exp $
* $Id: packet.c,v 1.21 1999/03/23 03:14:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,7 +31,7 @@
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <glib.h>
#include <stdio.h>
#include <stdarg.h>
@ -47,13 +47,9 @@
# include <netinet/in.h>
#endif
#include "ethereal.h"
#include "packet.h"
#include "etypes.h"
#include "file.h"
extern GtkWidget *byte_view;
extern GdkFont *m_r_font, *m_b_font;
extern capture_file cf;
gchar *
@ -139,93 +135,7 @@ time_secs_to_str(guint32 time)
return cur;
}
void
packet_hex_print(GtkText *bv, guchar *pd, gint len, gint bstart, gint blen) {
gint i = 0, j, k, cur;
gchar line[128], hexchars[] = "0123456789abcdef";
GdkFont *cur_font, *new_font;
while (i < len) {
/* Print the line number */
sprintf(line, "%04x ", i);
gtk_text_insert(bv, m_r_font, NULL, NULL, line, -1);
/* Do we start in bold? */
cur_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
j = i;
k = i + BYTE_VIEW_WIDTH;
cur = 0;
/* Print the hex bit */
while (i < k) {
if (i < len) {
line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
line[cur++] = hexchars[pd[i] & 0x0f];
} else {
line[cur++] = ' '; line[cur++] = ' ';
}
line[cur++] = ' ';
i++;
/* Did we cross a bold/plain boundary? */
new_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
if (cur_font != new_font) {
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur_font = new_font;
cur = 0;
}
}
line[cur++] = ' ';
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur = 0;
i = j;
/* Print the ASCII bit */
cur_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
while (i < k) {
if (i < len) {
line[cur++] = (isgraph(pd[i])) ? pd[i] : '.';
} else {
line[cur++] = ' ';
}
i++;
/* Did we cross a bold/plain boundary? */
new_font = (i >= bstart && i < (bstart + blen)) ? m_b_font : m_r_font;
if (cur_font != new_font) {
gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
cur_font = new_font;
cur = 0;
}
}
line[cur++] = '\n';
line[cur] = '\0';
gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
}
}
static void
set_item_style(GtkWidget *widget, gpointer dummy)
{
gtk_widget_set_style(widget, item_style);
}
GtkWidget *
add_item_to_tree(GtkWidget *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 ti;
}
/*
* Given a pointer into a data buffer, and to the end of the buffer,
@ -359,36 +269,6 @@ format_line(const u_char *line, int len)
return linebuf;
}
void
set_item_len(GtkWidget *ti, gint len)
{
gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len);
}
void
add_subtree(GtkWidget *ti, GtkWidget *subtree, gint idx) {
static gint tree_type[NUM_TREE_TYPES];
gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), 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]);
}
void
expand_tree(GtkWidget *w, gpointer data) {
gint *val = (gint *) data;
*val = 1;
}
void
collapse_tree(GtkWidget *w, gpointer data) {
gint *val = (gint *) data;
*val = 0;
}
/* Tries to match val against each element in the value_string array vs.
Returns the associated string ptr on a match.
@ -487,9 +367,10 @@ static const char *mon_names[12] = {
/* this routine checks the frame type from the cf structure */
void
dissect_packet(const u_char *pd, frame_data *fd, GtkTree *tree)
dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
{
GtkWidget *fh_tree, *ti;
proto_tree *fh_tree;
proto_item *ti;
struct tm *tmp;
time_t then;
@ -511,15 +392,15 @@ dissect_packet(const u_char *pd, frame_data *fd, GtkTree *tree)
}
if (tree) {
ti = add_item_to_tree(GTK_WIDGET(tree), 0, fd->cap_len,
ti = proto_tree_add_item(tree, 0, fd->cap_len,
"Frame (%d on wire, %d captured)",
fd->pkt_len, fd->cap_len);
fh_tree = gtk_tree_new();
add_subtree(ti, fh_tree, ETT_FRAME);
fh_tree = proto_tree_new();
proto_item_add_subtree(ti, fh_tree, ETT_FRAME);
then = fd->abs_secs;
tmp = localtime(&then);
add_item_to_tree(fh_tree, 0, 0,
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,
@ -529,9 +410,9 @@ dissect_packet(const u_char *pd, frame_data *fd, GtkTree *tree)
tmp->tm_sec,
(long)fd->abs_usecs/100);
add_item_to_tree(fh_tree, 0, 0, "Total frame length: %d bytes",
proto_tree_add_item(fh_tree, 0, 0, "Total frame length: %d bytes",
fd->pkt_len);
add_item_to_tree(fh_tree, 0, 0, "Capture frame length: %d bytes",
proto_tree_add_item(fh_tree, 0, 0, "Capture frame length: %d bytes",
fd->cap_len);
}

444
packet.h
View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.40 1999/03/22 03:56:34 guy Exp $
* $Id: packet.h,v 1.41 1999/03/23 03:14:45 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -60,8 +60,6 @@
*/
#define END_OF_FRAME (fd->cap_len - offset)
#define IEEE_802_3_MAX_LEN 1500
#define BYTE_VIEW_WIDTH 16
typedef struct _column_info {
gint num_cols; /* Number of columns */
@ -113,266 +111,10 @@ typedef struct _value_string {
gchar *strptr;
} value_string;
/* Many of the structs and definitions below were taken from include files
* in the Linux distribution. */
/* Many of the structs and definitions below and in packet-*.c files
* were taken from include files in the Linux distribution. */
/* ARP / RARP structs and definitions */
#ifndef ARPOP_REQUEST
#define ARPOP_REQUEST 1 /* ARP request. */
#endif
#ifndef ARPOP_REPLY
#define ARPOP_REPLY 2 /* ARP reply. */
#endif
/* Some OSes have different names, or don't define these at all */
#ifndef ARPOP_RREQUEST
#define ARPOP_RREQUEST 3 /* RARP request. */
#endif
#ifndef ARPOP_RREPLY
#define ARPOP_RREPLY 4 /* RARP reply. */
#endif
/* ICMP structs and definitions */
typedef struct _e_icmp {
guint8 icmp_type;
guint8 icmp_code;
guint16 icmp_cksum;
union {
struct { /* Address mask request/reply */
guint16 id;
guint16 seq;
guint32 sn_mask;
} am;
struct { /* Timestap request/reply */
guint16 id;
guint16 seq;
guint32 orig;
guint32 recv;
guint32 xmit;
} ts;
guint32 zero; /* Unreachable */
} opt;
} e_icmp;
#define ICMP_ECHOREPLY 0
#define ICMP_UNREACH 3
#define ICMP_SOURCEQUENCH 4
#define ICMP_REDIRECT 5
#define ICMP_ECHO 8
#define ICMP_TIMXCEED 11
#define ICMP_PARAMPROB 12
#define ICMP_TSTAMP 13
#define ICMP_TSTAMPREPLY 14
#define ICMP_IREQ 15
#define ICMP_IREQREPLY 16
#define ICMP_MASKREQ 17
#define ICMP_MASKREPLY 18
/* IGMP structs and definitions */
typedef struct _e_igmp {
guint8 igmp_v_t; /* combines igmp_v and igmp_t */
guint8 igmp_unused;
guint16 igmp_cksum;
guint32 igmp_gaddr;
} e_igmp;
#define IGMP_M_QRY 0x01
#define IGMP_V1_M_RPT 0x02
#define IGMP_V2_LV_GRP 0x07
#define IGMP_DVMRP 0x03
#define IGMP_PIM 0x04
#define IGMP_V2_M_RPT 0x06
#define IGMP_MTRC_RESP 0x1e
#define IGMP_MTRC 0x1f
/* IP structs and definitions */
typedef struct _e_ip {
guint8 ip_v_hl; /* combines ip_v and ip_hl */
guint8 ip_tos;
guint16 ip_len;
guint16 ip_id;
guint16 ip_off;
guint8 ip_ttl;
guint8 ip_p;
guint16 ip_sum;
guint32 ip_src;
guint32 ip_dst;
} e_ip;
/* IP flags. */
#define IP_CE 0x8000 /* Flag: "Congestion" */
#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
#define IP_MF 0x2000 /* Flag: "More Fragments" */
#define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_NONE 0x00
#define IPTOS_LOWCOST 0x02
#define IPTOS_RELIABILITY 0x04
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_LOWDELAY 0x10
#define IPTOS_SECURITY 0x1E
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/* IP options */
#define IPOPT_COPY 0x80
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_MEASUREMENT 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_END (0 |IPOPT_CONTROL)
#define IPOPT_NOOP (1 |IPOPT_CONTROL)
#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
#define IPOPT_RR (7 |IPOPT_CONTROL)
#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
/* IP option lengths */
#define IPOLEN_SEC 11
#define IPOLEN_LSRR_MIN 3
#define IPOLEN_TIMESTAMP_MIN 5
#define IPOLEN_RR_MIN 3
#define IPOLEN_SID 4
#define IPOLEN_SSRR_MIN 3
#define IPSEC_UNCLASSIFIED 0x0000
#define IPSEC_CONFIDENTIAL 0xF135
#define IPSEC_EFTO 0x789A
#define IPSEC_MMMM 0xBC4D
#define IPSEC_RESTRICTED 0xAF13
#define IPSEC_SECRET 0xD788
#define IPSEC_TOPSECRET 0x6BC5
#define IPSEC_RESERVED1 0x35E2
#define IPSEC_RESERVED2 0x9AF1
#define IPSEC_RESERVED3 0x4D78
#define IPSEC_RESERVED4 0x24BD
#define IPSEC_RESERVED5 0x135E
#define IPSEC_RESERVED6 0x89AF
#define IPSEC_RESERVED7 0xC4D6
#define IPSEC_RESERVED8 0xE26B
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
#define IP_PROTO_ICMP 1
#define IP_PROTO_IGMP 2
#define IP_PROTO_TCP 6
#define IP_PROTO_UDP 17
#define IP_PROTO_OSPF 89
/* Null/loopback structs and definitions */
typedef struct _e_nullhdr {
guint8 null_next;
guint8 null_len;
guint16 null_family;
} e_nullhdr;
/* PPP structs and definitions */
typedef struct _e_ppphdr {
guint8 ppp_addr;
guint8 ppp_ctl;
guint16 ppp_prot;
} e_ppphdr;
/* TCP structs and definitions */
typedef struct _e_tcphdr {
guint16 th_sport;
guint16 th_dport;
guint32 th_seq;
guint32 th_ack;
guint8 th_off_x2; /* combines th_off and th_x2 */
guint8 th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
guint16 th_win;
guint16 th_sum;
guint16 th_urp;
} e_tcphdr;
/*
* TCP option
*/
#define TCPOPT_NOP 1 /* Padding */
#define TCPOPT_EOL 0 /* End of options */
#define TCPOPT_MSS 2 /* Segment size negotiating */
#define TCPOPT_WINDOW 3 /* Window scaling */
#define TCPOPT_SACK_PERM 4 /* SACK Permitted */
#define TCPOPT_SACK 5 /* SACK Block */
#define TCPOPT_ECHO 6
#define TCPOPT_ECHOREPLY 7
#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */
#define TCPOPT_CC 11
#define TCPOPT_CCNEW 12
#define TCPOPT_CCECHO 13
/*
* TCP option lengths
*/
#define TCPOLEN_MSS 4
#define TCPOLEN_WINDOW 3
#define TCPOLEN_SACK_PERM 2
#define TCPOLEN_SACK_MIN 2
#define TCPOLEN_ECHO 6
#define TCPOLEN_ECHOREPLY 6
#define TCPOLEN_TIMESTAMP 10
#define TCPOLEN_CC 6
#define TCPOLEN_CCNEW 6
#define TCPOLEN_CCECHO 6
/* UDP structs and definitions */
typedef struct _e_udphdr {
guint16 uh_sport;
guint16 uh_dport;
guint16 uh_ulen;
guint16 uh_sum;
} e_udphdr;
/* UDP Ports -> should go in packet-udp.h */
#define UDP_PORT_DNS 53
#define UDP_PORT_BOOTPS 67
#define UDP_PORT_TFTP 69
#define UDP_PORT_IPX 213
#define UDP_PORT_NBNS 137
#define UDP_PORT_NBDGM 138
#define UDP_PORT_RIP 520
#define UDP_PORT_VINES 573
/* TCP Ports */
#define TCP_PORT_HTTP 80
#define TCP_PORT_PRINTER 515
#define TCP_ALT_PORT_HTTP 8080
/* Tree types. Each dissect_* routine should have one for each
add_subtree() call. */
@ -473,42 +215,13 @@ enum {
#define DLT_PPP_BSDOS 14
#endif
typedef enum {
NO_LENGTH, /* option has no data, hence no length */
FIXED_LENGTH, /* option always has the same length */
VARIABLE_LENGTH /* option is variable-length - optlen is minimum */
} opt_len_type;
/* Member of table of IP or TCP options. */
typedef struct {
int optcode; /* code for option */
char *name; /* name of option */
opt_len_type len_type; /* type of option length field */
int optlen; /* value length should be (minimum if VARIABLE) */
void (*dissect)(GtkWidget *, const char *, const u_char *, int, guint);
/* routine to dissect option */
} ip_tcp_opt;
/* Routine to dissect IP or TCP options. */
void dissect_ip_tcp_options(GtkWidget *, const u_char *, int, guint,
ip_tcp_opt *, int, int);
/* Utility routines used by packet*.c */
gchar* ether_to_str(const guint8 *);
gchar* ip_to_str(const guint8 *);
gchar* time_secs_to_str(guint32);
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"
#if __GNUC__ == 2
GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...)
__attribute__((format (printf, 4, 5)));
#else
GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...);
#endif
const u_char *find_line_end(const u_char *data, const u_char *dataend);
gchar* format_line(const u_char *line, int len);
void set_item_len(GtkWidget *, gint);
gchar* val_to_str(guint32, const value_string *, const char *);
gchar* match_strval(guint32, const value_string*);
gint check_col(frame_data *, gint);
@ -522,11 +235,25 @@ void col_add_str(frame_data *, gint, gchar *);
/* Routines in packet.c */
void dissect_packet(const u_char *, frame_data *, GtkTree *);
void add_subtree(GtkWidget *, GtkWidget*, gint);
void expand_tree(GtkWidget *, gpointer);
void collapse_tree(GtkWidget *, gpointer);
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 *);
/*
* Routines in packet-*.c
* Routines should take three args: packet data *, cap_len, packet_counts *
@ -553,12 +280,12 @@ void capture_ip(const u_char *, int, guint32, packet_counts *);
* Routines should take three args: packet data *, frame_data *, tree *
* They should never modify the packet data.
*/
void dissect_eth(const u_char *, frame_data *, GtkTree *);
void dissect_fddi(const u_char *, frame_data *, GtkTree *);
void dissect_null(const u_char *, frame_data *, GtkTree *);
void dissect_ppp(const u_char *, frame_data *, GtkTree *);
void dissect_raw(const u_char *, frame_data *, GtkTree *);
void dissect_tr(const u_char *, frame_data *, GtkTree *);
void dissect_eth(const u_char *, frame_data *, proto_tree *);
void dissect_fddi(const u_char *, frame_data *, proto_tree *);
void dissect_null(const u_char *, frame_data *, proto_tree *);
void dissect_ppp(const u_char *, frame_data *, proto_tree *);
void dissect_raw(const u_char *, frame_data *, proto_tree *);
void dissect_tr(const u_char *, frame_data *, proto_tree *);
/*
* Routines in packet-*.c
@ -566,42 +293,42 @@ void dissect_tr(const u_char *, frame_data *, GtkTree *);
* tree *
* They should never modify the packet data.
*/
void dissect_aarp(const u_char *, int, frame_data *, GtkTree *);
void dissect_arp(const u_char *, int, frame_data *, GtkTree *);
void dissect_bootp(const u_char *, int, frame_data *, GtkTree *);
void dissect_cdp(const u_char *, int, frame_data *, GtkTree *);
void dissect_data(const u_char *, int, frame_data *, GtkTree *);
void dissect_ddp(const u_char *, int, frame_data *, GtkTree *);
void dissect_dns(const u_char *, int, frame_data *, GtkTree *);
void dissect_giop(const u_char *, int, frame_data *, GtkTree *);
void dissect_http(const u_char *, int, frame_data *, GtkTree *);
void dissect_icmp(const u_char *, int, frame_data *, GtkTree *);
void dissect_igmp(const u_char *, int, frame_data *, GtkTree *);
void dissect_ip(const u_char *, int, frame_data *, GtkTree *);
void dissect_ipv6(const u_char *, int, frame_data *, GtkTree *);
void dissect_ipx(const u_char *, int, frame_data *, GtkTree *);
void dissect_llc(const u_char *, int, frame_data *, GtkTree *);
void dissect_lpd(const u_char *, int, frame_data *, GtkTree *);
void dissect_nbdgm(const u_char *, int, frame_data *, GtkTree *);
void dissect_nbipx_ns(const u_char *, int, frame_data *, GtkTree *);
void dissect_nbns(const u_char *, int, frame_data *, GtkTree *);
void dissect_ncp(const u_char *, int, frame_data *, GtkTree *);
void dissect_nwlink_dg(const u_char *, int, frame_data *, GtkTree *);
void dissect_osi(const u_char *, int, frame_data *, GtkTree *);
void dissect_ospf(const u_char *, int, frame_data *, GtkTree *);
void dissect_ospf_hello(const u_char *, int, frame_data *, GtkTree *);
void dissect_rip(const u_char *, int, frame_data *, GtkTree *);
void dissect_tcp(const u_char *, int, frame_data *, GtkTree *);
void dissect_tftp(const u_char *, int, frame_data *, GtkTree *);
void dissect_trmac(const u_char *, int, frame_data *, GtkTree *);
void dissect_udp(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_arp(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_frp(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_icp(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_ipc(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_rtp(const u_char *, int, frame_data *, GtkTree *);
void dissect_vines_spp(const u_char *, int, frame_data *, GtkTree *);
void dissect_aarp(const u_char *, int, frame_data *, proto_tree *);
void dissect_arp(const u_char *, int, frame_data *, proto_tree *);
void dissect_bootp(const u_char *, int, frame_data *, proto_tree *);
void dissect_cdp(const u_char *, int, frame_data *, proto_tree *);
void dissect_data(const u_char *, int, frame_data *, proto_tree *);
void dissect_ddp(const u_char *, int, frame_data *, proto_tree *);
void dissect_dns(const u_char *, int, frame_data *, proto_tree *);
void dissect_giop(const u_char *, int, frame_data *, proto_tree *);
void dissect_http(const u_char *, int, frame_data *, proto_tree *);
void dissect_icmp(const u_char *, int, frame_data *, proto_tree *);
void dissect_igmp(const u_char *, int, frame_data *, proto_tree *);
void dissect_ip(const u_char *, int, frame_data *, proto_tree *);
void dissect_ipv6(const u_char *, int, frame_data *, proto_tree *);
void dissect_ipx(const u_char *, int, frame_data *, proto_tree *);
void dissect_llc(const u_char *, int, frame_data *, proto_tree *);
void dissect_lpd(const u_char *, int, frame_data *, proto_tree *);
void dissect_nbdgm(const u_char *, int, frame_data *, proto_tree *);
void dissect_nbipx_ns(const u_char *, int, frame_data *, proto_tree *);
void dissect_nbns(const u_char *, int, frame_data *, proto_tree *);
void dissect_ncp(const u_char *, int, frame_data *, proto_tree *);
void dissect_nwlink_dg(const u_char *, int, frame_data *, proto_tree *);
void dissect_osi(const u_char *, int, frame_data *, proto_tree *);
void dissect_ospf(const u_char *, int, frame_data *, proto_tree *);
void dissect_ospf_hello(const u_char *, int, frame_data *, proto_tree *);
void dissect_rip(const u_char *, int, frame_data *, proto_tree *);
void dissect_tcp(const u_char *, int, frame_data *, proto_tree *);
void dissect_tftp(const u_char *, int, frame_data *, proto_tree *);
void dissect_trmac(const u_char *, int, frame_data *, proto_tree *);
void dissect_udp(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_arp(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_frp(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_icp(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_ipc(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_rtp(const u_char *, int, frame_data *, proto_tree *);
void dissect_vines_spp(const u_char *, int, frame_data *, proto_tree *);
void init_dissect_udp(void);
@ -610,11 +337,52 @@ 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, GtkTree *tree,
GtkWidget *fh_tree);
const u_char *pd, frame_data *fd, proto_tree *tree,
proto_tree *fh_tree);
/* These functions are in packet-arp.c */
gchar *arphrdaddr_to_str(guint8 *ad, int ad_len, guint16 type);
gchar *arphrdtype_to_str(guint16 hwtype, const char *fmt);
/*
* All of the possible columns in summary listing.
*
* NOTE: The SRC and DST entries MUST remain in this order, or else you
* need to fix the offset #defines before get_column_format!
*/
enum {
COL_NUMBER, /* Packet list item number */
COL_CLS_TIME, /* Command line-specified time (default relative) */
COL_REL_TIME, /* Relative time */
COL_ABS_TIME, /* Absolute time */
COL_DELTA_TIME, /* Delta time */
COL_DEF_SRC, /* Source address */
COL_RES_SRC, /* Resolved source */
COL_UNRES_SRC, /* Unresolved source */
COL_DEF_DL_SRC, /* Data link layer source address */
COL_RES_DL_SRC, /* Resolved DL source */
COL_UNRES_DL_SRC, /* Unresolved DL source */
COL_DEF_NET_SRC, /* Network layer source address */
COL_RES_NET_SRC, /* Resolved net source */
COL_UNRES_NET_SRC, /* Unresolved net source */
COL_DEF_DST, /* Destination address */
COL_RES_DST, /* Resolved dest */
COL_UNRES_DST, /* Unresolved dest */
COL_DEF_DL_DST, /* Data link layer dest address */
COL_RES_DL_DST, /* Resolved DL dest */
COL_UNRES_DL_DST, /* Unresolved DL dest */
COL_DEF_NET_DST, /* Network layer dest address */
COL_RES_NET_DST, /* Resolved net dest */
COL_UNRES_NET_DST, /* Unresolved net dest */
COL_DEF_SRC_PORT, /* Source port */
COL_RES_SRC_PORT, /* Resolved source port */
COL_UNRES_SRC_PORT, /* Unresolved source port */
COL_DEF_DST_PORT, /* Destination port */
COL_RES_DST_PORT, /* Resolved dest port */
COL_UNRES_DST_PORT, /* Unresolved dest port */
COL_PROTOCOL, /* Protocol */
COL_INFO, /* Description */
NUM_COL_FMTS /* Should always be last */
};
#endif /* packet.h */

View File

@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
* $Id: print.c,v 1.8 1998/10/28 21:38:11 gerald Exp $
* $Id: print.c,v 1.9 1999/03/23 03:14:46 gram Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@ -38,6 +38,7 @@
#endif
#include "ethereal.h"
#include "gtkpacket.h"
#include "packet.h"
#include "prefs.h"
#include "print.h"

6
util.c
View File

@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
* $Id: util.c,v 1.10 1999/01/01 07:40:34 gram Exp $
* $Id: util.c,v 1.11 1999/03/23 03:14:46 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -54,6 +54,8 @@
#include "image/icon-excl.xpm"
#include "image/icon-ethereal.xpm"
static void simple_dialog_cancel_cb(GtkWidget *, gpointer);
const gchar *bm_key = "button mask";
/* Simple dialog function - Displays a dialog box with the supplied message
@ -162,7 +164,7 @@ simple_dialog(gint type, gint *btn_mask, gchar *msg_format, ...) {
gtk_widget_show(win);
}
void
static void
simple_dialog_cancel_cb(GtkWidget *w, gpointer win) {
gint *btn_mask = (gint *) gtk_object_get_data(win, bm_key);

3
util.h
View File

@ -1,7 +1,7 @@
/* util.h
* Utility definitions
*
* $Id: util.h,v 1.6 1998/12/29 04:05:37 gerald Exp $
* $Id: util.h,v 1.7 1999/03/23 03:14:46 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -46,7 +46,6 @@ void simple_dialog(gint, gint *, gchar *, ...)
void simple_dialog(gint, gint *, gchar *, ...);
#endif
void simple_dialog_cancel_cb(GtkWidget *, gpointer);
const char *decode_boolean_bitfield(guint32 val, guint32 mask, int width,
const char *truedesc, const char *falsedesc);