Ethereal-dev: [ethereal-dev] FDDI support

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Laurent Deniel <deniel@xxxxxxxxxxx>
Date: Mon, 28 Sep 1998 18:51:49 +0200
 Hi,

 The attached patch file (diff to ethereal 0.3.17) is a preliminary
 support of FDDI.

 I will have to fix some other alignment problems (due to the size of
 the FDDI+LLC headers) in UDP decoding to  make it work as I want.
 So it works fine on Linux with a tcpdump file generated on Alpha and
 works also on Digital UNIX (the alignment problems are displayed but 
 correctly handled by the OS).

 Laurent.

--
Laurent DENIEL            | E-mail: deniel@xxxxxxxxxxx
Paris, FRANCE             |         deniel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
                          | WWW   : http://www.worldnet.fr/~deniel
    All above opinions are personal, unless stated otherwise.
diff -u --recursive --new-file ethereal-0.3.17/AUTHORS ethereal-0.3.17-deniel/AUTHORS
--- ethereal-0.3.17/AUTHORS	Wed Sep 23 01:26:27 1998
+++ ethereal-0.3.17-deniel/AUTHORS	Mon Sep 28 07:54:48 1998
@@ -37,6 +37,7 @@
 
     Name resolution
     Ethernet/Manufacturer files support
+    FDDI support
     ISO/OSI CLNP/COTP support
     Miscellaneous enhancements and fixes
 }
diff -u --recursive --new-file ethereal-0.3.17/Makefile.am ethereal-0.3.17-deniel/Makefile.am
--- ethereal-0.3.17/Makefile.am	Fri Sep 25 23:08:34 1998
+++ ethereal-0.3.17-deniel/Makefile.am	Mon Sep 28 07:54:48 1998
@@ -18,6 +18,7 @@
 	packet-data.c  \
 	packet-dns.c   \
 	packet-eth.c   \
+	packet-fddi.c  \
 	packet-llc.c   \
 	packet-lpd.c   \
 	packet-ip.c    \
diff -u --recursive --new-file ethereal-0.3.17/Makefile.in ethereal-0.3.17-deniel/Makefile.in
--- ethereal-0.3.17/Makefile.in	Fri Sep 25 23:13:10 1998
+++ ethereal-0.3.17-deniel/Makefile.in	Mon Sep 28 07:54:49 1998
@@ -90,6 +90,7 @@
 	packet-data.c  \
 	packet-dns.c   \
 	packet-eth.c   \
+	packet-fddi.c  \
 	packet-llc.c   \
 	packet-lpd.c   \
 	packet-ip.c    \
@@ -162,11 +163,11 @@
 LIBS = @LIBS@
 ethereal_OBJECTS =  capture.o ethereal.o ethertype.o file.o filter.o \
 follow.o menu.o packet.o packet-arp.o packet-bootp.o packet-data.o \
-packet-dns.o packet-eth.o packet-llc.o packet-lpd.o packet-ip.o \
-packet-ipv6.o packet-ipx.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-tr.o packet-trmac.o packet-udp.o packet-vines.o prefs.o print.o \
-ps.o resolv.o util.o
+packet-dns.o packet-eth.o packet-fddi.o packet-llc.o packet-lpd.o \
+packet-ip.o packet-ipv6.o packet-ipx.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-tr.o packet-trmac.o packet-udp.o packet-vines.o \
+prefs.o print.o ps.o resolv.o util.o
 ethereal_LDADD = $(LDADD)
 ethereal_LDFLAGS = 
 CFLAGS = @CFLAGS@
@@ -405,7 +406,6 @@
 	  || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
 	  || cp -p $$d/$$file $(distdir)/$$file; \
 	done
-
 info:
 dvi:
 check: all
