From 8b51233a230501d8f2580c77ea393a175b4e2b99 Mon Sep 17 00:00:00 2001 From: David Underhill Date: Fri, 11 Jul 2008 18:52:41 -0700 Subject: [PATCH] Completed dissection of Feature Reply and ofp_phy_port. --- .../openflow/packet-openflow.c | 150 +++++++++++++++++- 1 file changed, 144 insertions(+), 6 deletions(-) diff --git a/utilities/wireshark_dissectors/openflow/packet-openflow.c b/utilities/wireshark_dissectors/openflow/packet-openflow.c index d634060..f59cb61 100644 --- a/utilities/wireshark_dissectors/openflow/packet-openflow.c +++ b/utilities/wireshark_dissectors/openflow/packet-openflow.c @@ -62,6 +62,7 @@ static const value_string names_ofp_port_flags[] = { { OFPPFL_NO_FLOOD, "Do not include this port when flooding" }, { 0, NULL } }; +#define NUM_PORT_FLAGS 1 /** names from ofp_port */ static const value_string names_ofp_port[] = { @@ -86,6 +87,7 @@ static const value_string names_ofp_port_features[] = { { OFPPF_10GB_FD, " 10 Gb full-duplex rate support" }, { 0, NULL } }; +#define NUM_PORT_FEATURES 7 /** names from ofp_flow_wildcards */ static const value_string names_ofp_flow_wildcards[] = { @@ -185,9 +187,11 @@ static gint ofp_phy_port = -1; static gint ofp_phy_port_port_no = -1; static gint ofp_phy_port_hw_addr = -1; static gint ofp_phy_port_name = -1; -static gint ofp_phy_port_flags = -1; +static gint ofp_phy_port_flags_hdr= -1; +static gint ofp_phy_port_flags[NUM_PORT_FLAGS]; static gint ofp_phy_port_speed = -1; -static gint ofp_phy_port_features = -1; +static gint ofp_phy_port_features_hdr = -1; +static gint ofp_phy_port_features[NUM_PORT_FEATURES]; static gint ofp_match = -1; static gint ofp_match_wildcards = -1; @@ -228,8 +232,11 @@ static gint ofp_switch_features_n_buffers = -1; static gint ofp_switch_features_capabilities_hdr = -1; static gint ofp_switch_features_capabilities[NUM_CAPABILITIES]; static gint ofp_switch_features_actions_hdr = -1; +static gint ofp_switch_features_actions_warn = -1; static gint ofp_switch_features_actions[NUM_ACTIONS]; -static gint ofp_switch_features_ports = -1; +static gint ofp_switch_features_ports_hdr = -1; +static gint ofp_switch_features_ports_num = -1; +static gint ofp_switch_features_ports_warn = -1; static gint ofp_switch_config = -1; static gint ofp_switch_config_flags = -1; @@ -342,6 +349,8 @@ static gint ett_ofp_header = -1; /* Common Structures */ static gint ett_ofp_phy_port = -1; +static gint ett_ofp_phy_port_flags_hdr = -1; +static gint ett_ofp_phy_port_features_hdr = -1; static gint ett_ofp_match = -1; static gint ett_ofp_action = -1; @@ -351,6 +360,9 @@ static gint ett_ofp_switch_features_table_info_hdr = -1; static gint ett_ofp_switch_features_buffer_limits_hdr = -1; static gint ett_ofp_switch_features_capabilities_hdr = -1; static gint ett_ofp_switch_features_actions_hdr = -1; +static gint ett_ofp_switch_features_actions_warn = -1; +static gint ett_ofp_switch_features_ports_hdr = -1; +static gint ett_ofp_switch_features_ports_warn = -1; static gint ett_ofp_switch_config = -1; static gint ett_ofp_flow_mod = -1; static gint ett_ofp_port_mod = -1; @@ -398,6 +410,12 @@ void proto_register_openflow() for( i=0; i 0) { + port_item = proto_tree_add_item(tree, ofp_phy_port, tvb, *offset, sizeof(struct ofp_phy_port), FALSE); + port_tree = proto_item_add_subtree(port_item, ett_ofp_phy_port); + + add_child( port_tree, ofp_phy_port_port_no, tvb, offset, 2 ); + add_child( port_tree, ofp_phy_port_hw_addr, tvb, offset, 6 ); + add_child( port_tree, ofp_phy_port_name, tvb, offset, OFP_MAX_PORT_NAME_LEN ); + + /* flags */ + flags_item = proto_tree_add_item(port_tree, ofp_phy_port_flags_hdr, tvb, *offset, 4, FALSE); + flags_tree = proto_item_add_subtree(flags_item, ett_ofp_phy_port_flags_hdr); + for(i=0; i 0 ) { + num_ports = sz / sizeof(struct ofp_phy_port); /* number of ports */ + proto_tree_add_uint(sf_port_tree, ofp_switch_features_ports_num, tvb, offset, num_ports*sizeof(struct ofp_phy_port), num_ports); + dissect_phy_ports(sf_port_tree, sf_port_item, tvb, pinfo, &offset, num_ports); + if( num_ports * sizeof(struct ofp_phy_port) < sz ) { + snprintf(str, STR_LEN, "%uB were leftover at end of packet", sz - num_ports*sizeof(struct ofp_phy_port)); + add_child_str(sf_port_tree, ofp_switch_features_ports_warn, tvb, &offset, 0, str); + } + } + else if( sz < 0 ) { + /* not enough bytes => wireshark will already have reported the error */ + } + else { + snprintf(str, STR_LEN, "No ports were specified"); + add_child_str(sf_port_tree, ofp_switch_features_ports_warn, tvb, &offset, 0, str); + } break; case OFPT_GET_CONFIG_REQUEST: