diff --git a/epan/dissectors/packet-igrp.c b/epan/dissectors/packet-igrp.c index 1c7b158d0f..2a91314e73 100644 --- a/epan/dissectors/packet-igrp.c +++ b/epan/dissectors/packet-igrp.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -44,11 +45,26 @@ void proto_reg_handoff_igrp(void); static gint proto_igrp = -1; static gint hf_igrp_update = -1; static gint hf_igrp_as = -1; - +/* Generated from convert_proto_tree_add_text.pl */ +static int hf_igrp_load = -1; +static int hf_igrp_bandwidth = -1; +static int hf_igrp_command = -1; +static int hf_igrp_reliability = -1; +static int hf_igrp_network = -1; +static int hf_igrp_version = -1; +static int hf_igrp_interior_routes = -1; +static int hf_igrp_mtu = -1; +static int hf_igrp_hop_count = -1; +static int hf_igrp_exterior_routes = -1; +static int hf_igrp_delay = -1; +static int hf_igrp_checksum = -1; +static int hf_igrp_system_routes = -1; static gint ett_igrp = -1; static gint ett_igrp_vektor = -1; static gint ett_igrp_net = -1; +static expert_field ei_igrp_version = EI_INIT; + static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, guint8 network); static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -90,8 +106,14 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) 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)")); + ti = proto_tree_add_item(igrp_tree, hf_igrp_version, tvb, 0, 1, ENC_NA); + if (version != 1) + expert_add_info(pinfo, ti, &ei_igrp_version); + ti = proto_tree_add_item(igrp_tree, hf_igrp_command, tvb, 0, 1, ENC_NA); + if (opcode==1) + proto_item_append_text(ti, " (Response)"); + else + proto_item_append_text(ti, " (Request)"); proto_tree_add_item(igrp_tree, hf_igrp_update, tvb, 1,1, ENC_BIG_ENDIAN); proto_tree_add_item(igrp_tree, hf_igrp_as, tvb, 2,2, ENC_BIG_ENDIAN); @@ -106,7 +128,7 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } else network = 0; /* XXX - shouldn't happen */ - ti = proto_tree_add_text(igrp_tree, tvb, 4,2,"Interior routes : %d",ninterior); + ti = proto_tree_add_item(igrp_tree, hf_igrp_interior_routes, tvb, 4, 2, ENC_BIG_ENDIAN); 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); @@ -114,7 +136,7 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset+=IGRP_ENTRY_LENGTH; } - ti = proto_tree_add_text(igrp_tree, tvb, 6,2,"System routes : %d",nsystem); + ti = proto_tree_add_item(igrp_tree, hf_igrp_system_routes, tvb, 6, 2, ENC_BIG_ENDIAN); 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); @@ -122,7 +144,7 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset+=IGRP_ENTRY_LENGTH; } - ti = proto_tree_add_text(igrp_tree, tvb, 8,2,"Exterior routes : %d",nexterior); + ti = proto_tree_add_item(igrp_tree, hf_igrp_exterior_routes, tvb, 8, 2, ENC_BIG_ENDIAN); 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); @@ -130,7 +152,7 @@ static void dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset+=IGRP_ENTRY_LENGTH; } - proto_tree_add_text(igrp_tree, tvb, 10,2,"Checksum = 0x%4x",tvb_get_ntohs(tvb,10)); + proto_tree_add_item(igrp_tree, hf_igrp_checksum, tvb, 10, 2, ENC_BIG_ENDIAN); } } @@ -148,14 +170,14 @@ static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, gu if (network==0) ptr_addr=&addr[1]; igrp_vektor_tree = proto_tree_add_subtree_format(igrp_vektor_tree, tvb, 0 ,14, - ett_igrp_net, NULL, "Entry for network %s", ip_to_str(ptr_addr)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 0 ,3,"Network = %s",ip_to_str(ptr_addr)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 3 ,3,"Delay = %d",tvb_get_ntoh24(tvb,3)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 6 ,3,"Bandwidth = %d",tvb_get_ntoh24(tvb,6)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 9 ,2,"MTU = %d bytes",tvb_get_ntohs(tvb,9)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 11,1,"Reliability = %d",tvb_get_guint8(tvb,11)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 12,1,"Load = %d",tvb_get_guint8(tvb,12)) ; - proto_tree_add_text (igrp_vektor_tree, tvb, 13,1,"Hop count = %d hops",tvb_get_guint8(tvb,13)) ; + ett_igrp_net, NULL, "Entry for network %s", ip_to_str(ptr_addr)); + proto_tree_add_ipv4(igrp_vektor_tree, hf_igrp_network, tvb, 0, 3, *((guint32*)ptr_addr)); + proto_tree_add_item(igrp_vektor_tree, hf_igrp_delay, tvb, 3, 3, ENC_BIG_ENDIAN); + proto_tree_add_item(igrp_vektor_tree, hf_igrp_bandwidth, tvb, 6, 3, ENC_BIG_ENDIAN); + proto_tree_add_uint_format_value(igrp_vektor_tree, hf_igrp_mtu, tvb, 9, 2, tvb_get_ntohs(tvb,9), "%d bytes", tvb_get_ntohs(tvb,9)); + proto_tree_add_item(igrp_vektor_tree, hf_igrp_reliability, tvb, 11, 1, ENC_NA); + proto_tree_add_item(igrp_vektor_tree, hf_igrp_load, tvb, 12, 1, ENC_NA); + proto_tree_add_item(igrp_vektor_tree, hf_igrp_hop_count, tvb, 13, 1, ENC_NA); } @@ -175,7 +197,22 @@ void proto_register_igrp(void) { "Autonomous System", "igrp.as", FT_UINT16, BASE_DEC, NULL, 0x0 , "Autonomous System number", HFILL } - } + }, + + /* Generated from convert_proto_tree_add_text.pl */ + { &hf_igrp_version, { "IGRP Version", "igrp.version", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }}, + { &hf_igrp_command, { "Command", "igrp.command", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }}, + { &hf_igrp_interior_routes, { "Interior routes", "igrp.interior_routes", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_system_routes, { "System routes", "igrp.system_routes", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_exterior_routes, { "Exterior routes", "igrp.exterior_routes", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_checksum, { "Checksum", "igrp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_network, { "Network", "igrp.network", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_delay, { "Delay", "igrp.delay", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_bandwidth, { "Bandwidth", "igrp.bandwidth", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_mtu, { "MTU", "igrp.mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_reliability, { "Reliability", "igrp.reliability", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_load, { "Load", "igrp.load", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_igrp_hop_count, { "Hop count", "igrp.hop_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, }; /* Setup protocol subtree array */ @@ -185,6 +222,12 @@ void proto_register_igrp(void) &ett_igrp_net }; + static ei_register_info ei[] = { + { &ei_igrp_version, { "igrp.version.invalid", PI_PROTOCOL, PI_WARN, "Unknown Version, The dissection may be inaccurate", EXPFILL }}, + }; + + expert_module_t* expert_igrp; + /* Register the protocol name and description */ proto_igrp = proto_register_protocol("Cisco Interior Gateway Routing Protocol", "IGRP", "igrp"); @@ -192,6 +235,8 @@ void proto_register_igrp(void) /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_igrp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_igrp = expert_register_protocol(proto_igrp); + expert_register_field_array(expert_igrp, ei, array_length(ei)); } void