X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-dpctl.c;h=950e8f41747b64999f05c87d0ee415473b40fd9e;hb=254f4f3bd8c070dae5c42459db477bde35548e5d;hp=5fa6fb7ebc97f76cfdcdb319fb89b14e4d611a3c;hpb=becffb862616fa1a5c76c948b4f39cd61f6efca8;p=openvswitch diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index 5fa6fb7e..950e8f41 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,8 @@ #include "ofpbuf.h" #include "packets.h" #include "shash.h" +#include "simap.h" +#include "smap.h" #include "sset.h" #include "timeval.h" #include "util.h" @@ -245,7 +247,7 @@ do_add_if(int argc OVS_UNUSED, char *argv[]) const char *name, *type; char *save_ptr = NULL; struct netdev *netdev = NULL; - struct shash args; + struct smap args; char *option; int error; @@ -258,7 +260,7 @@ do_add_if(int argc OVS_UNUSED, char *argv[]) continue; } - shash_init(&args); + smap_init(&args); while ((option = strtok_r(NULL, ",", &save_ptr)) != NULL) { char *save_ptr_2 = NULL; char *key, *value; @@ -271,7 +273,7 @@ do_add_if(int argc OVS_UNUSED, char *argv[]) if (!strcmp(key, "type")) { type = value; - } else if (!shash_add_once(&args, key, value)) { + } else if (!smap_add_once(&args, key, value)) { ovs_error(0, "duplicate \"%s\" option", key); } } @@ -322,7 +324,7 @@ do_set_if(int argc, char *argv[]) char *save_ptr = NULL; char *type = NULL; const char *name; - struct shash args; + struct smap args; char *option; int error; @@ -349,7 +351,7 @@ do_set_if(int argc, char *argv[]) goto next; } - shash_init(&args); + smap_init(&args); error = netdev_get_config(netdev, &args); if (error) { ovs_error(error, "%s: failed to fetch configuration", name); @@ -374,9 +376,9 @@ do_set_if(int argc, char *argv[]) failure = true; } } else if (value[0] == '\0') { - free(shash_find_and_delete(&args, key)); + smap_remove(&args, key); } else { - free(shash_replace(&args, key, xstrdup(value))); + smap_replace(&args, key, value); } } @@ -499,26 +501,26 @@ show_dpif(struct dpif *dpif) error = netdev_open(dpif_port.name, dpif_port.type, &netdev); if (!error) { - struct shash config; + struct smap config; - shash_init(&config); + smap_init(&config); error = netdev_get_config(netdev, &config); if (!error) { - const struct shash_node **nodes; + const struct smap_node **nodes; size_t i; - 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); + nodes = smap_sort(&config); + for (i = 0; i < smap_count(&config); i++) { + const struct smap_node *node = nodes[i]; + printf("%c %s=%s", i ? ',' : ':', node->key, + node->value); } free(nodes); } else { printf(", could not retrieve configuration (%s)", strerror(error)); } - shash_destroy_free_data(&config); + smap_destroy(&config); netdev_close(netdev); } else { @@ -826,7 +828,7 @@ sort_output_actions(struct nlattr *actions, size_t length) static void do_normalize_actions(int argc, char *argv[]) { - struct shash port_names; + struct simap port_names; struct ofpbuf keybuf; struct flow flow; struct ofpbuf odp_actions; @@ -841,14 +843,15 @@ do_normalize_actions(int argc, char *argv[]) ds_init(&s); - shash_init(&port_names); + simap_init(&port_names); for (i = 3; i < argc; i++) { char name[16]; int number; int n = -1; if (sscanf(argv[i], "%15[^=]=%d%n", name, &number, &n) > 0 && n > 0) { - shash_add(&port_names, name, (void *) number); + uintptr_t n = number; + simap_put(&port_names, name, n); } else { ovs_fatal(0, "%s: expected NAME=NUMBER", argv[i]); }