datapath: Mega flow implementation
[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 "vlog.h"
5 #include "dynamic-string.h"
6
7 VLOG_DEFINE_THIS_MODULE(ofp_version);
8
9 static uint32_t allowed_versions = 0;
10
11 uint32_t
12 get_allowed_ofp_versions(void)
13 {
14     return allowed_versions ? allowed_versions : OFPUTIL_DEFAULT_VERSIONS;
15 }
16
17 void
18 set_allowed_ofp_versions(const char *string)
19 {
20     allowed_versions = ofputil_versions_from_string(string);
21 }
22
23 void
24 mask_allowed_ofp_versions(uint32_t bitmap)
25 {
26     allowed_versions &= bitmap;
27 }
28
29 void
30 ofp_version_usage(void)
31 {
32     struct ds msg = DS_EMPTY_INITIALIZER;
33
34     ofputil_format_version_bitmap_names(&msg, OFPUTIL_DEFAULT_VERSIONS);
35     printf(
36         "\nOpen Flow Version options:\n"
37         "  -V, --version           display version information\n"
38         "  -O, --protocols         set allowed Open Flow versions\n"
39         "                          (default: %s)\n",
40         ds_cstr(&msg));
41     ds_destroy(&msg);
42 }