Signed-off-by: Simon Horman <[email protected]>
---
lib/automake.mk | 3 +++
lib/ofp-version-opt.c | 32 ++++++++++++++++++++++++++++++++
lib/ofp-version-opt.h | 39 +++++++++++++++++++++++++++++++++++++++
lib/ofp-version.man | 23 +++++++++++++++++++++++
4 files changed, 97 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 94b86f6..1f90419 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 \
@@ -282,6 +284,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..ec5d3cc
--- /dev/null
+++ b/lib/ofp-version-opt.c
@@ -0,0 +1,32 @@
+#include <config.h>
+#include "ofp-util.h"
+#include "ofp-version-opt.h"
+#include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(ofp_version);
+
+enum ofp_version min_ofp_version = DEFAULT_MIN_OFP_VERSION;
+enum ofp_version max_ofp_version = DEFAULT_MAX_OFP_VERSION;
+
+void
+ofp_version_check(void)
+{
+ if (min_ofp_version > max_ofp_version) {
+ VLOG_FATAL("maximum Open Flow version must not be less than the "
+ "minimum Open Flow version");
+ }
+}
+
+void
+ofp_version_usage(void)
+{
+ printf(
+ "\nOpen Flow Version options:\n"
+ " -V, --version display version information\n"
+ " --min-ofp-version minimum ofp version\n"
+ " (default: %s)\n"
+ " --max-ofp-version maximum ofp version\n"
+ " (default: %s)\n",
+ ofputil_version_to_string(DEFAULT_MIN_OFP_VERSION),
+ ofputil_version_to_string(DEFAULT_MAX_OFP_VERSION));
+}
diff --git a/lib/ofp-version-opt.h b/lib/ofp-version-opt.h
new file mode 100644
index 0000000..f9a1703
--- /dev/null
+++ b/lib/ofp-version-opt.h
@@ -0,0 +1,39 @@
+#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_MIN_OFP_VERSION, \
+ OPT_MAX_OFP_VERSION
+
+#define OFP_VERSION_LONG_OPTIONS \
+ {"version", no_argument, NULL, 'V'}, \
+ {"min-ofp-version", required_argument, NULL, OPT_MIN_OFP_VERSION}, \
+ {"max-ofp-version", required_argument, NULL, OPT_MAX_OFP_VERSION}
+
+#define OFP_VERSION_OPTION_HANDLERS \
+ case 'V': \
+ ovs_print_version(OFP10_VERSION, OFP12_VERSION); \
+ exit(EXIT_SUCCESS); \
+ \
+ case OPT_MIN_OFP_VERSION: \
+ min_ofp_version = ofputil_version_from_string(optarg); \
+ break; \
+ \
+ case OPT_MAX_OFP_VERSION: \
+ max_ofp_version = ofputil_version_from_string(optarg); \
+ break;
+
+#define DEFAULT_MIN_OFP_VERSION OFP10_VERSION
+#define DEFAULT_MAX_OFP_VERSION OFP10_VERSION
+
+extern enum ofp_version min_ofp_version;
+extern enum ofp_version max_ofp_version;
+
+void ofp_version_check(void);
+void ofp_version_usage(void);
+
+#endif
diff --git a/lib/ofp-version.man b/lib/ofp-version.man
new file mode 100644
index 0000000..a25d45e
--- /dev/null
+++ b/lib/ofp-version.man
@@ -0,0 +1,23 @@
+.IP "\fB\-\-min\-ofp-version=\fIversion\fR"
+.IQ "\fB\-\-max\-ofp-version=\fIversion\fR"
+\fBovs\-vswitchd\fR supports the following OpenFlow protocol versions.
+-\-min\-ofp-version and -\-max\-ofp-version set upper and lower bounds
+on the version that may be negotiated when establishing a session. By
+default both -\-min\-ofp-version and -\-max\-ofp-version are set to
+"\fBOpenFlow10\fR".
+.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
[email protected]
http://openvswitch.org/mailman/listinfo/dev