diff -u --recursive --new-file ethereal-0.3.17/packet-fddi.c ethereal-0.3.17-deniel/packet-fddi.c
--- ethereal-0.3.17/packet-fddi.c	Thu Jan  1 00:00:00 1970
+++ ethereal-0.3.17-deniel/packet-fddi.c	Mon Sep 28 08:35:06 1998
@@ -0,0 +1,132 @@
+/* packet-fddi.c
+ * Routines for FDDI packet disassembly
+ *
+ * Laurent Deniel <deniel@xxxxxxxxxxx>
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@xxxxxxxx>
+ * 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
+
+#include <gtk/gtk.h>
+
+#include <stdio.h>
+
+#include <pcap.h>
+
+#include "packet.h"
+#include "ethereal.h"
+#include "resolv.h"
+
+/* FDDI Frame Control values */
+
+#define FDDI_FC_VOID		0x00		/* Void frame */
+#define FDDI_FC_NRT		0x80		/* Nonrestricted token */
+#define FDDI_FC_RT		0xc0		/* Restricted token */
+#define FDDI_FC_MAC		0xc0		/* MAC frame */
+#define FDDI_FC_SMT		0x40		/* SMT frame */
+#define FDDI_FC_SMT_INFO	0x41		/* SMT Info */
+#define FDDI_FC_SMT_NSA		0x4F		/* SMT Next station adrs */
+#define FDDI_FC_SMT_MIN		FDDI_FC_SMT_INFO
+#define FDDI_FC_SMT_MAX		FDDI_FC_SMT_NSA
+#define FDDI_FC_MAC_MIN		0xc1
+#define FDDI_FC_MAC_BEACON	0xc2		/* MAC Beacon frame */
+#define FDDI_FC_MAC_CLAIM	0xc3		/* MAC Claim frame */
+#define FDDI_FC_MAC_MAX		0xcf
+#define FDDI_FC_LLC_ASYNC	0x50		/* Async. LLC frame */
+#define FDDI_FC_LLC_ASYNC_MIN	FDDI_FC_LLC_ASYNC
+#define FDDI_FC_LLC_ASYNC_DEF	0x54
+#define FDDI_FC_LLC_ASYNC_MAX	0x5f
+#define FDDI_FC_LLC_SYNC	0xd0		/* Sync. LLC frame */
+#define FDDI_FC_LLC_SYNC_MIN	FDDI_FC_LLC_SYNC
+#define FDDI_FC_LLC_SYNC_MAX	0xd7
+#define FDDI_FC_IMP_ASYNC	0x60		/* Implementor Async. */
+#define FDDI_FC_IMP_ASYNC_MIN	FDDI_FC_IMP_ASYNC
+#define FDDI_FC_IMP_ASYNC_MAX	0x6f
+#define FDDI_FC_IMP_SYNC	0xe0		/* Implementor Synch. */
+
+#define FDDI_HEADER_SIZE	13
+
+/* field positions */
+
+#define FDDI_P_FC		0
+#define FDDI_P_DHOST		1
+#define FDDI_P_SHOST		7
+
+void dissect_fddi(const u_char *pd, frame_data *fd, GtkTree *tree) 
+{
+
+  int        offset = 0, fc;
+  GtkWidget *fh_tree, *ti;
+
+  if (fd->cap_len < FDDI_HEADER_SIZE) {
+    dissect_data(pd, offset, fd, tree);
+    return;
+  }
+
+  fc = (int) pd[FDDI_P_FC];
+
+  if (fd->win_info[0]) {
+    strcpy(fd->win_info[2], get_ether_name((u_char *)&pd[FDDI_P_DHOST]));
+    strcpy(fd->win_info[1], get_ether_name((u_char *)&pd[FDDI_P_SHOST]));
+    strcpy(fd->win_info[4], "FDDI");
+  }
+
+  if (tree) {
+    ti = add_item_to_tree(GTK_WIDGET(tree), 0, offset,
+			  "FDDI %s (%d on wire, %d captured)",
+			  (fc == FDDI_FC_LLC_ASYNC_DEF || fc == FDDI_FC_LLC_ASYNC) ?
+			  "Async LLC" : "unsupported FC",
+			  fd->pkt_len, fd->cap_len);
+
+      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)",
+		       ether_to_str((guint8 *) &pd[FDDI_P_DHOST]),
+		       get_ether_name((u_char *) &pd[FDDI_P_DHOST]));
+      add_item_to_tree(fh_tree, FDDI_P_SHOST, 6, "Source: %s (%s)",
+		       ether_to_str((guint8 *) &pd[FDDI_P_SHOST]),
+		       get_ether_name((u_char *)&pd[FDDI_P_SHOST]));
+    }
+
+  offset = FDDI_HEADER_SIZE;
+
+  switch (fc) {
+
+    /* From now, only 802.2 SNAP (Async. LCC frame) is supported */
+
+    case FDDI_FC_LLC_ASYNC     :
+    case FDDI_FC_LLC_ASYNC_DEF :
+      dissect_llc(pd, offset, fd, tree);
+      return;
+      
+    default :
+      dissect_data(pd, offset, fd, tree);
+      return;
+
+  } /* fc */
+
+} /* dissect_fddi */
+
diff -u --recursive --new-file ethereal-0.3.17/packet.c ethereal-0.3.17-deniel/packet.c
--- ethereal-0.3.17/packet.c	Fri Sep 25 18:16:55 1998
+++ ethereal-0.3.17-deniel/packet.c	Mon Sep 28 07:54:49 1998
@@ -208,6 +208,9 @@
 		case DLT_EN10MB :
 			dissect_eth(pd, fd, tree);
 			break;
+		case DLT_FDDI :
+			dissect_fddi(pd, fd, tree);
+			break;
 		case DLT_IEEE802 :
 			dissect_tr(pd, fd, tree);
 			break;
diff -u --recursive --new-file ethereal-0.3.17/packet.h ethereal-0.3.17-deniel/packet.h
--- ethereal-0.3.17/packet.h	Fri Sep 25 18:32:27 1998
+++ ethereal-0.3.17-deniel/packet.h	Mon Sep 28 07:54:50 1998
@@ -315,9 +315,10 @@
 #define ETT_IPXSAP        39
 #define ETT_IPXSAP_SERVER 40
 #define ETT_NULL          41
+#define ETT_FDDI          42
 
 /* Should be the last item number plus one */
-#define NUM_TREE_TYPES 42
+#define NUM_TREE_TYPES 43
 
 /* The version of pcap.h that comes with some systems is missing these
  * #defines.
@@ -357,6 +358,7 @@
 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_fddi(const u_char *, frame_data *, GtkTree *);
 
 /*
  * Routines in packet-*.c