- query_ports(dpif, &ports, &n_ports);
- for (i = 0; i < n_ports; i++) {
- printf("\tport %u: %s", ports[i].port, ports[i].devname);
- if (ports[i].flags & ODP_PORT_INTERNAL) {
- printf(" (internal)");
+ DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) {
+ printf("\tport %u: %s", dpif_port.port_no, dpif_port.name);
+
+ if (strcmp(dpif_port.type, "system")) {
+ struct netdev_options netdev_options;
+ struct netdev *netdev;
+ int error;
+
+ printf (" (%s", dpif_port.type);
+
+ netdev_options.name = dpif_port.name;
+ netdev_options.type = dpif_port.type;
+ netdev_options.args = NULL;
+ netdev_options.ethertype = NETDEV_ETH_TYPE_NONE;
+ error = netdev_open(&netdev_options, &netdev);
+ if (!error) {
+ const struct shash_node **nodes;
+ const struct shash *config;
+ size_t i;
+
+ config = netdev_get_config(netdev);
+ nodes = shash_sort(config);
+ for (i = 0; i < shash_count(config); i++) {
+ const struct shash_node *node = nodes[i];
+ printf("%c %s=%s", i ? ',' : ':',
+ node->name, (char *) node->data);
+ }
+ free(nodes);
+
+ netdev_close(netdev);
+ } else {
+ printf(": open failed (%s)", strerror(error));
+ }
+ putchar(')');