Add the header files to "libwiretap_a_SOURCES", so they get included if
[obnox/wireshark/wip.git] / packet-vines.c
1 /* packet-vines.c
2  * Routines for Banyan VINES protocol packet disassembly
3  *
4  * $Id: packet-vines.c,v 1.4 1998/11/17 04:29:08 gerald Exp $
5  *
6  * Don Lafontaine <lafont02@cn.ca>
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@zing.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * 
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.
17  * 
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.
22  * 
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.
26  */
27
28 #include "config.h"
29
30 #include <gtk/gtk.h>
31
32 #include <stdio.h>
33
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37
38 #ifdef HAVE_NETINET_IN_H
39 #include <netinet/in.h>
40 #endif
41
42 #include "ethereal.h"
43 #include "packet.h"
44 #include "etypes.h"
45 #include "packet-vines.h"
46
47 #define VINES_VSPP 2
48 #define VINES_DATA 1
49
50 void
51 dissect_vines(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) 
52         {
53         e_vip       iph;
54         GtkWidget *vip_tree, *ti;
55 /*      gchar      tos_str[32]; */
56
57   /* To do: check for runts, errs, etc. */
58   /* Avoids alignment problems on many architectures. */
59         memcpy(&iph, &pd[offset], sizeof(e_vip));
60
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]);
67
68         switch (iph.vip_proto) 
69                 {
70                 case VINES_VSPP:      
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);
75                         break;
76                 case VINES_DATA:
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);
81                                 break;
82                 default:
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);
87                 }
88
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);
93   /*
94         iph.ip_tos = IPTOS_TOS(iph.ip_tos);
95         switch (iph.ip_tos) 
96                 {
97         case IPTOS_NONE:
98                 strcpy(tos_str, "None");
99                 break;
100         case IPTOS_LOWDELAY:
101                 strcpy(tos_str, "Minimize delay");
102                 break;
103         case IPTOS_THROUGHPUT:
104                 strcpy(tos_str, "Maximize throughput");
105                 break;
106         case IPTOS_RELIABILITY:
107                 strcpy(tos_str, "Maximize reliability");
108                 break;
109         case IPTOS_LOWCOST:
110                 strcpy(tos_str, "Minimize cost");
111                 break;
112         default:
113                 strcpy(tos_str, "Unknon.  Malformed?");
114                 break;
115                 }
116   */
117         if (tree) 
118                 {
119         ti = add_item_to_tree(GTK_WIDGET(tree), offset, (iph.vip_len),
120                 "Vines IP");
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",
126                 iph.vip_tos);
127         add_item_to_tree(vip_tree, offset +  5, 1, "Protocol: 0x%02x", iph.vip_proto);
128                 }
129
130
131         offset += 18;
132         switch (iph.vip_proto) 
133                 {
134         case VINES_VSPP:
135                 dissect_vspp(pd, offset, fd, tree); 
136                 break;
137                 }
138         }
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) 
142         {
143         e_vspp       iph;
144         GtkWidget *vspp_tree, *ti;
145 /*      gchar      tos_str[32];*/
146
147   /* To do: check for runts, errs, etc. */
148   /* Avoids alignment problems on many architectures. */
149         memcpy(&iph, &pd[offset], sizeof(e_vspp));
150
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);
155
156     switch (iph.vspp_pkttype) 
157         {
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);
165                 break;
166         case VINES_VSPP_ACK:
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,
172                         iph.vspp_lclid);
173
174                         break;
175         default:
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);
180         }
181   /*
182         iph.ip_tos = IPTOS_TOS(iph.ip_tos);
183         switch (iph.ip_tos) 
184                 {
185         case IPTOS_NONE:
186                 strcpy(tos_str, "None");
187                 break;
188         case IPTOS_LOWDELAY:
189                 strcpy(tos_str, "Minimize delay");
190                 break;
191         case IPTOS_THROUGHPUT:
192                 strcpy(tos_str, "Maximize throughput");
193                 break;
194         case IPTOS_RELIABILITY:
195                 strcpy(tos_str, "Maximize reliability");
196                 break;
197         case IPTOS_LOWCOST:
198                 strcpy(tos_str, "Minimize cost");
199                 break;
200         default:
201                 strcpy(tos_str, "Unknon.  Malformed?");
202                 break;
203                 }
204 */ 
205         if (tree) 
206                 {
207         ti = add_item_to_tree(GTK_WIDGET(tree), offset, sizeof(iph),
208                 "Vines SPP");
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);
220                 }
221
222         }