21 #include <boost/algorithm/string.hpp> 28 : enum_base<rc_t>(v, s)
33 rc_t::from_vpp_retval(int32_t rv)
47 return (rc_t::INVALID);
51 const rc_t rc_t::NOOP(1,
"no-op");
52 const rc_t rc_t::OK(2,
"ok");
53 const rc_t rc_t::INVALID(3,
"invalid");
56 const handle_t handle_t::INVALID(~0);
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));
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);
330 os <<
"[packets: " << c.
packets <<
" bytes:" << c.
bytes <<
"]";
static const ethertype_t FCOE
Ethertype FCoE.
std::string to_string() const
String conversion.
direction_t(int v, const std::string s)
Constructor.
uint32_t value() const
get the value of the handle
A template base class for all enum types.
bool operator==(const handle_t &other) const
Comparison operator.
mac_address_t(const uint8_t bytes[6])
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.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
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.
bool operator==(const l2_address_t &m) const
Comparison operator.
bool operator==(const mac_address_t &m) const
Comparison operator.
static const ethertype_t MAC_SECURITY
Ethertype MAC Security.
bool operator<(const handle_t &other) const
less than operator
bool operator!=(const l2_address_t &m) 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.
mac_address_t to_mac() const
MAC address conversion.
std::vector< uint8_t > bytes
Underlying bytes array - filled from least to most significant.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
sll srl srl sll sra u16x4 i
std::string to_string() const
convert to string format for debug purposes
static const ethertype_t TRILL
Ethertype TRILL.
static const ethertype_t ARP
Ethertype Arp.
A type declaration of an interface handle in VPP.
const std::string & to_string() const
convert to string format for debug purposes
std::array< uint8_t, 6 > bytes
Underlying bytes array.
static const ethertype_t UNSPECIFIED
Ethertype Unspecified.
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
std::string to_string() const
String conversion.
bool operator<(const mac_address_t &m) const
less than operator
The VPP Object Model (VOM) library.
void reset()
reset the value of the handle to ~0
static const ethertype_t MPLS_UNICAST
Ethertype MPLS unicast.
static const direction_t OUTPUT
Deny Direction.
bool operator!=(const handle_t &other) const
Comparison operator.
f64 end
end of the time range
Type def of a Ethernet address.
static const mac_address_t ZERO
An all 0's MAC address.
l2_address_t(const uint8_t bytes[8], uint8_t n_bytes)