1999-12-15 04:34:44 +00:00
|
|
|
/* packet-isis-clv.c
|
|
|
|
* Common CLV decode routines.
|
|
|
|
*
|
2003-05-24 19:51:48 +00:00
|
|
|
* $Id: packet-isis-clv.c,v 1.26 2003/05/24 19:51:48 gerald Exp $
|
1999-12-15 04:34:44 +00:00
|
|
|
* Stuart Stanley <stuarts@mxmail.net>
|
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-06-23 19:45:12 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-15 04:34:44 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-08-11 13:37:21 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2000-04-15 22:11:26 +00:00
|
|
|
#include "packet-osi.h"
|
1999-12-15 04:34:44 +00:00
|
|
|
#include "packet-isis.h"
|
|
|
|
#include "packet-isis-clv.h"
|
2001-04-16 10:04:33 +00:00
|
|
|
#include "nlpid.h"
|
1999-12-15 04:34:44 +00:00
|
|
|
|
2002-06-29 23:03:24 +00:00
|
|
|
static void
|
|
|
|
free_g_string(void *arg)
|
|
|
|
{
|
|
|
|
g_string_free(arg, TRUE);
|
|
|
|
}
|
1999-12-15 04:34:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Name: isis_dissect_area_address_clv()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Description:
|
|
|
|
* Take an area address CLV and display it pieces. An area address
|
|
|
|
* CLV is n, x byte hex strings.
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
1999-12-15 04:34:44 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length)
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2002-06-28 22:46:36 +00:00
|
|
|
int arealen,area_idx;
|
2002-06-29 23:03:24 +00:00
|
|
|
GString *gstr;
|
1999-12-15 04:34:44 +00:00
|
|
|
|
|
|
|
while ( length > 0 ) {
|
2002-06-28 22:46:36 +00:00
|
|
|
arealen = tvb_get_guint8(tvb, offset);
|
1999-12-15 04:34:44 +00:00
|
|
|
length--;
|
|
|
|
if (length<=0) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
1999-12-15 04:34:44 +00:00
|
|
|
"short address (no length for payload)");
|
|
|
|
return;
|
|
|
|
}
|
2002-06-28 22:46:36 +00:00
|
|
|
if ( arealen > length) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
2002-06-29 23:03:24 +00:00
|
|
|
"short address, packet says %d, we have %d left",
|
2002-06-28 22:46:36 +00:00
|
|
|
arealen, length );
|
1999-12-15 04:34:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( tree ) {
|
2002-08-28 21:04:11 +00:00
|
|
|
/*
|
2002-06-29 23:03:24 +00:00
|
|
|
* Lets turn the area address into "standard"
|
|
|
|
* xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx format string.
|
|
|
|
* this is a private routine as the print_nsap_net in
|
|
|
|
* epan/osi_utils.c is incomplete and we need only
|
|
|
|
* a subset - actually some nice placing of dots ....
|
|
|
|
*
|
|
|
|
* We pick an initial size of 32 bytes.
|
|
|
|
*/
|
|
|
|
gstr = g_string_sized_new(32);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the GString if we throw an exception.
|
|
|
|
*/
|
|
|
|
CLEANUP_PUSH(free_g_string, gstr);
|
|
|
|
|
|
|
|
for (area_idx = 0; area_idx < arealen; area_idx++) {
|
|
|
|
g_string_sprintfa(gstr, "%02x",
|
|
|
|
tvb_get_guint8(tvb, offset+area_idx+1));
|
|
|
|
if (((area_idx & 1) == 0) &&
|
|
|
|
(area_idx + 1 < arealen)) {
|
|
|
|
g_string_sprintfa(gstr, ".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* and spit it out */
|
2002-08-28 21:04:11 +00:00
|
|
|
proto_tree_add_text ( tree, tvb, offset, arealen + 1,
|
2002-06-29 23:03:24 +00:00
|
|
|
"Area address (%d): %s", arealen, gstr->str );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're done with the GString, so delete it and
|
|
|
|
* get rid of the cleanup handler.
|
|
|
|
*/
|
|
|
|
CLEANUP_CALL_AND_POP;
|
1999-12-15 04:34:44 +00:00
|
|
|
}
|
2002-06-28 22:46:36 +00:00
|
|
|
offset += arealen + 1;
|
|
|
|
length -= arealen; /* length already adjusted for len fld*/
|
1999-12-15 04:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Name: isis_dissect_authentication_clv()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Description:
|
|
|
|
* Take apart the CLV that hold authentication information. This
|
|
|
|
* is currently 1 octet auth type (which must be 1) and then
|
|
|
|
* the clear text password.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* An ISIS password has different meaning depending where it
|
2002-08-28 21:04:11 +00:00
|
|
|
* is found. Thus we support a passed in prefix string to
|
1999-12-15 04:34:44 +00:00
|
|
|
* use to name this.
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
1999-12-15 04:34:44 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
1999-12-15 04:34:44 +00:00
|
|
|
* char * : Password meaning
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2003-05-24 19:51:48 +00:00
|
|
|
#define SBUF_LEN 300 /* 255 + header info area */
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_authentication_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length, char *meaning)
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2002-08-02 23:36:07 +00:00
|
|
|
guchar pw_type;
|
2003-05-24 19:51:48 +00:00
|
|
|
char sbuf[SBUF_LEN];
|
1999-12-15 04:34:44 +00:00
|
|
|
char *s = sbuf;
|
2003-05-24 19:51:48 +00:00
|
|
|
int auth_unsupported, ret;
|
1999-12-15 04:34:44 +00:00
|
|
|
|
|
|
|
if ( length <= 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-02 00:19:34 +00:00
|
|
|
pw_type = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
1999-12-15 04:34:44 +00:00
|
|
|
length--;
|
2001-06-05 21:23:32 +00:00
|
|
|
auth_unsupported = FALSE;
|
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
switch (pw_type) {
|
|
|
|
case 1:
|
2003-05-24 19:51:48 +00:00
|
|
|
ret = sprintf ( s, "clear text (1), password (length %d) = ", length );
|
|
|
|
s += ret;
|
2001-06-05 21:23:32 +00:00
|
|
|
|
|
|
|
if ( length > 0 ) {
|
2003-05-24 19:51:48 +00:00
|
|
|
strncpy(s, tvb_get_ptr(tvb, offset, length), MIN(length, SBUF_LEN - ret));
|
2001-06-05 21:23:32 +00:00
|
|
|
} else {
|
|
|
|
strcat(s, "no clear-text password found!!!" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 54:
|
|
|
|
s += sprintf ( s, "hmac-md5 (54), password (length %d) = ", length );
|
|
|
|
|
|
|
|
if ( length == 16 ) {
|
2001-07-02 00:19:34 +00:00
|
|
|
s += sprintf ( s, "0x%02x", tvb_get_guint8(tvb, offset) );
|
|
|
|
offset += 1;
|
2001-06-05 21:23:32 +00:00
|
|
|
length--;
|
|
|
|
while (length > 0) {
|
2001-07-02 00:19:34 +00:00
|
|
|
s += sprintf ( s, "%02x", tvb_get_guint8(tvb, offset) );
|
|
|
|
offset += 1;
|
2001-06-05 21:23:32 +00:00
|
|
|
length--;
|
|
|
|
}
|
|
|
|
s = 0;
|
|
|
|
} else {
|
|
|
|
strcat(s, "illegal hmac-md5 digest format (must be 16 bytes)" );
|
|
|
|
}
|
1999-12-15 04:34:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
2003-05-24 19:51:48 +00:00
|
|
|
sprintf (sbuf, "type 0x%02x (0x%02x): ", pw_type, length );
|
2001-06-05 21:23:32 +00:00
|
|
|
auth_unsupported=TRUE;
|
1999-12-15 04:34:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-05-24 19:51:48 +00:00
|
|
|
sbuf[SBUF_LEN] = '\0';
|
2001-07-02 00:19:34 +00:00
|
|
|
proto_tree_add_text ( tree, tvb, offset - 1, length + 1,
|
1999-12-15 04:34:44 +00:00
|
|
|
"%s %s", meaning, sbuf );
|
2001-06-05 21:23:32 +00:00
|
|
|
|
|
|
|
if ( auth_unsupported ) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
2001-06-05 21:23:32 +00:00
|
|
|
"Unknown authentication type" );
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-08 19:32:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Name: isis_dissect_hostname_clv()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* dump the hostname information found in TLV 137
|
|
|
|
* pls note that the hostname is not null terminated
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
2001-04-08 19:32:05 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
2001-04-08 19:32:05 +00:00
|
|
|
*
|
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_hostname_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length)
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2001-04-08 19:32:05 +00:00
|
|
|
if ( !tree ) return; /* nothing to do! */
|
|
|
|
|
2001-07-02 00:19:34 +00:00
|
|
|
if ( length == 0 ) {
|
|
|
|
proto_tree_add_text ( tree, tvb, offset, length,
|
|
|
|
"Hostname: --none--" );
|
|
|
|
} else {
|
|
|
|
proto_tree_add_text ( tree, tvb, offset, length,
|
|
|
|
"Hostname: %.*s", length,
|
|
|
|
tvb_get_ptr(tvb, offset, length) );
|
2001-04-08 19:32:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_mt_clv(tvbuff_t *tvb, proto_tree *tree, int offset, int length,
|
|
|
|
int tree_id)
|
2002-08-28 21:04:11 +00:00
|
|
|
{
|
2002-04-07 23:39:00 +00:00
|
|
|
guint16 mt_block;
|
|
|
|
char mt_desc[60];
|
2001-06-23 19:45:12 +00:00
|
|
|
|
2002-04-07 23:39:00 +00:00
|
|
|
while (length>0) {
|
2002-08-28 21:04:11 +00:00
|
|
|
/* length can only be a multiple of 2, otherwise there is
|
2002-04-07 23:39:00 +00:00
|
|
|
something broken -> so decode down until length is 1 */
|
|
|
|
if (length!=1) {
|
|
|
|
/* fetch two bytes */
|
|
|
|
mt_block=tvb_get_ntohs(tvb, offset);
|
2001-06-23 19:45:12 +00:00
|
|
|
|
2002-04-07 23:39:00 +00:00
|
|
|
/* mask out the lower 12 bits */
|
|
|
|
switch(mt_block&0x0fff) {
|
|
|
|
case 0:
|
|
|
|
strcpy(mt_desc,"IPv4 unicast");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
strcpy(mt_desc,"In-Band Management");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
strcpy(mt_desc,"IPv6 unicast");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
strcpy(mt_desc,"Multicast");
|
|
|
|
break;
|
|
|
|
case 4095:
|
|
|
|
strcpy(mt_desc,"Development, Experimental or Proprietary");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
strcpy(mt_desc,"Reserved for IETF Consensus");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
proto_tree_add_uint_format ( tree, tree_id, tvb, offset, 2,
|
|
|
|
mt_block,
|
|
|
|
"%s Topology (0x%03x)%s%s",
|
2001-06-23 19:45:12 +00:00
|
|
|
mt_desc,
|
|
|
|
mt_block&0xfff,
|
|
|
|
(mt_block&0x8000) ? "" : ", no sub-TLVs present",
|
|
|
|
(mt_block&0x4000) ? ", ATT bit set" : "" );
|
2002-04-07 23:39:00 +00:00
|
|
|
} else {
|
|
|
|
proto_tree_add_text ( tree, tvb, offset, 1,
|
|
|
|
"malformed MT-ID");
|
|
|
|
break;
|
2001-06-23 19:45:12 +00:00
|
|
|
}
|
2002-04-07 23:39:00 +00:00
|
|
|
length=length-2;
|
|
|
|
offset=offset+2;
|
2001-06-23 19:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-08 19:32:05 +00:00
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
/*
|
|
|
|
* Name: isis_dissect_ip_int_clv()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Description:
|
|
|
|
* Take apart the CLV that lists all the IP interfaces. The
|
|
|
|
* meaning of which is slightly different for the different base packet
|
|
|
|
* types, but the display is not different. What we have is n ip
|
|
|
|
* addresses, plain and simple.
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
1999-12-15 04:34:44 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
|
|
|
* int : tree id to use for proto tree.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_ip_int_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length, int tree_id)
|
2001-07-02 00:19:34 +00:00
|
|
|
{
|
1999-12-15 04:34:44 +00:00
|
|
|
if ( length <= 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( length > 0 ) {
|
|
|
|
if ( length < 4 ) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
2002-06-28 22:46:36 +00:00
|
|
|
"Short IP interface address (%d vs 4)",length );
|
1999-12-15 04:34:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-07-02 00:19:34 +00:00
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
if ( tree ) {
|
2002-04-02 01:25:08 +00:00
|
|
|
proto_tree_add_item(tree, tree_id, tvb, offset, 4, FALSE);
|
1999-12-15 04:34:44 +00:00
|
|
|
}
|
|
|
|
offset += 4;
|
|
|
|
length -= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-14 18:40:17 +00:00
|
|
|
/*
|
|
|
|
* Name: isis_dissect_ipv6_int_clv()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-05-14 18:40:17 +00:00
|
|
|
* Description:
|
|
|
|
* Take apart the CLV that lists all the IPv6 interfaces. The
|
|
|
|
* meaning of which is slightly different for the different base packet
|
|
|
|
* types, but the display is not different. What we have is n ip
|
|
|
|
* addresses, plain and simple.
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
2001-05-14 18:40:17 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
|
|
|
* int : tree id to use for proto tree.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2001-05-14 18:40:17 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_ipv6_int_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length, int tree_id)
|
2001-07-02 00:19:34 +00:00
|
|
|
{
|
2001-05-14 18:40:17 +00:00
|
|
|
guint8 addr [16];
|
|
|
|
|
|
|
|
if ( length <= 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( length > 0 ) {
|
|
|
|
if ( length < 16 ) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
2001-05-14 18:40:17 +00:00
|
|
|
"Short IPv6 interface address (%d vs 16)",length );
|
|
|
|
return;
|
|
|
|
}
|
2001-07-02 00:19:34 +00:00
|
|
|
tvb_memcpy(tvb, addr, offset, sizeof(addr));
|
2001-05-14 18:40:17 +00:00
|
|
|
if ( tree ) {
|
2001-07-02 00:19:34 +00:00
|
|
|
proto_tree_add_ipv6(tree, tree_id, tvb, offset, 16, addr);
|
2001-05-14 18:40:17 +00:00
|
|
|
}
|
|
|
|
offset += 16;
|
|
|
|
length -= 16;
|
|
|
|
}
|
|
|
|
}
|
2001-04-16 10:04:33 +00:00
|
|
|
|
2001-07-02 00:19:34 +00:00
|
|
|
|
2001-04-16 10:04:33 +00:00
|
|
|
/*
|
|
|
|
* Name: isis_dissect_te_router_id_clv()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Display the Traffic Engineering Router ID TLV #134.
|
|
|
|
* This TLV is like the IP Interface TLV, except that
|
|
|
|
* only _one_ IP address is present
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
2001-04-16 10:04:33 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
|
|
|
* int : tree id to use for proto tree.
|
2001-04-16 10:04:33 +00:00
|
|
|
*
|
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_te_router_id_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
int length, int tree_id)
|
2001-07-02 00:19:34 +00:00
|
|
|
{
|
2001-04-16 10:04:33 +00:00
|
|
|
if ( length <= 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( length != 4 ) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
2001-04-16 10:04:33 +00:00
|
|
|
"malformed Traffic Engineering Router ID (%d vs 4)",length );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( tree ) {
|
2002-04-02 01:25:08 +00:00
|
|
|
proto_tree_add_item(tree, tree_id, tvb, offset, 4, FALSE);
|
2001-04-16 10:04:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
/*
|
|
|
|
* Name: isis_dissect_nlpid_clv()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Description:
|
|
|
|
* Take apart a NLPID packet and display it. The NLPID (for intergrated
|
|
|
|
* ISIS, contains n network layer protocol IDs that the box supports.
|
|
|
|
* Our display buffer we use is upto 255 entries, 6 bytes per (0x00, )
|
|
|
|
* plus 1 for zero termination. We just just 256*6 for simplicity.
|
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
1999-12-15 04:34:44 +00:00
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : offset into packet data where we are.
|
|
|
|
* int : length of clv we are decoding
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_nlpid_clv(tvbuff_t *tvb, proto_tree *tree, int offset, int length)
|
2001-07-02 00:19:34 +00:00
|
|
|
{
|
1999-12-15 04:34:44 +00:00
|
|
|
char sbuf[256*6];
|
|
|
|
char *s = sbuf;
|
|
|
|
int hlen = length;
|
|
|
|
int old_offset = offset;
|
|
|
|
|
|
|
|
if ( !tree ) return; /* nothing to do! */
|
|
|
|
|
|
|
|
while ( length-- > 0 ) {
|
|
|
|
if (s != sbuf ) {
|
2002-08-28 21:04:11 +00:00
|
|
|
s += sprintf ( s, ", " );
|
2001-04-16 10:04:33 +00:00
|
|
|
}
|
|
|
|
s += sprintf ( s, "%s (0x%02x)",
|
2002-08-28 21:04:11 +00:00
|
|
|
val_to_str(tvb_get_guint8(tvb, offset), nlpid_vals,
|
2001-07-02 00:19:34 +00:00
|
|
|
"Unknown"), tvb_get_guint8(tvb, offset));
|
2002-08-28 21:04:11 +00:00
|
|
|
offset++;
|
1999-12-15 04:34:44 +00:00
|
|
|
}
|
2001-04-16 10:04:33 +00:00
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
if ( hlen == 0 ) {
|
|
|
|
sprintf ( sbuf, "--none--" );
|
|
|
|
}
|
|
|
|
|
2001-07-02 00:19:34 +00:00
|
|
|
proto_tree_add_text ( tree, tvb, old_offset, hlen,
|
2001-04-16 10:04:33 +00:00
|
|
|
"NLPID(s): %s", sbuf );
|
1999-12-15 04:34:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Name: isis_dissect_clvs()
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Description:
|
|
|
|
* Dispatch routine to shred all the CLVs in a packet. We just
|
|
|
|
* walk through the clv entries in the packet. For each one, we
|
|
|
|
* search the passed in valid clv's for this protocol (opts) for
|
|
|
|
* a matching code. If found, we add to the display tree and
|
|
|
|
* then call the dissector. If it is not, we just post an
|
2002-04-07 22:36:55 +00:00
|
|
|
* "unknown" clv entry using the passed in unknown clv tree id.
|
1999-12-15 04:34:44 +00:00
|
|
|
*
|
|
|
|
* Input:
|
2001-07-02 00:19:34 +00:00
|
|
|
* tvbuff_t * : tvbuffer for packet data
|
|
|
|
* proto_tree * : protocol display tree to fill out. May be NULL
|
|
|
|
* int : offset into packet data where we are.
|
1999-12-15 04:34:44 +00:00
|
|
|
* isis_clv_handle_t * : NULL dissector terminated array of codes
|
|
|
|
* and handlers (along with tree text and tree id's).
|
|
|
|
* int : length of CLV area.
|
2001-07-02 00:19:34 +00:00
|
|
|
* int : length of IDs in packet.
|
|
|
|
* int : unknown clv tree id
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-15 04:34:44 +00:00
|
|
|
* Output:
|
|
|
|
* void, but we will add to proto tree if !NULL.
|
|
|
|
*/
|
2002-08-28 21:04:11 +00:00
|
|
|
void
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|
|
|
const isis_clv_handle_t *opts, int len, int id_length,
|
2001-07-02 00:19:34 +00:00
|
|
|
int unknown_tree_id)
|
|
|
|
{
|
1999-12-15 04:34:44 +00:00
|
|
|
guint8 code;
|
|
|
|
guint8 length;
|
|
|
|
int q;
|
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *clv_tree;
|
|
|
|
int adj;
|
|
|
|
|
|
|
|
while ( len > 0 ) {
|
2001-07-02 00:19:34 +00:00
|
|
|
code = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
length = tvb_get_guint8(tvb, offset);
|
|
|
|
offset += 1;
|
|
|
|
|
1999-12-15 04:34:44 +00:00
|
|
|
adj = (sizeof(code) + sizeof(length) + length);
|
|
|
|
len -= adj;
|
2001-07-02 00:19:34 +00:00
|
|
|
if ( len < 0 ) {
|
2002-04-07 22:36:55 +00:00
|
|
|
isis_dissect_unknown(tvb, tree, offset,
|
1999-12-15 04:34:44 +00:00
|
|
|
"Short CLV header (%d vs %d)",
|
|
|
|
adj, len + adj );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
q = 0;
|
|
|
|
while ((opts[q].dissect != NULL )&&( opts[q].optcode != code )){
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
if ( opts[q].dissect ) {
|
|
|
|
if (tree) {
|
|
|
|
/* adjust by 2 for code/len octets */
|
2002-08-28 21:04:11 +00:00
|
|
|
ti = proto_tree_add_text(tree, tvb, offset - 2,
|
2003-04-02 08:31:37 +00:00
|
|
|
length + 2, "%s (%u)",
|
|
|
|
opts[q].tree_text, length );
|
2002-08-28 21:04:11 +00:00
|
|
|
clv_tree = proto_item_add_subtree(ti,
|
1999-12-15 04:34:44 +00:00
|
|
|
*opts[q].tree_id );
|
|
|
|
} else {
|
|
|
|
clv_tree = NULL;
|
|
|
|
}
|
2002-04-07 22:36:55 +00:00
|
|
|
opts[q].dissect(tvb, clv_tree, offset,
|
2001-07-02 00:19:34 +00:00
|
|
|
id_length, length);
|
1999-12-15 04:34:44 +00:00
|
|
|
} else {
|
2002-08-28 21:04:11 +00:00
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_text(tree, tvb, offset - 2,
|
2003-04-02 08:31:37 +00:00
|
|
|
length + 2, "Unknown code %u (%u)",
|
|
|
|
code, length);
|
2002-08-28 21:04:11 +00:00
|
|
|
clv_tree = proto_item_add_subtree(ti,
|
1999-12-15 04:34:44 +00:00
|
|
|
unknown_tree_id );
|
2002-08-28 21:04:11 +00:00
|
|
|
} else {
|
1999-12-15 04:34:44 +00:00
|
|
|
clv_tree = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
offset += length;
|
|
|
|
}
|
|
|
|
}
|