Bring manpages and usage messages up-to-date.
[openvswitch] / utilities / dpctl.c
index a66975a0c6525bcc9d8374835cb87ba45fdb667b..2d09e98e0aa1d04c702b03fac47a621cde84f0e9 100644 (file)
@@ -171,12 +171,15 @@ usage(void)
            "  dump-ports SWITCH           print port statistics\n"
            "  dump-flows SWITCH           print all flow entries\n"
            "  dump-flows SWITCH FLOW      print matching FLOWs\n"
+           "  dump-aggregate SWITCH       print aggregate flow statistics\n"
+           "  dump-aggregate SWITCH FLOW  print aggregate stats for FLOWs\n"
            "  add-flows SWITCH FILE       add flows from FILE\n"
            "  del-flows SWITCH FLOW       delete matching FLOWs\n"
            "where each SWITCH is an active OpenFlow connection method.\n",
            program_name, program_name);
     vconn_usage(true, false);
     printf("\nOptions:\n"
+           "  -v, --verbose=MODULE:FACILITY:LEVEL  configure logging levels\n"
            "  -v, --verbose               set maximum verbosity level\n"
            "  -h, --help                  display this help message\n"
            "  -V, --version               display version information\n");
@@ -499,10 +502,16 @@ str_to_action(const char *str, struct ofp_action *action)
 {
     uint16_t port;
 
-    if (!strcasecmp(str, "flood")) {
+    if (!strcasecmp(str, "normal")) {
+        port = OFPP_NORMAL;
+    } else if (!strcasecmp(str, "flood")) {
         port = OFPP_FLOOD;
+    } else if (!strcasecmp(str, "all")) {
+        port = OFPP_ALL;
     } else if (!strcasecmp(str, "controller")) {
         port = OFPP_CONTROLLER;
+    } else if (!strcasecmp(str, "local")) {
+        port = OFPP_LOCAL;
     } else {
         port = str_to_int(str);
     }
@@ -549,9 +558,9 @@ str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
     }
     memset(match, 0, sizeof *match);
     wildcards = OFPFW_ALL;
-    for (name = strtok(string, "="), value = strtok(NULL, " \t\n");
+    for (name = strtok(string, "="), value = strtok(NULL, ", \t\r\n");
          name && value;
-         name = strtok(NULL, "="), value = strtok(NULL, " \t\n"))
+         name = strtok(NULL, "="), value = strtok(NULL, ", \t\r\n"))
     {
         const struct field *f;
         void *data;
@@ -590,7 +599,7 @@ str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
 
     found:
         data = (char *) match + f->offset;
-        if (!strcmp(value, "*")) {
+        if (!strcmp(value, "*") || !strcmp(value, "ANY")) {
             wildcards |= f->wildcard;
         } else {
             wildcards &= ~f->wildcard;
@@ -624,8 +633,20 @@ static void do_dump_flows(int argc, char *argv[])
     req = alloc_stats_request(sizeof *req, OFPST_FLOW, &request);
     str_to_flow(argc > 2 ? argv[2] : "", &req->match, NULL, &req->table_id, 
             NULL);
-    req->type = OFPFS_INDIV;
-    req->pad = 0;
+    memset(req->pad, 0, sizeof req->pad);
+
+    dump_stats_transaction(argv[1], request);
+}
+
+static void do_dump_aggregate(int argc, char *argv[])
+{
+    struct ofp_aggregate_stats_request *req;
+    struct buffer *request;
+
+    req = alloc_stats_request(sizeof *req, OFPST_AGGREGATE, &request);
+    str_to_flow(argc > 2 ? argv[2] : "", &req->match, NULL, &req->table_id,
+                NULL);
+    memset(req->pad, 0, sizeof req->pad);
 
     dump_stats_transaction(argv[1], request);
 }
@@ -681,6 +702,7 @@ static void do_add_flows(int argc, char *argv[])
 static void do_del_flows(int argc, char *argv[])
 {
     struct vconn *vconn;
+    uint16_t priority;
 
     run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
     struct buffer *buffer;
@@ -691,12 +713,12 @@ static void do_del_flows(int argc, char *argv[])
     /* Parse and send. */
     size = sizeof *ofm;
     ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
+    str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL, &priority);
     ofm->command = htons(OFPFC_DELETE);
     ofm->max_idle = htons(0);
     ofm->buffer_id = htonl(UINT32_MAX);
-    ofm->priority = htons(0);
+    ofm->priority = htons(priority);
     ofm->reserved = htonl(0);
-    str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL, NULL);
 
     send_openflow_buffer(vconn, buffer);
 
@@ -729,6 +751,7 @@ static struct command all_commands[] = {
     { "monitor", 1, 1, do_monitor },
     { "dump-tables", 1, 1, do_dump_tables },
     { "dump-flows", 1, 2, do_dump_flows },
+    { "dump-aggregate", 1, 2, do_dump_aggregate },
     { "add-flows", 2, 2, do_add_flows },
     { "del-flows", 1, 2, do_del_flows },
     { "dump-ports", 1, 1, do_dump_ports },