2 * Routines for the Juniper Netscreen Redundant Protocol (NSRP)
4 * Secfire <secfire@gmail.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
16 * NSRP update information can be found at www.juniper.net
20 * NSRP Packet Header is defined as follow:
23 * +--------+--------+--------+--------+--------+--------+--------+--------+
24 * |Version | Type |Clust ID|MSG Flag| Length |HA Port |Not Used|
25 * +--------+--------+--------+--------+--------+--------+--------+--------+
26 * | Destination Unit | Source Unit |
27 * +--------+--------+--------+--------+--------+--------+--------+--------+
35 #include <epan/packet.h>
36 #include <epan/etypes.h>
38 void proto_register_nsrp(void);
39 void proto_reg_handoff_nsrp(void);
41 #define NSRP_MIN_LEN 32
43 /* Initialize the protocol and registered fields */
44 static int proto_nsrp = -1;
46 static int hf_nsrp_version = -1;
47 static int hf_nsrp_msg_type = -1;
48 static int hf_nsrp_clust_id = -1;
49 static int hf_nsrp_msg_flag = -1;
50 static int hf_nsrp_len = -1;
51 static int hf_nsrp_ha_port = -1;
52 static int hf_nsrp_not_used = -1;
53 static int hf_nsrp_dst_unit = -1;
54 static int hf_nsrp_src_unit = -1;
55 static int hf_nsrp_msgtype = -1;
56 static int hf_nsrp_wst_group = -1;
57 static int hf_nsrp_hst_group = -1;
58 static int hf_nsrp_msgflag = -1;
59 static int hf_nsrp_authflag = -1;
60 static int hf_nsrp_priority = -1;
61 static int hf_nsrp_dummy = -1;
62 static int hf_nsrp_authchecksum = -1;
63 static int hf_nsrp_ifnum = -1;
66 /* Dada defined for HA Message */
67 static int hf_nsrp_msglen = -1;
68 static int hf_nsrp_encflag = -1;
69 /* static int hf_nsrp_notused = -1; */
71 static int hf_nsrp_total_size = -1;
73 static int hf_nsrp_ns = -1;
74 static int hf_nsrp_nr = -1;
76 static int hf_nsrp_no_used = -1;
77 static int hf_nsrp_checksum = -1;
79 static int hf_nsrp_data = -1;
82 static const value_string nsrp_msg_type_vals[] = {
83 { 0x01, "HA MESSAGE" },
84 { 0x02, "MNG MESSAGE" },
85 { 0x03, "DADA MESSAGE" },
89 static const value_string nsrp_msgtype_vals[] = {
90 { 0x01, "CREATE SESSION" },
91 { 0x02, "CLOSE SESSION" },
92 { 0x03, "CHANG SESSION" },
93 { 0x04, "CREATE SP SESSION" },
94 { 0x05, "SYS CONFIG" },
97 { 0x08, "SAVE SLAVE" },
100 { 0x0b, "HEALTH CHECK" },
101 { 0x0c, "EMW DATA" },
102 { 0x0d, "INVITE SYNC" },
103 { 0x0e, "DOWNLOAD CONFIG" },
104 { 0x0f, "L2TP TUNL CREATE" },
105 { 0x10, "L2TP TUNL DELETE" },
106 { 0x11, "L2TP CALL CREATE" },
107 { 0x12, "L2TP CALL DELETE" },
108 { 0x13, "PKI SYNC" },
114 static const value_string nsrp_flag_vals[] = {
115 { 0x80, "ENCRPT MESSAGE" },
116 { 0x40, "CLOSE SESSION" },
117 { 0x20, "CHANG SESSION" },
118 { 0x10, "CREATE SP SESSION" },
119 { 0x08, "SYS CONFIG" },
120 { 0x04, "FILE SYS" },
125 static const value_string nsrp_encflag_vals[] = {
126 { 0xf0, "ENCRYPT METHOD MASK" },
127 { 0x0f, "ENCRYPT PAD BIT MASK" },
132 /* Initialize the subtree pointers */
133 static gint ett_nsrp = -1;
135 /* Code to actually dissect the packets */
137 dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
140 proto_tree *nsrp_tree = NULL;
144 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSRP");
146 col_set_str(pinfo->cinfo, COL_INFO, "NSRP Protocol");
149 ti = proto_tree_add_item(tree, proto_nsrp, tvb, 0, -1, ENC_NA);
150 nsrp_tree = proto_item_add_subtree(ti, ett_nsrp);
153 proto_tree_add_item(nsrp_tree, hf_nsrp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
156 msgtype = tvb_get_guint8(tvb, offset);
157 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
160 proto_tree_add_item(nsrp_tree, hf_nsrp_clust_id, tvb, offset, 1, ENC_BIG_ENDIAN);
163 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
166 proto_tree_add_item(nsrp_tree, hf_nsrp_len, tvb, offset, 2, ENC_BIG_ENDIAN);
169 proto_tree_add_item(nsrp_tree, hf_nsrp_ha_port, tvb, offset, 1, ENC_BIG_ENDIAN);
172 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
175 proto_tree_add_item(nsrp_tree, hf_nsrp_dst_unit, tvb, offset, 4, ENC_BIG_ENDIAN);
178 proto_tree_add_item(nsrp_tree, hf_nsrp_src_unit, tvb, offset, 4, ENC_BIG_ENDIAN);
185 * NSRP HA Packet is defined as follow:
188 * +--------+--------+--------+--------+--------+--------+--------+--------+
189 * | Type |WstGroup|HstGroup|MSG Flag| Length |Enc Flag|Not Used|
190 * +--------+--------+--------+--------+--------+--------+--------+--------+
191 * | Total Size | NS | NR |
192 * +--------+--------+--------+--------+--------+--------+--------+--------+
193 * | No Used | Checksum | Data |
194 * +--------+--------+--------+--------+-----------------------------------+
199 if ( msgtype == 0x00 ) {
201 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
204 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
207 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
210 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
213 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
216 proto_tree_add_item(nsrp_tree, hf_nsrp_encflag, tvb, offset, 1, ENC_BIG_ENDIAN);
219 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
222 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, ENC_BIG_ENDIAN);
225 proto_tree_add_item(nsrp_tree, hf_nsrp_ns, tvb, offset, 2, ENC_BIG_ENDIAN);
228 proto_tree_add_item(nsrp_tree, hf_nsrp_nr, tvb, offset, 2, ENC_BIG_ENDIAN);
231 proto_tree_add_item(nsrp_tree, hf_nsrp_no_used, tvb, offset, 2, ENC_BIG_ENDIAN);
234 proto_tree_add_checksum(nsrp_tree, tvb, offset, hf_nsrp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
237 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
243 * NSRP MNG Packet is defined as follow:
246 * +--------+--------+--------+--------+--------+--------+--------+--------+
247 * | Type |WstGroup|HstGroup|MSG Flag| Length |AuthFlag|Not Used|
248 * +--------+--------+--------+--------+--------+--------+--------+--------+
249 * |Priority+ Dummy + Auth CheckSum + Data |
250 * +--------+--------+--------+--------+-----------------------------------+
255 if ( msgtype == 0x02 ) {
257 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
260 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
263 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
266 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
269 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
272 proto_tree_add_item(nsrp_tree, hf_nsrp_authflag, tvb, offset, 1, ENC_BIG_ENDIAN);
275 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
278 proto_tree_add_item(nsrp_tree, hf_nsrp_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
281 proto_tree_add_item(nsrp_tree, hf_nsrp_dummy, tvb, offset, 1, ENC_BIG_ENDIAN);
284 proto_tree_add_checksum(nsrp_tree, tvb, offset, hf_nsrp_authchecksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
287 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
295 * NSRP DATA Packet is defined as follow:
298 * +--------+--------+--------+--------+--------+--------+--------+--------+
299 * | Type |WstGroup|HstGroup|MSG Flag| Length | Ifnum |Not Used|
300 * +--------+--------+--------+--------+--------+--------+--------+--------+
301 * | Total Size | Data |
302 * +--------+--------+--------+--------+-----------------------------------+
306 if ( msgtype == 0x03 ) {
308 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, ENC_BIG_ENDIAN);
311 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
314 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, ENC_BIG_ENDIAN);
317 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, ENC_BIG_ENDIAN);
320 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, ENC_BIG_ENDIAN);
323 proto_tree_add_item(nsrp_tree, hf_nsrp_ifnum, tvb, offset, 1, ENC_BIG_ENDIAN);
326 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, ENC_BIG_ENDIAN);
329 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, ENC_BIG_ENDIAN);
332 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
336 return tvb_captured_length(tvb);
341 proto_register_nsrp(void)
344 static hf_register_info hf[] = {
346 { "Version", "nsrp.version",
347 FT_UINT8, BASE_DEC, NULL, 0,
348 "NSRP Version", HFILL }
351 { "Type", "nsrp.type",
352 FT_UINT8, BASE_DEC, VALS(nsrp_msg_type_vals), 0,
353 "NSRP Message Type", HFILL }
356 { "Clust ID", "nsrp.clustid",
357 FT_UINT8, BASE_DEC, NULL, 0,
358 "NSRP CLUST ID", HFILL }
361 { "Flag", "nsrp.flag",
362 FT_UINT8, BASE_DEC, NULL, 0,
366 { "Length", "nsrp.length",
367 FT_UINT16, BASE_DEC, NULL, 0,
368 "NSRP Length", HFILL }
371 { "Port", "nsrp.haport",
372 FT_UINT8, BASE_DEC, NULL, 0,
373 "NSRP HA Port", HFILL }
376 { "Not used", "nsrp.notused",
377 FT_UINT8, BASE_DEC, NULL, 0,
381 { "Destination", "nsrp.dst",
382 FT_UINT32, BASE_DEC, NULL, 0,
383 "DESTINATION UNIT INFORMATION", HFILL }
386 { "Source", "nsrp.src",
387 FT_UINT32, BASE_DEC, NULL, 0,
388 "SOURCE UNIT INFORMATION", HFILL }
391 { "MsgType", "nsrp.msgtype",
392 FT_UINT8, BASE_DEC, VALS(nsrp_msgtype_vals), 0,
393 "Message Type", HFILL }
395 { &hf_nsrp_wst_group,
396 { "Wst group", "nsrp.wst",
397 FT_UINT8, BASE_DEC, NULL, 0,
398 "NSRP WST GROUP", HFILL }
400 { &hf_nsrp_hst_group,
401 { "Hst group", "nsrp.hst",
402 FT_UINT8, BASE_DEC, NULL, 0,
403 "NSRP HST GROUP", HFILL }
406 { "Msgflag", "nsrp.msgflag",
407 FT_UINT8, BASE_DEC, VALS(nsrp_flag_vals), 0,
408 "NSRP MSG FLAG", HFILL }
411 { "Msg Length", "nsrp.msglen",
412 FT_UINT16, BASE_DEC, NULL, 0,
413 "NSRP MESSAGE LENGTH", HFILL }
417 { "Enc Flag", "nsrp.encflag",
418 FT_UINT8, BASE_DEC, VALS(nsrp_encflag_vals), 0,
419 "NSRP ENCRYPT FLAG", HFILL }
423 { "Not Used", "nsrp.notused",
424 FT_UINT8, BASE_DEC, NULL, 0,
428 { &hf_nsrp_total_size,
429 { "Total Size", "nsrp.totalsize",
430 FT_UINT32, BASE_DEC, NULL, 0,
431 "NSRP MSG TOTAL MESSAGE", HFILL }
435 FT_UINT16, BASE_DEC, NULL, 0,
440 FT_UINT16, BASE_DEC, NULL, 0,
444 { "Reserved", "nsrp.reserved",
445 FT_UINT16, BASE_DEC, NULL, 0,
449 { "Checksum", "nsrp.checksum",
450 FT_UINT16, BASE_HEX, NULL, 0,
451 "NSRP PACKET CHECKSUM", HFILL }
454 { "AuthFlag", "nsrp.authflag",
455 FT_UINT8, BASE_HEX, NULL, 0,
456 "NSRP Auth Flag", HFILL }
459 { "Priority", "nsrp.priority",
460 FT_UINT8, BASE_HEX, NULL, 0,
461 "NSRP Priority", HFILL }
464 { "Dummy", "nsrp.dummy",
465 FT_UINT8, BASE_HEX, NULL, 0,
466 "NSRP Dummy", HFILL }
468 { &hf_nsrp_authchecksum,
469 { "Checksum", "nsrp.authchecksum",
470 FT_UINT16, BASE_HEX, NULL, 0,
471 "NSRP AUTH CHECKSUM", HFILL }
474 { "Ifnum", "nsrp.ifnum",
475 FT_UINT16, BASE_HEX, NULL, 0,
476 "NSRP IfNum", HFILL }
479 { "Data", "nsrp.data",
480 FT_STRING, BASE_NONE, NULL, 0,
485 static gint *ett[] = {
489 proto_nsrp = proto_register_protocol("Juniper Netscreen Redundant Protocol",
491 proto_register_field_array(proto_nsrp, hf, array_length(hf));
492 proto_register_subtree_array(ett, array_length(ett));
497 proto_reg_handoff_nsrp(void)
499 dissector_handle_t nsrp_handle;
501 nsrp_handle = create_dissector_handle(dissect_nsrp, proto_nsrp);
502 dissector_add_uint("ethertype", ETHERTYPE_NSRP, nsrp_handle);
507 * Editor modelines - http://www.wireshark.org/tools/modelines.html
512 * indent-tabs-mode: nil
515 * vi: set shiftwidth=4 tabstop=8 expandtab:
516 * :indentSize=4:tabSize=8:noTabs=true: