Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v4 * Rebase --- lib/automake.mk | 3 +++ lib/ofp-version-opt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/ofp-version-opt.h | 28 ++++++++++++++++++++++++++++ lib/ofp-version.man | 26 ++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 lib/ofp-version-opt.c create mode 100644 lib/ofp-version-opt.h create mode 100644 lib/ofp-version.man diff --git a/lib/automake.mk b/lib/automake.mk index f6b2aa1..740f33f 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -111,6 +111,8 @@ lib_libopenvswitch_a_SOURCES = \ lib/ofp-util.c \ lib/ofp-util.def \ lib/ofp-util.h \ + lib/ofp-version-opt.h \ + lib/ofp-version-opt.c \ lib/ofpbuf.c \ lib/ofpbuf.h \ lib/ovsdb-data.c \ @@ -287,6 +289,7 @@ MAN_FRAGMENTS += \ lib/daemon-syn.man \ lib/leak-checker.man \ lib/memory-unixctl.man \ + lib/ofp-version.man \ lib/ovs.tmac \ lib/ssl-bootstrap.man \ lib/ssl-bootstrap-syn.man \ diff --git a/lib/ofp-version-opt.c b/lib/ofp-version-opt.c new file mode 100644 index 0000000..3a3bde0 --- /dev/null +++ b/lib/ofp-version-opt.c @@ -0,0 +1,42 @@ +#include <config.h> +#include "ofp-util.h" +#include "ofp-version-opt.h" +#include "vlog.h" +#include "dynamic-string.h" + +VLOG_DEFINE_THIS_MODULE(ofp_version); + +static uint32_t allowed_versions = 0; +static bool allowed_versions_set = false; + +uint32_t +get_allowed_ofp_versions(void) +{ + if (!allowed_versions_set) { + return ofputil_get_allowed_versions_default(); + } + return allowed_versions; +} + +void +ofp_version_usage(void) +{ + struct ds msg = DS_EMPTY_INITIALIZER; + + ofputil_format_version_bitmap_names(&msg, + ofputil_get_allowed_versions_default()); + printf( + "\nOpen Flow Version options:\n" + " -V, --version display version information\n" + " --allowed-ofp-versions list of allowed Open Flow versions\n" + " (default: %s)\n", + ds_cstr(&msg)); + ds_destroy(&msg); +} + +void +ofp_versions_from_string(const char *string) +{ + allowed_versions = ofputil_versions_from_string(string); + allowed_versions_set = true; +} diff --git a/lib/ofp-version-opt.h b/lib/ofp-version-opt.h new file mode 100644 index 0000000..d59e7cc --- /dev/null +++ b/lib/ofp-version-opt.h @@ -0,0 +1,28 @@ +#ifndef OFP_VERSION_H +#define OFP_VERSION_H 1 + +#include <openflow/openflow-common.h> +#include "util.h" +#include "ofp-util.h" + +#define OFP_VERSION_OPTION_ENUMS \ + OPT_ALLOWED_OFP_VERSION + +#define OFP_VERSION_LONG_OPTIONS \ + {"version", no_argument, NULL, 'V'}, \ + {"allowed-ofp-versions", required_argument, NULL, OPT_ALLOWED_OFP_VERSION} + +#define OFP_VERSION_OPTION_HANDLERS \ + case 'V': \ + ovs_print_version(OFP10_VERSION, OFP12_VERSION); \ + exit(EXIT_SUCCESS); \ + \ + case OPT_ALLOWED_OFP_VERSION: \ + ofp_versions_from_string(optarg); \ + break; + +uint32_t get_allowed_ofp_versions(void); +void ofp_version_usage(void); +void ofp_versions_from_string(const char *string); + +#endif diff --git a/lib/ofp-version.man b/lib/ofp-version.man new file mode 100644 index 0000000..a87a744 --- /dev/null +++ b/lib/ofp-version.man @@ -0,0 +1,26 @@ +.IP "\fB\-\-allowed\-ofp-versions=\fI[version[,version]...]\fR" +-\-allowed\-ofp-versions designates the versions that are allowed +when establishing an OpenFlow session. By default 'OpenFlow10' is used. +The allowed versions of ovs-vswitchd should be configured using +the 'openflow-versions' column of the 'other-config' row +of the Bridges table in ovsdb. The syntax of its value +is the same as the value of -\-allowed\-ofp-versions. +. +.IP +The known versions are: +.RS +.IP \(bu +\fBOpenFlow10\fR +. +.IP \(bu +\fBOpenFlow11\fR (Experimental Implementation) +. +.IP \(bu +\fBOpenFlow12\fR (Experimental Implementation) +.RE +. +.IP +N.B: Currently only \fBOpenFlow10\fR is considered to be ready +for general consumption. The option to enable \fBOpenFlow11\fR and +\fBOpenFlow12\fR is currently provided for development purposes. +. -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev