2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00
ovs/lib/ofp-version-opt.c
Ben Pfaff 0d71302e36 ofp-util, ofp-parse: Break up into many separate modules.
ofp-util had been far too large and monolithic for a long time.  This
commit breaks it up into units that make some logical sense.  It also
moves the pieces of ofp-parse that were specific to each unit into the
relevant unit.

Most of this commit is just moving code around.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
2018-02-13 10:43:13 -08:00

50 lines
1.1 KiB
C

#include <config.h>
#include "openvswitch/dynamic-string.h"
#include "openvswitch/ofp-protocol.h"
#include "ofp-version-opt.h"
#include "ovs-thread.h"
static uint32_t allowed_versions = 0;
uint32_t
get_allowed_ofp_versions(void)
{
return allowed_versions ? allowed_versions : OFPUTIL_DEFAULT_VERSIONS;
}
void
set_allowed_ofp_versions(const char *string)
{
assert_single_threaded();
allowed_versions = ofputil_versions_from_string(string);
}
void
mask_allowed_ofp_versions(uint32_t bitmap)
{
assert_single_threaded();
allowed_versions &= bitmap;
}
void
add_allowed_ofp_versions(uint32_t bitmap)
{
assert_single_threaded();
allowed_versions |= bitmap;
}
void
ofp_version_usage(void)
{
struct ds msg = DS_EMPTY_INITIALIZER;
ofputil_format_version_bitmap_names(&msg, OFPUTIL_DEFAULT_VERSIONS);
printf(
"\nOpenFlow version options:\n"
" -V, --version display version information\n"
" -O, --protocols set allowed OpenFlow versions\n"
" (default: %s)\n",
ds_cstr(&msg));
ds_destroy(&msg);
}