Ethereal-dev: [ethereal-dev] patches for Banyan Vines (Preliminary)

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

From: Don Lafontaine <lafont02@xxxxx>
Date: Mon, 14 Sep 1998 21:28:34 -0400 (EDT)
Here's the preliminary (But functional) support for Vines.

Patch applied against source tree including Daniels recent additions.

copy packet-vines.* to the base directory.

(If anyone can tell me what command line to use so that patch will create
new files,  let me know).

There are no code changes,  just additions.  Read patch-0.3.15-vines if
you are nervous about patching working code. :)


Don Lafontaine
diff -u --recursive --new-file ethereal-0.3.15/AUTHORS ethereal-0.3.15-vines/AUTHORS
--- ethereal-0.3.15/AUTHORS	Mon Sep 14 22:17:01 1998
+++ ethereal-0.3.15-vines/AUTHORS	Mon Sep 14 21:53:25 1998
@@ -33,6 +33,10 @@
     Miscellaneous enhancements and fixes
 }
 
+Don Lafontaine       <lafont02@xxxxx> {
+    Banyan Vines support    
+}
+
 Alain Magloire <alainm@xxxxxxxxxxxxxxxxxx> was kind enough to
 give his permission to use his version of snprintf.c.
 
diff -u --recursive --new-file ethereal-0.3.15/Makefile.in ethereal-0.3.15-vines/Makefile.in
--- ethereal-0.3.15/Makefile.in	Mon Sep 14 22:17:01 1998
+++ ethereal-0.3.15-vines/Makefile.in	Mon Sep 14 21:38:04 1998
@@ -98,6 +98,7 @@
 	packet-tr.c    \
 	packet-trmac.c \
 	packet-udp.c   \
+	packet-vines.c \
 	print.c        \
 	ps.c           \
 	resolv.c       \
@@ -146,8 +147,8 @@
 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-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 print.o ps.o \
-resolv.o util.o
+packet-tcp.o packet-tr.o packet-trmac.o packet-udp.o packet-vines.o print.o 
+ps.o resolv.o util.o 
 ethereal_LDADD = $(LDADD)
 ethereal_LDFLAGS = 
 CFLAGS = @CFLAGS@
diff -u --recursive --new-file ethereal-0.3.15/ethertype.c ethereal-0.3.15-vines/ethertype.c
--- ethereal-0.3.15/ethertype.c	Mon Sep 14 22:17:01 1998
+++ ethereal-0.3.15-vines/ethertype.c	Mon Sep 14 21:40:28 1998
@@ -95,6 +95,13 @@
       }
       dissect_ipx(pd, offset, fd, tree);
       break;
