2 * Routines for the Juniper Netscreen Redundant Protocol (NSRP)
4 * Secfire <secfire@gmail.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * NSRP update information can be found at www.juniper.net
34 * NSRP Packet Header is defined as follow:
37 * +--------+--------+--------+--------+--------+--------+--------+--------+
38 * |Version | Type |Clust ID|MSG Flag| Length |HA Port |Not Used|
39 * +--------+--------+--------+--------+--------+--------+--------+--------+
40 * | Destination Unit | Source Unit |
41 * +--------+--------+--------+--------+--------+--------+--------+--------+
53 #include <epan/packet.h>
54 #include <epan/etypes.h>
56 #define NSRP_MIN_LEN 32
58 /* Initialize the protocol and registered fields */
59 static int proto_nsrp = -1;
61 static int hf_nsrp_version = -1;
62 static int hf_nsrp_msg_type = -1;
63 static int hf_nsrp_clust_id = -1;
64 static int hf_nsrp_msg_flag = -1;
65 static int hf_nsrp_len = -1;
66 static int hf_nsrp_ha_port = -1;
67 static int hf_nsrp_not_used = -1;
68 static int hf_nsrp_dst_unit = -1;
69 static int hf_nsrp_src_unit = -1;
70 static int hf_nsrp_msgtype = -1;
71 static int hf_nsrp_wst_group = -1;
72 static int hf_nsrp_hst_group = -1;
73 static int hf_nsrp_msgflag = -1;
74 static int hf_nsrp_authflag = -1;
75 static int hf_nsrp_priority = -1;
76 static int hf_nsrp_dummy = -1;
77 static int hf_nsrp_authchecksum = -1;
78 static int hf_nsrp_ifnum = -1;
81 /* Dada defined for HA Message */
82 static int hf_nsrp_msglen = -1;
83 static int hf_nsrp_encflag = -1;
84 static int hf_nsrp_notused = -1;
86 static int hf_nsrp_total_size = -1;
88 static int hf_nsrp_ns = -1;
89 static int hf_nsrp_nr = -1;
91 static int hf_nsrp_no_used = -1;
92 static int hf_nsrp_checksum = -1;
94 static int hf_nsrp_data = -1;
97 static const value_string nsrp_msg_type_vals[] = {
98 { 0x01, "HA MESSAGE" },
99 { 0x02, "MNG MESSAGE" },
100 { 0x03, "DADA MESSAGE" },
104 static const value_string nsrp_msgtype_vals[] = {
105 { 0x01, "CREATE SESSION" },
106 { 0x02, "CLOSE SESSION" },
107 { 0x03, "CHANG SESSION" },
108 { 0x04, "CREATE SP SESSION" },
109 { 0x05, "SYS CONFIG" },
110 { 0x06, "FILE SYS" },
112 { 0x08, "SAVE SLAVE" },
115 { 0x0b, "HEALTH CHECK" },
116 { 0x0c, "EMW DATA" },
117 { 0x0d, "INVITE SYNC" },
118 { 0x0e, "DOWNLOAD CONFIG" },
119 { 0x0f, "L2TP TUNL CREATE" },
120 { 0x10, "L2TP TUNL DELETE" },
121 { 0x11, "L2TP CALL CREATE" },
122 { 0x12, "L2TP CALL DELETE" },
123 { 0x13, "PKI SYNC" },
129 static const value_string nsrp_flag_vals[] = {
130 { 0x80, "ENCRPT MESSAGE" },
131 { 0x40, "CLOSE SESSION" },
132 { 0x20, "CHANG SESSION" },
133 { 0x10, "CREATE SP SESSION" },
134 { 0x08, "SYS CONFIG" },
135 { 0x04, "FILE SYS" },
140 static const value_string nsrp_encflag_vals[] = {
141 { 0xf0, "ENCRYPT METHOD MASK" },
142 { 0x0f, "ENCRYPT PAD BIT MASK" },
147 /* Initialize the subtree pointers */
148 static gint ett_nsrp = -1;
150 /* Code to actually dissect the packets */
152 dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
155 proto_tree *nsrp_tree = NULL;
159 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSRP");
161 if (check_col(pinfo->cinfo, COL_INFO))
163 col_set_str(pinfo->cinfo, COL_INFO, "NSRP Protocol");
167 ti = proto_tree_add_item(tree, proto_nsrp, tvb, 0, -1, FALSE);
168 nsrp_tree = proto_item_add_subtree(ti, ett_nsrp);
171 proto_tree_add_item(nsrp_tree, hf_nsrp_version, tvb, offset, 1, FALSE);
174 msgtype = tvb_get_guint8(tvb, offset);
175 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_type, tvb, offset, 1, FALSE);
178 proto_tree_add_item(nsrp_tree, hf_nsrp_clust_id, tvb, offset, 1, FALSE);
181 proto_tree_add_item(nsrp_tree, hf_nsrp_msg_flag, tvb, offset, 1, FALSE);
184 proto_tree_add_item(nsrp_tree, hf_nsrp_len, tvb, offset, 2, FALSE);
187 proto_tree_add_item(nsrp_tree, hf_nsrp_ha_port, tvb, offset, 1, FALSE);
190 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
193 proto_tree_add_item(nsrp_tree, hf_nsrp_dst_unit, tvb, offset, 4, FALSE);
196 proto_tree_add_item(nsrp_tree, hf_nsrp_src_unit, tvb, offset, 4, FALSE);
203 * NSRP HA Packet is defined as follow:
206 * +--------+--------+--------+--------+--------+--------+--------+--------+
207 * | Type |WstGroup|HstGroup|MSG Flag| Length |Enc Flag|Not Used|
208 * +--------+--------+--------+--------+--------+--------+--------+--------+
209 * | Total Size | NS | NR |
210 * +--------+--------+--------+--------+--------+--------+--------+--------+
211 * | No Used | Checksum | Data |
212 * +--------+--------+--------+--------+-----------------------------------+
217 if ( msgtype == 0x00 ) {
219 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
222 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
225 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
228 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
231 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
234 proto_tree_add_item(nsrp_tree, hf_nsrp_encflag, tvb, offset, 1, FALSE);
237 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
240 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, FALSE);
243 proto_tree_add_item(nsrp_tree, hf_nsrp_ns, tvb, offset, 2, FALSE);
246 proto_tree_add_item(nsrp_tree, hf_nsrp_nr, tvb, offset, 2, FALSE);
249 proto_tree_add_item(nsrp_tree, hf_nsrp_no_used, tvb, offset, 2, FALSE);
252 proto_tree_add_item(nsrp_tree, hf_nsrp_checksum, tvb, offset, 2, FALSE);
255 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
261 * NSRP MNG Packet is defined as follow:
264 * +--------+--------+--------+--------+--------+--------+--------+--------+
265 * | Type |WstGroup|HstGroup|MSG Flag| Length |AuthFlag|Not Used|
266 * +--------+--------+--------+--------+--------+--------+--------+--------+
267 * |Priority+ Dummy + Auth CheckSum + Data |
268 * +--------+--------+--------+--------+-----------------------------------+
273 if ( msgtype == 0x02 ) {
275 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
278 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
281 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
284 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
287 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
290 proto_tree_add_item(nsrp_tree, hf_nsrp_authflag, tvb, offset, 1, FALSE);
293 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
296 proto_tree_add_item(nsrp_tree, hf_nsrp_priority, tvb, offset, 1, FALSE);
299 proto_tree_add_item(nsrp_tree, hf_nsrp_dummy, tvb, offset, 1, FALSE);
302 proto_tree_add_item(nsrp_tree, hf_nsrp_authchecksum, tvb, offset, 2, FALSE);
305 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
313 * NSRP DATA Packet is defined as follow:
316 * +--------+--------+--------+--------+--------+--------+--------+--------+
317 * | Type |WstGroup|HstGroup|MSG Flag| Length | Ifnum |Not Used|
318 * +--------+--------+--------+--------+--------+--------+--------+--------+
319 * | Total Size | Data |
320 * +--------+--------+--------+--------+-----------------------------------+
324 if ( msgtype == 0x03 ) {
326 proto_tree_add_item(nsrp_tree, hf_nsrp_msgtype, tvb, offset, 1, FALSE);
329 proto_tree_add_item(nsrp_tree, hf_nsrp_wst_group, tvb, offset, 1, FALSE);
332 proto_tree_add_item(nsrp_tree, hf_nsrp_hst_group, tvb, offset, 1, FALSE);
335 proto_tree_add_item(nsrp_tree, hf_nsrp_msgflag, tvb, offset, 1, FALSE);
338 proto_tree_add_item(nsrp_tree, hf_nsrp_msglen, tvb, offset, 2, FALSE);
341 proto_tree_add_item(nsrp_tree, hf_nsrp_ifnum, tvb, offset, 1, FALSE);
344 proto_tree_add_item(nsrp_tree, hf_nsrp_not_used, tvb, offset, 1, FALSE);
347 proto_tree_add_item(nsrp_tree, hf_nsrp_total_size, tvb, offset, 4, FALSE);
350 proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, FALSE);
358 proto_register_nsrp(void)
361 static hf_register_info hf[] = {
363 { "Version", "nsrp.version",
364 FT_UINT8, BASE_DEC, NULL, 0,
365 "NSRP Version", HFILL }
368 { "Type", "nsrp.type",
369 FT_UINT8, BASE_DEC, nsrp_msg_type_vals, 0,
370 "NSRP Message Type", HFILL }
373 { "Clust ID", "nsrp.clustid",
374 FT_UINT8, BASE_DEC, NULL, 0,
375 "NSRP CLUST ID", HFILL }
378 { "Flag", "nsrp.flag",
379 FT_UINT8, BASE_DEC, NULL, 0,
383 { "Length", "nsrp.length",
384 FT_UINT16, BASE_DEC, NULL, 0,
385 "NSRP Length", HFILL }
388 { "Port", "nsrp.haport",
389 FT_UINT8, BASE_DEC, NULL, 0,
390 "NSRP HA Port", HFILL }
393 { "Not used", "nsrp.notused",
394 FT_UINT8, BASE_DEC, NULL, 0,
398 { "Destination", "nsrp.dst",
399 FT_UINT32, BASE_DEC, NULL, 0,
400 "DESTINATION UNIT INFORMATION", HFILL }
403 { "Source", "nsrp.src",
404 FT_UINT32, BASE_DEC, NULL, 0,
405 "SOURCE UNIT INFORMATION", HFILL }
408 { "MsgType", "nsrp.msgtype",
409 FT_UINT8, BASE_DEC, VALS(nsrp_msgtype_vals), 0,
410 "Message Type", HFILL }
412 { &hf_nsrp_wst_group,
413 { "Wst group", "nsrp.wst",
414 FT_UINT8, BASE_DEC, NULL, 0,
415 "NSRP WST GROUP", HFILL }
417 { &hf_nsrp_hst_group,
418 { "Hst group", "nsrp.hst",
419 FT_UINT8, BASE_DEC, NULL, 0,
420 "NSRP HST GROUP", HFILL }
423 { "Msgflag", "nsrp.msgflag",
424 FT_UINT8, BASE_DEC, VALS(nsrp_flag_vals), 0,
425 "NSRP MSG FLAG", HFILL }
428 { "Msg Length", "nsrp.msglen",
429 FT_UINT16, BASE_DEC, NULL, 0,
430 "NSRP MESSAGE LENGTH", HFILL }
434 { "Enc Flag", "nsrp.encflag",
435 FT_UINT8, BASE_DEC, VALS(nsrp_encflag_vals), 0,
436 "NSRP ENCRYPT FLAG", HFILL }
439 { "Not Used", "nsrp.notused",
440 FT_UINT8, BASE_DEC, NULL, 0,
443 { &hf_nsrp_total_size,
444 { "Total Size", "nsrp.totalsize",
445 FT_UINT32, BASE_DEC, NULL, 0,
446 "NSRP MSG TOTAL MESSAGE", HFILL }
450 FT_UINT16, BASE_DEC, NULL, 0,
455 FT_UINT16, BASE_DEC, NULL, 0,
459 { "Reserved", "nsrp.reserved",
460 FT_UINT16, BASE_DEC, NULL, 0,
464 { "Checksum", "nsrp.checksum",
465 FT_UINT16, BASE_HEX, NULL, 0,
466 "NSRP PACKET CHECKSUM", HFILL }
469 { "AuthFlag", "nsrp.authflag",
470 FT_UINT8, BASE_HEX, NULL, 0,
471 "NSRP Auth Flag", HFILL }
474 { "Priority", "nsrp.priority",
475 FT_UINT8, BASE_HEX, NULL, 0,
476 "NSRP Priority", HFILL }
479 { "Dummy", "nsrp.dummy",
480 FT_UINT8, BASE_HEX, NULL, 0,
481 "NSRP Dummy", HFILL }
483 { &hf_nsrp_authchecksum,
484 { "Checksum", "nsrp.authchecksum",
485 FT_UINT16, BASE_HEX, NULL, 0,
486 "NSRP AUTH CHECKSUM", HFILL }
489 { "Ifnum", "nsrp.ifnum",
490 FT_UINT16, BASE_HEX, NULL, 0,
491 "NSRP IfNum", HFILL }
494 { "Data", "nsrp.data",
495 FT_STRING, BASE_NONE, NULL, 0,
500 static gint *ett[] = {
504 proto_nsrp = proto_register_protocol("Juniper Netscreen Redundant Protocol",
506 proto_register_field_array(proto_nsrp, hf, array_length(hf));
507 proto_register_subtree_array(ett, array_length(ett));
512 proto_reg_handoff_nsrp(void)
514 dissector_handle_t nsrp_handle;
516 nsrp_handle = create_dissector_handle(dissect_nsrp, proto_nsrp);
517 dissector_add("ethertype", ETHERTYPE_NSRP, nsrp_handle);