ofp_print_phy_ports(struct ds *string, uint8_t ofp_version,
struct ofpbuf *b)
{
- size_t n_ports;
struct ofputil_phy_port *ports;
- enum ofperr error;
+ size_t allocated_ports, n_ports;
+ int retval;
size_t i;
- n_ports = ofputil_count_phy_ports(ofp_version, b);
+ ports = NULL;
+ allocated_ports = 0;
+ for (n_ports = 0; ; n_ports++) {
+ if (n_ports >= allocated_ports) {
+ ports = x2nrealloc(ports, &allocated_ports, sizeof *ports);
+ }
- ports = xmalloc(n_ports * sizeof *ports);
- for (i = 0; i < n_ports; i++) {
- error = ofputil_pull_phy_port(ofp_version, b, &ports[i]);
- if (error) {
- ofp_print_error(string, error);
- goto exit;
+ retval = ofputil_pull_phy_port(ofp_version, b, &ports[n_ports]);
+ if (retval) {
+ break;
}
}
+
qsort(ports, n_ports, sizeof *ports, compare_ports);
for (i = 0; i < n_ports; i++) {
ofp_print_phy_port(string, &ports[i]);
}
-
-exit:
free(ports);
+
+ if (retval != EOF) {
+ ofp_print_error(string, retval);
+ }
}
static const char *
break;
case OFP13_VERSION:
case OFP14_VERSION:
+ case OFP15_VERSION:
return; /* no ports in ofp13_switch_features */
default:
OVS_NOT_REACHED();
struct ofputil_port_mod pm;
enum ofperr error;
- error = ofputil_decode_port_mod(oh, &pm);
+ error = ofputil_decode_port_mod(oh, &pm, true);
if (error) {
ofp_print_error(string, error);
return;
int verbosity)
{
switch ((enum ofp_version)oh->version) {
+ case OFP15_VERSION:
case OFP14_VERSION:
case OFP13_VERSION:
ofp_print_ofpst_table_reply13(string, oh, verbosity);
case OFP14_VERSION:
ds_put_cstr(string, " (OF1.4)");
break;
+ case OFP15_VERSION:
+ ds_put_cstr(string, " (OF1.5)");
+ break;
default:
ds_put_format(string, " (OF 0x%02"PRIx8")", oh->version);
break;