MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-nsrp.c
bloba6a5e0b3c282e45a31f3f9475b22f008bcaf9284
1 /* packet-nsrp.c
2 * Routines for the Juniper Netscreen Redundant Protocol (NSRP)
4 * Secfire <secfire@gmail.com>
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 * NSRP update information can be found at www.juniper.net
34 * NSRP Packet Header is defined as follow:
36 * 1 2 3 4 5 6 7 8
37 * +--------+--------+--------+--------+--------+--------+--------+--------+
38 * |Version | Type |Clust ID|MSG Flag| Length |HA Port |Not Used|
39 * +--------+--------+--------+--------+--------+--------+--------+--------+
40 * | Destination Unit | Source Unit |
41 * +--------+--------+--------+--------+--------+--------+--------+--------+
47 #include "config.h"
49 #include <glib.h>
51 #include <epan/packet.h>
52 #include <epan/etypes.h>
54 #define NSRP_MIN_LEN 32
56 /* Initialize the protocol and registered fields */
57 static int proto_nsrp = -1;
59 static int hf_nsrp_version = -1;
60 static int hf_nsrp_msg_type = -1;
61 static int hf_nsrp_clust_id = -1;
62 static int hf_nsrp_msg_flag = -1;
63 static int hf_nsrp_len = -1;
64 static int hf_nsrp_ha_port = -1;
65 static int hf_nsrp_not_used = -1;
66 static int hf_nsrp_dst_unit = -1;
67 static int hf_nsrp_src_unit = -1;
68 static int hf_nsrp_msgtype = -1;
69 static int hf_nsrp_wst_group = -1;
70 static int hf_nsrp_hst_group = -1;
71 static int hf_nsrp_msgflag = -1;
72 static int hf_nsrp_authflag = -1;
73 static int hf_nsrp_priority = -1;
74 static int hf_nsrp_dummy = -1;
75 static int hf_nsrp_authchecksum = -1;
76 static int hf_nsrp_ifnum = -1;
79 /* Dada defined for HA Message */
80 static int hf_nsrp_msglen = -1;
81 static int hf_nsrp_encflag = -1;
82 /* static int hf_nsrp_notused = -1; */
84 static int hf_nsrp_total_size = -1;
86 static int hf_nsrp_ns = -1;
87 static int hf_nsrp_nr = -1;
89 static int hf_nsrp_no_used = -1;
90 static int hf_nsrp_checksum = -1;
92 static int hf_nsrp_data = -1;
95 static const value_string nsrp_msg_type_vals[] = {
96 { 0x01, "HA MESSAGE" },
97 { 0x02, "MNG MESSAGE" },
98 { 0x03, "DADA MESSAGE" },
99 { 0, NULL }
102 static const value_string nsrp_msgtype_vals[] = {
103 { 0x01, "CREATE SESSION" },
104 { 0x02, "CLOSE SESSION" },
105 { 0x03, "CHANG SESSION" },
106 { 0x04, "CREATE SP SESSION" },
107 { 0x05, "SYS CONFIG" },
108 { 0x06, "FILE SYS" },
109 { 0x07, "CMD WEB" },
110 { 0x08, "SAVE SLAVE" },
111 { 0x09, "VPN SPI" },
112 { 0x0a, "ARP" },
113 { 0x0b, "HEALTH CHECK" },
114 { 0x0c, "EMW DATA" },
115 { 0x0d, "INVITE SYNC" },
116 { 0x0e, "DOWNLOAD CONFIG" },
117 { 0x0f, "L2TP TUNL CREATE" },
118 { 0x10, "L2TP TUNL DELETE" },
119 { 0x11, "L2TP CALL CREATE" },
120 { 0x12, "L2TP CALL DELETE" },
121 { 0x13, "PKI SYNC" },
122 { 0x14, "VPN SEQ" },
123 { 0x15, "MAX" },
124 { 0, NULL }
127 static const value_string nsrp_flag_vals[] = {
128 { 0x80, "ENCRPT MESSAGE" },
129 { 0x40, "CLOSE SESSION" },
130 { 0x20, "CHANG SESSION" },
131 { 0x10, "CREATE SP SESSION" },
132 { 0x08, "SYS CONFIG" },
133 { 0x04, "FILE SYS" },
134 { 0x02, "CMD WEB" },
135 { 0, NULL }
138 static const value_string nsrp_encflag_vals[] = {
139 { 0xf0, "ENCRYPT METHOD MASK" },
140 { 0x0f, "ENCRYPT PAD BIT MASK" },
141 { 0, NULL }
145 /* Initialize the subtree pointers */
146 static gint ett_nsrp = -1;
148 /* Code to actually dissect the packets */
149 static void
150 dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
152 proto_item *ti;
153 proto_tree *nsrp_tree = NULL;
154 gint offset = 0;
155 guint8 msgtype = 0;
157 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSRP");
159 col_set_str(pinfo->cinfo, COL_INFO, "NSRP Protocol");
161 if (tree) {
162 ti = proto_tree_add_item(tree, proto_nsrp, tvb, 0, -1, ENC_NA);
163 nsrp_tree = proto_item_add_subtree(ti, ett_nsrp);
166 proto_tree_add_item(nsrp_tree, hf_nsrp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
167 offset += 1;
169 msgtype = tvb_get_guint8(tvb, offset);
170 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
171 offset += 1;
173 proto_tree_add_item(nsrp_tree, hf_nsrp_clust_id, tvb, offset, 1, ENC_BIG_ENDIAN);
174 offset += 1;
176 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
177 offset += 1;
179 proto_tree_add_item(nsrp_tree, hf_nsrp_len, tvb, offset, 2, ENC_BIG_ENDIAN);
180 offset += 2;
182 proto_tree_add_item(nsrp_tree, hf_nsrp_ha_port, tvb, offset, 1, ENC_BIG_ENDIAN);
183 offset += 1;
185 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
186 offset += 1;
188 proto_tree_add_item(nsrp_tree, hf_nsrp_dst_unit, tvb, offset, 4, ENC_BIG_ENDIAN);
189 offset += 4;
191 proto_tree_add_item(nsrp_tree, hf_nsrp_src_unit, tvb, offset, 4, ENC_BIG_ENDIAN);
192 offset += 4;
198 * NSRP HA Packet is defined as follow:
200 * 1 2 3 4 5 6 7 8
201 * +--------+--------+--------+--------+--------+--------+--------+--------+
202 * | Type |WstGroup|HstGroup|MSG Flag| Length |Enc Flag|Not Used|
203 * +--------+--------+--------+--------+--------+--------+--------+--------+
204 * | Total Size | NS | NR |
205 * +--------+--------+--------+--------+--------+--------+--------+--------+
206 * | No Used | Checksum | Data |
207 * +--------+--------+--------+--------+-----------------------------------+
212 if ( msgtype == 0x00 ) {
214 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
215 offset += 1;
217 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
218 offset += 1;
220 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
221 offset += 1;
223 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
224 offset += 1;
226 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
227 offset += 2;
229 proto_tree_add_item(nsrp_tree, hf_nsrp_encflag, tvb, offset, 1, ENC_BIG_ENDIAN);
230 offset += 1;
232 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
233 offset += 1;
235 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, ENC_BIG_ENDIAN);
236 offset += 4;
238 proto_tree_add_item(nsrp_tree, hf_nsrp_ns, tvb, offset, 2, ENC_BIG_ENDIAN);
239 offset += 2;
241 proto_tree_add_item(nsrp_tree, hf_nsrp_nr, tvb, offset, 2, ENC_BIG_ENDIAN);
242 offset += 2;
244 proto_tree_add_item(nsrp_tree, hf_nsrp_no_used, tvb, offset, 2, ENC_BIG_ENDIAN);
245 offset += 2;
247 proto_tree_add_item(nsrp_tree, hf_nsrp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
248 offset += 2;
250 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
256 * NSRP MNG Packet is defined as follow:
258 * 1 2 3 4 5 6 7 8
259 * +--------+--------+--------+--------+--------+--------+--------+--------+
260 * | Type |WstGroup|HstGroup|MSG Flag| Length |AuthFlag|Not Used|
261 * +--------+--------+--------+--------+--------+--------+--------+--------+
262 * |Priority+ Dummy + Auth CheckSum + Data |
263 * +--------+--------+--------+--------+-----------------------------------+
268 if ( msgtype == 0x02 ) {
270 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
271 offset += 1;
273 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
274 offset += 1;
276 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
277 offset += 1;
279 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
280 offset += 1;
282 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
283 offset += 2;
285 proto_tree_add_item(nsrp_tree, hf_nsrp_authflag, tvb, offset, 1, ENC_BIG_ENDIAN);
286 offset += 1;
288 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
289 offset += 1;
291 proto_tree_add_item(nsrp_tree, hf_nsrp_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
292 offset += 1;
294 proto_tree_add_item(nsrp_tree, hf_nsrp_dummy, tvb, offset, 1, ENC_BIG_ENDIAN);
295 offset += 1;
297 proto_tree_add_item(nsrp_tree, hf_nsrp_authchecksum, tvb, offset, 2, ENC_BIG_ENDIAN);
298 offset += 2;
300 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
308 * NSRP DATA Packet is defined as follow:
310 * 1 2 3 4 5 6 7 8
311 * +--------+--------+--------+--------+--------+--------+--------+--------+
312 * | Type |WstGroup|HstGroup|MSG Flag| Length | Ifnum |Not Used|
313 * +--------+--------+--------+--------+--------+--------+--------+--------+
314 * | Total Size | Data |
315 * +--------+--------+--------+--------+-----------------------------------+
319 if ( msgtype == 0x03 ) {
321 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
322 offset += 1;
324 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
325 offset += 1;
327 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
328 offset += 1;
330 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
331 offset += 1;
333 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
334 offset += 2;
336 proto_tree_add_item(nsrp_tree, hf_nsrp_ifnum, tvb, offset, 1, ENC_BIG_ENDIAN);
337 offset += 1;
339 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
340 offset += 1;
342 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, ENC_BIG_ENDIAN);
343 offset += 4;
345 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
352 void
353 proto_register_nsrp(void)
356 static hf_register_info hf[] = {
357 { &hf_nsrp_version,
358 { "Version", "nsrp.version",
359 FT_UINT8, BASE_DEC, NULL, 0,
360 "NSRP Version", HFILL }
362 { &hf_nsrp_msg_type,
363 { "Type", "nsrp.type",
364 FT_UINT8, BASE_DEC, nsrp_msg_type_vals, 0,
365 "NSRP Message Type", HFILL }
367 { &hf_nsrp_clust_id,
368 { "Clust ID", "nsrp.clustid",
369 FT_UINT8, BASE_DEC, NULL, 0,
370 "NSRP CLUST ID", HFILL }
372 { &hf_nsrp_msg_flag,
373 { "Flag", "nsrp.flag",
374 FT_UINT8, BASE_DEC, NULL, 0,
375 "NSRP FLAG", HFILL }
377 { &hf_nsrp_len,
378 { "Length", "nsrp.length",
379 FT_UINT16, BASE_DEC, NULL, 0,
380 "NSRP Length", HFILL }
382 { &hf_nsrp_ha_port,
383 { "Port", "nsrp.haport",
384 FT_UINT8, BASE_DEC, NULL, 0,
385 "NSRP HA Port", HFILL }
387 { &hf_nsrp_not_used,
388 { "Not used", "nsrp.notused",
389 FT_UINT8, BASE_DEC, NULL, 0,
390 NULL, HFILL }
392 { &hf_nsrp_dst_unit,
393 { "Destination", "nsrp.dst",
394 FT_UINT32, BASE_DEC, NULL, 0,
395 "DESTINATION UNIT INFORMATION", HFILL }
397 { &hf_nsrp_src_unit,
398 { "Source", "nsrp.src",
399 FT_UINT32, BASE_DEC, NULL, 0,
400 "SOURCE UNIT INFORMATION", HFILL }
402 { &hf_nsrp_msgtype,
403 { "MsgType", "nsrp.msgtype",
404 FT_UINT8, BASE_DEC, VALS(nsrp_msgtype_vals), 0,
405 "Message Type", HFILL }
407 { &hf_nsrp_wst_group,
408 { "Wst group", "nsrp.wst",
409 FT_UINT8, BASE_DEC, NULL, 0,
410 "NSRP WST GROUP", HFILL }
412 { &hf_nsrp_hst_group,
413 { "Hst group", "nsrp.hst",
414 FT_UINT8, BASE_DEC, NULL, 0,
415 "NSRP HST GROUP", HFILL }
417 { &hf_nsrp_msgflag,
418 { "Msgflag", "nsrp.msgflag",
419 FT_UINT8, BASE_DEC, VALS(nsrp_flag_vals), 0,
420 "NSRP MSG FLAG", HFILL }
422 { &hf_nsrp_msglen,
423 { "Msg Length", "nsrp.msglen",
424 FT_UINT16, BASE_DEC, NULL, 0,
425 "NSRP MESSAGE LENGTH", HFILL }
428 { &hf_nsrp_encflag,
429 { "Enc Flag", "nsrp.encflag",
430 FT_UINT8, BASE_DEC, VALS(nsrp_encflag_vals), 0,
431 "NSRP ENCRYPT FLAG", HFILL }
433 #if 0
434 { &hf_nsrp_notused,
435 { "Not Used", "nsrp.notused",
436 FT_UINT8, BASE_DEC, NULL, 0,
437 NULL, HFILL }
439 #endif
440 { &hf_nsrp_total_size,
441 { "Total Size", "nsrp.totalsize",
442 FT_UINT32, BASE_DEC, NULL, 0,
443 "NSRP MSG TOTAL MESSAGE", HFILL }
445 { &hf_nsrp_ns,
446 { "Ns", "nsrp.ns",
447 FT_UINT16, BASE_DEC, NULL, 0,
448 NULL, HFILL }
450 { &hf_nsrp_nr,
451 { "Nr", "nsrp.nr",
452 FT_UINT16, BASE_DEC, NULL, 0,
453 NULL, HFILL }
455 { &hf_nsrp_no_used,
456 { "Reserved", "nsrp.reserved",
457 FT_UINT16, BASE_DEC, NULL, 0,
458 NULL, HFILL }
460 { &hf_nsrp_checksum,
461 { "Checksum", "nsrp.checksum",
462 FT_UINT16, BASE_HEX, NULL, 0,
463 "NSRP PACKET CHECKSUM", HFILL }
465 { &hf_nsrp_authflag,
466 { "AuthFlag", "nsrp.authflag",
467 FT_UINT8, BASE_HEX, NULL, 0,
468 "NSRP Auth Flag", HFILL }
470 { &hf_nsrp_priority,
471 { "Priority", "nsrp.priority",
472 FT_UINT8, BASE_HEX, NULL, 0,
473 "NSRP Priority", HFILL }
475 { &hf_nsrp_dummy,
476 { "Dummy", "nsrp.dummy",
477 FT_UINT8, BASE_HEX, NULL, 0,
478 "NSRP Dummy", HFILL }
480 { &hf_nsrp_authchecksum,
481 { "Checksum", "nsrp.authchecksum",
482 FT_UINT16, BASE_HEX, NULL, 0,
483 "NSRP AUTH CHECKSUM", HFILL }
485 { &hf_nsrp_ifnum,
486 { "Ifnum", "nsrp.ifnum",
487 FT_UINT16, BASE_HEX, NULL, 0,
488 "NSRP IfNum", HFILL }
490 { &hf_nsrp_data,
491 { "Data", "nsrp.data",
492 FT_STRING, BASE_NONE, NULL, 0,
493 "PADDING", HFILL }
497 static gint *ett[] = {
498 &ett_nsrp
501 proto_nsrp = proto_register_protocol("Juniper Netscreen Redundant Protocol",
502 "NSRP", "nsrp");
503 proto_register_field_array(proto_nsrp, hf, array_length(hf));
504 proto_register_subtree_array(ett, array_length(ett));
508 void
509 proto_reg_handoff_nsrp(void)
511 dissector_handle_t nsrp_handle;
513 nsrp_handle = create_dissector_handle(dissect_nsrp, proto_nsrp);
514 dissector_add_uint("ethertype", ETHERTYPE_NSRP, nsrp_handle);