diff --git a/EosSdk.i b/EosSdk.i index c5c015c..fa4cf48 100644 --- a/EosSdk.i +++ b/EosSdk.i @@ -27,7 +27,7 @@ except ImportError: // Change all some_class_t names to just SomeClass: // The <<""< uses automatic string concatination to get around the // conflict marker limitation. -%rename("%(command:python $SRCDIR/SwigRenamer.py --classname <<""<)s", %$isclass) ""; +%rename("%(command:python3 $SRCDIR/SwigRenamer.py --classname <<""<)s", %$isclass) ""; // Don't do anything for enum values, functions or variables. // Cause SWIG to produce basic documentation in the generated eossdk.py @@ -169,14 +169,11 @@ typedef uint64_t uint64_be_t; %feature("nodirector") eos::eth_phy_intf_mgr; %feature("nodirector") eos::eth_phy_intf_counter_mgr; %feature("nodirector") eos::fib_mgr; -%feature("nodirector") eos::fpga_mgr; -%feature("nodirector") eos::ham_mgr; %feature("nodirector") eos::hardware_table_mgr; %feature("nodirector") eos::intf_mgr; %feature("nodirector") eos::intf_counter_mgr; %feature("nodirector") eos::ip_intf_mgr; %feature("nodirector") eos::ip_route_mgr; -%feature("nodirector") eos::l1_source_mgr; %feature("nodirector") eos::lldp_mgr; %feature("nodirector") eos::macsec_mgr; %feature("nodirector") eos::mac_table_mgr; @@ -194,10 +191,12 @@ typedef uint64_t uint64_be_t; %feature("nodirector") eos::vrf_mgr; %feature("nodirector") eos::xcvr_mgr; -// Do not generate Python bindings for the old programmed callback in the extended -// nexthop group handler class +// Do not generate Python bindings for the old programmed callbacks in the extended +// nexthop group handlers %feature("nodirector") eos::nexthop_group_handler_v2::on_nexthop_group_programmed( std::string const &); +%feature("nodirector") eos::nexthop_group_handler_v3::on_nexthop_group_programmed( + std::string const &); %{ #include "eos/acl.h" @@ -218,8 +217,6 @@ typedef uint64_t uint64_be_t; #include "eos/exception.h" #include "eos/fd.h" #include "eos/fib.h" -#include "eos/fpga.h" -#include "eos/ham.h" #include "eos/hardware_table.h" #include "eos/hash_mix.h" #include "eos/intf.h" @@ -227,7 +224,6 @@ typedef uint64_t uint64_be_t; #include "eos/ip_intf.h" #include "eos/ip_route.h" #include "eos/iterator.h" -#include "eos/l1_source.h" #include "eos/lldp.h" #include "eos/macsec.h" #include "eos/mac_table.h" @@ -407,9 +403,6 @@ wrap_iterator(eos::class_map_iter_t, eos::class_map_iter_impl, eos::class_map_ke wrap_iterator(eos::fib_fec_iter_t, eos::fib_fec_iter_impl, eos::fib_fec_t); wrap_iterator(eos::fib_route_iter_t, eos::fib_route_iter_impl, eos::fib_route_t); wrap_iterator(eos::flow_entry_iter_t, eos::flow_entry_iter_impl, eos::flow_entry_t); -wrap_iterator(eos::fpga_iter_t, eos::fpga_iter_impl, eos::fpga_t); -wrap_iterator(eos::fpga_reservation_iter_t, eos::fpga_reservation_iter_impl, eos::fpga_reservation_t); -wrap_iterator(eos::fpga_reservation_status_iter_t, eos::fpga_reservation_status_iter_impl, eos::fpga_reservation_status_t); wrap_iterator(eos::eth_intf_iter_t, eos::eth_intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::eth_lag_intf_iter_t, eos::eth_lag_intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::eth_lag_intf_member_iter_t, eos::eth_lag_intf_member_iter_impl, eos::intf_id_t); @@ -419,7 +412,6 @@ wrap_iterator(eos::intf_iter_t, eos::intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::ip_route_iter_t, eos::ip_route_iter_impl, eos::ip_route_t); wrap_iterator(eos::ip_route_via_iter_t, eos::ip_route_via_iter_impl, eos::ip_route_via_t); wrap_iterator(eos::decap_group_iter_t, eos::decap_group_iter_impl, eos::decap_group_t); -wrap_iterator(eos::l1_source_iter_t, eos::l1_source_iter_impl, eos::intf_id_t); wrap_iterator(eos::lldp_remote_system_iter_t, eos::lldp_remote_system_iter_impl, lldp_remote_system_t); wrap_iterator(eos::lldp_intf_iter_t, eos::lldp_intf_iter_impl, intf_id_t); wrap_iterator(eos::lldp_neighbor_iter_t, eos::lldp_neighbor_iter_impl, lldp_neighbor_t); diff --git a/GoEosSdk.i b/GoEosSdk.i index 219e640..22f21b4 100644 --- a/GoEosSdk.i +++ b/GoEosSdk.i @@ -27,7 +27,7 @@ // Change all some_class_t names to just SomeClass: // The <<""< uses automatic string concatination to get around the // conflict marker limitation. -%rename("%(command:python $SRCDIR/SwigRenamer.py --classname --go <<""<)s", %$isclass) ""; +%rename("%(command:python3 $SRCDIR/SwigRenamer.py --classname --go <<""<)s", %$isclass) ""; // Don't do anything for enum values, functions or variables. // Cause SWIG to produce basic documentation in the generated eossdk.go @@ -80,14 +80,11 @@ typedef uint64_t uint64_be_t; %feature("nodirector") eos::eth_phy_intf_mgr; %feature("nodirector") eos::eth_phy_intf_counter_mgr; %feature("nodirector") eos::fib_mgr; -%feature("nodirector") eos::fpga_mgr; -%feature("nodirector") eos::ham_mgr; %feature("nodirector") eos::hardware_table_mgr; %feature("nodirector") eos::intf_mgr; %feature("nodirector") eos::intf_counter_mgr; %feature("nodirector") eos::ip_intf_mgr; %feature("nodirector") eos::ip_route_mgr; -%feature("nodirector") eos::l1_source_mgr; %feature("nodirector") eos::lldp_mgr; %feature("nodirector") eos::macsec_mgr; %feature("nodirector") eos::mac_table_mgr; @@ -124,8 +121,6 @@ typedef uint64_t uint64_be_t; #include "eos/exception.h" #include "eos/fd.h" #include "eos/fib.h" -#include "eos/fpga.h" -#include "eos/ham.h" #include "eos/hardware_table.h" #include "eos/hash_mix.h" #include "eos/intf.h" @@ -133,7 +128,6 @@ typedef uint64_t uint64_be_t; #include "eos/ip_intf.h" #include "eos/ip_route.h" #include "eos/iterator.h" -#include "eos/l1_source.h" #include "eos/lldp.h" #include "eos/macsec.h" #include "eos/mac_table.h" @@ -237,7 +231,6 @@ wrap_iterator(eos::class_map_iter_t, eos::class_map_iter_impl, eos::class_map_ke wrap_iterator(eos::fib_fec_iter_t, eos::fib_fec_iter_impl, eos::fib_fec_t); wrap_iterator(eos::fib_route_iter_t, eos::fib_route_iter_impl, eos::fib_route_t); wrap_iterator(eos::flow_entry_iter_t, eos::flow_entry_iter_impl, eos::flow_entry_t); -wrap_iterator(eos::fpga_iter_t, eos::fpga_iter_impl, eos::fpga_t); wrap_iterator(eos::eth_intf_iter_t, eos::eth_intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::eth_lag_intf_iter_t, eos::eth_lag_intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::eth_lag_intf_member_iter_t, eos::eth_lag_intf_member_iter_impl, eos::intf_id_t); @@ -247,7 +240,6 @@ wrap_iterator(eos::intf_iter_t, eos::intf_iter_impl, eos::intf_id_t); wrap_iterator(eos::ip_route_iter_t, eos::ip_route_iter_impl, eos::ip_route_t); wrap_iterator(eos::ip_route_via_iter_t, eos::ip_route_via_iter_impl, eos::ip_route_via_t); wrap_iterator(eos::decap_group_iter_t, eos::decap_group_iter_impl, eos::decap_group_t); -wrap_iterator(eos::l1_source_iter_t, eos::l1_source_iter_impl, eos::intf_id_t); wrap_iterator(eos::lldp_remote_system_iter_t, eos::lldp_remote_system_iter_impl, lldp_remote_system_t); wrap_iterator(eos::lldp_intf_iter_t, eos::lldp_intf_iter_impl, intf_id_t); wrap_iterator(eos::lldp_neighbor_iter_t, eos::lldp_neighbor_iter_impl, lldp_neighbor_t); diff --git a/Includes.i b/Includes.i index 7248d87..a5b5403 100644 --- a/Includes.i +++ b/Includes.i @@ -14,14 +14,13 @@ %include "eos/types/intf.h" %include "eos/types/bfd.h" %include "eos/types/eth_phy_intf.h" -%include "eos/types/fpga.h" -%include "eos/types/ham.h" %include "eos/types/hardware_table.h" %include "eos/types/lldp.h" %include "eos/types/macsec.h" %include "eos/types/mpls.h" %include "eos/types/mpls_vrf_label.h" %include "eos/types/nexthop_group.h" +%include "eos/types/structured_filter.h" %include "eos/types/vrf.h" %include "eos/types/subintf.h" %include "eos/ip.h" @@ -35,7 +34,6 @@ %include "eos/types/eth_lag_intf.h" %include "eos/mpls.h" %include "eos/types/ip_route.h" -%include "eos/types/l1_source.h" %include "eos/types/mac_table.h" %include "eos/types/mpls_route.h" %include "eos/types/neighbor_table.h" @@ -67,16 +65,12 @@ %include "eos/inline/types/eapi.h" %include "eos/inline/types/sdk.h" %include "eos/timer.h" -%include "eos/fpga.h" -%include "eos/ham.h" %include "eos/hardware_table.h" %include "eos/inline/agent.h" %include "eos/inline/types/acl.h" %include "eos/inline/types/bfd.h" %include "eos/inline/types/eth.h" %include "eos/inline/types/eth_phy_intf.h" -%include "eos/inline/types/fpga.h" -%include "eos/inline/types/ham.h" %include "eos/inline/types/hardware_table.h" %include "eos/inline/types/intf.h" %include "eos/inline/types/ip.h" @@ -85,6 +79,7 @@ %include "eos/inline/types/mpls.h" %include "eos/inline/types/mpls_vrf_label.h" %include "eos/inline/types/nexthop_group.h" +%include "eos/inline/types/structured_filter.h" %include "eos/inline/types/vrf.h" %include "eos/sdk.h" %include "eos/vrf.h" @@ -92,8 +87,6 @@ %include "eos/bfd.h" %include "eos/eth_intf.h" %include "eos/eth_phy_intf.h" -%include "eos/inline/fpga.h" -%include "eos/inline/ham.h" %include "eos/inline/hardware_table.h" %include "eos/inline/intf.h" %include "eos/inline/sdk.h" @@ -128,12 +121,10 @@ %include "eos/inline/types/directflow.h" %include "eos/inline/types/eth_lag_intf.h" %include "eos/inline/types/ip_route.h" -%include "eos/inline/types/l1_source.h" %include "eos/inline/types/mac_table.h" %include "eos/inline/types/mpls_route.h" %include "eos/inline/types/neighbor_table.h" %include "eos/inline/types/nexthop_group_tunnel.h" -%include "eos/l1_source.h" %include "eos/mac_table.h" %include "eos/mpls_route.h" %include "eos/mpls_vrf_label.h" @@ -144,7 +135,6 @@ %include "eos/inline/bgp_path.h" %include "eos/inline/directflow.h" %include "eos/inline/eth_lag_intf.h" -%include "eos/inline/l1_source.h" %include "eos/inline/mac_table.h" %include "eos/inline/mpls_route.h" %include "eos/inline/neighbor_table.h" diff --git a/Makefile.am b/Makefile.am index b31e63d..0a0cb05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,8 +2,10 @@ lib_LTLIBRARIES = libeos.la AM_CXXFLAGS = -fvisibility=hidden AM_CXXFLAGS += -Wextra -Wall -Wnon-virtual-dtor -Werror -Wno-unused-parameter -Wno-error=unused-value +AM_CXXFLAGS += $(EXTRA_CFLAGS) AM_LDFLAGS = -Wl,--no-undefined + PUBLISHED_HEADER_FILES := $(wildcard eos/*.h) $(wildcard eos/inline/*.h) $(wildcard eos/types/*.h) $(wildcard eos/inline/types/*.h) nobase_include_HEADERS = $(PUBLISHED_HEADER_FILES) @@ -39,7 +41,6 @@ libeos_la_SOURCES += eth_phy_intf.cpp libeos_la_SOURCES += event_loop.cpp libeos_la_SOURCES += exception.cpp libeos_la_SOURCES += fd.cpp -libeos_la_SOURCES += ham.cpp libeos_la_SOURCES += hardware_table.cpp libeos_la_SOURCES += intf.cpp libeos_la_SOURCES += intf_types.cpp @@ -49,9 +50,7 @@ libeos_la_SOURCES += ip_types.cpp libeos_la_SOURCES += ip_intf.cpp libeos_la_SOURCES += ip_route.cpp libeos_la_SOURCES += fib.cpp -libeos_la_SOURCES += fpga.cpp libeos_la_SOURCES += iterator.cpp -libeos_la_SOURCES += l1_source.cpp libeos_la_SOURCES += macsec.cpp libeos_la_SOURCES += mac_table.cpp libeos_la_SOURCES += mlag.cpp @@ -79,13 +78,14 @@ libeos_la_SOURCES += lldp.cpp libeos_la_SOURCES += xcvr.cpp libeos_la_SOURCES += nexthop_group_tunnel.cpp -libeos_la_CPPFLAGS = $(AM_CPPFLAGS) $(SHIPPING_FLAG) +libeos_la_CPPFLAGS = $(AM_CPPFLAGS) $(SHIPPING_FLAG) -fPIC -fPIE libeos_la_LDFLAGS = -version-info $(SDK_LIBTOOL_VERSION) -lrt libeos_la_LDFLAGS += -soname libeos.so.$(SDK_VERSION_MAJOR).$(SDK_VERSION_MINOR) noinst_PROGRAMS = HelloWorld HelloWorld_SOURCES = examples/HelloWorld.cpp HelloWorld_LDADD = libeos.la +HelloWorld_CPPFLAGS = -fPIE # --------- # # SWIG libs # @@ -106,8 +106,7 @@ _eossdk_la_CPPFLAGS = -I/usr/include/python$(PYTHON_VERSION) _eossdk_la_LIBADD = libeos.la $(srcdir)/eossdk_wrap.cpp: $(SWIG_FILES) $(nobase_include_HEADERS) $(srcdir)/eossdk_wrap.cpp - echo ./build_eossdk_wrap_py2 # built in python2 virtual-env - SRCDIR=$(srcdir) prefix [stubs-swig] $(SWIG) -threads -c++ -python -dirvtable -O -I$(srcdir) -o $@-t $(srcdir)/EosSdk.i + SRCDIR=$(srcdir) prefix [stubs-swig] $(SWIG) -threads -c++ -python -py3 -dirvtable -O -I$(srcdir) -o $@-t $(srcdir)/EosSdk.i patch --batch --no-backup-if-mismatch -p0 <$(srcdir)/swig.patch mv $@-t $@ sed 's/#define PyString_AS_STRING.x. PyUnicode_AS_STRING.x./#define PyString_AS_STRING(x) PyBytes_AS_STRING(x)/' -i eossdk_wrap.cpp diff --git a/SdkImpl.cpp b/SdkImpl.cpp index 4d9ba42..b0b9946 100644 --- a/SdkImpl.cpp +++ b/SdkImpl.cpp @@ -33,15 +33,12 @@ namespace eos { eth_lag_intf_mgr_(0), \ event_loop_(0), \ fib_mgr_(0), \ - fpga_mgr_(0), \ - ham_mgr_(0), \ hardware_table_mgr_(0), \ intf_mgr_helper_(0), \ intf_mgr_(0), \ intf_counter_mgr_(0), \ ip_intf_mgr_(0), \ ip_route_mgr_(0), \ - l1_source_mgr_(0), \ lldp_mgr_(0), \ macsec_mgr_(0), \ mac_table_mgr_(0), \ @@ -112,14 +109,11 @@ INIT_STUB_MGR(eth_intf_mgr) INIT_STUB_MGR(eth_phy_intf_mgr) INIT_STUB_MGR(eth_phy_intf_counter_mgr) INIT_STUB_MGR(eth_lag_intf_mgr) -INIT_STUB_MGR(fpga_mgr) -INIT_STUB_MGR(ham_mgr) INIT_STUB_MGR(hardware_table_mgr) INIT_STUB_MGR(intf_mgr) INIT_STUB_MGR(intf_counter_mgr) INIT_STUB_MGR(ip_intf_mgr) INIT_STUB_MGR(ip_route_mgr) -INIT_STUB_MGR(l1_source_mgr) INIT_STUB_MGR(lldp_mgr) INIT_STUB_MGR(macsec_mgr) INIT_STUB_MGR(mac_table_mgr) diff --git a/SdkImpl.h b/SdkImpl.h index a0ae825..89f7403 100644 --- a/SdkImpl.h +++ b/SdkImpl.h @@ -28,15 +28,12 @@ class eth_phy_intf_mgr; class eth_phy_intf_counter_mgr; class event_loop; class fib_mgr; -class fpga_mgr; -class ham_mgr; class hardware_table_mgr; class intf_mgr_helper; class intf_mgr; class intf_counter_mgr; class ip_intf_mgr; class ip_route_mgr; -class l1_source_mgr; class lldp_mgr; class macsec_mgr; class mac_table_mgr; @@ -128,14 +125,11 @@ class EOS_SDK_PUBLIC sdk::SdkImpl { void init_eth_phy_intf_counter_mgr(); void init_event_loop(); void init_fib_mgr(mgr_mode_type_t mode=MODE_TYPE_READ_ONLY); - void init_fpga_mgr(); - void init_ham_mgr(); void init_hardware_table_mgr(); void init_intf_mgr(); void init_intf_counter_mgr(); void init_ip_intf_mgr(); void init_ip_route_mgr(); - void init_l1_source_mgr(); void init_lldp_mgr(); void init_macsec_mgr(); void init_mac_table_mgr(); @@ -169,14 +163,11 @@ class EOS_SDK_PUBLIC sdk::SdkImpl { eth_phy_intf_counter_mgr * get_eth_phy_intf_counter_mgr(); event_loop * get_event_loop(); fib_mgr * get_fib_mgr(mgr_mode_type_t mode=MODE_TYPE_READ_ONLY); - fpga_mgr * get_fpga_mgr(); - ham_mgr * get_ham_mgr(); hardware_table_mgr * get_hardware_table_mgr(); intf_mgr * get_intf_mgr(); intf_counter_mgr * get_intf_counter_mgr(); ip_intf_mgr * get_ip_intf_mgr(); ip_route_mgr * get_ip_route_mgr(); - l1_source_mgr * get_l1_source_mgr(); lldp_mgr * get_lldp_mgr(); macsec_mgr * get_macsec_mgr(); mac_table_mgr * get_mac_table_mgr(); @@ -218,15 +209,12 @@ class EOS_SDK_PUBLIC sdk::SdkImpl { eth_lag_intf_mgr * eth_lag_intf_mgr_; event_loop * event_loop_; fib_mgr * fib_mgr_; - fpga_mgr * fpga_mgr_; - ham_mgr * ham_mgr_; hardware_table_mgr * hardware_table_mgr_; intf_mgr_helper * intf_mgr_helper_; intf_mgr * intf_mgr_; intf_counter_mgr * intf_counter_mgr_; ip_intf_mgr * ip_intf_mgr_; ip_route_mgr * ip_route_mgr_; - l1_source_mgr * l1_source_mgr_; lldp_mgr * lldp_mgr_; macsec_mgr * macsec_mgr_; mac_table_mgr * mac_table_mgr_; @@ -370,14 +358,6 @@ inline fib_mgr * sdk::SdkImpl::get_fib_mgr(mgr_mode_type_t mode) { return fib_mgr_; } -inline fpga_mgr * sdk::SdkImpl::get_fpga_mgr() { - GET_MGR(fpga) -} - -inline ham_mgr * sdk::SdkImpl::get_ham_mgr() { - GET_MGR(ham) -} - inline hardware_table_mgr * sdk::SdkImpl::get_hardware_table_mgr() { GET_MGR(hardware_table) } @@ -412,10 +392,6 @@ inline intf_mgr_helper * sdk::SdkImpl::get_intf_mgr_helper() { return intf_mgr_helper_; } -inline l1_source_mgr * sdk::SdkImpl::get_l1_source_mgr() { - GET_MGR(l1_source) -} - inline macsec_mgr * sdk::SdkImpl::get_macsec_mgr() { GET_MGR(macsec) } diff --git a/SwigRenamer.py b/SwigRenamer.py index 2cecfed..5096289 100644 --- a/SwigRenamer.py +++ b/SwigRenamer.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2013 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import print_function import string import sys diff --git a/eos/acl.h b/eos/acl.h index bc84902..b61051a 100644 --- a/eos/acl.h +++ b/eos/acl.h @@ -66,6 +66,7 @@ #include #include +#include namespace eos { diff --git a/eos/fpga.h b/eos/fpga.h deleted file mode 100644 index b5af14a..0000000 --- a/eos/fpga.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_FPGA_H -#define EOS_FPGA_H - -#include -#include -#include -#include - -#include "eos/types/ham.h" -#include - -namespace eos { - -class fpga_mgr; - -class EOS_SDK_PUBLIC fpga_handler : public base_handler { - - public: - explicit fpga_handler(fpga_mgr *); - fpga_mgr * get_fpga_mgr() const; - - void watch_all_fpga_reservation_status(bool); - void watch_fpga_reservation_status(const std::string&, bool); - virtual void on_fpga_reservation_status_set(std::string); - virtual void on_fpga_reservation_status_del(std::string); -}; - -class fpga_iter_impl; - -class EOS_SDK_PUBLIC fpga_iter_t : public iter_base { - private: - friend class fpga_iter_impl; - explicit fpga_iter_t(fpga_iter_impl * const) EOS_SDK_PRIVATE; - -}; - -class fpga_reservation_iter_impl; - -class EOS_SDK_PUBLIC fpga_reservation_iter_t - : public iter_base { - private: - friend class fpga_reservation_iter_impl; - explicit fpga_reservation_iter_t( - fpga_reservation_iter_impl * const) EOS_SDK_PRIVATE; - -}; - -class fpga_reservation_status_iter_impl; - -class EOS_SDK_PUBLIC fpga_reservation_status_iter_t - : public iter_base { - private: - friend class fpga_reservation_status_iter_impl; - explicit fpga_reservation_status_iter_t( - fpga_reservation_status_iter_impl * const) EOS_SDK_PRIVATE; - -}; - -class EOS_SDK_PUBLIC fpga_mgr : public base_mgr { - public: - virtual ~fpga_mgr(); - - virtual fpga_iter_t fpga_status_iter() const = 0; - virtual fpga_t fpga(const std::string&) const = 0; - virtual fpga_reservation_iter_t reservation_iter() const = 0; - virtual fpga_reservation_status_iter_t reservation_status_iter() const = 0; - virtual bool reservation_exists(const std::string&) const = 0; - virtual bool reservation_status_exists(const std::string&) const = 0; - virtual fpga_reservation_t reservation(const std::string&) const = 0; - virtual fpga_reservation_status_t reservation_status(const std::string&) - const = 0; - virtual void reservation_set(const fpga_reservation_t&) = 0; - virtual void reservation_del(const std::string&) = 0; - virtual eossdk_ham_t ham(const fpga_t&, size_t) const = 0; - protected: - fpga_mgr() EOS_SDK_PRIVATE; - friend class fpga_handler; - - private: - EOS_SDK_DISALLOW_COPY_CTOR(fpga_mgr); -}; - -} // end namespace eos - -#include - -#endif // EOS_FPGA_H - diff --git a/eos/ham.h b/eos/ham.h deleted file mode 100644 index 7e1a7cb..0000000 --- a/eos/ham.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_HAM_H -#define EOS_HAM_H - -#include -#include -#include -#include -#include - - -/** - * @file - * HAM management module. - * - * Provides a Hardware Access Method manager with read and write APIs to - * support communication protocols such as i2c within EosSdk. - */ - -namespace eos{ - -class ham_mgr; - -class EOS_SDK_PUBLIC ham_handler : public base_handler< ham_mgr, ham_handler > { - public: - explicit ham_handler( ham_mgr * ); - ham_mgr * get_ham_mgr() const; -}; - -class EOS_SDK_PUBLIC ham_mgr : public base_mgr { - public: - virtual ~ham_mgr(); - - /** - * Called to read 8 bytes of data at a time from given register, stores - * the 8 bytes that was read within the return value's attribute named 'result', - * and stores the response_enum within the return value's attribute named - * 'status', using the HAM passed in to this API. - */ - virtual eos::read8_result_t read8( eossdk_ham_t ham, - register_t reg ) = 0; - - /** - * Called to read 16 bytes of data at a time from given register, stores - * the 16 bytes that was read within the return value's attribute named 'result', - * and stores the response_enum within the return value's attribute named - * 'status', using the HAM passed into this API. - */ - virtual eos::read16_result_t read16( eossdk_ham_t ham, - register_t reg ) = 0; - - /** - * Called to read 32 bytes of data at a time from given register, stores - * the 32 bytes that was read within the return value's attribute named 'result', - * and stores the response_enum within the return value's attribute named - * 'status', using the HAM passed into this API. - * Uses string ptr to store result because underlying pluto - * call requires a string pointer for this call. - */ - virtual eos::read_result_t read32( eossdk_ham_t ham, register_t reg ) = 0; - - /** - * Called to issue an I2C variable-sized/block read from given register. - * Reads up to 'size' amount of bytes of data from given register, and - * stores the bytes that were read within the return value's attribute named - * 'result'. Uses the HAM passed into this API. - */ - virtual eos::read_result_t read( eossdk_ham_t ham, register_t reg, - size_t size ) = 0; - - /** - * Called to issue am Smbus block read from given register, stores the bytes - * that were read within the return value's attribute named 'result', - * using the HAM passed into this API. - * Reads up to a max of 32 bytes from register. - * Uses string ptr to store result because underlying pluto - * call requires a string pointer for this call. - */ - virtual eos::read_result_t readBlock( eossdk_ham_t ham, register_t reg ) = 0; - - /** - * Called to write 8 bytes that are stored in 'data' to register 'reg', - * using the HAM passed into this API. 'reliable' represents if the - * data transfer was reliable/successful or not. - */ - virtual eos::response_enum_t write8( eossdk_ham_t ham, register_t reg, - uint8_t data, bool reliable = false ) = 0; - - /** - * Called to write 16 bytes that are stored in 'data' to register 'reg', - * using the HAM passed into this API. 'reliable' represents if the - * data transfer was reliable/successful or not. - */ - virtual eos::response_enum_t write16( eossdk_ham_t ham, register_t reg, - uint16_t data, bool reliable = false ) = 0; - - /** - * Called to write 32 bytes that are stored in 'data' to register 'reg', - * using the HAM passed into this API. 'reliable' represents if the - * data transfer was reliable/successful or not. - */ - virtual eos::response_enum_t write32( eossdk_ham_t ham, register_t reg, - uint32_t data, bool reliable = false ) = 0; - - /** - * Called to issue an I2C variable-sized/block write call, writes a block of data - * of a given size to register 'reg', using the HAM passed into this API. - * Stores the result in 'data'. 'reliable' represents if the data transfer was - * reliable/successful or not. - */ - virtual eos::response_enum_t write( eossdk_ham_t ham, register_t reg, - eos::ByteString const & data, - bool reliable = false ) = 0; - - /** - * Called to issue an Smbus write block call, writes a block of data of a - * given size to register 'reg', using the HAM passed into this API. - * Stores the result in 'data'. - * 'reliable' represents if the data transfer was reliable/successful or not. - */ - virtual eos::response_enum_t writeBlock( eossdk_ham_t ham, register_t reg, - eos::ByteString const & data, - bool reliable = false ) = 0; - - protected: - ham_mgr() EOS_SDK_PRIVATE; - friend class ham_handler; - - private: - EOS_SDK_DISALLOW_COPY_CTOR( ham_mgr ); - -}; -} - -#include -#endif // EOS_HAM_H diff --git a/eos/inline/fpga.h b/eos/inline/fpga.h deleted file mode 100644 index 49ba4ea..0000000 --- a/eos/inline/fpga.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef INLINE_FPGA_H -#define INLINE_FPGA_H - -namespace eos { - -inline fpga_mgr * fpga_handler::get_fpga_mgr() const { - return mgr_; -} - -} // end namespace eos - -#endif // INLINE_FPGA_H diff --git a/eos/inline/ham.h b/eos/inline/ham.h deleted file mode 100644 index 7528dfd..0000000 --- a/eos/inline/ham.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_HAM_H -#define EOS_INLINE_HAM_H - -namespace eos{ - -inline ham_mgr * ham_handler::get_ham_mgr() const { - return mgr_; -} - -} - -#endif // EOS_INLINE_HAM_H diff --git a/eos/inline/l1_source.h b/eos/inline/l1_source.h deleted file mode 100644 index ef2a0f8..0000000 --- a/eos/inline/l1_source.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2013 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_L1_SOURCE_H -#define EOS_INLINE_L1_SOURCE_H - -#include - -namespace eos { - -inline l1_source_mgr * l1_source_handler::get_l1_source_mgr() const { - return mgr_; -} - -} - -#endif // EOS_INLINE_L1_SOURCE_H diff --git a/eos/inline/types/fpga.h b/eos/inline/types/fpga.h deleted file mode 100644 index b2d886d..0000000 --- a/eos/inline/types/fpga.h +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_FPGA_H -#define EOS_INLINE_TYPES_FPGA_H - -namespace eos { - -fpga_t::fpga_t() { - pimpl = std::shared_ptr( - new fpga_impl_t() - ); -} -fpga_t::fpga_t(std::string const & name, std::string const & board_standard, - std::string const & part_number) { - pimpl = std::shared_ptr( - new fpga_impl_t( - name, - board_standard, - part_number - ) - ); -} -fpga_t::fpga_t( - const fpga_t& other) -{ - pimpl = std::make_unique( - fpga_impl_t(*other.pimpl)); -} -fpga_t& -fpga_t::operator=( - fpga_t const & other) -{ - pimpl = std::shared_ptr( - new fpga_impl_t(*other.pimpl)); - return *this; -} - -std::string -fpga_t::name() const { - return pimpl->name(); -} -std::string -fpga_t::board_standard() const { - return pimpl->board_standard(); -} -std::string -fpga_t::part_number() const { - return pimpl->part_number(); -} -bool -fpga_t::operator==(fpga_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -fpga_t::operator!=(fpga_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -fpga_t::operator<(fpga_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -fpga_t::hash() const { - return pimpl->hash(); -} -void -fpga_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -fpga_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const fpga_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -fpga_reservation_t::fpga_reservation_t() { - pimpl = std::shared_ptr( - new fpga_reservation_impl_t() - ); -} -fpga_reservation_t::fpga_reservation_t(std::string const & id) { - pimpl = std::shared_ptr( - new fpga_reservation_impl_t( - id - ) - ); -} -fpga_reservation_t::fpga_reservation_t( - const fpga_reservation_t& other) -{ - pimpl = std::make_unique( - fpga_reservation_impl_t(*other.pimpl)); -} -fpga_reservation_t& -fpga_reservation_t::operator=( - fpga_reservation_t const & other) -{ - pimpl = std::shared_ptr( - new fpga_reservation_impl_t(*other.pimpl)); - return *this; -} - -std::string -fpga_reservation_t::id() const { - return pimpl->id(); -} -std::string -fpga_reservation_t::board_standard() const { - return pimpl->board_standard(); -} -void -fpga_reservation_t::board_standard_is(std::string const & board_standard) { - pimpl->board_standard_is(board_standard); -} -std::string -fpga_reservation_t::fpga_name() const { - return pimpl->fpga_name(); -} -void -fpga_reservation_t::fpga_name_is(std::string const & fpga_name) { - pimpl->fpga_name_is(fpga_name); -} -std::string -fpga_reservation_t::bitfile() const { - return pimpl->bitfile(); -} -void -fpga_reservation_t::bitfile_is(std::string const & bitfile) { - pimpl->bitfile_is(bitfile); -} -bool -fpga_reservation_t::operator==(fpga_reservation_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -fpga_reservation_t::operator!=(fpga_reservation_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -fpga_reservation_t::operator<(fpga_reservation_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -fpga_reservation_t::hash() const { - return pimpl->hash(); -} -void -fpga_reservation_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -fpga_reservation_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const fpga_reservation_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -EOS_SDK_PUBLIC std::ostream& -operator<<(std::ostream& os, const fpga_reservation_result_t & enum_val) { - if (enum_val==FRR_INVALID) { - os << "FRR_INVALID"; - } else if (enum_val==FRR_PENDING) { - os << "FRR_PENDING"; - } else if (enum_val==FRR_SUCCESS) { - os << "FRR_SUCCESS"; - } else if (enum_val==FRR_FAILED_TO_MATCH_FPGA) { - os << "FRR_FAILED_TO_MATCH_FPGA"; - } else if (enum_val==FRR_FAILED_TO_RESERVE) { - os << "FRR_FAILED_TO_RESERVE"; - } else if (enum_val==FRR_FAILED_TO_PROGRAM) { - os << "FRR_FAILED_TO_PROGRAM"; - } else if (enum_val==FRR_FAILED_TO_CLEAR) { - os << "FRR_FAILED_TO_CLEAR"; - } else { - os << "Unknown value"; - } - return os; -} - - -fpga_reservation_status_t::fpga_reservation_status_t() { - pimpl = std::shared_ptr( - new fpga_reservation_status_impl_t() - ); -} -fpga_reservation_status_t::fpga_reservation_status_t( - std::string const & id, fpga_reservation_result_t result, - std::string fpga_name) { - pimpl = std::shared_ptr( - new fpga_reservation_status_impl_t( - id, - result, - fpga_name - ) - ); -} -fpga_reservation_status_t::fpga_reservation_status_t( - const fpga_reservation_status_t& other) -{ - pimpl = std::make_unique( - fpga_reservation_status_impl_t(*other.pimpl)); -} -fpga_reservation_status_t& -fpga_reservation_status_t::operator=( - fpga_reservation_status_t const & other) -{ - pimpl = std::shared_ptr( - new fpga_reservation_status_impl_t(*other.pimpl)); - return *this; -} - -std::string -fpga_reservation_status_t::id() const { - return pimpl->id(); -} -fpga_reservation_result_t -fpga_reservation_status_t::result() const { - return pimpl->result(); -} -std::string -fpga_reservation_status_t::fpga_name() const { - return pimpl->fpga_name(); -} -bool -fpga_reservation_status_t::operator==(fpga_reservation_status_t const & other) - const { - return pimpl->operator==(*other.pimpl); -} -bool -fpga_reservation_status_t::operator!=(fpga_reservation_status_t const & other) - const { - return pimpl->operator!=(*other.pimpl); -} -bool -fpga_reservation_status_t::operator<(fpga_reservation_status_t const & other) - const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -fpga_reservation_status_t::hash() const { - return pimpl->hash(); -} -void -fpga_reservation_status_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -fpga_reservation_status_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const fpga_reservation_status_t& obj) { - return operator<<(os, *obj.pimpl); -} - -} - -#endif // EOS_INLINE_TYPES_FPGA_H diff --git a/eos/inline/types/fpga_impl.h b/eos/inline/types/fpga_impl.h deleted file mode 100644 index 5502ea6..0000000 --- a/eos/inline/types/fpga_impl.h +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_FPGA_IMPL_H -#define EOS_INLINE_TYPES_FPGA_IMPL_H - -namespace eos { - -fpga_impl_t::fpga_impl_t() : - name_(), board_standard_(), part_number_() { -} - -fpga_impl_t::fpga_impl_t(std::string const & name, - std::string const & board_standard, - std::string const & part_number) : - name_(name), board_standard_(board_standard), part_number_(part_number) { -} - -std::string -fpga_impl_t::name() const { - return name_; -} - -std::string -fpga_impl_t::board_standard() const { - return board_standard_; -} - -std::string -fpga_impl_t::part_number() const { - return part_number_; -} - -bool -fpga_impl_t::operator==(fpga_impl_t const & other) const { - return name_ == other.name_ && - board_standard_ == other.board_standard_ && - part_number_ == other.part_number_; -} - -bool -fpga_impl_t::operator!=(fpga_impl_t const & other) const { - return !operator==(other); -} - -bool -fpga_impl_t::operator<(fpga_impl_t const & other) const { - if(name_ != other.name_) { - return name_ < other.name_; - } else if(board_standard_ != other.board_standard_) { - return board_standard_ < other.board_standard_; - } else if(part_number_ != other.part_number_) { - return part_number_ < other.part_number_; - } - return false; -} - -uint32_t -fpga_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -fpga_impl_t::mix_me(hash_mix & h) const { - h.mix(name_); // std::string - h.mix(board_standard_); // std::string - h.mix(part_number_); // std::string -} - -std::string -fpga_impl_t::to_string() const { - std::ostringstream ss; - ss << "fpga_t("; - ss << "name='" << name_ << "'"; - ss << ", board_standard='" << board_standard_ << "'"; - ss << ", part_number='" << part_number_ << "'"; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const fpga_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -fpga_reservation_impl_t::fpga_reservation_impl_t() : - id_(), board_standard_(), fpga_name_(), bitfile_() { -} - -fpga_reservation_impl_t::fpga_reservation_impl_t(std::string const & id) : - id_(id), board_standard_(), fpga_name_(), bitfile_() { -} - -std::string -fpga_reservation_impl_t::id() const { - return id_; -} - -std::string -fpga_reservation_impl_t::board_standard() const { - return board_standard_; -} - -void -fpga_reservation_impl_t::board_standard_is(std::string const & board_standard) { - board_standard_ = board_standard; -} - -std::string -fpga_reservation_impl_t::fpga_name() const { - return fpga_name_; -} - -void -fpga_reservation_impl_t::fpga_name_is(std::string const & fpga_name) { - fpga_name_ = fpga_name; -} - -std::string -fpga_reservation_impl_t::bitfile() const { - return bitfile_; -} - -void -fpga_reservation_impl_t::bitfile_is(std::string const & bitfile) { - bitfile_ = bitfile; -} - -bool -fpga_reservation_impl_t::operator==(fpga_reservation_impl_t const & other) const { - return id_ == other.id_ && - board_standard_ == other.board_standard_ && - fpga_name_ == other.fpga_name_ && - bitfile_ == other.bitfile_; -} - -bool -fpga_reservation_impl_t::operator!=(fpga_reservation_impl_t const & other) const { - return !operator==(other); -} - -bool -fpga_reservation_impl_t::operator<(fpga_reservation_impl_t const & other) const { - if(id_ != other.id_) { - return id_ < other.id_; - } else if(board_standard_ != other.board_standard_) { - return board_standard_ < other.board_standard_; - } else if(fpga_name_ != other.fpga_name_) { - return fpga_name_ < other.fpga_name_; - } else if(bitfile_ != other.bitfile_) { - return bitfile_ < other.bitfile_; - } - return false; -} - -uint32_t -fpga_reservation_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -fpga_reservation_impl_t::mix_me(hash_mix & h) const { - h.mix(id_); // std::string - h.mix(board_standard_); // std::string - h.mix(fpga_name_); // std::string - h.mix(bitfile_); // std::string -} - -std::string -fpga_reservation_impl_t::to_string() const { - std::ostringstream ss; - ss << "fpga_reservation_t("; - ss << "id='" << id_ << "'"; - ss << ", board_standard='" << board_standard_ << "'"; - ss << ", fpga_name='" << fpga_name_ << "'"; - ss << ", bitfile='" << bitfile_ << "'"; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const fpga_reservation_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - - - -fpga_reservation_status_impl_t::fpga_reservation_status_impl_t() : - id_(), result_(), fpga_name_() { -} - -fpga_reservation_status_impl_t::fpga_reservation_status_impl_t( - std::string const & id, fpga_reservation_result_t result, - std::string fpga_name) : - id_(id), result_(result), fpga_name_(fpga_name) { -} - -std::string -fpga_reservation_status_impl_t::id() const { - return id_; -} - -fpga_reservation_result_t -fpga_reservation_status_impl_t::result() const { - return result_; -} - -std::string -fpga_reservation_status_impl_t::fpga_name() const { - return fpga_name_; -} - -bool -fpga_reservation_status_impl_t::operator==( - fpga_reservation_status_impl_t const & other) const { - return id_ == other.id_ && - result_ == other.result_ && - fpga_name_ == other.fpga_name_; -} - -bool -fpga_reservation_status_impl_t::operator!=( - fpga_reservation_status_impl_t const & other) const { - return !operator==(other); -} - -bool -fpga_reservation_status_impl_t::operator<( - fpga_reservation_status_impl_t const & other) const { - if(id_ != other.id_) { - return id_ < other.id_; - } else if(result_ != other.result_) { - return result_ < other.result_; - } else if(fpga_name_ != other.fpga_name_) { - return fpga_name_ < other.fpga_name_; - } - return false; -} - -uint32_t -fpga_reservation_status_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -fpga_reservation_status_impl_t::mix_me(hash_mix & h) const { - h.mix(id_); // std::string - h.mix(result_); // fpga_reservation_result_t - h.mix(fpga_name_); // std::string -} - -std::string -fpga_reservation_status_impl_t::to_string() const { - std::ostringstream ss; - ss << "fpga_reservation_status_t("; - ss << "id='" << id_ << "'"; - ss << ", result=" << result_; - ss << ", fpga_name='" << fpga_name_ << "'"; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const fpga_reservation_status_impl_t& obj) { - os << obj.to_string(); - return os; -} - - -} - -#include - -#endif // EOS_INLINE_TYPES_FPGA_IMPL_H diff --git a/eos/inline/types/ham.h b/eos/inline/types/ham.h deleted file mode 100644 index 15af82a..0000000 --- a/eos/inline/types/ham.h +++ /dev/null @@ -1,598 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_HAM_H -#define EOS_INLINE_TYPES_HAM_H - -namespace eos { - -EOS_SDK_PUBLIC std::ostream& -operator<<(std::ostream& os, const response_enum_t & enum_val) { - if (enum_val==STATUS_OK) { - os << "STATUS_OK"; - } else if (enum_val==STATUS_ERR_HW_NOT_PRESENT) { - os << "STATUS_ERR_HW_NOT_PRESENT"; - } else if (enum_val==STATUS_ERR_HW_FAILURE) { - os << "STATUS_ERR_HW_FAILURE"; - } else if (enum_val==STATUS_ERR_ARGS) { - os << "STATUS_ERR_ARGS"; - } else if (enum_val==STATUS_ERR_COMM) { - os << "STATUS_ERR_COMM"; - } else if (enum_val==STATUS_ERR_API_UNSUPPORTED) { - os << "STATUS_ERR_API_UNSUPPORTED"; - } else if (enum_val==STATUS_ERR_INTERNAL) { - os << "STATUS_ERR_INTERNAL"; - } else { - os << "Unknown value"; - } - return os; -} - - -device_t::device_t() { - pimpl = std::shared_ptr( - new device_impl_t() - ); -} -device_t::device_t( - const device_t& other) -{ - pimpl = std::make_unique( - device_impl_t(*other.pimpl)); -} -device_t& -device_t::operator=( - device_t const & other) -{ - pimpl = std::shared_ptr( - new device_impl_t(*other.pimpl)); - return *this; -} - -std::string -device_t::driver() const { - return pimpl->driver(); -} -void -device_t::driver_is(std::string driver) { - pimpl->driver_is(driver); -} -uint32_t -device_t::uid() const { - return pimpl->uid(); -} -void -device_t::uid_is(uint32_t uid) { - pimpl->uid_is(uid); -} -uint32_t -device_t::did() const { - return pimpl->did(); -} -void -device_t::did_is(uint32_t did) { - pimpl->did_is(did); -} -uint32_t -device_t::bus() const { - return pimpl->bus(); -} -void -device_t::bus_is(uint32_t bus) { - pimpl->bus_is(bus); -} -uint32_t -device_t::accelerator() const { - return pimpl->accelerator(); -} -void -device_t::accelerator_is(uint32_t accelerator) { - pimpl->accelerator_is(accelerator); -} -bool -device_t::operator==(device_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -device_t::operator!=(device_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -device_t::operator<(device_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -device_t::hash() const { - return pimpl->hash(); -} -void -device_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -device_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const device_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -pci_address_t::pci_address_t() { - pimpl = std::shared_ptr( - new pci_address_impl_t() - ); -} -pci_address_t::pci_address_t( - const pci_address_t& other) -{ - pimpl = std::make_unique( - pci_address_impl_t(*other.pimpl)); -} -pci_address_t& -pci_address_t::operator=( - pci_address_t const & other) -{ - pimpl = std::shared_ptr( - new pci_address_impl_t(*other.pimpl)); - return *this; -} - -uint32_t -pci_address_t::domain() const { - return pimpl->domain(); -} -void -pci_address_t::domain_is(uint32_t domain) { - pimpl->domain_is(domain); -} -uint32_t -pci_address_t::bus() const { - return pimpl->bus(); -} -void -pci_address_t::bus_is(uint32_t bus) { - pimpl->bus_is(bus); -} -uint32_t -pci_address_t::device() const { - return pimpl->device(); -} -void -pci_address_t::device_is(uint32_t device) { - pimpl->device_is(device); -} -uint32_t -pci_address_t::function() const { - return pimpl->function(); -} -void -pci_address_t::function_is(uint32_t function) { - pimpl->function_is(function); -} -bool -pci_address_t::operator==(pci_address_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -pci_address_t::operator!=(pci_address_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -pci_address_t::operator<(pci_address_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -pci_address_t::hash() const { - return pimpl->hash(); -} -void -pci_address_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -pci_address_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const pci_address_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -aham_address_t::aham_address_t() { - pimpl = std::shared_ptr( - new aham_address_impl_t() - ); -} -aham_address_t::aham_address_t( - const aham_address_t& other) -{ - pimpl = std::make_unique( - aham_address_impl_t(*other.pimpl)); -} -aham_address_t& -aham_address_t::operator=( - aham_address_t const & other) -{ - pimpl = std::shared_ptr( - new aham_address_impl_t(*other.pimpl)); - return *this; -} - -uint32_t -aham_address_t::bus() const { - return pimpl->bus(); -} -void -aham_address_t::bus_is(uint32_t bus) { - pimpl->bus_is(bus); -} -uint32_t -aham_address_t::accelerator() const { - return pimpl->accelerator(); -} -void -aham_address_t::accelerator_is(uint32_t accelerator) { - pimpl->accelerator_is(accelerator); -} -uint32_t -aham_address_t::address() const { - return pimpl->address(); -} -void -aham_address_t::address_is(uint32_t address) { - pimpl->address_is(address); -} -bool -aham_address_t::operator==(aham_address_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -aham_address_t::operator!=(aham_address_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -aham_address_t::operator<(aham_address_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -aham_address_t::hash() const { - return pimpl->hash(); -} -void -aham_address_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -aham_address_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const aham_address_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -eossdk_ham_t::eossdk_ham_t(device_t device_Args, uint32_t endpoint_Addr) { - pimpl = std::shared_ptr( - new eossdk_ham_impl_t( - device_Args, - endpoint_Addr - ) - ); -} -eossdk_ham_t::eossdk_ham_t(aham_address_t aham_address, - pci_address_t pci_address) { - pimpl = std::shared_ptr( - new eossdk_ham_impl_t( - aham_address, - pci_address - ) - ); -} -eossdk_ham_t::eossdk_ham_t( - const eossdk_ham_t& other) -{ - pimpl = std::make_unique( - eossdk_ham_impl_t(*other.pimpl)); -} -eossdk_ham_t& -eossdk_ham_t::operator=( - eossdk_ham_t const & other) -{ - pimpl = std::shared_ptr( - new eossdk_ham_impl_t(*other.pimpl)); - return *this; -} - -device_t -eossdk_ham_t::device_Args() const { - return pimpl->device_Args(); -} -uint32_t -eossdk_ham_t::endpoint_Addr() const { - return pimpl->endpoint_Addr(); -} -aham_address_t -eossdk_ham_t::aham_address() const { - return pimpl->aham_address(); -} -pci_address_t -eossdk_ham_t::pci_address() const { - return pimpl->pci_address(); -} -uint32_t -eossdk_ham_t::hash() const { - return pimpl->hash(); -} -void -eossdk_ham_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -eossdk_ham_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const eossdk_ham_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -read8_result_t::read8_result_t(response_enum_t status, uint8_t result) { - pimpl = std::shared_ptr( - new read8_result_impl_t( - status, - result - ) - ); -} -read8_result_t::read8_result_t( - const read8_result_t& other) -{ - pimpl = std::make_unique( - read8_result_impl_t(*other.pimpl)); -} -read8_result_t& -read8_result_t::operator=( - read8_result_t const & other) -{ - pimpl = std::shared_ptr( - new read8_result_impl_t(*other.pimpl)); - return *this; -} - -response_enum_t -read8_result_t::status() const { - return pimpl->status(); -} -void -read8_result_t::status_is(response_enum_t status) { - pimpl->status_is(status); -} -uint8_t -read8_result_t::result() const { - return pimpl->result(); -} -void -read8_result_t::result_is(uint8_t result) { - pimpl->result_is(result); -} -bool -read8_result_t::operator==(read8_result_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -read8_result_t::operator!=(read8_result_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -uint32_t -read8_result_t::hash() const { - return pimpl->hash(); -} -void -read8_result_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -read8_result_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const read8_result_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -read16_result_t::read16_result_t(response_enum_t status, uint16_t result) { - pimpl = std::shared_ptr( - new read16_result_impl_t( - status, - result - ) - ); -} -read16_result_t::read16_result_t( - const read16_result_t& other) -{ - pimpl = std::make_unique( - read16_result_impl_t(*other.pimpl)); -} -read16_result_t& -read16_result_t::operator=( - read16_result_t const & other) -{ - pimpl = std::shared_ptr( - new read16_result_impl_t(*other.pimpl)); - return *this; -} - -response_enum_t -read16_result_t::status() const { - return pimpl->status(); -} -void -read16_result_t::status_is(response_enum_t status) { - pimpl->status_is(status); -} -uint16_t -read16_result_t::result() const { - return pimpl->result(); -} -void -read16_result_t::result_is(uint16_t result) { - pimpl->result_is(result); -} -bool -read16_result_t::operator==(read16_result_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -read16_result_t::operator!=(read16_result_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -uint32_t -read16_result_t::hash() const { - return pimpl->hash(); -} -void -read16_result_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -read16_result_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const read16_result_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -read_result_t::read_result_t(response_enum_t status, ByteString result) { - pimpl = std::shared_ptr( - new read_result_impl_t( - status, - result - ) - ); -} -read_result_t::read_result_t( - const read_result_t& other) -{ - pimpl = std::make_unique( - read_result_impl_t(*other.pimpl)); -} -read_result_t& -read_result_t::operator=( - read_result_t const & other) -{ - pimpl = std::shared_ptr( - new read_result_impl_t(*other.pimpl)); - return *this; -} - -response_enum_t -read_result_t::status() const { - return pimpl->status(); -} -void -read_result_t::status_is(response_enum_t status) { - pimpl->status_is(status); -} -ByteString -read_result_t::result() const { - return pimpl->result(); -} -void -read_result_t::result_is(ByteString result) { - pimpl->result_is(result); -} -bool -read_result_t::operator==(read_result_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -read_result_t::operator!=(read_result_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -uint32_t -read_result_t::hash() const { - return pimpl->hash(); -} -void -read_result_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -read_result_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const read_result_t& obj) { - return operator<<(os, *obj.pimpl); -} - - -register_t::register_t() { - pimpl = std::shared_ptr( - new register_impl_t() - ); -} -register_t::register_t( - const register_t& other) -{ - pimpl = std::make_unique( - register_impl_t(*other.pimpl)); -} -register_t& -register_t::operator=( - register_t const & other) -{ - pimpl = std::shared_ptr( - new register_impl_t(*other.pimpl)); - return *this; -} - -uint32_t -register_t::reg() const { - return pimpl->reg(); -} -void -register_t::reg_is(uint32_t reg) { - pimpl->reg_is(reg); -} -bool -register_t::operator==(register_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -register_t::operator!=(register_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -register_t::operator<(register_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -register_t::hash() const { - return pimpl->hash(); -} -void -register_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -register_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const register_t& obj) { - return operator<<(os, *obj.pimpl); -} - -} - -#endif // EOS_INLINE_TYPES_HAM_H diff --git a/eos/inline/types/ham_impl.h b/eos/inline/types/ham_impl.h deleted file mode 100644 index 73c1520..0000000 --- a/eos/inline/types/ham_impl.h +++ /dev/null @@ -1,663 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_HAM_IMPL_H -#define EOS_INLINE_TYPES_HAM_IMPL_H - -namespace eos { - - - -device_impl_t::device_impl_t() : - driver_(), uid_(0xFFFFFFFF), did_(0xFFFFFFFF), bus_(0xFFFFFFFF), - accelerator_(0xFFFFFFFF) { -} - -std::string -device_impl_t::driver() const { - return driver_; -} - -void -device_impl_t::driver_is(std::string driver) { - driver_ = driver; -} - -uint32_t -device_impl_t::uid() const { - return uid_; -} - -void -device_impl_t::uid_is(uint32_t uid) { - uid_ = uid; -} - -uint32_t -device_impl_t::did() const { - return did_; -} - -void -device_impl_t::did_is(uint32_t did) { - did_ = did; -} - -uint32_t -device_impl_t::bus() const { - return bus_; -} - -void -device_impl_t::bus_is(uint32_t bus) { - bus_ = bus; -} - -uint32_t -device_impl_t::accelerator() const { - return accelerator_; -} - -void -device_impl_t::accelerator_is(uint32_t accelerator) { - accelerator_ = accelerator; -} - -bool -device_impl_t::operator==(device_impl_t const & other) const { - return driver_ == other.driver_ && - uid_ == other.uid_ && - did_ == other.did_ && - bus_ == other.bus_ && - accelerator_ == other.accelerator_; -} - -bool -device_impl_t::operator!=(device_impl_t const & other) const { - return !operator==(other); -} - -bool -device_impl_t::operator<(device_impl_t const & other) const { - if(driver_ != other.driver_) { - return driver_ < other.driver_; - } else if(uid_ != other.uid_) { - return uid_ < other.uid_; - } else if(did_ != other.did_) { - return did_ < other.did_; - } else if(bus_ != other.bus_) { - return bus_ < other.bus_; - } else if(accelerator_ != other.accelerator_) { - return accelerator_ < other.accelerator_; - } - return false; -} - -uint32_t -device_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -device_impl_t::mix_me(hash_mix & h) const { - h.mix(driver_); // std::string - h.mix(uid_); // uint32_t - h.mix(did_); // uint32_t - h.mix(bus_); // uint32_t - h.mix(accelerator_); // uint32_t -} - -std::string -device_impl_t::to_string() const { - std::ostringstream ss; - ss << "device_t("; - ss << "driver='" << driver_ << "'"; - ss << ", uid=" << uid_; - ss << ", did=" << did_; - ss << ", bus=" << bus_; - ss << ", accelerator=" << accelerator_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const device_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -pci_address_impl_t::pci_address_impl_t() : - domain_(0xFFFFFFFF), bus_(0xFFFFFFFF), device_(0xFFFFFFFF), - function_(0xFFFFFFFF) { -} - -uint32_t -pci_address_impl_t::domain() const { - return domain_; -} - -void -pci_address_impl_t::domain_is(uint32_t domain) { - domain_ = domain; -} - -uint32_t -pci_address_impl_t::bus() const { - return bus_; -} - -void -pci_address_impl_t::bus_is(uint32_t bus) { - bus_ = bus; -} - -uint32_t -pci_address_impl_t::device() const { - return device_; -} - -void -pci_address_impl_t::device_is(uint32_t device) { - device_ = device; -} - -uint32_t -pci_address_impl_t::function() const { - return function_; -} - -void -pci_address_impl_t::function_is(uint32_t function) { - function_ = function; -} - -bool -pci_address_impl_t::operator==(pci_address_impl_t const & other) const { - return domain_ == other.domain_ && - bus_ == other.bus_ && - device_ == other.device_ && - function_ == other.function_; -} - -bool -pci_address_impl_t::operator!=(pci_address_impl_t const & other) const { - return !operator==(other); -} - -bool -pci_address_impl_t::operator<(pci_address_impl_t const & other) const { - if(domain_ != other.domain_) { - return domain_ < other.domain_; - } else if(bus_ != other.bus_) { - return bus_ < other.bus_; - } else if(device_ != other.device_) { - return device_ < other.device_; - } else if(function_ != other.function_) { - return function_ < other.function_; - } - return false; -} - -uint32_t -pci_address_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -pci_address_impl_t::mix_me(hash_mix & h) const { - h.mix(domain_); // uint32_t - h.mix(bus_); // uint32_t - h.mix(device_); // uint32_t - h.mix(function_); // uint32_t -} - -std::string -pci_address_impl_t::to_string() const { - std::ostringstream ss; - ss << "pci_address_t("; - ss << "domain=" << domain_; - ss << ", bus=" << bus_; - ss << ", device=" << device_; - ss << ", function=" << function_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const pci_address_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -aham_address_impl_t::aham_address_impl_t() : - bus_(0xFFFFFFFF), accelerator_(0xFFFFFFFF), address_(0xFFFFFFFF) { -} - -uint32_t -aham_address_impl_t::bus() const { - return bus_; -} - -void -aham_address_impl_t::bus_is(uint32_t bus) { - bus_ = bus; -} - -uint32_t -aham_address_impl_t::accelerator() const { - return accelerator_; -} - -void -aham_address_impl_t::accelerator_is(uint32_t accelerator) { - accelerator_ = accelerator; -} - -uint32_t -aham_address_impl_t::address() const { - return address_; -} - -void -aham_address_impl_t::address_is(uint32_t address) { - address_ = address; -} - -bool -aham_address_impl_t::operator==(aham_address_impl_t const & other) const { - return bus_ == other.bus_ && - accelerator_ == other.accelerator_ && - address_ == other.address_; -} - -bool -aham_address_impl_t::operator!=(aham_address_impl_t const & other) const { - return !operator==(other); -} - -bool -aham_address_impl_t::operator<(aham_address_impl_t const & other) const { - if(bus_ != other.bus_) { - return bus_ < other.bus_; - } else if(accelerator_ != other.accelerator_) { - return accelerator_ < other.accelerator_; - } else if(address_ != other.address_) { - return address_ < other.address_; - } - return false; -} - -uint32_t -aham_address_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -aham_address_impl_t::mix_me(hash_mix & h) const { - h.mix(bus_); // uint32_t - h.mix(accelerator_); // uint32_t - h.mix(address_); // uint32_t -} - -std::string -aham_address_impl_t::to_string() const { - std::ostringstream ss; - ss << "aham_address_t("; - ss << "bus=" << bus_; - ss << ", accelerator=" << accelerator_; - ss << ", address=" << address_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const aham_address_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -eossdk_ham_impl_t::eossdk_ham_impl_t(device_t device_Args, - uint32_t endpoint_Addr) : - device_Args_(device_Args), endpoint_Addr_(endpoint_Addr), aham_address_(), - pci_address_() { -} - -eossdk_ham_impl_t::eossdk_ham_impl_t(aham_address_t aham_address, - pci_address_t pci_address) : - device_Args_(), endpoint_Addr_(), aham_address_(aham_address), - pci_address_(pci_address) { -} - -device_t -eossdk_ham_impl_t::device_Args() const { - return device_Args_; -} - -uint32_t -eossdk_ham_impl_t::endpoint_Addr() const { - return endpoint_Addr_; -} - -aham_address_t -eossdk_ham_impl_t::aham_address() const { - return aham_address_; -} - -pci_address_t -eossdk_ham_impl_t::pci_address() const { - return pci_address_; -} - -uint32_t -eossdk_ham_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -eossdk_ham_impl_t::mix_me(hash_mix & h) const { - h.mix(device_Args_); // device_t - h.mix(endpoint_Addr_); // uint32_t - h.mix(aham_address_); // aham_address_t - h.mix(pci_address_); // pci_address_t -} - -std::string -eossdk_ham_impl_t::to_string() const { - std::ostringstream ss; - ss << "eossdk_ham_t("; - ss << "device_Args=" << device_Args_; - ss << ", endpoint_Addr=" << endpoint_Addr_; - ss << ", aham_address=" << aham_address_; - ss << ", pci_address=" << pci_address_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const eossdk_ham_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -read8_result_impl_t::read8_result_impl_t(response_enum_t status, - uint8_t result) : - status_(status), result_(result) { -} - -response_enum_t -read8_result_impl_t::status() const { - return status_; -} - -void -read8_result_impl_t::status_is(response_enum_t status) { - status_ = status; -} - -uint8_t -read8_result_impl_t::result() const { - return result_; -} - -void -read8_result_impl_t::result_is(uint8_t result) { - result_ = result; -} - -bool -read8_result_impl_t::operator==(read8_result_impl_t const & other) const { - return status_ == other.status_ && - result_ == other.result_; -} - -bool -read8_result_impl_t::operator!=(read8_result_impl_t const & other) const { - return !operator==(other); -} - -uint32_t -read8_result_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -read8_result_impl_t::mix_me(hash_mix & h) const { - h.mix(status_); // response_enum_t - h.mix(result_); // uint8_t -} - -std::string -read8_result_impl_t::to_string() const { - std::ostringstream ss; - ss << "read8_result_t("; - ss << "status=" << status_; - ss << ", result=" << result_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const read8_result_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -read16_result_impl_t::read16_result_impl_t(response_enum_t status, - uint16_t result) : - status_(status), result_(result) { -} - -response_enum_t -read16_result_impl_t::status() const { - return status_; -} - -void -read16_result_impl_t::status_is(response_enum_t status) { - status_ = status; -} - -uint16_t -read16_result_impl_t::result() const { - return result_; -} - -void -read16_result_impl_t::result_is(uint16_t result) { - result_ = result; -} - -bool -read16_result_impl_t::operator==(read16_result_impl_t const & other) const { - return status_ == other.status_ && - result_ == other.result_; -} - -bool -read16_result_impl_t::operator!=(read16_result_impl_t const & other) const { - return !operator==(other); -} - -uint32_t -read16_result_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -read16_result_impl_t::mix_me(hash_mix & h) const { - h.mix(status_); // response_enum_t - h.mix(result_); // uint16_t -} - -std::string -read16_result_impl_t::to_string() const { - std::ostringstream ss; - ss << "read16_result_t("; - ss << "status=" << status_; - ss << ", result=" << result_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const read16_result_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -read_result_impl_t::read_result_impl_t(response_enum_t status, - ByteString result) : - status_(status), result_(result) { -} - -response_enum_t -read_result_impl_t::status() const { - return status_; -} - -void -read_result_impl_t::status_is(response_enum_t status) { - status_ = status; -} - -ByteString -read_result_impl_t::result() const { - return result_; -} - -void -read_result_impl_t::result_is(ByteString result) { - result_ = result; -} - -bool -read_result_impl_t::operator==(read_result_impl_t const & other) const { - return status_ == other.status_ && - result_ == other.result_; -} - -bool -read_result_impl_t::operator!=(read_result_impl_t const & other) const { - return !operator==(other); -} - -uint32_t -read_result_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -read_result_impl_t::mix_me(hash_mix & h) const { - h.mix(status_); // response_enum_t - h.mix(result_); // ByteString -} - -std::string -read_result_impl_t::to_string() const { - std::ostringstream ss; - ss << "read_result_t("; - ss << "status=" << status_; - ss << ", result=" << result_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const read_result_impl_t& obj) { - os << obj.to_string(); - return os; -} - - - -register_impl_t::register_impl_t() : - reg_() { -} - -uint32_t -register_impl_t::reg() const { - return reg_; -} - -void -register_impl_t::reg_is(uint32_t reg) { - reg_ = reg; -} - -bool -register_impl_t::operator==(register_impl_t const & other) const { - return reg_ == other.reg_; -} - -bool -register_impl_t::operator!=(register_impl_t const & other) const { - return !operator==(other); -} - -bool -register_impl_t::operator<(register_impl_t const & other) const { - if(reg_ != other.reg_) { - return reg_ < other.reg_; - } - return false; -} - -uint32_t -register_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -register_impl_t::mix_me(hash_mix & h) const { - h.mix(reg_); // uint32_t -} - -std::string -register_impl_t::to_string() const { - std::ostringstream ss; - ss << "register_t("; - ss << "reg=" << reg_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const register_impl_t& obj) { - os << obj.to_string(); - return os; -} - - -} - -#include - -#endif // EOS_INLINE_TYPES_HAM_IMPL_H diff --git a/eos/inline/types/ip_route.h b/eos/inline/types/ip_route.h index 21e3aeb..a37a3c0 100644 --- a/eos/inline/types/ip_route.h +++ b/eos/inline/types/ip_route.h @@ -152,6 +152,14 @@ void ip_route_t::rib_bypass_is(bool rib_bypass) { pimpl->rib_bypass_is(rib_bypass); } +std::string +ip_route_t::command_tag() const { + return pimpl->command_tag(); +} +void +ip_route_t::command_tag_is(std::string const & command_tag) { + pimpl->command_tag_is(command_tag); +} bool ip_route_t::operator==(ip_route_t const & other) const { return pimpl->operator==(*other.pimpl); @@ -301,6 +309,14 @@ void ip_route_via_t::vtep_sip_validation_is(bool vtep_sip_validation) { pimpl->vtep_sip_validation_is(vtep_sip_validation); } +ip_via_weight_t +ip_route_via_t::weight() const { + return pimpl->weight(); +} +void +ip_route_via_t::weight_is(ip_via_weight_t weight) { + pimpl->weight_is(weight); +} bool ip_route_via_t::operator==(ip_route_via_t const & other) const { return pimpl->operator==(*other.pimpl); diff --git a/eos/inline/types/ip_route_impl.h b/eos/inline/types/ip_route_impl.h index 541840d..6e7f714 100644 --- a/eos/inline/types/ip_route_impl.h +++ b/eos/inline/types/ip_route_impl.h @@ -84,11 +84,11 @@ operator<<(std::ostream& os, const ip_route_key_impl_t& obj) { ip_route_impl_t::ip_route_impl_t() : - key_(), tag_(0), rib_bypass_() { + key_(), tag_(0), rib_bypass_(), command_tag_() { } ip_route_impl_t::ip_route_impl_t(ip_route_key_t const & key) : - key_(key), tag_(0), rib_bypass_() { + key_(key), tag_(0), rib_bypass_(), command_tag_() { } ip_route_key_t @@ -121,11 +121,22 @@ ip_route_impl_t::rib_bypass_is(bool rib_bypass) { rib_bypass_ = rib_bypass; } +std::string +ip_route_impl_t::command_tag() const { + return command_tag_; +} + +void +ip_route_impl_t::command_tag_is(std::string const & command_tag) { + command_tag_ = command_tag; +} + bool ip_route_impl_t::operator==(ip_route_impl_t const & other) const { return key_ == other.key_ && tag_ == other.tag_ && - rib_bypass_ == other.rib_bypass_; + rib_bypass_ == other.rib_bypass_ && + command_tag_ == other.command_tag_; } bool @@ -145,6 +156,7 @@ ip_route_impl_t::mix_me(hash_mix & h) const { h.mix(key_); // ip_route_key_t h.mix(tag_); // ip_route_tag_t h.mix(rib_bypass_); // bool + h.mix(command_tag_); // std::string } std::string @@ -154,6 +166,7 @@ ip_route_impl_t::to_string() const { ss << "key=" << key_; ss << ", tag=" << tag_; ss << ", rib_bypass=" << rib_bypass_; + ss << ", command_tag='" << command_tag_ << "'"; ss << ")"; return ss.str(); } @@ -169,13 +182,13 @@ operator<<(std::ostream& os, const ip_route_impl_t& obj) { ip_route_via_impl_t::ip_route_via_impl_t() : route_key_(), hop_(), intf_(), nexthop_group_(), mpls_label_(), vni_(), vtep_addr_(), router_mac_(), egress_vrf_(), metric_(0), vxlan_intf_(), - vtep_sip_validation_() { + vtep_sip_validation_(), weight_() { } ip_route_via_impl_t::ip_route_via_impl_t(ip_route_key_t const & route_key) : route_key_(route_key), hop_(), intf_(), nexthop_group_(), mpls_label_(), vni_(), vtep_addr_(), router_mac_(), egress_vrf_(), metric_(0), - vxlan_intf_(), vtep_sip_validation_() { + vxlan_intf_(), vtep_sip_validation_(), weight_() { } ip_route_key_t @@ -298,6 +311,16 @@ ip_route_via_impl_t::vtep_sip_validation_is(bool vtep_sip_validation) { vtep_sip_validation_ = vtep_sip_validation; } +ip_via_weight_t +ip_route_via_impl_t::weight() const { + return weight_; +} + +void +ip_route_via_impl_t::weight_is(ip_via_weight_t weight) { + weight_ = weight; +} + bool ip_route_via_impl_t::operator==(ip_route_via_impl_t const & other) const { return route_key_ == other.route_key_ && @@ -311,7 +334,8 @@ ip_route_via_impl_t::operator==(ip_route_via_impl_t const & other) const { egress_vrf_ == other.egress_vrf_ && metric_ == other.metric_ && vxlan_intf_ == other.vxlan_intf_ && - vtep_sip_validation_ == other.vtep_sip_validation_; + vtep_sip_validation_ == other.vtep_sip_validation_ && + weight_ == other.weight_; } bool @@ -340,6 +364,7 @@ ip_route_via_impl_t::mix_me(hash_mix & h) const { h.mix(metric_); // ip_via_metric_t h.mix(vxlan_intf_); // intf_id_t h.mix(vtep_sip_validation_); // bool + h.mix(weight_); // ip_via_weight_t } std::string @@ -358,6 +383,7 @@ ip_route_via_impl_t::to_string() const { ss << ", metric=" << metric_; ss << ", vxlan_intf=" << vxlan_intf_; ss << ", vtep_sip_validation=" << vtep_sip_validation_; + ss << ", weight=" << weight_; ss << ")"; return ss.str(); } diff --git a/eos/inline/types/l1_source.h b/eos/inline/types/l1_source.h deleted file mode 100644 index af4df93..0000000 --- a/eos/inline/types/l1_source.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_L1_SOURCE_H -#define EOS_INLINE_TYPES_L1_SOURCE_H - -namespace eos { - -EOS_SDK_PUBLIC std::ostream& -operator<<(std::ostream& os, const l1_source_type_t & enum_val) { - if (enum_val==unknown) { - os << "unknown"; - } else if (enum_val==none) { - os << "none"; - } else if (enum_val==port) { - os << "port"; - } else if (enum_val==mac) { - os << "mac"; - } else if (enum_val==switchPort) { - os << "switchPort"; - } else { - os << "Unknown value"; - } - return os; -} - - -l1_source_t::l1_source_t() { - pimpl = std::shared_ptr( - new l1_source_impl_t() - ); -} -l1_source_t::l1_source_t(l1_source_type_t l1_source_type) { - pimpl = std::shared_ptr( - new l1_source_impl_t( - l1_source_type - ) - ); -} -l1_source_t::l1_source_t(l1_source_type_t l1_source_type, intf_id_t port) { - pimpl = std::shared_ptr( - new l1_source_impl_t( - l1_source_type, - port - ) - ); -} -l1_source_t::l1_source_t( - const l1_source_t& other) -{ - pimpl = std::make_unique( - l1_source_impl_t(*other.pimpl)); -} -l1_source_t& -l1_source_t::operator=( - l1_source_t const & other) -{ - pimpl = std::shared_ptr( - new l1_source_impl_t(*other.pimpl)); - return *this; -} - -l1_source_type_t -l1_source_t::l1_source_type() const { - return pimpl->l1_source_type(); -} -void -l1_source_t::l1_source_type_is(l1_source_type_t l1_source_type) { - pimpl->l1_source_type_is(l1_source_type); -} -intf_id_t -l1_source_t::port() const { - return pimpl->port(); -} -void -l1_source_t::port_is(intf_id_t port) { - pimpl->port_is(port); -} -bool -l1_source_t::operator==(l1_source_t const & other) const { - return pimpl->operator==(*other.pimpl); -} -bool -l1_source_t::operator!=(l1_source_t const & other) const { - return pimpl->operator!=(*other.pimpl); -} -bool -l1_source_t::operator<(l1_source_t const & other) const { - return pimpl->operator<(*other.pimpl); -} -uint32_t -l1_source_t::hash() const { - return pimpl->hash(); -} -void -l1_source_t::mix_me(hash_mix & h) const { - pimpl->mix_me(h); -} -std::string -l1_source_t::to_string() const { - return pimpl->to_string(); -} -std::ostream& -operator<<(std::ostream& os, const l1_source_t& obj) { - return operator<<(os, *obj.pimpl); -} - -} - -#endif // EOS_INLINE_TYPES_L1_SOURCE_H diff --git a/eos/inline/types/l1_source_impl.h b/eos/inline/types/l1_source_impl.h deleted file mode 100644 index 821773d..0000000 --- a/eos/inline/types/l1_source_impl.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_INLINE_TYPES_L1_SOURCE_IMPL_H -#define EOS_INLINE_TYPES_L1_SOURCE_IMPL_H - -namespace eos { - - - -l1_source_impl_t::l1_source_impl_t() : - l1_source_type_(), port_() { -} - -l1_source_impl_t::l1_source_impl_t(l1_source_type_t l1_source_type) : - l1_source_type_(l1_source_type), port_() { -} - -l1_source_impl_t::l1_source_impl_t(l1_source_type_t l1_source_type, - intf_id_t port) : - l1_source_type_(l1_source_type), port_(port) { -} - -l1_source_type_t -l1_source_impl_t::l1_source_type() const { - return l1_source_type_; -} - -void -l1_source_impl_t::l1_source_type_is(l1_source_type_t l1_source_type) { - l1_source_type_ = l1_source_type; -} - -intf_id_t -l1_source_impl_t::port() const { - return port_; -} - -void -l1_source_impl_t::port_is(intf_id_t port) { - port_ = port; -} - -bool -l1_source_impl_t::operator==(l1_source_impl_t const & other) const { - return l1_source_type_ == other.l1_source_type_ && - port_ == other.port_; -} - -bool -l1_source_impl_t::operator!=(l1_source_impl_t const & other) const { - return !operator==(other); -} - -bool -l1_source_impl_t::operator<(l1_source_impl_t const & other) const { - if(l1_source_type_ != other.l1_source_type_) { - return l1_source_type_ < other.l1_source_type_; - } else if(port_ != other.port_) { - return port_ < other.port_; - } - return false; -} - -uint32_t -l1_source_impl_t::hash() const { - hash_mix h; - mix_me(h); - return h.result(); -} - -void -l1_source_impl_t::mix_me(hash_mix & h) const { - h.mix(l1_source_type_); // l1_source_type_t - h.mix(port_); // intf_id_t -} - -std::string -l1_source_impl_t::to_string() const { - std::ostringstream ss; - ss << "l1_source_t("; - ss << "l1_source_type=" << l1_source_type_; - ss << ", port=" << port_; - ss << ")"; - return ss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const l1_source_impl_t& obj) { - os << obj.to_string(); - return os; -} - - -} - -#include - -#endif // EOS_INLINE_TYPES_L1_SOURCE_IMPL_H diff --git a/eos/inline/types/mac_table.h b/eos/inline/types/mac_table.h index 9748bfa..4376277 100644 --- a/eos/inline/types/mac_table.h +++ b/eos/inline/types/mac_table.h @@ -66,6 +66,8 @@ operator<<(std::ostream& os, const mac_entry_type_t & enum_val) { os << "MAC_ENTRY_PENDING_SECURE"; } else if (enum_val==MAC_ENTRY_VPLS_DYNAMIC_REMOTE) { os << "MAC_ENTRY_VPLS_DYNAMIC_REMOTE"; + } else if (enum_val==MAC_ENTRY_SOFTWARE_LEARNED_DYNAMIC) { + os << "MAC_ENTRY_SOFTWARE_LEARNED_DYNAMIC"; } else { os << "Unknown value"; } diff --git a/eos/inline/types/macsec_impl.h b/eos/inline/types/macsec_impl.h index cde46a4..3dd3734 100644 --- a/eos/inline/types/macsec_impl.h +++ b/eos/inline/types/macsec_impl.h @@ -110,7 +110,7 @@ operator<<(std::ostream& os, const macsec_key_impl_t& obj) { macsec_profile_impl_t::macsec_profile_impl_t() : name_(), primary_key_(), fallback_key_(), key_server_priority_(16), rekey_period_(0), mka_life_time_(6), cipher_(GCM_AES_XPN_128), dot1x_(false), - include_sci_(false), bypass_lldp_(false), lldp_bypass_level_(BYPASS_NULL), + include_sci_(false), lldp_bypass_level_(BYPASS_NULL), traffic_policy_(TRAFFIC_POLICY_ACTIVE_SAK), replay_protection_(true), replay_protection_window_(0), key_retirement_immediate_(false), intfs_() { } @@ -118,7 +118,7 @@ macsec_profile_impl_t::macsec_profile_impl_t() : macsec_profile_impl_t::macsec_profile_impl_t(macsec_profile_name_t name) : name_(name), primary_key_(), fallback_key_(), key_server_priority_(16), rekey_period_(0), mka_life_time_(6), cipher_(GCM_AES_XPN_128), dot1x_(false), - include_sci_(false), bypass_lldp_(false), lldp_bypass_level_(BYPASS_NULL), + include_sci_(false), lldp_bypass_level_(BYPASS_NULL), traffic_policy_(TRAFFIC_POLICY_ACTIVE_SAK), replay_protection_(true), replay_protection_window_(0), key_retirement_immediate_(false), intfs_() { } @@ -302,7 +302,6 @@ macsec_profile_impl_t::operator==(macsec_profile_impl_t const & other) const { cipher_ == other.cipher_ && dot1x_ == other.dot1x_ && include_sci_ == other.include_sci_ && - bypass_lldp_ == other.bypass_lldp_ && lldp_bypass_level_ == other.lldp_bypass_level_ && traffic_policy_ == other.traffic_policy_ && replay_protection_ == other.replay_protection_ && @@ -336,8 +335,6 @@ macsec_profile_impl_t::operator<(macsec_profile_impl_t const & other) const { return dot1x_ < other.dot1x_; } else if(include_sci_ != other.include_sci_) { return include_sci_ < other.include_sci_; - } else if(bypass_lldp_ != other.bypass_lldp_) { - return bypass_lldp_ < other.bypass_lldp_; } else if(lldp_bypass_level_ != other.lldp_bypass_level_) { return lldp_bypass_level_ < other.lldp_bypass_level_; } else if(traffic_policy_ != other.traffic_policy_) { @@ -372,7 +369,6 @@ macsec_profile_impl_t::mix_me(hash_mix & h) const { h.mix(cipher_); // macsec_cipher_suite_t h.mix(dot1x_); // bool h.mix(include_sci_); // bool - h.mix(bypass_lldp_); // bool h.mix(lldp_bypass_level_); // macsec_bypass_t h.mix(traffic_policy_); // macsec_profile_traffic_policy_t h.mix(replay_protection_); // bool @@ -397,7 +393,6 @@ macsec_profile_impl_t::to_string() const { ss << ", cipher=" << cipher_; ss << ", dot1x=" << dot1x_; ss << ", include_sci=" << include_sci_; - ss << ", bypass_lldp=" << bypass_lldp_; ss << ", lldp_bypass_level=" << lldp_bypass_level_; ss << ", traffic_policy=" << traffic_policy_; ss << ", replay_protection=" << replay_protection_; diff --git a/eos/inline/types/nexthop_group.h b/eos/inline/types/nexthop_group.h index 47c9e08..e905b24 100644 --- a/eos/inline/types/nexthop_group.h +++ b/eos/inline/types/nexthop_group.h @@ -522,6 +522,86 @@ operator<<(std::ostream& os, const nexthop_group_t& obj) { return operator<<(os, *obj.pimpl); } + +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const nexthop_group_counter_state_t & enum_val) { + if (enum_val==NEXTHOP_GROUP_COUNTER_INACTIVE) { + os << "NEXTHOP_GROUP_COUNTER_INACTIVE"; + } else if (enum_val==NEXTHOP_GROUP_COUNTER_PROGRAMMING_FAILED) { + os << "NEXTHOP_GROUP_COUNTER_PROGRAMMING_FAILED"; + } else if (enum_val==NEXTHOP_GROUP_COUNTER_PROGRAMMING_COMPLETE) { + os << "NEXTHOP_GROUP_COUNTER_PROGRAMMING_COMPLETE"; + } else { + os << "Unknown value"; + } + return os; +} + + +nexthop_group_programmed_status_t::nexthop_group_programmed_status_t() { + pimpl = std::shared_ptr( + new nexthop_group_programmed_status_impl_t() + ); +} +nexthop_group_programmed_status_t::nexthop_group_programmed_status_t( + nexthop_group_counter_state_t counter_state) { + pimpl = std::shared_ptr( + new nexthop_group_programmed_status_impl_t( + counter_state + ) + ); +} +nexthop_group_programmed_status_t::nexthop_group_programmed_status_t( + const nexthop_group_programmed_status_t& other) +{ + pimpl = std::make_unique( + nexthop_group_programmed_status_impl_t(*other.pimpl)); +} +nexthop_group_programmed_status_t& +nexthop_group_programmed_status_t::operator=( + nexthop_group_programmed_status_t const & other) +{ + pimpl = std::shared_ptr( + new nexthop_group_programmed_status_impl_t(*other.pimpl)); + return *this; +} + +nexthop_group_counter_state_t +nexthop_group_programmed_status_t::counter_state() const { + return pimpl->counter_state(); +} +bool +nexthop_group_programmed_status_t::operator==( + nexthop_group_programmed_status_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +nexthop_group_programmed_status_t::operator!=( + nexthop_group_programmed_status_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +nexthop_group_programmed_status_t::operator<( + nexthop_group_programmed_status_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +nexthop_group_programmed_status_t::hash() const { + return pimpl->hash(); +} +void +nexthop_group_programmed_status_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +nexthop_group_programmed_status_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const nexthop_group_programmed_status_t& obj) { + return operator<<(os, *obj.pimpl); +} + } #endif // EOS_INLINE_TYPES_NEXTHOP_GROUP_H diff --git a/eos/inline/types/nexthop_group_impl.h b/eos/inline/types/nexthop_group_impl.h index 8b23a7b..43969fc 100644 --- a/eos/inline/types/nexthop_group_impl.h +++ b/eos/inline/types/nexthop_group_impl.h @@ -694,6 +694,73 @@ operator<<(std::ostream& os, const nexthop_group_impl_t& obj) { } + + + +nexthop_group_programmed_status_impl_t::nexthop_group_programmed_status_impl_t() + : + counter_state_(NEXTHOP_GROUP_COUNTER_INACTIVE) { +} + +nexthop_group_programmed_status_impl_t::nexthop_group_programmed_status_impl_t( + nexthop_group_counter_state_t counter_state) : + counter_state_(counter_state) { +} + +nexthop_group_counter_state_t +nexthop_group_programmed_status_impl_t::counter_state() const { + return counter_state_; +} + +bool +nexthop_group_programmed_status_impl_t::operator==( + nexthop_group_programmed_status_impl_t const & other) const { + return counter_state_ == other.counter_state_; +} + +bool +nexthop_group_programmed_status_impl_t::operator!=( + nexthop_group_programmed_status_impl_t const & other) const { + return !operator==(other); +} + +bool +nexthop_group_programmed_status_impl_t::operator<( + nexthop_group_programmed_status_impl_t const & other) const { + if(counter_state_ != other.counter_state_) { + return counter_state_ < other.counter_state_; + } + return false; +} + +uint32_t +nexthop_group_programmed_status_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +nexthop_group_programmed_status_impl_t::mix_me(hash_mix & h) const { + h.mix(counter_state_); // nexthop_group_counter_state_t +} + +std::string +nexthop_group_programmed_status_impl_t::to_string() const { + std::ostringstream ss; + ss << "nexthop_group_programmed_status_t("; + ss << "counter_state=" << counter_state_; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const nexthop_group_programmed_status_impl_t& obj) { + os << obj.to_string(); + return os; +} + + } #include diff --git a/eos/inline/types/policy_map.h b/eos/inline/types/policy_map.h index c623061..ea7eb63 100644 --- a/eos/inline/types/policy_map.h +++ b/eos/inline/types/policy_map.h @@ -29,6 +29,8 @@ operator<<(std::ostream& os, const policy_feature_t & enum_val) { os << "POLICY_FEATURE_QOS"; } else if (enum_val==POLICY_FEATURE_TAP_AGG) { os << "POLICY_FEATURE_TAP_AGG"; + } else if (enum_val==POLICY_FEATURE_TRAFFIC_POLICY) { + os << "POLICY_FEATURE_TRAFFIC_POLICY"; } else { os << "Unknown value"; } @@ -59,6 +61,56 @@ operator<<(std::ostream& os, const policy_action_type_t & enum_val) { } +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const traffic_policy_action_type_t & enum_val) { + if (enum_val==TRAFFIC_POLICY_ACTION_DROP) { + os << "TRAFFIC_POLICY_ACTION_DROP"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_POLICE) { + os << "TRAFFIC_POLICY_ACTION_POLICE"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_COUNT) { + os << "TRAFFIC_POLICY_ACTION_COUNT"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_LOG) { + os << "TRAFFIC_POLICY_ACTION_LOG"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_GOTO) { + os << "TRAFFIC_POLICY_ACTION_GOTO"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_DSCP) { + os << "TRAFFIC_POLICY_ACTION_DSCP"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_TRAFFIC_CLASS) { + os << "TRAFFIC_POLICY_ACTION_TRAFFIC_CLASS"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_SET_VRF) { + os << "TRAFFIC_POLICY_ACTION_SET_VRF"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_SET_VRF_SECONDARY) { + os << "TRAFFIC_POLICY_ACTION_SET_VRF_SECONDARY"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_USE_VRF_SECONDARY) { + os << "TRAFFIC_POLICY_ACTION_USE_VRF_SECONDARY"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_MIRROR) { + os << "TRAFFIC_POLICY_ACTION_MIRROR"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_SFLOW) { + os << "TRAFFIC_POLICY_ACTION_SFLOW"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_NEXTHOP) { + os << "TRAFFIC_POLICY_ACTION_NEXTHOP"; + } else if (enum_val==TRAFFIC_POLICY_ACTION_NEXTHOP_GROUP) { + os << "TRAFFIC_POLICY_ACTION_NEXTHOP_GROUP"; + } else { + os << "Unknown value"; + } + return os; +} + + +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const traffic_policy_direction_t & enum_val) { + if (enum_val==TRAFFIC_POLICY_DIRECTION_NULL) { + os << "TRAFFIC_POLICY_DIRECTION_NULL"; + } else if (enum_val==TRAFFIC_POLICY_DIRECTION_INPUT) { + os << "TRAFFIC_POLICY_DIRECTION_INPUT"; + } else { + os << "Unknown value"; + } + return os; +} + + EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const policy_map_rule_type_t & enum_val) { if (enum_val==POLICY_RULE_TYPE_CLASSMAP) { @@ -149,7 +201,39 @@ operator<<(std::ostream& os, const policy_map_key_t& obj) { } -// Default constructor. +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const police_rate_unit_t & enum_val) { + if (enum_val==BPS) { + os << "BPS"; + } else if (enum_val==KBPS) { + os << "KBPS"; + } else if (enum_val==MBPS) { + os << "MBPS"; + } else if (enum_val==GBPS) { + os << "GBPS"; + } else { + os << "Unknown value"; + } + return os; +} + + +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const police_burst_unit_t & enum_val) { + if (enum_val==BYTES) { + os << "BYTES"; + } else if (enum_val==KBYTES) { + os << "KBYTES"; + } else if (enum_val==MBYTES) { + os << "MBYTES"; + } else { + os << "Unknown value"; + } + return os; +} + + +// Default constructor of a PBR/QOS action. policy_map_action_t::policy_map_action_t() { pimpl = std::shared_ptr( new policy_map_action_impl_t() @@ -267,6 +351,193 @@ operator<<(std::ostream& os, const policy_map_action_t& obj) { } +// Default constructor of a traffic-policy action. +traffic_policy_action_t::traffic_policy_action_t() { + pimpl = std::shared_ptr( + new traffic_policy_action_impl_t() + ); +} +traffic_policy_action_t::traffic_policy_action_t( + traffic_policy_action_type_t action_type) { + pimpl = std::shared_ptr( + new traffic_policy_action_impl_t( + action_type + ) + ); +} +traffic_policy_action_t::traffic_policy_action_t( + const traffic_policy_action_t& other) +{ + pimpl = std::make_unique( + traffic_policy_action_impl_t(*other.pimpl)); +} +traffic_policy_action_t& +traffic_policy_action_t::operator=( + traffic_policy_action_t const & other) +{ + pimpl = std::shared_ptr( + new traffic_policy_action_impl_t(*other.pimpl)); + return *this; +} + + +traffic_policy_action_t::~traffic_policy_action_t() { + +} +traffic_policy_action_type_t +traffic_policy_action_t::action_type() const { + return pimpl->action_type(); +} +void +traffic_policy_action_t::action_type_is(traffic_policy_action_type_t action_type) { + pimpl->action_type_is(action_type); +} +std::string +traffic_policy_action_t::goto_class_name() const { + return pimpl->goto_class_name(); +} +void +traffic_policy_action_t::goto_class_name_is(std::string const & goto_class_name) { + pimpl->goto_class_name_is(goto_class_name); +} +bool +traffic_policy_action_t::goto_next() const { + return pimpl->goto_next(); +} +void +traffic_policy_action_t::goto_next_is(bool const & goto_next) { + pimpl->goto_next_is(goto_next); +} +uint8_t +traffic_policy_action_t::dscp() const { + return pimpl->dscp(); +} +void +traffic_policy_action_t::dscp_is(uint8_t dscp) { + pimpl->dscp_is(dscp); +} +uint8_t +traffic_policy_action_t::traffic_class() const { + return pimpl->traffic_class(); +} +void +traffic_policy_action_t::traffic_class_is(uint8_t traffic_class) { + pimpl->traffic_class_is(traffic_class); +} +std::string +traffic_policy_action_t::vrf() const { + return pimpl->vrf(); +} +void +traffic_policy_action_t::vrf_is(std::string const & vrf) { + pimpl->vrf_is(vrf); +} +std::string +traffic_policy_action_t::mirror_session() const { + return pimpl->mirror_session(); +} +void +traffic_policy_action_t::mirror_session_is(std::string const & mirror_session) { + pimpl->mirror_session_is(mirror_session); +} +uint64_t +traffic_policy_action_t::police_rate() const { + return pimpl->police_rate(); +} +void +traffic_policy_action_t::police_rate_is(uint64_t const & police_rate) { + pimpl->police_rate_is(police_rate); +} +uint64_t +traffic_policy_action_t::police_burst_size() const { + return pimpl->police_burst_size(); +} +void +traffic_policy_action_t::police_burst_size_is(uint64_t const & police_burst_size) { + pimpl->police_burst_size_is(police_burst_size); +} +police_rate_unit_t +traffic_policy_action_t::police_rate_unit() const { + return pimpl->police_rate_unit(); +} +void +traffic_policy_action_t::police_rate_unit_is( + police_rate_unit_t const & police_rate_unit) { + pimpl->police_rate_unit_is(police_rate_unit); +} +police_burst_unit_t +traffic_policy_action_t::police_burst_unit() const { + return pimpl->police_burst_unit(); +} +void +traffic_policy_action_t::police_burst_unit_is( + police_burst_unit_t const & police_burst_unit) { + pimpl->police_burst_unit_is(police_burst_unit); +} +std::unordered_set const & +traffic_policy_action_t::nexthop_groups() const { + return pimpl->nexthop_groups(); +} +void +traffic_policy_action_t::nexthop_groups_is( + std::unordered_set const & nexthop_groups) { + pimpl->nexthop_groups_is(nexthop_groups); +} +void +traffic_policy_action_t::nexthop_group_set(std::string const & value) { + pimpl->nexthop_group_set(value); +} +void +traffic_policy_action_t::nexthop_group_del(std::string const & value) { + pimpl->nexthop_group_del(value); +} +std::unordered_set const & +traffic_policy_action_t::nexthops() const { + return pimpl->nexthops(); +} +void +traffic_policy_action_t::nexthops_is( + std::unordered_set const & nexthops) { + pimpl->nexthops_is(nexthops); +} +void +traffic_policy_action_t::nexthop_set(ip_addr_t const & value) { + pimpl->nexthop_set(value); +} +void +traffic_policy_action_t::nexthop_del(ip_addr_t const & value) { + pimpl->nexthop_del(value); +} +bool +traffic_policy_action_t::operator==(traffic_policy_action_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +traffic_policy_action_t::operator!=(traffic_policy_action_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +traffic_policy_action_t::operator<(traffic_policy_action_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +traffic_policy_action_t::hash() const { + return pimpl->hash(); +} +void +traffic_policy_action_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +traffic_policy_action_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const traffic_policy_action_t& obj) { + return operator<<(os, *obj.pimpl); +} + + policy_map_rule_t::policy_map_rule_t() { pimpl = std::shared_ptr( new policy_map_rule_impl_t() @@ -455,6 +726,176 @@ operator<<(std::ostream& os, const policy_map_t& obj) { } +traffic_policy_rule_t::traffic_policy_rule_t() { + pimpl = std::shared_ptr( + new traffic_policy_rule_impl_t() + ); +} +traffic_policy_rule_t::traffic_policy_rule_t( + std::string match_rule_name, + traffic_policy_rule_type_t traffic_policy_rule_type) { + pimpl = std::shared_ptr( + new traffic_policy_rule_impl_t( + match_rule_name, + traffic_policy_rule_type + ) + ); +} +traffic_policy_rule_t::traffic_policy_rule_t( + const traffic_policy_rule_t& other) +{ + pimpl = std::make_unique( + traffic_policy_rule_impl_t(*other.pimpl)); +} +traffic_policy_rule_t& +traffic_policy_rule_t::operator=( + traffic_policy_rule_t const & other) +{ + pimpl = std::shared_ptr( + new traffic_policy_rule_impl_t(*other.pimpl)); + return *this; +} + +std::string +traffic_policy_rule_t::match_rule_name() const { + return pimpl->match_rule_name(); +} +traffic_policy_rule_type_t +traffic_policy_rule_t::traffic_policy_rule_type() const { + return pimpl->traffic_policy_rule_type(); +} +tp_rule_filter_t +traffic_policy_rule_t::raw_rule() const { + return pimpl->raw_rule(); +} +std::set const & +traffic_policy_rule_t::actions() const { + return pimpl->actions(); +} +void +traffic_policy_rule_t::actions_is( + std::set const & actions) { + pimpl->actions_is(actions); +} +void +traffic_policy_rule_t::action_set(traffic_policy_action_t const & value) { + pimpl->action_set(value); +} +void +traffic_policy_rule_t::action_del(traffic_policy_action_t const & value) { + pimpl->action_del(value); +} +void +traffic_policy_rule_t::raw_rule_is(tp_rule_filter_t const & raw_rule) { + pimpl->raw_rule_is(raw_rule); +} +void +traffic_policy_rule_t::action_del(traffic_policy_action_type_t action_type) { + pimpl->action_del(action_type); +} +bool +traffic_policy_rule_t::operator==(traffic_policy_rule_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +traffic_policy_rule_t::operator!=(traffic_policy_rule_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +traffic_policy_rule_t::operator<(traffic_policy_rule_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +traffic_policy_rule_t::hash() const { + return pimpl->hash(); +} +void +traffic_policy_rule_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +traffic_policy_rule_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const traffic_policy_rule_t& obj) { + return operator<<(os, *obj.pimpl); +} + + +traffic_policy_t::traffic_policy_t(std::string const & key) { + pimpl = std::shared_ptr( + new traffic_policy_impl_t( + key + ) + ); +} +traffic_policy_t::traffic_policy_t( + const traffic_policy_t& other) +{ + pimpl = std::make_unique( + traffic_policy_impl_t(*other.pimpl)); +} +traffic_policy_t& +traffic_policy_t::operator=( + traffic_policy_t const & other) +{ + pimpl = std::shared_ptr( + new traffic_policy_impl_t(*other.pimpl)); + return *this; +} + +std::string +traffic_policy_t::key() const { + return pimpl->key(); +} +std::map const & +traffic_policy_t::rules() const { + return pimpl->rules(); +} +void +traffic_policy_t::rules_is(std::map const & rules) + { + pimpl->rules_is(rules); +} +void +traffic_policy_t::rule_set(uint32_t key, traffic_policy_rule_t const & value) { + pimpl->rule_set(key, value); +} +void +traffic_policy_t::rule_del(uint32_t key) { + pimpl->rule_del(key); +} +bool +traffic_policy_t::operator==(traffic_policy_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +traffic_policy_t::operator!=(traffic_policy_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +traffic_policy_t::operator<(traffic_policy_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +traffic_policy_t::hash() const { + return pimpl->hash(); +} +void +traffic_policy_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +traffic_policy_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const traffic_policy_t& obj) { + return operator<<(os, *obj.pimpl); +} + + unsupported_policy_feature_error::unsupported_policy_feature_error( policy_feature_t policy_feature) noexcept : unsupported_error(std::string("Unsupported policy feature")), diff --git a/eos/inline/types/policy_map_impl.h b/eos/inline/types/policy_map_impl.h index 45fc72b..94afc82 100644 --- a/eos/inline/types/policy_map_impl.h +++ b/eos/inline/types/policy_map_impl.h @@ -14,6 +14,10 @@ namespace eos { + + + + policy_map_key_impl_t::policy_map_key_impl_t() : name_(), feature_() { } @@ -95,7 +99,11 @@ operator<<(std::ostream& os, const policy_map_key_impl_t& obj) { -// Default constructor. + + + + +// Default constructor of a PBR/QOS action. policy_map_action_impl_t::policy_map_action_impl_t() : action_type_(), nexthop_group_name_(), nexthops_(), vrf_(), dscp_(), traffic_class_() { @@ -268,6 +276,318 @@ operator<<(std::ostream& os, const policy_map_action_impl_t& obj) { +// Default constructor of a traffic-policy action. +traffic_policy_action_impl_t::traffic_policy_action_impl_t() : + action_type_(), goto_class_name_(), goto_next_(), dscp_(), traffic_class_(), + vrf_(), mirror_session_(), police_rate_(), police_burst_size_(), + police_rate_unit_(), police_burst_unit_(), nexthop_groups_(), nexthops_() { +} + +traffic_policy_action_impl_t::traffic_policy_action_impl_t( + traffic_policy_action_type_t action_type) : + action_type_(action_type), goto_class_name_(), goto_next_(), dscp_(), + traffic_class_(), vrf_(), mirror_session_(), police_rate_(), + police_burst_size_(), police_rate_unit_(), police_burst_unit_(), + nexthop_groups_(), nexthops_() { +} + + +traffic_policy_action_impl_t::~traffic_policy_action_impl_t() { + +} + +traffic_policy_action_type_t +traffic_policy_action_impl_t::action_type() const { + return action_type_; +} + +void +traffic_policy_action_impl_t::action_type_is( + traffic_policy_action_type_t action_type) { + action_type_ = action_type; +} + +std::string +traffic_policy_action_impl_t::goto_class_name() const { + return goto_class_name_; +} + +void +traffic_policy_action_impl_t::goto_class_name_is( + std::string const & goto_class_name) { + goto_class_name_ = goto_class_name; +} + +bool +traffic_policy_action_impl_t::goto_next() const { + return goto_next_; +} + +void +traffic_policy_action_impl_t::goto_next_is(bool const & goto_next) { + goto_next_ = goto_next; +} + +uint8_t +traffic_policy_action_impl_t::dscp() const { + return dscp_; +} + +void +traffic_policy_action_impl_t::dscp_is(uint8_t dscp) { + dscp_ = dscp; +} + +uint8_t +traffic_policy_action_impl_t::traffic_class() const { + return traffic_class_; +} + +void +traffic_policy_action_impl_t::traffic_class_is(uint8_t traffic_class) { + traffic_class_ = traffic_class; +} + +std::string +traffic_policy_action_impl_t::vrf() const { + return vrf_; +} + +void +traffic_policy_action_impl_t::vrf_is(std::string const & vrf) { + vrf_ = vrf; +} + +std::string +traffic_policy_action_impl_t::mirror_session() const { + return mirror_session_; +} + +void +traffic_policy_action_impl_t::mirror_session_is(std::string const & mirror_session) + { + mirror_session_ = mirror_session; +} + +uint64_t +traffic_policy_action_impl_t::police_rate() const { + return police_rate_; +} + +void +traffic_policy_action_impl_t::police_rate_is(uint64_t const & police_rate) { + police_rate_ = police_rate; +} + +uint64_t +traffic_policy_action_impl_t::police_burst_size() const { + return police_burst_size_; +} + +void +traffic_policy_action_impl_t::police_burst_size_is( + uint64_t const & police_burst_size) { + police_burst_size_ = police_burst_size; +} + +police_rate_unit_t +traffic_policy_action_impl_t::police_rate_unit() const { + return police_rate_unit_; +} + +void +traffic_policy_action_impl_t::police_rate_unit_is( + police_rate_unit_t const & police_rate_unit) { + police_rate_unit_ = police_rate_unit; +} + +police_burst_unit_t +traffic_policy_action_impl_t::police_burst_unit() const { + return police_burst_unit_; +} + +void +traffic_policy_action_impl_t::police_burst_unit_is( + police_burst_unit_t const & police_burst_unit) { + police_burst_unit_ = police_burst_unit; +} + +std::unordered_set const & +traffic_policy_action_impl_t::nexthop_groups() const { + return nexthop_groups_; +} + +void +traffic_policy_action_impl_t::nexthop_groups_is( + std::unordered_set const & nexthop_groups) { + nexthop_groups_ = nexthop_groups; +} + +void +traffic_policy_action_impl_t::nexthop_group_set(std::string const & value) { + nexthop_groups_.insert(value); +} + +void +traffic_policy_action_impl_t::nexthop_group_del(std::string const & value) { + nexthop_groups_.erase(value); +} + +std::unordered_set const & +traffic_policy_action_impl_t::nexthops() const { + return nexthops_; +} + +void +traffic_policy_action_impl_t::nexthops_is( + std::unordered_set const & nexthops) { + nexthops_ = nexthops; +} + +void +traffic_policy_action_impl_t::nexthop_set(ip_addr_t const & value) { + nexthops_.insert(value); +} + +void +traffic_policy_action_impl_t::nexthop_del(ip_addr_t const & value) { + nexthops_.erase(value); +} + +bool +traffic_policy_action_impl_t::operator==( + traffic_policy_action_impl_t const & other) const { + return action_type_ == other.action_type_ && + goto_class_name_ == other.goto_class_name_ && + goto_next_ == other.goto_next_ && + dscp_ == other.dscp_ && + traffic_class_ == other.traffic_class_ && + vrf_ == other.vrf_ && + mirror_session_ == other.mirror_session_ && + police_rate_ == other.police_rate_ && + police_burst_size_ == other.police_burst_size_ && + police_rate_unit_ == other.police_rate_unit_ && + police_burst_unit_ == other.police_burst_unit_ && + nexthop_groups_ == other.nexthop_groups_ && + nexthops_ == other.nexthops_; +} + +bool +traffic_policy_action_impl_t::operator!=( + traffic_policy_action_impl_t const & other) const { + return !operator==(other); +} + +bool +traffic_policy_action_impl_t::operator<(traffic_policy_action_impl_t const & other) + const { + if(action_type_ != other.action_type_) { + return action_type_ < other.action_type_; + } else if(goto_class_name_ != other.goto_class_name_) { + return goto_class_name_ < other.goto_class_name_; + } else if(goto_next_ != other.goto_next_) { + return goto_next_ < other.goto_next_; + } else if(dscp_ != other.dscp_) { + return dscp_ < other.dscp_; + } else if(traffic_class_ != other.traffic_class_) { + return traffic_class_ < other.traffic_class_; + } else if(vrf_ != other.vrf_) { + return vrf_ < other.vrf_; + } else if(mirror_session_ != other.mirror_session_) { + return mirror_session_ < other.mirror_session_; + } else if(police_rate_ != other.police_rate_) { + return police_rate_ < other.police_rate_; + } else if(police_burst_size_ != other.police_burst_size_) { + return police_burst_size_ < other.police_burst_size_; + } else if(police_rate_unit_ != other.police_rate_unit_) { + return police_rate_unit_ < other.police_rate_unit_; + } else if(police_burst_unit_ != other.police_burst_unit_) { + return police_burst_unit_ < other.police_burst_unit_; + } + return false; +} + +uint32_t +traffic_policy_action_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +traffic_policy_action_impl_t::mix_me(hash_mix & h) const { + h.mix(action_type_); // traffic_policy_action_type_t + h.mix(goto_class_name_); // std::string + h.mix(goto_next_); // bool + h.mix(dscp_); // uint8_t + h.mix(traffic_class_); // uint8_t + h.mix(vrf_); // std::string + h.mix(mirror_session_); // std::string + h.mix(police_rate_); // uint64_t + h.mix(police_burst_size_); // uint64_t + h.mix(police_rate_unit_); // police_rate_unit_t + h.mix(police_burst_unit_); // police_burst_unit_t + for (auto it=nexthop_groups_.cbegin(); + it!=nexthop_groups_.cend(); ++it) { + h.mix(*it); // std::string + } + for (auto it=nexthops_.cbegin(); + it!=nexthops_.cend(); ++it) { + h.mix(*it); // ip_addr_t + } +} + +std::string +traffic_policy_action_impl_t::to_string() const { + std::ostringstream ss; + ss << "traffic_policy_action_t("; + ss << "action_type=" << action_type_; + ss << ", goto_class_name='" << goto_class_name_ << "'"; + ss << ", goto_next=" << goto_next_; + ss << ", dscp=" << dscp_; + ss << ", traffic_class=" << traffic_class_; + ss << ", vrf='" << vrf_ << "'"; + ss << ", mirror_session='" << mirror_session_ << "'"; + ss << ", police_rate=" << police_rate_; + ss << ", police_burst_size=" << police_burst_size_; + ss << ", police_rate_unit=" << police_rate_unit_; + ss << ", police_burst_unit=" << police_burst_unit_; + ss << ", nexthop_groups=" <<"'"; + bool first_nexthop_groups = true; + for (auto it=nexthop_groups_.cbegin(); + it!=nexthop_groups_.cend(); ++it) { + if (first_nexthop_groups) { + ss << (*it); + first_nexthop_groups = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", nexthops=" <<"'"; + bool first_nexthops = true; + for (auto it=nexthops_.cbegin(); + it!=nexthops_.cend(); ++it) { + if (first_nexthops) { + ss << (*it); + first_nexthops = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const traffic_policy_action_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + policy_map_rule_impl_t::policy_map_rule_impl_t() : class_map_key_(), policy_map_rule_type_(POLICY_RULE_TYPE_CLASSMAP), raw_rule_(), actions_() { @@ -592,6 +912,253 @@ operator<<(std::ostream& os, const policy_map_impl_t& obj) { +traffic_policy_rule_impl_t::traffic_policy_rule_impl_t() : + match_rule_name_(), traffic_policy_rule_type_(), raw_rule_(), actions_() { +} + +traffic_policy_rule_impl_t::traffic_policy_rule_impl_t( + std::string match_rule_name, + traffic_policy_rule_type_t traffic_policy_rule_type) : + match_rule_name_(match_rule_name), + traffic_policy_rule_type_(traffic_policy_rule_type), raw_rule_(), actions_() { +} + +std::string +traffic_policy_rule_impl_t::match_rule_name() const { + return match_rule_name_; +} + +traffic_policy_rule_type_t +traffic_policy_rule_impl_t::traffic_policy_rule_type() const { + return traffic_policy_rule_type_; +} + +tp_rule_filter_t +traffic_policy_rule_impl_t::raw_rule() const { + return raw_rule_; +} + +std::set const & +traffic_policy_rule_impl_t::actions() const { + return actions_; +} + +void +traffic_policy_rule_impl_t::actions_is( + std::set const & actions) { + actions_ = actions; +} + +void +traffic_policy_rule_impl_t::action_set(traffic_policy_action_t const & value) { + actions_.insert(value); +} + +void +traffic_policy_rule_impl_t::action_del(traffic_policy_action_t const & value) { + actions_.erase(value); +} + +void +traffic_policy_rule_impl_t::raw_rule_is(tp_rule_filter_t const & raw_rule) { + + std::string const TP_FILTER_TYPE_MISMATCH_CONFIG_ERROR_ = \ + "Configured filter type does not match the traffic-policy rule type"; + if(traffic_policy_rule_type_ != raw_rule.filter_type()) { + panic(configuration_error(TP_FILTER_TYPE_MISMATCH_CONFIG_ERROR_)); + } + raw_rule_ = raw_rule; + +} + +void +traffic_policy_rule_impl_t::action_del(traffic_policy_action_type_t action_type) { + auto act = actions_.begin(); + while(act != actions_.end()) { + if(act->action_type() == action_type) { + act = actions_.erase(act); + } else { + ++act; + } + } +} + +bool +traffic_policy_rule_impl_t::operator==(traffic_policy_rule_impl_t const & other) + const { + return match_rule_name_ == other.match_rule_name_ && + traffic_policy_rule_type_ == other.traffic_policy_rule_type_ && + raw_rule_ == other.raw_rule_ && + actions_ == other.actions_; +} + +bool +traffic_policy_rule_impl_t::operator!=(traffic_policy_rule_impl_t const & other) + const { + return !operator==(other); +} + +bool +traffic_policy_rule_impl_t::operator<(traffic_policy_rule_impl_t const & other) + const { + if(match_rule_name_ != other.match_rule_name_) { + return match_rule_name_ < other.match_rule_name_; + } else if(traffic_policy_rule_type_ != other.traffic_policy_rule_type_) { + return traffic_policy_rule_type_ < other.traffic_policy_rule_type_; + } else if(raw_rule_ != other.raw_rule_) { + return raw_rule_ < other.raw_rule_; + } else if(actions_ != other.actions_) { + return actions_ < other.actions_; + } + return false; +} + +uint32_t +traffic_policy_rule_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +traffic_policy_rule_impl_t::mix_me(hash_mix & h) const { + h.mix(match_rule_name_); // std::string + h.mix(traffic_policy_rule_type_); // traffic_policy_rule_type_t + h.mix(raw_rule_); // tp_rule_filter_t + for (auto it=actions_.cbegin(); + it!=actions_.cend(); ++it) { + h.mix(*it); // traffic_policy_action_t + } +} + +std::string +traffic_policy_rule_impl_t::to_string() const { + std::ostringstream ss; + ss << "traffic_policy_rule_t("; + ss << "match_rule_name='" << match_rule_name_ << "'"; + ss << ", traffic_policy_rule_type=" << traffic_policy_rule_type_; + ss << ", raw_rule=" << raw_rule_; + ss << ", actions=" <<"'"; + bool first_actions = true; + for (auto it=actions_.cbegin(); + it!=actions_.cend(); ++it) { + if (first_actions) { + ss << (*it); + first_actions = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const traffic_policy_rule_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + +traffic_policy_impl_t::traffic_policy_impl_t(std::string const & key) : + key_(key), rules_() { +} + +std::string +traffic_policy_impl_t::key() const { + return key_; +} + +std::map const & +traffic_policy_impl_t::rules() const { + return rules_; +} + +void +traffic_policy_impl_t::rules_is( + std::map const & rules) { + rules_ = rules; +} + +void +traffic_policy_impl_t::rule_set(uint32_t key, traffic_policy_rule_t const & value) { + rules_[key] = value; +} + +void +traffic_policy_impl_t::rule_del(uint32_t key) { + rules_.erase(key); +} + +bool +traffic_policy_impl_t::operator==(traffic_policy_impl_t const & other) const { + return key_ == other.key_ && + rules_ == other.rules_; +} + +bool +traffic_policy_impl_t::operator!=(traffic_policy_impl_t const & other) const { + return !operator==(other); +} + +bool +traffic_policy_impl_t::operator<(traffic_policy_impl_t const & other) const { + if(key_ != other.key_) { + return key_ < other.key_; + } else if(rules_ != other.rules_) { + return rules_ < other.rules_; + } + return false; +} + +uint32_t +traffic_policy_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +traffic_policy_impl_t::mix_me(hash_mix & h) const { + h.mix(key_); // std::string + for (auto it=rules_.cbegin(); + it!=rules_.cend(); ++it) { + h.mix(it->first); // uint32_t + h.mix(it->second); // traffic_policy_rule_t + } +} + +std::string +traffic_policy_impl_t::to_string() const { + std::ostringstream ss; + ss << "traffic_policy_t("; + ss << "key='" << key_ << "'"; + ss << ", rules=" <<"'"; + bool first_rules = true; + for (auto it=rules_.cbegin(); + it!=rules_.cend(); ++it) { + if (first_rules) { + ss << it->first << "=" << it->second; + first_rules = false; + } else { + ss << "," << it->first << "=" << it->second; + } + } + ss << "'"; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const traffic_policy_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + diff --git a/eos/inline/types/structured_filter.h b/eos/inline/types/structured_filter.h new file mode 100644 index 0000000..96d9c2d --- /dev/null +++ b/eos/inline/types/structured_filter.h @@ -0,0 +1,505 @@ +// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. +// Arista Networks, Inc. Confidential and Proprietary. + +#ifndef EOS_INLINE_TYPES_STRUCTURED_FILTER_H +#define EOS_INLINE_TYPES_STRUCTURED_FILTER_H + +namespace eos { + +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const tp_max_values_t & enum_val) { + if (enum_val==TP_MAX_PROTO) { + os << "TP_MAX_PROTO"; + } else if (enum_val==TP_MAX_L4PORT) { + os << "TP_MAX_L4PORT"; + } else { + os << "Unknown value"; + } + return os; +} + + +protocol_range_t::protocol_range_t() { + pimpl = std::shared_ptr( + new protocol_range_impl_t() + ); +} +protocol_range_t::protocol_range_t( + const protocol_range_t& other) +{ + pimpl = std::make_unique( + protocol_range_impl_t(*other.pimpl)); +} +protocol_range_t& +protocol_range_t::operator=( + protocol_range_t const & other) +{ + pimpl = std::shared_ptr( + new protocol_range_impl_t(*other.pimpl)); + return *this; +} + +uint32_t +protocol_range_t::range_start() const { + return pimpl->range_start(); +} +void +protocol_range_t::range_start_is(uint32_t range_start) { + pimpl->range_start_is(range_start); +} +uint32_t +protocol_range_t::range_end() const { + return pimpl->range_end(); +} +void +protocol_range_t::range_end_is(uint32_t range_end) { + pimpl->range_end_is(range_end); +} +bool +protocol_range_t::operator==(protocol_range_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +protocol_range_t::operator!=(protocol_range_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +protocol_range_t::operator<(protocol_range_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +protocol_range_t::hash() const { + return pimpl->hash(); +} +void +protocol_range_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +protocol_range_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const protocol_range_t& obj) { + return operator<<(os, *obj.pimpl); +} + + +port_range_t::port_range_t() { + pimpl = std::shared_ptr( + new port_range_impl_t() + ); +} +port_range_t::port_range_t( + const port_range_t& other) +{ + pimpl = std::make_unique( + port_range_impl_t(*other.pimpl)); +} +port_range_t& +port_range_t::operator=( + port_range_t const & other) +{ + pimpl = std::shared_ptr( + new port_range_impl_t(*other.pimpl)); + return *this; +} + +uint32_t +port_range_t::range_start() const { + return pimpl->range_start(); +} +void +port_range_t::range_start_is(uint32_t range_start) { + pimpl->range_start_is(range_start); +} +uint32_t +port_range_t::range_end() const { + return pimpl->range_end(); +} +void +port_range_t::range_end_is(uint32_t range_end) { + pimpl->range_end_is(range_end); +} +bool +port_range_t::operator==(port_range_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +port_range_t::operator!=(port_range_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +port_range_t::operator<(port_range_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +port_range_t::hash() const { + return pimpl->hash(); +} +void +port_range_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +port_range_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const port_range_t& obj) { + return operator<<(os, *obj.pimpl); +} + + +port_field_t::port_field_t() { + pimpl = std::shared_ptr( + new port_field_impl_t() + ); +} +port_field_t::port_field_t( + const port_field_t& other) +{ + pimpl = std::make_unique( + port_field_impl_t(*other.pimpl)); +} +port_field_t& +port_field_t::operator=( + port_field_t const & other) +{ + pimpl = std::shared_ptr( + new port_field_impl_t(*other.pimpl)); + return *this; +} + +std::set const & +port_field_t::src_ports() const { + return pimpl->src_ports(); +} +void +port_field_t::src_ports_is(std::set const & src_ports) { + pimpl->src_ports_is(src_ports); +} +void +port_field_t::src_port_set(port_range_t const & value) { + pimpl->src_port_set(value); +} +void +port_field_t::src_port_del(port_range_t const & value) { + pimpl->src_port_del(value); +} +std::set const & +port_field_t::dst_ports() const { + return pimpl->dst_ports(); +} +void +port_field_t::dst_ports_is(std::set const & dst_ports) { + pimpl->dst_ports_is(dst_ports); +} +void +port_field_t::dst_port_set(port_range_t const & value) { + pimpl->dst_port_set(value); +} +void +port_field_t::dst_port_del(port_range_t const & value) { + pimpl->dst_port_del(value); +} +std::unordered_set const & +port_field_t::src_port_field_sets() const { + return pimpl->src_port_field_sets(); +} +void +port_field_t::src_port_field_sets_is( + std::unordered_set const & src_port_field_sets) { + pimpl->src_port_field_sets_is(src_port_field_sets); +} +void +port_field_t::src_port_field_set_set(std::string const & value) { + pimpl->src_port_field_set_set(value); +} +void +port_field_t::src_port_field_set_del(std::string const & value) { + pimpl->src_port_field_set_del(value); +} +std::unordered_set const & +port_field_t::dst_port_field_sets() const { + return pimpl->dst_port_field_sets(); +} +void +port_field_t::dst_port_field_sets_is( + std::unordered_set const & dst_port_field_sets) { + pimpl->dst_port_field_sets_is(dst_port_field_sets); +} +void +port_field_t::dst_port_field_set_set(std::string const & value) { + pimpl->dst_port_field_set_set(value); +} +void +port_field_t::dst_port_field_set_del(std::string const & value) { + pimpl->dst_port_field_set_del(value); +} +bool +port_field_t::operator==(port_field_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +port_field_t::operator!=(port_field_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +port_field_t::operator<(port_field_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +port_field_t::hash() const { + return pimpl->hash(); +} +void +port_field_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +port_field_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const port_field_t& obj) { + return operator<<(os, *obj.pimpl); +} + + +protocol_field_t::protocol_field_t() { + pimpl = std::shared_ptr( + new protocol_field_impl_t() + ); +} +protocol_field_t::protocol_field_t( + const protocol_field_t& other) +{ + pimpl = std::make_unique( + protocol_field_impl_t(*other.pimpl)); +} +protocol_field_t& +protocol_field_t::operator=( + protocol_field_t const & other) +{ + pimpl = std::shared_ptr( + new protocol_field_impl_t(*other.pimpl)); + return *this; +} + +std::map const & +protocol_field_t::ports() const { + return pimpl->ports(); +} +void +protocol_field_t::ports_is(std::map const & ports) { + pimpl->ports_is(ports); +} +void +protocol_field_t::port_set(uint32_t key, port_field_t const & value) { + pimpl->port_set(key, value); +} +void +protocol_field_t::port_del(uint32_t key) { + pimpl->port_del(key); +} +bool +protocol_field_t::operator==(protocol_field_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +protocol_field_t::operator!=(protocol_field_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +protocol_field_t::operator<(protocol_field_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +protocol_field_t::hash() const { + return pimpl->hash(); +} +void +protocol_field_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +protocol_field_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const protocol_field_t& obj) { + return operator<<(os, *obj.pimpl); +} + + +EOS_SDK_PUBLIC std::ostream& +operator<<(std::ostream& os, const traffic_policy_rule_type_t & enum_val) { + if (enum_val==TRAFFIC_POLICY_RULE_TYPE_NULL) { + os << "TRAFFIC_POLICY_RULE_TYPE_NULL"; + } else if (enum_val==TRAFFIC_POLICY_RULE_TYPE_IPV4) { + os << "TRAFFIC_POLICY_RULE_TYPE_IPV4"; + } else if (enum_val==TRAFFIC_POLICY_RULE_TYPE_IPV6) { + os << "TRAFFIC_POLICY_RULE_TYPE_IPV6"; + } else { + os << "Unknown value"; + } + return os; +} + + + + + + + + + + +tp_rule_filter_t::tp_rule_filter_t() { + pimpl = std::shared_ptr( + new tp_rule_filter_impl_t() + ); +} +tp_rule_filter_t::tp_rule_filter_t(traffic_policy_rule_type_t filter_type) { + pimpl = std::shared_ptr( + new tp_rule_filter_impl_t( + filter_type + ) + ); +} +tp_rule_filter_t::tp_rule_filter_t( + const tp_rule_filter_t& other) +{ + pimpl = std::make_unique( + tp_rule_filter_impl_t(*other.pimpl)); +} +tp_rule_filter_t& +tp_rule_filter_t::operator=( + tp_rule_filter_t const & other) +{ + pimpl = std::shared_ptr( + new tp_rule_filter_impl_t(*other.pimpl)); + return *this; +} + +std::set const & +tp_rule_filter_t::src_addrs() const { + return pimpl->src_addrs(); +} +std::unordered_set const & +tp_rule_filter_t::src_addr_field_sets() const { + return pimpl->src_addr_field_sets(); +} +std::set const & +tp_rule_filter_t::dst_addrs() const { + return pimpl->dst_addrs(); +} +std::unordered_set const & +tp_rule_filter_t::dst_addr_field_sets() const { + return pimpl->dst_addr_field_sets(); +} +std::map const & +tp_rule_filter_t::protocols() const { + return pimpl->protocols(); +} +void +tp_rule_filter_t::protocols_is( + std::map const & protocols) { + pimpl->protocols_is(protocols); +} +void +tp_rule_filter_t::protocol_set(protocol_range_t key, + protocol_field_t const & value) { + pimpl->protocol_set(key, value); +} +void +tp_rule_filter_t::protocol_del(protocol_range_t key) { + pimpl->protocol_del(key); +} +traffic_policy_rule_type_t +tp_rule_filter_t::filter_type() const { + return pimpl->filter_type(); +} +void +tp_rule_filter_t::src_addr_set(ip_addr_mask_t const & value) { + pimpl->src_addr_set(value); +} +void +tp_rule_filter_t::src_addr_del(ip_addr_mask_t const & value) { + pimpl->src_addr_del(value); +} +void +tp_rule_filter_t::src_addrs_is(std::set const & src_addrs) { + pimpl->src_addrs_is(src_addrs); +} +void +tp_rule_filter_t::dst_addr_set(ip_addr_mask_t const & value) { + pimpl->dst_addr_set(value); +} +void +tp_rule_filter_t::dst_addr_del(ip_addr_mask_t const & value) { + pimpl->dst_addr_del(value); +} +void +tp_rule_filter_t::dst_addrs_is(std::set const & dst_addrs) { + pimpl->dst_addrs_is(dst_addrs); +} +void +tp_rule_filter_t::src_addr_field_set_set(std::string const & value) { + pimpl->src_addr_field_set_set(value); +} +void +tp_rule_filter_t::src_addr_field_set_del(std::string const & value) { + pimpl->src_addr_field_set_del(value); +} +void +tp_rule_filter_t::src_addr_field_sets_is( + std::unordered_set const & src_addr_field_sets) { + pimpl->src_addr_field_sets_is(src_addr_field_sets); +} +void +tp_rule_filter_t::dst_addr_field_set_set(std::string const & value) { + pimpl->dst_addr_field_set_set(value); +} +void +tp_rule_filter_t::dst_addr_field_set_del(std::string const & value) { + pimpl->dst_addr_field_set_del(value); +} +void +tp_rule_filter_t::dst_addr_field_sets_is( + std::unordered_set const & dst_addr_field_sets) { + pimpl->dst_addr_field_sets_is(dst_addr_field_sets); +} +bool +tp_rule_filter_t::operator==(tp_rule_filter_t const & other) const { + return pimpl->operator==(*other.pimpl); +} +bool +tp_rule_filter_t::operator!=(tp_rule_filter_t const & other) const { + return pimpl->operator!=(*other.pimpl); +} +bool +tp_rule_filter_t::operator<(tp_rule_filter_t const & other) const { + return pimpl->operator<(*other.pimpl); +} +uint32_t +tp_rule_filter_t::hash() const { + return pimpl->hash(); +} +void +tp_rule_filter_t::mix_me(hash_mix & h) const { + pimpl->mix_me(h); +} +std::string +tp_rule_filter_t::to_string() const { + return pimpl->to_string(); +} +std::ostream& +operator<<(std::ostream& os, const tp_rule_filter_t& obj) { + return operator<<(os, *obj.pimpl); +} + +} + +#endif // EOS_INLINE_TYPES_STRUCTURED_FILTER_H diff --git a/eos/inline/types/structured_filter_impl.h b/eos/inline/types/structured_filter_impl.h new file mode 100644 index 0000000..261e711 --- /dev/null +++ b/eos/inline/types/structured_filter_impl.h @@ -0,0 +1,811 @@ +// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. +// Arista Networks, Inc. Confidential and Proprietary. + +#ifndef EOS_INLINE_TYPES_STRUCTURED_FILTER_IMPL_H +#define EOS_INLINE_TYPES_STRUCTURED_FILTER_IMPL_H + +namespace eos { + + + +protocol_range_impl_t::protocol_range_impl_t() : + range_start_(), range_end_() { +} + +uint32_t +protocol_range_impl_t::range_start() const { + return range_start_; +} + +void +protocol_range_impl_t::range_start_is(uint32_t range_start) { + range_start_ = range_start; +} + +uint32_t +protocol_range_impl_t::range_end() const { + return range_end_; +} + +void +protocol_range_impl_t::range_end_is(uint32_t range_end) { + if (range_end > TP_MAX_PROTO) { + panic(invalid_range_error( + "range_end", + 0, + TP_MAX_PROTO)); + } + range_end_ = range_end; +} + +bool +protocol_range_impl_t::operator==(protocol_range_impl_t const & other) const { + return range_start_ == other.range_start_ && + range_end_ == other.range_end_; +} + +bool +protocol_range_impl_t::operator!=(protocol_range_impl_t const & other) const { + return !operator==(other); +} + +bool +protocol_range_impl_t::operator<(protocol_range_impl_t const & other) const { + if(range_start_ != other.range_start_) { + return range_start_ < other.range_start_; + } else if(range_end_ != other.range_end_) { + return range_end_ < other.range_end_; + } + return false; +} + +uint32_t +protocol_range_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +protocol_range_impl_t::mix_me(hash_mix & h) const { + h.mix(range_start_); // uint32_t + h.mix(range_end_); // uint32_t +} + +std::string +protocol_range_impl_t::to_string() const { + std::ostringstream ss; + ss << "protocol_range_t("; + ss << "range_start=" << range_start_; + ss << ", range_end=" << range_end_; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const protocol_range_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + +port_range_impl_t::port_range_impl_t() : + range_start_(), range_end_() { +} + +uint32_t +port_range_impl_t::range_start() const { + return range_start_; +} + +void +port_range_impl_t::range_start_is(uint32_t range_start) { + range_start_ = range_start; +} + +uint32_t +port_range_impl_t::range_end() const { + return range_end_; +} + +void +port_range_impl_t::range_end_is(uint32_t range_end) { + if (range_end > TP_MAX_L4PORT) { + panic(invalid_range_error( + "range_end", + 0, + TP_MAX_L4PORT)); + } + range_end_ = range_end; +} + +bool +port_range_impl_t::operator==(port_range_impl_t const & other) const { + return range_start_ == other.range_start_ && + range_end_ == other.range_end_; +} + +bool +port_range_impl_t::operator!=(port_range_impl_t const & other) const { + return !operator==(other); +} + +bool +port_range_impl_t::operator<(port_range_impl_t const & other) const { + if(range_start_ != other.range_start_) { + return range_start_ < other.range_start_; + } else if(range_end_ != other.range_end_) { + return range_end_ < other.range_end_; + } + return false; +} + +uint32_t +port_range_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +port_range_impl_t::mix_me(hash_mix & h) const { + h.mix(range_start_); // uint32_t + h.mix(range_end_); // uint32_t +} + +std::string +port_range_impl_t::to_string() const { + std::ostringstream ss; + ss << "port_range_t("; + ss << "range_start=" << range_start_; + ss << ", range_end=" << range_end_; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const port_range_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + +port_field_impl_t::port_field_impl_t() : + src_ports_(), dst_ports_(), src_port_field_sets_(), dst_port_field_sets_() { +} + +std::set const & +port_field_impl_t::src_ports() const { + return src_ports_; +} + +void +port_field_impl_t::src_ports_is(std::set const & src_ports) { + src_ports_ = src_ports; +} + +void +port_field_impl_t::src_port_set(port_range_t const & value) { + src_ports_.insert(value); +} + +void +port_field_impl_t::src_port_del(port_range_t const & value) { + src_ports_.erase(value); +} + +std::set const & +port_field_impl_t::dst_ports() const { + return dst_ports_; +} + +void +port_field_impl_t::dst_ports_is(std::set const & dst_ports) { + dst_ports_ = dst_ports; +} + +void +port_field_impl_t::dst_port_set(port_range_t const & value) { + dst_ports_.insert(value); +} + +void +port_field_impl_t::dst_port_del(port_range_t const & value) { + dst_ports_.erase(value); +} + +std::unordered_set const & +port_field_impl_t::src_port_field_sets() const { + return src_port_field_sets_; +} + +void +port_field_impl_t::src_port_field_sets_is( + std::unordered_set const & src_port_field_sets) { + src_port_field_sets_ = src_port_field_sets; +} + +void +port_field_impl_t::src_port_field_set_set(std::string const & value) { + src_port_field_sets_.insert(value); +} + +void +port_field_impl_t::src_port_field_set_del(std::string const & value) { + src_port_field_sets_.erase(value); +} + +std::unordered_set const & +port_field_impl_t::dst_port_field_sets() const { + return dst_port_field_sets_; +} + +void +port_field_impl_t::dst_port_field_sets_is( + std::unordered_set const & dst_port_field_sets) { + dst_port_field_sets_ = dst_port_field_sets; +} + +void +port_field_impl_t::dst_port_field_set_set(std::string const & value) { + dst_port_field_sets_.insert(value); +} + +void +port_field_impl_t::dst_port_field_set_del(std::string const & value) { + dst_port_field_sets_.erase(value); +} + +bool +port_field_impl_t::operator==(port_field_impl_t const & other) const { + return src_ports_ == other.src_ports_ && + dst_ports_ == other.dst_ports_ && + src_port_field_sets_ == other.src_port_field_sets_ && + dst_port_field_sets_ == other.dst_port_field_sets_; +} + +bool +port_field_impl_t::operator!=(port_field_impl_t const & other) const { + return !operator==(other); +} + +bool +port_field_impl_t::operator<(port_field_impl_t const & other) const { + if(src_ports_ != other.src_ports_) { + return src_ports_ < other.src_ports_; + } else if(dst_ports_ != other.dst_ports_) { + return dst_ports_ < other.dst_ports_; + } + return false; +} + +uint32_t +port_field_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +port_field_impl_t::mix_me(hash_mix & h) const { + for (auto it=src_ports_.cbegin(); + it!=src_ports_.cend(); ++it) { + h.mix(*it); // port_range_t + } + for (auto it=dst_ports_.cbegin(); + it!=dst_ports_.cend(); ++it) { + h.mix(*it); // port_range_t + } + for (auto it=src_port_field_sets_.cbegin(); + it!=src_port_field_sets_.cend(); ++it) { + h.mix(*it); // std::string + } + for (auto it=dst_port_field_sets_.cbegin(); + it!=dst_port_field_sets_.cend(); ++it) { + h.mix(*it); // std::string + } +} + +std::string +port_field_impl_t::to_string() const { + std::ostringstream ss; + ss << "port_field_t("; + ss << "src_ports=" <<"'"; + bool first_src_ports = true; + for (auto it=src_ports_.cbegin(); + it!=src_ports_.cend(); ++it) { + if (first_src_ports) { + ss << (*it); + first_src_ports = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", dst_ports=" <<"'"; + bool first_dst_ports = true; + for (auto it=dst_ports_.cbegin(); + it!=dst_ports_.cend(); ++it) { + if (first_dst_ports) { + ss << (*it); + first_dst_ports = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", src_port_field_sets=" <<"'"; + bool first_src_port_field_sets = true; + for (auto it=src_port_field_sets_.cbegin(); + it!=src_port_field_sets_.cend(); ++it) { + if (first_src_port_field_sets) { + ss << (*it); + first_src_port_field_sets = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", dst_port_field_sets=" <<"'"; + bool first_dst_port_field_sets = true; + for (auto it=dst_port_field_sets_.cbegin(); + it!=dst_port_field_sets_.cend(); ++it) { + if (first_dst_port_field_sets) { + ss << (*it); + first_dst_port_field_sets = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const port_field_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + +protocol_field_impl_t::protocol_field_impl_t() : + ports_() { +} + +std::map const & +protocol_field_impl_t::ports() const { + return ports_; +} + +void +protocol_field_impl_t::ports_is(std::map const & ports) { + ports_ = ports; +} + +void +protocol_field_impl_t::port_set(uint32_t key, port_field_t const & value) { + ports_[key] = value; +} + +void +protocol_field_impl_t::port_del(uint32_t key) { + ports_.erase(key); +} + +bool +protocol_field_impl_t::operator==(protocol_field_impl_t const & other) const { + return ports_ == other.ports_; +} + +bool +protocol_field_impl_t::operator!=(protocol_field_impl_t const & other) const { + return !operator==(other); +} + +bool +protocol_field_impl_t::operator<(protocol_field_impl_t const & other) const { + if(ports_ != other.ports_) { + return ports_ < other.ports_; + } + return false; +} + +uint32_t +protocol_field_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +protocol_field_impl_t::mix_me(hash_mix & h) const { + for (auto it=ports_.cbegin(); + it!=ports_.cend(); ++it) { + h.mix(it->first); // uint32_t + h.mix(it->second); // port_field_t + } +} + +std::string +protocol_field_impl_t::to_string() const { + std::ostringstream ss; + ss << "protocol_field_t("; + ss << "ports=" <<"'"; + bool first_ports = true; + for (auto it=ports_.cbegin(); + it!=ports_.cend(); ++it) { + if (first_ports) { + ss << it->first << "=" << it->second; + first_ports = false; + } else { + ss << "," << it->first << "=" << it->second; + } + } + ss << "'"; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const protocol_field_impl_t& obj) { + os << obj.to_string(); + return os; +} + + + + + + +EOS_SDK_PRIVATE void addr_type_check( traffic_policy_rule_type_t filter_type, + ip_addr_mask_t const & value ) { + std::string const TP_FILTER_TYPE_CONFIG_ERROR_ = \ + "Traffic-policy raw rule type should be either v4 or v6"; + std::string const TP_ADDRESS_TYPE_CONFIG_ERROR_ = \ + "Configured ip address type does not match the traffic-policy filter type"; + af_t expected_af; + if( filter_type == TRAFFIC_POLICY_RULE_TYPE_IPV4 ) { + expected_af = AF_IPV4; + } else if( filter_type == TRAFFIC_POLICY_RULE_TYPE_IPV6 ) { + expected_af = AF_IPV6; + } else { + panic( configuration_error( TP_FILTER_TYPE_CONFIG_ERROR_ ) ); + } + if( value.af() != expected_af ) { + panic( configuration_error( TP_ADDRESS_TYPE_CONFIG_ERROR_ ) ); + } +} + + + + +std::string const TP_PREFIX_FIELDSET_CONFLICT_CONFIG_ERROR_ = \ + "Configure prefixes along with prefix field-set is not allowed"; + + + + +EOS_SDK_PRIVATE void addr_field_sets_check( + std::unordered_set const & addr_field_sets) { + if(!addr_field_sets.empty()) { + panic(configuration_error(TP_PREFIX_FIELDSET_CONFLICT_CONFIG_ERROR_)); + } +} + + + + +EOS_SDK_PRIVATE void prefixes_check( + std::set const & prefixes) { + if(!prefixes.empty()) { + panic(configuration_error(TP_PREFIX_FIELDSET_CONFLICT_CONFIG_ERROR_)); + } +} + + + +tp_rule_filter_impl_t::tp_rule_filter_impl_t() : + src_addrs_(), src_addr_field_sets_(), dst_addrs_(), dst_addr_field_sets_(), + protocols_(), filter_type_() { +} + +tp_rule_filter_impl_t::tp_rule_filter_impl_t( + traffic_policy_rule_type_t filter_type) : + src_addrs_(), src_addr_field_sets_(), dst_addrs_(), dst_addr_field_sets_(), + protocols_(), filter_type_(filter_type) { +} + +std::set const & +tp_rule_filter_impl_t::src_addrs() const { + return src_addrs_; +} + +std::unordered_set const & +tp_rule_filter_impl_t::src_addr_field_sets() const { + return src_addr_field_sets_; +} + +std::set const & +tp_rule_filter_impl_t::dst_addrs() const { + return dst_addrs_; +} + +std::unordered_set const & +tp_rule_filter_impl_t::dst_addr_field_sets() const { + return dst_addr_field_sets_; +} + +std::map const & +tp_rule_filter_impl_t::protocols() const { + return protocols_; +} + +void +tp_rule_filter_impl_t::protocols_is( + std::map const & protocols) { + protocols_ = protocols; +} + +void +tp_rule_filter_impl_t::protocol_set(protocol_range_t key, + protocol_field_t const & value) { + protocols_[key] = value; +} + +void +tp_rule_filter_impl_t::protocol_del(protocol_range_t key) { + protocols_.erase(key); +} + +traffic_policy_rule_type_t +tp_rule_filter_impl_t::filter_type() const { + return filter_type_; +} + +void +tp_rule_filter_impl_t::src_addr_set(ip_addr_mask_t const & value) { + + addr_field_sets_check(src_addr_field_sets_); + addr_type_check(filter_type_, value); + src_addrs_.insert(value); + +} + +void +tp_rule_filter_impl_t::src_addr_del(ip_addr_mask_t const & value) { + src_addrs_.erase(value); +} + +void +tp_rule_filter_impl_t::src_addrs_is(std::set const & src_addrs) { + + src_addrs_.clear(); + for(auto it = src_addrs.cbegin(); it != src_addrs.cend(); ++it) { + src_addr_set(*it); + } + +} + +void +tp_rule_filter_impl_t::dst_addr_set(ip_addr_mask_t const & value) { + + addr_field_sets_check(dst_addr_field_sets_); + addr_type_check(filter_type_, value); + dst_addrs_.insert(value); + +} + +void +tp_rule_filter_impl_t::dst_addr_del(ip_addr_mask_t const & value) { + dst_addrs_.erase(value); +} + +void +tp_rule_filter_impl_t::dst_addrs_is(std::set const & dst_addrs) { + + dst_addrs_.clear(); + for(auto it = dst_addrs.cbegin(); it != dst_addrs.cend(); ++it) { + dst_addr_set(*it); + } + +} + +void +tp_rule_filter_impl_t::src_addr_field_set_set(std::string const & value) { + + prefixes_check(src_addrs_); + src_addr_field_sets_.insert(value); + +} + +void +tp_rule_filter_impl_t::src_addr_field_set_del(std::string const & value) { + + src_addr_field_sets_.erase(value); + +} + +void +tp_rule_filter_impl_t::src_addr_field_sets_is( + std::unordered_set const & src_addr_field_sets) { + + if(!src_addr_field_sets.empty()) { + prefixes_check(src_addrs_); + } + src_addr_field_sets_ = src_addr_field_sets; + +} + +void +tp_rule_filter_impl_t::dst_addr_field_set_set(std::string const & value) { + + prefixes_check(dst_addrs_); + dst_addr_field_sets_.insert(value); + +} + +void +tp_rule_filter_impl_t::dst_addr_field_set_del(std::string const & value) { + + dst_addr_field_sets_.erase(value); + +} + +void +tp_rule_filter_impl_t::dst_addr_field_sets_is( + std::unordered_set const & dst_addr_field_sets) { + + if(!dst_addr_field_sets.empty()) { + prefixes_check(dst_addrs_); + } + dst_addr_field_sets_ = dst_addr_field_sets; + +} + +bool +tp_rule_filter_impl_t::operator==(tp_rule_filter_impl_t const & other) const { + return src_addrs_ == other.src_addrs_ && + src_addr_field_sets_ == other.src_addr_field_sets_ && + dst_addrs_ == other.dst_addrs_ && + dst_addr_field_sets_ == other.dst_addr_field_sets_ && + protocols_ == other.protocols_ && + filter_type_ == other.filter_type_; +} + +bool +tp_rule_filter_impl_t::operator!=(tp_rule_filter_impl_t const & other) const { + return !operator==(other); +} + +bool +tp_rule_filter_impl_t::operator<(tp_rule_filter_impl_t const & other) const { + if(src_addrs_ != other.src_addrs_) { + return src_addrs_ < other.src_addrs_; + } else if(dst_addrs_ != other.dst_addrs_) { + return dst_addrs_ < other.dst_addrs_; + } else if(protocols_ != other.protocols_) { + return protocols_ < other.protocols_; + } else if(filter_type_ != other.filter_type_) { + return filter_type_ < other.filter_type_; + } + return false; +} + +uint32_t +tp_rule_filter_impl_t::hash() const { + hash_mix h; + mix_me(h); + return h.result(); +} + +void +tp_rule_filter_impl_t::mix_me(hash_mix & h) const { + for (auto it=src_addrs_.cbegin(); + it!=src_addrs_.cend(); ++it) { + h.mix(*it); // ip_addr_mask_t + } + for (auto it=src_addr_field_sets_.cbegin(); + it!=src_addr_field_sets_.cend(); ++it) { + h.mix(*it); // std::string + } + for (auto it=dst_addrs_.cbegin(); + it!=dst_addrs_.cend(); ++it) { + h.mix(*it); // ip_addr_mask_t + } + for (auto it=dst_addr_field_sets_.cbegin(); + it!=dst_addr_field_sets_.cend(); ++it) { + h.mix(*it); // std::string + } + for (auto it=protocols_.cbegin(); + it!=protocols_.cend(); ++it) { + h.mix(it->first); // protocol_range_t + h.mix(it->second); // protocol_field_t + } + h.mix(filter_type_); // traffic_policy_rule_type_t +} + +std::string +tp_rule_filter_impl_t::to_string() const { + std::ostringstream ss; + ss << "tp_rule_filter_t("; + ss << "src_addrs=" <<"'"; + bool first_src_addrs = true; + for (auto it=src_addrs_.cbegin(); + it!=src_addrs_.cend(); ++it) { + if (first_src_addrs) { + ss << (*it); + first_src_addrs = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", src_addr_field_sets=" <<"'"; + bool first_src_addr_field_sets = true; + for (auto it=src_addr_field_sets_.cbegin(); + it!=src_addr_field_sets_.cend(); ++it) { + if (first_src_addr_field_sets) { + ss << (*it); + first_src_addr_field_sets = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", dst_addrs=" <<"'"; + bool first_dst_addrs = true; + for (auto it=dst_addrs_.cbegin(); + it!=dst_addrs_.cend(); ++it) { + if (first_dst_addrs) { + ss << (*it); + first_dst_addrs = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", dst_addr_field_sets=" <<"'"; + bool first_dst_addr_field_sets = true; + for (auto it=dst_addr_field_sets_.cbegin(); + it!=dst_addr_field_sets_.cend(); ++it) { + if (first_dst_addr_field_sets) { + ss << (*it); + first_dst_addr_field_sets = false; + } else { + ss << "," << (*it); + } + } + ss << "'"; + ss << ", protocols=" <<"'"; + bool first_protocols = true; + for (auto it=protocols_.cbegin(); + it!=protocols_.cend(); ++it) { + if (first_protocols) { + ss << it->first << "=" << it->second; + first_protocols = false; + } else { + ss << "," << it->first << "=" << it->second; + } + } + ss << "'"; + ss << ", filter_type=" << filter_type_; + ss << ")"; + return ss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const tp_rule_filter_impl_t& obj) { + os << obj.to_string(); + return os; +} + + +} + +#include + +#endif // EOS_INLINE_TYPES_STRUCTURED_FILTER_IMPL_H diff --git a/eos/l1_source.h b/eos/l1_source.h deleted file mode 100644 index 33b998b..0000000 --- a/eos/l1_source.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_L1_SOURCE_H -#define EOS_L1_SOURCE_H - -#include -#include - -#include -#include - -/** - * @file - * L1 source management module. - * - * On platforms with a crosspoint, interfaces can configure their source using a - * config. - * - * This module provides APIs to set and delete source configs, watch for - * config changes, get source configs and source statuses, and iterate through - * source configs and source statuses. - */ - -namespace eos { - -class l1_source_mgr; - -class EOS_SDK_PUBLIC l1_source_handler : public base_handler { - public: - explicit l1_source_handler(l1_source_mgr *); - l1_source_mgr * get_l1_source_mgr() const; - - /** - * Register to receive notification when l1 source config for any interface - * changes. - */ - void watch_all_l1_source(bool); - - /** - * Register to receive notification when l1 source config of an interface - * changes. - */ - void watch_l1_source(intf_id_t, bool); - - /** - * Called when l1 source of an interface is set. - */ - virtual void on_l1_source_set(intf_id_t); - - /** - * Called when l1 source of an interface is removed. - */ - virtual void on_l1_source_del(intf_id_t); -}; - -class l1_source_iter_impl; - -/// An iterator that yields a intf_id_t for each l1 source config/status. -class EOS_SDK_PUBLIC l1_source_iter_t : public iter_base { - private: - friend class l1_source_iter_impl; - explicit l1_source_iter_t(l1_source_iter_impl * const) EOS_SDK_PRIVATE; -}; - -/** - * The l1 source manager. - * This class inspects and configures l1 source for an interface. - */ -class EOS_SDK_PUBLIC l1_source_mgr : public base_mgr { - public: - virtual ~l1_source_mgr(); - - /** - * Configures l1 source of an interface. - */ - virtual void l1_source_is(intf_id_t, l1_source_t source) = 0; - - /** - * Remove the l1 source of an interface. - */ - virtual void l1_source_del(intf_id_t) = 0; - - /** - * Returns whether a l1 source config exists for the interface. - */ - virtual bool exists(intf_id_t) const = 0; - - /** - * Returns the source config for an interface. - * If no source config is set, returns the default source config. - */ - virtual l1_source_t l1_source_config(intf_id_t) = 0; - - /** - * Returns the source status for an interface. - * If no source status exists, returns the default source status. - */ - virtual l1_source_t l1_source_status(intf_id_t) = 0; - - /** - * Iterator for l1 source configuration. - */ - virtual l1_source_iter_t l1_source_config_iter() const = 0; - - /** - * Iterator for l1 source status. - */ - virtual l1_source_iter_t l1_source_status_iter() const = 0; - - /** - * Configures the description of an application interface. - */ - virtual void app_description_is(intf_id_t, std::string) = 0; - - /** - * Remove the description of an application interface. - */ - virtual void app_description_del(intf_id_t) = 0; - - protected: - l1_source_mgr() EOS_SDK_PRIVATE; - friend class l1_source_handler; - - private: - EOS_SDK_DISALLOW_COPY_CTOR(l1_source_mgr); -}; - -} - -#include - -#endif // EOS_L1_SOURCE_H diff --git a/eos/nexthop_group.h b/eos/nexthop_group.h index 43f8a31..dc71e07 100644 --- a/eos/nexthop_group.h +++ b/eos/nexthop_group.h @@ -126,6 +126,30 @@ class EOS_SDK_PUBLIC nexthop_group_handler_v2 : public nexthop_group_handler { uint16_t version_id); }; +/** + * This class handles changes to a nexthop group's status and provides its version + * ID as well as a nexthop_group_status attribute in the programmed callback. + */ +class EOS_SDK_PUBLIC nexthop_group_handler_v3 : public nexthop_group_handler { + public: + explicit nexthop_group_handler_v3(nexthop_group_mgr *); + + /** + * Do not override this function. Instead override the alternative programmed + * handler. + */ + virtual void on_nexthop_group_programmed(std::string const & nexthop_group_name) + override final {} + /** + * Alternative handler called when a nexthop group is programmed in response to + * a configuration change. Provides the nexthop group's version ID along with + * the status for the nexthop group that triggered the callback + */ + virtual void on_nexthop_group_programmed( + std::string const & nexthop_group_name, uint16_t version_id, + nexthop_group_programmed_status_t const & callback_status); +}; + class nexthop_group_iter_impl; // An iterator that yields nexthop group for each configured nexthop group @@ -214,15 +238,22 @@ class EOS_SDK_PUBLIC nexthop_group_mgr : virtual nexthop_group_t programmed_nexthop_group(std::string const & nexthop_group_name) const = 0; + + // Creates or updates a nexthop group and provides its version ID. + virtual void nexthop_group_set(nexthop_group_t const & group, + uint16_t * version_id) = 0; + + // Returns the current entry counter state for the nexthop group associated with + // the provided nexthop group name + virtual nexthop_group_counter_state_t + get_nexthop_group_counter_state(std::string const & nexthop_group_name) + const = 0; + protected: nexthop_group_mgr() EOS_SDK_PRIVATE; friend class nexthop_group_handler; private: EOS_SDK_DISALLOW_COPY_CTOR(nexthop_group_mgr); - public: - // Creates or updates a nexthop group and provides its version ID. - virtual void nexthop_group_set(nexthop_group_t const & group, - uint16_t * version_id) = 0; }; } // end namespace eos diff --git a/eos/policy_map.h b/eos/policy_map.h index d1b9004..8e19b28 100644 --- a/eos/policy_map.h +++ b/eos/policy_map.h @@ -204,6 +204,15 @@ class EOS_SDK_PUBLIC policy_map_handler : public base_handler -#include -#include -#include - -namespace eos { - -class fpga_impl_t; -/** Describes an application FPGA on a switch. */ -class EOS_SDK_PUBLIC fpga_t { - public: - /** Default constructor. */ - fpga_t(); - fpga_t(std::string const & name, std::string const & board_standard, - std::string const & part_number); - fpga_t(const fpga_t& other); - fpga_t& operator=( - fpga_t const & other); - - - /** Getter for 'name': The name of the FPGA. */ - std::string name() const; - - /** Getter for 'board_standard': The board standard of the FPGA. */ - std::string board_standard() const; - - /** Getter for 'part_number': The part number of the FPGA. */ - std::string part_number() const; - - bool operator==(fpga_t const & other) const; - bool operator!=(fpga_t const & other) const; - bool operator<(fpga_t const & other) const; - /** The hash function for type fpga_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of fpga_t to the - * ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const fpga_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const fpga_t& obj); - -class fpga_reservation_impl_t; -/** Describes an FPGA reservation on the switch. */ -class EOS_SDK_PUBLIC fpga_reservation_t { - public: - fpga_reservation_t(); - explicit fpga_reservation_t(std::string const & id); - fpga_reservation_t(const fpga_reservation_t& other); - fpga_reservation_t& operator=( - fpga_reservation_t const & other); - - - /** Getter for 'id': The ID of the reservation. */ - std::string id() const; - - /** Getter for 'board_standard': The target FPGA board standard. */ - std::string board_standard() const; - /** Setter for 'board_standard'. */ - void board_standard_is(std::string const & board_standard); - - /** Getter for 'fpga_name': The target FPGA name for the reservation. */ - std::string fpga_name() const; - /** Setter for 'fpga_name'. */ - void fpga_name_is(std::string const & fpga_name); - - /** - * Getter for 'bitfile': The file to be programmed. Empty string means to clear - * the FPGA. - */ - std::string bitfile() const; - /** Setter for 'bitfile'. */ - void bitfile_is(std::string const & bitfile); - - bool operator==(fpga_reservation_t const & other) const; - bool operator!=(fpga_reservation_t const & other) const; - bool operator<(fpga_reservation_t const & other) const; - /** The hash function for type fpga_reservation_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_reservation_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * fpga_reservation_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const fpga_reservation_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const fpga_reservation_t& obj); - -enum fpga_reservation_result_t { - /** The request is invalid. */ - FRR_INVALID, - /** The request is pending. */ - FRR_PENDING, - /** The request has succeeded. */ - FRR_SUCCESS, - /** The request failed; no matching FPGA was found. */ - FRR_FAILED_TO_MATCH_FPGA, - /** The request failed; an FPGA could not be reserved. */ - FRR_FAILED_TO_RESERVE, - /** The request failed; the FPGA could not be programmed. */ - FRR_FAILED_TO_PROGRAM, - /** The request failed; the FPGA could not be cleared. */ - FRR_FAILED_TO_CLEAR, -}; -/** - * Appends a string representation of enum fpga_reservation_result_t value to the - * ostream. - */ -EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, - const fpga_reservation_result_t & enum_val); - -class fpga_reservation_status_impl_t; -/** Describes an FPGA reservation status on the switch. */ -class EOS_SDK_PUBLIC fpga_reservation_status_t { - public: - fpga_reservation_status_t(); - fpga_reservation_status_t(std::string const & id, - fpga_reservation_result_t result, - std::string fpga_name); - fpga_reservation_status_t(const fpga_reservation_status_t& other); - fpga_reservation_status_t& operator=( - fpga_reservation_status_t const & other); - - - /** Getter for 'id': The ID of the reservation status. */ - std::string id() const; - - /** Getter for 'result': The result of the reservation. */ - fpga_reservation_result_t result() const; - - /** Getter for 'fpga_name': The name of the reserved FPGA. */ - std::string fpga_name() const; - - bool operator==(fpga_reservation_status_t const & other) const; - bool operator!=(fpga_reservation_status_t const & other) const; - bool operator<(fpga_reservation_status_t const & other) const; - /** The hash function for type fpga_reservation_status_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_reservation_status_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * fpga_reservation_status_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const fpga_reservation_status_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const fpga_reservation_status_t& obj); -} - -#endif // EOS_TYPES_FPGA_H diff --git a/eos/types/fpga_impl.h b/eos/types/fpga_impl.h deleted file mode 100644 index 23f4aeb..0000000 --- a/eos/types/fpga_impl.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_TYPES_FPGA_IMPL_H -#define EOS_TYPES_FPGA_IMPL_H - -#include -#include -#include -#include - -namespace eos { - -/** Describes an application FPGA on a switch. */ -class EOS_SDK_PUBLIC fpga_impl_t { - public: - /** Default constructor. */ - fpga_impl_t(); - fpga_impl_t(std::string const & name, std::string const & board_standard, - std::string const & part_number); - - /** Getter for 'name': The name of the FPGA. */ - std::string name() const; - - /** Getter for 'board_standard': The board standard of the FPGA. */ - std::string board_standard() const; - - /** Getter for 'part_number': The part number of the FPGA. */ - std::string part_number() const; - - bool operator==(fpga_impl_t const & other) const; - bool operator!=(fpga_impl_t const & other) const; - bool operator<(fpga_impl_t const & other) const; - /** The hash function for type fpga_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of fpga_t to the - * ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const fpga_impl_t& obj); - - private: - std::string name_; - std::string board_standard_; - std::string part_number_; -}; - -/** Describes an FPGA reservation on the switch. */ -class EOS_SDK_PUBLIC fpga_reservation_impl_t { - public: - fpga_reservation_impl_t(); - explicit fpga_reservation_impl_t(std::string const & id); - - /** Getter for 'id': The ID of the reservation. */ - std::string id() const; - - /** Getter for 'board_standard': The target FPGA board standard. */ - std::string board_standard() const; - /** Setter for 'board_standard'. */ - void board_standard_is(std::string const & board_standard); - - /** Getter for 'fpga_name': The target FPGA name for the reservation. */ - std::string fpga_name() const; - /** Setter for 'fpga_name'. */ - void fpga_name_is(std::string const & fpga_name); - - /** - * Getter for 'bitfile': The file to be programmed. Empty string means to clear - * the FPGA. - */ - std::string bitfile() const; - /** Setter for 'bitfile'. */ - void bitfile_is(std::string const & bitfile); - - bool operator==(fpga_reservation_impl_t const & other) const; - bool operator!=(fpga_reservation_impl_t const & other) const; - bool operator<(fpga_reservation_impl_t const & other) const; - /** The hash function for type fpga_reservation_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_reservation_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * fpga_reservation_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const fpga_reservation_impl_t& obj); - - private: - std::string id_; - std::string board_standard_; - std::string fpga_name_; - std::string bitfile_; -}; - -/** Describes an FPGA reservation status on the switch. */ -class EOS_SDK_PUBLIC fpga_reservation_status_impl_t { - public: - fpga_reservation_status_impl_t(); - fpga_reservation_status_impl_t(std::string const & id, - fpga_reservation_result_t result, - std::string fpga_name); - - /** Getter for 'id': The ID of the reservation status. */ - std::string id() const; - - /** Getter for 'result': The result of the reservation. */ - fpga_reservation_result_t result() const; - - /** Getter for 'fpga_name': The name of the reserved FPGA. */ - std::string fpga_name() const; - - bool operator==(fpga_reservation_status_impl_t const & other) const; - bool operator!=(fpga_reservation_status_impl_t const & other) const; - bool operator<(fpga_reservation_status_impl_t const & other) const; - /** The hash function for type fpga_reservation_status_t. */ - uint32_t hash() const; - /** The hash mix function for type fpga_reservation_status_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * fpga_reservation_status_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const fpga_reservation_status_impl_t& obj); - - private: - std::string id_; - fpga_reservation_result_t result_; - std::string fpga_name_; -}; -} - -#endif // EOS_TYPES_FPGA_IMPL_H diff --git a/eos/types/ham.h b/eos/types/ham.h deleted file mode 100644 index b6410c5..0000000 --- a/eos/types/ham.h +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_TYPES_HAM_H -#define EOS_TYPES_HAM_H - -#include -#include -#include -#include - -namespace eos { - -/** The response_enum_t is the return value of any read or write with the ham. */ -enum response_enum_t { - /** Ok. */ - STATUS_OK, - /** Hardware not present. */ - STATUS_ERR_HW_NOT_PRESENT, - /** General hardware failure. */ - STATUS_ERR_HW_FAILURE, - /** Invalid parameter arguments. */ - STATUS_ERR_ARGS, - /** Communication error. Possible to retry later. */ - STATUS_ERR_COMM, - /** API not supported. */ - STATUS_ERR_API_UNSUPPORTED, - /** Internal error. */ - STATUS_ERR_INTERNAL, -}; -/** Appends a string representation of enum response_enum_t value to the ostream. */ -EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, - const response_enum_t & enum_val); - -class device_impl_t; -/** The device_t type is passed to the ctor of the eossdk_ham_t type. */ -class EOS_SDK_PUBLIC device_t { - public: - /** Default constructor. */ - device_t(); - device_t(const device_t& other); - device_t& operator=( - device_t const & other); - - - /** Getter for 'driver': Driver name. */ - std::string driver() const; - /** Setter for 'driver'. */ - void driver_is(std::string driver); - - /** Getter for 'uid': The unique ID for the component. */ - uint32_t uid() const; - /** Setter for 'uid'. */ - void uid_is(uint32_t uid); - - /** Getter for 'did': The unique topology ID for the device. */ - uint32_t did() const; - /** Setter for 'did'. */ - void did_is(uint32_t did); - - /** Getter for 'bus': The Bus ID attribute. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'accelerator': The accelerator attribute. */ - uint32_t accelerator() const; - /** Setter for 'accelerator'. */ - void accelerator_is(uint32_t accelerator); - - bool operator==(device_t const & other) const; - bool operator!=(device_t const & other) const; - bool operator<(device_t const & other) const; - /** The hash function for type device_t. */ - uint32_t hash() const; - /** The hash mix function for type device_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of device_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const device_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const device_t& obj); - -class pci_address_impl_t; -/** - * The pci_address_t type is passed to the ctor of the eossdk_ham_t type. The HAM - * should use the PCI address of the SCD. If zero, the CPUs SMBuses are used. - */ -class EOS_SDK_PUBLIC pci_address_t { - public: - /** Default constructor. */ - pci_address_t(); - pci_address_t(const pci_address_t& other); - pci_address_t& operator=( - pci_address_t const & other); - - - /** Getter for 'domain': Domain of the pci address. */ - uint32_t domain() const; - /** Setter for 'domain'. */ - void domain_is(uint32_t domain); - - /** Getter for 'bus': Bus identifier for pci address. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'device': Device identifier for pci address. */ - uint32_t device() const; - /** Setter for 'device'. */ - void device_is(uint32_t device); - - /** Getter for 'function': Function identifier for pci address. */ - uint32_t function() const; - /** Setter for 'function'. */ - void function_is(uint32_t function); - - bool operator==(pci_address_t const & other) const; - bool operator!=(pci_address_t const & other) const; - bool operator<(pci_address_t const & other) const; - /** The hash function for type pci_address_t. */ - uint32_t hash() const; - /** The hash mix function for type pci_address_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of pci_address_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const pci_address_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const pci_address_t& obj); - -class aham_address_impl_t; -/** - * The aham_address_t type is passed to the ctor of the eossdk_ham_t type. It holds - * the bus Id, the accelerator,and the endpoint address. - */ -class EOS_SDK_PUBLIC aham_address_t { - public: - /** Default constructor. */ - aham_address_t(); - aham_address_t(const aham_address_t& other); - aham_address_t& operator=( - aham_address_t const & other); - - - /** Getter for 'bus': Bus attribute for aham address. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'accelerator': Accelerator for ahamaddress. */ - uint32_t accelerator() const; - /** Setter for 'accelerator'. */ - void accelerator_is(uint32_t accelerator); - - /** Getter for 'address': Address field of the aham addressobject. */ - uint32_t address() const; - /** Setter for 'address'. */ - void address_is(uint32_t address); - - bool operator==(aham_address_t const & other) const; - bool operator!=(aham_address_t const & other) const; - bool operator<(aham_address_t const & other) const; - /** The hash function for type aham_address_t. */ - uint32_t hash() const; - /** The hash mix function for type aham_address_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of aham_address_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const aham_address_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const aham_address_t& obj); - -class eossdk_ham_impl_t; -/** Hardware access method. */ -class EOS_SDK_PUBLIC eossdk_ham_t { - public: - /** - * Default constructor, where deviceArgs and endpointAddr are passed in from the - * EosSdk FPGA module. - */ - eossdk_ham_t(device_t device_Args, uint32_t endpoint_Addr); - /** - * Constructor specifying the AhamAddress for the ham device, where the - * AhamAddress contains the endpoint address, the bus Id, and the accelerator - * for the ham. Also specifies PCI Address. - */ - eossdk_ham_t(aham_address_t aham_address, pci_address_t pci_address); - eossdk_ham_t(const eossdk_ham_t& other); - eossdk_ham_t& operator=( - eossdk_ham_t const & other); - - - device_t device_Args() const; - - uint32_t endpoint_Addr() const; - - aham_address_t aham_address() const; - - pci_address_t pci_address() const; - - /** The hash function for type eossdk_ham_t. */ - uint32_t hash() const; - /** The hash mix function for type eossdk_ham_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of eossdk_ham_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const eossdk_ham_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const eossdk_ham_t& obj); - -class read8_result_impl_t; -/** Stores the status and result of read8 calls. */ -class EOS_SDK_PUBLIC read8_result_t { - public: - /** Default constructor. */ - read8_result_t(response_enum_t status, uint8_t result); - read8_result_t(const read8_result_t& other); - read8_result_t& operator=( - read8_result_t const & other); - - - response_enum_t status() const; - void status_is(response_enum_t status); - - uint8_t result() const; - void result_is(uint8_t result); - - bool operator==(read8_result_t const & other) const; - bool operator!=(read8_result_t const & other) const; - /** The hash function for type read8_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read8_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of read8_result_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const read8_result_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const read8_result_t& obj); - -class read16_result_impl_t; -/** Stores the status and result of read16 calls. */ -class EOS_SDK_PUBLIC read16_result_t { - public: - /** Default constructor. */ - read16_result_t(response_enum_t status, uint16_t result); - read16_result_t(const read16_result_t& other); - read16_result_t& operator=( - read16_result_t const & other); - - - response_enum_t status() const; - void status_is(response_enum_t status); - - uint16_t result() const; - void result_is(uint16_t result); - - bool operator==(read16_result_t const & other) const; - bool operator!=(read16_result_t const & other) const; - /** The hash function for type read16_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read16_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * read16_result_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const read16_result_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const read16_result_t& obj); - -class read_result_impl_t; -/** Stores the status and result of read calls that readup to 32 bytes. */ -class EOS_SDK_PUBLIC read_result_t { - public: - /** Default constructor. */ - read_result_t(response_enum_t status, ByteString result); - read_result_t(const read_result_t& other); - read_result_t& operator=( - read_result_t const & other); - - - response_enum_t status() const; - void status_is(response_enum_t status); - - ByteString result() const; - void result_is(ByteString result); - - bool operator==(read_result_t const & other) const; - bool operator!=(read_result_t const & other) const; - /** The hash function for type read_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of read_result_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const read_result_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const read_result_t& obj); - -class register_impl_t; -/** Register type, from which the HAM will read from/write to. */ -class EOS_SDK_PUBLIC register_t { - public: - register_t(); - register_t(const register_t& other); - register_t& operator=( - register_t const & other); - - - uint32_t reg() const; - void reg_is(uint32_t reg); - - bool operator==(register_t const & other) const; - bool operator!=(register_t const & other) const; - bool operator<(register_t const & other) const; - /** The hash function for type register_t. */ - uint32_t hash() const; - /** The hash mix function for type register_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of register_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const register_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const register_t& obj); -} - -#endif // EOS_TYPES_HAM_H diff --git a/eos/types/ham_impl.h b/eos/types/ham_impl.h deleted file mode 100644 index 4374a6a..0000000 --- a/eos/types/ham_impl.h +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_TYPES_HAM_IMPL_H -#define EOS_TYPES_HAM_IMPL_H - -#include -#include -#include -#include - -namespace eos { - -/** The device_t type is passed to the ctor of the eossdk_ham_t type. */ -class EOS_SDK_PUBLIC device_impl_t { - public: - /** Default constructor. */ - device_impl_t(); - - /** Getter for 'driver': Driver name. */ - std::string driver() const; - /** Setter for 'driver'. */ - void driver_is(std::string driver); - - /** Getter for 'uid': The unique ID for the component. */ - uint32_t uid() const; - /** Setter for 'uid'. */ - void uid_is(uint32_t uid); - - /** Getter for 'did': The unique topology ID for the device. */ - uint32_t did() const; - /** Setter for 'did'. */ - void did_is(uint32_t did); - - /** Getter for 'bus': The Bus ID attribute. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'accelerator': The accelerator attribute. */ - uint32_t accelerator() const; - /** Setter for 'accelerator'. */ - void accelerator_is(uint32_t accelerator); - - bool operator==(device_impl_t const & other) const; - bool operator!=(device_impl_t const & other) const; - bool operator<(device_impl_t const & other) const; - /** The hash function for type device_t. */ - uint32_t hash() const; - /** The hash mix function for type device_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of device_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const device_impl_t& obj); - - private: - std::string driver_; - uint32_t uid_; - uint32_t did_; - uint32_t bus_; - uint32_t accelerator_; -}; - -/** - * The pci_address_t type is passed to the ctor of the eossdk_ham_t type. The HAM - * should use the PCI address of the SCD. If zero, the CPUs SMBuses are used. - */ -class EOS_SDK_PUBLIC pci_address_impl_t { - public: - /** Default constructor. */ - pci_address_impl_t(); - - /** Getter for 'domain': Domain of the pci address. */ - uint32_t domain() const; - /** Setter for 'domain'. */ - void domain_is(uint32_t domain); - - /** Getter for 'bus': Bus identifier for pci address. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'device': Device identifier for pci address. */ - uint32_t device() const; - /** Setter for 'device'. */ - void device_is(uint32_t device); - - /** Getter for 'function': Function identifier for pci address. */ - uint32_t function() const; - /** Setter for 'function'. */ - void function_is(uint32_t function); - - bool operator==(pci_address_impl_t const & other) const; - bool operator!=(pci_address_impl_t const & other) const; - bool operator<(pci_address_impl_t const & other) const; - /** The hash function for type pci_address_t. */ - uint32_t hash() const; - /** The hash mix function for type pci_address_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of pci_address_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const pci_address_impl_t& obj); - - private: - uint32_t domain_; - uint32_t bus_; - uint32_t device_; - uint32_t function_; -}; - -/** - * The aham_address_t type is passed to the ctor of the eossdk_ham_t type. It holds - * the bus Id, the accelerator,and the endpoint address. - */ -class EOS_SDK_PUBLIC aham_address_impl_t { - public: - /** Default constructor. */ - aham_address_impl_t(); - - /** Getter for 'bus': Bus attribute for aham address. */ - uint32_t bus() const; - /** Setter for 'bus'. */ - void bus_is(uint32_t bus); - - /** Getter for 'accelerator': Accelerator for ahamaddress. */ - uint32_t accelerator() const; - /** Setter for 'accelerator'. */ - void accelerator_is(uint32_t accelerator); - - /** Getter for 'address': Address field of the aham addressobject. */ - uint32_t address() const; - /** Setter for 'address'. */ - void address_is(uint32_t address); - - bool operator==(aham_address_impl_t const & other) const; - bool operator!=(aham_address_impl_t const & other) const; - bool operator<(aham_address_impl_t const & other) const; - /** The hash function for type aham_address_t. */ - uint32_t hash() const; - /** The hash mix function for type aham_address_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of aham_address_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const aham_address_impl_t& obj); - - private: - uint32_t bus_; - uint32_t accelerator_; - uint32_t address_; -}; - -/** Hardware access method. */ -class EOS_SDK_PUBLIC eossdk_ham_impl_t { - public: - /** - * Default constructor, where deviceArgs and endpointAddr are passed in from the - * EosSdk FPGA module. - */ - eossdk_ham_impl_t(device_t device_Args, uint32_t endpoint_Addr); - /** - * Constructor specifying the AhamAddress for the ham device, where the - * AhamAddress contains the endpoint address, the bus Id, and the accelerator - * for the ham. Also specifies PCI Address. - */ - eossdk_ham_impl_t(aham_address_t aham_address, pci_address_t pci_address); - - device_t device_Args() const; - - uint32_t endpoint_Addr() const; - - aham_address_t aham_address() const; - - pci_address_t pci_address() const; - - /** The hash function for type eossdk_ham_t. */ - uint32_t hash() const; - /** The hash mix function for type eossdk_ham_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of eossdk_ham_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const eossdk_ham_impl_t& obj); - - private: - device_t device_Args_; - uint32_t endpoint_Addr_; - aham_address_t aham_address_; - pci_address_t pci_address_; -}; - -/** Stores the status and result of read8 calls. */ -class EOS_SDK_PUBLIC read8_result_impl_t { - public: - /** Default constructor. */ - read8_result_impl_t(response_enum_t status, uint8_t result); - - response_enum_t status() const; - void status_is(response_enum_t status); - - uint8_t result() const; - void result_is(uint8_t result); - - bool operator==(read8_result_impl_t const & other) const; - bool operator!=(read8_result_impl_t const & other) const; - /** The hash function for type read8_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read8_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of read8_result_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const read8_result_impl_t& obj); - - private: - response_enum_t status_; - uint8_t result_; -}; - -/** Stores the status and result of read16 calls. */ -class EOS_SDK_PUBLIC read16_result_impl_t { - public: - /** Default constructor. */ - read16_result_impl_t(response_enum_t status, uint16_t result); - - response_enum_t status() const; - void status_is(response_enum_t status); - - uint16_t result() const; - void result_is(uint16_t result); - - bool operator==(read16_result_impl_t const & other) const; - bool operator!=(read16_result_impl_t const & other) const; - /** The hash function for type read16_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read16_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of - * read16_result_t to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, - const read16_result_impl_t& obj); - - private: - response_enum_t status_; - uint16_t result_; -}; - -/** Stores the status and result of read calls that readup to 32 bytes. */ -class EOS_SDK_PUBLIC read_result_impl_t { - public: - /** Default constructor. */ - read_result_impl_t(response_enum_t status, ByteString result); - - response_enum_t status() const; - void status_is(response_enum_t status); - - ByteString result() const; - void result_is(ByteString result); - - bool operator==(read_result_impl_t const & other) const; - bool operator!=(read_result_impl_t const & other) const; - /** The hash function for type read_result_t. */ - uint32_t hash() const; - /** The hash mix function for type read_result_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of read_result_t - * to the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const read_result_impl_t& obj); - - private: - response_enum_t status_; - ByteString result_; -}; - -/** Register type, from which the HAM will read from/write to. */ -class EOS_SDK_PUBLIC register_impl_t { - public: - register_impl_t(); - - uint32_t reg() const; - void reg_is(uint32_t reg); - - bool operator==(register_impl_t const & other) const; - bool operator!=(register_impl_t const & other) const; - bool operator<(register_impl_t const & other) const; - /** The hash function for type register_t. */ - uint32_t hash() const; - /** The hash mix function for type register_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of register_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const register_impl_t& obj); - - private: - uint32_t reg_; -}; -} - -#endif // EOS_TYPES_HAM_IMPL_H diff --git a/eos/types/ip_route.h b/eos/types/ip_route.h index 6dd3816..3709ab3 100644 --- a/eos/types/ip_route.h +++ b/eos/types/ip_route.h @@ -21,6 +21,7 @@ typedef uint32_t ip_route_metric_t; /** Valid range of 1 - (2^24)-1, set to 0 if unused. */ typedef uint32_t vni_t; typedef uint32_t ip_via_metric_t; +typedef uint32_t ip_via_weight_t; /** * The type of the ip_route_t. This is determined by the ip_route_via_t's attached @@ -115,6 +116,14 @@ class EOS_SDK_PUBLIC ip_route_t { /** Setter for 'rib_bypass'. */ void rib_bypass_is(bool rib_bypass); + /** + * Getter for 'command_tag': Associates the route with a command_tag, which + * might be used to manipulate configuration externally to the agent. + */ + std::string command_tag() const; + /** Setter for 'command_tag'. */ + void command_tag_is(std::string const & command_tag); + bool operator==(ip_route_t const & other) const; bool operator!=(ip_route_t const & other) const; /** The hash function for type ip_route_t. */ @@ -227,6 +236,11 @@ class EOS_SDK_PUBLIC ip_route_via_t { /** Setter for 'vtep_sip_validation'. */ void vtep_sip_validation_is(bool vtep_sip_validation); + /** Getter for 'weight': the weight for this via. */ + ip_via_weight_t weight() const; + /** Setter for 'weight'. */ + void weight_is(ip_via_weight_t weight); + bool operator==(ip_route_via_t const & other) const; bool operator!=(ip_route_via_t const & other) const; /** The hash function for type ip_route_via_t. */ diff --git a/eos/types/ip_route_impl.h b/eos/types/ip_route_impl.h index d3c94d8..4ade9c7 100644 --- a/eos/types/ip_route_impl.h +++ b/eos/types/ip_route_impl.h @@ -82,6 +82,14 @@ class EOS_SDK_PUBLIC ip_route_impl_t { /** Setter for 'rib_bypass'. */ void rib_bypass_is(bool rib_bypass); + /** + * Getter for 'command_tag': Associates the route with a command_tag, which + * might be used to manipulate configuration externally to the agent. + */ + std::string command_tag() const; + /** Setter for 'command_tag'. */ + void command_tag_is(std::string const & command_tag); + bool operator==(ip_route_impl_t const & other) const; bool operator!=(ip_route_impl_t const & other) const; /** The hash function for type ip_route_t. */ @@ -100,6 +108,7 @@ class EOS_SDK_PUBLIC ip_route_impl_t { ip_route_key_t key_; ip_route_tag_t tag_; bool rib_bypass_; + std::string command_tag_; }; /** @@ -188,6 +197,11 @@ class EOS_SDK_PUBLIC ip_route_via_impl_t { /** Setter for 'vtep_sip_validation'. */ void vtep_sip_validation_is(bool vtep_sip_validation); + /** Getter for 'weight': the weight for this via. */ + ip_via_weight_t weight() const; + /** Setter for 'weight'. */ + void weight_is(ip_via_weight_t weight); + bool operator==(ip_route_via_impl_t const & other) const; bool operator!=(ip_route_via_impl_t const & other) const; /** The hash function for type ip_route_via_t. */ @@ -216,6 +230,7 @@ class EOS_SDK_PUBLIC ip_route_via_impl_t { ip_via_metric_t metric_; intf_id_t vxlan_intf_; bool vtep_sip_validation_; + ip_via_weight_t weight_; }; } diff --git a/eos/types/l1_source.h b/eos/types/l1_source.h deleted file mode 100644 index 1408752..0000000 --- a/eos/types/l1_source.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_TYPES_L1_SOURCE_H -#define EOS_TYPES_L1_SOURCE_H - -#include -#include -#include -#include -#include - -namespace eos { - -/** The type of an l1 source. */ -enum l1_source_type_t { - unknown, - none, - port, - mac, - switchPort, -}; -/** Appends a string representation of enum l1_source_type_t value to the ostream. */ -EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, - const l1_source_type_t & enum_val); - -class l1_source_impl_t; -/** - * L1 source class. - * - * The interface id "port" should be defined only if l1 source type is port. - */ -class EOS_SDK_PUBLIC l1_source_t { - public: - /** Default constructor. */ - l1_source_t(); - /** Constructor specifying only l1 source type. */ - explicit l1_source_t(l1_source_type_t l1_source_type); - /** Constructor specifying both l1 source type and interface id. */ - l1_source_t(l1_source_type_t l1_source_type, intf_id_t port); - l1_source_t(const l1_source_t& other); - l1_source_t& operator=( - l1_source_t const & other); - - - l1_source_type_t l1_source_type() const; - void l1_source_type_is(l1_source_type_t l1_source_type); - - intf_id_t port() const; - void port_is(intf_id_t port); - - bool operator==(l1_source_t const & other) const; - bool operator!=(l1_source_t const & other) const; - bool operator<(l1_source_t const & other) const; - /** The hash function for type l1_source_t. */ - uint32_t hash() const; - /** The hash mix function for type l1_source_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of l1_source_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const l1_source_t& obj); - - private: - std::shared_ptr pimpl; -}; - -EOS_SDK_PUBLIC -std::ostream& operator<<(std::ostream& os, const l1_source_t& obj); -} - -#endif // EOS_TYPES_L1_SOURCE_H diff --git a/eos/types/l1_source_impl.h b/eos/types/l1_source_impl.h deleted file mode 100644 index 5c8d574..0000000 --- a/eos/types/l1_source_impl.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#ifndef EOS_TYPES_L1_SOURCE_IMPL_H -#define EOS_TYPES_L1_SOURCE_IMPL_H - -#include -#include -#include -#include -#include - -namespace eos { - -/** - * L1 source class. - * - * The interface id "port" should be defined only if l1 source type is port. - */ -class EOS_SDK_PUBLIC l1_source_impl_t { - public: - /** Default constructor. */ - l1_source_impl_t(); - /** Constructor specifying only l1 source type. */ - explicit l1_source_impl_t(l1_source_type_t l1_source_type); - /** Constructor specifying both l1 source type and interface id. */ - l1_source_impl_t(l1_source_type_t l1_source_type, intf_id_t port); - - l1_source_type_t l1_source_type() const; - void l1_source_type_is(l1_source_type_t l1_source_type); - - intf_id_t port() const; - void port_is(intf_id_t port); - - bool operator==(l1_source_impl_t const & other) const; - bool operator!=(l1_source_impl_t const & other) const; - bool operator<(l1_source_impl_t const & other) const; - /** The hash function for type l1_source_t. */ - uint32_t hash() const; - /** The hash mix function for type l1_source_t. */ - void mix_me(hash_mix & h) const; - /** Returns a string representation of the current object's values. */ - std::string to_string() const; - /** - * A utility stream operator that adds a string representation of l1_source_t to - * the ostream. - */ - friend std::ostream& operator<<(std::ostream& os, const l1_source_impl_t& obj); - - private: - l1_source_type_t l1_source_type_; - intf_id_t port_; -}; -} - -#endif // EOS_TYPES_L1_SOURCE_IMPL_H diff --git a/eos/types/mac_table.h b/eos/types/mac_table.h index 42ccbf0..31d9b90 100644 --- a/eos/types/mac_table.h +++ b/eos/types/mac_table.h @@ -48,6 +48,7 @@ enum mac_entry_type_t { MAC_ENTRY_PEER_AUTHENTICATED, MAC_ENTRY_PENDING_SECURE, MAC_ENTRY_VPLS_DYNAMIC_REMOTE, + MAC_ENTRY_SOFTWARE_LEARNED_DYNAMIC, }; /** Appends a string representation of enum mac_entry_type_t value to the ostream. */ EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, diff --git a/eos/types/macsec.h b/eos/types/macsec.h index aa0315b..255042d 100644 --- a/eos/types/macsec.h +++ b/eos/types/macsec.h @@ -231,7 +231,13 @@ class EOS_SDK_PUBLIC macsec_profile_t { * protection : deprecated in favour of lldp_bypass_level. */ bool bypass_lldp() const; - /** Setter for 'bypass_lldp': deprecated in favour of lldp_bypass_level_is. */ + /** + * Setter for 'bypass_lldp': deprecated in favour of lldp_bypass_level_is. + * Both `bypass_lldp` and `lldp_bypass_level` operate on the same internal + * attribute. + * A value of false corresponds to the macsec_bypass_t value BYPASS_NULL while a + * value of true corresponds to BYPASS_AUTHORIZED. + */ void bypass_lldp_is(bool bypass_lldp); /** * Getter for 'lldp_bypass_level': If set, transmit/receive LLDP frames without diff --git a/eos/types/macsec_impl.h b/eos/types/macsec_impl.h index 60ea42c..6f5a0da 100644 --- a/eos/types/macsec_impl.h +++ b/eos/types/macsec_impl.h @@ -129,7 +129,13 @@ class EOS_SDK_PUBLIC macsec_profile_impl_t { * protection : deprecated in favour of lldp_bypass_level. */ bool bypass_lldp() const; - /** Setter for 'bypass_lldp': deprecated in favour of lldp_bypass_level_is. */ + /** + * Setter for 'bypass_lldp': deprecated in favour of lldp_bypass_level_is. + * Both `bypass_lldp` and `lldp_bypass_level` operate on the same internal + * attribute. + * A value of false corresponds to the macsec_bypass_t value BYPASS_NULL while a + * value of true corresponds to BYPASS_AUTHORIZED. + */ void bypass_lldp_is(bool bypass_lldp); /** * Getter for 'lldp_bypass_level': If set, transmit/receive LLDP frames without @@ -192,7 +198,6 @@ class EOS_SDK_PUBLIC macsec_profile_impl_t { macsec_cipher_suite_t cipher_; bool dot1x_; bool include_sci_; - bool bypass_lldp_; macsec_bypass_t lldp_bypass_level_; macsec_profile_traffic_policy_t traffic_policy_; bool replay_protection_; diff --git a/eos/types/nexthop_group.h b/eos/types/nexthop_group.h index 51e80a4..63eacb8 100644 --- a/eos/types/nexthop_group.h +++ b/eos/types/nexthop_group.h @@ -375,6 +375,75 @@ class EOS_SDK_PUBLIC nexthop_group_t { EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const nexthop_group_t& obj); + +/** + * The current counter programming status for a nexthop group. + * + * Counter State is a summary of the entire nexthop group and will not + * note which specific entries are in the provided state. + */ +enum nexthop_group_counter_state_t { + /** Nexthop group entry counters are not configured for this group. */ + NEXTHOP_GROUP_COUNTER_INACTIVE, + /** + * At least one nexthop group entry counter has failed to + * be programmed in hardware. + */ + NEXTHOP_GROUP_COUNTER_PROGRAMMING_FAILED, + /** + * All nexthop group entry counters have been successfully + * programmed in hardware. + */ + NEXTHOP_GROUP_COUNTER_PROGRAMMING_COMPLETE, +}; +/** + * Appends a string representation of enum nexthop_group_counter_state_t value to + * the ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<( + std::ostream& os, const nexthop_group_counter_state_t & enum_val); + +class nexthop_group_programmed_status_impl_t; +/** Status for the associated nexthop group. */ +class EOS_SDK_PUBLIC nexthop_group_programmed_status_t { + public: + nexthop_group_programmed_status_t(); + explicit nexthop_group_programmed_status_t( + nexthop_group_counter_state_t counter_state); + nexthop_group_programmed_status_t(const nexthop_group_programmed_status_t& other); + nexthop_group_programmed_status_t& operator=( + nexthop_group_programmed_status_t const & other); + + + /** + * Getter for 'counter_state': The status of the counter programming for this + * nexthop group. + */ + nexthop_group_counter_state_t counter_state() const; + + bool operator==(nexthop_group_programmed_status_t const & other) const; + bool operator!=(nexthop_group_programmed_status_t const & other) const; + bool operator<(nexthop_group_programmed_status_t const & other) const; + /** The hash function for type nexthop_group_programmed_status_t. */ + uint32_t hash() const; + /** The hash mix function for type nexthop_group_programmed_status_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * nexthop_group_programmed_status_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const nexthop_group_programmed_status_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, + const nexthop_group_programmed_status_t& obj); } #endif // EOS_TYPES_NEXTHOP_GROUP_H diff --git a/eos/types/nexthop_group_impl.h b/eos/types/nexthop_group_impl.h index deb82e5..4e27d99 100644 --- a/eos/types/nexthop_group_impl.h +++ b/eos/types/nexthop_group_impl.h @@ -318,6 +318,39 @@ class EOS_SDK_PUBLIC nexthop_group_impl_t { bool counters_persistent_; uint16_t version_id_; }; + +/** Status for the associated nexthop group. */ +class EOS_SDK_PUBLIC nexthop_group_programmed_status_impl_t { + public: + nexthop_group_programmed_status_impl_t(); + explicit nexthop_group_programmed_status_impl_t( + nexthop_group_counter_state_t counter_state); + + /** + * Getter for 'counter_state': The status of the counter programming for this + * nexthop group. + */ + nexthop_group_counter_state_t counter_state() const; + + bool operator==(nexthop_group_programmed_status_impl_t const & other) const; + bool operator!=(nexthop_group_programmed_status_impl_t const & other) const; + bool operator<(nexthop_group_programmed_status_impl_t const & other) const; + /** The hash function for type nexthop_group_programmed_status_t. */ + uint32_t hash() const; + /** The hash mix function for type nexthop_group_programmed_status_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * nexthop_group_programmed_status_t to the ostream. + */ + friend std::ostream& operator<<( + std::ostream& os, const nexthop_group_programmed_status_impl_t& obj); + + private: + nexthop_group_counter_state_t counter_state_; +}; } #endif // EOS_TYPES_NEXTHOP_GROUP_IMPL_H diff --git a/eos/types/policy_map.h b/eos/types/policy_map.h index e8af48f..b21c583 100644 --- a/eos/types/policy_map.h +++ b/eos/types/policy_map.h @@ -44,12 +44,13 @@ enum policy_feature_t { POLICY_FEATURE_PBR, POLICY_FEATURE_QOS, POLICY_FEATURE_TAP_AGG, + POLICY_FEATURE_TRAFFIC_POLICY, }; /** Appends a string representation of enum policy_feature_t value to the ostream. */ EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const policy_feature_t & enum_val); -/** The actions a policy map rule may apply to classified packets. */ +/** The actions a PBR/QOS policy rule may apply to classified packets. */ enum policy_action_type_t { POLICY_ACTION_NULL, /** Perform no action. */ @@ -72,6 +73,57 @@ enum policy_action_type_t { EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const policy_action_type_t & enum_val); +/** The actions a traffic-policy rule may apply to classified packets. */ +enum traffic_policy_action_type_t { + /** Drop traffic for this policy. */ + TRAFFIC_POLICY_ACTION_DROP, + /** Perform police action to limit traffic flow. */ + TRAFFIC_POLICY_ACTION_POLICE, + /** Perform count action to count packets. */ + TRAFFIC_POLICY_ACTION_COUNT, + /** Perform log action for logging. */ + TRAFFIC_POLICY_ACTION_LOG, + /** Perform goto action for matching packet. */ + TRAFFIC_POLICY_ACTION_GOTO, + /** Set DSCP bits. */ + TRAFFIC_POLICY_ACTION_DSCP, + /** Set traffic class. */ + TRAFFIC_POLICY_ACTION_TRAFFIC_CLASS, + /** Set vrf action. */ + TRAFFIC_POLICY_ACTION_SET_VRF, + /** Set vrf secondary action. */ + TRAFFIC_POLICY_ACTION_SET_VRF_SECONDARY, + /** Use vrf secondary action. */ + TRAFFIC_POLICY_ACTION_USE_VRF_SECONDARY, + /** Mirror matching traffic to destinations. */ + TRAFFIC_POLICY_ACTION_MIRROR, + /** Sample traffic and redirect to destinations. */ + TRAFFIC_POLICY_ACTION_SFLOW, + /** Forward to one or more IP nexthops. */ + TRAFFIC_POLICY_ACTION_NEXTHOP, + /** Forward to named group of nexthops/interfaces. */ + TRAFFIC_POLICY_ACTION_NEXTHOP_GROUP, +}; +/** + * Appends a string representation of enum traffic_policy_action_type_t value to + * the ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<( + std::ostream& os, const traffic_policy_action_type_t & enum_val); + +/** The direction in which a traffic-policy is applied. */ +enum traffic_policy_direction_t { + TRAFFIC_POLICY_DIRECTION_NULL, + /** Ingress traffic-policy. */ + TRAFFIC_POLICY_DIRECTION_INPUT, +}; +/** + * Appends a string representation of enum traffic_policy_direction_t value to the + * ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<( + std::ostream& os, const traffic_policy_direction_t & enum_val); + /** The policy map rule type. Valid types are IPV4 IPV6 and CLASSMAP. */ enum policy_map_rule_type_t { POLICY_RULE_TYPE_CLASSMAP, @@ -126,9 +178,35 @@ std::ostream& operator<<(std::ostream& os, const policy_map_key_t& obj); typedef policy_map_key_t class_map_key_t; +/** The rate unit type of police action. */ +enum police_rate_unit_t { + BPS, + KBPS, + MBPS, + GBPS, +}; +/** + * Appends a string representation of enum police_rate_unit_t value to the ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, + const police_rate_unit_t & enum_val); + +/** The burst unit type of police action. */ +enum police_burst_unit_t { + BYTES, + KBYTES, + MBYTES, +}; +/** + * Appends a string representation of enum police_burst_unit_t value to the + * ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, + const police_burst_unit_t & enum_val); + class policy_map_action_impl_t; /** - * A single policy map action. + * A single PBR/QOS action. * Each action defines a single type of action to be performed, presently * supporting: "set nexthop", "set nexthop group" and "drop". * It is illegal to set both nexthop and nexthop group or drop operations in a @@ -138,7 +216,7 @@ class EOS_SDK_PUBLIC policy_map_action_t { public: policy_map_action_t(); /** - * Constructs a policy map action of a particular type. + * Constructs a PBR/QOS action of a particular type. * * After construction, set attributes appropriate for the action type using the * mutators below; only the action-specific attributes will be considered when @@ -157,7 +235,7 @@ class EOS_SDK_PUBLIC policy_map_action_t { /** * Getter for 'nexthop_group_name': the name of the nexthop group to be used - * when the action is POLICY_ACTION_NEXTHOP_GROUP. + * when the action is POLICY_ACTION_NEXTHOP_GROUP for PBR. * If the nexthop group does not yet exist when calling policy_map_is() on the * policy_map_mgr, that action will complete successfully but FIB entries for * the nextop group will not be programmed until the group is configured. @@ -222,6 +300,141 @@ class EOS_SDK_PUBLIC policy_map_action_t { EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const policy_map_action_t& obj); +class traffic_policy_action_impl_t; +/** + * A single traffic-policy action. + * Each action defines a single type of action to be performed, presently + * supporting: "set nexthop", "set nexthop group" and "drop". + * It is illegal to set both nexthop and nexthop group or drop operations in a + * single policy map rule. + */ +class EOS_SDK_PUBLIC traffic_policy_action_t { + public: + traffic_policy_action_t(); + /** + * Constructs a traffic-policy action of a particular type. + * + * After construction, set attributes appropriate for the action type using the + * mutators below; only the action-specific attributes will be considered when + * the policy is applied. If the action is POLICY_ACTION_DROP, no further + * attributes require being set. + */ + explicit traffic_policy_action_t(traffic_policy_action_type_t action_type); + traffic_policy_action_t(const traffic_policy_action_t& other); + traffic_policy_action_t& operator=( + traffic_policy_action_t const & other); + + virtual ~traffic_policy_action_t(); + + traffic_policy_action_type_t action_type() const; + void action_type_is(traffic_policy_action_type_t action_type); + + /** Getter for 'goto_class_name': the name of class for goto action. */ + std::string goto_class_name() const; + /** Setter for 'goto_class_name'. */ + void goto_class_name_is(std::string const & goto_class_name); + + /** Getter for 'goto_next': the flag indicating if it is goto next action. */ + bool goto_next() const; + /** Setter for 'goto_next'. */ + void goto_next_is(bool const & goto_next); + + /** + * Getter for 'dscp': the DiffServ Code Point on matching IPv4/IPv6 packets. + * This sets the 6-bit IPv4 DSCP or IPv6 traffic class field. + * + * @throw eos::invalid_argument_error if value outside range 0..63. + */ + uint8_t dscp() const; + /** Setter for 'dscp'. */ + void dscp_is(uint8_t dscp); + + /** + * Getter for 'traffic_class': the internal EOS traffic class on matching + * packets. + * Setting this 3-bit value overrides any interface CoS/DSCP trust mapping. + * + * @throw eos::invalid_argument_error if value outside range 0..7. + */ + uint8_t traffic_class() const; + /** Setter for 'traffic_class'. */ + void traffic_class_is(uint8_t traffic_class); + + /** Getter for 'vrf': the name of the VRF for nexthop action. */ + std::string vrf() const; + /** Setter for 'vrf'. */ + void vrf_is(std::string const & vrf); + + /** Getter for 'mirror_session': the name of mirror session for mirror action. */ + std::string mirror_session() const; + /** Setter for 'mirror_session'. */ + void mirror_session_is(std::string const & mirror_session); + + /** Getter for 'police_rate': the police rate value for police action. */ + uint64_t police_rate() const; + /** Setter for 'police_rate'. */ + void police_rate_is(uint64_t const & police_rate); + + /** + * Getter for 'police_burst_size': the police burst size value for police + * action. + */ + uint64_t police_burst_size() const; + /** Setter for 'police_burst_size'. */ + void police_burst_size_is(uint64_t const & police_burst_size); + + /** Getter for 'police_rate_unit': the police rate unit for police action. */ + police_rate_unit_t police_rate_unit() const; + /** Setter for 'police_rate_unit'. */ + void police_rate_unit_is(police_rate_unit_t const & police_rate_unit); + + /** Getter for 'police_burst_unit': the police burst unit for police action. */ + police_burst_unit_t police_burst_unit() const; + /** Setter for 'police_burst_unit'. */ + void police_burst_unit_is(police_burst_unit_t const & police_burst_unit); + + /** + * Getter for 'nexthop_groups': the set of nexthop group names for traffic- + * policy nexthop group action. + */ + std::unordered_set const & nexthop_groups() const; + /** Setter for 'nexthop_groups'. */ + void nexthop_groups_is(std::unordered_set const & nexthop_groups); + /** Inserts one nexthop_group of 'value' to the set. */ + void nexthop_group_set(std::string const & value); + /** Deletes one nexthop_group of 'value' from the set. */ + void nexthop_group_del(std::string const & value); + + std::unordered_set const & nexthops() const; + void nexthops_is(std::unordered_set const & nexthops); + /** Inserts one nexthop of 'value' to the set. */ + void nexthop_set(ip_addr_t const & value); + /** Deletes one nexthop of 'value' from the set. */ + void nexthop_del(ip_addr_t const & value); + + bool operator==(traffic_policy_action_t const & other) const; + bool operator!=(traffic_policy_action_t const & other) const; + bool operator<(traffic_policy_action_t const & other) const; + /** The hash function for type traffic_policy_action_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_action_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_action_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const traffic_policy_action_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const traffic_policy_action_t& obj); + class policy_map_rule_impl_t; /** * A policy map rule, describing a traffic match and actions. @@ -266,13 +479,14 @@ class EOS_SDK_PUBLIC policy_map_rule_t { /** Setter for 'policy_map_rule_type'. */ void policy_map_rule_type_is(policy_map_rule_type_t policy_map_rule_type); - /** Getter for 'raw_rule': the raw match statement. */ + /** Getter for 'raw_rule': the raw match statement of PBR. */ acl_rule_ip_t raw_rule() const; /** Setter for 'raw_rule'. */ void raw_rule_is(acl_rule_ip_t raw_rule); /** - * Getter for 'actions': the set of actions configured for this particular rule. + * Getter for 'actions': the set of actions configured for this particular rule + * of a PBR/QOS policy. */ std::set const & actions() const; /** Setter for 'actions'. */ @@ -352,6 +566,120 @@ class EOS_SDK_PUBLIC policy_map_t { EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, const policy_map_t& obj); +class traffic_policy_rule_impl_t; +/** + * A traffic policy rule, describing traffic match and actions. + * + * A rule works by creating a filter to match only certain types of traffic. Any + * traffic that passes this filter then has the corresponding + * `traffic_policy_action_t` actions applied. For example, a rule can specify that + * any traffic on protocol tcp should have its traffic class set to 4. + * + * Actions can be set at once or added or removed one at a time. + */ +class EOS_SDK_PUBLIC traffic_policy_rule_t { + public: + traffic_policy_rule_t(); + traffic_policy_rule_t(std::string match_rule_name, + traffic_policy_rule_type_t traffic_policy_rule_type); + traffic_policy_rule_t(const traffic_policy_rule_t& other); + traffic_policy_rule_t& operator=( + traffic_policy_rule_t const & other); + + + std::string match_rule_name() const; + + /** + * Getter for 'traffic_policy_rule_type': the rule type of traffic-policy. Set + * the rule type to TRAFFIC_POLICY_RULE_TYPE_IPV4 or + * TRAFFIC_POLICY_RULE_TYPE_IPV6. + */ + traffic_policy_rule_type_t traffic_policy_rule_type() const; + + /** Getter for 'raw_rule': the match rule of a traffic policy. */ + tp_rule_filter_t raw_rule() const; + + /** + * Getter for 'actions': the set of actions configured for this particular rule + * of a traffic policy. + */ + std::set const & actions() const; + /** Setter for 'actions'. */ + void actions_is(std::set const & actions); + /** Inserts one action of 'value' to the set. */ + void action_set(traffic_policy_action_t const & value); + /** Deletes one action of 'value' from the set. */ + void action_del(traffic_policy_action_t const & value); + + void raw_rule_is(tp_rule_filter_t const & raw_rule); + void action_del(traffic_policy_action_type_t action_type); + bool operator==(traffic_policy_rule_t const & other) const; + bool operator!=(traffic_policy_rule_t const & other) const; + bool operator<(traffic_policy_rule_t const & other) const; + /** The hash function for type traffic_policy_rule_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_rule_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_rule_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const traffic_policy_rule_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const traffic_policy_rule_t& obj); + +class traffic_policy_impl_t; +/** + * A traffic policy instance. + * + * Once appropriately configured, traffic policies are committed and applied to + * interfaces using the policy_map_mgr. + */ +class EOS_SDK_PUBLIC traffic_policy_t { + public: + explicit traffic_policy_t(std::string const & key); + traffic_policy_t(const traffic_policy_t& other); + traffic_policy_t& operator=( + traffic_policy_t const & other); + + + std::string key() const; + + std::map const & rules() const; + + void rules_is(std::map const & rules); + void rule_set(uint32_t key, traffic_policy_rule_t const & value); + void rule_del(uint32_t key); + bool operator==(traffic_policy_t const & other) const; + bool operator!=(traffic_policy_t const & other) const; + bool operator<(traffic_policy_t const & other) const; + /** The hash function for type traffic_policy_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const traffic_policy_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const traffic_policy_t& obj); + /** The policy feature requested is unavailable in this SDK release. */ class EOS_SDK_PUBLIC unsupported_policy_feature_error : public unsupported_error { public: diff --git a/eos/types/policy_map_impl.h b/eos/types/policy_map_impl.h index 48af54d..5a51bab 100644 --- a/eos/types/policy_map_impl.h +++ b/eos/types/policy_map_impl.h @@ -52,7 +52,7 @@ class EOS_SDK_PUBLIC policy_map_key_impl_t { }; /** - * A single policy map action. + * A single PBR/QOS action. * Each action defines a single type of action to be performed, presently * supporting: "set nexthop", "set nexthop group" and "drop". * It is illegal to set both nexthop and nexthop group or drop operations in a @@ -62,7 +62,7 @@ class EOS_SDK_PUBLIC policy_map_action_impl_t { public: policy_map_action_impl_t(); /** - * Constructs a policy map action of a particular type. + * Constructs a PBR/QOS action of a particular type. * * After construction, set attributes appropriate for the action type using the * mutators below; only the action-specific attributes will be considered when @@ -77,7 +77,7 @@ class EOS_SDK_PUBLIC policy_map_action_impl_t { /** * Getter for 'nexthop_group_name': the name of the nexthop group to be used - * when the action is POLICY_ACTION_NEXTHOP_GROUP. + * when the action is POLICY_ACTION_NEXTHOP_GROUP for PBR. * If the nexthop group does not yet exist when calling policy_map_is() on the * policy_map_mgr, that action will complete successfully but FIB entries for * the nextop group will not be programmed until the group is configured. @@ -144,6 +144,145 @@ class EOS_SDK_PUBLIC policy_map_action_impl_t { uint8_t traffic_class_; }; +/** + * A single traffic-policy action. + * Each action defines a single type of action to be performed, presently + * supporting: "set nexthop", "set nexthop group" and "drop". + * It is illegal to set both nexthop and nexthop group or drop operations in a + * single policy map rule. + */ +class EOS_SDK_PUBLIC traffic_policy_action_impl_t { + public: + traffic_policy_action_impl_t(); + /** + * Constructs a traffic-policy action of a particular type. + * + * After construction, set attributes appropriate for the action type using the + * mutators below; only the action-specific attributes will be considered when + * the policy is applied. If the action is POLICY_ACTION_DROP, no further + * attributes require being set. + */ + explicit traffic_policy_action_impl_t(traffic_policy_action_type_t action_type); + virtual ~traffic_policy_action_impl_t(); + + traffic_policy_action_type_t action_type() const; + void action_type_is(traffic_policy_action_type_t action_type); + + /** Getter for 'goto_class_name': the name of class for goto action. */ + std::string goto_class_name() const; + /** Setter for 'goto_class_name'. */ + void goto_class_name_is(std::string const & goto_class_name); + + /** Getter for 'goto_next': the flag indicating if it is goto next action. */ + bool goto_next() const; + /** Setter for 'goto_next'. */ + void goto_next_is(bool const & goto_next); + + /** + * Getter for 'dscp': the DiffServ Code Point on matching IPv4/IPv6 packets. + * This sets the 6-bit IPv4 DSCP or IPv6 traffic class field. + * + * @throw eos::invalid_argument_error if value outside range 0..63. + */ + uint8_t dscp() const; + /** Setter for 'dscp'. */ + void dscp_is(uint8_t dscp); + + /** + * Getter for 'traffic_class': the internal EOS traffic class on matching + * packets. + * Setting this 3-bit value overrides any interface CoS/DSCP trust mapping. + * + * @throw eos::invalid_argument_error if value outside range 0..7. + */ + uint8_t traffic_class() const; + /** Setter for 'traffic_class'. */ + void traffic_class_is(uint8_t traffic_class); + + /** Getter for 'vrf': the name of the VRF for nexthop action. */ + std::string vrf() const; + /** Setter for 'vrf'. */ + void vrf_is(std::string const & vrf); + + /** Getter for 'mirror_session': the name of mirror session for mirror action. */ + std::string mirror_session() const; + /** Setter for 'mirror_session'. */ + void mirror_session_is(std::string const & mirror_session); + + /** Getter for 'police_rate': the police rate value for police action. */ + uint64_t police_rate() const; + /** Setter for 'police_rate'. */ + void police_rate_is(uint64_t const & police_rate); + + /** + * Getter for 'police_burst_size': the police burst size value for police + * action. + */ + uint64_t police_burst_size() const; + /** Setter for 'police_burst_size'. */ + void police_burst_size_is(uint64_t const & police_burst_size); + + /** Getter for 'police_rate_unit': the police rate unit for police action. */ + police_rate_unit_t police_rate_unit() const; + /** Setter for 'police_rate_unit'. */ + void police_rate_unit_is(police_rate_unit_t const & police_rate_unit); + + /** Getter for 'police_burst_unit': the police burst unit for police action. */ + police_burst_unit_t police_burst_unit() const; + /** Setter for 'police_burst_unit'. */ + void police_burst_unit_is(police_burst_unit_t const & police_burst_unit); + + /** + * Getter for 'nexthop_groups': the set of nexthop group names for traffic- + * policy nexthop group action. + */ + std::unordered_set const & nexthop_groups() const; + /** Setter for 'nexthop_groups'. */ + void nexthop_groups_is(std::unordered_set const & nexthop_groups); + /** Inserts one nexthop_group of 'value' to the set. */ + void nexthop_group_set(std::string const & value); + /** Deletes one nexthop_group of 'value' from the set. */ + void nexthop_group_del(std::string const & value); + + std::unordered_set const & nexthops() const; + void nexthops_is(std::unordered_set const & nexthops); + /** Inserts one nexthop of 'value' to the set. */ + void nexthop_set(ip_addr_t const & value); + /** Deletes one nexthop of 'value' from the set. */ + void nexthop_del(ip_addr_t const & value); + + bool operator==(traffic_policy_action_impl_t const & other) const; + bool operator!=(traffic_policy_action_impl_t const & other) const; + bool operator<(traffic_policy_action_impl_t const & other) const; + /** The hash function for type traffic_policy_action_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_action_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_action_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const traffic_policy_action_impl_t& obj); + + private: + traffic_policy_action_type_t action_type_; + std::string goto_class_name_; + bool goto_next_; + uint8_t dscp_; + uint8_t traffic_class_; + std::string vrf_; + std::string mirror_session_; + uint64_t police_rate_; + uint64_t police_burst_size_; + police_rate_unit_t police_rate_unit_; + police_burst_unit_t police_burst_unit_; + std::unordered_set nexthop_groups_; + std::unordered_set nexthops_; +}; + /** * A policy map rule, describing a traffic match and actions. * @@ -183,13 +322,14 @@ class EOS_SDK_PUBLIC policy_map_rule_impl_t { /** Setter for 'policy_map_rule_type'. */ void policy_map_rule_type_is(policy_map_rule_type_t policy_map_rule_type); - /** Getter for 'raw_rule': the raw match statement. */ + /** Getter for 'raw_rule': the raw match statement of PBR. */ acl_rule_ip_t raw_rule() const; /** Setter for 'raw_rule'. */ void raw_rule_is(acl_rule_ip_t raw_rule); /** - * Getter for 'actions': the set of actions configured for this particular rule. + * Getter for 'actions': the set of actions configured for this particular rule + * of a PBR/QOS policy. */ std::set const & actions() const; /** Setter for 'actions'. */ @@ -263,6 +403,109 @@ class EOS_SDK_PUBLIC policy_map_impl_t { std::map rules_; }; +/** + * A traffic policy rule, describing traffic match and actions. + * + * A rule works by creating a filter to match only certain types of traffic. Any + * traffic that passes this filter then has the corresponding + * `traffic_policy_action_t` actions applied. For example, a rule can specify that + * any traffic on protocol tcp should have its traffic class set to 4. + * + * Actions can be set at once or added or removed one at a time. + */ +class EOS_SDK_PUBLIC traffic_policy_rule_impl_t { + public: + traffic_policy_rule_impl_t(); + traffic_policy_rule_impl_t(std::string match_rule_name, + traffic_policy_rule_type_t traffic_policy_rule_type); + + std::string match_rule_name() const; + + /** + * Getter for 'traffic_policy_rule_type': the rule type of traffic-policy. Set + * the rule type to TRAFFIC_POLICY_RULE_TYPE_IPV4 or + * TRAFFIC_POLICY_RULE_TYPE_IPV6. + */ + traffic_policy_rule_type_t traffic_policy_rule_type() const; + + /** Getter for 'raw_rule': the match rule of a traffic policy. */ + tp_rule_filter_t raw_rule() const; + + /** + * Getter for 'actions': the set of actions configured for this particular rule + * of a traffic policy. + */ + std::set const & actions() const; + /** Setter for 'actions'. */ + void actions_is(std::set const & actions); + /** Inserts one action of 'value' to the set. */ + void action_set(traffic_policy_action_t const & value); + /** Deletes one action of 'value' from the set. */ + void action_del(traffic_policy_action_t const & value); + + void raw_rule_is(tp_rule_filter_t const & raw_rule); + void action_del(traffic_policy_action_type_t action_type); + bool operator==(traffic_policy_rule_impl_t const & other) const; + bool operator!=(traffic_policy_rule_impl_t const & other) const; + bool operator<(traffic_policy_rule_impl_t const & other) const; + /** The hash function for type traffic_policy_rule_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_rule_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_rule_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const traffic_policy_rule_impl_t& obj); + + private: + std::string match_rule_name_; + traffic_policy_rule_type_t traffic_policy_rule_type_; + tp_rule_filter_t raw_rule_; + std::set actions_; +}; + +/** + * A traffic policy instance. + * + * Once appropriately configured, traffic policies are committed and applied to + * interfaces using the policy_map_mgr. + */ +class EOS_SDK_PUBLIC traffic_policy_impl_t { + public: + explicit traffic_policy_impl_t(std::string const & key); + + std::string key() const; + + std::map const & rules() const; + + void rules_is(std::map const & rules); + void rule_set(uint32_t key, traffic_policy_rule_t const & value); + void rule_del(uint32_t key); + bool operator==(traffic_policy_impl_t const & other) const; + bool operator!=(traffic_policy_impl_t const & other) const; + bool operator<(traffic_policy_impl_t const & other) const; + /** The hash function for type traffic_policy_t. */ + uint32_t hash() const; + /** The hash mix function for type traffic_policy_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * traffic_policy_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const traffic_policy_impl_t& obj); + + private: + std::string key_; + std::map rules_; +}; + /** policy map hardware interface key. */ class EOS_SDK_PUBLIC policy_map_hw_status_key_impl_t { diff --git a/eos/types/structured_filter.h b/eos/types/structured_filter.h new file mode 100644 index 0000000..8aea0a6 --- /dev/null +++ b/eos/types/structured_filter.h @@ -0,0 +1,291 @@ +// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. +// Arista Networks, Inc. Confidential and Proprietary. + +#ifndef EOS_TYPES_STRUCTURED_FILTER_H +#define EOS_TYPES_STRUCTURED_FILTER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eos { + +/** + * Constant enums for traffic-policy to define the maximum values of fields + * (protocols, l4-ports). + */ +enum tp_max_values_t { + TP_MAX_PROTO = 255, + TP_MAX_L4PORT = 65535, +}; +/** Appends a string representation of enum tp_max_values_t value to the ostream. */ +EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, + const tp_max_values_t & enum_val); + +class protocol_range_impl_t; +/** Range type for configuring protocol ranges of traffic-policy. */ +class EOS_SDK_PUBLIC protocol_range_t { + public: + protocol_range_t(); + protocol_range_t(const protocol_range_t& other); + protocol_range_t& operator=( + protocol_range_t const & other); + + + uint32_t range_start() const; + void range_start_is(uint32_t range_start); + + uint32_t range_end() const; + void range_end_is(uint32_t range_end); + + bool operator==(protocol_range_t const & other) const; + bool operator!=(protocol_range_t const & other) const; + bool operator<(protocol_range_t const & other) const; + /** The hash function for type protocol_range_t. */ + uint32_t hash() const; + /** The hash mix function for type protocol_range_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * protocol_range_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const protocol_range_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const protocol_range_t& obj); + +class port_range_impl_t; +/** Range type for configuring port ranges of traffic-policy. */ +class EOS_SDK_PUBLIC port_range_t { + public: + port_range_t(); + port_range_t(const port_range_t& other); + port_range_t& operator=( + port_range_t const & other); + + + uint32_t range_start() const; + void range_start_is(uint32_t range_start); + + uint32_t range_end() const; + void range_end_is(uint32_t range_end); + + bool operator==(port_range_t const & other) const; + bool operator!=(port_range_t const & other) const; + bool operator<(port_range_t const & other) const; + /** The hash function for type port_range_t. */ + uint32_t hash() const; + /** The hash mix function for type port_range_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of port_range_t + * to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const port_range_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const port_range_t& obj); + +class port_field_impl_t; +/** Field type used to configure the port ranges or port field-sets. */ +class EOS_SDK_PUBLIC port_field_t { + public: + port_field_t(); + port_field_t(const port_field_t& other); + port_field_t& operator=( + port_field_t const & other); + + + std::set const & src_ports() const; + void src_ports_is(std::set const & src_ports); + /** Inserts one src_port of 'value' to the set. */ + void src_port_set(port_range_t const & value); + /** Deletes one src_port of 'value' from the set. */ + void src_port_del(port_range_t const & value); + + std::set const & dst_ports() const; + void dst_ports_is(std::set const & dst_ports); + /** Inserts one dst_port of 'value' to the set. */ + void dst_port_set(port_range_t const & value); + /** Deletes one dst_port of 'value' from the set. */ + void dst_port_del(port_range_t const & value); + + std::unordered_set const & src_port_field_sets() const; + void src_port_field_sets_is( + std::unordered_set const & src_port_field_sets); + /** Inserts one src_port_field_set of 'value' to the set. */ + void src_port_field_set_set(std::string const & value); + /** Deletes one src_port_field_set of 'value' from the set. */ + void src_port_field_set_del(std::string const & value); + + std::unordered_set const & dst_port_field_sets() const; + void dst_port_field_sets_is( + std::unordered_set const & dst_port_field_sets); + /** Inserts one dst_port_field_set of 'value' to the set. */ + void dst_port_field_set_set(std::string const & value); + /** Deletes one dst_port_field_set of 'value' from the set. */ + void dst_port_field_set_del(std::string const & value); + + bool operator==(port_field_t const & other) const; + bool operator!=(port_field_t const & other) const; + bool operator<(port_field_t const & other) const; + /** The hash function for type port_field_t. */ + uint32_t hash() const; + /** The hash mix function for type port_field_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of port_field_t + * to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const port_field_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const port_field_t& obj); + +class protocol_field_impl_t; +/** Field type used to configure the protocol ranges or protocol field-sets. */ +class EOS_SDK_PUBLIC protocol_field_t { + public: + protocol_field_t(); + protocol_field_t(const protocol_field_t& other); + protocol_field_t& operator=( + protocol_field_t const & other); + + + /** Getter for 'ports': the key of the map ports should be an unique id. */ + std::map const & ports() const; + /** Setter for 'ports'. */ + void ports_is(std::map const & ports); + /** Inserts key/value pair to the map. */ + void port_set(uint32_t key, port_field_t const & value); + /** Deletes the key/value pair from the map. */ + void port_del(uint32_t key); + + bool operator==(protocol_field_t const & other) const; + bool operator!=(protocol_field_t const & other) const; + bool operator<(protocol_field_t const & other) const; + /** The hash function for type protocol_field_t. */ + uint32_t hash() const; + /** The hash mix function for type protocol_field_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * protocol_field_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const protocol_field_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const protocol_field_t& obj); + +/** The traffic policy rule type. Valid types are IPV4 and IPV6. */ +enum traffic_policy_rule_type_t { + TRAFFIC_POLICY_RULE_TYPE_NULL, + TRAFFIC_POLICY_RULE_TYPE_IPV4, + TRAFFIC_POLICY_RULE_TYPE_IPV6, +}; +/** + * Appends a string representation of enum traffic_policy_rule_type_t value to the + * ostream. + */ +EOS_SDK_PUBLIC std::ostream& operator<<( + std::ostream& os, const traffic_policy_rule_type_t & enum_val); + +class tp_rule_filter_impl_t; +/** + * This type is used to store the configs of all match fields of a traffic-policy + * rule. + */ +class EOS_SDK_PUBLIC tp_rule_filter_t { + public: + tp_rule_filter_t(); + explicit tp_rule_filter_t(traffic_policy_rule_type_t filter_type); + tp_rule_filter_t(const tp_rule_filter_t& other); + tp_rule_filter_t& operator=( + tp_rule_filter_t const & other); + + + std::set const & src_addrs() const; + + std::unordered_set const & src_addr_field_sets() const; + + std::set const & dst_addrs() const; + + std::unordered_set const & dst_addr_field_sets() const; + + std::map const & protocols() const; + void protocols_is( + std::map const & protocols); + /** Inserts key/value pair to the map. */ + void protocol_set(protocol_range_t key, protocol_field_t const & value); + /** Deletes the key/value pair from the map. */ + void protocol_del(protocol_range_t key); + + traffic_policy_rule_type_t filter_type() const; + + void src_addr_set(ip_addr_mask_t const & value); + void src_addr_del(ip_addr_mask_t const & value); + void src_addrs_is(std::set const & src_addrs); + void dst_addr_set(ip_addr_mask_t const & value); + void dst_addr_del(ip_addr_mask_t const & value); + void dst_addrs_is(std::set const & dst_addrs); + void src_addr_field_set_set(std::string const & value); + void src_addr_field_set_del(std::string const & value); + void src_addr_field_sets_is( + std::unordered_set const & src_addr_field_sets); + void dst_addr_field_set_set(std::string const & value); + void dst_addr_field_set_del(std::string const & value); + void dst_addr_field_sets_is( + std::unordered_set const & dst_addr_field_sets); + bool operator==(tp_rule_filter_t const & other) const; + bool operator!=(tp_rule_filter_t const & other) const; + bool operator<(tp_rule_filter_t const & other) const; + /** The hash function for type tp_rule_filter_t. */ + uint32_t hash() const; + /** The hash mix function for type tp_rule_filter_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * tp_rule_filter_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const tp_rule_filter_t& obj); + + private: + std::shared_ptr pimpl; +}; + +EOS_SDK_PUBLIC +std::ostream& operator<<(std::ostream& os, const tp_rule_filter_t& obj); +} + +#endif // EOS_TYPES_STRUCTURED_FILTER_H diff --git a/eos/types/structured_filter_impl.h b/eos/types/structured_filter_impl.h new file mode 100644 index 0000000..2b6c527 --- /dev/null +++ b/eos/types/structured_filter_impl.h @@ -0,0 +1,239 @@ +// Copyright (c) 2023 Arista Networks, Inc. All rights reserved. +// Arista Networks, Inc. Confidential and Proprietary. + +#ifndef EOS_TYPES_STRUCTURED_FILTER_IMPL_H +#define EOS_TYPES_STRUCTURED_FILTER_IMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eos { + +/** Range type for configuring protocol ranges of traffic-policy. */ +class EOS_SDK_PUBLIC protocol_range_impl_t { + public: + protocol_range_impl_t(); + + uint32_t range_start() const; + void range_start_is(uint32_t range_start); + + uint32_t range_end() const; + void range_end_is(uint32_t range_end); + + bool operator==(protocol_range_impl_t const & other) const; + bool operator!=(protocol_range_impl_t const & other) const; + bool operator<(protocol_range_impl_t const & other) const; + /** The hash function for type protocol_range_t. */ + uint32_t hash() const; + /** The hash mix function for type protocol_range_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * protocol_range_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const protocol_range_impl_t& obj); + + private: + uint32_t range_start_; + uint32_t range_end_; +}; + +/** Range type for configuring port ranges of traffic-policy. */ +class EOS_SDK_PUBLIC port_range_impl_t { + public: + port_range_impl_t(); + + uint32_t range_start() const; + void range_start_is(uint32_t range_start); + + uint32_t range_end() const; + void range_end_is(uint32_t range_end); + + bool operator==(port_range_impl_t const & other) const; + bool operator!=(port_range_impl_t const & other) const; + bool operator<(port_range_impl_t const & other) const; + /** The hash function for type port_range_t. */ + uint32_t hash() const; + /** The hash mix function for type port_range_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of port_range_t + * to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const port_range_impl_t& obj); + + private: + uint32_t range_start_; + uint32_t range_end_; +}; + +/** Field type used to configure the port ranges or port field-sets. */ +class EOS_SDK_PUBLIC port_field_impl_t { + public: + port_field_impl_t(); + + std::set const & src_ports() const; + void src_ports_is(std::set const & src_ports); + /** Inserts one src_port of 'value' to the set. */ + void src_port_set(port_range_t const & value); + /** Deletes one src_port of 'value' from the set. */ + void src_port_del(port_range_t const & value); + + std::set const & dst_ports() const; + void dst_ports_is(std::set const & dst_ports); + /** Inserts one dst_port of 'value' to the set. */ + void dst_port_set(port_range_t const & value); + /** Deletes one dst_port of 'value' from the set. */ + void dst_port_del(port_range_t const & value); + + std::unordered_set const & src_port_field_sets() const; + void src_port_field_sets_is( + std::unordered_set const & src_port_field_sets); + /** Inserts one src_port_field_set of 'value' to the set. */ + void src_port_field_set_set(std::string const & value); + /** Deletes one src_port_field_set of 'value' from the set. */ + void src_port_field_set_del(std::string const & value); + + std::unordered_set const & dst_port_field_sets() const; + void dst_port_field_sets_is( + std::unordered_set const & dst_port_field_sets); + /** Inserts one dst_port_field_set of 'value' to the set. */ + void dst_port_field_set_set(std::string const & value); + /** Deletes one dst_port_field_set of 'value' from the set. */ + void dst_port_field_set_del(std::string const & value); + + bool operator==(port_field_impl_t const & other) const; + bool operator!=(port_field_impl_t const & other) const; + bool operator<(port_field_impl_t const & other) const; + /** The hash function for type port_field_t. */ + uint32_t hash() const; + /** The hash mix function for type port_field_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of port_field_t + * to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, const port_field_impl_t& obj); + + private: + std::set src_ports_; + std::set dst_ports_; + std::unordered_set src_port_field_sets_; + std::unordered_set dst_port_field_sets_; +}; + +/** Field type used to configure the protocol ranges or protocol field-sets. */ +class EOS_SDK_PUBLIC protocol_field_impl_t { + public: + protocol_field_impl_t(); + + /** Getter for 'ports': the key of the map ports should be an unique id. */ + std::map const & ports() const; + /** Setter for 'ports'. */ + void ports_is(std::map const & ports); + /** Inserts key/value pair to the map. */ + void port_set(uint32_t key, port_field_t const & value); + /** Deletes the key/value pair from the map. */ + void port_del(uint32_t key); + + bool operator==(protocol_field_impl_t const & other) const; + bool operator!=(protocol_field_impl_t const & other) const; + bool operator<(protocol_field_impl_t const & other) const; + /** The hash function for type protocol_field_t. */ + uint32_t hash() const; + /** The hash mix function for type protocol_field_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * protocol_field_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const protocol_field_impl_t& obj); + + private: + std::map ports_; +}; + +/** + * This type is used to store the configs of all match fields of a traffic-policy + * rule. + */ +class EOS_SDK_PUBLIC tp_rule_filter_impl_t { + public: + tp_rule_filter_impl_t(); + explicit tp_rule_filter_impl_t(traffic_policy_rule_type_t filter_type); + + std::set const & src_addrs() const; + + std::unordered_set const & src_addr_field_sets() const; + + std::set const & dst_addrs() const; + + std::unordered_set const & dst_addr_field_sets() const; + + std::map const & protocols() const; + void protocols_is( + std::map const & protocols); + /** Inserts key/value pair to the map. */ + void protocol_set(protocol_range_t key, protocol_field_t const & value); + /** Deletes the key/value pair from the map. */ + void protocol_del(protocol_range_t key); + + traffic_policy_rule_type_t filter_type() const; + + void src_addr_set(ip_addr_mask_t const & value); + void src_addr_del(ip_addr_mask_t const & value); + void src_addrs_is(std::set const & src_addrs); + void dst_addr_set(ip_addr_mask_t const & value); + void dst_addr_del(ip_addr_mask_t const & value); + void dst_addrs_is(std::set const & dst_addrs); + void src_addr_field_set_set(std::string const & value); + void src_addr_field_set_del(std::string const & value); + void src_addr_field_sets_is( + std::unordered_set const & src_addr_field_sets); + void dst_addr_field_set_set(std::string const & value); + void dst_addr_field_set_del(std::string const & value); + void dst_addr_field_sets_is( + std::unordered_set const & dst_addr_field_sets); + bool operator==(tp_rule_filter_impl_t const & other) const; + bool operator!=(tp_rule_filter_impl_t const & other) const; + bool operator<(tp_rule_filter_impl_t const & other) const; + /** The hash function for type tp_rule_filter_t. */ + uint32_t hash() const; + /** The hash mix function for type tp_rule_filter_t. */ + void mix_me(hash_mix & h) const; + /** Returns a string representation of the current object's values. */ + std::string to_string() const; + /** + * A utility stream operator that adds a string representation of + * tp_rule_filter_t to the ostream. + */ + friend std::ostream& operator<<(std::ostream& os, + const tp_rule_filter_impl_t& obj); + + private: + std::set src_addrs_; + std::unordered_set src_addr_field_sets_; + std::set dst_addrs_; + std::unordered_set dst_addr_field_sets_; + std::map protocols_; + traffic_policy_rule_type_t filter_type_; +}; +} + +#endif // EOS_TYPES_STRUCTURED_FILTER_IMPL_H diff --git a/eos/version.h b/eos/version.h index bbaa627..d565ab9 100644 --- a/eos/version.h +++ b/eos/version.h @@ -24,10 +24,10 @@ #include -#define EOSSDK_VERSION "2.22.3" +#define EOSSDK_VERSION "2.22.4" #define EOSSDK_MAJOR 2 #define EOSSDK_MINOR 22 -#define EOSSDK_PATCH 3 +#define EOSSDK_PATCH 4 namespace eos { diff --git a/examples/BgpPathAgent.cpp b/examples/BgpPathAgent.cpp index 4775b58..f1ba8b6 100644 --- a/examples/BgpPathAgent.cpp +++ b/examples/BgpPathAgent.cpp @@ -100,12 +100,15 @@ class BgpPathTestAgent : public eos::agent_handler, void dump_bgp_paths() { t.trace0("Dumping paths"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" for(auto & iter : ipv4_unicast_paths) { t.trace2(iter.second.to_string().c_str()); } for(auto & iter : ipv6_unicast_paths) { t.trace2(iter.second.to_string().c_str()); } +#pragma GCC diagnostic pop } void on_ipv4_unicast_bgp_converged(bool converged) { diff --git a/examples/CliPlugin/CustomIpRouteCli.py b/examples/CliPlugin/CustomIpRouteCli.py index 5c59946..3141f4b 100644 --- a/examples/CliPlugin/CustomIpRouteCli.py +++ b/examples/CliPlugin/CustomIpRouteCli.py @@ -1,4 +1,4 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -22,7 +22,6 @@ def Plugin(sdk): "killall FastCli" to reload all CLIs so the new CLI will take effect. """ -from __future__ import absolute_import, division, print_function import BasicCli import CliMatcher import eossdk diff --git a/examples/CliPlugin/CustomMoveAccessInterfaceCli.py b/examples/CliPlugin/CustomMoveAccessInterfaceCli.py index d59b547..686cfca 100644 --- a/examples/CliPlugin/CustomMoveAccessInterfaceCli.py +++ b/examples/CliPlugin/CustomMoveAccessInterfaceCli.py @@ -1,4 +1,4 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -22,7 +22,6 @@ def Plugin(sdk): need to issue "killall FastCli" to reload all CLIs so the new CLI will take effect. """ -from __future__ import absolute_import, division, print_function import BasicCli import CliMatcher import CliCommand diff --git a/examples/DirectFlowProgrammer.py b/examples/DirectFlowProgrammer.py index 29c6353..b382163 100755 --- a/examples/DirectFlowProgrammer.py +++ b/examples/DirectFlowProgrammer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -120,7 +120,7 @@ def on_readable(self, fd): # NAME (add|delete) IPADDR INTERFACE # and adds/deletes a flow that matches on that destination ip address # and outputs that flow on the given interface - buf = os.read(fd, 4096).strip() + buf = os.read( fd, 4096 ).decode().strip() if not buf: self.agentMgr_.exit() for line in buf.split("\n"): @@ -128,7 +128,7 @@ def on_readable(self, fd): continue m = re.search(r"(\S+) (add|delete) (\d+.\d+.\d+.\d+) +(\S+)", line) if not m: - print "Could not match line:", line + print( "Could not match line:", line ) continue name = m.group(1) operation = m.group(2) @@ -148,7 +148,7 @@ def on_readable(self, fd): self.directFlowMgr_.flow_entry_del(name) def on_flow_status(self, name, status): - print "Flow", name, "status changed to", status + print( "Flow", name, "status changed to", status ) self.changes += 1 @@ -156,7 +156,7 @@ def main(args): sdk = eossdk.Sdk("DirectFlowProgrammer") programmer = DirectFlowProgrammer(sdk.get_agent_mgr(), sdk.get_directflow_mgr()) sdk.main_loop(sys.argv) - print "Saw %d flow status changes" % programmer.changes + print( "Saw %d flow status changes" % programmer.changes ) if __name__ == '__main__': diff --git a/examples/HamAgent.cpp b/examples/HamAgent.cpp deleted file mode 100644 index 3074371..0000000 --- a/examples/HamAgent.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2021 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#include -#include -#include -#include -#include -#include -#include -#include - -class ham_agent : public eos::agent_handler { - - public: - eos::tracer t; - eos::ham_mgr *ham_mgr_; - - explicit ham_agent(eos::sdk & sdk) - : eos::agent_handler(sdk.get_agent_mgr()), - t("HamAgent"), - ham_mgr_(sdk.get_ham_mgr()){ - t.trace0("Agent constructed"); - } - - void on_initialized(){ - t.enabled_is(eos::Level0, true); - t.trace0("Initialized"); - get_agent_mgr()->status_set("Ready_for_testing", "True"); - t.trace0("Set the status to ready for testing"); - } - - void on_agent_option(std::string const & option_name, - std::string const & value ){ - // Create ham using createFromAddress funciton call - // Create aham_address_t to pass in - auto aham_address = eos::aham_address_t(); - // Initialize aham_address to be passed to HAM constructor - // Initialize bus ID to 0 and address to 0x48 because those are - // the corresponding values for the temperature sensor we will be - // writing to/reading from - aham_address.bus_is( 1 ); - aham_address.accelerator_is( 0 ); - aham_address.address_is( 0x48 ); - // Initialize pci_address to be passed to HAM constructor - // Initialize all fields to 0 because we are testing on - // dropbear duts, which have all fields for pci addr as 0 - auto pci_address = eos::pci_address_t(); - pci_address.domain_is( 0 ); - pci_address.bus_is( 0 ); - pci_address.device_is( 0 ); - pci_address.function_is( 0 ); - auto eossdk_ham_from_address = eos::eossdk_ham_t( aham_address, pci_address ); - if(option_name == "test_write_and_read_8"){ - // Hardcode address at 0x03, which represents the address of the - // overtemperature sensor on a lm75 temperature sensor on a 7130, - // to write to/read from in the test - auto reg = eos::register_t() ; - reg.reg_is(0x03); - // Convert value to appropriate type to pass to write8 - uint8_t val = stoi(value); - ham_mgr_->write8(eossdk_ham_from_address,reg, val, true); - auto retVal = ham_mgr_->read8(eossdk_ham_from_address, reg); - uint8_t valueRead = retVal.result(); - t.trace0("Value read was: %d", valueRead); - assert(retVal.status() == eos::STATUS_OK); - assert (valueRead == val); - get_agent_mgr()->status_set("test_write_and_read_8", - "Value successfully written and read."); - } - else if(option_name == "test_write_and_read_16"){ - // Hardcode address to write to/read from into test - auto reg = eos::register_t() ; - reg.reg_is(0x03); - // Convert value to appropriate type to pass to write16 - uint16_t val = stoi(value); - ham_mgr_->write16(eossdk_ham_from_address, reg, val, true); - auto retVal = ham_mgr_->read16(eossdk_ham_from_address, reg); - uint16_t valueRead = retVal.result(); - t.trace0( "Value read was: %d", valueRead ); - assert(valueRead == val); - assert(retVal.status() == eos::STATUS_OK); - get_agent_mgr()->status_set("test_write_and_read_16", - "Value successfully written and read."); - } - } - -}; - -int main(int argc, char ** argv){ - eos::sdk sdk; - ham_agent agent(sdk); - sdk.main_loop(argc, argv); -} diff --git a/examples/HelloWorld.cpp b/examples/HelloWorld.cpp index 635aa64..50807b8 100644 --- a/examples/HelloWorld.cpp +++ b/examples/HelloWorld.cpp @@ -5,10 +5,10 @@ #include #include -// This simple agent says "hi" to a user when the user configures his -// or her name, and demonstrates how to use the various components of -// the SDK. To run this agent, first build this agent and copy the -// resulting binary to switch. Then, from the CLI, run: +// This simple agent says "hi" to a user when the user configures their +// name, and demonstrates how to use the various components of the SDK. +// To run this agent, first build this agent and copy the resulting +// binary to switch. Then, from the CLI, run: // switch# configure // switch(conf)# daemon HelloAgent diff --git a/examples/HelloWorld.py b/examples/HelloWorld.py index 708ef0e..af274b9 100755 --- a/examples/HelloWorld.py +++ b/examples/HelloWorld.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. diff --git a/examples/InotifyExample.py b/examples/InotifyExample.py index f6c20ca..1c62ab8 100755 --- a/examples/InotifyExample.py +++ b/examples/InotifyExample.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -41,16 +41,16 @@ def my_init(self, parent): # pylint: disable-msg=W0221 self.p = parent # pylint: disable-msg=W0201 def process_IN_MODIFY(self, event): - print "File changed" + print( "File changed" ) self.p.process_file() def process_IN_CREATE(self, event): - print "File created" + print( "File created" ) self.p.process_file() def process_IN_DELETE(self, event): # In this example, we don't take an action on file deletion. - print "File deleted" + print( "File deleted" ) class FileWatcher(eossdk_utils.EosSdkAgent, diff --git a/examples/InterfaceMonitor.py b/examples/InterfaceMonitor.py index 6d0492d..3a0b00d 100755 --- a/examples/InterfaceMonitor.py +++ b/examples/InterfaceMonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2016 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. diff --git a/examples/IntfIpAddrMergeExample.py b/examples/IntfIpAddrMergeExample.py index 42ecc2a..0544e0c 100644 --- a/examples/IntfIpAddrMergeExample.py +++ b/examples/IntfIpAddrMergeExample.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2019 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. diff --git a/examples/IpRouteBulkUpdater.py b/examples/IpRouteBulkUpdater.py index a7ea08d..10f83b3 100644 --- a/examples/IpRouteBulkUpdater.py +++ b/examples/IpRouteBulkUpdater.py @@ -2,7 +2,6 @@ # Copyright (c) 2019 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import eossdk import sys @@ -86,7 +85,7 @@ def on_timeout(self): self.handle_phase() def on_agent_option(self, name, value): - self.tracer.trace3("on_agent_option: key={}, value={}".format(name, value)) + self.tracer.trace3( f"on_agent_option: key={name}, value={value}" ) if name == "insert_vrf_routes": if value == "ip": self.insert_routes_vrf(0, INITIAL_ROUTES, "blue") @@ -117,7 +116,7 @@ def on_agent_option(self, name, value): self.timeout_time_is(eossdk.now() + 5) def handle_phase(self): - self.tracer.trace0("Starting phase {}".format(self.phase)) + self.tracer.trace0( f"Starting phase {self.phase}" ) if self.phase == 0: self.clear_routes() @@ -128,7 +127,7 @@ def handle_phase(self): elif self.phase == 2: self.re_insert_routes() - self.tracer.trace0("Finished phase {}".format(self.phase)) + self.tracer.trace0( f"Finished phase {self.phase}" ) self.phase += 1 def clear_routes(self): @@ -230,7 +229,7 @@ def insert_v6_routes(self, start, end, newApi): for i in range(start, end): first = (i / 65536) % 65536 second = i % 65536 - addrStr = "%04x:%04x::" % (first, second) + addrStr = f"{first:04x}:{second:04x}::" ip = eossdk.IpAddr(addrStr) prefix6 = eossdk.IpPrefix(ip, 64) rkey6 = eossdk.IpRouteKey(prefix6) @@ -280,7 +279,7 @@ def create_ip_route_key(self, i): def create_ip_v6_route_key(self, i): first = (i / 65536) % 65536 second = i % 65536 - addrStr = "%04x:%04x::" % (first, second) + addrStr = f"{first:04x}:{second:04x}::" ip = eossdk.IpAddr(addrStr) prefix6 = eossdk.IpPrefix(ip, 64) rkey6 = eossdk.IpRouteKey(prefix6) diff --git a/examples/MplsTunnelLivenessAgent.py b/examples/MplsTunnelLivenessAgent.py index 8c1df1a..67eecb5 100755 --- a/examples/MplsTunnelLivenessAgent.py +++ b/examples/MplsTunnelLivenessAgent.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. diff --git a/examples/PolicyRouter.py b/examples/PolicyRouter.py index 61d59ef..440837d 100755 --- a/examples/PolicyRouter.py +++ b/examples/PolicyRouter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -21,14 +21,12 @@ install that using the EOS extension manager. """ -from __future__ import absolute_import, division, print_function -import simplejson as json +import json import collections import datetime import functools import os import sys -import six import pyinotify @@ -66,7 +64,7 @@ class ConfigError(Error): 'nexthop_group', 'interface_policy')) -MANDATORY_CONFIG_SECTIONS = CONFIG_SECTIONS - set(['nexthop_group']) +MANDATORY_CONFIG_SECTIONS = CONFIG_SECTIONS - { 'nexthop_group' } # Configuration data structures Filter = collections.namedtuple( @@ -94,7 +92,7 @@ class ConfigError(Error): def load_match(d): acls = {} - for k, vs in sorted(six.iteritems(d)): + for k, vs in sorted( d.items() ): acls.setdefault(k, []) for v in vs: ace = Filter(src_ip=v.get('src_ip'), @@ -110,7 +108,7 @@ def load_match(d): def load_classifier(d): c = {} - for k, v in six.iteritems(d): + for k, v in d.items(): matches = [Match(type=None, acl_name=x.get('match')) for x in v] c[k] = Classifier(matches=matches) return c @@ -118,7 +116,7 @@ def load_classifier(d): def load_action(d): a = {} - for k, v in six.iteritems(d): + for k, v in d.items(): a[k] = Action(v.get('type'), nexthop_group=v.get('nexthop_group'), nexthops=v.get('nexthops'), @@ -128,21 +126,21 @@ def load_action(d): def load_policy(d): p = {} - for k, v in six.iteritems(d): + for k, v in d.items(): p[k] = Policy(**v) return p def load_apply(d): a = {} - for k, v in six.iteritems(d): + for k, v in d.items(): a[k] = Apply(policy=v) return a def load_nexthop_group(d): g = {} - for k, v in six.iteritems(d): + for k, v in d.items(): g[k] = NexthopGroup(type=v.get('type', 'ipinip'), src_intf=v.get('src_intf'), src_ips=v.get('src_ips', []), @@ -183,7 +181,7 @@ def load_config_file_obj(f): return None -class PolicyRouter(object): +class PolicyRouter: """The policy router state and context.""" def __init__(self, acl_mgr, agent_mgr, class_map_mgr, @@ -210,8 +208,8 @@ def config_is(self, value): self.buildPolicy() def _buildAcls(self): - for aclname, aclrules in six.iteritems(self.config.match): - key = eossdk.AclKey(aclname, eossdk.ACL_TYPE_IPV4) + for aclname, aclrules in self.config.match.items(): + key = eossdk.AclKey( aclname, eossdk.ACL_TYPE_IPV4 ) # todo support ipv6 also for i, rule in enumerate(aclrules): @@ -287,8 +285,8 @@ def _buildPortSpec(self, portspec): def _buildClassMaps(self): classifiers = self.config_.classifiers - for name, classifier in six.iteritems(classifiers): - key = eossdk.PolicyMapKey(name, eossdk.POLICY_FEATURE_PBR) + for name, classifier in classifiers.items(): + key = eossdk.PolicyMapKey( name, eossdk.POLICY_FEATURE_PBR ) class_map = eossdk.ClassMap(key) for rule_index, match in enumerate(classifier.matches): @@ -302,7 +300,7 @@ def _buildClassMaps(self): print( 'Set class map:', name, 'now with', len(cm.rules()), 'rules' ) def _buildActions(self): - for name, action in six.iteritems(self.config_.actions): + for name, action in self.config_.actions.items(): if action.type == 'drop': act = eossdk.PolicyMapAction(eossdk.POLICY_ACTION_DROP) elif action.type == 'nexthop_group' and action.nexthop_group: @@ -320,7 +318,7 @@ def _buildActions(self): def _buildNexthopGroups(self): groups = self.config_.nexthop_groups - for name, data in six.iteritems(groups): + for name, data in groups.items(): if data.type not in NEXTHOP_GROUP_TYPE: sys.stderr.write('Unknown nexthop group type="%s"' % data.type) continue @@ -347,7 +345,7 @@ def _buildNexthopGroups(self): def _buildPolicyMaps(self): policies = self.config_.policy - for name, data in six.iteritems(policies): + for name, data in policies.items(): # add the class map rule_key = eossdk.PolicyMapKey(data.classifier, eossdk.POLICY_FEATURE_PBR) @@ -364,8 +362,9 @@ def _buildPolicyMaps(self): def _applyToInterfaces(self): interface_policy = self.config_.interface_policy - for intf_name, data in six.iteritems(interface_policy): - policy_map_key = eossdk.PolicyMapKey(data.policy, eossdk.POLICY_FEATURE_PBR) + for intf_name, data in interface_policy.items(): + policy_map_key = eossdk.PolicyMapKey( data.policy, + eossdk.POLICY_FEATURE_PBR ) intf_id = eossdk.IntfId(intf_name) if self.intf_mgr.exists(intf_id): print( 'Interface %s exists, applying policy' % intf_id.to_string() ) @@ -540,7 +539,7 @@ def get_ip_addr(ip_addr): try: return eossdk.IpAddr(ip_addr) except eossdk.Error as e: - sys.stderr.write('Invalid IP address: %s (%s)' % (ip_addr, e)) + sys.stderr.write( f'Invalid IP address: {ip_addr} ({e})' ) def main(): diff --git a/examples/ReactorExample.py b/examples/ReactorExample.py index d683ab6..b2fc62b 100755 --- a/examples/ReactorExample.py +++ b/examples/ReactorExample.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -12,19 +12,19 @@ def __init__( self, intfMgr, agentMgr ): eossdk.IntfHandler.__init__( self, intfMgr ) # pylint: disable-msg=W0233 self.intfMgr_ = intfMgr self.numIntfChanges_ = 0 - print "Constructed" + print( "Constructed" ) # Callback provided by AgentHandler when all state is synchronized def on_initialized( self ): - print "We are initialized!" + print( "We are initialized!" ) self.watch_all_intfs( True ) # pylint: disable-msg=E1101 # Callback provided by IntfHandler when an interface's configuration changes def on_oper_status( self, intfId, operState ): intfState = 'up' if operState == eossdk.INTF_OPER_UP else 'down' - print "The state of", intfId.to_string(), "is now", intfState + print( "The state of", intfId.to_string(), "is now", intfState ) self.numIntfChanges_ += 1 - print " We have seen", self.numIntfChanges_, "state changes" + print( " We have seen", self.numIntfChanges_, "state changes" ) self.intfMgr_.description_is(intfId, "Changed state [%d]" % self.numIntfChanges_) diff --git a/examples/SimpleIntfAgent.py b/examples/SimpleIntfAgent.py index 097a6f8..e6c29c7 100755 --- a/examples/SimpleIntfAgent.py +++ b/examples/SimpleIntfAgent.py @@ -1,8 +1,7 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import sys import eossdk @@ -33,7 +32,7 @@ def on_readable(self, fd): print( "- Fd %d is readable" % fd ) curEnabledStatus = ("enabled" if self.intfMgr_.admin_enabled(self.intfObj_) else "disabled") - print( "- %s is currently %s" % (self.intfObj_.to_string(), curEnabledStatus) ) + print( f"- {self.intfObj_.to_string()} is currently {curEnabledStatus}" ) msg = sys.stdin.readline() if msg.startswith("shut"): print( "Shutting down %s" % self.intfObj_.to_string() ) diff --git a/examples/ThriftClient.cpp b/examples/ThriftClient.cpp index d2db846..8005402 100644 --- a/examples/ThriftClient.cpp +++ b/examples/ThriftClient.cpp @@ -16,6 +16,13 @@ using namespace apache::thrift::protocol; using namespace apache::thrift::transport; namespace po = boost::program_options; +#include "thriftconfig.h" +#ifdef HAVE_RECENT_THRIFT +using std::shared_ptr; +#else +using boost::shared_ptr; +#endif + using namespace eos; int main(int argc, char **argv) { @@ -43,9 +50,9 @@ int main(int argc, char **argv) { } po::notify(flags); - boost::shared_ptr socket(new TSocket(server, port)); - boost::shared_ptr transport(new TFramedTransport(socket)); - boost::shared_ptr protocol(new TBinaryProtocol(transport)); + shared_ptr socket(new TSocket(server, port)); + shared_ptr transport(new TFramedTransport(socket)); + shared_ptr protocol(new TBinaryProtocol(transport)); ThriftSdkClient client(protocol); transport->open(); diff --git a/examples/ThriftServer.cpp b/examples/ThriftServer.cpp index 54c1128..7dfb443 100644 --- a/examples/ThriftServer.cpp +++ b/examples/ThriftServer.cpp @@ -14,7 +14,13 @@ using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; +#include "thriftconfig.h" +#ifdef HAVE_RECENT_THRIFT +#include +using std::shared_ptr; +#else using boost::shared_ptr; +#endif using namespace eos; @@ -78,8 +84,14 @@ int main(int argc, char **argv) { event_base_holder base; libevent_loop loop(sdk, base.ptr()); shared_ptr processor(new ThriftSdkProcessor(handler)); +#ifdef HAVE_RECENT_THRIFT + shared_ptr socket; + socket.reset(new transport::TNonblockingServerSocket(port)); + TNonblockingServer server(processor, socket); +#else TNonblockingServer server(processor, port); +#endif loop.init(); server.registerEvents(base.ptr()); event_base_dispatch(base.ptr()); diff --git a/examples/XcvrMgr.py b/examples/XcvrMgr.py index b8f0ed4..b624d60 100644 --- a/examples/XcvrMgr.py +++ b/examples/XcvrMgr.py @@ -1,8 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import eossdk import argparse import sys @@ -47,7 +46,7 @@ def on_initialized( self ): print( " tx turnup: 0x%X" % self.xcvrMgr_.tx_turnup_state( intfId ) ) print( " rx turnup: 0x%X" % self.xcvrMgr_.rx_turnup_state( intfId ) ) if self.addr is not None: - print( " Addr: 0x%X Data: 0x%X" % ( + print( " Addr: 0x{:X} Data: 0x{:X}".format( self.addr, self.xcvrMgr_.register_read( intfId, self.addr ) ) ) self.agentMgr_.exit() diff --git a/examples/eossdk_utils.py b/examples/eossdk_utils.py index 9a62cb9..3449d7b 100644 --- a/examples/eossdk_utils.py +++ b/examples/eossdk_utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. @@ -34,7 +34,7 @@ def debug_fn(func): @wraps(func) def wrapped_fn(*args, **kwargs): try: - func(*args, **kwargs) + return func(*args, **kwargs) except Exception as e: traceback.print_exc() if sys.stdout.isatty(): diff --git a/examples/test/EosSdkGenericTestLib.py b/examples/test/EosSdkGenericTestLib.py index a14b5bc..a277905 100644 --- a/examples/test/EosSdkGenericTestLib.py +++ b/examples/test/EosSdkGenericTestLib.py @@ -1,9 +1,7 @@ # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import jsonrpclib -import socket import time import sys @@ -75,8 +73,8 @@ def __init__(self, msg): Error.__init__(self, msg) -class TestLib(object): - def __init__(self, host_name, user_name, password, port=None, is_secure=False): +class TestLib: + def __init__( self, host_name, user_name, password, port=None, is_secure=False ): """ Establish the eAPI session. host_name: the host name or ip address of the switch against which the @@ -102,8 +100,9 @@ def setupEapi(self): # setup the eApi connection proto = SERVER_PROTOCOL_HTTPS if self.is_secure_ else SERVER_PROTOCOL_HTTP port_string = self.port_ if self.port_ else '' - url = "%s://%s:%s@%s%s/command-api" % (proto, self.user_name_, self.password_, - self.host_name_, port_string) + url = "{}://{}:{}@{}{}/command-api".format( proto, + self.user_name_, self.password_, + self.host_name_, port_string ) self.history_ = jsonrpclib.history.History() self.eapi_ = jsonrpclib.Server(url, history=self.history_) @@ -138,8 +137,8 @@ def run_cmds(self, cmds, data_format=JSON): try: response_list = self.eapi_.runCmds(1, cmds, data_format) - except socket.error as e: - raise ConnectionError(e.strerror) + except OSError as e: + raise ConnectionError( e.strerror ) except jsonrpclib.jsonrpc.TransportError as e: raise ProtocolError(e.errcode, e.errmsg, str(e.msg)) except jsonrpclib.jsonrpc.ProtocolError: @@ -155,7 +154,7 @@ def run_cmds(self, cmds, data_format=JSON): return response_list -class AgentLib(object): +class AgentLib: def __init__(self, test_lib, agent_name, agent_binary_path, args=None): """ This class handles all functions needed for an agent. @@ -190,10 +189,10 @@ def start_agent(self): won't be started. Once started, the agent is running as a daemon on switch. """ - cmds = ["enable", "configure terminal", - "daemon %s" % self.agent_name, - "exec %s %s" % (self.agent_binary_path, self.args), - "no shutdown"] + cmds = [ "enable", "configure terminal", + "daemon %s" % self.agent_name, + f"exec {self.agent_binary_path} {self.args}", + "no shutdown" ] self.test_lib.run_cmds( cmds ) wait_for(self.agent_running, "agent running", timeout=600) @@ -214,11 +213,11 @@ def remove_agent(self): def agent_option_is(self, key, value): """ Configures an option/value pair for this agent by issuing 'option opt value val' command.""" - self.test_lib.run_cmds(["enable", "configure terminal", - "daemon %s" % self.agent_name, - "option %s value %s" % (key, value)]) + self.test_lib.run_cmds( [ "enable", "configure terminal", + "daemon %s" % self.agent_name, + f"option {key} value {value}" ] ) - def agent_option_del(self, key): + def agent_option_del( self, key ): """ Removes an option/value pair from this daemon's configuration. """ self.test_lib.run_cmds(["enable", "configure terminal", "daemon %s" % self.agent_name, @@ -294,11 +293,11 @@ def wait_for_status(self, key, expected_value): def get_status(): data = self.agent_data() return expected_value == data['data'][key] - wait_for(get_status, - "status '%s' to be '%s'" % (key, expected_value), - timeout=600) + wait_for( get_status, + f"status '{key}' to be '{expected_value}'", + timeout=600 ) - def wait_for(self, func, description, timeout=300.0): + def wait_for( self, func, description, timeout=300.0 ): """ The jump from EosSdkGenericTestLib.AgentLib.wait_for to EosSdkGenericTestLib.wait_for is kept for legacy reasons in case some customers were relying on it. diff --git a/examples/test/FibTestAgent.py b/examples/test/FibTestAgent.py index 43272d2..193fea3 100644 --- a/examples/test/FibTestAgent.py +++ b/examples/test/FibTestAgent.py @@ -1,11 +1,10 @@ # Copyright (c) 2020 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import EosSdkGenericTestLib -class FibTestAgent( object ): +class FibTestAgent: def __init__( self, test_lib, switch_ip, intf, intf_ip, intf2, intf2_ip, agent_name, agent_binary_path, args=None ): diff --git a/examples/test/HardwareTableTest.py b/examples/test/HardwareTableTest.py index aabc400..158aeb9 100644 --- a/examples/test/HardwareTableTest.py +++ b/examples/test/HardwareTableTest.py @@ -1,7 +1,6 @@ # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import argparse import EosSdkGenericTestLib from EosSdkGenericTestLib import AgentLib @@ -11,8 +10,8 @@ # run this test script. -class HardwareTableTest(object): - def __init__(self, test_lib, agent_name, agent_binary_path, args=None): +class HardwareTableTest: + def __init__( self, test_lib, agent_name, agent_binary_path, args=None ): self.test_lib = test_lib self.agent_name = agent_name self.agent_binary_path = agent_binary_path diff --git a/examples/test/HelloWorldTest.py b/examples/test/HelloWorldTest.py index 70af1ae..c06178a 100644 --- a/examples/test/HelloWorldTest.py +++ b/examples/test/HelloWorldTest.py @@ -1,8 +1,7 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import argparse import EosSdkGenericTestLib from EosSdkGenericTestLib import AgentLib @@ -14,8 +13,8 @@ # run this test script. -class HelloWorldTest(object): - def __init__(self, test_lib, agent_name, agent_binary_path, args=None): +class HelloWorldTest: + def __init__( self, test_lib, agent_name, agent_binary_path, args=None ): self.test_lib = test_lib self.agent_name = agent_name self.agent_binary_path = agent_binary_path diff --git a/examples/test/InterfaceMonitorTest.py b/examples/test/InterfaceMonitorTest.py index 99dd514..e8405a8 100644 --- a/examples/test/InterfaceMonitorTest.py +++ b/examples/test/InterfaceMonitorTest.py @@ -1,14 +1,12 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2016 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import EosSdkGenericTestLib -import six -class InterfaceMonitorTest(object): - def __init__(self, test_lib, agent_name, sintfs, agent_binary_path, args=None): +class InterfaceMonitorTest: + def __init__( self, test_lib, agent_name, sintfs, agent_binary_path, args=None ): self.test_lib = test_lib self.agent_name = agent_name self.agent_binary_path = agent_binary_path @@ -21,8 +19,8 @@ def find_connected_interface(self): # to receive two "on_oper_status" notifications. Otherwise 1 is returned. response = self.test_lib.run_cmds(["show interfaces status"])[0] - for intf, status in six.iteritems( response[ "interfaceStatuses" ] ): - if status["linkStatus"] == 'connected' and "Ma" not in intf: + for intf, status in response[ "interfaceStatuses" ].items(): + if status[ "linkStatus" ] == 'connected' and "Ma" not in intf: if intf in self.sintfs: return intf, 2 else: diff --git a/examples/test/VrfTest.py b/examples/test/VrfTest.py index c96c034..ddc5e22 100644 --- a/examples/test/VrfTest.py +++ b/examples/test/VrfTest.py @@ -1,8 +1,7 @@ -#!/usr/bin/env pychooser +#!/usr/bin/env python3 # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. # Arista Networks, Inc. Confidential and Proprietary. -from __future__ import absolute_import, division, print_function import argparse import socket @@ -20,7 +19,7 @@ VRF_BLUE = 'vrfBlue' -class VrfTest(object): +class VrfTest: def __init__(self, test_lib, switch_ip, intf, intf_ip, agent_name, agent_binary_path, args=None): self.switch_ip = switch_ip diff --git a/fpga.cpp b/fpga.cpp deleted file mode 100644 index 2570276..0000000 --- a/fpga.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#include "eos/fpga.h" -#include "impl.h" - -namespace eos { - -fpga_handler::fpga_handler(fpga_mgr * mgr) : - base_handler(mgr) { -} - -void -fpga_handler::watch_all_fpga_reservation_status(bool) { -} - -void -fpga_handler::watch_fpga_reservation_status(const std::string &, bool) { -} - -void -fpga_handler::on_fpga_reservation_status_set(std::string id) { -} - -void -fpga_handler::on_fpga_reservation_status_del(std::string id) { -} - -class fpga_mgr_impl : public fpga_mgr { - public: - fpga_mgr_impl() { - } - - fpga_iter_t fpga_status_iter() const { - fpga_iter_t * nop = 0; - return *nop; - } - - fpga_t fpga(const std::string&) const { - fpga_t * nop = 0; - return *nop; - } - - fpga_reservation_iter_t reservation_iter() const { - fpga_reservation_iter_t * nop = 0; - return *nop; - } - - fpga_reservation_status_iter_t reservation_status_iter() const { - fpga_reservation_status_iter_t * nop = 0; - return *nop; - } - - bool reservation_exists(const std::string&) const { - return false; - } - - bool reservation_status_exists(const std::string&) const { - return false; - } - - fpga_reservation_t reservation(const std::string&) const { - fpga_reservation_t * nop = 0; - return *nop; - } - - fpga_reservation_status_t reservation_status(const std::string&) const { - fpga_reservation_status_t * nop = 0; - return *nop; - } - - void reservation_set(const fpga_reservation_t&) { - } - - void reservation_del(const std::string&) { - } - - eossdk_ham_t ham(const fpga_t&, size_t) const { - eossdk_ham_t * nop = 0; - return *nop; - } -}; - -DEFINE_STUB_MGR_CTOR(fpga_mgr) - -} // end namespace eos diff --git a/ham.cpp b/ham.cpp deleted file mode 100644 index ab1b0da..0000000 --- a/ham.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#include "eos/ham.h" -#include "impl.h" - -namespace eos{ - -ham_handler::ham_handler( ham_mgr * mgr ) : base_handler< ham_mgr, ham_handler >( - mgr ){ -} - -class ham_mgr_impl : public ham_mgr { - public: - ham_mgr_impl(){ - } - - read8_result_t read8( eossdk_ham_t ham, register_t reg ){ - read8_result_t * nop = 0; - return *nop; - } - - read16_result_t read16( eossdk_ham_t ham, register_t reg ){ - read16_result_t * nop = 0; - return *nop; - } - - read_result_t read32( eossdk_ham_t ham, register_t reg ){ - read_result_t * nop = 0; - return *nop; - } - - read_result_t read( eossdk_ham_t ham, register_t reg, size_t size ){ - read_result_t * nop = 0; - return *nop; - } - - read_result_t readBlock( eossdk_ham_t ham, register_t reg ){ - read_result_t * nop = 0; - return *nop; - } - - response_enum_t write8( eossdk_ham_t ham, register_t reg, uint8_t data, - bool reliable = false ){ - response_enum_t * nop = 0; - return *nop; - } - - response_enum_t write16( eossdk_ham_t ham, register_t reg, uint16_t data, - bool reliable = false ){ - response_enum_t * nop = 0; - return *nop; - } - - response_enum_t write32( eossdk_ham_t ham, register_t reg, uint32_t data, - bool reliable = false ){ - response_enum_t * nop = 0; - return *nop; - } - - response_enum_t write( eossdk_ham_t ham, register_t reg, - std::string const & data, bool reliable = false ){ - response_enum_t * nop = 0; - return *nop; - } - - response_enum_t writeBlock( eossdk_ham_t ham, register_t reg, - std::string const & data, bool reliable = false ){ - response_enum_t * nop = 0; - return *nop; - } - -}; - -DEFINE_STUB_MGR_CTOR( ham_mgr ) - -} // end namespace eos diff --git a/iterator.cpp b/iterator.cpp index 4c328b3..fe72d54 100644 --- a/iterator.cpp +++ b/iterator.cpp @@ -12,12 +12,10 @@ #include "eos/eth_lag_intf.h" #include "eos/eth_phy_intf.h" #include "eos/fib.h" -#include "eos/fpga.h" #include "eos/hardware_table.h" #include "eos/intf.h" #include "eos/ip_route.h" #include "eos/iterator.h" -#include "eos/l1_source.h" #include "eos/macsec.h" #include "eos/mac_table.h" #include "eos/mpls_route.h" @@ -122,9 +120,6 @@ INSTANTIATE_ITERATOR(decap_group_t, decap_group_iter_impl); INSTANTIATE_ITERATOR(fib_fec_t, fib_fec_iter_impl); INSTANTIATE_ITERATOR(fib_route_t, fib_route_iter_impl); INSTANTIATE_ITERATOR(flow_entry_t, flow_entry_iter_impl); -INSTANTIATE_ITERATOR(fpga_t, fpga_iter_impl); -INSTANTIATE_ITERATOR(fpga_reservation_t, fpga_reservation_iter_impl); -INSTANTIATE_ITERATOR(fpga_reservation_status_t, fpga_reservation_status_iter_impl); INSTANTIATE_ITERATOR(hardware_table_key_t, hardware_table_iter_impl); INSTANTIATE_ITERATOR(intf_id_t, intf_iter_impl); INSTANTIATE_ITERATOR(intf_id_t, eth_intf_iter_impl); @@ -133,7 +128,6 @@ INSTANTIATE_ITERATOR(intf_id_t, eth_lag_intf_member_iter_impl); INSTANTIATE_ITERATOR(intf_id_t, eth_phy_intf_iter_impl); INSTANTIATE_ITERATOR(ip_route_t, ip_route_iter_impl); INSTANTIATE_ITERATOR(ip_route_via_t, ip_route_via_iter_impl); -INSTANTIATE_ITERATOR(intf_id_t, l1_source_iter_impl); INSTANTIATE_ITERATOR(mac_key_t, mac_table_iter_impl); INSTANTIATE_ITERATOR(mac_key_t, mac_table_status_iter_impl); INSTANTIATE_ITERATOR(mpls_route_t, mpls_route_iter_impl); diff --git a/l1_source.cpp b/l1_source.cpp deleted file mode 100644 index d71427d..0000000 --- a/l1_source.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2020 Arista Networks, Inc. All rights reserved. -// Arista Networks, Inc. Confidential and Proprietary. - -#include "eos/l1_source.h" -#include "impl.h" - -namespace eos { - -l1_source_handler::l1_source_handler(l1_source_mgr * mgr) : - base_handler(mgr) { -} - -void -l1_source_handler::watch_all_l1_source(bool interest) { -} - -void -l1_source_handler::watch_l1_source(intf_id_t intf_id, bool interest) { -} - -void -l1_source_handler::on_l1_source_set(intf_id_t intf_id) { -} - -void -l1_source_handler::on_l1_source_del(intf_id_t intf_id) { -} - -class l1_source_mgr_impl : public l1_source_mgr { - public: - l1_source_mgr_impl() { - } - - void l1_source_is(intf_id_t intf_id, l1_source_t source) { - } - - void l1_source_del(intf_id_t intf_id) { - } - - bool exists(intf_id_t) const { - return false; - } - - l1_source_t l1_source_config(intf_id_t intf_id) { - l1_source_t * nop = 0; - return *nop; - } - - l1_source_t l1_source_status(intf_id_t intf_id) { - l1_source_t * nop = 0; - return *nop; - } - - l1_source_iter_t l1_source_config_iter() const { - l1_source_iter_t * nop = 0; - return *nop; - } - - l1_source_iter_t l1_source_status_iter() const { - l1_source_iter_t * nop = 0; - return *nop; - } - - void app_description_is(intf_id_t intf_id, std::string description) { - } - - void app_description_del(intf_id_t intf_id) { - } -}; - -DEFINE_STUB_MGR_CTOR(l1_source_mgr) - -} // end namespace eos diff --git a/nexthop_group.cpp b/nexthop_group.cpp index f97cb28..bb68d5d 100644 --- a/nexthop_group.cpp +++ b/nexthop_group.cpp @@ -63,6 +63,11 @@ class nexthop_group_mgr_impl : public nexthop_group_mgr { return nexthop_group_t(); } + nexthop_group_counter_state_t get_nexthop_group_counter_state( + std::string const & nexthop_group_name) const { + return NEXTHOP_GROUP_COUNTER_INACTIVE; + } + }; DEFINE_STUB_MGR_CTOR(nexthop_group_mgr); @@ -103,4 +108,13 @@ nexthop_group_handler_v2::on_nexthop_group_programmed(std::string const & group_ // TODO: No op impl. } +nexthop_group_handler_v3::nexthop_group_handler_v3(nexthop_group_mgr * mgr) : + nexthop_group_handler(mgr) { +} + +void +nexthop_group_handler_v3::on_nexthop_group_programmed(std::string const & group_name, + uint16_t version_id, nexthop_group_programmed_status_t const & status) { + // TODO: No op impl. +} } diff --git a/policy_map.cpp b/policy_map.cpp index 0a6c2e9..1b10f2b 100644 --- a/policy_map.cpp +++ b/policy_map.cpp @@ -61,6 +61,13 @@ policy_map_handler::on_policy_map_config_set(policy_map_key_t const & name) { // TODO: no op impl. } +#if TRAFFIC_POLICY_ENABLED +void +policy_map_handler::on_traffic_policy_config_set( policy_map_key_t const & name ) { + // TODO: no op impl. +} +#endif + class policy_map_mgr_impl : public policy_map_mgr { public: policy_map_mgr_impl() { @@ -76,6 +83,12 @@ class policy_map_mgr_impl : public policy_map_mgr { return false; } + #if TRAFFIC_POLICY_ENABLED + bool traffic_policy_exists(std::string const & key) const { + return false; + } + #endif + policy_map_t policy_map(policy_map_key_t const & key) const { return policy_map_t(); } @@ -86,15 +99,40 @@ class policy_map_mgr_impl : public policy_map_mgr { void policy_map_del(policy_map_key_t const & key) { } + #if TRAFFIC_POLICY_ENABLED + traffic_policy_t traffic_policy(std::string const & tpName) const { + return traffic_policy_t(""); + } + + void traffic_policy_is(traffic_policy_t const & tp) { + } + + void traffic_policy_del(std::string const & tpName) { + } + #endif + policy_map_iter_t policy_map_iter(policy_feature_t) const { policy_map_iter_t * nop = 0; return *nop; } + #if TRAFFIC_POLICY_ENABLED + policy_map_iter_t traffic_policy_iter() const { + policy_map_iter_t * nop = 0; + return *nop; + } + #endif + void policy_map_apply(policy_map_key_t const &, intf_id_t, acl_direction_t, bool apply) { } + #if TRAFFIC_POLICY_ENABLED + void traffic_policy_apply(std::string const &, intf_id_t, + traffic_policy_direction_t, bool apply) { + } + #endif + policy_map_hw_status_iter_t policy_map_hw_status_iter(policy_feature_t) const { policy_map_hw_status_iter_t *nop = 0; return *nop; diff --git a/sdk.cpp b/sdk.cpp index e834830..37c92f7 100644 --- a/sdk.cpp +++ b/sdk.cpp @@ -32,12 +32,10 @@ #include "eos/eth_lag_intf.h" #include "eos/eth_phy_intf.h" #include "eos/fib.h" -#include "eos/fpga.h" #include "eos/hardware_table.h" #include "eos/intf.h" #include "eos/ip.h" #include "eos/ip_route.h" -#include "eos/l1_source.h" #include "eos/lldp.h" #include "eos/macsec.h" #include "eos/mac_table.h" @@ -52,10 +50,10 @@ #include "eos/route_map.h" #include "eos/subintf.h" #include "eos/vrf.h" -#include "eos/ham.h" #include "eos/types/sdk.h" #include "eos/types/acl.h" +#include "eos/types/structured_filter.h" #include "eos/types/aresolve.h" #include "eos/types/bfd.h" #include "eos/types/bgp.h" @@ -69,12 +67,10 @@ #include "eos/types/eth_lag_intf.h" #include "eos/types/eth_phy_intf.h" #include "eos/types/fib.h" -#include "eos/types/fpga.h" #include "eos/types/hardware_table.h" #include "eos/types/intf.h" #include "eos/types/ip.h" #include "eos/types/ip_route.h" -#include "eos/types/l1_source.h" #include "eos/types/lldp.h" #include "eos/types/macsec.h" #include "eos/types/mac_table.h" @@ -89,9 +85,9 @@ #include "eos/types/route_map.h" #include "eos/types/subintf.h" #include "eos/types/vrf.h" -#include "eos/types/ham.h" #include "eos/types/acl_impl.h" +#include "eos/types/structured_filter_impl.h" #include "eos/types/aresolve_impl.h" #include "eos/types/bfd_impl.h" #include "eos/types/bgp_impl.h" @@ -105,12 +101,10 @@ #include "eos/types/eth_lag_intf_impl.h" #include "eos/types/eth_phy_intf_impl.h" #include "eos/types/fib_impl.h" -#include "eos/types/fpga_impl.h" #include "eos/types/hardware_table_impl.h" #include "eos/types/intf_impl.h" #include "eos/types/ip_impl.h" #include "eos/types/ip_route_impl.h" -#include "eos/types/l1_source_impl.h" #include "eos/types/lldp_impl.h" #include "eos/types/macsec_impl.h" #include "eos/types/mac_table_impl.h" @@ -125,9 +119,9 @@ #include "eos/types/route_map_impl.h" #include "eos/types/subintf_impl.h" #include "eos/types/vrf_impl.h" -#include "eos/types/ham_impl.h" #include "eos/inline/types/acl_impl.h" +#include "eos/inline/types/structured_filter_impl.h" #include "eos/inline/types/aresolve_impl.h" #include "eos/inline/types/bfd_impl.h" #include "eos/inline/types/bgp_impl.h" @@ -141,12 +135,10 @@ #include "eos/inline/types/eth_lag_intf_impl.h" #include "eos/inline/types/eth_phy_intf_impl.h" #include "eos/inline/types/fib_impl.h" -#include "eos/inline/types/fpga_impl.h" #include "eos/inline/types/hardware_table_impl.h" #include "eos/inline/types/intf_impl.h" #include "eos/inline/types/ip_impl.h" #include "eos/inline/types/ip_route_impl.h" -#include "eos/inline/types/l1_source_impl.h" #include "eos/inline/types/lldp_impl.h" #include "eos/inline/types/macsec_impl.h" #include "eos/inline/types/mac_table_impl.h" @@ -161,10 +153,10 @@ #include "eos/inline/types/route_map_impl.h" #include "eos/inline/types/subintf_impl.h" #include "eos/inline/types/vrf_impl.h" -#include "eos/inline/types/ham_impl.h" #include "eos/inline/types/sdk.h" #include "eos/inline/types/acl.h" +#include "eos/inline/types/structured_filter.h" #include "eos/inline/types/aresolve.h" #include "eos/inline/types/bfd.h" #include "eos/inline/types/bgp.h" @@ -178,12 +170,10 @@ #include "eos/inline/types/eth_lag_intf.h" #include "eos/inline/types/eth_phy_intf.h" #include "eos/inline/types/fib.h" -#include "eos/inline/types/fpga.h" #include "eos/inline/types/hardware_table.h" #include "eos/inline/types/intf.h" #include "eos/inline/types/ip.h" #include "eos/inline/types/ip_route.h" -#include "eos/inline/types/l1_source.h" #include "eos/inline/types/lldp.h" #include "eos/inline/types/macsec.h" #include "eos/inline/types/mac_table.h" @@ -198,7 +188,6 @@ #include "eos/inline/types/route_map.h" #include "eos/inline/types/subintf.h" #include "eos/inline/types/vrf.h" -#include "eos/inline/types/ham.h" namespace eos { @@ -294,14 +283,6 @@ fib_mgr * sdk::get_fib_mgr(mgr_mode_type_t mode) { return sdkImpl->get_fib_mgr(mode); } -fpga_mgr * sdk::get_fpga_mgr() { - return sdkImpl->get_fpga_mgr(); -} - -ham_mgr * sdk::get_ham_mgr() { - return sdkImpl->get_ham_mgr(); -} - hardware_table_mgr * sdk::get_hardware_table_mgr() { return sdkImpl->get_hardware_table_mgr(); } @@ -328,10 +309,6 @@ intf_mgr_helper * sdk::get_intf_mgr_helper() { } #endif -l1_source_mgr * sdk::get_l1_source_mgr() { - return sdkImpl->get_l1_source_mgr(); -} - xcvr_mgr * sdk::get_xcvr_mgr() { return sdkImpl->get_xcvr_mgr(); } diff --git a/swig.patch b/swig.patch index 9bbca67..c9a9223 100644 --- a/swig.patch +++ b/swig.patch @@ -35,3 +35,12 @@ // Access iterator method, required by Python virtual PyObject *value() const = 0; +@@ -11477,7 +11477,7 @@ SWIGINTERN PyObject *_wrap__BitSet4096__ + try { + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; +- result = (bool)((std::bitset< 4096 > const *)arg1)->operator !=((std::bitset< 4096 > const &)*arg2); ++ result = !(bool)((std::bitset< 4096 > const *)arg1)->operator ==((std::bitset< 4096 > const &)*arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + } catch (error const & e) { diff --git a/version.m4 b/version.m4 index 29e6036..a42304c 100644 --- a/version.m4 +++ b/version.m4 @@ -1,2 +1,2 @@ m4_define([_NAME_],[EosSdk]) -m4_define([_VERSION_],[2.22.3]) \ No newline at end of file +m4_define([_VERSION_],[2.22.4]) \ No newline at end of file