vconn: Fix formatting of user message.
[sliver-openvswitch.git] / lib / ofp-version-opt.c
1 #include <config.h>
2 #include "ofp-util.h"
3 #include "ofp-version-opt.h"
4 #include "ovs-thread.h"
5 #include "vlog.h"
6 #include "dynamic-string.h"
7
8 VLOG_DEFINE_THIS_MODULE(ofp_version);
9
10 static uint32_t allowed_versions = 0;
11
12 uint32_t
13 get_allowed_ofp_versions(void)
14 {
15     return allowed_versions ? allowed_versions : OFPUTIL_DEFAULT_VERSIONS;
16 }
17
18 void
19 set_allowed_ofp_versions(const char *string)
20 {
21     assert_single_threaded();
22     allowed_versions = ofputil_versions_from_string(string);
23 }
24
25 void
26 mask_allowed_ofp_versions(uint32_t bitmap)
27 {
28     assert_single_threaded();
29     allowed_versions &= bitmap;
30 }
31
32 void
33 ofp_version_usage(void)
34 {
35     struct ds msg = DS_EMPTY_INITIALIZER;
36
37     ofputil_format_version_bitmap_names(&msg, OFPUTIL_DEFAULT_VERSIONS);
38     printf(
39         "\nOpen Flow Version options:\n"
40         "  -V, --version           display version information\n"
41         "  -O, --protocols         set allowed Open Flow versions\n"
42         "                          (default: %s)\n",
43         ds_cstr(&msg));
44     ds_destroy(&msg);
45 }