Fixup: tvb_get_string(z) -> tvb_get_string(z)_enc
[metze/wireshark/wip.git] / epan / dissectors / packet-ismp.c
1 /* packet-ismp.c
2  * Routines for ISMP dissection
3  * Enterasys Networks Home: http://www.enterasys.com/
4  * Copyright 2003, Joshua Craig Douglas <jdouglas@enterasys.com>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #include "config.h"
26
27 #include <glib.h>
28
29 #include <epan/packet.h>
30 #include <epan/to_str.h>
31 #include <epan/strutil.h>
32 #include <epan/etypes.h>
33
34 void proto_register_ismp(void);
35 void proto_reg_handoff_ismp(void);
36
37 /* Initialize the protocol and registered fields */
38 static int proto_ismp = -1;
39 static int hf_ismp_version = -1;
40 static int hf_ismp_message_type = -1;
41 static int hf_ismp_seq_num = -1;
42 static int hf_ismp_code_length = -1;
43 static int hf_ismp_auth_data = -1;
44
45 /* Enterasys/Cabletron Dicovery Protocol fields*/
46 static int hf_ismp_edp = -1;
47 static int hf_ismp_edp_version = -1;
48 static int hf_ismp_edp_module_ip = -1;
49 static int hf_ismp_edp_module_mac = -1;
50 static int hf_ismp_edp_module_port = -1;
51 static int hf_ismp_edp_chassis_mac =-1;
52 static int hf_ismp_edp_chassis_ip = -1;
53 static int hf_ismp_edp_device_type = -1;
54 static int hf_ismp_edp_module_rev = -1;
55 static int hf_ismp_edp_options = -1;
56 static int hf_ismp_edp_sfs_option_unused1 = -1;
57 static int hf_ismp_edp_sfs_option_sfssup = -1;
58 static int hf_ismp_edp_sfs_option_lsp = -1;
59 static int hf_ismp_edp_sfs_option_flood = -1;
60 static int hf_ismp_edp_sfs_option_resolve = -1;
61 static int hf_ismp_edp_sfs_option_unused2 = -1;
62 static int hf_ismp_edp_sfs_option_tagflood = -1;
63 static int hf_ismp_edp_sfs_option_calltap = -1;
64 static int hf_ismp_edp_sfs_option_conmsg = -1;
65 static int hf_ismp_edp_sfs_option_redun = -1;
66 static int hf_ismp_edp_sfs_option_isolated = -1;
67 static int hf_ismp_edp_sfs_option_uplink_switch = -1;
68 static int hf_ismp_edp_sfs_option_uplink_core = -1;
69 static int hf_ismp_edp_sfs_option_uplink_port = -1;
70 static int hf_ismp_edp_sfs_option_uplink_flood = -1;
71 static int hf_ismp_edp_rtr_option_ssr = -1;
72 static int hf_ismp_edp_rtr_option_igmp = -1;
73 static int hf_ismp_edp_rtr_option_rip = -1;
74 static int hf_ismp_edp_rtr_option_bgp = -1;
75 static int hf_ismp_edp_rtr_option_ospf = -1;
76 static int hf_ismp_edp_rtr_option_dvmrp = -1;
77 static int hf_ismp_edp_rtr_option_8021q = -1;
78 static int hf_ismp_edp_rtr_option_gvrp = -1;
79 static int hf_ismp_edp_rtr_option_gmrp = -1;
80 static int hf_ismp_edp_rtr_option_igmp_snoop = -1;
81 static int hf_ismp_edp_rtr_option_route = -1;
82 static int hf_ismp_edp_rtr_option_trans = -1;
83 static int hf_ismp_edp_rtr_option_level1 = -1;
84 static int hf_ismp_edp_switch_option_8021q = -1;
85 static int hf_ismp_edp_switch_option_gvrp = -1;
86 static int hf_ismp_edp_switch_option_gmrp = -1;
87 static int hf_ismp_edp_switch_option_igmp = -1;
88 static int hf_ismp_edp_switch_option_route = -1;
89 static int hf_ismp_edp_switch_option_trans = -1;
90 static int hf_ismp_edp_switch_option_level1 = -1;
91 static int hf_ismp_edp_end_station_option_dhcp = -1;
92 static int hf_ismp_edp_end_station_option_dns = -1;
93 static int hf_ismp_edp_end_station_option_ad = -1;
94 static int hf_ismp_edp_num_neighbors = -1;
95 static int hf_ismp_edp_neighbors = -1;
96 static int hf_ismp_edp_num_tuples = -1;
97 static int hf_ismp_edp_tuples = -1;
98
99
100 /* Initialize the subtree pointers */
101 static gint ett_ismp = -1;
102 static gint ett_ismp_edp = -1;
103 static gint ett_ismp_edp_options = -1;
104 static gint ett_ismp_edp_neighbors = -1;
105 static gint ett_ismp_edp_neighbors_leaf = -1;
106 static gint ett_ismp_edp_tuples = -1;
107 static gint ett_ismp_edp_tuples_leaf = -1;
108
109 /* ISMP TYPES */
110 #define ISMPTYPE_EDP    2
111
112
113 /* EDP DEVICE TYPES */
114 #define EDP_DEVICE_TYPE_SFS17           1
115 #define EDP_DEVICE_TYPE_SFS18           2
116 #define EDP_DEVICE_TYPE_ROUTER          3
117 #define EDP_DEVICE_TYPE_BRIDGE          4
118 #define EDP_DEVICE_TYPE_VLANMAN         5
119 #define EDP_DEVICE_TYPE_NTSERVER        6
120 #define EDP_DEVICE_TYPE_NTCLIENT        7
121 #define EDP_DEVICE_TYPE_WIN95           8
122 #define EDP_DEVICE_TYPE_WIN98           9
123 #define EDP_DEVICE_TYPE_UNIXSERVER      10
124 #define EDP_DEVICE_TYPE_UNIXCLIENT      11
125 #define EDP_DEVICE_TYPE_ACCESSPOINT     12
126
127
128 static const value_string edp_device_types[] = {
129         { EDP_DEVICE_TYPE_SFS17,       "Network Switch running SecureFast version 1.7 or lower" },
130         { EDP_DEVICE_TYPE_SFS18,       "Network Switch running SecureFast version 1.8 or greater" },
131         { EDP_DEVICE_TYPE_ROUTER,      "Router" },
132         { EDP_DEVICE_TYPE_BRIDGE,      "Bridge" },
133         { EDP_DEVICE_TYPE_VLANMAN,     "Cabletron VLAN Manager" },
134         { EDP_DEVICE_TYPE_NTSERVER,    "Network Server (NT)" },
135         { EDP_DEVICE_TYPE_NTCLIENT,    "Network Workstation (NT)" },
136         { EDP_DEVICE_TYPE_WIN95,       "Windows95" },
137         { EDP_DEVICE_TYPE_WIN98,       "Windows98" },
138         { EDP_DEVICE_TYPE_UNIXSERVER,  "UNIX Server" },
139         { EDP_DEVICE_TYPE_UNIXCLIENT,  "UNIX Workstation" },
140         { EDP_DEVICE_TYPE_ACCESSPOINT, "Roamabout wireless access point" },
141         { 0,                    NULL },
142 };
143
144
145 /* EDP SFS Options */
146 #define EDP_SFS_OPTION_UNUSED1          0x1
147 #define EDP_SFS_OPTION_SFSSUP           0x2
148 #define EDP_SFS_OPTION_LSP              0x4
149 #define EDP_SFS_OPTION_FLOOD            0x8
150 #define EDP_SFS_OPTION_RESOLVE          0x10
151 #define EDP_SFS_OPTION_UNUSED2          0x20
152 #define EDP_SFS_OPTION_TAGFLOOD         0x40
153 #define EDP_SFS_OPTION_CALLTAP          0x80
154 #define EDP_SFS_OPTION_CONMSG           0x100
155 #define EDP_SFS_OPTION_REDUN            0x200
156 #define EDP_SFS_OPTION_ISOLATED         0x400
157 #define EDP_SFS_OPTION_UPLINK_SWITCH    0x800
158 #define EDP_SFS_OPTION_UPLINK_CORE      0x1000
159 #define EDP_SFS_OPTION_UPLINK_PORT      0x2000
160 #define EDP_SFS_OPTION_UPLINK_FLOOD     0x4000
161
162 /* EDP Router Options */
163 #define EDP_RTR_OPTION_SSR              0x1
164 #define EDP_RTR_OPTION_IGMP             0x2
165 #define EDP_RTR_OPTION_RIP              0x4
166 #define EDP_RTR_OPTION_BGP              0x8
167 #define EDP_RTR_OPTION_OSPF             0x10
168 #define EDP_RTR_OPTION_DVMRP            0x20
169 #define EDP_RTR_OPTION_8021Q            0x40
170 #define EDP_RTR_OPTION_GVRP             0x80
171 #define EDP_RTR_OPTION_GMRP             0x100
172 #define EDP_RTR_OPTION_IGMP_SNOOP       0x200
173 #define EDP_RTR_OPTION_ROUTE            0x400
174 #define EDP_RTR_OPTION_TRANS            0x800
175 #define EDP_RTR_OPTION_LEVEL1           0x1000
176
177 /* EDP Switch Options */
178 #define EDP_SWITCH_OPTION_8021Q         0x1
179 #define EDP_SWITCH_OPTION_GVRP          0x2
180 #define EDP_SWITCH_OPTION_GMRP          0x4
181 #define EDP_SWITCH_OPTION_IGMP          0x8
182 #define EDP_SWITCH_OPTION_ROUTE         0x10
183 #define EDP_SWITCH_OPTION_TRANS         0x20
184 #define EDP_SWITCH_OPTION_LEVEL1        0x40
185
186 /* EDP End Station and Server Options */
187 #define EDP_END_STATION_OPTION_DHCP     0x1
188 #define EDP_END_STATION_OPTION_DNS      0x2
189 #define EDP_END_STATION_OPTION_AD       0x4
190
191 /* EDP Tuple Types */
192 #define EDP_TUPLE_UNKNOWN               0
193 #define EDP_TUPLE_HOLD                  1
194 #define EDP_TUPLE_INT_NAME              2
195 #define EDP_TUPLE_SYS_DESCRIPT  3
196 #define EDP_TUPLE_IPX_ADDR              4
197
198 static const value_string edp_tuple_types[] =
199 {
200         { EDP_TUPLE_UNKNOWN,"Unknown" },
201         { EDP_TUPLE_HOLD,"Hold Time" },
202         { EDP_TUPLE_INT_NAME,"Interface Name" },
203         { EDP_TUPLE_SYS_DESCRIPT,"System Description" },
204         { EDP_TUPLE_IPX_ADDR,"IPX Address" },
205         { 0,NULL }
206 };
207
208 /* Is value set? */
209 static const true_false_string is_set = {
210         "set",
211         "not set"
212 };
213
214
215 /* Function to dissect EDP portion of ISMP message */
216 static void
217 dissect_ismp_edp(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *ismp_tree)
218 {
219         /* local variables used for EDP dissection */
220         int neighbors_count = 0;
221         int tuples_count = 0;
222         guint16 device_type = 0;
223         guint32 options = 0;
224         guint16 num_neighbors = 0;
225         guint16 num_tuples = 0;
226         guint16 tuple_type = 0;
227         guint16 tuple_length = 0;
228
229         /* Set up structures needed to add the protocol subtree and manage it */
230         proto_item *edp_ti;
231         proto_tree *edp_tree;
232
233         proto_item *edp_options_ti;
234         proto_tree *edp_options_tree;
235
236         proto_item *edp_neighbors_ti;
237         proto_tree *edp_neighbors_tree;
238
239         proto_item *edp_neighbors_leaf_ti;
240         proto_tree *edp_neighbors_leaf_tree;
241
242         proto_item *edp_tuples_ti;
243         proto_tree *edp_tuples_tree;
244
245         proto_item *edp_tuples_leaf_ti;
246         proto_tree *edp_tuples_leaf_tree;
247
248         /* add column iformation marking this as EDP (Enterasys Discover Protocol */
249         col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISMP.EDP");
250         col_clear(pinfo->cinfo, COL_INFO);
251
252         /* create display subtree for EDP */
253         if (ismp_tree) {
254                 edp_ti  = proto_tree_add_item(ismp_tree, hf_ismp_edp, tvb, offset,
255                         tvb_length_remaining(tvb, offset), ENC_NA);
256                 edp_tree = proto_item_add_subtree(edp_ti, ett_ismp_edp);
257
258                 col_add_fstr(pinfo->cinfo, COL_INFO, "MIP %s, MMAC %s, ifIdx %d",
259                         tvb_ip_to_str(tvb, offset+2),
260                         tvb_ether_to_str(tvb, offset+6),
261                         tvb_get_ntohl(tvb, offset+12));
262
263                 proto_tree_add_item(edp_tree, hf_ismp_edp_version, tvb, offset, 2, ENC_BIG_ENDIAN);
264                 offset += 2;
265                 proto_tree_add_item(edp_tree, hf_ismp_edp_module_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
266                 offset += 4;
267                 proto_tree_add_item(edp_tree, hf_ismp_edp_module_mac, tvb, offset, 6, ENC_NA);
268                 offset += 6;
269                 proto_tree_add_item(edp_tree, hf_ismp_edp_module_port, tvb, offset, 4, ENC_BIG_ENDIAN);
270                 offset += 4;
271                 proto_tree_add_item(edp_tree, hf_ismp_edp_chassis_mac, tvb, offset, 6, ENC_NA);
272                 offset += 6;
273                 proto_tree_add_item(edp_tree, hf_ismp_edp_chassis_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
274                 offset += 4;
275                 device_type = tvb_get_ntohs(tvb, offset);
276                 proto_tree_add_item(edp_tree, hf_ismp_edp_device_type, tvb, offset, 2, ENC_BIG_ENDIAN);
277                 offset += 2;
278                 proto_tree_add_uint_format_value(edp_tree, hf_ismp_edp_module_rev, tvb, offset, 4, tvb_get_ntohl(tvb, offset),
279                         "%02x.%02x.%02x.%02x", tvb_get_guint8(tvb, offset),
280                         tvb_get_guint8(tvb, offset+1), tvb_get_guint8(tvb, offset+2), tvb_get_guint8(tvb, offset+3));
281                 offset += 4;
282
283                 /* create display subtree for EDP options */
284                 options = tvb_get_ntohl(tvb, offset);
285                 edp_options_ti = proto_tree_add_uint_format(edp_tree, hf_ismp_edp_options, tvb, offset, 4,
286                         options,"Options: 0x%08x",options);
287                 edp_options_tree = proto_item_add_subtree(edp_options_ti, ett_ismp_edp_options);
288
289                 /* depending on device_type, show the appropriate options */
290                 switch (device_type) {
291                         case EDP_DEVICE_TYPE_SFS17:
292                         case EDP_DEVICE_TYPE_SFS18:
293                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_uplink_flood, tvb, offset, 4, ENC_BIG_ENDIAN);
294                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_uplink_port, tvb, offset, 4, ENC_BIG_ENDIAN);
295                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_uplink_core, tvb, offset, 4, ENC_BIG_ENDIAN);
296                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_uplink_switch, tvb, offset, 4, ENC_BIG_ENDIAN);
297                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_isolated, tvb, offset, 4, ENC_BIG_ENDIAN);
298                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_redun, tvb, offset, 4, ENC_BIG_ENDIAN);
299                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_conmsg, tvb, offset, 4, ENC_BIG_ENDIAN);
300                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_calltap, tvb, offset, 4, ENC_BIG_ENDIAN);
301                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_tagflood, tvb, offset, 4, ENC_BIG_ENDIAN);
302                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_unused2, tvb, offset, 4, ENC_BIG_ENDIAN);
303                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_resolve, tvb, offset, 4, ENC_BIG_ENDIAN);
304                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_flood, tvb, offset, 4, ENC_BIG_ENDIAN);
305                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_lsp, tvb, offset, 4, ENC_BIG_ENDIAN);
306                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_sfssup, tvb, offset, 4, ENC_BIG_ENDIAN);
307                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_sfs_option_unused1, tvb, offset, 4, ENC_BIG_ENDIAN);
308                                 break;
309                         case EDP_DEVICE_TYPE_ROUTER:
310                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_level1, tvb, offset, 4, ENC_BIG_ENDIAN);
311                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_trans, tvb, offset, 4, ENC_BIG_ENDIAN);
312                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_route, tvb, offset, 4, ENC_BIG_ENDIAN);
313                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_igmp_snoop, tvb, offset, 4, ENC_BIG_ENDIAN);
314                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_gmrp, tvb, offset, 4, ENC_BIG_ENDIAN);
315                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_gvrp, tvb, offset, 4, ENC_BIG_ENDIAN);
316                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_8021q, tvb, offset, 4, ENC_BIG_ENDIAN);
317                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_dvmrp, tvb, offset, 4, ENC_BIG_ENDIAN);
318                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_ospf, tvb, offset, 4, ENC_BIG_ENDIAN);
319                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_bgp, tvb, offset, 4, ENC_BIG_ENDIAN);
320                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_rip, tvb, offset, 4, ENC_BIG_ENDIAN);
321                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_igmp, tvb, offset, 4, ENC_BIG_ENDIAN);
322                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_rtr_option_ssr, tvb, offset, 4, ENC_BIG_ENDIAN);
323                                 break;
324                         case EDP_DEVICE_TYPE_BRIDGE:
325                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_level1, tvb, offset, 4, ENC_BIG_ENDIAN);
326                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_trans, tvb, offset, 4, ENC_BIG_ENDIAN);
327                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_route, tvb, offset, 4, ENC_BIG_ENDIAN);
328                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_igmp, tvb, offset, 4, ENC_BIG_ENDIAN);
329                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_gmrp, tvb, offset, 4, ENC_BIG_ENDIAN);
330                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_gvrp, tvb, offset, 4, ENC_BIG_ENDIAN);
331                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_switch_option_8021q, tvb, offset, 4, ENC_BIG_ENDIAN);
332                                 break;
333                         case EDP_DEVICE_TYPE_VLANMAN:
334                                 break;
335                         case EDP_DEVICE_TYPE_NTSERVER:
336                         case EDP_DEVICE_TYPE_NTCLIENT:
337                         case EDP_DEVICE_TYPE_WIN95:
338                         case EDP_DEVICE_TYPE_WIN98:
339                         case EDP_DEVICE_TYPE_UNIXSERVER:
340                         case EDP_DEVICE_TYPE_UNIXCLIENT:
341                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_end_station_option_ad, tvb, offset, 4, ENC_BIG_ENDIAN);
342                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_end_station_option_dns, tvb, offset, 4, ENC_BIG_ENDIAN);
343                                 proto_tree_add_item(edp_options_tree, hf_ismp_edp_end_station_option_dhcp, tvb, offset, 4, ENC_BIG_ENDIAN);
344                                 break;
345                         case EDP_DEVICE_TYPE_ACCESSPOINT:
346                         default:
347                                 break;
348                 }
349                 offset += 4;
350
351                 /* determine the number of neighbors and create EDP neighbors subtree */
352                 num_neighbors = tvb_get_ntohs(tvb, offset);
353                 proto_tree_add_item(edp_tree, hf_ismp_edp_num_neighbors, tvb, offset, 2, ENC_BIG_ENDIAN);
354                 offset += 2;
355                 if (num_neighbors > 0)
356                 {
357                         edp_neighbors_ti = proto_tree_add_item(edp_tree, hf_ismp_edp_neighbors, tvb,
358                                                                                 offset, num_neighbors*10, ENC_NA);
359                         edp_neighbors_tree = proto_item_add_subtree(edp_neighbors_ti, ett_ismp_edp_neighbors);
360                         while ( neighbors_count < num_neighbors && tvb_reported_length_remaining(tvb, offset) >= 10)
361                         {
362                                 edp_neighbors_leaf_ti = proto_tree_add_text(edp_neighbors_tree, tvb, offset, 10,
363                                                                                 "Neighbor%d", (neighbors_count+1));
364                                 edp_neighbors_leaf_tree = proto_item_add_subtree(edp_neighbors_leaf_ti, ett_ismp_edp_neighbors_leaf);
365
366                                 proto_tree_add_text(edp_neighbors_leaf_tree, tvb, offset, 6,
367                                         "MAC Address: %s", tvb_ether_to_str(tvb, offset));
368                                 proto_tree_add_text(edp_neighbors_leaf_tree, tvb, offset, 4,
369                                         "Assigned Neighbor State 0x%04x", tvb_get_ntohl(tvb, offset));
370                                 offset += 10;
371                                 neighbors_count++;
372                         }
373                         if (neighbors_count != num_neighbors)
374                         {
375                                 proto_tree_add_text(edp_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset),
376                                 "MALFORMED PACKET");
377                                 return;
378                         }
379                 }
380
381                 /* determine data remains, if so, count tuples
382                    and create EDP tuples subtree */
383                 if (tvb_reported_length_remaining(tvb, offset) != 0 &&
384                         tvb_reported_length_remaining(tvb, offset) >= 2)
385                 {
386                         num_tuples = tvb_get_ntohs(tvb, offset);
387                         proto_tree_add_item(edp_tree, hf_ismp_edp_num_tuples, tvb, offset, 2, ENC_BIG_ENDIAN);
388                         offset += 2;
389                 }
390                 else if (tvb_reported_length_remaining(tvb, offset) > 0) {
391                         proto_tree_add_text(edp_tree, tvb, offset,
392                                 tvb_reported_length_remaining(tvb, offset), "MALFORMED PACKET");
393                         return;
394                 }
395                 else
396                 {
397                         return;
398                 }
399
400                 /* start populating tuple information */
401                 if (num_tuples && tvb_reported_length_remaining(tvb, offset) >= 4)
402                 {
403                         edp_tuples_ti = proto_tree_add_bytes_format(edp_tree, hf_ismp_edp_tuples, tvb,
404                                 offset, tvb_reported_length_remaining(tvb, offset), NULL, "Tuples");
405                         edp_tuples_tree = proto_item_add_subtree(edp_tuples_ti, ett_ismp_edp_tuples);
406
407                         while ( (tuples_count < num_tuples) && (tvb_reported_length_remaining(tvb, offset) >= 4) )
408                         {
409
410                                 tuple_length = tvb_get_ntohs(tvb, offset+2);
411                                 edp_tuples_leaf_ti = proto_tree_add_text(edp_tuples_tree, tvb, offset, tuple_length,
412                                         "Tuple%d", tuples_count+1);
413
414                                 edp_tuples_leaf_tree = proto_item_add_subtree(edp_tuples_leaf_ti, ett_ismp_edp_tuples_leaf);
415
416                                 tuple_type = tvb_get_ntohs(tvb, offset);
417                                 proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, 2,
418                                         "Tuple Type: %s(%d)", val_to_str_const( tuple_type, edp_tuple_types, "Unknown"), tuple_type );
419                                 offset += 2;
420                                 proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, 2,
421                                         "Tuple Length: %d", tuple_length);
422                                 offset += 2;
423
424                                 if (tvb_reported_length_remaining(tvb, offset) >= tuple_length)
425                                 {
426                                         tvb_ensure_bytes_exist(tvb, offset, tuple_length);
427                                         switch (tuple_type)
428                                         {
429                                                 case EDP_TUPLE_HOLD:
430                                                         proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, tuple_length,
431                                                                 "Hold Time = %d", tvb_get_ntohs(tvb, offset));
432                                                         break;
433                                                 case EDP_TUPLE_INT_NAME:
434                                                         proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, tuple_length,
435                                                                 "Interface Name = %s", tvb_format_text(tvb, offset, tuple_length));
436                                                         col_append_fstr(pinfo->cinfo, COL_INFO, ", ifName %s",
437                                                                 tvb_format_text(tvb, offset, tuple_length));
438                                                         break;
439                                                 case EDP_TUPLE_SYS_DESCRIPT:
440                                                         proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, tuple_length,
441                                                                 "System Description = %s", tvb_format_text(tvb, offset, tuple_length));
442                                                         break;
443                                                 case EDP_TUPLE_IPX_ADDR:
444                                                         proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, tuple_length,
445                                                                 "Interface IPX_address = %s",
446                                                                 ipx_addr_to_str(tvb_get_ntohl(tvb, offset),
447                                                                 tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, tuple_length-4, ENC_ASCII)));
448                                                         break;
449                                                 case EDP_TUPLE_UNKNOWN:
450                                                 default:
451                                                         proto_tree_add_text(edp_tuples_leaf_tree, tvb, offset, tuple_length,
452                                                                 "Unknown Tuple Data %s", tvb_format_text(tvb, offset, tuple_length));
453                                                         break;
454                                         }
455                                 }
456                                 offset += tuple_length;
457
458                                 tuples_count++;
459                         }
460                         if (tuples_count != num_tuples)
461                         {
462                                 proto_tree_add_text(edp_tree, tvb, offset,
463                                         tvb_reported_length_remaining(tvb, offset), "MALFORMED PACKET");
464                                 return;
465                         }
466                         else
467                         {
468                                 return;
469                         }
470                 }
471
472         }
473
474
475 }
476
477
478 /* Code to actually dissect the packets */
479 static void
480 dissect_ismp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
481 {
482         int offset = 0;
483         guint16 message_type = 0;
484         guint8 code_length = 0;
485         guint8 weird_stuff[3] = { 0x42, 0x42, 0x03 };
486
487 /* Set up structures needed to add the protocol subtree and manage it */
488         proto_item *ti;
489         proto_tree *ismp_tree;
490
491 /* Make entries in Protocol column and Info column on summary display */
492         col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISMP");
493         col_clear(pinfo->cinfo, COL_INFO);
494
495         /*
496          * XXX - I've seen captures with packets that have the ISMP
497          * Ethernet frame type, but with the payload being 0x42 0x42 0x03
498          * followed by what appears to be an ISMP frame.
499          *
500          * 0x4242 is not a valid ISMP version number.
501          */
502         if (tvb_memeql(tvb, offset, weird_stuff, sizeof weird_stuff) == 0)
503                 offset += 3;    /* skip the weird stuff, for now */
504         if (tree) {
505                 /* create display subtree for ismp */
506                 ti = proto_tree_add_item(tree, proto_ismp, tvb, offset, -1, ENC_NA);
507
508                 ismp_tree = proto_item_add_subtree(ti, ett_ismp);
509
510                 /* add an items to the subtree */
511                 proto_tree_add_item(ismp_tree, hf_ismp_version, tvb, offset, 2, ENC_BIG_ENDIAN);
512                 offset += 2;
513                 message_type = tvb_get_ntohs(tvb, offset);
514                 proto_tree_add_item(ismp_tree, hf_ismp_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
515                 offset += 2;
516                 proto_tree_add_item(ismp_tree, hf_ismp_seq_num, tvb, offset, 2, ENC_BIG_ENDIAN);
517                 offset += 2;
518                 code_length = tvb_get_guint8(tvb, offset);
519                 proto_tree_add_item(ismp_tree, hf_ismp_code_length, tvb, offset, 1, ENC_BIG_ENDIAN);
520                 offset += 1;
521                 proto_tree_add_item(ismp_tree, hf_ismp_auth_data, tvb, offset, code_length, ENC_NA);
522                 offset += code_length;
523
524                 /* if Enterasys Discover Protocol, dissect it */
525                 if(message_type == ISMPTYPE_EDP)
526                         dissect_ismp_edp(tvb, pinfo, offset, tree);
527         }
528
529 }
530
531
532 /* Register this protocol with Wireshark */
533 void
534 proto_register_ismp(void)
535 {
536
537 /* Setup list of header fields  See Section 1.6.1 for details*/
538         static hf_register_info hf[] = {
539 #if 0
540                 { &hf_ismp,
541                         { "ISMP", "ismp",
542                         FT_PROTOCOL, BASE_NONE, NULL, 0x0,
543                         "Inter Switch Message Protocol", HFILL }
544                 },
545 #endif
546                 { &hf_ismp_version,
547                         { "Version",           "ismp.version",
548                         FT_UINT16, BASE_DEC, NULL, 0x0,
549                         NULL, HFILL }
550                 },
551                 { &hf_ismp_message_type,
552                         { "Message Type", "ismp.msgtype",
553                         FT_UINT16, BASE_DEC, NULL, 0x0,
554                         NULL, HFILL }
555                 },
556                 { &hf_ismp_seq_num,
557                         { "Sequence Number", "ismp.seqnum",
558                         FT_UINT16, BASE_DEC, NULL, 0x0,
559                         NULL, HFILL }
560                 },
561                 { &hf_ismp_code_length,
562                         { "Auth Code Length", "ismp.codelen",
563                         FT_UINT8, BASE_DEC, NULL, 0x0,
564                         NULL, HFILL }
565                 },
566                 { &hf_ismp_auth_data,
567                         { "Auth Data", "ismp.authdata",
568                         FT_BYTES, BASE_NONE, NULL, 0x0,
569                         NULL, HFILL }
570                 },
571                 { &hf_ismp_edp,
572                         { "EDP", "ismp.edp",
573                         FT_PROTOCOL, BASE_NONE, NULL, 0x0,
574                         "Enterasys Discovery Protocol", HFILL }
575                 },
576                 { &hf_ismp_edp_version,
577                         { "Version", "ismp.edp.version",
578                         FT_UINT16, BASE_DEC, NULL, 0x0,
579                         NULL, HFILL }
580                 },
581                 { &hf_ismp_edp_module_ip,
582                         { "Module IP Address", "ismp.edp.modip",
583                         FT_IPv4, BASE_NONE, NULL, 0x0,
584                         NULL, HFILL }
585                 },
586                 { &hf_ismp_edp_module_mac,
587                         { "Module MAC Address", "ismp.edp.modmac",
588                         FT_ETHER, BASE_NONE, NULL, 0x0,
589                         NULL, HFILL }
590                 },
591                 { &hf_ismp_edp_module_port,
592                         { "Module Port (ifIndex num)", "ismp.edp.modport",
593                         FT_UINT32, BASE_DEC, NULL, 0x0,
594                         NULL, HFILL }
595                 },
596                 { &hf_ismp_edp_chassis_mac,
597                         { "Chassis MAC Address", "ismp.edp.chassismac",
598                         FT_ETHER, BASE_NONE, NULL, 0x0,
599                         NULL, HFILL }
600                 },
601                 { &hf_ismp_edp_chassis_ip,
602                         { "Chassis IP Address", "ismp.edp.chassisip",
603                         FT_IPv4, BASE_NONE, NULL, 0x0,
604                         NULL, HFILL }
605                 },
606                 { &hf_ismp_edp_device_type,
607                         { "Device Type", "ismp.edp.devtype",
608                         FT_UINT16, BASE_DEC, VALS(edp_device_types), 0x0,
609                         NULL, HFILL }
610                 },
611                 { &hf_ismp_edp_module_rev,
612                         { "Module Firmware Revision", "ismp.edp.rev",
613                         FT_UINT32, BASE_DEC, NULL, 0x0,
614                         NULL, HFILL }
615                 },
616                 { &hf_ismp_edp_options,
617                         { "Device Options", "ismp.edp.options",
618                         FT_UINT32, BASE_DEC, NULL, 0x0,
619                         NULL, HFILL }
620                 },
621                 { &hf_ismp_edp_sfs_option_unused1,
622                         { "Unused", "ismp.edp.sfs_option_unused1",
623                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UNUSED1,
624                         NULL, HFILL }
625                 },
626                 { &hf_ismp_edp_sfs_option_sfssup,
627                         { "SFS Support", "ismp.edp.sfs_option_sfssup",
628                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_SFSSUP,
629                         NULL, HFILL }
630                 },
631                 { &hf_ismp_edp_sfs_option_lsp,
632                         { "LSP Support", "ismp.edp.sfs_option_lsp",
633                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_LSP,
634                         NULL, HFILL }
635                 },
636                 { &hf_ismp_edp_sfs_option_flood,
637                         { "Flood Path Support", "ismp.edp.sfs_option_flood",
638                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_FLOOD,
639                         NULL, HFILL }
640                 },
641                 { &hf_ismp_edp_sfs_option_resolve,
642                         { "Resolve Support", "ismp.edp.sfs_option_resolve",
643                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_RESOLVE,
644                         NULL, HFILL }
645                 },
646                 { &hf_ismp_edp_sfs_option_unused2,
647                         { "Unused", "ismp.edp.sfs_option_unused2",
648                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UNUSED2,
649                         NULL, HFILL }
650                 },
651                 { &hf_ismp_edp_sfs_option_tagflood,
652                         { "Tagged Flood Support", "ismp.edp.sfs_option_tagflood",
653                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_TAGFLOOD,
654                         NULL, HFILL }
655                 },
656                 { &hf_ismp_edp_sfs_option_calltap,
657                         { "Call Tap Support", "ismp.edp.sfs_option_calltap",
658                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_CALLTAP,
659                         NULL, HFILL }
660                 },
661                 { &hf_ismp_edp_sfs_option_conmsg,
662                         { "Connection Message Support", "ismp.edp.sfs_option_conmsg",
663                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_CONMSG,
664                         NULL, HFILL }
665                 },
666                 { &hf_ismp_edp_sfs_option_redun,
667                         { "Redundant Access Support", "ismp.edp.sfs_option_redun",
668                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_REDUN,
669                         NULL, HFILL }
670                 },
671                 { &hf_ismp_edp_sfs_option_isolated,
672                         { "Isolated Switch", "ismp.edp.sfs_option_isolated",
673                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_ISOLATED,
674                         NULL, HFILL }
675                 },
676                 { &hf_ismp_edp_sfs_option_uplink_switch,
677                         { "Uplink Switch", "ismp.edp.sfs_option_uplink_switch",
678                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UPLINK_SWITCH,
679                         NULL, HFILL }
680                 },
681                 { &hf_ismp_edp_sfs_option_uplink_core,
682                         { "Uplink Core", "ismp.edp.sfs_option_uplink_core",
683                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UPLINK_CORE,
684                         NULL, HFILL }
685                 },
686                 { &hf_ismp_edp_sfs_option_uplink_port,
687                         { "Uplink Port", "ismp.edp.sfs_option_uplink_port",
688                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UPLINK_PORT,
689                         NULL, HFILL }
690                 },
691                 { &hf_ismp_edp_sfs_option_uplink_flood,
692                         { "Uplink Flood Support", "ismp.edp.sfs_option_uplink_flood",
693                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SFS_OPTION_UPLINK_FLOOD,
694                         NULL, HFILL }
695                 },
696                 { &hf_ismp_edp_rtr_option_ssr,
697                         { "SSR Type Device", "ismp.edp.rtr_option_ssr",
698                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_SSR,
699                         NULL, HFILL }
700                 },
701                 { &hf_ismp_edp_rtr_option_igmp,
702                         { "IGMP Active", "ismp.edp.rtr_option_igmp",
703                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_IGMP,
704                         NULL, HFILL }
705                 },
706                 { &hf_ismp_edp_rtr_option_rip,
707                         { "RIP Active", "ismp.edp.rtr_option_rip",
708                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_RIP,
709                         NULL, HFILL }
710                 },
711                 { &hf_ismp_edp_rtr_option_bgp,
712                         { "BGP Active", "ismp.edp.rtr_option_bgp",
713                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_BGP,
714                         NULL, HFILL }
715                 },
716                 { &hf_ismp_edp_rtr_option_ospf,
717                         { "OSPF Active", "ismp.edp.rtr_option_ospf",
718                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_OSPF,
719                         NULL, HFILL }
720                 },
721                 { &hf_ismp_edp_rtr_option_dvmrp,
722                         { "DVMRP Active", "ismp.edp.rtr_option_dvmrp",
723                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_DVMRP,
724                         NULL, HFILL }
725                 },
726                 { &hf_ismp_edp_rtr_option_8021q,
727                         { "802.1Q Support", "ismp.edp.rtr_option_8021q",
728                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_8021Q,
729                         NULL, HFILL }
730                 },
731                 { &hf_ismp_edp_rtr_option_gvrp,
732                         { "GVRP Support", "ismp.edp.rtr_option_gvrp",
733                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_GVRP,
734                         NULL, HFILL }
735                 },
736                 { &hf_ismp_edp_rtr_option_gmrp,
737                         { "GMRP Support", "ismp.edp.rtr_option_gmrp",
738                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_GMRP,
739                         NULL, HFILL }
740                 },
741                 { &hf_ismp_edp_rtr_option_igmp_snoop,
742                         { "IGMP Snooping Support", "ismp.edp.rtr_option_igmp_snoop",
743                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_IGMP_SNOOP,
744                         NULL, HFILL }
745                 },
746                 { &hf_ismp_edp_rtr_option_route,
747                         { "Route Bridging", "ismp.edp.rtr_option_route",
748                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_ROUTE,
749                         NULL, HFILL }
750                 },
751                 { &hf_ismp_edp_rtr_option_trans,
752                         { "Transparent Bridging", "ismp.edp.rtr_option_trans",
753                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_TRANS,
754                         NULL, HFILL }
755                 },
756                 { &hf_ismp_edp_rtr_option_level1,
757                         { "Level 1 Functionality", "ismp.edp.rtr_option_level1",
758                         FT_BOOLEAN, 32, TFS(&is_set), EDP_RTR_OPTION_LEVEL1,
759                         NULL, HFILL }
760                 },
761                 { &hf_ismp_edp_switch_option_8021q,
762                         { "802.1Q Support", "ismp.edp.switch_option_8021q",
763                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_8021Q,
764                         NULL, HFILL }
765                 },
766                 { &hf_ismp_edp_switch_option_gvrp,
767                         { "GVRP Support", "ismp.edp.switch_option_gvrp",
768                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_GVRP,
769                         NULL, HFILL }
770                 },
771                 { &hf_ismp_edp_switch_option_gmrp,
772                         { "GMRP Support", "ismp.edp.switch_option_gmrp",
773                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_GMRP,
774                         NULL, HFILL }
775                 },
776                 { &hf_ismp_edp_switch_option_igmp,
777                         { "IGMP Snooping Support", "ismp.edp.switch_option_igmp",
778                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_IGMP,
779                         NULL, HFILL }
780                 },
781                 { &hf_ismp_edp_switch_option_route,
782                         { "Route Bridging", "ismp.edp.switch_option_route",
783                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_ROUTE,
784                         NULL, HFILL }
785                 },
786                 { &hf_ismp_edp_switch_option_trans,
787                         { "Transparent Bridging", "ismp.edp.switch_option_trans",
788                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_TRANS,
789                         NULL, HFILL }
790                 },
791                 { &hf_ismp_edp_switch_option_level1,
792                         { "Level 1 Functionality", "ismp.edp.switch_option_level1",
793                         FT_BOOLEAN, 32, TFS(&is_set), EDP_SWITCH_OPTION_LEVEL1,
794                         NULL, HFILL }
795                 },
796                 { &hf_ismp_edp_end_station_option_dhcp,
797                         { "DHCP Enabled", "ismp.edp.end_station_option_dhcp",
798                         FT_BOOLEAN, 32, TFS(&is_set), EDP_END_STATION_OPTION_DHCP,
799                         NULL, HFILL }
800                 },
801                 { &hf_ismp_edp_end_station_option_dns,
802                         { "DNS Enabled", "ismp.edp.end_station_option_dns",
803                         FT_BOOLEAN, 32, TFS(&is_set), EDP_END_STATION_OPTION_DNS,
804                         NULL, HFILL }
805                 },
806                 { &hf_ismp_edp_end_station_option_ad,
807                         { "Active Directory Enabled", "ismp.edp.end_station_option_ad",
808                         FT_BOOLEAN, 32, TFS(&is_set), EDP_END_STATION_OPTION_AD,
809                         NULL, HFILL }
810                 },
811                 { &hf_ismp_edp_num_neighbors,
812                         { "Number of Known Neighbors", "ismp.edp.maccount",
813                         FT_UINT16, BASE_DEC, NULL, 0x0,
814                         NULL, HFILL }
815                 },
816                 { &hf_ismp_edp_neighbors,
817                         { "Neighbors", "ismp.edp.nbrs",
818                         FT_BYTES, BASE_NONE, NULL, 0x0,
819                         NULL, HFILL }
820                 },
821                 { &hf_ismp_edp_num_tuples,
822                         { "Number of Tuples", "ismp.edp.numtups",
823                         FT_UINT16, BASE_DEC, NULL, 0x0,
824                         NULL, HFILL }
825                 },
826                 { &hf_ismp_edp_tuples,
827                         { "Number of Tuples", "ismp.edp.tups",
828                         FT_BYTES, BASE_NONE, NULL, 0x0,
829                         NULL, HFILL }
830                 },
831         };
832
833 /* Setup protocol subtree array */
834         static gint *ett[] = {
835                 &ett_ismp,
836                 &ett_ismp_edp,
837                 &ett_ismp_edp_options,
838                 &ett_ismp_edp_neighbors,
839                 &ett_ismp_edp_neighbors_leaf,
840                 &ett_ismp_edp_tuples,
841                 &ett_ismp_edp_tuples_leaf,
842         };
843
844 /* Register the protocol name and description */
845         proto_ismp = proto_register_protocol("InterSwitch Message Protocol",
846             "ISMP", "ismp");
847
848 /* Required function calls to register the header fields and subtrees used */
849         proto_register_field_array(proto_ismp, hf, array_length(hf));
850         proto_register_subtree_array(ett, array_length(ett));
851 }
852
853
854 /* If this dissector uses sub-dissector registration add a registration routine.
855    This format is required because a script is used to find these routines and
856    create the code that calls these routines.
857 */
858 void
859 proto_reg_handoff_ismp(void)
860 {
861         dissector_handle_t ismp_handle;
862
863         ismp_handle = create_dissector_handle(dissect_ismp,
864             proto_ismp);
865         dissector_add_uint("ethertype", ETHERTYPE_ISMP, ismp_handle);
866 }
867
868 /*
869  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
870  *
871  * Local variables:
872  * c-basic-offset: 8
873  * tab-width: 8
874  * indent-tabs-mode: t
875  * End:
876  *
877  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
878  * :indentSize=8:tabSize=8:noTabs=false:
879  */