Files
scylladb/utils/fb_utilities.hh
Avi Kivity fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00

62 lines
1.4 KiB
C++

/*
*/
/*
* Modified by ScyllaDB
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#pragma once
#include <cstdint>
#include <optional>
#include "gms/inet_address.hh"
namespace utils {
using inet_address = gms::inet_address;
class fb_utilities {
private:
static std::optional<inet_address>& broadcast_address() noexcept {
static std::optional<inet_address> _broadcast_address;
return _broadcast_address;
}
static std::optional<inet_address>& broadcast_rpc_address() noexcept {
static std::optional<inet_address> _broadcast_rpc_address;
return _broadcast_rpc_address;
}
public:
static constexpr int32_t MAX_UNSIGNED_SHORT = 0xFFFF;
static void set_broadcast_address(inet_address addr) noexcept {
broadcast_address() = addr;
}
static void set_broadcast_rpc_address(inet_address addr) noexcept {
broadcast_rpc_address() = addr;
}
static const inet_address get_broadcast_address() noexcept {
assert(broadcast_address());
return *broadcast_address();
}
static const inet_address get_broadcast_rpc_address() noexcept {
assert(broadcast_rpc_address());
return *broadcast_rpc_address();
}
static bool is_me(gms::inet_address addr) noexcept {
return addr == get_broadcast_address();
}
};
}