diff options
author | Guy Harris <guy@alum.mit.edu> | 2009-05-18 00:27:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2009-05-18 00:27:44 +0000 |
commit | 19a74e6fcceaeb8a643815c0d4d05bd182c399ac (patch) | |
tree | 6e411ed11ad6b8b289d0e63a6448c45668ff40ae /epan | |
parent | 9b3360c5ef4fad6a9281e6945ca6e0eeb3539e6a (diff) |
Just use proto_tree_add_item() for some fields whose values we don't
use.
Rename some variables to reflect the names they have in the IGRP
document.
Don't treat being called with a non-IPv4 address as a dissector bug - we
can't prevent ourselves from being called from the IPv6 dissector. This
fixes bug 3466.
Clean up indentation.
svn path=/trunk/; revision=28390
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-igrp.c | 89 |
1 files changed, 42 insertions, 47 deletions
diff --git a/epan/dissectors/packet-igrp.c b/epan/dissectors/packet-igrp.c index c6d65a1837..5a51a756a2 100644 --- a/epan/dissectors/packet-igrp.c +++ b/epan/dissectors/packet-igrp.c @@ -57,9 +57,9 @@ static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, gu static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint8 ver_and_opcode,version,opcode,update,network; + guint8 ver_and_opcode,version,opcode,network; gint offset=IGRP_HEADER_LENGTH; - guint16 as,net1,net2,net3; + guint16 ninterior,nsystem,nexterior; const guint8 *ipsrc; proto_item *ti; proto_tree *igrp_tree, *igrp_vektor_tree; @@ -71,8 +71,6 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo, COL_INFO); ver_and_opcode = tvb_get_guint8(tvb,0); - update = tvb_get_guint8(tvb,1); - as = tvb_get_ntohs(tvb,2); if (check_col(pinfo->cinfo, COL_INFO)) { @@ -92,59 +90,56 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { - ti = proto_tree_add_protocol_format(tree, proto_igrp, tvb, 0, -1, - "Cisco IGRP"); + ti = proto_tree_add_protocol_format(tree, proto_igrp, tvb, 0, -1, + "Cisco IGRP"); - igrp_tree = proto_item_add_subtree(ti, ett_igrp); + igrp_tree = proto_item_add_subtree(ti, ett_igrp); - version = (ver_and_opcode&0xf0)>>4 ; /* version is the fist half of the byte */ - opcode = ver_and_opcode&0x0f ; /* opcode is the last half of the byte */ + version = (ver_and_opcode&0xf0)>>4 ; /* version is the fist half of the byte */ + opcode = ver_and_opcode&0x0f ; /* opcode is the last half of the byte */ - proto_tree_add_text(igrp_tree, tvb, 0,1,"IGRP Version : %d %s",version,(version==1?" ":" - Unknown Version, The dissection may be inaccurate")); - proto_tree_add_text(igrp_tree, tvb, 0,1,"Command : %d %s",opcode,(opcode==1?"(Response)":"(Request)")); - proto_tree_add_uint(igrp_tree, hf_igrp_update, tvb, 1,1, update); - proto_tree_add_uint(igrp_tree, hf_igrp_as, tvb, 2,2,as); + proto_tree_add_text(igrp_tree, tvb, 0,1,"IGRP Version : %d %s",version,(version==1?" ":" - Unknown Version, The dissection may be inaccurate")); + proto_tree_add_text(igrp_tree, tvb, 0,1,"Command : %d %s",opcode,(opcode==1?"(Response)":"(Request)")); + proto_tree_add_item(igrp_tree, hf_igrp_update, tvb, 1,1, FALSE); + proto_tree_add_item(igrp_tree, hf_igrp_as, tvb, 2,2, FALSE); - net1 = tvb_get_ntohs(tvb,4); - net2 = tvb_get_ntohs(tvb,6); - net3 = tvb_get_ntohs(tvb,8); + ninterior = tvb_get_ntohs(tvb,4); + nsystem = tvb_get_ntohs(tvb,6); + nexterior = tvb_get_ntohs(tvb,8); - /* this is a ugly hack to find the first byte of the IP source address */ - DISSECTOR_ASSERT(pinfo->net_src.type == AT_IPv4); + /* this is a ugly hack to find the first byte of the IP source address */ + if (pinfo->net_src.type == AT_IPv4) { ipsrc = pinfo->net_src.data; network = ipsrc[0]; + } else + network = 0; /* XXX - shouldn't happen */ + + ti = proto_tree_add_text(igrp_tree, tvb, 4,2,"Interior routes : %d",ninterior); + for( ; ninterior>0 ; ninterior-- ) { + igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); + next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + dissect_vektor_igrp (next_tvb,igrp_vektor_tree,network); + offset+=IGRP_ENTRY_LENGTH; + } + + ti = proto_tree_add_text(igrp_tree, tvb, 6,2,"System routes : %d",nsystem); + for( ; nsystem>0 ; nsystem-- ) { + igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); + next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); + offset+=IGRP_ENTRY_LENGTH; + } - ti = proto_tree_add_text(igrp_tree, tvb, 4,2,"Interior routes : %d",net1); - for( ; net1>0 ; net1-- ) - { - igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); - dissect_vektor_igrp (next_tvb,igrp_vektor_tree,network); - offset+=IGRP_ENTRY_LENGTH; - } - - ti = proto_tree_add_text(igrp_tree, tvb, 6,2,"System routes : %d",net2); - for( ; net2>0 ; net2-- ) - { - igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); - dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); - offset+=IGRP_ENTRY_LENGTH; - } - - ti = proto_tree_add_text(igrp_tree, tvb, 8,2,"Exterior routes : %d",net3); - for( ; net3>0 ; net3-- ) - { - igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); - next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); - dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); - offset+=IGRP_ENTRY_LENGTH; - } - - proto_tree_add_text(igrp_tree, tvb, 10,2,"Checksum = 0x%4x",tvb_get_ntohs(tvb,10)); + ti = proto_tree_add_text(igrp_tree, tvb, 8,2,"Exterior routes : %d",nexterior); + for( ; nexterior>0 ; nexterior-- ) { + igrp_vektor_tree = proto_item_add_subtree(ti,ett_igrp_vektor); + next_tvb = tvb_new_subset(tvb, offset, IGRP_ENTRY_LENGTH, -1); + dissect_vektor_igrp (next_tvb,igrp_vektor_tree,0); + offset+=IGRP_ENTRY_LENGTH; + } + proto_tree_add_text(igrp_tree, tvb, 10,2,"Checksum = 0x%4x",tvb_get_ntohs(tvb,10)); } - return; } static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, guint8 network) |