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., 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:
37 * +--------+--------+--------+--------+--------+--------+--------+--------+
38 * |Version | Type |Clust ID|MSG Flag| Length |HA Port |Not Used|
39 * +--------+--------+--------+--------+--------+--------+--------+--------+
40 * | Destination Unit | Source Unit |
41 * +--------+--------+--------+--------+--------+--------+--------+--------+
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" },
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" },
110 { 0x08, "SAVE SLAVE" },
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" },
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" },
138 static const value_string nsrp_encflag_vals
[] = {
139 { 0xf0, "ENCRYPT METHOD MASK" },
140 { 0x0f, "ENCRYPT PAD BIT MASK" },
145 /* Initialize the subtree pointers */
146 static gint ett_nsrp
= -1;
148 /* Code to actually dissect the packets */
150 dissect_nsrp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
153 proto_tree
*nsrp_tree
= NULL
;
157 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "NSRP");
159 col_set_str(pinfo
->cinfo
, COL_INFO
, "NSRP Protocol");
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
);
169 msgtype
= tvb_get_guint8(tvb
, offset
);
170 proto_tree_add_item(nsrp_tree
, hf_nsrp_msg_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
173 proto_tree_add_item(nsrp_tree
, hf_nsrp_clust_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
176 proto_tree_add_item(nsrp_tree
, hf_nsrp_msg_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
179 proto_tree_add_item(nsrp_tree
, hf_nsrp_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
182 proto_tree_add_item(nsrp_tree
, hf_nsrp_ha_port
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
185 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
188 proto_tree_add_item(nsrp_tree
, hf_nsrp_dst_unit
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
191 proto_tree_add_item(nsrp_tree
, hf_nsrp_src_unit
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
198 * NSRP HA Packet is defined as follow:
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
);
217 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
220 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
223 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
226 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
229 proto_tree_add_item(nsrp_tree
, hf_nsrp_encflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
232 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
235 proto_tree_add_item(nsrp_tree
, hf_nsrp_total_size
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
238 proto_tree_add_item(nsrp_tree
, hf_nsrp_ns
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
241 proto_tree_add_item(nsrp_tree
, hf_nsrp_nr
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
244 proto_tree_add_item(nsrp_tree
, hf_nsrp_no_used
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
247 proto_tree_add_item(nsrp_tree
, hf_nsrp_checksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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:
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
);
273 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
276 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
279 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
282 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
285 proto_tree_add_item(nsrp_tree
, hf_nsrp_authflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
288 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
291 proto_tree_add_item(nsrp_tree
, hf_nsrp_priority
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
294 proto_tree_add_item(nsrp_tree
, hf_nsrp_dummy
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
297 proto_tree_add_item(nsrp_tree
, hf_nsrp_authchecksum
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
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:
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
);
324 proto_tree_add_item(nsrp_tree
, hf_nsrp_wst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
327 proto_tree_add_item(nsrp_tree
, hf_nsrp_hst_group
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
330 proto_tree_add_item(nsrp_tree
, hf_nsrp_msgflag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
333 proto_tree_add_item(nsrp_tree
, hf_nsrp_msglen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
336 proto_tree_add_item(nsrp_tree
, hf_nsrp_ifnum
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
339 proto_tree_add_item(nsrp_tree
, hf_nsrp_not_used
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
342 proto_tree_add_item(nsrp_tree
, hf_nsrp_total_size
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
345 proto_tree_add_item(nsrp_tree
, hf_nsrp_data
, tvb
, offset
, -1, ENC_ASCII
|ENC_NA
);
353 proto_register_nsrp(void)
356 static hf_register_info hf
[] = {
358 { "Version", "nsrp.version",
359 FT_UINT8
, BASE_DEC
, NULL
, 0,
360 "NSRP Version", HFILL
}
363 { "Type", "nsrp.type",
364 FT_UINT8
, BASE_DEC
, nsrp_msg_type_vals
, 0,
365 "NSRP Message Type", HFILL
}
368 { "Clust ID", "nsrp.clustid",
369 FT_UINT8
, BASE_DEC
, NULL
, 0,
370 "NSRP CLUST ID", HFILL
}
373 { "Flag", "nsrp.flag",
374 FT_UINT8
, BASE_DEC
, NULL
, 0,
378 { "Length", "nsrp.length",
379 FT_UINT16
, BASE_DEC
, NULL
, 0,
380 "NSRP Length", HFILL
}
383 { "Port", "nsrp.haport",
384 FT_UINT8
, BASE_DEC
, NULL
, 0,
385 "NSRP HA Port", HFILL
}
388 { "Not used", "nsrp.notused",
389 FT_UINT8
, BASE_DEC
, NULL
, 0,
393 { "Destination", "nsrp.dst",
394 FT_UINT32
, BASE_DEC
, NULL
, 0,
395 "DESTINATION UNIT INFORMATION", HFILL
}
398 { "Source", "nsrp.src",
399 FT_UINT32
, BASE_DEC
, NULL
, 0,
400 "SOURCE UNIT INFORMATION", HFILL
}
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
}
418 { "Msgflag", "nsrp.msgflag",
419 FT_UINT8
, BASE_DEC
, VALS(nsrp_flag_vals
), 0,
420 "NSRP MSG FLAG", HFILL
}
423 { "Msg Length", "nsrp.msglen",
424 FT_UINT16
, BASE_DEC
, NULL
, 0,
425 "NSRP MESSAGE LENGTH", HFILL
}
429 { "Enc Flag", "nsrp.encflag",
430 FT_UINT8
, BASE_DEC
, VALS(nsrp_encflag_vals
), 0,
431 "NSRP ENCRYPT FLAG", HFILL
}
435 { "Not Used", "nsrp.notused",
436 FT_UINT8
, BASE_DEC
, NULL
, 0,
440 { &hf_nsrp_total_size
,
441 { "Total Size", "nsrp.totalsize",
442 FT_UINT32
, BASE_DEC
, NULL
, 0,
443 "NSRP MSG TOTAL MESSAGE", HFILL
}
447 FT_UINT16
, BASE_DEC
, NULL
, 0,
452 FT_UINT16
, BASE_DEC
, NULL
, 0,
456 { "Reserved", "nsrp.reserved",
457 FT_UINT16
, BASE_DEC
, NULL
, 0,
461 { "Checksum", "nsrp.checksum",
462 FT_UINT16
, BASE_HEX
, NULL
, 0,
463 "NSRP PACKET CHECKSUM", HFILL
}
466 { "AuthFlag", "nsrp.authflag",
467 FT_UINT8
, BASE_HEX
, NULL
, 0,
468 "NSRP Auth Flag", HFILL
}
471 { "Priority", "nsrp.priority",
472 FT_UINT8
, BASE_HEX
, NULL
, 0,
473 "NSRP Priority", HFILL
}
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
}
486 { "Ifnum", "nsrp.ifnum",
487 FT_UINT16
, BASE_HEX
, NULL
, 0,
488 "NSRP IfNum", HFILL
}
491 { "Data", "nsrp.data",
492 FT_STRING
, BASE_NONE
, NULL
, 0,
497 static gint
*ett
[] = {
501 proto_nsrp
= proto_register_protocol("Juniper Netscreen Redundant Protocol",
503 proto_register_field_array(proto_nsrp
, hf
, array_length(hf
));
504 proto_register_subtree_array(ett
, array_length(ett
));
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
);