2 * Routines for Banyan VINES protocol packet disassembly
4 * $Id: packet-vines.c,v 1.4 1998/11/17 04:29:08 gerald Exp $
6 * Don Lafontaine <lafont02@cn.ca>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
38 #ifdef HAVE_NETINET_IN_H
39 #include <netinet/in.h>
45 #include "packet-vines.h"
51 dissect_vines(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
54 GtkWidget *vip_tree, *ti;
55 /* gchar tos_str[32]; */
57 /* To do: check for runts, errs, etc. */
58 /* Avoids alignment problems on many architectures. */
59 memcpy(&iph, &pd[offset], sizeof(e_vip));
61 iph.vip_sum = pntohs(&pd[offset]);
62 iph.vip_len = pntohs(&pd[offset+2]);
63 iph.vip_dnet = pntohl(&pd[offset+6]);
64 iph.vip_snet = pntohl(&pd[offset+12]);
65 iph.vip_dsub = pntohs(&pd[offset+10]);
66 iph.vip_ssub = pntohs(&pd[offset+16]);
68 switch (iph.vip_proto)
71 if (check_col(fd, COL_PROTOCOL))
72 col_add_str(fd, COL_PROTOCOL, "Vines");
73 if (check_col(fd, COL_INFO))
74 col_add_fstr(fd, COL_INFO, "VSPP (%02x)", iph.vip_proto);
77 if (check_col(fd, COL_PROTOCOL))
78 col_add_str(fd, COL_PROTOCOL, "Vines IP");
79 if (check_col(fd, COL_INFO))
80 col_add_fstr(fd, COL_INFO, "DATA (%02x)", iph.vip_proto);
83 if (check_col(fd, COL_PROTOCOL))
84 col_add_str(fd, COL_PROTOCOL, "Vines IP");
85 if (check_col(fd, COL_INFO))
86 col_add_fstr(fd, COL_INFO, "Unknown VIP protocol (%02x)", iph.vip_proto);
89 if (check_col(fd, COL_RES_NET_SRC))
90 col_add_fstr(fd, COL_RES_NET_SRC, "%08x.%04x", iph.vip_snet, iph.vip_ssub);
91 if (check_col(fd, COL_RES_NET_DST))
92 col_add_fstr(fd, COL_RES_NET_DST, "%08x.%04x", iph.vip_dnet, iph.vip_dsub);
94 iph.ip_tos = IPTOS_TOS(iph.ip_tos);
98 strcpy(tos_str, "None");
101 strcpy(tos_str, "Minimize delay");
103 case IPTOS_THROUGHPUT:
104 strcpy(tos_str, "Maximize throughput");
106 case IPTOS_RELIABILITY:
107 strcpy(tos_str, "Maximize reliability");
110 strcpy(tos_str, "Minimize cost");
113 strcpy(tos_str, "Unknon. Malformed?");
119 ti = add_item_to_tree(GTK_WIDGET(tree), offset, (iph.vip_len),
121 vip_tree = gtk_tree_new();
122 add_subtree(ti, vip_tree, ETT_VINES);
123 add_item_to_tree(vip_tree, offset, 2, "Header checksum: 0x%04x", iph.vip_sum);
124 add_item_to_tree(vip_tree, offset + 2, 2, "Header length: 0x%02x (%d)", iph.vip_len, iph.vip_len);
125 add_item_to_tree(vip_tree, offset + 4, 1, "Transport control: 0x%02x",
127 add_item_to_tree(vip_tree, offset + 5, 1, "Protocol: 0x%02x", iph.vip_proto);
132 switch (iph.vip_proto)
135 dissect_vspp(pd, offset, fd, tree);
139 #define VINES_VSPP_DATA 1
140 #define VINES_VSPP_ACK 5
141 void dissect_vspp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
144 GtkWidget *vspp_tree, *ti;
145 /* gchar tos_str[32];*/
147 /* To do: check for runts, errs, etc. */
148 /* Avoids alignment problems on many architectures. */
149 memcpy(&iph, &pd[offset], sizeof(e_vspp));
151 iph.vspp_sport = ntohs(iph.vspp_sport);
152 iph.vspp_dport = ntohs(iph.vspp_dport);
153 iph.vspp_lclid = ntohs(iph.vspp_lclid);
154 iph.vspp_rmtid = ntohs(iph.vspp_rmtid);
156 switch (iph.vspp_pkttype)
158 case VINES_VSPP_DATA:
159 if (check_col(fd, COL_PROTOCOL))
160 col_add_str(fd, COL_PROTOCOL, "Vines");
161 if (check_col(fd, COL_INFO))
162 col_add_fstr(fd, COL_INFO, "VSPP Data Port=%04x(Transient) NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x D=%04x S=%04x",
163 iph.vspp_sport, iph.vspp_seq, iph.vspp_ack, iph.vspp_win, iph.vspp_rmtid,
164 iph.vspp_lclid, iph.vspp_dport, iph.vspp_sport);
167 if (check_col(fd, COL_PROTOCOL))
168 col_add_str(fd, COL_PROTOCOL, "Vines");
169 if (check_col(fd, COL_INFO))
170 col_add_fstr(fd, COL_INFO, "VSPP Ack Port=%04x(Transient) NS=%04x NR=%04x Window=%04x RID=%04x LID=%04x",
171 iph.vspp_sport, iph.vspp_seq, iph.vspp_ack, iph.vspp_win, iph.vspp_rmtid,
176 if (check_col(fd, COL_PROTOCOL))
177 col_add_str(fd, COL_PROTOCOL, "Vines IP");
178 if (check_col(fd, COL_INFO))
179 col_add_fstr(fd, COL_INFO, "Unknown VSPP packet type (%02x)", iph.vspp_pkttype);
182 iph.ip_tos = IPTOS_TOS(iph.ip_tos);
186 strcpy(tos_str, "None");
189 strcpy(tos_str, "Minimize delay");
191 case IPTOS_THROUGHPUT:
192 strcpy(tos_str, "Maximize throughput");
194 case IPTOS_RELIABILITY:
195 strcpy(tos_str, "Maximize reliability");
198 strcpy(tos_str, "Minimize cost");
201 strcpy(tos_str, "Unknon. Malformed?");
207 ti = add_item_to_tree(GTK_WIDGET(tree), offset, sizeof(iph),
209 vspp_tree = gtk_tree_new();
210 add_subtree(ti, vspp_tree, ETT_VSPP);
211 add_item_to_tree(vspp_tree, offset, 2, "Source port: 0x%04x", iph.vspp_sport);
212 add_item_to_tree(vspp_tree, offset+2, 2, "Destination port: 0x%04x", iph.vspp_dport);
213 add_item_to_tree(vspp_tree, offset+4, 1, "Packet type: 0x%02x", iph.vspp_pkttype);
214 add_item_to_tree(vspp_tree, offset+5, 1, "Control: 0x%02x", iph.vspp_tos);
215 add_item_to_tree(vspp_tree, offset+6, 2, "Local Connection ID: 0x%04x", iph.vspp_lclid);
216 add_item_to_tree(vspp_tree, offset+8, 2, "Remote Connection ID: 0x%04x", iph.vspp_rmtid);
217 add_item_to_tree(vspp_tree, offset+10, 2, "Sequence number: 0x%04x", iph.vspp_seq);
218 add_item_to_tree(vspp_tree, offset+12, 2, "Ack number: 0x%04x", iph.vspp_ack);
219 add_item_to_tree(vspp_tree, offset+14, 2, "Window: 0x%04x", iph.vspp_win);