2 * Routines for decoding isis complete & partial SNP and their payload
4 * $Id: packet-isis-snp.c,v 1.15 2002/04/07 22:36:55 guy Exp $
5 * Stuart Stanley <stuarts@mxmail.net>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
37 #include <epan/packet.h>
38 #include "packet-osi.h"
39 #include "packet-isis.h"
40 #include "packet-isis-clv.h"
41 #include "packet-isis-lsp.h"
42 #include "packet-isis-snp.h"
45 static int hf_isis_csnp_pdu_length = -1;
46 static gint ett_isis_csnp = -1;
47 static gint ett_isis_csnp_lsp_entries = -1;
48 static gint ett_isis_csnp_authentication = -1;
49 static gint ett_isis_csnp_clv_unknown = -1;
52 static int hf_isis_psnp_pdu_length = -1;
53 static gint ett_isis_psnp = -1;
54 static gint ett_isis_psnp_lsp_entries = -1;
55 static gint ett_isis_psnp_authentication = -1;
56 static gint ett_isis_psnp_clv_unknown = -1;
58 static void dissect_l1_snp_authentication_clv(tvbuff_t *tvb,
59 proto_tree *tree, int offset, int id_length, int length);
60 static void dissect_l2_snp_authentication_clv(tvbuff_t *tvb,
61 proto_tree *tree, int offset, int id_length, int length);
62 static void dissect_snp_lsp_entries(tvbuff_t *tvb,
63 proto_tree *tree, int offset, int id_length, int length);
65 static const isis_clv_handle_t clv_l1_csnp_opts[] = {
67 ISIS_CLV_L1_CSNP_LSP_ENTRIES,
69 &ett_isis_csnp_lsp_entries,
70 dissect_snp_lsp_entries
73 ISIS_CLV_L1_CSNP_AUTHENTICATION_NS,
74 "Authentication(non spec)",
75 &ett_isis_csnp_authentication,
76 dissect_l1_snp_authentication_clv
79 ISIS_CLV_L1_CSNP_AUTHENTICATION,
81 &ett_isis_csnp_authentication,
82 dissect_l1_snp_authentication_clv
89 static const isis_clv_handle_t clv_l2_csnp_opts[] = {
91 ISIS_CLV_L2_CSNP_LSP_ENTRIES,
93 &ett_isis_csnp_lsp_entries,
94 dissect_snp_lsp_entries
97 ISIS_CLV_L2_CSNP_AUTHENTICATION_NS,
98 "Authentication(non spec)",
99 &ett_isis_csnp_authentication,
100 dissect_l2_snp_authentication_clv
103 ISIS_CLV_L2_CSNP_AUTHENTICATION,
105 &ett_isis_csnp_authentication,
106 dissect_l2_snp_authentication_clv
113 static const isis_clv_handle_t clv_l1_psnp_opts[] = {
115 ISIS_CLV_L1_PSNP_LSP_ENTRIES,
117 &ett_isis_psnp_lsp_entries,
118 dissect_snp_lsp_entries
121 ISIS_CLV_L1_PSNP_AUTHENTICATION_NS,
122 "Authentication(non spec)",
123 &ett_isis_psnp_authentication,
124 dissect_l1_snp_authentication_clv
127 ISIS_CLV_L1_PSNP_AUTHENTICATION,
129 &ett_isis_psnp_authentication,
130 dissect_l1_snp_authentication_clv
137 static const isis_clv_handle_t clv_l2_psnp_opts[] = {
139 ISIS_CLV_L2_PSNP_LSP_ENTRIES,
141 &ett_isis_psnp_lsp_entries,
142 dissect_snp_lsp_entries
145 ISIS_CLV_L2_PSNP_AUTHENTICATION,
147 &ett_isis_psnp_authentication,
148 dissect_l2_snp_authentication_clv
151 ISIS_CLV_L2_PSNP_AUTHENTICATION_NS,
152 "Authentication(non spec)",
153 &ett_isis_psnp_authentication,
154 dissect_l2_snp_authentication_clv
161 * Name: dissect_snp_lsp_entries()
164 * All the snp packets use a common payload format. We have up
165 * to n entries (based on length), which are made of:
166 * 2 : remaining life time
168 * 4 : sequence number
172 * tvbuff_t * : tvbuffer for packet data
173 * proto_tree * : protocol display tree to fill out. May be NULL
174 * int : offset into packet data where we are.
175 * int : length of payload to decode.
176 * int : length of IDs in packet.
179 * void, but we will add to proto tree if !NULL.
182 dissect_snp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
183 int id_length, int length)
185 while ( length > 0 ) {
186 if ( length < 2+id_length+2+4+2 ) {
187 isis_dissect_unknown(tvb, tree, offset,
188 "Short SNP header entry (%d vs %d)", length,
193 proto_tree_add_text(tree, tvb, offset, 2, "Remaining life : %d",
194 tvb_get_ntohs(tvb, offset));
198 isis_lsp_decode_lsp_id(tvb, tree, offset,
199 "LSP ID ", id_length);
200 length -= id_length + 2;
201 offset += id_length + 2;
203 proto_tree_add_text(tree, tvb, offset, 4,
204 "LSP Sequence Number : 0x%04x",
205 tvb_get_ntohl(tvb, offset));
209 proto_tree_add_text(tree, tvb, offset, 2,
210 "LSP checksum : 0x%02x",
211 tvb_get_ntohs(tvb, offset));
219 * Name: isis_dissect_isis_csnp()
222 * Tear apart a L1 or L2 CSNP header and then call into payload dissect
223 * to pull apart the lsp id payload.
226 * tvbuff_t * : tvbuffer for packet data
227 * proto_tree * : protocol display tree to add to. May be NULL.
228 * int offset : our offset into packet data.
229 * int : type (l1 csnp, l2 csnp)
230 * int : header length of packet.
231 * int : length of IDs in packet.
234 * void, but we will add to proto tree if !NULL.
237 isis_dissect_isis_csnp(tvbuff_t *tvb, proto_tree *tree, int offset,
238 int type, int header_length, int id_length)
241 proto_tree *csnp_tree = NULL;
246 ti = proto_tree_add_text(tree, tvb, offset, -1,
248 csnp_tree = proto_item_add_subtree(ti, ett_isis_csnp);
251 pdu_length = tvb_get_ntohs(tvb, offset);
253 proto_tree_add_uint(csnp_tree, hf_isis_csnp_pdu_length, tvb,
254 offset, 2, pdu_length);
259 proto_tree_add_text(csnp_tree, tvb, offset, id_length + 1,
261 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
263 offset += id_length + 1;
266 isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
267 "Start LSP id ", id_length );
269 offset += id_length + 2;
272 isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
273 "End LSP id ", id_length );
275 offset += id_length + 2;
277 len = pdu_length - header_length;
281 /* Call into payload dissector */
282 if (type == ISIS_TYPE_L1_CSNP ) {
283 isis_dissect_clvs(tvb, csnp_tree, offset,
284 clv_l1_csnp_opts, len, id_length,
285 ett_isis_csnp_clv_unknown );
287 isis_dissect_clvs(tvb, csnp_tree, offset,
288 clv_l2_csnp_opts, len, id_length,
289 ett_isis_csnp_clv_unknown );
294 * Name: isis_dissect_isis_psnp()
297 * Tear apart a L1 or L2 PSNP header and then call into payload dissect
298 * to pull apart the lsp id payload.
301 * tvbuff_t * : tvbuffer for packet data
302 * proto_tree * : protocol display tree to add to. May be NULL.
303 * int : our offset into packet data
304 * int : type (l1 psnp, l2 psnp)
305 * int : header length of packet.
306 * int : length of IDs in packet.
309 * void, but we will add to proto tree if !NULL.
312 isis_dissect_isis_psnp(tvbuff_t *tvb, proto_tree *tree, int offset,
313 int type, int header_length, int id_length)
316 proto_tree *psnp_tree = NULL;
321 ti = proto_tree_add_text(tree, tvb, offset, -1,
323 psnp_tree = proto_item_add_subtree(ti, ett_isis_psnp);
326 pdu_length = tvb_get_ntohs(tvb, offset);
328 proto_tree_add_uint(psnp_tree, hf_isis_psnp_pdu_length, tvb,
329 offset, 2, pdu_length);
334 proto_tree_add_text(psnp_tree, tvb, offset, id_length + 1,
336 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length + 1 ) );
338 offset += id_length + 1;
340 len = pdu_length - header_length;
342 isis_dissect_unknown(tvb, tree, offset,
343 "packet header length %d went beyond packet",
347 /* Call into payload dissector */
348 if (type == ISIS_TYPE_L1_CSNP ) {
349 isis_dissect_clvs(tvb, psnp_tree, offset,
350 clv_l1_csnp_opts, len, id_length,
351 ett_isis_psnp_clv_unknown );
353 isis_dissect_clvs(tvb, psnp_tree, offset,
354 clv_l2_csnp_opts, len, id_length,
355 ett_isis_psnp_clv_unknown );
360 * Name: dissect_L1_snp_authentication_clv()
363 * Decode for a lsp packets authenticaion clv. Calls into the
364 * clv common one. An auth inside a L1 SNP is a per area password
367 * tvbuff_t * : tvbuffer for packet data
368 * proto_tree * : proto tree to build on (may be null)
369 * int : current offset into packet data
370 * int : length of IDs in packet.
371 * int : length of this clv
374 * void, will modify proto_tree if not null.
377 dissect_l1_snp_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
378 int id_length, int length)
380 isis_dissect_authentication_clv(tvb, tree, offset, length,
381 "Per area authentication" );
385 * Name: dissect_l2_authentication_clv()
388 * Decode for a lsp packets authenticaion clv. Calls into the
389 * clv common one. An auth inside a L2 LSP is a per domain password
392 * tvbuff_t * : tvbuffer for packet data
393 * proto_tree * : proto tree to build on (may be null)
394 * int : current offset into packet data
395 * int : length of IDs in packet.
396 * int : length of this clv
399 * void, will modify proto_tree if not null.
402 dissect_l2_snp_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
403 int id_length, int length)
405 isis_dissect_authentication_clv(tvb, tree, offset, length,
406 "Per domain authentication" );
410 * Name: isis_register_csnp()
413 * Register our protocol sub-sets with protocol manager.
416 * int : protocol index for the ISIS protocol
422 isis_register_csnp(int proto_isis) {
423 static hf_register_info hf[] = {
424 { &hf_isis_csnp_pdu_length,
425 { "PDU length", "isis.csnp.pdu_length", FT_UINT16,
426 BASE_DEC, NULL, 0x0, "", HFILL }},
428 static gint *ett[] = {
430 &ett_isis_csnp_lsp_entries,
431 &ett_isis_csnp_authentication,
432 &ett_isis_csnp_clv_unknown,
435 proto_register_field_array(proto_isis, hf, array_length(hf));
436 proto_register_subtree_array(ett, array_length(ett));
441 * Name: isis_register_psnp()
444 * Register our protocol sub-sets with protocol manager.
447 * int : protocol index for the ISIS protocol
453 isis_register_psnp(int proto_isis) {
454 static hf_register_info hf[] = {
455 { &hf_isis_psnp_pdu_length,
456 { "PDU length", "isis.psnp.pdu_length", FT_UINT16,
457 BASE_DEC, NULL, 0x0, "", HFILL }},
459 static gint *ett[] = {
461 &ett_isis_psnp_lsp_entries,
462 &ett_isis_psnp_authentication,
463 &ett_isis_psnp_clv_unknown,
466 proto_register_field_array(proto_isis, hf, array_length(hf));
467 proto_register_subtree_array(ett, array_length(ett));