21 #include <boost/algorithm/string.hpp> 27 rc_t::rc_t(
int v,
const std::string s)
28 : enum_base<rc_t>(v, s)
71 return (std::to_string(m_value));
77 return (m_value == other.m_value);
83 return (!(*
this == other));
89 return (m_value < other.m_value);
114 std::copy(b, b + 6, std::begin(bytes));
119 std::copy(i.begin(), i.end(), std::begin(bytes));
124 std::vector<std::string> parts;
126 boost::split(parts, str, boost::is_any_of(
":"));
128 size_t n_bytes = std::min(bytes.size(), parts.size());
130 for (uint32_t ii = 0; ii < n_bytes; ii++) {
131 bytes[ii] = std::stoul(parts[ii],
nullptr, 16);
142 for (
int i = 0;
i < 6 &&
i < len;
i++) {
150 std::ostringstream s;
155 for (
auto byte : bytes) {
160 s << std::setw(2) << static_cast<unsigned int>(byte);
169 return (bytes == mac.
bytes);
174 return (bytes < m.
bytes);
188 std::copy_n(b, n_bytes, std::begin(
bytes));
210 for (uint8_t
i = 0;
i <
bytes.size() &&
i < len;
i++) {
220 std::copy_n(
bytes.begin(), mac.bytes.size(), mac.bytes.begin());
228 std::ostringstream s;
233 for (
auto byte :
bytes) {
238 s << std::setw(2) << static_cast<unsigned int>(byte);
302 if (0x0806 == numeric) {
303 return (ethertype_t::ARP);
305 if (0x8906 == numeric) {
306 return (ethertype_t::FCOE);
308 if (0x0800 == numeric) {
309 return (ethertype_t::IPV4);
311 if (0x86DD == numeric) {
312 return (ethertype_t::IPV6);
314 if (0x88E5 == numeric) {
315 return (ethertype_t::MAC_SECURITY);
317 if (0x8847 == numeric) {
318 return (ethertype_t::MPLS_UNICAST);
320 if (0x22F3 == numeric) {
321 return (ethertype_t::TRILL);
324 return (ethertype_t::UNSPECIFIED);
static const ethertype_t FCOE
Ethertype FCoE.
static const rc_t NOOP
The HW write/update action was/has not been attempted.
static const rc_t & from_vpp_retval(int32_t rv)
Get the rc_t from the VPP API value.
direction_t(int v, const std::string s)
Constructor.
A template base class for all enum types.
uint32_t value() const
get the value of the handle
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
bool operator<(const handle_t &other) const
less than operator
std::string to_string() const
String conversion.
bool operator==(const mac_address_t &m) const
Comparison operator.
Error codes that VPP will return during a HW write.
static const ethertype_t & from_numeric_val(uint16_t numeric)
Get the ethertype from the numeric value.
static const ethertype_t IPV6
Ethertype Ipv6.
static const l2_address_t ZERO
An all 0's L2 address.
static const direction_t INPUT
Permit Direction.
static const handle_t INVALID
A value of an interface handle_t that means the itf does not exist.
Type def of a L2 address as read from VPP.
ethertype_t(int v, const std::string s)
Constructor.
static const l2_address_t ONE
An all 1's L2 address.
std::string to_string() const
convert to string format for debug purposes
static const ethertype_t MAC_SECURITY
Ethertype MAC Security.
bool operator!=(const handle_t &other) const
Comparison operator.
static heap_elt_t * first(heap_header_t *h)
static const ethertype_t IPV4
Ethertype IPv4.
static const mac_address_t ONE
An all 1's MAC address.
std::vector< uint8_t > bytes
Underlying bytes array - filled from least to most significant.
std::string to_string() const
String conversion.
static const ethertype_t TRILL
Ethertype TRILL.
static const ethertype_t ARP
Ethertype Arp.
A type declaration of an interface handle in VPP.
std::array< uint8_t, 6 > bytes
Underlying bytes array.
static const rc_t OK
The HW write was successfull.
static const ethertype_t UNSPECIFIED
Ethertype Unspecified.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
static const rc_t INVALID
HW write reported invalid input.
The VPP Object Model (VOM) library.
bool operator<(const mac_address_t &m) const
less than operator
void reset()
reset the value of the handle to ~0
static const rc_t UNSET
The value un-set.
bool operator==(const handle_t &other) const
Comparison operator.
bool operator==(const l2_address_t &m) const
Comparison operator.
static const ethertype_t MPLS_UNICAST
Ethertype MPLS unicast.
static const direction_t OUTPUT
Deny Direction.
const std::string & to_string() const
convert to string format for debug purposes
mac_address_t to_mac() const
MAC address conversion.
mac_address_t(uint8_t bytes[6])
Type def of a Ethernet address.
static const mac_address_t ZERO
An all 0's MAC address.
bool operator!=(const l2_address_t &m) const
Comparison operator.
static const rc_t TIMEOUT
HW write timedout - VPP did not respond within a timely manner.
l2_address_t(const uint8_t bytes[8], uint8_t n_bytes)