+    case ETHERTYPE_VINES:
+      if (tree) {
+        add_item_to_tree(fh_tree, offset - 2, 2,
+          "Type Vines (0x%04x)", etype);
+      }
+      dissect_vines(pd, offset, fd, tree);
+      break;
     default:
       if (tree) {
         add_item_to_tree(fh_tree, offset - 2, 2,
diff -u --recursive --new-file ethereal-0.3.15/etypes.h ethereal-0.3.15-vines/etypes.h
--- ethereal-0.3.15/etypes.h	Mon Sep 14 22:17:01 1998
+++ ethereal-0.3.15-vines/etypes.h	Mon Sep 14 21:41:05 1998
@@ -64,4 +64,7 @@
 #define ETHERTYPE_IPX 0x8137
 #endif
 
+#ifndef ETHERTYPE_VINES
+#define ETHERTYPE_VINES 0xbad
+#endif
 #endif /* etypes.h */
/* packet-vines.h
 * Definitions for packet disassembly structures and routines
 *
 * 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.
 */


#ifndef __PACKETVINES_H__
#define __PACKETVINES_H__

/* VINES IP structs and definitions */

typedef struct _e_vip {
  guint16 vip_sum;
  guint16 vip_len;
  guint8  vip_tos;
  guint8  vip_proto;    /* 2 = VSPP */
  guint32 vip_dnet;
  guint16 vip_dsub;
  guint32 vip_snet;
  guint16 vip_ssub;

} e_vip;

/* VINES SPP structs and definitions */

typedef struct _e_vspp {
  guint16 vspp_sport;
  guint16 vspp_dport;
  guint8  vspp_pkttype; /* 5=ack 1=data */
  guint8  vspp_tos;  /* Unused with type 5 packets */
  guint16 vspp_lclid;
  guint16 vspp_rmtid;
  guint16 vspp_seq; 
  guint16 vspp_ack;
  guint16 vspp_win;
} e_vspp;

/* VINES SMB structs and definitions */

typedef struct _e_vsmb {
  guint32 vsmb_tag;
  guint8  vsmb_func;
  guint8  vsmb_d1;
  guint32 vsmb_d2;
  guint32 vsmb_d3;
  guint16 vsmb_d4;
  guint32 vsmb_d5;
  guint32 vsmb_d6;
  guint16 vsmb_treeid; 
  guint16 vsmb_pid;
  guint16 vsmb_uid;
  guint16 vsmb_mid; 
  guint8  vsmb_wcnt;
  guint16 vsmb_pbytes;
  guint16 vsmb_dbytes;
  guint16 vsmb_maxpbytes;
  guint16 vsmb_maxdbytes;
  guint16 vsmb_setupw;
  guint16 vsmb_tflags;
  guint32 vsmb_ttw;
} e_vsmb;

#endif /* packet-vines.h */
/* packet-vines.c
 * Routines for Banyan VINES protocol packet disassembly
 *
 * 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.
 */

#include "config.h"

#include <gtk/gtk.h>
#include <pcap.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 "packet.h"
#include "etypes.h"
#include "packet-vines.h"

#define VINES_VSPP 2
#define VINES_DATA 1

void dissect_vspp(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) 
	{
  	e_vip       iph;
  	GtkWidget *vip_tree, *ti;
  	gchar      tos_str[32];

  /* To do: check for runts, errs, etc. */
  /* Avoids alignment problems on many architectures. */
  	memcpy(&iph, &pd[offset], sizeof(e_vip));

  	iph.vip_sum = pntohs(&pd[offset]);
  	iph.vip_len = pntohs(&pd[offset+2]);
  	iph.vip_dnet = pntohl(&pd[offset+6]);
  	iph.vip_snet = pntohl(&pd[offset+12]);
  	iph.vip_dsub = pntohs(&pd[offset+10]);
  	iph.vip_ssub = pntohs(&pd[offset+16]);

  	if (fd->win_info[0]) 
  		{
    	switch (iph.vip_proto) 
    		{
      		case VINES_VSPP:      
        		strcpy(fd->win_info[3], "Vines");
        		sprintf(fd->win_info[4], "VSPP (%02x)", iph.vip_proto);
        		break;
      		case VINES_DATA:
        		strcpy(fd->win_info[3], "Vines IP");
        		sprintf(fd->win_info[4], "DATA (%02x)", iph.vip_proto);
				break;
      		default:
        		strcpy(fd->win_info[3], "Vines IP");
        		sprintf(fd->win_info[4], "Unknown VIP protocol (%02x)", iph.vip_proto);
    		}

    	sprintf(fd->win_info[1], "%08x.%04x", iph.vip_snet, iph.vip_ssub);
    	sprintf(fd->win_info[2], "%08x.%04x", iph.vip_dnet, iph.vip_dsub);
  		}
  /*
  	iph.ip_tos = IPTOS_TOS(iph.ip_tos);
  	switch (iph.ip_tos) 
  		{
    	case IPTOS_NONE:
    	  	strcpy(tos_str, "None");
    	  	break;
    	case IPTOS_LOWDELAY:
    	  	strcpy(tos_str, "Minimize delay");
    	  	break;
    	case IPTOS_THROUGHPUT:
    	  	strcpy(tos_str, "Maximize throughput");
    	  	break;
    	case IPTOS_RELIABILITY:
    	  	strcpy(tos_str, "Maximize reliability");
    	  	break;
    	case IPTOS_LOWCOST:
    	  	strcpy(tos_str, "Minimize cost");
    	  	break;
    	default:
    	  	strcpy(tos_str, "Unknon.  Malformed?");
    	  	break;
  		}
  */
  	if (tree) 
  		{
    	ti = add_item_to_tree(GTK_WIDGET(tree), offset, (iph.vip_len),
      		"Vines IP");
    	vip_tree = gtk_tree_new();
    	gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), vip_tree);
    	add_item_to_tree(vip_tree, offset,      2, "Header checksum: 0x%04x", iph.vip_sum);
    	add_item_to_tree(vip_tree, offset +  2, 2, "Header length: 0x%02x (%d)", iph.vip_len, iph.vip_len); 
    	add_item_to_tree(vip_tree, offset +  4, 1, "Transport control: 0x%02x",
      		iph.vip_tos);
    	add_item_to_tree(vip_tree, offset +  5, 1, "Protocol: 0x%02x", iph.vip_proto);
  		}


  	offset += 18;
	switch (iph.vip_proto) 
		{
    	case VINES_VSPP:
	      	dissect_vspp(pd, offset, fd, tree); 
    		break;
  		}
	}
