]>
git.proxmox.com Git - ovs.git/blob - utilities/ovs-dpctl.c
2 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <arpa/inet.h>
22 #include <sys/socket.h>
24 #include <netinet/in.h>
33 #include "command-line.h"
37 #include "fatal-signal.h"
39 #include "ofp-parse.h"
45 static struct dpctl_params dpctl_p
;
47 NO_RETURN
static void usage(void *userdata OVS_UNUSED
);
48 static void parse_options(int argc
, char *argv
[]);
51 dpctl_print(void *userdata OVS_UNUSED
, bool error
, const char *msg
)
53 FILE *outfile
= error
? stderr
: stdout
;
58 main(int argc
, char *argv
[])
61 set_program_name(argv
[0]);
62 parse_options(argc
, argv
);
63 fatal_ignore_sigpipe();
65 dpctl_p
.is_appctl
= false;
66 dpctl_p
.output
= dpctl_print
;
67 dpctl_p
.usage
= usage
;
69 error
= dpctl_run_command(argc
- optind
, (const char **) argv
+ optind
,
71 return error
? EXIT_FAILURE
: EXIT_SUCCESS
;
75 parse_options(int argc
, char *argv
[])
78 OPT_CLEAR
= UCHAR_MAX
+ 1,
82 static const struct option long_options
[] = {
83 {"statistics", no_argument
, NULL
, 's'},
84 {"clear", no_argument
, NULL
, OPT_CLEAR
},
85 {"may-create", no_argument
, NULL
, OPT_MAY_CREATE
},
86 {"more", no_argument
, NULL
, 'm'},
87 {"timeout", required_argument
, NULL
, 't'},
88 {"help", no_argument
, NULL
, 'h'},
89 {"option", no_argument
, NULL
, 'o'},
90 {"version", no_argument
, NULL
, 'V'},
94 char *short_options
= long_options_to_short_options(long_options
);
97 unsigned long int timeout
;
100 c
= getopt_long(argc
, argv
, short_options
, long_options
, NULL
);
107 dpctl_p
.print_statistics
= true;
111 dpctl_p
.zero_statistics
= true;
115 dpctl_p
.may_create
= true;
123 timeout
= strtoul(optarg
, NULL
, 10);
125 ovs_fatal(0, "value %s on -t or --timeout is not at least 1",
136 print_options(long_options
);
140 ovs_print_version(0, 0);
156 usage(void *userdata OVS_UNUSED
)
158 printf("%s: Open vSwitch datapath management utility\n"
159 "usage: %s [OPTIONS] COMMAND [ARG...]\n"
160 " add-dp DP [IFACE...] add new datapath DP (with IFACEs)\n"
161 " del-dp DP delete local datapath DP\n"
162 " add-if DP IFACE... add each IFACE as a port on DP\n"
163 " set-if DP IFACE... reconfigure each IFACE within DP\n"
164 " del-if DP IFACE... delete each IFACE from DP\n"
165 " dump-dps display names of all datapaths\n"
166 " show show basic info on all datapaths\n"
167 " show DP... show basic info on each DP\n"
168 " dump-flows [DP] display flows in DP\n"
169 " add-flow [DP] FLOW ACTIONS add FLOW with ACTIONS to DP\n"
170 " mod-flow [DP] FLOW ACTIONS change FLOW actions to ACTIONS in DP\n"
171 " del-flow [DP] FLOW delete FLOW from DP\n"
172 " del-flows [DP] delete all flows from DP\n"
173 "Each IFACE on add-dp, add-if, and set-if may be followed by\n"
174 "comma-separated options. See ovs-dpctl(8) for syntax, or the\n"
175 "Interface table in ovs-vswitchd.conf.db(5) for an options list.\n"
176 "For COMMAND dump-flows, add-flow, mod-flow, del-flow and\n"
177 "del-flows, DP is optional if there is only one datapath.\n",
178 program_name
, program_name
);
180 printf("\nOptions for show and mod-flow:\n"
181 " -s, --statistics print statistics for port or flow\n"
182 "\nOptions for dump-flows:\n"
183 " -m, --more increase verbosity of output\n"
184 "\nOptions for mod-flow:\n"
185 " --may-create create flow if it doesn't exist\n"
186 " --clear reset existing stats to zero\n"
188 " -t, --timeout=SECS give up after SECS seconds\n"
189 " -h, --help display this help message\n"
190 " -V, --version display version information\n");