2 * Routines for decoding isis complete & partial SNP and their payload
4 * $Id: packet-isis-snp.c,v 1.20 2002/09/02 22:10:15 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.
33 #include <epan/packet.h>
34 #include "packet-osi.h"
35 #include "packet-isis.h"
36 #include "packet-isis-clv.h"
37 #include "packet-isis-lsp.h"
38 #include "packet-isis-snp.h"
41 static int hf_isis_csnp_pdu_length = -1;
42 static gint ett_isis_csnp = -1;
43 static gint ett_isis_csnp_lsp_entries = -1;
44 static gint ett_isis_csnp_authentication = -1;
45 static gint ett_isis_csnp_clv_unknown = -1;
48 static int hf_isis_psnp_pdu_length = -1;
49 static gint ett_isis_psnp = -1;
50 static gint ett_isis_psnp_lsp_entries = -1;
51 static gint ett_isis_psnp_authentication = -1;
52 static gint ett_isis_psnp_clv_unknown = -1;
54 static void dissect_l1_snp_authentication_clv(tvbuff_t *tvb,
55 proto_tree *tree, int offset, int id_length, int length);
56 static void dissect_l2_snp_authentication_clv(tvbuff_t *tvb,
57 proto_tree *tree, int offset, int id_length, int length);
58 static void dissect_csnp_lsp_entries(tvbuff_t *tvb,
59 proto_tree *tree, int offset, int id_length, int length);
60 static void dissect_psnp_lsp_entries(tvbuff_t *tvb,
61 proto_tree *tree, int offset, int id_length, int length);
63 static const isis_clv_handle_t clv_l1_csnp_opts[] = {
65 ISIS_CLV_L1_CSNP_LSP_ENTRIES,
67 &ett_isis_csnp_lsp_entries,
68 dissect_csnp_lsp_entries
71 ISIS_CLV_L1_CSNP_AUTHENTICATION_NS,
72 "Authentication(non spec)",
73 &ett_isis_csnp_authentication,
74 dissect_l1_snp_authentication_clv
77 ISIS_CLV_L1_CSNP_AUTHENTICATION,
79 &ett_isis_csnp_authentication,
80 dissect_l1_snp_authentication_clv
87 static const isis_clv_handle_t clv_l2_csnp_opts[] = {
89 ISIS_CLV_L2_CSNP_LSP_ENTRIES,
91 &ett_isis_csnp_lsp_entries,
92 dissect_csnp_lsp_entries
95 ISIS_CLV_L2_CSNP_AUTHENTICATION_NS,
96 "Authentication(non spec)",
97 &ett_isis_csnp_authentication,
98 dissect_l2_snp_authentication_clv
101 ISIS_CLV_L2_CSNP_AUTHENTICATION,
103 &ett_isis_csnp_authentication,
104 dissect_l2_snp_authentication_clv
111 static const isis_clv_handle_t clv_l1_psnp_opts[] = {
113 ISIS_CLV_L1_PSNP_LSP_ENTRIES,
115 &ett_isis_psnp_lsp_entries,
116 dissect_psnp_lsp_entries
119 ISIS_CLV_L1_PSNP_AUTHENTICATION_NS,
120 "Authentication(non spec)",
121 &ett_isis_psnp_authentication,
122 dissect_l1_snp_authentication_clv
125 ISIS_CLV_L1_PSNP_AUTHENTICATION,
127 &ett_isis_psnp_authentication,
128 dissect_l1_snp_authentication_clv
135 static const isis_clv_handle_t clv_l2_psnp_opts[] = {
137 ISIS_CLV_L2_PSNP_LSP_ENTRIES,
139 &ett_isis_psnp_lsp_entries,
140 dissect_psnp_lsp_entries
143 ISIS_CLV_L2_PSNP_AUTHENTICATION,
145 &ett_isis_psnp_authentication,
146 dissect_l2_snp_authentication_clv
149 ISIS_CLV_L2_PSNP_AUTHENTICATION_NS,
150 "Authentication(non spec)",
151 &ett_isis_psnp_authentication,
152 dissect_l2_snp_authentication_clv
160 * Name: dissect_snp_lsp_entries()
163 * All the snp packets use a common payload format. We have up
164 * to n entries (based on length), which are made of:
165 * 2 : remaining life time
167 * 4 : sequence number
171 * tvbuff_t * : tvbuffer for packet data
172 * proto_tree * : protocol display tree to fill out. May be NULL
173 * int : offset into packet data where we are.
174 * int : length of payload to decode.
175 * int : length of IDs in packet.
178 * void, but we will add to proto tree if !NULL.
181 dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
182 int id_length, int length)
184 proto_tree *subtree,*ti;
186 while ( length > 0 ) {
187 if ( length < 2+id_length+2+4+2 ) {
188 isis_dissect_unknown(tvb, tree, offset,
189 "Short SNP header entry (%d vs %d)", length,
194 ti = proto_tree_add_text(tree, tvb, offset, 16,
195 "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
196 print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), id_length+2 ),
197 tvb_get_ntohl(tvb, offset+10),
198 tvb_get_ntohs(tvb, offset),
199 tvb_get_ntohs(tvb, offset+14));
201 subtree = proto_item_add_subtree(ti,ett_isis_csnp_lsp_entries);
203 proto_tree_add_text(subtree, tvb, offset+2, 8,
205 print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), id_length+2 ));
207 proto_tree_add_text(subtree, tvb, offset+10, 4,
208 "LSP Sequence Number : 0x%08x",
209 tvb_get_ntohl(tvb, offset+10));
211 proto_tree_add_text(subtree, tvb, offset, 2,
212 "Remaining Lifetime : %us",
213 tvb_get_ntohs(tvb, offset));
215 proto_tree_add_text(subtree, tvb, offset+14, 2,
216 "LSP checksum : 0x%04x",
217 tvb_get_ntohs(tvb, offset+14));
225 dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
226 int id_length, int length)
228 proto_tree *subtree,*ti;
230 while ( length > 0 ) {
231 if ( length < 2+id_length+2+4+2 ) {
232 isis_dissect_unknown(tvb, tree, offset,
233 "Short SNP header entry (%d vs %d)", length,
238 ti = proto_tree_add_text(tree, tvb, offset, 16,
239 "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
240 print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), id_length+2 ),
241 tvb_get_ntohl(tvb, offset+10),
242 tvb_get_ntohs(tvb, offset),
243 tvb_get_ntohs(tvb, offset+14));
245 subtree = proto_item_add_subtree(ti,ett_isis_psnp_lsp_entries);
247 proto_tree_add_text(subtree, tvb, offset+2, 8,
249 print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), id_length+2 ));
251 proto_tree_add_text(subtree, tvb, offset+10, 4,
252 "LSP Sequence Number : 0x%08x",
253 tvb_get_ntohl(tvb, offset+10));
255 proto_tree_add_text(subtree, tvb, offset, 2,
256 "Remaining Lifetime : %us",
257 tvb_get_ntohs(tvb, offset));
259 proto_tree_add_text(subtree, tvb, offset+14, 2,
260 "LSP checksum : 0x%04x",
261 tvb_get_ntohs(tvb, offset+14));
270 * Name: isis_dissect_isis_csnp()
273 * Tear apart a L1 or L2 CSNP header and then call into payload dissect
274 * to pull apart the lsp id payload.
277 * tvbuff_t * : tvbuffer for packet data
278 * proto_tree * : protocol display tree to add to. May be NULL.
279 * int offset : our offset into packet data.
280 * int : type (l1 csnp, l2 csnp)
281 * int : header length of packet.
282 * int : length of IDs in packet.
285 * void, but we will add to proto tree if !NULL.
288 isis_dissect_isis_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
289 int type, int header_length, int id_length)
292 proto_tree *csnp_tree = NULL;
297 ti = proto_tree_add_text(tree, tvb, offset, -1,
299 csnp_tree = proto_item_add_subtree(ti, ett_isis_csnp);
302 pdu_length = tvb_get_ntohs(tvb, offset);
304 proto_tree_add_uint(csnp_tree, hf_isis_csnp_pdu_length, tvb,
305 offset, 2, pdu_length);
310 proto_tree_add_text(csnp_tree, tvb, offset, id_length + 1,
312 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
314 if (check_col(pinfo->cinfo, COL_INFO)) {
315 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
316 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
318 offset += id_length + 1;
321 proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2,
323 print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
325 if (check_col(pinfo->cinfo, COL_INFO)) {
326 col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP-ID: %s",
327 print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
329 offset += id_length + 2;
332 proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2,
334 print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
336 if (check_col(pinfo->cinfo, COL_INFO)) {
337 col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP-ID: %s",
338 print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
340 offset += id_length + 2;
342 len = pdu_length - header_length;
346 /* Call into payload dissector */
347 if (type == ISIS_TYPE_L1_CSNP ) {
348 isis_dissect_clvs(tvb, csnp_tree, offset,
349 clv_l1_csnp_opts, len, id_length,
350 ett_isis_csnp_clv_unknown );
352 isis_dissect_clvs(tvb, csnp_tree, offset,
353 clv_l2_csnp_opts, len, id_length,
354 ett_isis_csnp_clv_unknown );
359 * Name: isis_dissect_isis_psnp()
362 * Tear apart a L1 or L2 PSNP header and then call into payload dissect
363 * to pull apart the lsp id payload.
366 * tvbuff_t * : tvbuffer for packet data
367 * proto_tree * : protocol display tree to add to. May be NULL.
368 * int : our offset into packet data
369 * int : type (l1 psnp, l2 psnp)
370 * int : header length of packet.
371 * int : length of IDs in packet.
374 * void, but we will add to proto tree if !NULL.
377 isis_dissect_isis_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
378 int type, int header_length, int id_length)
381 proto_tree *psnp_tree = NULL;
386 ti = proto_tree_add_text(tree, tvb, offset, -1,
388 psnp_tree = proto_item_add_subtree(ti, ett_isis_psnp);
391 pdu_length = tvb_get_ntohs(tvb, offset);
393 proto_tree_add_uint(psnp_tree, hf_isis_psnp_pdu_length, tvb,
394 offset, 2, pdu_length);
399 proto_tree_add_text(psnp_tree, tvb, offset, id_length + 1,
401 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length + 1 ) );
403 if (check_col(pinfo->cinfo, COL_INFO)) {
404 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
405 print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
407 offset += id_length + 1;
409 len = pdu_length - header_length;
411 isis_dissect_unknown(tvb, tree, offset,
412 "packet header length %d went beyond packet",
416 /* Call into payload dissector */
417 if (type == ISIS_TYPE_L1_CSNP ) {
418 isis_dissect_clvs(tvb, psnp_tree, offset,
419 clv_l1_csnp_opts, len, id_length,
420 ett_isis_psnp_clv_unknown );
422 isis_dissect_clvs(tvb, psnp_tree, offset,
423 clv_l2_csnp_opts, len, id_length,
424 ett_isis_psnp_clv_unknown );
429 * Name: dissect_L1_snp_authentication_clv()
432 * Decode for a lsp packets authenticaion clv. Calls into the
433 * clv common one. An auth inside a L1 SNP is a per area password
436 * tvbuff_t * : tvbuffer for packet data
437 * proto_tree * : proto tree to build on (may be null)
438 * int : current offset into packet data
439 * int : length of IDs in packet.
440 * int : length of this clv
443 * void, will modify proto_tree if not null.
446 dissect_l1_snp_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
447 int id_length _U_, int length)
449 isis_dissect_authentication_clv(tvb, tree, offset, length,
450 "Per area authentication" );
454 * Name: dissect_l2_authentication_clv()
457 * Decode for a lsp packets authenticaion clv. Calls into the
458 * clv common one. An auth inside a L2 LSP is a per domain password
461 * tvbuff_t * : tvbuffer for packet data
462 * proto_tree * : proto tree to build on (may be null)
463 * int : current offset into packet data
464 * int : length of IDs in packet.
465 * int : length of this clv
468 * void, will modify proto_tree if not null.
471 dissect_l2_snp_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
472 int id_length _U_, int length)
474 isis_dissect_authentication_clv(tvb, tree, offset, length,
475 "Per domain authentication" );
479 * Name: isis_register_csnp()
482 * Register our protocol sub-sets with protocol manager.
485 * int : protocol index for the ISIS protocol
491 isis_register_csnp(int proto_isis) {
492 static hf_register_info hf[] = {
493 { &hf_isis_csnp_pdu_length,
494 { "PDU length", "isis.csnp.pdu_length", FT_UINT16,
495 BASE_DEC, NULL, 0x0, "", HFILL }},
497 static gint *ett[] = {
499 &ett_isis_csnp_lsp_entries,
500 &ett_isis_csnp_authentication,
501 &ett_isis_csnp_clv_unknown,
504 proto_register_field_array(proto_isis, hf, array_length(hf));
505 proto_register_subtree_array(ett, array_length(ett));
510 * Name: isis_register_psnp()
513 * Register our protocol sub-sets with protocol manager.
516 * int : protocol index for the ISIS protocol
522 isis_register_psnp(int proto_isis) {
523 static hf_register_info hf[] = {
524 { &hf_isis_psnp_pdu_length,
525 { "PDU length", "isis.psnp.pdu_length", FT_UINT16,
526 BASE_DEC, NULL, 0x0, "", HFILL }},
528 static gint *ett[] = {
530 &ett_isis_psnp_lsp_entries,
531 &ett_isis_psnp_authentication,
532 &ett_isis_psnp_clv_unknown,
535 proto_register_field_array(proto_isis, hf, array_length(hf));
536 proto_register_subtree_array(ett, array_length(ett));