#define VINES_VSPP_DATA 1
#define VINES_VSPP_ACK 5
void dissect_vspp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) 
	{
  	e_vspp       iph;
  	GtkWidget *vspp_tree, *ti;
  	gchar      tos_str[32];

  /* To do: check for runts, errs, etc. */
  /* Avoids alignment problems on many architectures. */
  	memcpy(&iph, &pd[offset], sizeof(e_vspp));

  	iph.vspp_sport = ntohs(iph.vspp_sport);
  	iph.vspp_dport = ntohs(iph.vspp_dport);
  	iph.vspp_lclid = ntohs(iph.vspp_lclid);
  	iph.vspp_rmtid = ntohs(iph.vspp_rmtid);

  	if (fd->win_info[0]) 
  		{
    	switch (iph.vspp_pkttype) 
    		{
      		case VINES_VSPP_DATA:      
        		strcpy(fd->win_info[3], "Vines");
        		sprintf(fd->win_info[4], "VSPP Data Port=%04x(Transient) NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x D=%04x S=%04x", 
        			iph.vspp_sport, iph.vspp_seq, iph.vspp_ack, iph.vspp_win, iph.vspp_rmtid,
        			iph.vspp_lclid, iph.vspp_dport, iph.vspp_sport);
        		break;
      		case VINES_VSPP_ACK:
        		strcpy(fd->win_info[3], "Vines");
        		sprintf(fd->win_info[4], "VSPP Ack Port=%04x(Transient) NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x", 
        			iph.vspp_sport, iph.vspp_seq, iph.vspp_ack, iph.vspp_win, iph.vspp_rmtid,
        			iph.vspp_lclid);

				break;
      		default:
        		strcpy(fd->win_info[3], "Vines IP");
        		sprintf(fd->win_info[4], "Unknown VSPP packet type (%02x)", iph.vspp_pkttype);
    		}
  		}
  /*
  	iph.ip_tos = IPTOS_TOS(iph.ip_tos);
  	switch (iph.ip_tos) 
  		{
    	case IPTOS_NONE:
    	  	strcpy(tos_str, "None");
    	  	break;
    	case IPTOS_LOWDELAY:
    	  	strcpy(tos_str, "Minimize delay");
    	  	break;
    	case IPTOS_THROUGHPUT:
    	  	strcpy(tos_str, "Maximize throughput");
    	  	break;
    	case IPTOS_RELIABILITY:
    	  	strcpy(tos_str, "Maximize reliability");
    	  	break;
    	case IPTOS_LOWCOST:
    	  	strcpy(tos_str, "Minimize cost");
    	  	break;
    	default:
    	  	strcpy(tos_str, "Unknon.  Malformed?");
    	  	break;
  		}
*/ 
  	if (tree) 
  		{
    	ti = add_item_to_tree(GTK_WIDGET(tree), offset, sizeof(iph),
      		"Vines SPP");
    	vspp_tree = gtk_tree_new();
    	gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), vspp_tree);
    	add_item_to_tree(vspp_tree, offset,      2, "Source port: 0x%04x", iph.vspp_sport);
    	add_item_to_tree(vspp_tree, offset+2,    2, "Destination port: 0x%04x", iph.vspp_dport); 
    	add_item_to_tree(vspp_tree, offset+4,    1, "Packet type: 0x%02x", iph.vspp_pkttype);
    	add_item_to_tree(vspp_tree, offset+5,    1, "Control: 0x%02x", iph.vspp_tos);
    	add_item_to_tree(vspp_tree, offset+6,    2, "Local Connection ID: 0x%04x", iph.vspp_lclid);
    	add_item_to_tree(vspp_tree, offset+8,    2, "Remote Connection ID: 0x%04x", iph.vspp_rmtid);
    	add_item_to_tree(vspp_tree, offset+10,   2, "Sequence number: 0x%04x", iph.vspp_seq);
    	add_item_to_tree(vspp_tree, offset+12,   2, "Ack number: 0x%04x", iph.vspp_ack);
    	add_item_to_tree(vspp_tree, offset+14,   2, "Window: 0x%04x", iph.vspp_win);
  		}

	}