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 static dissector_handle_t nsrp_handle
;
43 #define NSRP_MIN_LEN 32
45 /* Initialize the protocol and registered fields */
46 static int proto_nsrp
;
48 static int hf_nsrp_version
;
49 static int hf_nsrp_msg_type
;
50 static int hf_nsrp_clust_id
;
51 static int hf_nsrp_msg_flag
;
52 static int hf_nsrp_len
;
53 static int hf_nsrp_ha_port
;
54 static int hf_nsrp_not_used
;
55 static int hf_nsrp_dst_unit
;
56 static int hf_nsrp_src_unit
;
57 static int hf_nsrp_msgtype
;
58 static int hf_nsrp_wst_group
;
59 static int hf_nsrp_hst_group
;
60 static int hf_nsrp_msgflag
;
61 static int hf_nsrp_authflag
;
62 static int hf_nsrp_priority
;
63 static int hf_nsrp_dummy
;
64 static int hf_nsrp_authchecksum
;
65 static int hf_nsrp_ifnum
;
68 /* Dada defined for HA Message */
69 static int hf_nsrp_msglen
;
70 static int hf_nsrp_encflag
;
71 /* static int hf_nsrp_notused; */
73 static int hf_nsrp_total_size
;
75 static int hf_nsrp_ns
;
76 static int hf_nsrp_nr
;
78 static int hf_nsrp_no_used
;
79 static int hf_nsrp_checksum
;
81 static int hf_nsrp_data
;
84 static const value_string nsrp_msg_type_vals
[] = {
85 { 0x01, "HA MESSAGE" },
86 { 0x02, "MNG MESSAGE" },
87 { 0x03, "DADA MESSAGE" },
91 static const value_string nsrp_msgtype_vals
[] = {
92 { 0x01, "CREATE SESSION" },
93 { 0x02, "CLOSE SESSION" },
94 { 0x03, "CHANG SESSION" },
95 { 0x04, "CREATE SP SESSION" },
96 { 0x05, "SYS CONFIG" },
99 { 0x08, "SAVE SLAVE" },
102 { 0x0b, "HEALTH CHECK" },
103 { 0x0c, "EMW DATA" },
104 { 0x0d, "INVITE SYNC" },
105 { 0x0e, "DOWNLOAD CONFIG" },
106 { 0x0f, "L2TP TUNL CREATE" },
107 { 0x10, "L2TP TUNL DELETE" },
108 { 0x11, "L2TP CALL CREATE" },
109 { 0x12, "L2TP CALL DELETE" },
110 { 0x13, "PKI SYNC" },
116 static const value_string nsrp_flag_vals
[] = {
117 { 0x80, "ENCRYPT MESSAGE" },
118 { 0x40, "CLOSE SESSION" },
119 { 0x20, "CHANG SESSION" },
120 { 0x10, "CREATE SP SESSION" },
121 { 0x08, "SYS CONFIG" },
122 { 0x04, "FILE SYS" },
127 static const value_string nsrp_encflag_vals
[] = {
128 { 0xf0, "ENCRYPT METHOD MASK" },
129 { 0x0f, "ENCRYPT PAD BIT MASK" },
134 /* Initialize the subtree pointers */
137 /* Code to actually dissect the packets */
139 dissect_nsrp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
142 proto_tree
*nsrp_tree
= NULL
;
146 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "NSRP");
148 col_set_str(pinfo
->cinfo
, COL_INFO
, "NSRP Protocol");
151 ti
= proto_tree_add_item(tree
, proto_nsrp
, tvb
, 0, -1, ENC_NA
);
152 nsrp_tree
= proto_item_add_subtree(ti
, ett_nsrp
);
155 proto_tree_add_item(nsrp_tree
, hf_nsrp_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
158 msgtype
= tvb_get_uint8(tvb
, offset
);
159 proto_tree_add_item(nsrp_tree
, hf_nsrp_msg_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
162 proto_tree_add_item(nsrp_tree
, hf_nsrp_clust_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
165 proto_tree_add_item(nsrp_tree
, hf_nsrp_msg_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
168 proto_tree_add_item(nsrp_tree
, hf_nsrp_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
171 proto_tree_add_item(nsrp_tree
, hf_nsrp_ha_port
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
174 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
177 proto_tree_add_item(nsrp_tree
, hf_nsrp_dst_unit
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
180 proto_tree_add_item(nsrp_tree
, hf_nsrp_src_unit
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
187 * NSRP HA Packet is defined as follow:
190 * +--------+--------+--------+--------+--------+--------+--------+--------+
191 * | Type |WstGroup|HstGroup|MSG Flag| Length |Enc Flag|Not Used|
192 * +--------+--------+--------+--------+--------+--------+--------+--------+
193 * | Total Size | NS | NR |
194 * +--------+--------+--------+--------+--------+--------+--------+--------+
195 * | No Used | Checksum | Data |
196 * +--------+--------+--------+--------+-----------------------------------+
201 if ( msgtype
== 0x00 ) {
203 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
206 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
209 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
212 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
215 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
218 proto_tree_add_item(nsrp_tree
, hf_nsrp_encflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
221 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
224 proto_tree_add_item(nsrp_tree
, hf_nsrp_total_size
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
227 proto_tree_add_item(nsrp_tree
, hf_nsrp_ns
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
230 proto_tree_add_item(nsrp_tree
, hf_nsrp_nr
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
233 proto_tree_add_item(nsrp_tree
, hf_nsrp_no_used
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
236 proto_tree_add_checksum(nsrp_tree
, tvb
, offset
, hf_nsrp_checksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
239 proto_tree_add_item(nsrp_tree
, hf_nsrp_data
, tvb
, offset
, -1, ENC_ASCII
);
245 * NSRP MNG Packet is defined as follow:
248 * +--------+--------+--------+--------+--------+--------+--------+--------+
249 * | Type |WstGroup|HstGroup|MSG Flag| Length |AuthFlag|Not Used|
250 * +--------+--------+--------+--------+--------+--------+--------+--------+
251 * |Priority+ Dummy + Auth CheckSum + Data |
252 * +--------+--------+--------+--------+-----------------------------------+
257 if ( msgtype
== 0x02 ) {
259 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
262 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
265 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
268 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
271 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
274 proto_tree_add_item(nsrp_tree
, hf_nsrp_authflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
277 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
280 proto_tree_add_item(nsrp_tree
, hf_nsrp_priority
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
283 proto_tree_add_item(nsrp_tree
, hf_nsrp_dummy
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
286 proto_tree_add_checksum(nsrp_tree
, tvb
, offset
, hf_nsrp_authchecksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
289 proto_tree_add_item(nsrp_tree
, hf_nsrp_data
, tvb
, offset
, -1, ENC_ASCII
);
297 * NSRP DATA Packet is defined as follow:
300 * +--------+--------+--------+--------+--------+--------+--------+--------+
301 * | Type |WstGroup|HstGroup|MSG Flag| Length | Ifnum |Not Used|
302 * +--------+--------+--------+--------+--------+--------+--------+--------+
303 * | Total Size | Data |
304 * +--------+--------+--------+--------+-----------------------------------+
308 if ( msgtype
== 0x03 ) {
310 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
313 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
316 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
319 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
322 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
325 proto_tree_add_item(nsrp_tree
, hf_nsrp_ifnum
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
328 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
331 proto_tree_add_item(nsrp_tree
, hf_nsrp_total_size
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
334 proto_tree_add_item(nsrp_tree
, hf_nsrp_data
, tvb
, offset
, -1, ENC_ASCII
);
338 return tvb_captured_length(tvb
);
343 proto_register_nsrp(void)
346 static hf_register_info hf
[] = {
348 { "Version", "nsrp.version",
349 FT_UINT8
, BASE_DEC
, NULL
, 0,
350 "NSRP Version", HFILL
}
353 { "Type", "nsrp.type",
354 FT_UINT8
, BASE_DEC
, VALS(nsrp_msg_type_vals
), 0,
355 "NSRP Message Type", HFILL
}
358 { "Clust ID", "nsrp.clustid",
359 FT_UINT8
, BASE_DEC
, NULL
, 0,
360 "NSRP CLUST ID", HFILL
}
363 { "Flag", "nsrp.flag",
364 FT_UINT8
, BASE_DEC
, NULL
, 0,
368 { "Length", "nsrp.length",
369 FT_UINT16
, BASE_DEC
, NULL
, 0,
370 "NSRP Length", HFILL
}
373 { "Port", "nsrp.haport",
374 FT_UINT8
, BASE_DEC
, NULL
, 0,
375 "NSRP HA Port", HFILL
}
378 { "Not used", "nsrp.notused",
379 FT_UINT8
, BASE_DEC
, NULL
, 0,
383 { "Destination", "nsrp.dst",
384 FT_UINT32
, BASE_DEC
, NULL
, 0,
385 "DESTINATION UNIT INFORMATION", HFILL
}
388 { "Source", "nsrp.src",
389 FT_UINT32
, BASE_DEC
, NULL
, 0,
390 "SOURCE UNIT INFORMATION", HFILL
}
393 { "MsgType", "nsrp.msgtype",
394 FT_UINT8
, BASE_DEC
, VALS(nsrp_msgtype_vals
), 0,
395 "Message Type", HFILL
}
397 { &hf_nsrp_wst_group
,
398 { "Wst group", "nsrp.wst",
399 FT_UINT8
, BASE_DEC
, NULL
, 0,
400 "NSRP WST GROUP", HFILL
}
402 { &hf_nsrp_hst_group
,
403 { "Hst group", "nsrp.hst",
404 FT_UINT8
, BASE_DEC
, NULL
, 0,
405 "NSRP HST GROUP", HFILL
}
408 { "Msgflag", "nsrp.msgflag",
409 FT_UINT8
, BASE_DEC
, VALS(nsrp_flag_vals
), 0,
410 "NSRP MSG FLAG", HFILL
}
413 { "Msg Length", "nsrp.msglen",
414 FT_UINT16
, BASE_DEC
, NULL
, 0,
415 "NSRP MESSAGE LENGTH", HFILL
}
419 { "Enc Flag", "nsrp.encflag",
420 FT_UINT8
, BASE_DEC
, VALS(nsrp_encflag_vals
), 0,
421 "NSRP ENCRYPT FLAG", HFILL
}
425 { "Not Used", "nsrp.notused",
426 FT_UINT8
, BASE_DEC
, NULL
, 0,
430 { &hf_nsrp_total_size
,
431 { "Total Size", "nsrp.totalsize",
432 FT_UINT32
, BASE_DEC
, NULL
, 0,
433 "NSRP MSG TOTAL MESSAGE", HFILL
}
437 FT_UINT16
, BASE_DEC
, NULL
, 0,
442 FT_UINT16
, BASE_DEC
, NULL
, 0,
446 { "Reserved", "nsrp.reserved",
447 FT_UINT16
, BASE_DEC
, NULL
, 0,
451 { "Checksum", "nsrp.checksum",
452 FT_UINT16
, BASE_HEX
, NULL
, 0,
453 "NSRP PACKET CHECKSUM", HFILL
}
456 { "AuthFlag", "nsrp.authflag",
457 FT_UINT8
, BASE_HEX
, NULL
, 0,
458 "NSRP Auth Flag", HFILL
}
461 { "Priority", "nsrp.priority",
462 FT_UINT8
, BASE_HEX
, NULL
, 0,
463 "NSRP Priority", HFILL
}
466 { "Dummy", "nsrp.dummy",
467 FT_UINT8
, BASE_HEX
, NULL
, 0,
468 "NSRP Dummy", HFILL
}
470 { &hf_nsrp_authchecksum
,
471 { "Checksum", "nsrp.authchecksum",
472 FT_UINT16
, BASE_HEX
, NULL
, 0,
473 "NSRP AUTH CHECKSUM", HFILL
}
476 { "Ifnum", "nsrp.ifnum",
477 FT_UINT16
, BASE_HEX
, NULL
, 0,
478 "NSRP IfNum", HFILL
}
481 { "Data", "nsrp.data",
482 FT_STRING
, BASE_NONE
, NULL
, 0,
487 static int *ett
[] = {
491 proto_nsrp
= proto_register_protocol("Juniper Netscreen Redundant Protocol",
493 proto_register_field_array(proto_nsrp
, hf
, array_length(hf
));
494 proto_register_subtree_array(ett
, array_length(ett
));
496 nsrp_handle
= register_dissector("nsrp", dissect_nsrp
, proto_nsrp
);
501 proto_reg_handoff_nsrp(void)
503 dissector_add_uint("ethertype", ETHERTYPE_NSRP
, nsrp_handle
);
508 * Editor modelines - https://www.wireshark.org/tools/modelines.html
513 * indent-tabs-mode: nil
516 * vi: set shiftwidth=4 tabstop=8 expandtab:
517 * :indentSize=4:tabSize=8:noTabs=true: