diff options
-rw-r--r-- | packet-isis-clv.c | 7 | ||||
-rw-r--r-- | packet-isis-clv.h | 8 | ||||
-rw-r--r-- | packet-isis-hello.c | 140 | ||||
-rw-r--r-- | packet-isis-hello.h | 24 | ||||
-rw-r--r-- | packet-isis-lsp.c | 201 | ||||
-rw-r--r-- | packet-isis-lsp.h | 30 | ||||
-rw-r--r-- | packet-isis-snp.c | 166 | ||||
-rw-r--r-- | packet-isis-snp.h | 36 | ||||
-rw-r--r-- | packet-isis.c | 42 |
9 files changed, 353 insertions, 301 deletions
diff --git a/packet-isis-clv.c b/packet-isis-clv.c index 7de64f88b6..a7b4b50161 100644 --- a/packet-isis-clv.c +++ b/packet-isis-clv.c @@ -1,7 +1,7 @@ /* packet-isis-clv.c * Common CLV decode routines. * - * $Id: packet-isis-clv.c,v 1.5 2000/05/31 05:07:12 guy Exp $ + * $Id: packet-isis-clv.c,v 1.6 2000/06/19 08:33:47 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -288,7 +288,7 @@ isis_dissect_nlpid_clv(const u_char *pd, int offset, * void, but we will add to proto tree if !NULL. */ void -isis_dissect_clvs(const isis_clv_handle_t *opts, int len, +isis_dissect_clvs(const isis_clv_handle_t *opts, int len, int id_length, const u_char *pd, int offset, frame_data *fd, proto_tree *tree, gint unknown_tree_id ) { guint8 code; @@ -326,7 +326,8 @@ isis_dissect_clvs(const isis_clv_handle_t *opts, int len, } else { clv_tree = NULL; } - opts[q].dissect(pd, offset, length, fd, clv_tree ); + opts[q].dissect(pd, offset, length, id_length, fd, + clv_tree ); } else { if (tree) { snprintf ( sbuf, sizeof(sbuf), diff --git a/packet-isis-clv.h b/packet-isis-clv.h index a604364f2f..44873af48e 100644 --- a/packet-isis-clv.h +++ b/packet-isis-clv.h @@ -1,7 +1,7 @@ /* packet-isis-clv.h * Declares for common clv decoding functions. * - * $Id: packet-isis-clv.h,v 1.1 1999/12/15 04:34:17 guy Exp $ + * $Id: packet-isis-clv.h,v 1.2 2000/06/19 08:33:48 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -36,7 +36,7 @@ typedef struct { char *tree_text; /* text for fold out */ gint *tree_id; /* id for add_item */ void (*dissect)(const u_char *pd, int offset, guint length, - frame_data *fd, proto_tree *tree ); + int id_length, frame_data *fd, proto_tree *tree ); } isis_clv_handle_t; /* @@ -44,8 +44,8 @@ typedef struct { * are only valid from with isis decodes. */ extern void isis_dissect_clvs(const isis_clv_handle_t *opts, int len, - const u_char *pd, int offset, frame_data *fd, proto_tree *tree, - int unknown_ett_handle ); + int id_length, const u_char *pd, int offset, frame_data *fd, + proto_tree *tree, int unknown_ett_handle ); extern void isis_dissect_area_address_clv(const u_char *pd, int offset, guint length, frame_data *fd, proto_tree *tree ); extern void isis_dissect_metric(proto_tree *tree, int offset, guint8 value, diff --git a/packet-isis-hello.c b/packet-isis-hello.c index 9f5c96e139..a268f2db2c 100644 --- a/packet-isis-hello.c +++ b/packet-isis-hello.c @@ -1,7 +1,7 @@ /* packet-isis-hello.c * Routines for decoding isis hello packets and their CLVs * - * $Id: packet-isis-hello.c,v 1.8 2000/05/31 05:07:12 guy Exp $ + * $Id: packet-isis-hello.c,v 1.9 2000/06/19 08:33:48 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -74,17 +74,17 @@ static const value_string isis_hello_circuit_type_vals[] = { * Predclare dissectors for use in clv dissection. */ static void dissect_hello_area_address_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_hello_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_hello_padding_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_hello_nlpid_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_hello_ip_int_addr_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_hello_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static const isis_clv_handle_t clv_l1_hello_opts[] = { { @@ -244,6 +244,7 @@ static const isis_clv_handle_t clv_ptp_hello_opts[] = { * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -252,7 +253,7 @@ static const isis_clv_handle_t clv_ptp_hello_opts[] = { */ static void dissect_hello_nlpid_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_nlpid_clv(pd, offset, length, fd, tree ); } @@ -267,6 +268,7 @@ dissect_hello_nlpid_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -275,7 +277,7 @@ dissect_hello_nlpid_clv(const u_char *pd, int offset, */ static void dissect_hello_ip_int_addr_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_ip_int_clv(pd, offset, length, fd, tree, hf_isis_hello_clv_ipv4_int_addr ); } @@ -292,6 +294,7 @@ dissect_hello_ip_int_addr_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -300,7 +303,7 @@ dissect_hello_ip_int_addr_clv(const u_char *pd, int offset, */ static void dissect_hello_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_authentication_clv(pd, offset, length, fd, tree, "Per Link authentication" ); } @@ -316,6 +319,7 @@ dissect_hello_auth_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -324,7 +328,7 @@ dissect_hello_auth_clv(const u_char *pd, int offset, */ static void dissect_hello_area_address_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_area_address_clv(pd, offset, length, fd, tree ); } @@ -339,6 +343,7 @@ dissect_hello_area_address_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * gint : tree id to use for proto tree. @@ -348,7 +353,7 @@ dissect_hello_area_address_clv(const u_char *pd, int offset, */ void dissect_hello_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree ) { + guint length, int id_length, frame_data *fd, proto_tree *tree ) { while ( length > 0 ) { if (length<6) { isis_dissect_unknown(offset, length, tree, fd, @@ -380,6 +385,7 @@ dissect_hello_is_neighbors_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -388,7 +394,7 @@ dissect_hello_is_neighbors_clv(const u_char *pd, int offset, */ static void dissect_hello_padding_clv(const u_char *pd, int offset, guint length, - frame_data *fd, proto_tree *tree) { + int id_length, frame_data *fd, proto_tree *tree) { /* nothing to do here! */ } @@ -397,12 +403,13 @@ dissect_hello_padding_clv(const u_char *pd, int offset, guint length, * * Description: * This procedure rips apart the various types of ISIS hellos. L1H and - * L2H's are identicle for the most part, while the PTP hello has + * L2H's are identical for the most part, while the PTP hello has * a shorter header. * * Input: - * int : hello type, alla packet-isis.h ISIS_TYPE_* values + * int : hello type, a la packet-isis.h ISIS_TYPE_* values * int : header length of packet. + * int : length of IDs in packet. * u_char * : packet data * int offset : our offset into packet data. * frame_data * : frame data @@ -412,18 +419,18 @@ dissect_hello_padding_clv(const u_char *pd, int offset, guint length, * void, will modify proto_tree if not NULL. */ void -isis_dissect_isis_hello(int hello_type, int header_length, +isis_dissect_isis_hello(int hello_type, int header_length, int id_length, const u_char *pd, int offset, frame_data *fd, proto_tree *tree){ - isis_hello_t *ihp; proto_item *ti; proto_tree *hello_tree = NULL; int len; int hlen; + guint16 pdu_length; if (hello_type == ISIS_TYPE_PTP_HELLO) { - hlen = sizeof(*ihp) - 6; /* make length correct */ + hlen = 1+id_length+2+2+1; } else { - hlen = sizeof(*ihp); + hlen = 1+id_length+2+2+1+id_length+1; } if (!BYTES_ARE_IN_FRAME(offset, hlen)) { @@ -433,47 +440,69 @@ isis_dissect_isis_hello(int hello_type, int header_length, return; } - ihp = (isis_hello_t *) &pd[offset]; - if (tree) { ti = proto_tree_add_item(tree, proto_isis_hello, NullTVB, offset, END_OF_FRAME, FALSE); hello_tree = proto_item_add_subtree(ti, ett_isis_hello); - proto_tree_add_uint_format(hello_tree, + proto_tree_add_uint_format(hello_tree, hf_isis_hello_circuit_reserved, - NullTVB, offset, 1, ihp->isis_hello_circuit_reserved, + NullTVB, offset, 1, pd[offset], "Circuit type : %s, reserved(0x%02x == 0)", - val_to_str(ihp->isis_hello_circuit, + val_to_str(pd[offset]&ISIS_HELLO_CTYPE_MASK, isis_hello_circuit_type_vals, "Unknown (0x%x)"), - ihp->isis_hello_creserved + pd[offset]&ISIS_HELLO_CT_RESERVED_MASK ); + } + offset += 1; - proto_tree_add_string_format(hello_tree, hf_isis_hello_lan_id, NullTVB, - offset + 1, 6, ihp->isis_hello_source_id, + if (tree) { + proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, NullTVB, + offset, id_length, &pd[offset], "SystemID{ Sender of PDU } : %s", - print_system_id( pd + offset + 1, 6 ) ); + print_system_id( pd + offset, id_length ) ); + } + offset += id_length; + + if (tree) { proto_tree_add_uint(hello_tree, hf_isis_hello_holding_timer, NullTVB, - offset + 7, 2,pntohs(&ihp->isis_hello_holding_timer[0])); + offset, 2, pntohs(&pd[offset])); + } + offset += 2; + + pdu_length = pntohs(&pd[offset]); + if (tree) { proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, NullTVB, - offset + 9, 2,pntohs(&ihp->isis_hello_pdu_length[0])); + offset, 2, pdu_length); + } + offset += 2; + + if (tree) { proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, NullTVB, - offset + 11, 1, ihp->isis_hello_priority_reserved, + offset, 1, pd[offset], "Priority : %d, reserved(0x%02x == 0)", - ihp->isis_hello_priority, ihp->isis_hello_preserved ); - if (hello_type == ISIS_TYPE_PTP_HELLO) { + pd[offset]&ISIS_HELLO_PRIORITY_MASK, + pd[offset]&ISIS_HELLO_P_RESERVED_MASK ); + } + offset += 1; + + if (hello_type == ISIS_TYPE_PTP_HELLO) { + if (tree) { proto_tree_add_uint(hello_tree, hf_isis_hello_local_circuit_id, NullTVB, - offset + 12, 1, ihp->isis_hello_lan_id[0] ); - } else { - proto_tree_add_string_format(hello_tree, hf_isis_hello_lan_id, NullTVB, - offset + 12, 7, ihp->isis_hello_lan_id, + offset, 1, pd[offset] ); + } + offset += 1; + } else { + if (tree) { + proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, NullTVB, + offset, id_length + 1, &pd[offset], "SystemID{ Designated IS } : %s", - print_system_id( pd + offset + 12, 7 ) ); + print_system_id( pd + offset, id_length + 1 ) ); } + offset += id_length + 1; } - offset += hlen; - len = pntohs(&ihp->isis_hello_pdu_length[0]); + len = pdu_length; len -= header_length; if (len < 0) { isis_dissect_unknown(offset, header_length, tree, fd, @@ -486,14 +515,14 @@ isis_dissect_isis_hello(int hello_type, int header_length, * our list of valid ones! */ if (hello_type == ISIS_TYPE_L1_HELLO){ - isis_dissect_clvs ( clv_l1_hello_opts, len, pd, offset, fd, - hello_tree, ett_isis_hello_clv_unknown ); + isis_dissect_clvs ( clv_l1_hello_opts, len, id_length, pd, + offset, fd, hello_tree, ett_isis_hello_clv_unknown ); } else if (hello_type == ISIS_TYPE_L2_HELLO) { - isis_dissect_clvs ( clv_l2_hello_opts, len, pd, offset, fd, - hello_tree, ett_isis_hello_clv_unknown ); + isis_dissect_clvs ( clv_l2_hello_opts, len, id_length, pd, + offset, fd, hello_tree, ett_isis_hello_clv_unknown ); } else { - isis_dissect_clvs ( clv_ptp_hello_opts, len, pd, offset, fd, - hello_tree, ett_isis_hello_clv_unknown ); + isis_dissect_clvs ( clv_ptp_hello_opts, len, id_length, pd, + offset, fd, hello_tree, ett_isis_hello_clv_unknown ); } } @@ -520,7 +549,7 @@ proto_register_isis_hello(void) { { &hf_isis_hello_source_id, { "SystemID{ Sender of PDU } ", "isis_hello.source_id", - FT_ETHER, BASE_HEX, NULL, 0x0, "" }}, + FT_BYTES, BASE_HEX, NULL, 0x0, "" }}, { &hf_isis_hello_holding_timer, { "Holding timer ", "isis_hello.holding_timer", @@ -531,20 +560,20 @@ proto_register_isis_hello(void) { FT_UINT16, BASE_DEC, NULL, 0x0, "" }}, { &hf_isis_hello_priority_reserved, - { "Priority ", "isis_hello.priority",FT_UINT8, BASE_DEC, NULL, - ISIS_HELLO_P_RESERVED_MASK, "" }}, + { "Priority ", "isis_hello.priority", + FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_P_RESERVED_MASK, "" }}, { &hf_isis_hello_lan_id, - { "SystemID{ Designated IS } ", "isis_hello.lan_id", FT_STRING, BASE_DEC, NULL, - 0x0, "" }}, + { "SystemID{ Designated IS } ", "isis_hello.lan_id", + FT_BYTES, BASE_DEC, NULL, 0x0, "" }}, { &hf_isis_hello_local_circuit_id, - { "Local circuit ID ", "isis_hello.local_circuit_id", FT_UINT8, - BASE_DEC, NULL, 0x0, "" }}, + { "Local circuit ID ", "isis_hello.local_circuit_id", + FT_UINT8, BASE_DEC, NULL, 0x0, "" }}, { &hf_isis_hello_clv_ipv4_int_addr, - { "IPv4 interface address ", "isis_hello.clv_ipv4_int_addr", FT_IPv4, - BASE_NONE, NULL, 0x0, "" }}, + { "IPv4 interface address ", "isis_hello.clv_ipv4_int_addr", + FT_IPv4, BASE_NONE, NULL, 0x0, "" }}, }; static gint *ett[] = { @@ -562,4 +591,3 @@ proto_register_isis_hello(void) { proto_register_field_array(proto_isis_hello, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } - diff --git a/packet-isis-hello.h b/packet-isis-hello.h index 9fa0099253..d1cfd2999b 100644 --- a/packet-isis-hello.h +++ b/packet-isis-hello.h @@ -1,7 +1,7 @@ /* packet-isis-hello.h * Declares for hello handling inside isis. * - * $Id: packet-isis-hello.h,v 1.1 1999/12/15 04:34:18 guy Exp $ + * $Id: packet-isis-hello.h,v 1.2 2000/06/19 08:33:48 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -30,29 +30,12 @@ #define _PACKET_ISIS_HELLO_H /* - * Declare L1/L2 hello base header. + * Declarations for L1/L2 hello base header. */ -typedef struct { - guint8 isis_hello_circuit_reserved; /* circuit type & reserved */ #define ISIS_HELLO_CTYPE_MASK 0x03 #define ISIS_HELLO_CT_RESERVED_MASK 0xfc - guint8 isis_hello_source_id[6]; /* source id */ - guint8 isis_hello_holding_timer[2]; /* holding timer */ - guint8 isis_hello_pdu_length[2]; /* full length, including hdr */ - guint8 isis_hello_priority_reserved; /* priority & reserved */ #define ISIS_HELLO_PRIORITY_MASK 0x7f #define ISIS_HELLO_P_RESERVED_MASK 0x80 - guint8 isis_hello_lan_id[7]; /* LAN id */ -} isis_hello_t; - -#define isis_hello_circuit isis_hello_circuit_reserved&ISIS_HELLO_CTYPE_MASK -#define isis_hello_creserved \ - isis_hello_circuit_reserved&ISIS_HELLO_CT_RESERVED_MASK - -#define isis_hello_priority \ - isis_hello_priority_reserved&ISIS_HELLO_PRIORITY_MASK -#define isis_hello_preserved \ - isis_hello_priority_reserved&ISIS_HELLO_P_RESERVED_MASK #define ISIS_HELLO_TYPE_RESERVED 0 #define ISIS_HELLO_TYPE_LEVEL_1 1 @@ -108,5 +91,6 @@ typedef struct { * are only valid from with isis decodes. */ extern void isis_dissect_isis_hello(int hello_type, int header_length, - const u_char *pd, int offset, frame_data *fd, proto_tree *tree); + int id_length, const u_char *pd, int offset, frame_data *fd, + proto_tree *tree); #endif /* _PACKET_ISIS_HELLO_H */ diff --git a/packet-isis-lsp.c b/packet-isis-lsp.c index 5148dcc8c1..2d14613276 100644 --- a/packet-isis-lsp.c +++ b/packet-isis-lsp.c @@ -1,7 +1,7 @@ /* packet-isis-lsp.c * Routines for decoding isis lsp packets and their CLVs * - * $Id: packet-isis-lsp.c,v 1.7 2000/05/31 05:07:12 guy Exp $ + * $Id: packet-isis-lsp.c,v 1.8 2000/06/19 08:33:48 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -82,27 +82,27 @@ static const value_string isis_lsp_istype_vals[] = { * Predclare dissectors for use in clv dissection. */ static void dissect_lsp_area_address_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_l1_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_l1_es_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_l2_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_partition_dis_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_prefix_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_ip_reachability_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_nlpid_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_ip_int_addr_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_l1_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static void dissect_lsp_l2_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree); + guint length, int id_length, frame_data *fd, proto_tree *tree); static const isis_clv_handle_t clv_l1_lsp_opts[] = { { @@ -289,6 +289,7 @@ dissect_metric(proto_tree *tree, int offset, guint8 value, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -297,7 +298,7 @@ dissect_metric(proto_tree *tree, int offset, guint8 value, */ static void dissect_lsp_ip_reachability_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { proto_item *ti; proto_tree *ntree = NULL; guint32 src, mask; @@ -344,6 +345,7 @@ dissect_lsp_ip_reachability_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -352,7 +354,7 @@ dissect_lsp_ip_reachability_clv(const u_char *pd, int offset, */ static void dissect_lsp_nlpid_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_nlpid_clv(pd, offset, length, fd, tree ); } @@ -367,6 +369,7 @@ dissect_lsp_nlpid_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -375,7 +378,7 @@ dissect_lsp_nlpid_clv(const u_char *pd, int offset, */ static void dissect_lsp_ip_int_addr_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_ip_int_clv(pd, offset, length, fd, tree, hf_isis_lsp_clv_ipv4_int_addr ); } @@ -391,6 +394,7 @@ dissect_lsp_ip_int_addr_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -399,7 +403,7 @@ dissect_lsp_ip_int_addr_clv(const u_char *pd, int offset, */ static void dissect_lsp_l1_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_authentication_clv(pd, offset, length, fd, tree, "Per area authentication" ); } @@ -415,6 +419,7 @@ dissect_lsp_l1_auth_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -423,7 +428,7 @@ dissect_lsp_l1_auth_clv(const u_char *pd, int offset, */ static void dissect_lsp_l2_auth_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_authentication_clv(pd, offset, length, fd, tree, "Per domain authentication" ); } @@ -439,6 +444,7 @@ dissect_lsp_l2_auth_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -447,7 +453,7 @@ dissect_lsp_l2_auth_clv(const u_char *pd, int offset, */ static void dissect_lsp_area_address_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_area_address_clv(pd, offset, length, fd, tree ); } @@ -467,6 +473,7 @@ dissect_lsp_area_address_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * int : set to decode first octet as virtual vs reserved == 0 @@ -477,16 +484,14 @@ dissect_lsp_area_address_clv(const u_char *pd, int offset, */ static void dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree, + guint length, int id_length, frame_data *fd, proto_tree *tree, int show_virtual, int is_eis) { proto_item *ti; proto_tree *ntree = NULL; int tlen; - if (is_eis) { - tlen = 10; - } else { - tlen = 11; + if (!is_eis) { + id_length++; /* IDs are one octet longer in IS neighbours */ if ( tree ) { if ( show_virtual ) { /* virtual path flag */ @@ -500,8 +505,8 @@ dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, } offset++; length--; - } + tlen = 4 + id_length; while ( length > 0 ) { if (length<tlen) { @@ -515,13 +520,13 @@ dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, */ if ( tree ) { if ( is_eis ) { - ti = proto_tree_add_text ( tree, NullTVB, offset, 11, + ti = proto_tree_add_text ( tree, NullTVB, offset, tlen, "ES Neighbor: %s", - print_system_id( pd + offset + 4, 6 ) ); + print_system_id( pd + offset + 4, id_length ) ); } else { - ti = proto_tree_add_text ( tree, NullTVB, offset, 11, + ti = proto_tree_add_text ( tree, NullTVB, offset, tlen, "IS Neighbor: %s", - print_system_id( pd + offset + 4, 6 ) ); + print_system_id( pd + offset + 4, id_length ) ); } ntree = proto_item_add_subtree(ti, ett_isis_lsp_clv_is_neighbors); @@ -533,6 +538,9 @@ dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, "Expense",FALSE ); dissect_metric ( ntree, offset + 3, pd[offset+3], "Error", FALSE ); + proto_tree_add_text ( ntree, NullTVB, offset + 4, id_length, + "Neighbour ID: %s", + print_system_id( pd + offset + 4, id_length ) ); } offset += tlen; length -= tlen; @@ -550,6 +558,7 @@ dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -558,9 +567,9 @@ dissect_lsp_eis_neighbors_clv_inner(const u_char *pd, int offset, */ static void dissect_lsp_l1_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { - dissect_lsp_eis_neighbors_clv_inner( pd, offset, length, fd, tree,TRUE, - FALSE ); + guint length, int id_length, frame_data *fd, proto_tree *tree) { + dissect_lsp_eis_neighbors_clv_inner( pd, offset, length, id_length, + fd, tree, TRUE, FALSE ); } /* @@ -574,6 +583,7 @@ dissect_lsp_l1_is_neighbors_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -582,9 +592,9 @@ dissect_lsp_l1_is_neighbors_clv(const u_char *pd, int offset, */ static void dissect_lsp_l1_es_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { - dissect_lsp_eis_neighbors_clv_inner( pd, offset, length, fd, tree, - TRUE, TRUE); + guint length, int id_length, frame_data *fd, proto_tree *tree) { + dissect_lsp_eis_neighbors_clv_inner( pd, offset, length, id_length, + fd, tree, TRUE, TRUE); } /* @@ -599,6 +609,7 @@ dissect_lsp_l1_es_neighbors_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -607,9 +618,9 @@ dissect_lsp_l1_es_neighbors_clv(const u_char *pd, int offset, */ static void dissect_lsp_l2_is_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { - dissect_lsp_eis_neighbors_clv_inner(pd,offset, length, fd, tree, FALSE, - FALSE); + guint length, int id_length, frame_data *fd, proto_tree *tree) { + dissect_lsp_eis_neighbors_clv_inner(pd, offset, length, id_length, + fd, tree, FALSE, FALSE); } /* @@ -617,13 +628,14 @@ dissect_lsp_l2_is_neighbors_clv(const u_char *pd, int offset, * * Description: * This CLV is used to indicate which system is the designated - * IS for partition repair. This means just putting out the 6 octet - * IS. + * IS for partition repair. This means just putting out the + * "id_length"-octet IS. * * Input: * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -632,23 +644,24 @@ dissect_lsp_l2_is_neighbors_clv(const u_char *pd, int offset, */ static void dissect_lsp_partition_dis_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { - if ( length < 6 ) { + if ( length < id_length ) { isis_dissect_unknown(offset, length, tree, fd, - "short lsp parition DIS(%d vs 6)", length ); + "short lsp parition DIS(%d vs %d)", length, + id_length ); return; } /* * Gotta build a sub-tree for all our pieces */ if ( tree ) { - proto_tree_add_text ( tree, NullTVB, offset+4, 6, + proto_tree_add_text ( tree, NullTVB, offset, id_length, "Partition designated L2 IS: %s", - print_system_id( pd + offset, 6 ) ); + print_system_id( pd + offset, id_length ) ); } - length -= 6; - offset += 6; + length -= id_length; + offset += id_length; if ( length > 0 ){ isis_dissect_unknown(offset, length, tree, fd, "Long lsp parition DIS, %d left over", length ); @@ -668,6 +681,7 @@ dissect_lsp_partition_dis_clv(const u_char *pd, int offset, * u_char * : packet data * int : offset into packet data where we are. * guint : length of clv we are decoding + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -676,7 +690,7 @@ dissect_lsp_partition_dis_clv(const u_char *pd, int offset, */ static void dissect_lsp_prefix_neighbors_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { char *sbuf; int mylen; @@ -735,20 +749,21 @@ dissect_lsp_prefix_neighbors_clv(const u_char *pd, int offset, * Input: * char * : title string * proto_tree * : tree to display into. REQUIRED + * u_char * : packet data * int : offset into packet data where we are. - * isis_lsp_id_t * : id to display. + * int : length of IDs in packet. * * Output: * void, but we will add to proto tree */ void -isis_lsp_decode_lsp_id(char *tstr, proto_tree *tree, int offset, - isis_lsp_id_t *id ) { - proto_tree_add_text(tree, NullTVB, offset, 8, +isis_lsp_decode_lsp_id(char *tstr, proto_tree *tree, const u_char *pd, + int offset, int id_length ) { + proto_tree_add_text(tree, NullTVB, offset, id_length + 2, "%s: %s.%02x-%02x", tstr, - print_system_id( id->source_id, 6 ), - id->psuodonode_id, - id->lsp_number ); + print_system_id( pd + offset, id_length ), + pd[offset + id_length], + pd[offset + id_length + 1] ); } /* @@ -759,26 +774,28 @@ isis_lsp_decode_lsp_id(char *tstr, proto_tree *tree, int offset, * de-mangler with the right list of valid CLVs. * * Input: + * int : LSP type, a la packet-isis.h ISIS_TYPE_* values + * int : header length of packet. + * int : length of IDs in packet. * u_char * : packet data - * int : offset into packet data where we are. - * guint : length of clv we are decoding - * frame_data * : frame data (complete frame) - * proto_tree * : protocol display tree to fill out. May be NULL + * int offset : our offset into packet data. + * frame_data * : frame data + * proto_tree * : protocol display tree to add to. May be NULL. * * Output: * void, but we will add to proto tree if !NULL. */ void -isis_dissect_isis_lsp(int lsp_type, int header_length, +isis_dissect_isis_lsp(int lsp_type, int header_length, int id_length, const u_char *pd, int offset, frame_data *fd, proto_tree *tree){ - isis_lsp_t *ilp; proto_item *ti; proto_tree *lsp_tree = NULL; int hlen; + guint16 pdu_length; char sbuf[128]; int inx, q, some, value, len; - hlen = sizeof(*ilp); + hlen = 2+2+id_length+2+4+2+1; if (!BYTES_ARE_IN_FRAME(offset, hlen)) { isis_dissect_unknown(offset, hlen, tree, fd, @@ -787,32 +804,52 @@ isis_dissect_isis_lsp(int lsp_type, int header_length, return; } - ilp = (isis_lsp_t *) &pd[offset]; - if (tree) { ti = proto_tree_add_item(tree, proto_isis_lsp, NullTVB, offset, END_OF_FRAME, FALSE); lsp_tree = proto_item_add_subtree(ti, ett_isis_lsp); + } + + pdu_length = pntohs(&pd[offset]); + if (tree) { proto_tree_add_uint(lsp_tree, hf_isis_lsp_pdu_length, NullTVB, - offset, 2, pntohs(&ilp->isis_lsp_pdu_length)); + offset, 2, pdu_length); + } + offset += 2; + + if (tree) { proto_tree_add_uint(lsp_tree, hf_isis_lsp_remaining_life, NullTVB, - offset + 2, 2, pntohs(&ilp->isis_lsp_remaining_life)); - isis_lsp_decode_lsp_id("LSP ID", lsp_tree, offset + 4, - &ilp->isis_lsp_id ); + offset, 2, pntohs(&pd[offset])); + } + offset += 2; + + if (tree) { + isis_lsp_decode_lsp_id("LSP ID", lsp_tree, pd, offset, + id_length ); + } + offset += id_length + 2; + + if (tree) { proto_tree_add_uint(lsp_tree, hf_isis_lsp_sequence_number, NullTVB, - offset + 12, 4, - pntohl(&ilp->isis_lsp_sequence_number)); + offset, 4, + pntohl(&pd[offset])); + } + offset += 4; + if (tree) { /* XXX -> we could validate the cksum here! */ proto_tree_add_uint(lsp_tree, hf_isis_lsp_checksum, NullTVB, - offset + 16, 2, pntohs(&ilp->isis_lsp_checksum)); + offset, 2, pntohs(&pd[offset])); + } + offset += 2; + if (tree) { /* * We need to build our type block values. */ sbuf[0] = 0; some = 0; - value = ISIS_LSP_ATT(ilp->isis_lsp_type_block); + value = ISIS_LSP_ATT(pd[offset]); inx = 0; for ( q = (1<<ISIS_LSP_ATT_SHIFT); q > 0; q = q >> 1 ){ if (q & value) { @@ -828,19 +865,17 @@ isis_dissect_isis_lsp(int lsp_type, int header_length, } proto_tree_add_text(lsp_tree, NullTVB, offset + 18, 1, "Type block(0x%02x): P:%d, Supported metric(s): %s, OL:%d, istype:%s", - ilp->isis_lsp_type_block, - ISIS_LSP_PARTITION(ilp->isis_lsp_type_block) ? 1 : 0, + pd[offset], + ISIS_LSP_PARTITION(pd[offset]) ? 1 : 0, sbuf, - ISIS_LSP_HIPPITY(ilp->isis_lsp_type_block) ? 1 : 0, - val_to_str(ISIS_LSP_IS_TYPE(ilp->isis_lsp_type_block), + ISIS_LSP_HIPPITY(pd[offset]) ? 1 : 0, + val_to_str(ISIS_LSP_IS_TYPE(pd[offset]), isis_lsp_istype_vals, "Unknown (0x%x)") ); - } + offset += 1; - offset += hlen; - len = pntohs(&ilp->isis_lsp_pdu_length); - len -= header_length; + len = pdu_length - header_length; if (len < 0) { isis_dissect_unknown(offset, header_length, tree, fd, "packet header length %d went beyond packet", @@ -852,11 +887,11 @@ isis_dissect_isis_lsp(int lsp_type, int header_length, * our list of valid ones! */ if (lsp_type == ISIS_TYPE_L1_LSP){ - isis_dissect_clvs ( clv_l1_lsp_opts, len, pd, offset, fd, - lsp_tree, ett_isis_lsp_clv_unknown ); + isis_dissect_clvs ( clv_l1_lsp_opts, len, id_length, pd, + offset, fd, lsp_tree, ett_isis_lsp_clv_unknown ); } else { - isis_dissect_clvs ( clv_l2_lsp_opts, len, pd, offset, fd, - lsp_tree, ett_isis_lsp_clv_unknown ); + isis_dissect_clvs ( clv_l2_lsp_opts, len, id_length, pd, + offset, fd, lsp_tree, ett_isis_lsp_clv_unknown ); } } /* diff --git a/packet-isis-lsp.h b/packet-isis-lsp.h index 81be07a4ae..1dec2552c7 100644 --- a/packet-isis-lsp.h +++ b/packet-isis-lsp.h @@ -1,7 +1,7 @@ /* packet-isis-lsp.h * Defines and such for LSP and their CLV decodes * - * $Id: packet-isis-lsp.h,v 1.1 1999/12/15 04:34:18 guy Exp $ + * $Id: packet-isis-lsp.h,v 1.2 2000/06/19 08:33:49 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -30,27 +30,8 @@ #define _PACKET_ISIS_LSP_H /* - * Declare what an LSP id looks like (used by LSP and sequence number - * packets) + * Declarations for L1/L2 LSP base header. */ -typedef struct { - guint8 source_id[6]; /* source id part */ - guint8 psuodonode_id; /* psn id */ - guint8 lsp_number; /* frag number */ -} isis_lsp_id_t; - - -/* - * Declare L1/L2 LSP base header. - */ -typedef struct { - guint8 isis_lsp_pdu_length[2]; /* pdu length including hdr */ - guint8 isis_lsp_remaining_life[2]; /* seconds before expiration */ - isis_lsp_id_t isis_lsp_id; - guint8 isis_lsp_sequence_number[4]; - guint8 isis_lsp_checksum[2]; - guint8 isis_lsp_type_block; /* partition/att/hip/istype */ -} isis_lsp_t; #define ISIS_LSP_PARTITION_MASK 0x80 #define ISIS_LSP_ATT_MASK 0x78 @@ -112,8 +93,9 @@ typedef struct { * are only valid from with isis decodes. */ extern void isis_dissect_isis_lsp(int hello_type, int header_length, - const u_char *pd, int offset, frame_data *fd, proto_tree *tree); -extern void isis_lsp_decode_lsp_id(char *tstr, proto_tree *tree, int offset, - isis_lsp_id_t *id ); + int id_length, const u_char *pd, int offset, frame_data *fd, + proto_tree *tree); +extern void isis_lsp_decode_lsp_id(char *tstr, proto_tree *tree, + const u_char *pd, int offset, int id_length); #endif /* _PACKET_ISIS_LSP_H */ diff --git a/packet-isis-snp.c b/packet-isis-snp.c index da82e77cd9..fb105d562f 100644 --- a/packet-isis-snp.c +++ b/packet-isis-snp.c @@ -1,7 +1,7 @@ /* packet-isis-snp.c * Routines for decoding isis complete & partial SNP and their payload * - * $Id: packet-isis-snp.c,v 1.5 2000/05/31 05:07:14 guy Exp $ + * $Id: packet-isis-snp.c,v 1.6 2000/06/19 08:33:49 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -61,11 +61,11 @@ static gint ett_isis_psnp_authentication = -1; static gint ett_isis_psnp_clv_unknown = -1; static void dissect_snp_lsp_entries(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree ); + guint length, int id_length, frame_data *fd, proto_tree *tree ); static void dissect_l1_snp_authentication_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree ); + guint length, int id_length, frame_data *fd, proto_tree *tree ); static void dissect_l2_snp_authentication_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree ); + guint length, int id_length, frame_data *fd, proto_tree *tree ); static const isis_clv_handle_t clv_l1_csnp_opts[] = { { @@ -163,7 +163,7 @@ static const isis_clv_handle_t clv_l2_psnp_opts[] = { } }; /* - * Name: dissect_snp_payload() + * Name: dissect_snp_lsp_entries() * * Description: * All the snp packets use a common payload format. We have up @@ -176,7 +176,8 @@ static const isis_clv_handle_t clv_l2_psnp_opts[] = { * Input: * u_char * : packet data * int : offset into packet data where we are. - * int : length of payload to decode. + * guint : length of payload to decode. + * int : length of IDs in packet. * frame_data * : frame data (complete frame) * proto_tree * : protocol display tree to fill out. May be NULL * @@ -185,31 +186,36 @@ static const isis_clv_handle_t clv_l2_psnp_opts[] = { */ static void dissect_snp_lsp_entries(const u_char *pd, int offset, guint length, - frame_data *fd, proto_tree *tree ) { - isis_snp_t *ps; - - ps = (isis_snp_t *) &pd[offset]; + int id_length, frame_data *fd, proto_tree *tree ) { while ( length > 0 ) { - if ( length < sizeof(isis_psnp_t) ) { + if ( length < 2+id_length+2+4+2 ) { isis_dissect_unknown(offset, length, tree, fd, "Short SNP header entry (%d vs %d)", length, - sizeof(isis_psnp_t) ); + 2+id_length+2+4+2 ); return; } proto_tree_add_text(tree, NullTVB, offset, 2, "Remaining life : %d", - pntohs(&ps->isis_snp_remaining_lifetime)); - isis_lsp_decode_lsp_id( "LSP ID ", tree, offset + 2, - &ps->isis_snp_lsp_id ); - proto_tree_add_text(tree, NullTVB, offset+10, 4, + pntohs(&pd[offset])); + length -= 2; + offset += 2; + + isis_lsp_decode_lsp_id( "LSP ID ", tree, pd, + offset, id_length); + length -= id_length + 2; + offset += id_length + 2; + + proto_tree_add_text(tree, NullTVB, offset, 4, "LSP Sequence Number : 0x%04x", - pntohl(&ps->isis_snp_sequence_number)); - proto_tree_add_text(tree, NullTVB, offset+14, 2, + pntohl(&pd[offset])); + length -= 4; + offset += 4; + + proto_tree_add_text(tree, NullTVB, offset, 2, "LSP checksum : 0x%02x", - pntohs(&ps->isis_snp_checksum)); - length -= sizeof ( isis_snp_t ); - offset += sizeof ( isis_snp_t ); - ps++; + pntohs(&pd[offset])); + length -= 2; + offset += 2; } } @@ -223,25 +229,26 @@ dissect_snp_lsp_entries(const u_char *pd, int offset, guint length, * * Input: * int : type (l1 csnp, l2 csnp) + * int : header length of packet. + * int : length of IDs in packet. * u_char * : packet data - * int : offset into packet data where we are. - * guint : length of clv we are decoding - * frame_data * : frame data (complete frame) - * proto_tree * : protocol display tree to fill out. May be NULL + * int offset : our offset into packet data. + * frame_data * : frame data + * proto_tree * : protocol display tree to add to. May be NULL. * * Output: * void, but we will add to proto tree if !NULL. */ void -isis_dissect_isis_csnp(int type, int header_length, const u_char *pd, - int offset, frame_data *fd, proto_tree *tree){ - isis_csnp_t *ilp; +isis_dissect_isis_csnp(int type, int header_length, int id_length, + const u_char *pd, int offset, frame_data *fd, proto_tree *tree){ proto_item *ti; proto_tree *csnp_tree = NULL; int hlen; + guint16 pdu_length; int len; - hlen = sizeof(*ilp); + hlen = 2+id_length+1+id_length+2+id_length+2; if (!BYTES_ARE_IN_FRAME(offset, hlen)) { isis_dissect_unknown(offset, hlen, tree, fd, @@ -250,36 +257,49 @@ isis_dissect_isis_csnp(int type, int header_length, const u_char *pd, return; } - ilp = (isis_csnp_t *) &pd[offset]; - if (tree) { ti = proto_tree_add_item(tree, proto_isis_csnp, NullTVB, offset, END_OF_FRAME, FALSE); csnp_tree = proto_item_add_subtree(ti, ett_isis_csnp); + } + + pdu_length = pntohs(&pd[offset]); + if (tree) { proto_tree_add_uint(csnp_tree, hf_isis_csnp_pdu_length, NullTVB, - offset, 2, pntohs(&ilp->isis_csnp_pdu_length)); - proto_tree_add_text(csnp_tree, NullTVB, offset + 2, 7, + offset, 2, pdu_length); + } + offset += 2; + + if (tree) { + proto_tree_add_text(csnp_tree, NullTVB, offset, id_length + 1, "Source id : %s", - print_system_id( pd + offset + 2, 7 ) ); - isis_lsp_decode_lsp_id( "Start LSP id ", csnp_tree, offset + 9, - &ilp->isis_csnp_start_lsp_id ); - isis_lsp_decode_lsp_id( "End LSP id ", csnp_tree, offset + 17, - &ilp->isis_csnp_end_lsp_id ); + print_system_id( pd + offset, id_length + 1 ) ); } + offset += id_length + 1; - offset += hlen; - len = pntohs(&ilp->isis_csnp_pdu_length); - len -= header_length; + if (tree) { + isis_lsp_decode_lsp_id( "Start LSP id ", csnp_tree, pd, offset, + id_length ); + } + offset += id_length + 2; + + if (tree) { + isis_lsp_decode_lsp_id( "End LSP id ", csnp_tree, pd, offset, + id_length ); + } + offset += id_length + 2; + + len = pdu_length - header_length; if (len < 0) { return; } /* Call into payload dissector */ if (type == ISIS_TYPE_L1_CSNP ) { - isis_dissect_clvs ( clv_l1_csnp_opts, len, pd, offset, fd, - csnp_tree, ett_isis_csnp_clv_unknown ); + isis_dissect_clvs ( clv_l1_csnp_opts, len, id_length, pd, + offset, fd, csnp_tree, ett_isis_csnp_clv_unknown ); } else { - isis_dissect_clvs ( clv_l2_csnp_opts, len, pd, offset, fd, - csnp_tree, ett_isis_csnp_clv_unknown ); + isis_dissect_clvs ( clv_l2_csnp_opts, len, id_length, pd, + offset, fd, csnp_tree, ett_isis_csnp_clv_unknown ); } } @@ -291,25 +311,27 @@ isis_dissect_isis_csnp(int type, int header_length, const u_char *pd, * to pull apart the lsp id payload. * * Input: + * int : type (l1 psnp, l2 psnp) + * int : header length of packet. + * int : length of IDs in packet. * u_char * : packet data - * int : offset into packet data where we are. - * guint : length of clv we are decoding - * frame_data * : frame data (complete frame) - * proto_tree * : protocol display tree to fill out. May be NULL + * int offset : our offset into packet data. + * frame_data * : frame data + * proto_tree * : protocol display tree to add to. May be NULL. * * Output: * void, but we will add to proto tree if !NULL. */ void -isis_dissect_isis_psnp(int type, int header_length, const u_char *pd, - int offset, frame_data *fd, proto_tree *tree){ - isis_psnp_t *ilp; +isis_dissect_isis_psnp(int type, int header_length, int id_length, + const u_char *pd, int offset, frame_data *fd, proto_tree *tree){ proto_item *ti; proto_tree *psnp_tree = NULL; int hlen; + guint16 pdu_length; int len; - hlen = sizeof(*ilp); + hlen = 2+id_length+1; if (!BYTES_ARE_IN_FRAME(offset, hlen)) { isis_dissect_unknown(offset, hlen, tree, fd, @@ -318,22 +340,27 @@ isis_dissect_isis_psnp(int type, int header_length, const u_char *pd, return; } - ilp = (isis_psnp_t *) &pd[offset]; - if (tree) { ti = proto_tree_add_item(tree, proto_isis_psnp, NullTVB, offset, END_OF_FRAME, FALSE); psnp_tree = proto_item_add_subtree(ti, ett_isis_psnp); + } + + pdu_length = pntohs(&pd[offset]); + if (tree) { proto_tree_add_uint(psnp_tree, hf_isis_psnp_pdu_length, NullTVB, - offset, 2, pntohs(&ilp->isis_psnp_pdu_length)); - proto_tree_add_text(psnp_tree, NullTVB, offset + 2, 7, + offset, 2, pdu_length); + } + offset += 2; + + if (tree) { + proto_tree_add_text(psnp_tree, NullTVB, offset, id_length + 1, "Source id: %s", - print_system_id( pd + offset + 2, 7 ) ); + print_system_id( pd + offset, id_length + 1 ) ); } + offset += id_length + 1; - offset += hlen; - len = pntohs(&ilp->isis_psnp_pdu_length); - len -= header_length; + len = pdu_length - header_length; if (len < 0) { isis_dissect_unknown(offset, header_length, tree, fd, "packet header length %d went beyond packet", @@ -342,11 +369,11 @@ isis_dissect_isis_psnp(int type, int header_length, const u_char *pd, } /* Call into payload dissector */ if (type == ISIS_TYPE_L1_CSNP ) { - isis_dissect_clvs ( clv_l1_csnp_opts, len, pd, offset, fd, - psnp_tree, ett_isis_psnp_clv_unknown ); + isis_dissect_clvs ( clv_l1_csnp_opts, len, id_length, pd, + offset, fd, psnp_tree, ett_isis_psnp_clv_unknown ); } else { - isis_dissect_clvs ( clv_l2_csnp_opts, len, pd, offset, fd, - psnp_tree, ett_isis_psnp_clv_unknown ); + isis_dissect_clvs ( clv_l2_csnp_opts, len, id_length, pd, + offset, fd, psnp_tree, ett_isis_psnp_clv_unknown ); } } @@ -361,6 +388,7 @@ isis_dissect_isis_psnp(int type, int header_length, const u_char *pd, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -369,7 +397,7 @@ isis_dissect_isis_psnp(int type, int header_length, const u_char *pd, */ static void dissect_l1_snp_authentication_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_authentication_clv(pd, offset, length, fd, tree, "Per area authentication" ); } @@ -385,6 +413,7 @@ dissect_l1_snp_authentication_clv(const u_char *pd, int offset, * u_char * : packet data * int : current offset into packet data * guint : length of this clv + * int : length of IDs in packet. * frame_data * : frame data * proto_tree * : proto tree to build on (may be null) * @@ -393,7 +422,7 @@ dissect_l1_snp_authentication_clv(const u_char *pd, int offset, */ static void dissect_l2_snp_authentication_clv(const u_char *pd, int offset, - guint length, frame_data *fd, proto_tree *tree) { + guint length, int id_length, frame_data *fd, proto_tree *tree) { isis_dissect_authentication_clv(pd, offset, length, fd, tree, "Per domain authentication" ); } @@ -472,4 +501,3 @@ proto_register_isis_psnp(void) { proto_register_field_array(proto_isis_psnp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } - diff --git a/packet-isis-snp.h b/packet-isis-snp.h index 15b7a92e44..e83a6c215d 100644 --- a/packet-isis-snp.h +++ b/packet-isis-snp.h @@ -1,7 +1,7 @@ /* packet-isis-snp.h * Defines and such for CSNP, PSNP, and their payloads * - * $Id: packet-isis-snp.h,v 1.1 1999/12/15 04:34:19 guy Exp $ + * $Id: packet-isis-snp.h,v 1.2 2000/06/19 08:33:50 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -63,40 +63,12 @@ #define ISIS_CLV_L2_PSNP_AUTHENTICATION 133 /* - * Declare L1/L2 CSNP header - */ -typedef struct { - guint8 isis_csnp_pdu_length[2]; /* pdu length including hdr */ - guint8 isis_csnp_source_id[7]; /* source sysid */ - isis_lsp_id_t isis_csnp_start_lsp_id; /* start LSP id */ - isis_lsp_id_t isis_csnp_end_lsp_id; /* end LSP id */ -} isis_csnp_t; - -/* - * Declare L1/L2 PSNP header - */ -typedef struct { - guint8 isis_psnp_pdu_length[2]; /* pdu length including hdr */ - guint8 isis_psnp_source_id[7]; /* source sysid */ -} isis_psnp_t; - -/* - * Declare SNP payload element - */ -typedef struct { - guint8 isis_snp_remaining_lifetime[2]; /* lifetime of LSP */ - isis_lsp_id_t isis_snp_lsp_id; /* target LSP id */ - guint8 isis_snp_sequence_number[4]; /* sequence number of LSP */ - guint8 isis_snp_checksum[2]; /* checksum of LSP */ -} isis_snp_t; - -/* * Published API functions. NOTE, this are "local" API functions and * are only valid from with isis decodes. */ -extern void isis_dissect_isis_csnp(int type, int header_length, - const u_char *pd, int offset, frame_data *fd, proto_tree *tree); -extern void isis_dissect_isis_psnp(int type, int header_length, +extern void isis_dissect_isis_csnp(int type, int header_length, int id_length, + const u_char *pd, int offset, frame_data *fd, proto_tree *tree); +extern void isis_dissect_isis_psnp(int type, int header_length, int id_length, const u_char *pd, int offset, frame_data *fd, proto_tree *tree); #endif /* _PACKET_ISIS_CSNP_H */ diff --git a/packet-isis.c b/packet-isis.c index aefc7f49e2..7b0e1153b7 100644 --- a/packet-isis.c +++ b/packet-isis.c @@ -2,7 +2,7 @@ * Routines for ISO/OSI network and transport protocol packet disassembly, core * bits. * - * $Id: packet-isis.c,v 1.10 2000/05/31 05:07:15 guy Exp $ + * $Id: packet-isis.c,v 1.11 2000/06/19 08:33:50 guy Exp $ * Stuart Stanley <stuarts@mxmail.net> * * Ethereal - Network traffic analyzer @@ -137,6 +137,7 @@ dissect_isis(const u_char *pd, int offset, frame_data *fd, isis_hdr_t *ihdr; proto_item *ti; proto_tree *isis_tree = NULL; + int id_length; if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "ISIS"); @@ -199,45 +200,66 @@ dissect_isis(const u_char *pd, int offset, frame_data *fd, } /* + * Interpret the system ID length. + */ + id_length = ihdr->isis_system_id_len; + if (id_length == 0) + id_length = 6; /* zero means 6-octet ID field length */ + else if (id_length == 255) { + id_length = 0; /* 255 means null ID field */ + /* XXX - what about the LAN ID? */ + } + /* XXX - otherwise, must be in the range 1 through 8 */ + + /* * Advance offset (we are past the header). */ offset += sizeof(*ihdr); switch (ihdr->isis_type) { case ISIS_TYPE_L1_HELLO: isis_dissect_isis_hello(ISIS_TYPE_L1_HELLO, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_L2_HELLO: isis_dissect_isis_hello(ISIS_TYPE_L2_HELLO, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_PTP_HELLO: isis_dissect_isis_hello(ISIS_TYPE_PTP_HELLO, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_L1_LSP: - isis_dissect_isis_lsp(ISIS_TYPE_L1_LSP, ihdr->isis_header_length, + isis_dissect_isis_lsp(ISIS_TYPE_L1_LSP, + ihdr->isis_header_length, id_length, pd, offset, fd, isis_tree); break; case ISIS_TYPE_L2_LSP: - isis_dissect_isis_lsp(ISIS_TYPE_L2_LSP, ihdr->isis_header_length, + isis_dissect_isis_lsp(ISIS_TYPE_L2_LSP, + ihdr->isis_header_length, id_length, pd, offset, fd, isis_tree); break; case ISIS_TYPE_L1_CSNP: isis_dissect_isis_csnp(ISIS_TYPE_L1_CSNP, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_L2_CSNP: isis_dissect_isis_csnp(ISIS_TYPE_L2_CSNP, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_L1_PSNP: isis_dissect_isis_psnp(ISIS_TYPE_L1_PSNP, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; case ISIS_TYPE_L2_PSNP: isis_dissect_isis_psnp(ISIS_TYPE_L2_PSNP, - ihdr->isis_header_length, pd, offset, fd, isis_tree); + ihdr->isis_header_length, id_length, + pd, offset, fd, isis_tree); break; default: isis_dissect_unknown(offset, END_OF_FRAME, tree, fd, |