├── version.m4 ├── bootstrap ├── eos ├── eth.h ├── inline │ ├── fib.h │ ├── sdk.h │ ├── types │ │ ├── sdk_impl.h │ │ ├── mlag_impl.h │ │ ├── eth_intf_impl.h │ │ ├── aresolve_impl.h │ │ ├── eth_impl.h │ │ ├── mpls_impl.h │ │ ├── sdk.h │ │ ├── mlag.h │ │ ├── eapi.h │ │ ├── eth_intf.h │ │ ├── subintf.h │ │ ├── mpls_vrf_label.h │ │ ├── vrf.h │ │ ├── subintf_impl.h │ │ ├── vrf_impl.h │ │ ├── decap_group.h │ │ ├── eapi_impl.h │ │ ├── mpls_vrf_label_impl.h │ │ ├── nexthop_group_tunnel.h │ │ ├── bgp.h │ │ ├── bgp_impl.h │ │ └── class_map.h │ ├── event_loop.h │ ├── lldp.h │ ├── mlag.h │ ├── vrf.h │ ├── agent.h │ ├── bgp.h │ ├── macsec.h │ ├── neighbor_table.h │ ├── system.h │ ├── acl.h │ ├── ip_intf.h │ ├── mac_table.h │ ├── aresolve.h │ ├── eth_intf.h │ ├── intf.h │ ├── utility.h │ ├── bfd.h │ ├── bgp_path.h │ ├── eth_lag_intf.h │ ├── policy_map.h │ ├── mpls_route.h │ ├── eth_phy_intf.h │ ├── nexthop_group.h │ ├── hardware_table.h │ ├── directflow.h │ ├── nexthop_group_tunnel.h │ ├── iterator.h │ ├── hash_mix.h │ └── exception.h ├── types │ ├── mlag_impl.h │ ├── eth_intf_impl.h │ ├── sdk_impl.h │ ├── mpls_impl.h │ ├── aresolve_impl.h │ ├── eth_impl.h │ ├── mlag.h │ ├── sdk.h │ ├── eth_intf.h │ ├── vrf_impl.h │ ├── subintf_impl.h │ ├── mpls_vrf_label_impl.h │ ├── eapi_impl.h │ ├── bgp_impl.h │ ├── subintf.h │ ├── ip_impl.h │ ├── mpls_vrf_label.h │ ├── eapi.h │ ├── decap_group_impl.h │ └── vrf.h ├── utility.h ├── base_handler.h ├── mpls.h ├── mlag.h ├── hash_mix.h ├── iterator.h ├── base.h ├── panic.h ├── version.h ├── eapi.h ├── timer.h ├── route_map.h └── bgp.h ├── examples ├── MplsTunnelLivenessConfig.json ├── EosThrift.thrift ├── libevent.h ├── ReactorExample.py ├── InternalVlan.cpp ├── example_base.cpp ├── libevent.cpp ├── HelloWorld.py ├── MplsLivenessExample.cpp ├── BgpAgent.cpp ├── SimpleBfdAgent.py ├── ThriftClient.cpp ├── eossdk_utils.py ├── MultiThreadedExample.cpp ├── SimpleIntfAgent.py ├── InterfaceMonitor.py ├── CliPlugin │ └── CustomMoveAccessInterfaceCli.py └── MplsNexthopGroups.cpp ├── ip.cpp ├── ltmain.patch ├── policy_map_types.cpp ├── swig-go.patch ├── aresolve_types.cpp ├── .travis.yml ├── SwigRenamer.py ├── mpls.cpp ├── eapi.cpp ├── mlag.cpp ├── README ├── class_map.cpp ├── version.cpp ├── aresolve.cpp ├── fd.cpp ├── intf_types.cpp ├── bgp.cpp ├── mpls_vrf_label.cpp ├── event_loop.cpp ├── timer.cpp ├── vrf.cpp ├── subintf.cpp ├── system.cpp ├── decap_group.cpp ├── panic.cpp ├── vrf_gen.cpp ├── mount_profile_eossdk_all ├── nexthop_group_tunnel.cpp ├── subintf_gen.cpp ├── LICENSE ├── ip_gen.cpp ├── route_map.cpp ├── swig.patch ├── bgp_gen.cpp ├── mpls_vrf_label_gen.cpp ├── directflow.cpp ├── neighbor_table.cpp ├── xcvr.cpp ├── decap_group_gen.cpp ├── eapi_gen.cpp ├── bgp_path.cpp ├── hardware_table.cpp ├── eth_types.cpp ├── ip_intf.cpp ├── nexthop_group_tunnel_gen.cpp ├── mac_table.cpp ├── tracing.cpp ├── exception.cpp ├── eth_intf.cpp ├── README.md ├── macsec.cpp └── eth_phy_intf.cpp /version.m4: -------------------------------------------------------------------------------- 1 | m4_define([_NAME_],[EosSdk]) 2 | m4_define([_VERSION_],[2.23.4]) -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | autoreconf --install --verbose -Wall -Wno-portability 5 | patch -f -p0 < ltmain.patch 6 | -------------------------------------------------------------------------------- /eos/eth.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_ETH_H 5 | #define EOS_ETH_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | } 12 | 13 | #endif // EOS_ETH_H 14 | -------------------------------------------------------------------------------- /eos/inline/fib.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_FIB_H 5 | #define INLINE_FIB_H 6 | 7 | inline fib_mgr * fib_handler::get_fib_mgr() const { 8 | return mgr_; 9 | } 10 | 11 | #endif // INLINE_FIB_H 12 | 13 | -------------------------------------------------------------------------------- /eos/types/mlag_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_MLAG_IMPL_H 5 | #define EOS_TYPES_MLAG_IMPL_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | } 11 | 12 | #endif // EOS_TYPES_MLAG_IMPL_H 13 | -------------------------------------------------------------------------------- /eos/types/eth_intf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_ETH_INTF_IMPL_H 5 | #define EOS_TYPES_ETH_INTF_IMPL_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | } 11 | 12 | #endif // EOS_TYPES_ETH_INTF_IMPL_H 13 | -------------------------------------------------------------------------------- /examples/MplsTunnelLivenessConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_intf": "Loopback1", 3 | "remote_switches": [ 4 | { 5 | "destination_ip": "20.0.0.2", 6 | "tunnels": { 7 | "4": {"nexthop_ip": "10.0.0.4", "label": 200}, 8 | "6": {"nexthop_ip": "10.0.0.6", "label": 200} 9 | } 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /eos/inline/sdk.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_SDK_H 5 | #define EOS_INLINE_SDK_H 6 | 7 | #include 8 | #include 9 | 10 | namespace eos { 11 | 12 | 13 | 14 | } 15 | 16 | #endif // EOS_INLINE_SDK_H 17 | -------------------------------------------------------------------------------- /eos/types/sdk_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_SDK_IMPL_H 5 | #define EOS_TYPES_SDK_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace eos { 12 | } 13 | 14 | #endif // EOS_TYPES_SDK_IMPL_H 15 | -------------------------------------------------------------------------------- /eos/inline/types/sdk_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_SDK_IMPL_H 5 | #define EOS_INLINE_TYPES_SDK_IMPL_H 6 | 7 | namespace eos { 8 | 9 | 10 | } 11 | 12 | #include 13 | 14 | #endif // EOS_INLINE_TYPES_SDK_IMPL_H 15 | -------------------------------------------------------------------------------- /eos/inline/event_loop.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_EVENT_LOOP_H 5 | #define EOS_INLINE_EVENT_LOOP_H 6 | 7 | namespace eos { 8 | 9 | inline event_loop_handler::~event_loop_handler() { 10 | } 11 | 12 | } 13 | 14 | #endif // EOS_INLINE_EVENT_LOOP_H 15 | -------------------------------------------------------------------------------- /eos/inline/lldp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_LLDP_H 5 | #define EOS_INLINE_LLDP_H 6 | 7 | namespace eos { 8 | 9 | inline lldp_mgr * lldp_handler::get_lldp_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_LLDP_H 16 | -------------------------------------------------------------------------------- /eos/inline/mlag.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_MLAG_H 5 | #define EOS_INLINE_MLAG_H 6 | 7 | namespace eos { 8 | 9 | inline mlag_mgr * mlag_handler::get_mlag_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_MLAG_H 16 | -------------------------------------------------------------------------------- /eos/inline/types/mlag_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_MLAG_IMPL_H 5 | #define EOS_INLINE_TYPES_MLAG_IMPL_H 6 | 7 | namespace eos { 8 | 9 | 10 | } 11 | 12 | #include 13 | 14 | #endif // EOS_INLINE_TYPES_MLAG_IMPL_H 15 | -------------------------------------------------------------------------------- /eos/inline/vrf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_VRF_H 5 | #define INLINE_VRF_H 6 | 7 | namespace eos { 8 | 9 | inline vrf_mgr *vrf_handler::get_vrf_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // end namespace eos 14 | 15 | #endif // INLINE_VRF_H 16 | -------------------------------------------------------------------------------- /eos/inline/agent.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_AGENT_H 5 | #define EOS_INLINE_AGENT_H 6 | 7 | namespace eos { 8 | 9 | inline agent_mgr * agent_handler::get_agent_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_AGENT_H 16 | -------------------------------------------------------------------------------- /ip.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | 6 | #include "eos/ip.h" 7 | 8 | namespace std { 9 | 10 | size_t hash::operator() (eos::ip_addr_t const & addr) const { 11 | return 0; // TODO: no op impl. 12 | } 13 | 14 | } // end namespace std 15 | -------------------------------------------------------------------------------- /eos/types/mpls_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_MPLS_IMPL_H 5 | #define EOS_TYPES_MPLS_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace eos { 12 | 13 | } 14 | 15 | #endif // EOS_TYPES_MPLS_IMPL_H 16 | -------------------------------------------------------------------------------- /eos/inline/bgp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_BGP_H 5 | #define INLINE_BGP_H 6 | 7 | namespace eos { 8 | 9 | inline bgp_mgr * bgp_peer_handler::get_bgp_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // end namespace eos 14 | 15 | #endif // INLINE_BGP_H 16 | 17 | -------------------------------------------------------------------------------- /eos/inline/macsec.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_MACSEC_H 5 | #define INLINE_MACSEC_H 6 | 7 | namespace eos { 8 | 9 | inline macsec_mgr * macsec_handler::get_macsec_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | 16 | #endif // INLINE_MACSEC_H 17 | 18 | -------------------------------------------------------------------------------- /eos/inline/neighbor_table.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_NEIGHBOR_TABLE_H 5 | #define INLINE_NEIGHBOR_TABLE_H 6 | 7 | inline neighbor_table_mgr *neighbor_table_handler::get_neighbor_table_mgr() const { 8 | return mgr_; 9 | } 10 | 11 | #endif // INLINE_NEIGHBOR_TABLE_H 12 | -------------------------------------------------------------------------------- /eos/inline/system.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_SYSTEM_H 5 | #define EOS_INLINE_SYSTEM_H 6 | 7 | namespace eos { 8 | 9 | inline system_mgr * system_handler::get_system_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_SYSTEM_H 16 | -------------------------------------------------------------------------------- /eos/inline/acl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_ACL_H 5 | #define EOS_INLINE_ACL_H 6 | 7 | namespace eos { 8 | 9 | 10 | inline acl_mgr * acl_handler::get_acl_mgr() const { 11 | return mgr_; 12 | } 13 | 14 | } // end namespace eos 15 | 16 | #endif // EOS_INLINE_ACL_H 17 | -------------------------------------------------------------------------------- /eos/inline/ip_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_IP_INTF_H 5 | #define EOS_INLINE_IP_INTF_H 6 | 7 | namespace eos { 8 | 9 | inline ip_intf_mgr * ip_intf_handler::get_ip_intf_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_IP_INTF_H 16 | -------------------------------------------------------------------------------- /eos/inline/mac_table.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_MAC_TABLE_H 5 | #define INLINE_MAC_TABLE_H 6 | 7 | namespace eos { 8 | 9 | inline mac_table_mgr * mac_table_handler::get_mac_table_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // INLINE_MAC_TABLE_H 16 | -------------------------------------------------------------------------------- /eos/inline/types/eth_intf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_ETH_INTF_IMPL_H 5 | #define EOS_INLINE_TYPES_ETH_INTF_IMPL_H 6 | 7 | namespace eos { 8 | 9 | 10 | } 11 | 12 | #include 13 | 14 | #endif // EOS_INLINE_TYPES_ETH_INTF_IMPL_H 15 | -------------------------------------------------------------------------------- /eos/inline/aresolve.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_ARESOLVE_H 5 | #define EOS_INLINE_ARESOLVE_H 6 | 7 | namespace eos { 8 | 9 | inline aresolve_mgr * aresolve_handler::get_aresolve_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_ARESOLVE_H 16 | -------------------------------------------------------------------------------- /eos/inline/eth_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_ETH_INTF_H 5 | #define EOS_INLINE_ETH_INTF_H 6 | 7 | namespace eos { 8 | 9 | inline eth_intf_mgr * eth_intf_handler::get_eth_intf_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_ETH_INTF_H 16 | -------------------------------------------------------------------------------- /ltmain.patch: -------------------------------------------------------------------------------- 1 | --- ./autogen/ltmain.sh.orig 2017-04-26 15:09:03.409119048 -0700 2 | +++ ./autogen/ltmain.sh 2017-04-26 15:09:22.825078726 -0700 3 | @@ -6939,6 +6939,12 @@ 4 | continue 5 | ;; 6 | 7 | + # Allow override of soname 8 | + -soname) 9 | + prev="soname_spec" 10 | + continue 11 | + ;; 12 | + 13 | -inst-prefix-dir) 14 | prev=inst_prefix 15 | continue 16 | -------------------------------------------------------------------------------- /eos/inline/intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_INTF_H 5 | #define EOS_INLINE_INTF_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | inline intf_mgr * intf_handler::get_intf_mgr() const { 12 | return mgr_; 13 | } 14 | 15 | } 16 | 17 | #endif // EOS_INLINE_INTF_H 18 | -------------------------------------------------------------------------------- /eos/inline/types/aresolve_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_ARESOLVE_IMPL_H 5 | #define EOS_INLINE_TYPES_ARESOLVE_IMPL_H 6 | 7 | namespace eos { 8 | 9 | 10 | 11 | 12 | } 13 | 14 | #include 15 | 16 | #endif // EOS_INLINE_TYPES_ARESOLVE_IMPL_H 17 | -------------------------------------------------------------------------------- /eos/inline/utility.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_UTILITY_H 5 | #define INLINE_UTILITY_H 6 | 7 | namespace eos { 8 | 9 | inline std::ostream &operator<<(std::ostream &os, uint8_t v) { 10 | return os << static_cast(v); 11 | } 12 | 13 | } 14 | 15 | #endif // INLINE_UTILITY_H 16 | -------------------------------------------------------------------------------- /eos/inline/bfd.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_BFD_H 5 | #define EOS_INLINE_BFD_H 6 | 7 | namespace eos { 8 | 9 | inline bfd_session_mgr * 10 | bfd_session_handler::get_bfd_session_mgr() const { 11 | return mgr_; 12 | } 13 | 14 | } // end namespace eos 15 | 16 | #endif // INLINE_BFD_H 17 | 18 | -------------------------------------------------------------------------------- /eos/inline/bgp_path.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_BGP_PATH_H 5 | #define INLINE_BGP_PATH_H 6 | 7 | namespace eos { 8 | 9 | inline bgp_path_mgr * bgp_path_handler::get_bgp_path_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // end namespace eos 14 | 15 | #endif // INLINE_BGP_PATH_H 16 | 17 | -------------------------------------------------------------------------------- /eos/inline/eth_lag_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_ETH_LAG_INTF_H 5 | #define INLINE_ETH_LAG_INTF_H 6 | 7 | namespace eos { 8 | 9 | inline eth_lag_intf_mgr * eth_lag_intf_handler::get_eth_lag_intf_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // INLINE_ETH_LAG_INTF_H 16 | -------------------------------------------------------------------------------- /eos/inline/policy_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_POLICY_H 5 | #define EOS_INLINE_POLICY_H 6 | 7 | namespace eos { 8 | 9 | inline policy_map_mgr * policy_map_handler::get_policy_map_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // namespace eos 14 | 15 | #endif // EOS_INLINE_POLICY_H 16 | -------------------------------------------------------------------------------- /eos/inline/mpls_route.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_MPLS_ROUTE_H 5 | #define INLINE_MPLS_ROUTE_H 6 | 7 | namespace eos { 8 | 9 | inline mpls_route_mgr *mpls_route_handler::get_mpls_route_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // end namespace eos 14 | 15 | #endif // INLINE_MPLS_ROUTE_H 16 | -------------------------------------------------------------------------------- /policy_map_types.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/policy_map.h" 5 | #include 6 | #include 7 | 8 | namespace eos { 9 | 10 | static std::string const RULE_CONFIG_ERROR_ = \ 11 | "Policy maps have either one MPLS match rule or a collection of other rules"; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /eos/inline/eth_phy_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_ETH_PHY_INTF_H 5 | #define EOS_INLINE_ETH_PHY_INTF_H 6 | 7 | namespace eos { 8 | 9 | inline eth_phy_intf_mgr * eth_phy_intf_handler::get_eth_phy_intf_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_ETH_PHY_INTF_H 16 | 17 | -------------------------------------------------------------------------------- /eos/inline/nexthop_group.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_NEXTHOP_GROUP_H 5 | #define EOS_INLINE_NEXTHOP_GROUP_H 6 | 7 | namespace eos { 8 | 9 | inline nexthop_group_mgr * nexthop_group_handler::get_nexthop_group_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } 14 | 15 | #endif // EOS_INLINE_NEXTHOP_GROUP_H 16 | -------------------------------------------------------------------------------- /swig-go.patch: -------------------------------------------------------------------------------- 1 | --- eossdk.go 2019-03-05 13:25:33.982085134 -0800 2 | +++ eossdk.go 2019-03-05 13:29:10.390894707 -0800 3 | @@ -2511,6 +2511,7 @@ 4 | extern uintptr_t _wrap_ClassMapMgr_class_map_iter_eossdk_184315817a81a75b(uintptr_t arg1, swig_intgo arg2); 5 | extern void _wrap_ClassMapMgr_class_map_del_eossdk_184315817a81a75b(uintptr_t arg1, uintptr_t arg2); 6 | #undef intgo 7 | +#cgo LDFLAGS: -leos 8 | */ 9 | import "C" 10 | 11 | -------------------------------------------------------------------------------- /eos/inline/hardware_table.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_HARDWARE_TABLE_H 5 | #define INLINE_HARDWARE_TABLE_H 6 | 7 | namespace eos { 8 | 9 | inline hardware_table_mgr *hardware_table_handler::get_hardware_table_mgr() const { 10 | return mgr_; 11 | } 12 | 13 | } // end namespace eos 14 | 15 | #endif // INLINE_HARDWARE_TABLE_H 16 | 17 | -------------------------------------------------------------------------------- /eos/inline/directflow.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_DIRECTFLOW_H 5 | #define EOS_INLINE_DIRECTFLOW_H 6 | 7 | #include 8 | #include 9 | 10 | namespace eos { 11 | 12 | inline directflow_mgr * flow_handler::get_directflow_mgr() const { 13 | return mgr_; 14 | } 15 | 16 | } 17 | 18 | #endif // EOS_INLINE_DIRECTFLOW_H 19 | -------------------------------------------------------------------------------- /eos/types/aresolve_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_ARESOLVE_IMPL_H 5 | #define EOS_TYPES_ARESOLVE_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace eos { 15 | 16 | 17 | } 18 | 19 | #endif // EOS_TYPES_ARESOLVE_IMPL_H 20 | -------------------------------------------------------------------------------- /eos/inline/nexthop_group_tunnel.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_NEXTHOP_GROUP_TUNNEL_H 5 | #define INLINE_NEXTHOP_GROUP_TUNNEL_H 6 | 7 | namespace eos { 8 | 9 | inline nexthop_group_tunnel_mgr * 10 | nexthop_group_tunnel_handler::get_nexthop_group_tunnel_mgr() const { 11 | return mgr_; 12 | } 13 | 14 | } 15 | 16 | #endif // INLINE_NEXTHOP_GROUP_TUNNEL_H 17 | 18 | -------------------------------------------------------------------------------- /aresolve_types.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/aresolve.h" 5 | 6 | namespace eos { 7 | 8 | aresolve_record_host::aresolve_record_host() { 9 | addr_v4_.push_back(ip_addr_t("1.2.3.4")); 10 | addr_v6_.push_back(ip_addr_t("dead::beef:1")); 11 | } 12 | 13 | aresolve_record_host::~aresolve_record_host() { 14 | addr_v4_.clear(); 15 | addr_v6_.clear(); 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # This file integrates our stubs with the Travis CI continuous 2 | # integration system. 3 | 4 | language: cpp 5 | compiler: 6 | - gcc 7 | 8 | env: 9 | - GCC_VERSION= # use travis's default GCC 4.6 10 | 11 | before_install: 12 | - mkdir -p autogen 13 | - sudo apt-get update -qq 14 | 15 | install: 16 | - sudo apt-get install -y g++-multilib libtool 17 | 18 | script: ./build.sh && sudo make install 19 | 20 | after_failure: 21 | - echo "Build failed! Output of ./config.log" 22 | - cat config.log 23 | - echo "---------" -------------------------------------------------------------------------------- /eos/inline/types/eth_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_ETH_IMPL_H 5 | #define EOS_INLINE_TYPES_ETH_IMPL_H 6 | 7 | namespace eos { 8 | 9 | #ifndef SWIG // BUG109396: SWIG + non parenthesized initializer lists 10 | 11 | 12 | 13 | 14 | #endif // BUG109396: SWIG + non parenthesized initializer lists 15 | 16 | 17 | 18 | 19 | 20 | } 21 | 22 | #include 23 | 24 | #endif // EOS_INLINE_TYPES_ETH_IMPL_H 25 | -------------------------------------------------------------------------------- /eos/inline/types/mpls_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_MPLS_IMPL_H 5 | #define EOS_INLINE_TYPES_MPLS_IMPL_H 6 | 7 | #include 8 | #include 9 | 10 | namespace eos { 11 | 12 | EOS_SDK_PRIVATE invalid_range_error invalid_mpls_label(uint32_t label); 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | } 23 | 24 | #include 25 | 26 | #endif // EOS_INLINE_TYPES_MPLS_IMPL_H 27 | -------------------------------------------------------------------------------- /SwigRenamer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | import string 5 | import sys 6 | 7 | # Converts a string_like_this from stdin to a stringLikeThis. If the 8 | # --classname flag is provided, we capitalize the first letter: 9 | # StringLikeThis 10 | 11 | i = sys.stdin.readline().strip() 12 | if i.endswith('_t'): 13 | i = i[:-2] 14 | i = string.capwords(i, '_').replace('_', '') 15 | if '--classname' not in sys.argv: 16 | i = i[0].lower() + i[1:] 17 | print(i, end="") 18 | -------------------------------------------------------------------------------- /eos/types/eth_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_ETH_IMPL_H 5 | #define EOS_TYPES_ETH_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace eos { 20 | 21 | 22 | 23 | } 24 | 25 | #endif // EOS_TYPES_ETH_IMPL_H 26 | -------------------------------------------------------------------------------- /mpls.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/exception.h" 5 | #include "eos/mpls.h" 6 | 7 | namespace eos { 8 | 9 | static uint32_t const mpls_label_unset = 0x100000; 10 | 11 | mpls_label_t::mpls_label_t() { 12 | label_ = mpls_label_unset; 13 | } 14 | 15 | invalid_range_error invalid_mpls_label(uint32_t label) { 16 | return invalid_range_error("label", mpls_label_t::MIN, mpls_label_t::MAX); 17 | } 18 | 19 | bool mpls_label_t::operator!() const { 20 | return label_ == mpls_label_unset; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /eos/inline/iterator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_ITERATOR_H 5 | #define EOS_INLINE_ITERATOR_H 6 | 7 | namespace eos { 8 | 9 | template 10 | inline iter_base 11 | iter_base::operator++(int) { 12 | iter_base me = *this; 13 | ++(*this); 14 | return me; 15 | } 16 | 17 | template 18 | inline bool 19 | iter_base::operator!=(iter_base const & rhs) const { 20 | return !(*this == rhs); 21 | } 22 | 23 | } 24 | 25 | #endif // EOS_INLINE_ITERATOR_H 26 | -------------------------------------------------------------------------------- /eos/types/mlag.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_MLAG_H 5 | #define EOS_TYPES_MLAG_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | enum mlag_state_t { 12 | MLAG_STATE_UNKNOWN, 13 | MLAG_STATE_DISABLED, 14 | MLAG_STATE_INACTIVE, 15 | MLAG_STATE_PRIMARY, 16 | MLAG_STATE_SECONDARY, 17 | }; 18 | /** Appends a string representation of enum mlag_state_t value to the ostream. */ 19 | EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, 20 | const mlag_state_t & enum_val); 21 | } 22 | 23 | #endif // EOS_TYPES_MLAG_H 24 | -------------------------------------------------------------------------------- /eos/utility.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_UTILITY_H 5 | #define EOS_UTILITY_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | typedef std::string ByteString; 12 | 13 | /** 14 | * Overwriting "<<" operator for uint8_t. The default behavior is to 15 | * print the value out as "char" (sometimes even invisible). What we 16 | * want is numerical value. 17 | * 18 | * This is used in to_string() method that is auto-generated. 19 | */ 20 | 21 | std::ostream &operator<<(std::ostream &os, uint8_t v) EOS_SDK_PUBLIC; 22 | 23 | } 24 | 25 | #include 26 | 27 | #endif // EOS_UTILITY_H 28 | -------------------------------------------------------------------------------- /eos/inline/types/sdk.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_SDK_H 5 | #define EOS_INLINE_TYPES_SDK_H 6 | 7 | namespace eos { 8 | 9 | EOS_SDK_PUBLIC std::ostream& 10 | operator<<(std::ostream& os, const mgr_mode_type_t & enum_val) { 11 | if (enum_val==MODE_TYPE_READ_ONLY) { 12 | os << "MODE_TYPE_READ_ONLY"; 13 | } else if (enum_val==MODE_TYPE_READ_NOTIFYING) { 14 | os << "MODE_TYPE_READ_NOTIFYING"; 15 | } else if (enum_val==MODE_TYPE_WRITE) { 16 | os << "MODE_TYPE_WRITE"; 17 | } else { 18 | os << "Unknown value"; 19 | } 20 | return os; 21 | } 22 | 23 | } 24 | 25 | #endif // EOS_INLINE_TYPES_SDK_H 26 | -------------------------------------------------------------------------------- /eapi.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/eapi.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class eapi_mgr_impl : public eapi_mgr { 10 | public: 11 | eapi_mgr_impl() { 12 | } 13 | 14 | eapi_response_t run_show_cmd(std::string const &) const { 15 | return eapi_response_t(); 16 | } 17 | 18 | eapi_response_t run_show_cmd_text(std::string const &) const { 19 | return eapi_response_t(); 20 | } 21 | 22 | eapi_response_t run_config_cmds(std::vector const &) const { 23 | return eapi_response_t(); 24 | } 25 | 26 | }; 27 | 28 | DEFINE_STUB_MGR_CTOR(eapi_mgr) 29 | 30 | } // end namespace eos 31 | -------------------------------------------------------------------------------- /examples/EosThrift.thrift: -------------------------------------------------------------------------------- 1 | #!/usr/bin/thrift --gen cpp 2 | # Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | namespace cpp eos 6 | 7 | enum OperStatus { 8 | UNKNOWN, 9 | UP, 10 | DOWN, 11 | } 12 | 13 | /// The interface's type 14 | enum InterfaceType { 15 | UNKNOWN, 16 | OTHER, 17 | ETH, 18 | VLAN, 19 | MANAGEMENT, 20 | LOOPBACK, 21 | LAG, 22 | NULL0, 23 | } 24 | 25 | // XXX exceptions. 26 | 27 | service ThriftSdk { 28 | // intf_mgr 29 | bool exists(1:string intf), 30 | bool adminEnabled(1:string intf), 31 | void adminEnabledIs(1:string intf, 2:bool enabled), 32 | void descriptionIs(1:string intf, 2:string description), 33 | OperStatus operStatus(1:string intf), 34 | } 35 | -------------------------------------------------------------------------------- /eos/types/sdk.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_SDK_H 5 | #define EOS_TYPES_SDK_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace eos { 12 | 13 | /** Enums for Manager mode type. */ 14 | enum mgr_mode_type_t { 15 | /** Reader without notifications. */ 16 | MODE_TYPE_READ_ONLY, 17 | /** Reader with notifications. */ 18 | MODE_TYPE_READ_NOTIFYING, 19 | /** Writer, manager can read and write state. */ 20 | MODE_TYPE_WRITE, 21 | }; 22 | /** Appends a string representation of enum mgr_mode_type_t value to the ostream. */ 23 | EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, 24 | const mgr_mode_type_t & enum_val); 25 | } 26 | 27 | #endif // EOS_TYPES_SDK_H 28 | -------------------------------------------------------------------------------- /eos/inline/types/mlag.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_MLAG_H 5 | #define EOS_INLINE_TYPES_MLAG_H 6 | 7 | namespace eos { 8 | 9 | EOS_SDK_PUBLIC std::ostream& 10 | operator<<(std::ostream& os, const mlag_state_t & enum_val) { 11 | if (enum_val==MLAG_STATE_UNKNOWN) { 12 | os << "MLAG_STATE_UNKNOWN"; 13 | } else if (enum_val==MLAG_STATE_DISABLED) { 14 | os << "MLAG_STATE_DISABLED"; 15 | } else if (enum_val==MLAG_STATE_INACTIVE) { 16 | os << "MLAG_STATE_INACTIVE"; 17 | } else if (enum_val==MLAG_STATE_PRIMARY) { 18 | os << "MLAG_STATE_PRIMARY"; 19 | } else if (enum_val==MLAG_STATE_SECONDARY) { 20 | os << "MLAG_STATE_SECONDARY"; 21 | } else { 22 | os << "Unknown value"; 23 | } 24 | return os; 25 | } 26 | 27 | } 28 | 29 | #endif // EOS_INLINE_TYPES_MLAG_H 30 | -------------------------------------------------------------------------------- /mlag.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/mlag.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | // 10 | // mlag_mgr implementation 11 | // 12 | 13 | class mlag_mgr_impl : public mlag_mgr { 14 | public: 15 | mlag_mgr_impl() { 16 | } 17 | 18 | bool enabled() const { 19 | return false; 20 | } 21 | 22 | void enabled_is(bool enabled) { 23 | } 24 | 25 | ip_addr_t peer_address() const { 26 | return ip_addr_t(); 27 | } 28 | 29 | mlag_state_t state() const { 30 | return MLAG_STATE_DISABLED; 31 | } 32 | 33 | }; 34 | 35 | DEFINE_STUB_MGR_CTOR(mlag_mgr) 36 | 37 | mlag_handler::mlag_handler(mlag_mgr *mgr) : 38 | base_handler(mgr) { 39 | } 40 | 41 | void mlag_handler::on_mlag_state(mlag_state_t state) { 42 | } 43 | 44 | } // end eos namespace 45 | -------------------------------------------------------------------------------- /eos/base_handler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_BASE_HANDLER_H 5 | #define EOS_BASE_HANDLER_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | template 12 | class EOS_SDK_PRIVATE base_handler { 13 | protected: 14 | explicit base_handler(Mgr * mgr) : mgr_(mgr) { 15 | } 16 | 17 | virtual ~base_handler() { 18 | if (mgr_) { 19 | // The add_handler has to remove every interface-specific handler... 20 | mgr_->add_handler(static_cast(this)); 21 | mgr_->remove_handler(static_cast(this)); 22 | } 23 | } 24 | 25 | void unregister_mgr() { 26 | mgr_ = 0; 27 | } 28 | 29 | template friend class base_mgr; 30 | Mgr * mgr_; 31 | }; 32 | 33 | } 34 | 35 | #endif // EOS_BASE_HANDLER_H 36 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | _____ ___ ____ ____ ____ _ __ 2 | | ____/ _ \/ ___| / ___|| _ \| |/ / 3 | | _|| | | \___ \ \___ \| | | | ' / 4 | | |__| |_| |___) | ___) | |_| | . \ 5 | |_____\___/|____/ |____/|____/|_|\_\ 6 | 7 | This package provides a self-contained implementation of stubs for the EOS 8 | SDK. The stubs mock how the real EOS SDK behaves on a real switch, to a 9 | certain extent. They are useful to build and test software in your favorite 10 | Linux environment, with your preferred build tools. 11 | 12 | In order to build code against the EOS SDK that can be run on EOS or vEOS, 13 | you must build your code for i686 in a similar fashion to how build.sh builds 14 | the stubs package, and you must link against ABI-compatible libraries. For 15 | instance if your code depends on OpenSSL, make sure you link against a version 16 | that is ABI-compatible with the version bundled in EOS. 17 | -------------------------------------------------------------------------------- /class_map.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/class_map.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class class_map_mgr_impl : public class_map_mgr { 10 | public: 11 | class_map_mgr_impl() { 12 | } 13 | 14 | void resync_init() { 15 | } 16 | 17 | void resync_complete() { 18 | } 19 | 20 | bool exists(class_map_key_t const & key) const { 21 | return true; 22 | } 23 | 24 | class_map_t class_map(class_map_key_t const & key) const { 25 | return class_map_t(); 26 | } 27 | 28 | void class_map_is(class_map_t const & class_map) { 29 | } 30 | 31 | class_map_iter_t class_map_iter(policy_feature_t) const { 32 | class_map_iter_t * nop = 0; 33 | return *nop; 34 | } 35 | 36 | void class_map_del(class_map_key_t const & key) { 37 | } 38 | }; 39 | 40 | DEFINE_STUB_MGR_CTOR(class_map_mgr) 41 | 42 | } 43 | -------------------------------------------------------------------------------- /examples/libevent.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EXAMPLES_LIBEVENT_H 5 | #define EXAMPLES_LIBEVENT_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | struct event_base; // Forward declare libevent's main data structure. 13 | 14 | class libevent_loop : public eos::event_loop_handler { 15 | public: 16 | libevent_loop(eos::sdk & sdk, event_base * eb) 17 | : eb_(eb), loop_(sdk.get_event_loop()) { 18 | } 19 | 20 | virtual ~libevent_loop() { 21 | } 22 | 23 | void init(); 24 | virtual void watch_readable(int fd, bool interested); 25 | virtual void watch_writable(int fd, bool interested); 26 | virtual void watch_exception(int fd, bool interested); 27 | virtual void timeout_time_is(struct timeval deadline); 28 | 29 | private: 30 | event_base * const eb_; 31 | eos::event_loop * loop_; 32 | }; 33 | 34 | #endif // EXAMPLES_LIBEVENT_H 35 | -------------------------------------------------------------------------------- /version.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/version.h" 5 | #include "config.h" // Generated by configure 6 | 7 | namespace eos { 8 | 9 | const char * const version = PACKAGE_VERSION "-stubs"; 10 | const uint8_t version_major = SDK_VERSION_MAJOR; 11 | const uint8_t version_minor = SDK_VERSION_MINOR; 12 | const uint8_t version_patch = SDK_VERSION_PATCH; 13 | #if SHIPPING 14 | const char * const build_project = SDK_BUILD_PROJECT; 15 | const char * const build_user = SDK_BUILD_USER; 16 | const char * const build_path = SDK_BUILD_PATH; 17 | const uint32_t build_cl = SDK_BUILD_PROJECT_CL; 18 | const uint64_t build_timestamp = SDK_BUILD_TIMESTAMP; 19 | #else 20 | const char * const build_project = "anonymous-dev-build"; 21 | const char * const build_user = "anonymous-dev-user"; 22 | const char * const build_path = "anonymous-dev-path"; 23 | const uint32_t build_cl = 0; 24 | const uint64_t build_timestamp = 0l; 25 | #endif 26 | 27 | } 28 | -------------------------------------------------------------------------------- /eos/inline/types/eapi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_EAPI_H 5 | #define EOS_INLINE_TYPES_EAPI_H 6 | 7 | namespace eos { 8 | 9 | bool 10 | eapi_response_t::success() const { 11 | return pimpl->success(); 12 | } 13 | uint32_t 14 | eapi_response_t::error_code() const { 15 | return pimpl->error_code(); 16 | } 17 | std::string 18 | eapi_response_t::error_message() const { 19 | return pimpl->error_message(); 20 | } 21 | std::vector const & 22 | eapi_response_t::responses() const { 23 | return pimpl->responses(); 24 | } 25 | std::string 26 | eapi_response_t::raw_response() const { 27 | return pimpl->raw_response(); 28 | } 29 | std::string 30 | eapi_response_t::to_string() const { 31 | return pimpl->to_string(); 32 | } 33 | std::ostream& 34 | operator<<(std::ostream& os, const eapi_response_t& obj) { 35 | return operator<<(os, *obj.pimpl); 36 | } 37 | 38 | } 39 | 40 | #endif // EOS_INLINE_TYPES_EAPI_H 41 | -------------------------------------------------------------------------------- /aresolve.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/aresolve.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | aresolve_handler::aresolve_handler(aresolve_mgr * mgr) : 10 | base_handler(mgr) { 11 | } 12 | 13 | void aresolve_handler::watch_host(std::string const &, bool) { 14 | } 15 | 16 | void aresolve_handler::on_aresolve_host(aresolve_record_host const & record) { 17 | } 18 | 19 | class aresolve_mgr_impl : public aresolve_mgr { 20 | public: 21 | aresolve_mgr_impl() { 22 | } 23 | 24 | uint32_t aresolve_short_time() const { 25 | return 1; 26 | } 27 | 28 | uint32_t aresolve_long_time() const { 29 | return 300; 30 | } 31 | 32 | void aresolve_short_time_is(uint32_t time) { 33 | } 34 | 35 | void aresolve_long_time_is(uint32_t time) { 36 | } 37 | 38 | void on_aresolve_host(aresolve_record_host const &) { 39 | } 40 | 41 | }; 42 | 43 | DEFINE_STUB_MGR_CTOR(aresolve_mgr) 44 | 45 | } 46 | -------------------------------------------------------------------------------- /eos/inline/types/eth_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_ETH_INTF_H 5 | #define EOS_INLINE_TYPES_ETH_INTF_H 6 | 7 | namespace eos { 8 | 9 | EOS_SDK_PUBLIC std::ostream& 10 | operator<<(std::ostream& os, const switchport_mode_t & enum_val) { 11 | if (enum_val==SWITCHPORT_MODE_ACCESS) { 12 | os << "SWITCHPORT_MODE_ACCESS"; 13 | } else if (enum_val==SWITCHPORT_MODE_TRUNK) { 14 | os << "SWITCHPORT_MODE_TRUNK"; 15 | } else if (enum_val==SWITCHPORT_MODE_DOT1Q_TUNNEL) { 16 | os << "SWITCHPORT_MODE_DOT1Q_TUNNEL"; 17 | } else if (enum_val==SWITCHPORT_MODE_TAP) { 18 | os << "SWITCHPORT_MODE_TAP"; 19 | } else if (enum_val==SWITCHPORT_MODE_TOOL) { 20 | os << "SWITCHPORT_MODE_TOOL"; 21 | } else if (enum_val==SWITCHPORT_MODE_ROUTED) { 22 | os << "SWITCHPORT_MODE_ROUTED"; 23 | } else { 24 | os << "Unknown value"; 25 | } 26 | return os; 27 | } 28 | 29 | } 30 | 31 | #endif // EOS_INLINE_TYPES_ETH_INTF_H 32 | -------------------------------------------------------------------------------- /fd.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/fd.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | fd_handler::fd_handler() { 10 | impl.register_fd_handler(this); 11 | } 12 | 13 | fd_handler::~fd_handler() { 14 | impl.unregister_fd_handler(this); 15 | } 16 | 17 | void 18 | fd_handler::on_readable(int fd) { 19 | // Default implementation: do nothing. 20 | } 21 | 22 | void 23 | fd_handler::on_writable(int fd) { 24 | // Default implementation: do nothing. 25 | } 26 | 27 | void 28 | fd_handler::on_exception(int fd) { 29 | // Default implementation: do nothing. 30 | } 31 | 32 | void 33 | fd_handler::watch_readable(int fd, bool interest) { 34 | impl.get_fd_sm(this)->watch_readable(fd, interest); 35 | } 36 | 37 | void 38 | fd_handler::watch_writable(int fd, bool interest) { 39 | impl.get_fd_sm(this)->watch_writable(fd, interest); 40 | } 41 | 42 | void 43 | fd_handler::watch_exception(int fd, bool interest) { 44 | impl.get_fd_sm(this)->watch_exception(fd, interest); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /intf_types.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/intf.h" 5 | #include 6 | 7 | namespace eos { 8 | 9 | intf_id_t::intf_id_t() { 10 | intfId_ = 0; // real impl uses Arnet::IntfId::emptyIntfId = 0xffffffff 11 | } 12 | 13 | intf_id_t::intf_id_t(char const * name) : 14 | intfId_() { 15 | intfId_ = eos::intf_id_t_ctor(name); 16 | } 17 | 18 | intf_id_t::intf_id_t(std::string const & name) : 19 | intfId_() { 20 | intfId_ = eos::intf_id_t_ctor(name.c_str()); 21 | } 22 | 23 | bool 24 | intf_id_t::is_null0() const { 25 | return eos::intf_id_t_is_null0(intfId_); 26 | } 27 | 28 | bool 29 | intf_id_t::is_subintf() const { 30 | return eos::intf_id_t_is_subintf(intfId_); 31 | } 32 | 33 | intf_type_t 34 | intf_id_t::intf_type() const { 35 | return eos::intf_id_t_intf_type(intfId_); 36 | } 37 | 38 | std::string 39 | intf_id_t::to_string() const { 40 | return eos::intf_id_t_to_string(intfId_); 41 | } 42 | 43 | bool 44 | intf_id_t::operator!() const { 45 | return intfId_ == 0; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /bgp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | 7 | namespace eos { 8 | 9 | class bgp_mgr_impl : public bgp_mgr { 10 | public: 11 | ~bgp_mgr_impl() { 12 | } 13 | 14 | bool exists(bgp_peer_key_t const & peer_key) const { 15 | return false; 16 | } 17 | 18 | bgp_peer_state_t peer_state(bgp_peer_key_t const & peer_key) const { 19 | bgp_peer_state_t *nop = 0; 20 | return *nop; 21 | } 22 | 23 | }; 24 | 25 | DEFINE_STUB_MGR_CTOR(bgp_mgr) 26 | 27 | bgp_peer_handler::bgp_peer_handler(bgp_mgr * mgr) : base_handler(mgr) { 28 | } 29 | 30 | void bgp_peer_handler::watch_all_peers(bool) {} 31 | 32 | void bgp_peer_handler::watch_peer(bgp_peer_key_t const & peer_key, bool) {} 33 | 34 | void bgp_peer_handler::on_peer_state(bgp_peer_key_t const & peer_key, 35 | bgp_peer_state_t peer_state) {} 36 | void bgp_peer_handler::on_peer_set(bgp_peer_key_t const & peer_key) {} 37 | void bgp_peer_handler::on_peer_del(bgp_peer_key_t const & peer_key) {} 38 | 39 | 40 | } // namespace eos 41 | -------------------------------------------------------------------------------- /eos/mpls.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_MPLS_H 5 | #define EOS_MPLS_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @file 13 | * MPLS related type definitions. 14 | */ 15 | 16 | namespace eos { 17 | 18 | /** 19 | * MPLS reserved label definitions (0..15). 20 | * See http://www.iana.org/assignments/mpls-label-values/mpls-label-values.xhtml 21 | */ 22 | static mpls_label_t const mpls_label_explicit_null_v4 = mpls_label_t(0); 23 | static mpls_label_t const mpls_label_router_alert = mpls_label_t(1); 24 | static mpls_label_t const mpls_label_explicit_null_v6 = mpls_label_t(2); 25 | static mpls_label_t const mpls_label_implicit_null = mpls_label_t(3); 26 | // 4..6 unassigned 27 | static mpls_label_t const mpls_label_entropy_indicator = mpls_label_t(7); 28 | // 8..12 unassigned 29 | static mpls_label_t const mpls_label_gal = mpls_label_t(13); 30 | static mpls_label_t const mpls_label_oam_alert = mpls_label_t(14); 31 | // 15 unassigned 32 | 33 | } // end namespace eos 34 | 35 | #endif // EOS_MPLS_H 36 | -------------------------------------------------------------------------------- /eos/types/eth_intf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_ETH_INTF_H 5 | #define EOS_TYPES_ETH_INTF_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | /** The mode of operation of a switch port. */ 12 | enum switchport_mode_t { 13 | /** Interface only has access to its access VLAN. */ 14 | SWITCHPORT_MODE_ACCESS, 15 | /** Interface is in 802.1q mode ("trunk mode"). */ 16 | SWITCHPORT_MODE_TRUNK, 17 | /** Interface is in 802.1ad mode ("QinQ mode"). */ 18 | SWITCHPORT_MODE_DOT1Q_TUNNEL, 19 | /** Interface is in tap mode ("span mode"). */ 20 | SWITCHPORT_MODE_TAP, 21 | /** Interface is a tool port (egress for a tap). */ 22 | SWITCHPORT_MODE_TOOL, 23 | /** Interface is routed ("no switchport"). */ 24 | SWITCHPORT_MODE_ROUTED, 25 | }; 26 | /** 27 | * Appends a string representation of enum switchport_mode_t value to the ostream. 28 | */ 29 | EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, 30 | const switchport_mode_t & enum_val); 31 | } 32 | 33 | #endif // EOS_TYPES_ETH_INTF_H 34 | -------------------------------------------------------------------------------- /eos/inline/types/subintf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_SUBINTF_H 5 | #define EOS_INLINE_TYPES_SUBINTF_H 6 | 7 | namespace eos { 8 | 9 | intf_id_t 10 | subintf_t::intf_id() const { 11 | return pimpl->intf_id(); 12 | } 13 | vlan_id_t 14 | subintf_t::vlan_id() const { 15 | return pimpl->vlan_id(); 16 | } 17 | void 18 | subintf_t::vlan_id_is(vlan_id_t vlan_id) { 19 | pimpl->vlan_id_is(vlan_id); 20 | } 21 | bool 22 | subintf_t::operator==(subintf_t const & other) const { 23 | return pimpl->operator==(*other.pimpl); 24 | } 25 | bool 26 | subintf_t::operator!=(subintf_t const & other) const { 27 | return pimpl->operator!=(*other.pimpl); 28 | } 29 | uint32_t 30 | subintf_t::hash() const { 31 | return pimpl->hash(); 32 | } 33 | void 34 | subintf_t::mix_me(hash_mix & h) const { 35 | pimpl->mix_me(h); 36 | } 37 | std::string 38 | subintf_t::to_string() const { 39 | return pimpl->to_string(); 40 | } 41 | std::ostream& 42 | operator<<(std::ostream& os, const subintf_t& obj) { 43 | return operator<<(os, *obj.pimpl); 44 | } 45 | 46 | } 47 | 48 | #endif // EOS_INLINE_TYPES_SUBINTF_H 49 | -------------------------------------------------------------------------------- /mpls_vrf_label.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/mpls_vrf_label.h" 5 | #include "eos/panic.h" 6 | #include "impl.h" 7 | 8 | namespace eos { 9 | 10 | class mpls_vrf_label_mgr_impl : public mpls_vrf_label_mgr { 11 | public: 12 | mpls_vrf_label_mgr_impl() { 13 | } 14 | 15 | void resync_init() { 16 | // TODO: No op impl 17 | } 18 | 19 | void resync_complete() { 20 | // TODO: No op impl 21 | } 22 | 23 | mpls_vrf_label_iter_t mpls_vrf_label_iter() const { 24 | mpls_vrf_label_iter_t * nop = 0; 25 | return *nop; // TODO: No op impl. 26 | } 27 | 28 | mpls_vrf_label_t mpls_vrf_label(mpls_label_t const & label) const { 29 | return mpls_vrf_label_t(); 30 | } 31 | 32 | void mpls_vrf_label_set(mpls_vrf_label_t const & vrf_label) { 33 | if(vrf_label.vrf_name().empty()) { 34 | panic("empty VRF name"); 35 | // TODO: No op impl. 36 | } 37 | } 38 | 39 | void mpls_vrf_label_del(mpls_label_t const & label) { 40 | // TODO: No op impl. 41 | } 42 | }; 43 | 44 | DEFINE_STUB_MGR_CTOR(mpls_vrf_label_mgr) 45 | 46 | }; // end namespace eos 47 | -------------------------------------------------------------------------------- /event_loop.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/panic.h" 5 | #include "eos/event_loop.h" 6 | #include "impl.h" 7 | 8 | namespace eos { 9 | 10 | void 11 | event_loop_handler::on_readable(int) { 12 | impl.main_loop(0); 13 | } 14 | 15 | void 16 | event_loop_handler::on_writable(int) { 17 | impl.main_loop(0); 18 | } 19 | 20 | void 21 | event_loop_handler::on_exception(int) { 22 | impl.main_loop(0); 23 | } 24 | 25 | void 26 | event_loop_handler::on_timeout() { 27 | impl.main_loop(0); 28 | } 29 | 30 | event_loop::event_loop(mount_mgr * mgr) : mount_mgr_(mgr) { 31 | } 32 | 33 | event_loop::~event_loop() { 34 | } 35 | 36 | void 37 | event_loop::wait_for_initialized() const { 38 | } 39 | 40 | void 41 | event_loop::run(seconds_t duration) const { 42 | if(duration < 0){ 43 | panic("duration must be 0 or greater"); 44 | } 45 | impl.main_loop(duration); 46 | } 47 | 48 | void 49 | event_loop::flush() const { 50 | impl.main_loop(0); 51 | } 52 | 53 | 54 | void 55 | event_loop::external_loop_is(event_loop_handler * loop) { 56 | if(!loop) { 57 | panic("The event_loop_handler passed in argument was null"); 58 | } 59 | loop_ = loop; 60 | // TODO: No-op impl. 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /timer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "eos/base_mgr.h" 9 | #include "eos/panic.h" 10 | #include "eos/timer.h" 11 | #include "impl.h" 12 | 13 | namespace eos { 14 | 15 | //static seconds_t const TIME_BASE = 1000000.0; 16 | 17 | seconds_t now() { 18 | struct timespec t; 19 | int ret = clock_gettime(CLOCK_MONOTONIC, &t); 20 | if(ret == -1) { 21 | panic("clock_gettime(CLOCK_MONOTONIC) returned %d", ret); 22 | } 23 | return t.tv_sec + 0.000000001 * t.tv_nsec;// + TIME_BASE; 24 | } 25 | 26 | timeout_handler::timeout_handler(timeout_mgr * mgr) : 27 | base_handler(mgr) { 28 | impl.register_timeout_handler(this); 29 | } 30 | 31 | timeout_handler::~timeout_handler() { 32 | impl.unregister_timeout_handler(this); 33 | } 34 | 35 | void 36 | timeout_handler::timeout_time_is(seconds_t timeout) { 37 | impl.timeout_is(this, timeout); 38 | } 39 | 40 | class timeout_mgr_impl: public timeout_mgr { 41 | public: 42 | timeout_mgr_impl() { 43 | } 44 | 45 | void init_handler(timeout_handler * handler) { 46 | // TODO: No op impl. 47 | } 48 | }; 49 | 50 | DEFINE_STUB_MGR_CTOR(timeout_mgr) 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vrf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | 7 | namespace eos { 8 | 9 | /// The manager for Vrf 10 | class vrf_mgr_impl : public vrf_mgr { 11 | public: 12 | ~vrf_mgr_impl() { 13 | } 14 | 15 | vrf_iter_t vrf_iter() const { 16 | vrf_iter_t * nop = 0; 17 | return *nop; 18 | } 19 | 20 | bool exists(std::string const & vrf_name) const { 21 | return false; 22 | } 23 | 24 | vrf_state_t state(std::string const & vrf_name) const { 25 | return VRF_NULL; 26 | } 27 | 28 | uint64_t rd(std::string const & vrf_name) const { 29 | return 0; 30 | } 31 | 32 | vrf_t vrf(std::string const & vrf_name) const { 33 | return vrf_t(); 34 | } 35 | 36 | int socket_at(int domain, int type, int protocol, std::string const & vrf_name) { 37 | return 0; 38 | } 39 | 40 | }; 41 | 42 | DEFINE_STUB_MGR_CTOR(vrf_mgr) 43 | 44 | vrf_handler::vrf_handler(vrf_mgr *mgr) : base_handler(mgr) { 45 | } 46 | 47 | void vrf_handler::watch_all_vrfs(bool) {} 48 | 49 | void vrf_handler::watch_vrf(std::string const & vrf_name, bool) {} 50 | 51 | void vrf_handler::on_vrf_state(std::string vrf_name, vrf_state_t vrf_state) { 52 | } 53 | 54 | } // end namespace eos 55 | -------------------------------------------------------------------------------- /subintf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | 5 | #include 6 | #include "eos/subintf.h" 7 | #include "impl.h" 8 | 9 | namespace eos { 10 | 11 | class subintf_mgr_impl : public subintf_mgr { 12 | public: 13 | subintf_mgr_impl() { 14 | } 15 | 16 | subintf_iter_t subintf_iter() const { 17 | subintf_iter_t * nop = 0; 18 | return *nop; // TODO: No op impl. 19 | } 20 | 21 | bool exists(intf_id_t) const { 22 | return false; 23 | } 24 | 25 | vlan_id_t vlan_tag(intf_id_t) const { 26 | return 0; // TODO: No-op impl. 27 | } 28 | 29 | void vlan_tag_is(intf_id_t, vlan_id_t) { 30 | // TODO: No-op impl. 31 | } 32 | 33 | intf_id_t parent_intf(intf_id_t) const { 34 | return intf_id_t(); // TODO: No-op impl. 35 | } 36 | 37 | void subintf_is(intf_id_t) { 38 | // TODO: No-op impl. 39 | } 40 | 41 | void subintf_is(intf_id_t, vlan_id_t) { 42 | // TODO: No-op impl. 43 | } 44 | 45 | void subintf_del(intf_id_t) { 46 | return; // TODO: No-op impl. 47 | } 48 | 49 | subintf_t subintf(intf_id_t) const { 50 | subintf_t * nop = 0; 51 | return *nop; // TODO: No op impl. 52 | } 53 | }; 54 | 55 | DEFINE_STUB_MGR_CTOR(subintf_mgr) 56 | 57 | } 58 | -------------------------------------------------------------------------------- /eos/inline/types/mpls_vrf_label.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_MPLS_VRF_LABEL_H 5 | #define EOS_INLINE_TYPES_MPLS_VRF_LABEL_H 6 | 7 | namespace eos { 8 | 9 | mpls_label_t 10 | mpls_vrf_label_t::label() const { 11 | return pimpl->label(); 12 | } 13 | std::string 14 | mpls_vrf_label_t::vrf_name() const { 15 | return pimpl->vrf_name(); 16 | } 17 | bool 18 | mpls_vrf_label_t::operator==(mpls_vrf_label_t const & other) const { 19 | return pimpl->operator==(*other.pimpl); 20 | } 21 | bool 22 | mpls_vrf_label_t::operator!=(mpls_vrf_label_t const & other) const { 23 | return pimpl->operator!=(*other.pimpl); 24 | } 25 | bool 26 | mpls_vrf_label_t::operator<(mpls_vrf_label_t const & other) const { 27 | return pimpl->operator<(*other.pimpl); 28 | } 29 | uint32_t 30 | mpls_vrf_label_t::hash() const { 31 | return pimpl->hash(); 32 | } 33 | void 34 | mpls_vrf_label_t::mix_me(hash_mix & h) const { 35 | pimpl->mix_me(h); 36 | } 37 | std::string 38 | mpls_vrf_label_t::to_string() const { 39 | return pimpl->to_string(); 40 | } 41 | std::ostream& 42 | operator<<(std::ostream& os, const mpls_vrf_label_t& obj) { 43 | return operator<<(os, *obj.pimpl); 44 | } 45 | 46 | } 47 | 48 | #endif // EOS_INLINE_TYPES_MPLS_VRF_LABEL_H 49 | -------------------------------------------------------------------------------- /system.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/system.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | // 10 | // system_mgr implementation 11 | // 12 | 13 | class system_mgr_impl : public system_mgr { 14 | public: 15 | system_mgr_impl() { 16 | } 17 | 18 | std::string hostname() const { 19 | return "localhost"; 20 | } 21 | 22 | std::string fqdn() const { 23 | return "localhost"; 24 | } 25 | 26 | std::string serial_number() const { 27 | return "None"; 28 | } 29 | 30 | std::string model_name() const { 31 | return "None"; 32 | } 33 | 34 | std::string hardware_revision() const { 35 | return "None"; 36 | } 37 | 38 | std::string software_revision() const { 39 | return "None"; 40 | } 41 | 42 | eth_addr_t system_mac() const { 43 | return eth_addr_t(); 44 | } 45 | }; 46 | 47 | DEFINE_STUB_MGR_CTOR(system_mgr) 48 | 49 | system_handler::system_handler(system_mgr * mgr) : 50 | base_handler(mgr) { 51 | } 52 | 53 | void system_handler::on_hostname(std::string const & hostname) { 54 | } 55 | 56 | void system_handler::on_fqdn(std::string const & fqdn) { 57 | } 58 | 59 | void system_handler::on_system_info_initialized() { 60 | } 61 | 62 | } // end eos namespace 63 | -------------------------------------------------------------------------------- /decap_group.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | 6 | #include "eos/decap_group.h" 7 | #include "eos/panic.h" 8 | #include "impl.h" 9 | 10 | namespace eos { 11 | 12 | class decap_group_mgr_impl : public decap_group_mgr { 13 | public: 14 | decap_group_mgr_impl() { 15 | } 16 | 17 | void resync_init() { 18 | // TODO: No op impl 19 | } 20 | 21 | void resync_complete() { 22 | // TODO: No op impl 23 | } 24 | 25 | decap_group_iter_t decap_group_iter() const { 26 | decap_group_iter_t * nop = 0; 27 | return *nop; // TODO: No op impl. 28 | } 29 | 30 | decap_group_t decap_group(std::string const & decap_group_name) const { 31 | return decap_group_t(); 32 | } 33 | 34 | void decap_group_set(decap_group_t const &group) { 35 | if(group.group_name().empty()) { 36 | panic("Empty decap group name"); 37 | } else if(group.protocol_type() == PROTOCOL_TYPE_NULL) { 38 | panic("must pass a tunnel protocol other than PROTOCOL_TYPE_NULL"); 39 | } 40 | // TODO: No op impl. 41 | } 42 | 43 | void decap_group_del(std::string const & group_name) { 44 | // TODO: No op impl. 45 | } 46 | }; 47 | 48 | DEFINE_STUB_MGR_CTOR(decap_group_mgr) 49 | 50 | }; // end namespace eos 51 | -------------------------------------------------------------------------------- /panic.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "eos/panic.h" 9 | #include "eos/exception.h" 10 | 11 | namespace eos { 12 | 13 | static void throw_exception(error const & exception) { 14 | exception.raise(); 15 | } 16 | 17 | auto exception_handler = throw_exception; 18 | 19 | void panic(char const * fmt, ...) { 20 | va_list ap; 21 | va_start(ap, fmt); 22 | vpanic(fmt, ap); 23 | // not reached 24 | } 25 | 26 | void panic(error const & error) { 27 | if(exception_handler) { 28 | exception_handler(error); 29 | } 30 | fprintf(stderr, "%s\n", error.what()); 31 | for(;;) { 32 | abort(); 33 | } 34 | } 35 | 36 | struct legacy_exception : public error { 37 | virtual ~legacy_exception() noexcept { 38 | } 39 | explicit legacy_exception(std::string const & msg) noexcept : error(msg) { 40 | } 41 | virtual void raise() const { 42 | throw *this; 43 | } 44 | }; 45 | 46 | void vpanic(char const * fmt, va_list ap) { 47 | char buf[1024]; 48 | vsnprintf(buf, 1024, fmt, ap); 49 | panic(legacy_exception(buf)); 50 | } 51 | 52 | void exception_handler_is(exception_handler_t h) { 53 | assert(h && "exception handler must not be null"); 54 | exception_handler = h; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /eos/mlag.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_MLAG_H 5 | #define EOS_MLAG_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace eos { 15 | 16 | class mlag_mgr; 17 | 18 | class EOS_SDK_PUBLIC mlag_handler : public base_handler { 19 | public: 20 | explicit mlag_handler(mlag_mgr *mgr); 21 | mlag_mgr * get_mlag_mgr() const; 22 | 23 | virtual void on_mlag_state(mlag_state_t); 24 | }; 25 | 26 | class EOS_SDK_PUBLIC mlag_mgr : public base_mgr { 27 | public: 28 | virtual ~mlag_mgr(); 29 | 30 | /// Returns whether or not MLAG is configured on this system 31 | virtual bool enabled() const = 0; 32 | /// Configures whether MLAG is enabled 33 | virtual void enabled_is(bool) = 0; 34 | 35 | /// Returns the configured IP address of our MLAG peer 36 | virtual ip_addr_t peer_address() const = 0; 37 | 38 | /// Returns the current operational state of our MLAG relationship 39 | virtual mlag_state_t state() const = 0; 40 | 41 | protected: 42 | mlag_mgr() EOS_SDK_PRIVATE; 43 | friend class mlag_handler; 44 | 45 | private: 46 | EOS_SDK_DISALLOW_COPY_CTOR(mlag_mgr); 47 | }; 48 | 49 | } 50 | 51 | #include 52 | 53 | #endif // EOS_MLAG_H 54 | -------------------------------------------------------------------------------- /examples/ReactorExample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | import eossdk 6 | import sys 7 | 8 | 9 | class MyIntfHandler( eossdk.AgentHandler, eossdk.IntfHandler ): 10 | def __init__( self, intfMgr, agentMgr ): 11 | eossdk.AgentHandler.__init__( self, agentMgr ) 12 | eossdk.IntfHandler.__init__( self, intfMgr ) # pylint: disable-msg=W0233 13 | self.intfMgr_ = intfMgr 14 | self.numIntfChanges_ = 0 15 | print( "Constructed" ) 16 | 17 | # Callback provided by AgentHandler when all state is synchronized 18 | def on_initialized( self ): 19 | print( "We are initialized!" ) 20 | self.watch_all_intfs( True ) # pylint: disable-msg=E1101 21 | 22 | # Callback provided by IntfHandler when an interface's configuration changes 23 | def on_oper_status( self, intfId, operState ): 24 | intfState = 'up' if operState == eossdk.INTF_OPER_UP else 'down' 25 | print( "The state of", intfId.to_string(), "is now", intfState ) 26 | self.numIntfChanges_ += 1 27 | print( " We have seen", self.numIntfChanges_, "state changes" ) 28 | self.intfMgr_.description_is(intfId, 29 | "Changed state [%d]" % self.numIntfChanges_) 30 | 31 | 32 | sdk = eossdk.Sdk() 33 | mta = MyIntfHandler( sdk.get_intf_mgr(), sdk.get_agent_mgr() ) 34 | sdk.main_loop( sys.argv ) 35 | -------------------------------------------------------------------------------- /vrf_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/vrf.h" 6 | #include "eos/types/vrf_impl.h" 7 | 8 | namespace eos { 9 | 10 | // Default constructor. 11 | vrf_t::vrf_t() : 12 | pimpl(std::make_shared()) {} 13 | vrf_t::vrf_t(std::string name, vrf_state_t state, uint64_t rd) : 14 | pimpl(std::make_shared( 15 | name, 16 | state, 17 | rd 18 | )) {} 19 | EOS_SDK_PUBLIC vrf_t::vrf_t( 20 | const vrf_t& other) : 21 | pimpl(std::make_shared( 22 | *other.pimpl)) {} 23 | EOS_SDK_PUBLIC vrf_t& 24 | vrf_t::operator=( 25 | vrf_t const & other) 26 | { 27 | if(this != &other) { 28 | pimpl = std::make_shared( 29 | *other.pimpl); 30 | } 31 | return *this; 32 | } 33 | 34 | EOS_SDK_PUBLIC vrf_t::vrf_t( 35 | vrf_t && other) noexcept : 36 | pimpl(std::move(other.pimpl)) {} 37 | EOS_SDK_PUBLIC vrf_t& 38 | vrf_t::operator=( 39 | vrf_t && other) noexcept 40 | { 41 | if(this != &other) { 42 | std::swap(pimpl, other.pimpl); 43 | } 44 | return *this; 45 | } 46 | 47 | EOS_SDK_PUBLIC void * 48 | vrf_t::operator new( std::size_t size ) { 49 | return ::operator new( size ); 50 | } 51 | EOS_SDK_PUBLIC void 52 | vrf_t::operator delete( void * p ) noexcept { 53 | ::operator delete( p ); 54 | } 55 | 56 | 57 | } // namespace eos 58 | -------------------------------------------------------------------------------- /mount_profile_eossdk_all: -------------------------------------------------------------------------------- 1 | agentName:EosSdk-%sliceId 2 | 3 | Include: EosSdk_acl.include 4 | Include: EosSdk_agent.include 5 | Include: EosSdk_bgp.include 6 | Include: EosSdk_bgp_path.include 7 | Include: EosSdk_class_map.include 8 | Include: EosSdk_decap_group.include 9 | Include: EosSdk_directflow.include 10 | Include: EosSdk_eth_intf.include 11 | Include: EosSdk_eth_lag_intf.include 12 | Include: EosSdk_eth_phy_intf.include 13 | Include: EosSdk_fib.include 14 | Include: EosSdk_hardware_table.include 15 | Include: EosSdk_intf.include 16 | Include: EosSdk_IntfMgrHelper.include 17 | Include: EosSdk_ip_intf.include 18 | Include: EosSdk_ip_route.include 19 | Include: EosSdk_l1_source.include 20 | Include: EosSdk_lldp.include 21 | Include: EosSdk_macsec.include 22 | Include: EosSdk_mac_table.include 23 | Include: EosSdk_mlag.include 24 | Include: EosSdk_mpls_route.include 25 | Include: EosSdk_mpls_vrf_label.include 26 | Include: EosSdk_neighbor_table.include 27 | Include: EosSdk_nexthop_group.include 28 | Include: EosSdk_policy_map.include 29 | Include: EosSdk_route_map.include 30 | Include: EosSdk_subintf.include 31 | Include: EosSdk_system.include 32 | Include: EosSdk_vrf.include 33 | Include: EosSdk_GOpenFlow.include 34 | Include: EosSdk_bfd_session.include 35 | Include: EosSdk_nexthop_group_tunnel.include 36 | 37 | # for mlag/status, Mlag::Status, r 38 | Include: MlagStatus-include 39 | 40 | # for interface support with EosSdk_IntfMgrHelper.include 41 | Include: AgentPlugin-IntfCollections-* 42 | -------------------------------------------------------------------------------- /nexthop_group_tunnel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/nexthop_group_tunnel.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class nexthop_group_tunnel_mgr_impl : public nexthop_group_tunnel_mgr { 10 | public: 11 | nexthop_group_tunnel_mgr_impl() { 12 | } 13 | 14 | void resync_init() { 15 | // TODO: No op impl 16 | } 17 | 18 | void resync_complete() { 19 | // TODO: No op impl 20 | } 21 | 22 | nexthop_group_tunnel_iter_t nexthop_group_tunnel_iter() const { 23 | nexthop_group_tunnel_iter_t * nop = 0; 24 | return *nop; // TODO: No op impl. 25 | } 26 | 27 | nexthop_group_tunnel_t nexthop_group_tunnel( 28 | ip_prefix_t const & tunnel_endpoint) const { 29 | return nexthop_group_tunnel_t(); 30 | } 31 | 32 | bool exists(ip_prefix_t const & tunnel_endpoint) const { 33 | return false; 34 | } 35 | 36 | void nexthop_group_tunnel_set(nexthop_group_tunnel_t const & tunnel) { 37 | // TODO: No op impl. 38 | } 39 | 40 | void nexthop_group_tunnel_del(ip_prefix_t const & tunnel_endpoint) { 41 | // TODO: No op impl. 42 | } 43 | }; 44 | 45 | DEFINE_STUB_MGR_CTOR(nexthop_group_tunnel_mgr); 46 | 47 | nexthop_group_tunnel_handler::nexthop_group_tunnel_handler( 48 | nexthop_group_tunnel_mgr *mgr) : 49 | base_handler(mgr) { 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /subintf_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/subintf.h" 6 | #include "eos/types/subintf_impl.h" 7 | 8 | namespace eos { 9 | 10 | // Default constructor. 11 | subintf_t::subintf_t() : 12 | pimpl(std::make_shared()) {} 13 | subintf_t::subintf_t(intf_id_t intf_id, vlan_id_t vlan_id) : 14 | pimpl(std::make_shared( 15 | intf_id, 16 | vlan_id 17 | )) {} 18 | EOS_SDK_PUBLIC subintf_t::subintf_t( 19 | const subintf_t& other) : 20 | pimpl(std::make_shared( 21 | *other.pimpl)) {} 22 | EOS_SDK_PUBLIC subintf_t& 23 | subintf_t::operator=( 24 | subintf_t const & other) 25 | { 26 | if(this != &other) { 27 | pimpl = std::make_shared( 28 | *other.pimpl); 29 | } 30 | return *this; 31 | } 32 | 33 | EOS_SDK_PUBLIC subintf_t::subintf_t( 34 | subintf_t && other) noexcept : 35 | pimpl(std::move(other.pimpl)) {} 36 | EOS_SDK_PUBLIC subintf_t& 37 | subintf_t::operator=( 38 | subintf_t && other) noexcept 39 | { 40 | if(this != &other) { 41 | std::swap(pimpl, other.pimpl); 42 | } 43 | return *this; 44 | } 45 | 46 | EOS_SDK_PUBLIC void * 47 | subintf_t::operator new( std::size_t size ) { 48 | return ::operator new( size ); 49 | } 50 | EOS_SDK_PUBLIC void 51 | subintf_t::operator delete( void * p ) noexcept { 52 | ::operator delete( p ); 53 | } 54 | 55 | 56 | } // namespace eos 57 | -------------------------------------------------------------------------------- /examples/InternalVlan.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * This example agent program displays changes to the 12 | * internal VLAN ID mappings via tracing. Compile it 13 | * and copy it to a switch and run it, e.g.,; 14 | * 15 | * $ scp InternalVlan switch:/mnt/flash/ 16 | * $ ssh switch 17 | * switch# bash 18 | * Arista Networks EOS shell 19 | * 20 | * $ TRACE="InternalVlanId*" /mnt/flash/InternalVlan 21 | */ 22 | 23 | class internal_vlan_id : public eos::agent_handler, 24 | public eos::ip_intf_handler { 25 | public: 26 | eos::tracer t; 27 | 28 | explicit internal_vlan_id(eos::sdk & sdk) 29 | : eos::agent_handler(sdk.get_agent_mgr()), 30 | eos::ip_intf_handler(sdk.get_ip_intf_mgr()), 31 | t("InternalVlanId") { 32 | t.trace0("Agent constructed"); 33 | watch_all_ip_intfs(true); 34 | } 35 | 36 | void on_initialized() { 37 | t.trace0("Initialized"); 38 | } 39 | 40 | void on_internal_vlan_id(eos::intf_id_t const & i, eos::vlan_id_t vlan_id) { 41 | t.trace0("on_internal_vlan_id: intf %s vlan_id %d", 42 | i.to_string().c_str(), vlan_id); 43 | } 44 | }; 45 | 46 | int main(int argc, char ** argv) { 47 | eos::sdk sdk; 48 | internal_vlan_id agent(sdk); 49 | sdk.main_loop(argc, argv); 50 | } 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Arista Networks Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /examples/example_base.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | // This file is a simple framework for constructing an agent. It does 10 | // nothing (except to emit some tracing), but contains the common 11 | // setup code that most agents will have in common. 12 | // 13 | // Make the agent using a 32-bit linux build environment: 14 | // bash# g++ -leos -std=gnu++14 examples/example_base.cpp -o exampleagent 15 | // Now you can transfer the binary to flash: on an EOS instance with 16 | // EosSdk.i686.rpm installed and run the agent from bash: 17 | // bash# TRACE=EosSdk* /mnt/flash/exampleagent 18 | // or from the CLI 19 | // (conf)# daemon example_agent 20 | // (conf-daemon-example_agent)# exec /mnt/flash/exampleagent 21 | // (conf-daemon-example_agent)# no shutdown 22 | 23 | 24 | class example_agent : public eos::agent_handler { 25 | public: 26 | explicit example_agent(eos::sdk & sdk) 27 | : t("example_agent"), 28 | eos::agent_handler(sdk.get_agent_mgr()) { 29 | t.trace0("Constructed agent"); 30 | // 31 | } 32 | 33 | void on_initialized() { 34 | t.trace0("Initialized agent"); 35 | // 36 | } 37 | 38 | // 39 | 40 | private: 41 | eos::tracer t; 42 | 43 | }; 44 | 45 | int main(int argc, char ** argv) { 46 | eos::sdk sdk; 47 | example_agent ex(sdk); 48 | sdk.main_loop(argc, argv); 49 | } 50 | -------------------------------------------------------------------------------- /ip_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/ip.h" 6 | #include "eos/types/ip_impl.h" 7 | 8 | namespace eos { 9 | 10 | ip_addr_mask_t::ip_addr_mask_t() : 11 | pimpl(std::make_shared()) {} 12 | ip_addr_mask_t::ip_addr_mask_t(ip_addr_t const & addr, uint8_t mask_length) : 13 | pimpl(std::make_shared( 14 | addr, 15 | mask_length 16 | )) {} 17 | EOS_SDK_PUBLIC ip_addr_mask_t::ip_addr_mask_t( 18 | const ip_addr_mask_t& other) : 19 | pimpl(std::make_shared( 20 | *other.pimpl)) {} 21 | EOS_SDK_PUBLIC ip_addr_mask_t& 22 | ip_addr_mask_t::operator=( 23 | ip_addr_mask_t const & other) 24 | { 25 | if(this != &other) { 26 | pimpl = std::make_shared( 27 | *other.pimpl); 28 | } 29 | return *this; 30 | } 31 | 32 | EOS_SDK_PUBLIC ip_addr_mask_t::ip_addr_mask_t( 33 | ip_addr_mask_t && other) noexcept : 34 | pimpl(std::move(other.pimpl)) {} 35 | EOS_SDK_PUBLIC ip_addr_mask_t& 36 | ip_addr_mask_t::operator=( 37 | ip_addr_mask_t && other) noexcept 38 | { 39 | if(this != &other) { 40 | std::swap(pimpl, other.pimpl); 41 | } 42 | return *this; 43 | } 44 | 45 | EOS_SDK_PUBLIC void * 46 | ip_addr_mask_t::operator new( std::size_t size ) { 47 | return ::operator new( size ); 48 | } 49 | EOS_SDK_PUBLIC void 50 | ip_addr_mask_t::operator delete( void * p ) noexcept { 51 | ::operator delete( p ); 52 | } 53 | 54 | 55 | } // namespace eos 56 | -------------------------------------------------------------------------------- /route_map.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/route_map.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class route_map_mgr_impl : public route_map_mgr { 10 | public: 11 | route_map_mgr_impl() { 12 | } 13 | 14 | route_map_t route_map(route_map_name_t const & name) const { 15 | return route_map_t(); // TODO: No op impl. 16 | } 17 | 18 | route_map_entry_t route_map_entry(route_map_name_t const & name, 19 | route_map_sequence_number_t sequence) const { 20 | return route_map_entry_t(); // TODO: No op impl. 21 | } 22 | 23 | void route_map_set(route_map_name_t const & name, 24 | route_map_t const & map) { 25 | // TODO: No op impl. 26 | } 27 | void route_map_entry_set(route_map_name_t const & name, 28 | route_map_sequence_number_t sequence, 29 | route_map_entry_t const & entry) { 30 | // TODO: No op impl. 31 | } 32 | 33 | void route_map_del(route_map_name_t const & name) { 34 | // TODO: No op impl. 35 | } 36 | 37 | void route_map_entry_del(route_map_name_t const & name, 38 | route_map_sequence_number_t sequence) { 39 | // TODO: No op impl. 40 | } 41 | 42 | uint8_t priority() const { 43 | return 0; // TODO: No op impl. 44 | } 45 | 46 | void priority_is(uint8_t priority) { 47 | // TODO: No op impl. 48 | } 49 | }; 50 | 51 | DEFINE_STUB_MGR_CTOR(route_map_mgr) 52 | 53 | } // namespace eos 54 | -------------------------------------------------------------------------------- /swig.patch: -------------------------------------------------------------------------------- 1 | # hunk 1: multi-inheritance is broken https://sourceforge.net/p/swig/bugs/1379/ 2 | # hunk 2: compilation issue on GCC 4.6 http://sourceforge.net/p/swig/patches/296/ 3 | # hunk 3: thread bug on iterators https://sourceforge.net/p/swig/bugs/1370/ 4 | --- eossdk_wrap.cpp-t 5 | +++ eossdk_wrap.cpp-t 6 | @@ -1599,6 +1599,10 @@ 7 | PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); 8 | return NULL; 9 | } 10 | + while (sobj->next && SwigPyObject_Check(sobj->next)) { 11 | + sobj = (SwigPyObject *)sobj->next; 12 | + } 13 | + ((SwigPyObject *)next)->next = sobj->next; 14 | sobj->next = next; 15 | Py_INCREF(next); 16 | return SWIG_Py_Void(); 17 | @@ -3403,6 +3407,7 @@ 18 | 19 | 20 | #include 21 | +#include 22 | 23 | 24 | namespace swig { 25 | @@ -3518,7 +3523,11 @@ 26 | } 27 | 28 | public: 29 | - virtual ~SwigPyIterator() {} 30 | + virtual ~SwigPyIterator() { 31 | + SWIG_PYTHON_THREAD_BEGIN_BLOCK; 32 | + _seq = 0; 33 | + SWIG_PYTHON_THREAD_END_BLOCK; 34 | + } 35 | 36 | // Access iterator method, required by Python 37 | virtual PyObject *value() const = 0; 38 | @@ -11477,7 +11477,7 @@ SWIGINTERN PyObject *_wrap__BitSet4096__ 39 | try { 40 | { 41 | SWIG_PYTHON_THREAD_BEGIN_ALLOW; 42 | - result = (bool)((std::bitset< 4096 > const *)arg1)->operator !=((std::bitset< 4096 > const &)*arg2); 43 | + result = !(bool)((std::bitset< 4096 > const *)arg1)->operator ==((std::bitset< 4096 > const &)*arg2); 44 | SWIG_PYTHON_THREAD_END_ALLOW; 45 | } 46 | } catch (error const & e) { 47 | -------------------------------------------------------------------------------- /bgp_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/bgp.h" 6 | #include "eos/types/bgp_impl.h" 7 | 8 | namespace eos { 9 | 10 | bgp_peer_key_t::bgp_peer_key_t() : 11 | pimpl(std::make_shared()) {} 12 | bgp_peer_key_t::bgp_peer_key_t(std::string const & vrf_name, 13 | ip_addr_t const & peer_addr) : 14 | pimpl(std::make_shared( 15 | vrf_name, 16 | peer_addr 17 | )) {} 18 | EOS_SDK_PUBLIC bgp_peer_key_t::bgp_peer_key_t( 19 | const bgp_peer_key_t& other) : 20 | pimpl(std::make_shared( 21 | *other.pimpl)) {} 22 | EOS_SDK_PUBLIC bgp_peer_key_t& 23 | bgp_peer_key_t::operator=( 24 | bgp_peer_key_t const & other) 25 | { 26 | if(this != &other) { 27 | pimpl = std::make_shared( 28 | *other.pimpl); 29 | } 30 | return *this; 31 | } 32 | 33 | EOS_SDK_PUBLIC bgp_peer_key_t::bgp_peer_key_t( 34 | bgp_peer_key_t && other) noexcept : 35 | pimpl(std::move(other.pimpl)) {} 36 | EOS_SDK_PUBLIC bgp_peer_key_t& 37 | bgp_peer_key_t::operator=( 38 | bgp_peer_key_t && other) noexcept 39 | { 40 | if(this != &other) { 41 | std::swap(pimpl, other.pimpl); 42 | } 43 | return *this; 44 | } 45 | 46 | EOS_SDK_PUBLIC void * 47 | bgp_peer_key_t::operator new( std::size_t size ) { 48 | return ::operator new( size ); 49 | } 50 | EOS_SDK_PUBLIC void 51 | bgp_peer_key_t::operator delete( void * p ) noexcept { 52 | ::operator delete( p ); 53 | } 54 | 55 | 56 | } // namespace eos 57 | -------------------------------------------------------------------------------- /eos/types/vrf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_VRF_IMPL_H 5 | #define EOS_TYPES_VRF_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace eos { 13 | 14 | /** @deprecated. This data structure is used to describe a VRF on a switch. */ 15 | class EOS_SDK_PUBLIC vrf_impl_t { 16 | public: 17 | vrf_impl_t(); 18 | vrf_impl_t(std::string name, vrf_state_t state, uint64_t rd); 19 | 20 | /** Getter for 'name': the name of the VRF. */ 21 | std::string name() const; 22 | 23 | /** Getter for 'state': the state of this VRF. */ 24 | vrf_state_t state() const; 25 | 26 | /** Getter for 'rd': the route distinguisher of the VRF. */ 27 | uint64_t rd() const; 28 | 29 | bool operator==(vrf_impl_t const & other) const; 30 | bool operator!=(vrf_impl_t const & other) const; 31 | bool operator<(vrf_impl_t const & other) const; 32 | /** The hash function for type vrf_t. */ 33 | uint32_t hash() const; 34 | /** The hash mix function for type vrf_t. */ 35 | void mix_me(hash_mix & h) const; 36 | /** Returns a string representation of the current object's values. */ 37 | std::string to_string() const; 38 | /** 39 | * A utility stream operator that adds a string representation of vrf_t to the 40 | * ostream. 41 | */ 42 | friend std::ostream& operator<<(std::ostream& os, const vrf_impl_t& obj); 43 | 44 | private: 45 | std::string name_; 46 | vrf_state_t state_; 47 | uint64_t rd_; 48 | }; 49 | } 50 | 51 | #endif // EOS_TYPES_VRF_IMPL_H 52 | -------------------------------------------------------------------------------- /eos/types/subintf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_SUBINTF_IMPL_H 5 | #define EOS_TYPES_SUBINTF_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace eos { 15 | 16 | /** This data structure defines a subinterface. */ 17 | class EOS_SDK_PUBLIC subintf_impl_t { 18 | public: 19 | subintf_impl_t(); 20 | subintf_impl_t(intf_id_t intf_id, vlan_id_t vlan_id); 21 | 22 | /** Getter for 'intf_id': the interface ID of this subinterface. */ 23 | intf_id_t intf_id() const; 24 | 25 | /** Getter for 'vlan_id': the VLAN tag of this subinterface. */ 26 | vlan_id_t vlan_id() const; 27 | /** Setter for 'vlan_id'. */ 28 | void vlan_id_is(vlan_id_t vlan_id); 29 | 30 | bool operator==(subintf_impl_t const & other) const; 31 | bool operator!=(subintf_impl_t const & other) const; 32 | /** The hash function for type subintf_t. */ 33 | uint32_t hash() const; 34 | /** The hash mix function for type subintf_t. */ 35 | void mix_me(hash_mix & h) const; 36 | /** Returns a string representation of the current object's values. */ 37 | std::string to_string() const; 38 | /** 39 | * A utility stream operator that adds a string representation of subintf_t to 40 | * the ostream. 41 | */ 42 | friend std::ostream& operator<<(std::ostream& os, const subintf_impl_t& obj); 43 | 44 | private: 45 | intf_id_t intf_id_; 46 | vlan_id_t vlan_id_; 47 | }; 48 | } 49 | 50 | #endif // EOS_TYPES_SUBINTF_IMPL_H 51 | -------------------------------------------------------------------------------- /mpls_vrf_label_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/mpls_vrf_label.h" 6 | #include "eos/types/mpls_vrf_label_impl.h" 7 | 8 | namespace eos { 9 | 10 | // Default constructor. 11 | mpls_vrf_label_t::mpls_vrf_label_t() : 12 | pimpl(std::make_shared()) {} 13 | mpls_vrf_label_t::mpls_vrf_label_t(mpls_label_t label, std::string vrf_name) : 14 | pimpl(std::make_shared( 15 | label, 16 | vrf_name 17 | )) {} 18 | EOS_SDK_PUBLIC mpls_vrf_label_t::mpls_vrf_label_t( 19 | const mpls_vrf_label_t& other) : 20 | pimpl(std::make_shared( 21 | *other.pimpl)) {} 22 | EOS_SDK_PUBLIC mpls_vrf_label_t& 23 | mpls_vrf_label_t::operator=( 24 | mpls_vrf_label_t const & other) 25 | { 26 | if(this != &other) { 27 | pimpl = std::make_shared( 28 | *other.pimpl); 29 | } 30 | return *this; 31 | } 32 | 33 | EOS_SDK_PUBLIC mpls_vrf_label_t::mpls_vrf_label_t( 34 | mpls_vrf_label_t && other) noexcept : 35 | pimpl(std::move(other.pimpl)) {} 36 | EOS_SDK_PUBLIC mpls_vrf_label_t& 37 | mpls_vrf_label_t::operator=( 38 | mpls_vrf_label_t && other) noexcept 39 | { 40 | if(this != &other) { 41 | std::swap(pimpl, other.pimpl); 42 | } 43 | return *this; 44 | } 45 | 46 | EOS_SDK_PUBLIC void * 47 | mpls_vrf_label_t::operator new( std::size_t size ) { 48 | return ::operator new( size ); 49 | } 50 | EOS_SDK_PUBLIC void 51 | mpls_vrf_label_t::operator delete( void * p ) noexcept { 52 | ::operator delete( p ); 53 | } 54 | 55 | 56 | } // namespace eos 57 | -------------------------------------------------------------------------------- /eos/inline/types/vrf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_VRF_H 5 | #define EOS_INLINE_TYPES_VRF_H 6 | 7 | namespace eos { 8 | 9 | EOS_SDK_PUBLIC std::ostream& 10 | operator<<(std::ostream& os, const vrf_state_t & enum_val) { 11 | if (enum_val==VRF_NULL) { 12 | os << "VRF_NULL"; 13 | } else if (enum_val==VRF_INITIALIZING) { 14 | os << "VRF_INITIALIZING"; 15 | } else if (enum_val==VRF_ACTIVE) { 16 | os << "VRF_ACTIVE"; 17 | } else if (enum_val==VRF_DELETING) { 18 | os << "VRF_DELETING"; 19 | } else { 20 | os << "Unknown value"; 21 | } 22 | return os; 23 | } 24 | 25 | 26 | std::string 27 | vrf_t::name() const { 28 | return pimpl->name(); 29 | } 30 | vrf_state_t 31 | vrf_t::state() const { 32 | return pimpl->state(); 33 | } 34 | uint64_t 35 | vrf_t::rd() const { 36 | return pimpl->rd(); 37 | } 38 | bool 39 | vrf_t::operator==(vrf_t const & other) const { 40 | return pimpl->operator==(*other.pimpl); 41 | } 42 | bool 43 | vrf_t::operator!=(vrf_t const & other) const { 44 | return pimpl->operator!=(*other.pimpl); 45 | } 46 | bool 47 | vrf_t::operator<(vrf_t const & other) const { 48 | return pimpl->operator<(*other.pimpl); 49 | } 50 | uint32_t 51 | vrf_t::hash() const { 52 | return pimpl->hash(); 53 | } 54 | void 55 | vrf_t::mix_me(hash_mix & h) const { 56 | pimpl->mix_me(h); 57 | } 58 | std::string 59 | vrf_t::to_string() const { 60 | return pimpl->to_string(); 61 | } 62 | std::ostream& 63 | operator<<(std::ostream& os, const vrf_t& obj) { 64 | return operator<<(os, *obj.pimpl); 65 | } 66 | 67 | } 68 | 69 | #endif // EOS_INLINE_TYPES_VRF_H 70 | -------------------------------------------------------------------------------- /eos/types/mpls_vrf_label_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_MPLS_VRF_LABEL_IMPL_H 5 | #define EOS_TYPES_MPLS_VRF_LABEL_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace eos { 14 | 15 | /** A static VRF label decap route configuration model. */ 16 | class EOS_SDK_PUBLIC mpls_vrf_label_impl_t { 17 | public: 18 | mpls_vrf_label_impl_t(); 19 | mpls_vrf_label_impl_t(mpls_label_t label, std::string vrf_name); 20 | 21 | /** Getter for 'label': the decap label. */ 22 | mpls_label_t label() const; 23 | 24 | /** Getter for 'vrf_name': the name of the VRF. */ 25 | std::string vrf_name() const; 26 | 27 | bool operator==(mpls_vrf_label_impl_t const & other) const; 28 | bool operator!=(mpls_vrf_label_impl_t const & other) const; 29 | bool operator<(mpls_vrf_label_impl_t const & other) const; 30 | /** The hash function for type mpls_vrf_label_t. */ 31 | uint32_t hash() const; 32 | /** The hash mix function for type mpls_vrf_label_t. */ 33 | void mix_me(hash_mix & h) const; 34 | /** Returns a string representation of the current object's values. */ 35 | std::string to_string() const; 36 | /** 37 | * A utility stream operator that adds a string representation of 38 | * mpls_vrf_label_t to the ostream. 39 | */ 40 | friend std::ostream& operator<<(std::ostream& os, 41 | const mpls_vrf_label_impl_t& obj); 42 | 43 | private: 44 | mpls_label_t label_; 45 | std::string vrf_name_; 46 | }; 47 | } 48 | 49 | #endif // EOS_TYPES_MPLS_VRF_LABEL_IMPL_H 50 | -------------------------------------------------------------------------------- /examples/libevent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "libevent.h" 9 | 10 | void 11 | libevent_loop::init() { 12 | loop_->wait_for_initialized(); 13 | loop_->external_loop_is(this); 14 | } 15 | 16 | static void cb_read(evutil_socket_t fd, short /*what*/, void *arg) { 17 | ((libevent_loop*) arg)->on_readable(fd); 18 | } 19 | 20 | void 21 | libevent_loop::watch_readable(int fd, bool interested) { 22 | assert(interested); // TODO: support unregistering an fd. 23 | struct event * ev = event_new(eb_, fd, EV_READ|EV_PERSIST, cb_read, this); 24 | event_add(ev, NULL); 25 | } 26 | 27 | static void cb_write(evutil_socket_t fd, short /*what*/, void *arg) { 28 | ((libevent_loop*) arg)->on_writable(fd); 29 | } 30 | 31 | void 32 | libevent_loop::watch_writable(int fd, bool interested) { 33 | assert(interested); // TODO: support unregistering an fd. 34 | struct event * ev = event_new(eb_, fd, EV_WRITE|EV_PERSIST, cb_write, this); 35 | event_add(ev, NULL); 36 | } 37 | 38 | void 39 | libevent_loop::watch_exception(int fd, bool interested) { 40 | // libevent doesn't allow watching just for "exceptions". Rather when a 41 | // connection is closed, we'll be notified the fd is "readable" and we'll 42 | // read EOF. 43 | watch_readable(fd, interested); 44 | } 45 | 46 | static void cb_timer(evutil_socket_t fd, short /*what*/, void *arg) { 47 | ((libevent_loop*) arg)->on_timeout(); 48 | } 49 | 50 | void 51 | libevent_loop::timeout_time_is(struct timeval deadline) { 52 | struct event * ev = evtimer_new(eb_, cb_timer, this); 53 | event_add(ev, &deadline); 54 | } 55 | -------------------------------------------------------------------------------- /directflow.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/directflow.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | // 10 | // flow_handler 11 | // 12 | 13 | flow_handler::flow_handler(directflow_mgr * mgr) : 14 | base_handler(mgr) { 15 | // TODO 16 | } 17 | 18 | void 19 | flow_handler::watch_all_flows(bool should_watch) { 20 | } 21 | 22 | void flow_handler::watch_flow(std::string const &, bool) { 23 | } 24 | 25 | void 26 | flow_handler::on_flow_status(const std::string & name, flow_status_t status) { 27 | } 28 | 29 | // 30 | // directflow_mgr 31 | // 32 | 33 | class directflow_mgr_impl : public directflow_mgr { 34 | public: 35 | directflow_mgr_impl() { 36 | } 37 | 38 | flow_entry_iter_t flow_entry_iter() const { 39 | flow_entry_iter_t * nop = 0; 40 | return *nop; // TODO: No op impl. 41 | } 42 | 43 | bool exists(std::string const & name) const { 44 | return false; 45 | } 46 | 47 | flow_entry_t flow_entry(std::string const & name) const { 48 | return flow_entry_t(); 49 | } 50 | 51 | void flow_entry_set(flow_entry_t const & flow_entry) { 52 | } 53 | 54 | void flow_entry_del(std::string const & name) { 55 | } 56 | 57 | flow_counters_t flow_counters(std::string const & name) const { 58 | return flow_counters_t(); 59 | } 60 | 61 | flow_status_t flow_status(std::string const & name) const { 62 | return FLOW_STATUS_UNKNOWN; 63 | } 64 | 65 | flow_rejected_reason_t flow_rejected_reason(std::string const & name) const { 66 | return FLOW_REJECTED_OTHER; 67 | } 68 | 69 | }; 70 | 71 | DEFINE_STUB_MGR_CTOR(directflow_mgr) 72 | 73 | } 74 | -------------------------------------------------------------------------------- /neighbor_table.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/neighbor_table.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class neighbor_table_mgr_impl : public neighbor_table_mgr { 10 | public: 11 | neighbor_table_mgr_impl() { 12 | } 13 | 14 | neighbor_table_iter_t neighbor_table_iter() const { 15 | neighbor_table_iter_t * nop = 0; 16 | return *nop; 17 | } 18 | 19 | neighbor_table_status_iter_t neighbor_table_status_iter() const { 20 | neighbor_table_status_iter_t * nop = 0; 21 | return *nop; 22 | } 23 | 24 | virtual neighbor_entry_t neighbor_entry_status(neighbor_key_t const & key) const { 25 | return neighbor_entry_t(); 26 | } 27 | 28 | virtual void neighbor_entry_set(neighbor_entry_t const & entry) {} 29 | virtual void neighbor_entry_del(neighbor_key_t const & key) {} 30 | 31 | virtual neighbor_entry_t neighbor_entry( 32 | neighbor_key_t const & key) const { 33 | return neighbor_entry_t(); 34 | } 35 | 36 | 37 | }; 38 | 39 | DEFINE_STUB_MGR_CTOR(neighbor_table_mgr) 40 | 41 | neighbor_table_handler::neighbor_table_handler(neighbor_table_mgr *mgr) : 42 | base_handler(mgr) { 43 | } 44 | void neighbor_table_handler::watch_all_neighbor_entries(bool interest) { 45 | } 46 | void neighbor_table_handler::watch_neighbor_entry(neighbor_key_t const & key, 47 | bool interest) { 48 | } 49 | void neighbor_table_handler::on_neighbor_entry_del(neighbor_key_t const & key) { 50 | } 51 | void neighbor_table_handler::on_neighbor_entry_set(neighbor_entry_t const & entry) { 52 | } 53 | 54 | } // end eos namespace 55 | -------------------------------------------------------------------------------- /xcvr.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/xcvr.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class xcvr_mgr_impl : public xcvr_mgr { 10 | public: 11 | xcvr_mgr_impl() { 12 | } 13 | 14 | void frequency_is( intf_id_t intf_id, uint32_t rx, uint32_t tx ) { 15 | } 16 | 17 | void rx_fine_frequency_is( intf_id_t intf_id, float freq ) { 18 | } 19 | 20 | void rx_frequency_is( intf_id_t intf_id, uint32_t freq ) { 21 | } 22 | 23 | void tx_frequency_is( intf_id_t intf_id, uint32_t freq ) { 24 | } 25 | 26 | void tx_disabled_is( intf_id_t intf_id, bool disabled ) { 27 | } 28 | 29 | void tx_output_power_is( intf_id_t intf_id, float power ) { 30 | } 31 | 32 | int32_t tx_turnup_state( intf_id_t intf_id ) const { 33 | return 0; 34 | } 35 | int32_t rx_turnup_state( intf_id_t intf_id ) const { 36 | return 0; 37 | } 38 | int32_t register_read( intf_id_t intf_id, uint16_t addr, 39 | std::string location = "" ) const { 40 | return 0; 41 | } 42 | 43 | float rx_fine_frequency( intf_id_t intf_id ) const { 44 | return 0.0; 45 | } 46 | uint32_t rx_frequency( intf_id_t intf_id ) const { 47 | return 0; 48 | } 49 | uint32_t tx_frequency( intf_id_t intf_id ) const { 50 | return 0; 51 | } 52 | bool tx_disabled( intf_id_t intf_id ) const { 53 | return false; 54 | } 55 | float tx_output_power( intf_id_t intf_id ) const { 56 | return 0.0; 57 | } 58 | 59 | }; 60 | 61 | DEFINE_STUB_MGR_CTOR( xcvr_mgr ) 62 | 63 | } // end namespace eos 64 | -------------------------------------------------------------------------------- /decap_group_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/decap_group.h" 6 | #include "eos/types/decap_group_impl.h" 7 | 8 | namespace eos { 9 | 10 | // Default constructor, sets NULL protocol type. 11 | decap_group_t::decap_group_t() : 12 | pimpl(std::make_shared()) {} 13 | decap_group_t::decap_group_t(std::string const & group_name, 14 | ip_addr_t const & destination_addr, 15 | decap_protocol_type_t protocol_type) : 16 | pimpl(std::make_shared( 17 | group_name, 18 | destination_addr, 19 | protocol_type 20 | )) {} 21 | EOS_SDK_PUBLIC decap_group_t::decap_group_t( 22 | const decap_group_t& other) : 23 | pimpl(std::make_shared( 24 | *other.pimpl)) {} 25 | EOS_SDK_PUBLIC decap_group_t& 26 | decap_group_t::operator=( 27 | decap_group_t const & other) 28 | { 29 | if(this != &other) { 30 | pimpl = std::make_shared( 31 | *other.pimpl); 32 | } 33 | return *this; 34 | } 35 | 36 | EOS_SDK_PUBLIC decap_group_t::decap_group_t( 37 | decap_group_t && other) noexcept : 38 | pimpl(std::move(other.pimpl)) {} 39 | EOS_SDK_PUBLIC decap_group_t& 40 | decap_group_t::operator=( 41 | decap_group_t && other) noexcept 42 | { 43 | if(this != &other) { 44 | std::swap(pimpl, other.pimpl); 45 | } 46 | return *this; 47 | } 48 | 49 | EOS_SDK_PUBLIC void * 50 | decap_group_t::operator new( std::size_t size ) { 51 | return ::operator new( size ); 52 | } 53 | EOS_SDK_PUBLIC void 54 | decap_group_t::operator delete( void * p ) noexcept { 55 | ::operator delete( p ); 56 | } 57 | 58 | 59 | } // namespace eos 60 | -------------------------------------------------------------------------------- /eapi_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/eapi.h" 6 | #include "eos/types/eapi_impl.h" 7 | 8 | namespace eos { 9 | 10 | eapi_response_t::eapi_response_t() : 11 | pimpl(std::make_shared()) {} 12 | eapi_response_t::eapi_response_t(bool success, uint32_t error_code, 13 | std::string const & error_message, 14 | std::vector const & responses) : 15 | pimpl(std::make_shared( 16 | success, 17 | error_code, 18 | error_message, 19 | responses 20 | )) {} 21 | EOS_SDK_PUBLIC eapi_response_t::eapi_response_t( 22 | const eapi_response_t& other) : 23 | pimpl(std::make_shared( 24 | *other.pimpl)) {} 25 | EOS_SDK_PUBLIC eapi_response_t& 26 | eapi_response_t::operator=( 27 | eapi_response_t const & other) 28 | { 29 | if(this != &other) { 30 | pimpl = std::make_shared( 31 | *other.pimpl); 32 | } 33 | return *this; 34 | } 35 | 36 | EOS_SDK_PUBLIC eapi_response_t::eapi_response_t( 37 | eapi_response_t && other) noexcept : 38 | pimpl(std::move(other.pimpl)) {} 39 | EOS_SDK_PUBLIC eapi_response_t& 40 | eapi_response_t::operator=( 41 | eapi_response_t && other) noexcept 42 | { 43 | if(this != &other) { 44 | std::swap(pimpl, other.pimpl); 45 | } 46 | return *this; 47 | } 48 | 49 | EOS_SDK_PUBLIC void * 50 | eapi_response_t::operator new( std::size_t size ) { 51 | return ::operator new( size ); 52 | } 53 | EOS_SDK_PUBLIC void 54 | eapi_response_t::operator delete( void * p ) noexcept { 55 | ::operator delete( p ); 56 | } 57 | 58 | 59 | } // namespace eos 60 | -------------------------------------------------------------------------------- /bgp_path.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/bgp_path.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class bgp_path_mgr_impl : public bgp_path_mgr { 10 | public: 11 | bgp_path_iter_t ipv4_unicast_path_iter(bgp_path_options_t & options) const { 12 | bgp_path_iter_t *nop = 0; 13 | return *nop; 14 | } 15 | 16 | bgp_path_t ipv4_unicast_path(bgp_path_key_t const & path_key, 17 | bgp_path_options_t & options) { 18 | return bgp_path_t(); 19 | } 20 | 21 | bool ipv4_unicast_bgp_convergence() { 22 | return false; 23 | } 24 | 25 | bgp_path_iter_t ipv6_unicast_path_iter(bgp_path_options_t & options) const { 26 | bgp_path_iter_t *nop = 0; 27 | return *nop; 28 | } 29 | 30 | bgp_path_t ipv6_unicast_path(bgp_path_key_t const & path_key, 31 | bgp_path_options_t & options) { 32 | return bgp_path_t(); 33 | } 34 | 35 | bool ipv6_unicast_bgp_convergence() { 36 | return false; 37 | } 38 | }; 39 | 40 | DEFINE_STUB_MGR_CTOR(bgp_path_mgr) 41 | 42 | bgp_path_handler::bgp_path_handler(bgp_path_mgr * mgr) : 43 | base_handler(mgr) { 44 | } 45 | 46 | void bgp_path_handler::watch_all_paths(bool) {} 47 | 48 | void bgp_path_handler::watch_ipv4_unicast_paths(bool) {} 49 | 50 | void bgp_path_handler::watch_ipv6_unicast_paths(bool) {} 51 | 52 | void bgp_path_handler::on_ipv4_unicast_path(bgp_path_key_t const & path_key) {} 53 | 54 | void bgp_path_handler::on_ipv4_unicast_bgp_converged(bool converged) {} 55 | 56 | void bgp_path_handler::on_ipv6_unicast_path(bgp_path_key_t const & path_key) {} 57 | 58 | void bgp_path_handler::on_ipv6_unicast_bgp_converged(bool converged) {} 59 | 60 | } // namespace eos 61 | -------------------------------------------------------------------------------- /hardware_table.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/hardware_table.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class hardware_table_mgr_impl : public hardware_table_mgr { 10 | public: 11 | hardware_table_mgr_impl() { 12 | } 13 | 14 | virtual bool exists(hardware_table_key_t const & key) const { 15 | return false; 16 | } 17 | 18 | virtual hardware_table_iter_t hardware_table_iter() const { 19 | hardware_table_iter_t * nop = 0; 20 | return *nop; 21 | } 22 | 23 | virtual hardware_table_usage_t usage(hardware_table_key_t const & key) const { 24 | return hardware_table_usage_t(); 25 | } 26 | 27 | virtual uint32_t max_entries(hardware_table_key_t const & key) const { 28 | return 0; 29 | } 30 | 31 | virtual hardware_table_high_watermark_t 32 | high_watermark(hardware_table_key_t const & key) const { 33 | return hardware_table_high_watermark_t(); 34 | } 35 | }; 36 | 37 | DEFINE_STUB_MGR_CTOR(hardware_table_mgr) 38 | 39 | hardware_table_handler::hardware_table_handler(hardware_table_mgr *mgr) : 40 | base_handler(mgr) {} 41 | 42 | void hardware_table_handler::watch_all_hardware_tables(bool enable) {} 43 | 44 | void hardware_table_handler::watch_hardware_table(hardware_table_key_t const & key, 45 | bool enable) {} 46 | 47 | void hardware_table_handler::on_hardware_table_entry_set( 48 | hardware_table_key_t const & key, 49 | hardware_table_entry_t const & entry) {} 50 | 51 | void hardware_table_handler::on_hardware_table_entry_del( 52 | hardware_table_key_t const & key) {} 53 | 54 | } // end eos namespace 55 | -------------------------------------------------------------------------------- /eos/inline/types/subintf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_SUBINTF_IMPL_H 5 | #define EOS_INLINE_TYPES_SUBINTF_IMPL_H 6 | 7 | namespace eos { 8 | 9 | // Default constructor. 10 | subintf_impl_t::subintf_impl_t() : 11 | intf_id_(intf_id_t()), vlan_id_(vlan_id_t()) { 12 | } 13 | 14 | subintf_impl_t::subintf_impl_t(intf_id_t intf_id, vlan_id_t vlan_id) : 15 | intf_id_(intf_id), vlan_id_(vlan_id) { 16 | } 17 | 18 | intf_id_t 19 | subintf_impl_t::intf_id() const { 20 | return intf_id_; 21 | } 22 | 23 | vlan_id_t 24 | subintf_impl_t::vlan_id() const { 25 | return vlan_id_; 26 | } 27 | 28 | void 29 | subintf_impl_t::vlan_id_is(vlan_id_t vlan_id) { 30 | vlan_id_ = vlan_id; 31 | } 32 | 33 | bool 34 | subintf_impl_t::operator==(subintf_impl_t const & other) const { 35 | return intf_id_ == other.intf_id_ && 36 | vlan_id_ == other.vlan_id_; 37 | } 38 | 39 | bool 40 | subintf_impl_t::operator!=(subintf_impl_t const & other) const { 41 | return !operator==(other); 42 | } 43 | 44 | uint32_t 45 | subintf_impl_t::hash() const { 46 | hash_mix h; 47 | mix_me(h); 48 | return h.result(); 49 | } 50 | 51 | void 52 | subintf_impl_t::mix_me(hash_mix & h) const { 53 | h.mix(intf_id_); // intf_id_t 54 | h.mix(vlan_id_); // vlan_id_t 55 | } 56 | 57 | std::string 58 | subintf_impl_t::to_string() const { 59 | std::ostringstream ss; 60 | ss << "subintf_t("; 61 | ss << "intf_id=" << intf_id_; 62 | ss << ", vlan_id=" << vlan_id_; 63 | ss << ")"; 64 | return ss.str(); 65 | } 66 | 67 | std::ostream& 68 | operator<<(std::ostream& os, const subintf_impl_t& obj) { 69 | os << obj.to_string(); 70 | return os; 71 | } 72 | 73 | 74 | } 75 | 76 | #include 77 | 78 | #endif // EOS_INLINE_TYPES_SUBINTF_IMPL_H 79 | -------------------------------------------------------------------------------- /eth_types.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/eth.h" 5 | #include 6 | #include 7 | #include 8 | 9 | namespace eos { 10 | 11 | eth_addr_t::eth_addr_t(char const * addr) : 12 | bytes_{} { 13 | eos::eth_addr_t_to_bytes(addr, bytes_); 14 | } 15 | 16 | eth_addr_t::eth_addr_t(std::string const & addr) : 17 | bytes_{} { 18 | eos::eth_addr_t_to_bytes(addr.c_str(), bytes_); 19 | } 20 | 21 | bool 22 | eth_addr_t::operator<(eth_addr_t other) const { 23 | return memcmp(bytes_, other.bytes_, 6) < 0; 24 | } 25 | 26 | uint8_t 27 | eth_addr_t::byte(int index) const { 28 | 29 | if (0 <= index && index <= 5) { 30 | return bytes_[index]; 31 | } 32 | assert(!"invalid byte index, must be in [0; 5]."); 33 | 34 | } 35 | 36 | void 37 | eth_addr_t::bytes(void * arr) const { 38 | memcpy(arr, bytes_, sizeof(bytes_)); 39 | } 40 | 41 | bool 42 | eth_addr_t::is_unicast() const { 43 | return ((bytes_[0] & 0x01) == 0); 44 | } 45 | 46 | bool 47 | eth_addr_t::is_multicast() const { 48 | return (!is_unicast() && !is_broadcast()); 49 | } 50 | 51 | bool 52 | eth_addr_t::is_broadcast() const { 53 | 54 | return (bytes_[0] == 0xff && bytes_[1] == 0xff && 55 | bytes_[2] == 0xff && bytes_[3] == 0xff && 56 | bytes_[4] == 0xff && bytes_[5] == 0xff); 57 | } 58 | 59 | 60 | 61 | 62 | static inline std::string 63 | internal_vlan_error_msg(vlan_id_t vlan) { 64 | std::stringstream str; 65 | str << "VLAN " << vlan << "is an internal VLAN and cannot be used on" 66 | " a trunk port"; 67 | return str.str(); 68 | } 69 | 70 | 71 | 72 | internal_vlan_error::internal_vlan_error(vlan_id_t vlan) noexcept : 73 | configuration_error(internal_vlan_error_msg(vlan)), vlan_(vlan) { 74 | 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /eos/hash_mix.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_SDK_HASH_MIX 5 | #define EOS_SDK_HASH_MIX 6 | 7 | #include 8 | #include 9 | 10 | namespace eos { 11 | 12 | /** 13 | * This is a helper class for incrementally-computed implementation of Bob 14 | * Jenkins' one-at-a-time hash, in C++. It's needed in hash function. 15 | */ 16 | 17 | class EOS_SDK_PUBLIC hash_mix { 18 | public: 19 | hash_mix(); 20 | uint32_t result() const; 21 | 22 | void mix(bool val); 23 | void mix(double val); 24 | void mix(float val); 25 | 26 | void mix(uint8_t val); 27 | void mix(uint16_t val); 28 | void mix(uint32_t val); 29 | void mix(uint64_t val); 30 | 31 | void mix(int8_t val); 32 | void mix(int16_t val); 33 | void mix(int32_t val); 34 | void mix(int64_t val); 35 | 36 | void mix(std::string const & val); 37 | 38 | // Mix enums 39 | template< typename T > 40 | typename std::enable_if< std::is_enum< T >::value >::type mix(T const & t) { 41 | mix(static_cast< typename std::underlying_type< T >::type >(t)); 42 | } 43 | 44 | // Mix scalar types like long not explicitly listed above. 45 | template< typename T > 46 | typename std::enable_if< std::is_integral< T >::value >::type mix(T const & t) { 47 | mix_bytes((uint8_t *) &t, sizeof(t)); 48 | } 49 | 50 | // Mix EosSdk types with mix_me method. 51 | template< typename T > 52 | typename std::enable_if< !std::is_integral< T >::value && 53 | !std::is_enum< T >::value >::type mix(T const & t) { 54 | t.mix_me(*this); 55 | } 56 | 57 | // Mix an array of bytes. 58 | void mix_bytes(uint8_t const *key, int len); 59 | 60 | private: 61 | uint32_t val_; 62 | }; 63 | 64 | } 65 | 66 | #include 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /ip_intf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/exception.h" 5 | #include "eos/intf.h" 6 | #include "eos/ip.h" 7 | #include "eos/ip_intf.h" 8 | #include "eos/panic.h" 9 | #include "impl.h" 10 | 11 | namespace eos { 12 | 13 | // 14 | // ip_intf_handler implementations 15 | // 16 | // 17 | ip_intf_handler::ip_intf_handler(ip_intf_mgr * mgr) 18 | : base_handler(mgr) { 19 | // TODO: No op impl. 20 | } 21 | 22 | void ip_intf_handler::watch_all_ip_intfs(bool interest) { 23 | // TODO: No op impl. 24 | } 25 | 26 | void ip_intf_handler::watch_ip_intf(intf_id_t i, bool interest) { 27 | // TODO: No op impl. 28 | } 29 | 30 | // Dummy implementations for virtual handler methods 31 | void ip_intf_handler::on_ip_addr_add(intf_id_t, ip_addr_mask_t const &) {} 32 | void ip_intf_handler::on_ip_addr_del(intf_id_t, ip_addr_mask_t const &) {} 33 | void ip_intf_handler::on_internal_vlan_id(intf_id_t, vlan_id_t new_vlan) {} 34 | 35 | class ip_intf_mgr_impl : public ip_intf_mgr { 36 | public: 37 | ip_intf_mgr_impl() { 38 | } 39 | 40 | bool exists(intf_id_t) const { 41 | return false; 42 | } 43 | 44 | std::set ip_addrs(intf_id_t) const { 45 | return std::set(); 46 | } 47 | 48 | void ip_addrs_is(intf_id_t, std::set const &) { 49 | } 50 | 51 | void ip_addr_add(intf_id_t, ip_addr_mask_t const &) { 52 | } 53 | 54 | void ip_addr_del(intf_id_t, ip_addr_mask_t const &) { 55 | } 56 | 57 | void ip_addr_merge_mode_is(intf_id_t, bool) { 58 | } 59 | 60 | bool ip_addr_merge_mode(intf_id_t) const { 61 | return false; 62 | } 63 | 64 | vlan_id_t internal_vlan_id(intf_id_t) const { 65 | return vlan_id_t(123); 66 | } 67 | }; 68 | 69 | DEFINE_STUB_MGR_CTOR(ip_intf_mgr) 70 | 71 | } 72 | -------------------------------------------------------------------------------- /nexthop_group_tunnel_gen.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/base.h" 5 | #include "eos/types/nexthop_group_tunnel.h" 6 | #include "eos/types/nexthop_group_tunnel_impl.h" 7 | 8 | namespace eos { 9 | 10 | nexthop_group_tunnel_t::nexthop_group_tunnel_t() : 11 | pimpl(std::make_shared()) {} 12 | nexthop_group_tunnel_t::nexthop_group_tunnel_t(ip_prefix_t const & tunnel_endpoint, 13 | std::string const & nhg_name) : 14 | pimpl(std::make_shared( 15 | tunnel_endpoint, 16 | nhg_name 17 | )) {} 18 | EOS_SDK_PUBLIC nexthop_group_tunnel_t::nexthop_group_tunnel_t( 19 | const nexthop_group_tunnel_t& other) : 20 | pimpl(std::make_shared( 21 | *other.pimpl)) {} 22 | EOS_SDK_PUBLIC nexthop_group_tunnel_t& 23 | nexthop_group_tunnel_t::operator=( 24 | nexthop_group_tunnel_t const & other) 25 | { 26 | if(this != &other) { 27 | pimpl = std::make_shared( 28 | *other.pimpl); 29 | } 30 | return *this; 31 | } 32 | 33 | EOS_SDK_PUBLIC nexthop_group_tunnel_t::nexthop_group_tunnel_t( 34 | nexthop_group_tunnel_t && other) noexcept : 35 | pimpl(std::move(other.pimpl)) {} 36 | EOS_SDK_PUBLIC nexthop_group_tunnel_t& 37 | nexthop_group_tunnel_t::operator=( 38 | nexthop_group_tunnel_t && other) noexcept 39 | { 40 | if(this != &other) { 41 | std::swap(pimpl, other.pimpl); 42 | } 43 | return *this; 44 | } 45 | 46 | EOS_SDK_PUBLIC void * 47 | nexthop_group_tunnel_t::operator new( std::size_t size ) { 48 | return ::operator new( size ); 49 | } 50 | EOS_SDK_PUBLIC void 51 | nexthop_group_tunnel_t::operator delete( void * p ) noexcept { 52 | ::operator delete( p ); 53 | } 54 | 55 | 56 | } // namespace eos 57 | -------------------------------------------------------------------------------- /mac_table.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/mac_table.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | class mac_table_mgr_impl : public mac_table_mgr { 10 | public: 11 | mac_table_mgr_impl() { 12 | } 13 | 14 | virtual mac_table_iter_t mac_table_iter() const { 15 | mac_table_iter_t * nop = 0; 16 | return *nop; 17 | } 18 | 19 | virtual mac_table_status_iter_t mac_table_status_iter() const { 20 | mac_table_status_iter_t * nop = 0; 21 | return *nop; 22 | } 23 | 24 | virtual mac_entry_t mac_entry_status(mac_key_t const & key) const { 25 | return mac_entry_t(); 26 | } 27 | 28 | virtual mac_entry_t mac_entry(mac_key_t const & key) const { 29 | return mac_entry_t(); 30 | } 31 | 32 | virtual mac_entry_t mac_entry(vlan_id_t vlan, eth_addr_t mac) const { 33 | return mac_entry_t(); 34 | } 35 | 36 | virtual mac_entry_type_t type(mac_key_t const & key) const { 37 | return mac_entry_type_t(); 38 | } 39 | 40 | virtual seconds_t last_move_time(mac_key_t const & key) const { 41 | return 0; 42 | } 43 | 44 | virtual uint32_t moves(mac_key_t const & key) const { 45 | return 0; 46 | } 47 | 48 | virtual void mac_entry_set(mac_entry_t const & entry) {} 49 | virtual void mac_entry_del(mac_key_t const & key) {} 50 | 51 | 52 | }; 53 | 54 | DEFINE_STUB_MGR_CTOR(mac_table_mgr) 55 | 56 | mac_table_handler::mac_table_handler(mac_table_mgr *mgr) : 57 | base_handler(mgr) { 58 | } 59 | void mac_table_handler::watch_all_mac_entries(bool all) {} 60 | void mac_table_handler::watch_mac_entry(mac_key_t const & key, bool interest) {} 61 | 62 | void mac_table_handler::on_mac_entry_set(mac_entry_t const & entry) {} 63 | void mac_table_handler::on_mac_entry_del(mac_key_t const & key) {} 64 | 65 | } // end namespace eos 66 | -------------------------------------------------------------------------------- /examples/HelloWorld.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | import eossdk 6 | import sys 7 | 8 | # This is the python version of the HelloWorld.cpp program. See the 9 | # explanation there, or a more detailed walkthrough at the GitHub wiki. 10 | 11 | 12 | class HelloWorldAgent(eossdk.AgentHandler): 13 | def __init__(self, sdk): 14 | self.agentMgr = sdk.get_agent_mgr() 15 | self.tracer = eossdk.Tracer("HelloWorldPythonAgent") 16 | eossdk.AgentHandler.__init__(self, self.agentMgr) 17 | self.tracer.trace0("Python agent constructed") 18 | 19 | def on_initialized(self): 20 | self.tracer.trace0("Initialized") 21 | name = self.agentMgr.agent_option("name") 22 | if not name: 23 | # No name initially set 24 | self.agentMgr.status_set("greeting", "Welcome! What is your name?") 25 | else: 26 | # Handle the initial state 27 | self.on_agent_option("name", name) 28 | 29 | def on_agent_option(self, optionName, value): 30 | if optionName == "name": 31 | if not value: 32 | self.tracer.trace3("Name deleted") 33 | self.agentMgr.status_set("greeting", "Goodbye!") 34 | else: 35 | # Time for some social networking! 36 | self.tracer.trace3("Saying hi to %s" % value) 37 | self.agentMgr.status_set("greeting", "Hello %s!" % value) 38 | 39 | def on_agent_enabled(self, enabled): 40 | if not enabled: 41 | self.tracer.trace0("Shutting down") 42 | self.agentMgr.status_set("greeting", "Adios!") 43 | self.agentMgr.agent_shutdown_complete_is(True) 44 | 45 | if __name__ == "__main__": 46 | sdk_ = eossdk.Sdk() 47 | # Assign the agent instance to a variable so it remains in scope and 48 | # is not deleted: 49 | _ = HelloWorldAgent(sdk_) 50 | sdk_.main_loop(sys.argv) 51 | -------------------------------------------------------------------------------- /eos/iterator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_ITERATOR_H 5 | #define EOS_ITERATOR_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace eos { 13 | 14 | template 15 | class EOS_SDK_PUBLIC iter_base : public std::iterator { 16 | public: 17 | iter_base(iter_base const &); 18 | ~iter_base(); 19 | iter_base & operator=(iter_base const & other); 20 | iter_base & operator++(); 21 | iter_base operator++(int); 22 | bool operator==(iter_base const & rhs) const; 23 | bool operator!=(iter_base const & rhs) const; 24 | operator bool() const; 25 | T operator*() const; 26 | T const * operator->() const; 27 | T * operator->(); 28 | 29 | protected: 30 | Impl * impl; 31 | explicit iter_base(Impl * const) EOS_SDK_PRIVATE; 32 | iter_base() EOS_SDK_PRIVATE; 33 | }; 34 | 35 | template 36 | class mocked_iter : public std::iterator 37 | { 38 | private: 39 | std::list li; 40 | typename std::list::iterator it; 41 | int count = 0; // it != li.end() does not work! 42 | int max; 43 | public: 44 | mocked_iter(std::list l) : li(l) { it = li.begin(); max = li.size(); } 45 | operator bool() const { return it != li.end() && count < max; } 46 | mocked_iter operator ++() { auto i = *this; it++; count++; return i; } 47 | mocked_iter operator ++(int dummy) { it++; count++; return *this; } 48 | V operator*() { return *it; } 49 | V const * operator->() const { return &(*it); } 50 | V * operator->() { return &(*it); } 51 | bool operator==(const mocked_iter& rhs) const { return *it==*rhs.it; } 52 | bool operator!=(const mocked_iter& rhs) const { return *it!=*rhs.it; } 53 | }; 54 | 55 | } 56 | 57 | #include 58 | 59 | #endif // EOS_ITERATOR_H 60 | -------------------------------------------------------------------------------- /eos/types/eapi_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_EAPI_IMPL_H 5 | #define EOS_TYPES_EAPI_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace eos { 13 | 14 | /** An eAPI response from the Cli server. */ 15 | class EOS_SDK_PUBLIC eapi_response_impl_t { 16 | public: 17 | /** Default constructor. */ 18 | eapi_response_impl_t(); 19 | /** Full constructor. */ 20 | eapi_response_impl_t(bool success, uint32_t error_code, 21 | std::string const & error_message, 22 | std::vector const & responses); 23 | 24 | /** Getter for 'success': indicates if a response was received. */ 25 | bool success() const; 26 | 27 | /** Getter for 'error_code': error code from eAPI response. */ 28 | uint32_t error_code() const; 29 | 30 | /** Getter for 'error_message': error message from response. */ 31 | std::string error_message() const; 32 | 33 | /** 34 | * Getter for 'responses': the set of strings that constitute an eAPI response. 35 | */ 36 | std::vector const & responses() const; 37 | 38 | /** Getter for 'raw_response': raw eAPI response (if requested). */ 39 | std::string raw_response() const; 40 | 41 | /** Returns a string representation of the current object's values. */ 42 | std::string to_string() const; 43 | /** 44 | * A utility stream operator that adds a string representation of 45 | * eapi_response_t to the ostream. 46 | */ 47 | friend std::ostream& operator<<(std::ostream& os, 48 | const eapi_response_impl_t& obj); 49 | 50 | private: 51 | bool success_; 52 | uint32_t error_code_; 53 | std::string error_message_; 54 | std::vector responses_; 55 | std::string raw_response_; 56 | }; 57 | } 58 | 59 | #endif // EOS_TYPES_EAPI_IMPL_H 60 | -------------------------------------------------------------------------------- /examples/MplsLivenessExample.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "MplsTunnelLivenessAgent.hpp" // MplsTunnelLivenessAgent definition 5 | 6 | struct MplsLivenessExample : public MplsTunnelLivenessAgent { 7 | eos::agent_mgr *agent_mgr_; 8 | 9 | explicit MplsLivenessExample(eos::sdk & sdk, const char *src_ip) 10 | : MplsTunnelLivenessAgent(sdk), agent_mgr_(sdk.get_agent_mgr()) { 11 | set_src_ip(src_ip); 12 | } 13 | 14 | virtual void on_initialized() { 15 | MplsTunnelLivenessAgent::on_initialized(); 16 | 17 | agent_mgr_->status_set("on_initialized", "SUCCESS"); 18 | } 19 | 20 | virtual void on_tunnel_status(uint32_t tunnel_key, tl_status_t status) { 21 | MplsTunnelLivenessAgent::on_tunnel_status(tunnel_key, status); 22 | 23 | // ADD YOUR CODE HERE 24 | std::cout << "Inherited on_tunnel_status!" << std::endl; 25 | } 26 | }; 27 | 28 | // The main() function's command-line arguments are to simplify testing. Using this 29 | // agent correctly is done via the add_session, remove_session, and on_tunnel_status 30 | // functions. 31 | // 32 | // Usage: ./MplsLivenessExample 33 | int main(int argc, char **argv) { 34 | const char *src_ip; 35 | if (argc == 2) { 36 | src_ip = argv[1]; 37 | } else { 38 | std::cout << "Usage: " << argv[0] << " " << std::endl; 39 | std::cout << "Using default src_ip" << std::endl; 40 | src_ip = "0.0.0.0"; 41 | } 42 | 43 | // Print welcome message. 44 | std::cout << "----------------------------------" << std::endl; 45 | std::cout << "Running MPLS Tunnel Liveness Agent" << std::endl; 46 | std::cout << "----------------------------------" << std::endl; 47 | std::cout << std::endl; 48 | std::cout << "src_ip: " << src_ip << std::endl; 49 | std::cout << std::endl; 50 | 51 | eos::sdk sdk; 52 | MplsLivenessExample agent(sdk, src_ip); 53 | 54 | sdk.main_loop(argc, argv); 55 | } 56 | -------------------------------------------------------------------------------- /eos/base.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_BASE_H 5 | #define EOS_BASE_H 6 | 7 | #include // for uint8_t, uint16_t, uint32_t, uint64_t, etc. 8 | 9 | /** 10 | * @file 11 | * Arista EOS Software Development Kit 12 | */ 13 | 14 | namespace eos { 15 | 16 | // Big endian (network byte order) hinted forms of uint16_t/uint32_t/uint64_t 17 | /// A uint16_t in big endian (network byte) order 18 | typedef uint16_t uint16_be_t; 19 | /// A uint32_t in big endian (network byte) order 20 | typedef uint32_t uint32_be_t; 21 | /// A uint64_t in big endian (network byte) order 22 | typedef uint64_t uint64_be_t; 23 | 24 | /// A decimal number of seconds, used for timestamps and durations 25 | typedef double seconds_t; 26 | 27 | #if defined(__GNUC__) && !defined(SWIG) 28 | #define EOS_SDK_PUBLIC __attribute__ ((visibility ("default"))) 29 | #ifdef EOS_SDK_ALLOW_MOCKS // Allows the use of gMock and such. 30 | # define EOS_SDK_PRIVATE EOS_SDK_PUBLIC 31 | #else 32 | # define EOS_SDK_PRIVATE __attribute__ ((visibility ("hidden"))) 33 | #endif 34 | // Things we need to expose but that aren't part of the API. 35 | // TODO(tsuna): Why can't we make this visibility protected? 36 | #define EOS_SDK_INTERNAL __attribute__ ((visibility ("default"))) 37 | #define EOS_SDK_NORETURN __attribute__ ((noreturn)) 38 | #define EOS_SDK_DEPRECATED __attribute__ ((deprecated)) 39 | #define EOS_SDK_FORMAT_STRING_CHECK(N) __attribute__ ((format (printf, N, N+1))) 40 | #else 41 | // SWIG doesn't understand __attribute__ overload macros 42 | #define EOS_SDK_PUBLIC 43 | #define EOS_SDK_PRIVATE 44 | #define EOS_SDK_INTERNAL 45 | #define EOS_SDK_NORETURN 46 | #define EOS_SDK_DEPRECATED 47 | #define EOS_SDK_FORMAT_STRING_CHECK(N) 48 | #endif 49 | 50 | #define EOS_SDK_DISALLOW_COPY_CTOR(ClassName) \ 51 | private: \ 52 | ClassName(ClassName const &) EOS_SDK_PRIVATE; \ 53 | ClassName & operator=(ClassName const &) EOS_SDK_PRIVATE; 54 | 55 | } 56 | 57 | #endif // EOS_BASE_H 58 | -------------------------------------------------------------------------------- /examples/BgpAgent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /** 10 | * This example agent reacts to bgp peer state change 11 | * and traces those events. 12 | * 13 | * To run this example: 14 | * $ Art scp BgpAgent :/mnt/flash/ 15 | * 16 | * bash# TRACE=BgpTestAgent /mnt/flash/BgpAgent 17 | * or from the CLI 18 | * (conf)# daemon BgpAgent 19 | * (conf-daemon-BgpAgent)# exe /mnt/flash/BgpAgent 20 | * (conf-daemon-BgpAgent)# no shutdown 21 | * (conf)# trace - setting BgpTestAgent 22 | */ 23 | 24 | 25 | class BgpTestAgent : public eos::agent_handler, 26 | public eos::bgp_peer_handler { 27 | public: 28 | eos::tracer t; 29 | 30 | explicit BgpTestAgent(eos::sdk & sdk) 31 | : eos::agent_handler(sdk.get_agent_mgr()), 32 | eos::bgp_peer_handler(sdk.get_bgp_mgr()), 33 | t("BgpTestAgent") { 34 | watch_all_peers(true); 35 | t.trace0("Constructed"); 36 | } 37 | 38 | void on_initialized() { 39 | t.trace0("Agent initialized"); 40 | } 41 | 42 | void on_peer_set(eos::bgp_peer_key_t const & peer_key) { 43 | t.trace0("peer %s created", peer_key.to_string().c_str()); 44 | } 45 | 46 | void on_peer_del(eos::bgp_peer_key_t const & peer_key) { 47 | t.trace0("peer %s deleted", peer_key.to_string().c_str()); 48 | } 49 | 50 | void on_peer_state(eos::bgp_peer_key_t const & peer_key, 51 | eos::bgp_peer_state_t peer_state) { 52 | t.trace0("peer %s state change to %d", peer_key.to_string().c_str(), 53 | peer_state); 54 | } 55 | 56 | void on_agent_enabled(bool enabled) { 57 | if (!enabled) { 58 | t.trace0("Shutting down"); 59 | get_agent_mgr()->agent_shutdown_complete_is(true); 60 | } 61 | } 62 | }; 63 | 64 | int main(int argc, char **argv) { 65 | eos::sdk sdk; 66 | BgpTestAgent agent(sdk); 67 | sdk.main_loop(argc, argv); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /eos/types/bgp_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_BGP_IMPL_H 5 | #define EOS_TYPES_BGP_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace eos { 14 | 15 | /** The BGP peer key which consists of the peer address and the VRF itresides in. */ 16 | class EOS_SDK_PUBLIC bgp_peer_key_impl_t { 17 | public: 18 | bgp_peer_key_impl_t(); 19 | explicit bgp_peer_key_impl_t(std::string const & vrf_name, 20 | ip_addr_t const & peer_addr); 21 | 22 | /** Getter for 'vrf_name': VRF name. */ 23 | std::string vrf_name() const; 24 | /** Setter for 'vrf_name'. */ 25 | void vrf_name_is(std::string const & vrf_name); 26 | /** Moving Setter for 'vrf_name'. */ 27 | void vrf_name_is(std::string && vrf_name); 28 | 29 | /** Getter for 'peer_addr': BGP peer address. */ 30 | ip_addr_t peer_addr() const; 31 | /** Setter for 'peer_addr'. */ 32 | void peer_addr_is(ip_addr_t const & peer_addr); 33 | /** Moving Setter for 'peer_addr'. */ 34 | void peer_addr_is(ip_addr_t && peer_addr); 35 | 36 | bool operator==(bgp_peer_key_impl_t const & other) const; 37 | bool operator!=(bgp_peer_key_impl_t const & other) const; 38 | bool operator<(bgp_peer_key_impl_t const & other) const; 39 | /** The hash function for type bgp_peer_key_t. */ 40 | uint32_t hash() const; 41 | /** The hash mix function for type bgp_peer_key_t. */ 42 | void mix_me(hash_mix & h) const; 43 | /** Returns a string representation of the current object's values. */ 44 | std::string to_string() const; 45 | /** 46 | * A utility stream operator that adds a string representation of bgp_peer_key_t 47 | * to the ostream. 48 | */ 49 | friend std::ostream& operator<<(std::ostream& os, 50 | const bgp_peer_key_impl_t& obj); 51 | 52 | private: 53 | std::string vrf_name_; 54 | ip_addr_t peer_addr_; 55 | }; 56 | } 57 | 58 | #endif // EOS_TYPES_BGP_IMPL_H 59 | -------------------------------------------------------------------------------- /examples/SimpleBfdAgent.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2023 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | import argparse 6 | import sys 7 | import eossdk 8 | 9 | 10 | class BfdAgent( eossdk.AgentHandler, eossdk.BfdSessionHandler ): 11 | def __init__( self, agentMgr, bfdSessionMgr, peerIp, intf ): 12 | self.agentMgr = agentMgr 13 | self.bfdSessionMgr = bfdSessionMgr 14 | self.peerIp = peerIp 15 | self.intf = intf 16 | ipAddr = eossdk.IpAddr( self.peerIp ) 17 | intfId = eossdk.IntfId( self.intf ) 18 | self.peer = eossdk.BfdSessionKey( 19 | ipAddr, "default", eossdk.BFD_SESSION_TYPE_NORMAL, intfId ) 20 | self.tracer = eossdk.Tracer( "BfdAgent" ) 21 | eossdk.AgentHandler.__init__( self, self.agentMgr ) 22 | eossdk.BfdSessionHandler.__init__( self, self.bfdSessionMgr ) 23 | self.tracer.trace0( "Constructed" ) 24 | 25 | def on_initialized( self ): 26 | self.tracer.trace0( "Initialized" ) 27 | self.bfdSessionMgr.session_set( self.peer ) 28 | self.watch_bfd_session( self.peer, True ) 29 | self.tracer.trace0( "BFD session created" ) 30 | 31 | def on_agent_enabled( self, enabled ): 32 | self.tracer.trace0( f"Agent enabled: {enabled}" ) 33 | if not enabled: 34 | self.watch_bfd_session( self.peer, False ) 35 | self.bfdSessionMgr.session_del( self.peer ) 36 | self.tracer.trace0( "BFD session deleted" ) 37 | self.agentMgr.agent_shutdown_complete_is( True ) 38 | 39 | def on_bfd_session_status( self, key, status ): 40 | self.tracer.trace0( f"{key.to_string()} {status}" ) 41 | 42 | if __name__ == '__main__': 43 | parser = argparse.ArgumentParser() 44 | parser.add_argument( '--peer-ip', help="Peer's IP address", required=True ) 45 | parser.add_argument( '--intf', help="Interface name", required=True ) 46 | args, _ = parser.parse_known_args( sys.argv ) 47 | sdk = eossdk.Sdk() 48 | _ = BfdAgent( 49 | sdk.get_agent_mgr(), 50 | sdk.get_bfd_session_mgr(), 51 | args.peer_ip, 52 | args.intf ) 53 | sdk.main_loop( sys.argv ) 54 | -------------------------------------------------------------------------------- /eos/inline/hash_mix.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef INLINE_HASH_MIX_H 5 | #define INLINE_HASH_MIX_H 6 | 7 | #include 8 | 9 | namespace eos { 10 | 11 | inline hash_mix::hash_mix() : val_(0) {} 12 | 13 | inline void hash_mix::mix(bool val) { 14 | mix_bytes((uint8_t const *)&val, sizeof(val)); 15 | } 16 | 17 | inline void hash_mix::mix(double val) { 18 | mix_bytes((uint8_t const *)&val, sizeof(val)); 19 | } 20 | 21 | inline void hash_mix::mix(float val) { 22 | mix_bytes((uint8_t const *)&val, sizeof(val)); 23 | } 24 | 25 | inline void hash_mix::mix(uint8_t val) { 26 | mix_bytes((uint8_t const *)&val, sizeof(val)); 27 | } 28 | 29 | inline void hash_mix::mix(uint16_t val) { 30 | mix_bytes((uint8_t const *)&val, sizeof(val)); 31 | } 32 | 33 | inline void hash_mix::mix(uint32_t val) { 34 | mix_bytes((uint8_t const *)&val, sizeof(val)); 35 | } 36 | 37 | inline void hash_mix::mix(uint64_t val) { 38 | mix_bytes((uint8_t const *)&val, sizeof(val)); 39 | } 40 | 41 | inline void hash_mix::mix(int8_t val) { 42 | mix_bytes((uint8_t const *)&val, sizeof(val)); 43 | } 44 | 45 | inline void hash_mix::mix(int16_t val) { 46 | mix_bytes((uint8_t const *)&val, sizeof(val)); 47 | } 48 | 49 | inline void hash_mix::mix(int32_t val) { 50 | mix_bytes((uint8_t const *)&val, sizeof( val )); 51 | } 52 | 53 | inline void hash_mix::mix(int64_t val) { 54 | mix_bytes((uint8_t const *)&val, sizeof(val)); 55 | } 56 | 57 | inline void hash_mix::mix(std::string const & val) { 58 | mix_bytes((uint8_t const *)val.c_str(), val.size()); 59 | } 60 | 61 | inline void hash_mix::mix_bytes(uint8_t const * key, int len) { 62 | // The incremental mix step 63 | for(int i = 0; i < len; ++i) { 64 | val_ += key[i]; 65 | val_ += val_ << 10; 66 | val_ ^= val_ >> 6; 67 | } 68 | } 69 | 70 | inline uint32_t hash_mix::result() const { 71 | uint32_t seed = val_; 72 | // Do the final mixing step 73 | seed += seed << 3; 74 | seed ^= seed >> 11; 75 | seed += seed << 15; 76 | return seed; 77 | } 78 | 79 | } 80 | 81 | #endif // INLINE_HASH_MIX_H 82 | -------------------------------------------------------------------------------- /eos/inline/types/vrf_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_VRF_IMPL_H 5 | #define EOS_INLINE_TYPES_VRF_IMPL_H 6 | 7 | namespace eos { 8 | 9 | 10 | 11 | // Default constructor. 12 | vrf_impl_t::vrf_impl_t() : 13 | name_(""), state_(VRF_NULL), rd_(0) { 14 | } 15 | 16 | vrf_impl_t::vrf_impl_t(std::string name, vrf_state_t state, uint64_t rd) : 17 | name_(name), state_(state), rd_(rd) { 18 | } 19 | 20 | std::string 21 | vrf_impl_t::name() const { 22 | return name_; 23 | } 24 | 25 | vrf_state_t 26 | vrf_impl_t::state() const { 27 | return state_; 28 | } 29 | 30 | uint64_t 31 | vrf_impl_t::rd() const { 32 | return rd_; 33 | } 34 | 35 | bool 36 | vrf_impl_t::operator==(vrf_impl_t const & other) const { 37 | return name_ == other.name_ && 38 | state_ == other.state_ && 39 | rd_ == other.rd_; 40 | } 41 | 42 | bool 43 | vrf_impl_t::operator!=(vrf_impl_t const & other) const { 44 | return !operator==(other); 45 | } 46 | 47 | bool 48 | vrf_impl_t::operator<(vrf_impl_t const & other) const { 49 | if(name_ != other.name_) { 50 | return name_ < other.name_; 51 | } else if(state_ != other.state_) { 52 | return state_ < other.state_; 53 | } else if(rd_ != other.rd_) { 54 | return rd_ < other.rd_; 55 | } 56 | return false; 57 | } 58 | 59 | uint32_t 60 | vrf_impl_t::hash() const { 61 | hash_mix h; 62 | mix_me(h); 63 | return h.result(); 64 | } 65 | 66 | void 67 | vrf_impl_t::mix_me(hash_mix & h) const { 68 | h.mix(name_); // std::string 69 | h.mix(state_); // vrf_state_t 70 | h.mix(rd_); // uint64_t 71 | } 72 | 73 | std::string 74 | vrf_impl_t::to_string() const { 75 | std::ostringstream ss; 76 | ss << "vrf_t("; 77 | ss << "name='" << name_ << "'"; 78 | ss << ", state=" << state_; 79 | ss << ", rd=" << rd_; 80 | ss << ")"; 81 | return ss.str(); 82 | } 83 | 84 | std::ostream& 85 | operator<<(std::ostream& os, const vrf_impl_t& obj) { 86 | os << obj.to_string(); 87 | return os; 88 | } 89 | 90 | 91 | } 92 | 93 | #include 94 | 95 | #endif // EOS_INLINE_TYPES_VRF_IMPL_H 96 | -------------------------------------------------------------------------------- /eos/inline/types/decap_group.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_DECAP_GROUP_H 5 | #define EOS_INLINE_TYPES_DECAP_GROUP_H 6 | 7 | namespace eos { 8 | 9 | EOS_SDK_PUBLIC std::ostream& 10 | operator<<(std::ostream& os, const decap_protocol_type_t & enum_val) { 11 | if (enum_val==PROTOCOL_TYPE_NULL) { 12 | os << "PROTOCOL_TYPE_NULL"; 13 | } else if (enum_val==PROTOCOL_TYPE_GRE) { 14 | os << "PROTOCOL_TYPE_GRE"; 15 | } else { 16 | os << "Unknown value"; 17 | } 18 | return os; 19 | } 20 | 21 | 22 | std::string 23 | decap_group_t::group_name() const { 24 | return pimpl->group_name(); 25 | } 26 | ip_addr_t 27 | decap_group_t::destination_addr() const { 28 | return pimpl->destination_addr(); 29 | } 30 | void 31 | decap_group_t::destination_addr_is(ip_addr_t const & destination_addr) { 32 | pimpl->destination_addr_is(destination_addr); 33 | } 34 | void 35 | decap_group_t::destination_addr_is(ip_addr_t && destination_addr) { 36 | pimpl->destination_addr_is(std::move(destination_addr)); 37 | } 38 | decap_protocol_type_t 39 | decap_group_t::protocol_type() const { 40 | return pimpl->protocol_type(); 41 | } 42 | void 43 | decap_group_t::protocol_type_is(decap_protocol_type_t protocol_type) { 44 | pimpl->protocol_type_is(protocol_type); 45 | } 46 | bool 47 | decap_group_t::operator==(decap_group_t const & other) const { 48 | return pimpl->operator==(*other.pimpl); 49 | } 50 | bool 51 | decap_group_t::operator!=(decap_group_t const & other) const { 52 | return pimpl->operator!=(*other.pimpl); 53 | } 54 | bool 55 | decap_group_t::operator<(decap_group_t const & other) const { 56 | return pimpl->operator<(*other.pimpl); 57 | } 58 | uint32_t 59 | decap_group_t::hash() const { 60 | return pimpl->hash(); 61 | } 62 | void 63 | decap_group_t::mix_me(hash_mix & h) const { 64 | pimpl->mix_me(h); 65 | } 66 | std::string 67 | decap_group_t::to_string() const { 68 | return pimpl->to_string(); 69 | } 70 | std::ostream& 71 | operator<<(std::ostream& os, const decap_group_t& obj) { 72 | return operator<<(os, *obj.pimpl); 73 | } 74 | 75 | } 76 | 77 | #endif // EOS_INLINE_TYPES_DECAP_GROUP_H 78 | -------------------------------------------------------------------------------- /eos/panic.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_PANIC_H 5 | #define EOS_PANIC_H 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @file 12 | * Panic handling framework. 13 | * 14 | * A 'panic' is raised by the EOS SDK to signal a programming error on 15 | * behalf of the SDK user. A regular 'assert' is used by the SDK to 16 | * signal an Arista error which should be reported for correction. 17 | * 18 | * Panics occur under a number of conditions, such as an invalid 19 | * string format for an IP address when using ip_addr_t's constructor 20 | * to checks of incompatible type attributes during manager calls. 21 | * The panic exception passed to the exception_handler_t callback 22 | * describes the fault condition observed. 23 | * 24 | * During a panic call, any panic handler set with exception_handler_is 25 | * is called with the message, and then the panic message is also written 26 | * to stderr and a SIGABRT raised. The SIGABRT will also cause a stack 27 | * trace to be dumped. 28 | */ 29 | 30 | namespace eos { 31 | 32 | class error; // Forward declaration. 33 | 34 | /** 35 | * Reports an exception from the SDK. 36 | * Internal errors and programming errors are reported via subclasses of 37 | * exception. See eos/exception.h for possible exceptions. 38 | */ 39 | void panic(error const & exception) EOS_SDK_NORETURN EOS_SDK_PUBLIC; 40 | 41 | /// @deprecated Obsolete, replaced with panic(error). 42 | void panic(char const * fmt, ...) 43 | EOS_SDK_NORETURN EOS_SDK_FORMAT_STRING_CHECK(1) EOS_SDK_PUBLIC; 44 | 45 | /// @deprecated Obsolete, replaced with panic(error). 46 | void vpanic(char const * fmt, va_list ap) 47 | EOS_SDK_NORETURN EOS_SDK_PUBLIC; 48 | 49 | /** 50 | * The exception handler callback definition. 51 | * 52 | * @param exception The exception that needs to be handled. 53 | */ 54 | typedef void (*exception_handler_t)(error const & exception); 55 | 56 | /** 57 | * Sets a custom panic handler. 58 | * 59 | * @param exception_handler_t An exception handler callback 60 | */ 61 | void exception_handler_is(exception_handler_t) EOS_SDK_PUBLIC; 62 | 63 | } 64 | 65 | #endif // EOS_PANIC_H 66 | -------------------------------------------------------------------------------- /eos/inline/types/eapi_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_EAPI_IMPL_H 5 | #define EOS_INLINE_TYPES_EAPI_IMPL_H 6 | 7 | namespace eos { 8 | 9 | eapi_response_impl_t::eapi_response_impl_t() : 10 | success_(false), error_code_(0), error_message_(), responses_(), 11 | raw_response_() { 12 | } 13 | 14 | eapi_response_impl_t::eapi_response_impl_t( 15 | bool success, uint32_t error_code, std::string const & error_message, 16 | std::vector const & responses) : 17 | success_(success), error_code_(error_code), error_message_(error_message), 18 | responses_(responses), raw_response_() { 19 | } 20 | 21 | bool 22 | eapi_response_impl_t::success() const { 23 | return success_; 24 | } 25 | 26 | uint32_t 27 | eapi_response_impl_t::error_code() const { 28 | return error_code_; 29 | } 30 | 31 | std::string 32 | eapi_response_impl_t::error_message() const { 33 | return error_message_; 34 | } 35 | 36 | std::vector const & 37 | eapi_response_impl_t::responses() const { 38 | return responses_; 39 | } 40 | 41 | std::string 42 | eapi_response_impl_t::raw_response() const { 43 | return raw_response_; 44 | } 45 | 46 | std::string 47 | eapi_response_impl_t::to_string() const { 48 | std::ostringstream ss; 49 | ss << "eapi_response_t("; 50 | ss << "success=" << success_; 51 | ss << ", error_code=" << error_code_; 52 | ss << ", error_message='" << error_message_ << "'"; 53 | ss << ", responses=" <<"'"; 54 | bool first_responses = true; 55 | for (auto it=responses_.cbegin(); 56 | it!=responses_.cend(); ++it) { 57 | if (first_responses) { 58 | ss << (*it); 59 | first_responses = false; 60 | } else { 61 | ss << "," << (*it); 62 | } 63 | } 64 | ss << "'"; 65 | ss << ", raw_response='" << raw_response_ << "'"; 66 | ss << ")"; 67 | return ss.str(); 68 | } 69 | 70 | std::ostream& 71 | operator<<(std::ostream& os, const eapi_response_impl_t& obj) { 72 | os << obj.to_string(); 73 | return os; 74 | } 75 | 76 | 77 | } 78 | 79 | #include 80 | 81 | #endif // EOS_INLINE_TYPES_EAPI_IMPL_H 82 | -------------------------------------------------------------------------------- /eos/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * The version module. It provides EosSdk version information. 4 | * 5 | * This module provides access to EosSdk version information, including 6 | * version major number, version minor number and version patch number. 7 | * 8 | * To access the version information, application will need to include 9 | * "eos/version.h", then it can access it directly, as following: 10 | * eos::version_major 11 | * eos::version_minor 12 | * eos::version_patch 13 | * eos::version 14 | * 15 | * Note: eos::version is of type "char *" while version_major, version_minor 16 | * and version_patch are of type "uint8_t". 17 | */ 18 | 19 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 20 | // Arista Networks, Inc. Confidential and Proprietary. 21 | 22 | #ifndef EOSSDK_VERSION_H 23 | #define EOSSDK_VERSION_H 24 | 25 | #include 26 | 27 | #define EOSSDK_VERSION "2.23.4" 28 | #define EOSSDK_MAJOR 2 29 | #define EOSSDK_MINOR 23 30 | #define EOSSDK_PATCH 4 31 | 32 | namespace eos { 33 | 34 | // Version string, at least of the form "X.Y.Z", but possibly followed by a 35 | // dash and more characters (e.g. "X.Y.Z-rc1"). 36 | extern const char * const version EOS_SDK_PUBLIC; 37 | 38 | // Major version number (i.e. the "X" in "X.Y.Z") 39 | extern const uint8_t version_major EOS_SDK_PUBLIC; 40 | 41 | // Minor version number (i.e. the "Y" in "X.Y.Z") 42 | extern const uint8_t version_minor EOS_SDK_PUBLIC; 43 | 44 | // Patch version number (i.e. the "Z" in "X.Y.Z", regardless of any trailing 45 | // characters followed by the dash optional) 46 | extern const uint8_t version_patch EOS_SDK_PUBLIC; 47 | 48 | // Arista project name used to build the EOS SDK. 49 | extern const char * const build_project EOS_SDK_PUBLIC; 50 | 51 | // User that built the EOS SDK. 52 | extern const char * const build_user EOS_SDK_PUBLIC; 53 | 54 | // Path under which the EOS SDK was built. 55 | extern const char * const build_path EOS_SDK_PUBLIC; 56 | 57 | // Source control system revision number at which the EOS SDK was built. 58 | extern const uint32_t build_cl EOS_SDK_PUBLIC; 59 | 60 | // UNIX timestamp at which the EOS SDK was built. 61 | extern const uint64_t build_timestamp EOS_SDK_PUBLIC; 62 | 63 | } 64 | 65 | #endif // EOSSDK_VERSION_H 66 | -------------------------------------------------------------------------------- /eos/inline/types/mpls_vrf_label_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_MPLS_VRF_LABEL_IMPL_H 5 | #define EOS_INLINE_TYPES_MPLS_VRF_LABEL_IMPL_H 6 | 7 | namespace eos { 8 | 9 | // Default constructor. 10 | mpls_vrf_label_impl_t::mpls_vrf_label_impl_t() : 11 | label_(), vrf_name_() { 12 | } 13 | 14 | mpls_vrf_label_impl_t::mpls_vrf_label_impl_t(mpls_label_t label, 15 | std::string vrf_name) : 16 | label_(label), vrf_name_(vrf_name) { 17 | } 18 | 19 | mpls_label_t 20 | mpls_vrf_label_impl_t::label() const { 21 | return label_; 22 | } 23 | 24 | std::string 25 | mpls_vrf_label_impl_t::vrf_name() const { 26 | return vrf_name_; 27 | } 28 | 29 | bool 30 | mpls_vrf_label_impl_t::operator==(mpls_vrf_label_impl_t const & other) const { 31 | return label_ == other.label_ && 32 | vrf_name_ == other.vrf_name_; 33 | } 34 | 35 | bool 36 | mpls_vrf_label_impl_t::operator!=(mpls_vrf_label_impl_t const & other) const { 37 | return !operator==(other); 38 | } 39 | 40 | bool 41 | mpls_vrf_label_impl_t::operator<(mpls_vrf_label_impl_t const & other) const { 42 | if(label_ != other.label_) { 43 | return label_ < other.label_; 44 | } else if(vrf_name_ != other.vrf_name_) { 45 | return vrf_name_ < other.vrf_name_; 46 | } 47 | return false; 48 | } 49 | 50 | uint32_t 51 | mpls_vrf_label_impl_t::hash() const { 52 | hash_mix h; 53 | mix_me(h); 54 | return h.result(); 55 | } 56 | 57 | void 58 | mpls_vrf_label_impl_t::mix_me(hash_mix & h) const { 59 | h.mix(label_); // mpls_label_t 60 | h.mix(vrf_name_); // std::string 61 | } 62 | 63 | std::string 64 | mpls_vrf_label_impl_t::to_string() const { 65 | std::ostringstream ss; 66 | ss << "mpls_vrf_label_t("; 67 | ss << "label=" << label_; 68 | ss << ", vrf_name='" << vrf_name_ << "'"; 69 | ss << ")"; 70 | return ss.str(); 71 | } 72 | 73 | std::ostream& 74 | operator<<(std::ostream& os, const mpls_vrf_label_impl_t& obj) { 75 | os << obj.to_string(); 76 | return os; 77 | } 78 | 79 | 80 | } 81 | 82 | #include 83 | 84 | #endif // EOS_INLINE_TYPES_MPLS_VRF_LABEL_IMPL_H 85 | -------------------------------------------------------------------------------- /tracing.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace eos { 12 | 13 | struct tracer_internal { 14 | explicit tracer_internal(char const * name_) 15 | : name(name_), levelEnabled(9, true) { 16 | } 17 | 18 | void trace(trace_level level, char const * expression, va_list args) const { 19 | char * expandedExpression = NULL; 20 | if (vasprintf(&expandedExpression, expression, args) != -1) { 21 | fprintf(stderr, "[%s]\t%s\n", name, expandedExpression); 22 | free(expandedExpression); 23 | } 24 | } 25 | 26 | char const * name; 27 | std::vector levelEnabled; 28 | }; 29 | 30 | tracer::tracer(char const * name) : tracer_(new tracer_internal(name)) { 31 | } 32 | 33 | tracer::~tracer() { 34 | delete tracer_; 35 | } 36 | 37 | bool tracer::enabled(trace_level level) const { 38 | return tracer_->levelEnabled[level]; 39 | } 40 | 41 | void tracer::enabled_is(trace_level level, bool value) { 42 | tracer_->levelEnabled[level] = value; 43 | } 44 | 45 | void tracer::trace(trace_level level, char const * expression, ...) const { 46 | if (enabled(level)) { 47 | va_list args; 48 | va_start(args, expression); 49 | tracer_->trace(level, expression, args); 50 | va_end(args); 51 | } 52 | } 53 | 54 | #define TRACE(level) void \ 55 | tracer::trace ## level (char const * expression, ...) const { \ 56 | if (enabled(static_cast(level))) { \ 57 | va_list args; \ 58 | va_start(args, expression); \ 59 | tracer_->trace(static_cast(level), expression, args); \ 60 | va_end(args); \ 61 | } \ 62 | } 63 | 64 | TRACE(0) 65 | TRACE(1) 66 | TRACE(2) 67 | TRACE(3) 68 | TRACE(4) 69 | TRACE(5) 70 | TRACE(6) 71 | TRACE(7) 72 | TRACE(8) 73 | TRACE(9) 74 | 75 | #undef TRACE 76 | 77 | } 78 | -------------------------------------------------------------------------------- /eos/inline/types/nexthop_group_tunnel.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_NEXTHOP_GROUP_TUNNEL_H 5 | #define EOS_INLINE_TYPES_NEXTHOP_GROUP_TUNNEL_H 6 | 7 | namespace eos { 8 | 9 | ip_prefix_t 10 | nexthop_group_tunnel_t::tunnel_endpoint() const { 11 | return pimpl->tunnel_endpoint(); 12 | } 13 | void 14 | nexthop_group_tunnel_t::tunnel_endpoint_is(ip_prefix_t const & tunnel_endpoint) { 15 | pimpl->tunnel_endpoint_is(tunnel_endpoint); 16 | } 17 | void 18 | nexthop_group_tunnel_t::tunnel_endpoint_is(ip_prefix_t && tunnel_endpoint) { 19 | pimpl->tunnel_endpoint_is(std::move(tunnel_endpoint)); 20 | } 21 | std::string 22 | nexthop_group_tunnel_t::nhg_name() const { 23 | return pimpl->nhg_name(); 24 | } 25 | void 26 | nexthop_group_tunnel_t::nhg_name_is(std::string const & nhg_name) { 27 | pimpl->nhg_name_is(nhg_name); 28 | } 29 | void 30 | nexthop_group_tunnel_t::nhg_name_is(std::string && nhg_name) { 31 | pimpl->nhg_name_is(std::move(nhg_name)); 32 | } 33 | uint8_t 34 | nexthop_group_tunnel_t::igp_pref() const { 35 | return pimpl->igp_pref(); 36 | } 37 | void 38 | nexthop_group_tunnel_t::igp_pref_is(uint8_t igp_pref) { 39 | pimpl->igp_pref_is(igp_pref); 40 | } 41 | uint32_t 42 | nexthop_group_tunnel_t::igp_metric() const { 43 | return pimpl->igp_metric(); 44 | } 45 | void 46 | nexthop_group_tunnel_t::igp_metric_is(uint32_t igp_metric) { 47 | pimpl->igp_metric_is(igp_metric); 48 | } 49 | bool 50 | nexthop_group_tunnel_t::operator==(nexthop_group_tunnel_t const & other) const { 51 | return pimpl->operator==(*other.pimpl); 52 | } 53 | bool 54 | nexthop_group_tunnel_t::operator!=(nexthop_group_tunnel_t const & other) const { 55 | return pimpl->operator!=(*other.pimpl); 56 | } 57 | uint32_t 58 | nexthop_group_tunnel_t::hash() const { 59 | return pimpl->hash(); 60 | } 61 | void 62 | nexthop_group_tunnel_t::mix_me(hash_mix & h) const { 63 | pimpl->mix_me(h); 64 | } 65 | std::string 66 | nexthop_group_tunnel_t::to_string() const { 67 | return pimpl->to_string(); 68 | } 69 | std::ostream& 70 | operator<<(std::ostream& os, const nexthop_group_tunnel_t& obj) { 71 | return operator<<(os, *obj.pimpl); 72 | } 73 | 74 | } 75 | 76 | #endif // EOS_INLINE_TYPES_NEXTHOP_GROUP_TUNNEL_H 77 | -------------------------------------------------------------------------------- /eos/types/subintf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_SUBINTF_H 5 | #define EOS_TYPES_SUBINTF_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef SWIG 15 | %ignore eos::subintf_t(eos::subintf_t &&) noexcept; 16 | %ignore eos::subintf_t::operator=(eos::subintf_t &&) noexcept; 17 | #endif 18 | 19 | namespace eos { 20 | 21 | class subintf_impl_t; 22 | /** This data structure defines a subinterface. */ 23 | class EOS_SDK_PUBLIC subintf_t { 24 | public: 25 | subintf_t(); 26 | subintf_t(intf_id_t intf_id, vlan_id_t vlan_id); 27 | subintf_t(const subintf_t& other); 28 | subintf_t& operator=( 29 | subintf_t const & other); 30 | 31 | subintf_t(subintf_t && other) noexcept; 32 | subintf_t & operator=(subintf_t && other) noexcept; 33 | static void * operator new( std::size_t, void * ptr ) { 34 | return ptr; 35 | } 36 | static void * operator new( std::size_t ); 37 | static void operator delete( void * ) noexcept; 38 | 39 | /** Getter for 'intf_id': the interface ID of this subinterface. */ 40 | intf_id_t intf_id() const; 41 | 42 | /** Getter for 'vlan_id': the VLAN tag of this subinterface. */ 43 | vlan_id_t vlan_id() const; 44 | /** Setter for 'vlan_id'. */ 45 | void vlan_id_is(vlan_id_t vlan_id); 46 | 47 | bool operator==(subintf_t const & other) const; 48 | bool operator!=(subintf_t const & other) const; 49 | /** The hash function for type subintf_t. */ 50 | uint32_t hash() const; 51 | /** The hash mix function for type subintf_t. */ 52 | void mix_me(hash_mix & h) const; 53 | /** Returns a string representation of the current object's values. */ 54 | std::string to_string() const; 55 | /** 56 | * A utility stream operator that adds a string representation of subintf_t to 57 | * the ostream. 58 | */ 59 | friend std::ostream& operator<<(std::ostream& os, const subintf_t& obj); 60 | 61 | private: 62 | std::shared_ptr pimpl; 63 | }; 64 | 65 | EOS_SDK_PUBLIC 66 | std::ostream& operator<<(std::ostream& os, const subintf_t& obj); 67 | } 68 | 69 | #endif // EOS_TYPES_SUBINTF_H 70 | -------------------------------------------------------------------------------- /exception.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | 7 | #include "eos/exception.h" 8 | 9 | namespace eos { 10 | 11 | // This file contains non-inlined constructors because the constructors 12 | // contain literal strings. Should they be inlined, there would be one 13 | // copy of each string used in each translation unit, which contributes 14 | // to increased binary size. 15 | 16 | invalid_argument_error::invalid_argument_error( 17 | std::string const & argument_name) noexcept 18 | : error(std::string("Invalid argument '" + argument_name + "'")), 19 | argument_name_(argument_name) { 20 | } 21 | 22 | invalid_argument_error::invalid_argument_error( 23 | std::string const & argument_name, 24 | std::string const & error_details) noexcept 25 | : error(std::string("Invalid argument '" + argument_name + 26 | "': " + error_details)), 27 | argument_name_(argument_name) { 28 | } 29 | 30 | static inline std::string 31 | invalid_range_error_msg(uint32_t min_valid, uint32_t max_valid) { 32 | std::stringstream str; 33 | str << "value is outside its valid range. min_valid = " 34 | << min_valid << ", max_valid = " << max_valid; 35 | return str.str(); 36 | } 37 | 38 | invalid_range_error::invalid_range_error(std::string const & argument_name, 39 | uint32_t min_valid, uint32_t max_valid) 40 | noexcept 41 | : invalid_argument_error(argument_name, 42 | invalid_range_error_msg(min_valid, max_valid)), 43 | min_valid_(min_valid), max_valid_(max_valid) { 44 | } 45 | 46 | static 47 | inline std::string unconfigured_agent_error_msg(std::string const & agent_name) { 48 | std::stringstream str; 49 | str << "The agent " << agent_name.c_str() << " has not been configured. " 50 | "Ensure that the agent has been configured to run from the CLI and " 51 | "that the executable uses the same agent name."; 52 | return str.str(); 53 | } 54 | 55 | unconfigured_agent_error::unconfigured_agent_error(std::string const & name) noexcept 56 | : configuration_error(unconfigured_agent_error_msg(name)), agent_name_(name) { 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /eos/types/ip_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_IP_IMPL_H 5 | #define EOS_TYPES_IP_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace eos { 21 | 22 | 23 | 24 | /** 25 | * An IP address with a subnet mask. 26 | * 27 | * This allows for contiguous subnet masks only for IPv4 and IPv6 addresses. 28 | * 29 | * IPv6 addresses in EOS only support contiguous masks, so for IPv6 addresses 30 | * mask() provides the same value as mask_length(). 31 | */ 32 | class EOS_SDK_PUBLIC ip_addr_mask_impl_t { 33 | public: 34 | ip_addr_mask_impl_t(); 35 | ip_addr_mask_impl_t(ip_addr_t const & addr, uint8_t mask_length); 36 | 37 | /** Getter for 'addr': the address/mask's IP address. */ 38 | ip_addr_t addr() const; 39 | 40 | /** Getter for 'mask_length': the bit mask length, e.g., 24. */ 41 | uint8_t mask_length() const; 42 | 43 | /** The address family of the prefix. */ 44 | af_t af() const; 45 | /** 46 | * The bit mask itself, e.g., 0xFFFFFF00 (IPv4). For IPv6, same as 47 | * mask_length(). 48 | */ 49 | uint32_be_t mask() const; 50 | /** The IP address and mask as a string, e.g., "192.0.2.1/0xFFFFFF00". */ 51 | std::string to_string() const; 52 | bool operator==(ip_addr_mask_impl_t const & other) const; 53 | bool operator!=(ip_addr_mask_impl_t const & other) const; 54 | bool operator<(ip_addr_mask_impl_t const & other) const; 55 | /** The hash function for type ip_addr_mask_t. */ 56 | uint32_t hash() const; 57 | /** The hash mix function for type ip_addr_mask_t. */ 58 | void mix_me(hash_mix & h) const; 59 | /** 60 | * A utility stream operator that adds a string representation of ip_addr_mask_t 61 | * to the ostream. 62 | */ 63 | friend std::ostream& operator<<(std::ostream& os, 64 | const ip_addr_mask_impl_t& obj); 65 | 66 | private: 67 | ip_addr_t addr_; 68 | uint8_t mask_length_; 69 | }; 70 | 71 | } 72 | 73 | #endif // EOS_TYPES_IP_IMPL_H 74 | -------------------------------------------------------------------------------- /examples/ThriftClient.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ThriftSdk.h" 13 | 14 | using namespace apache::thrift; 15 | using namespace apache::thrift::protocol; 16 | using namespace apache::thrift::transport; 17 | namespace po = boost::program_options; 18 | 19 | #include "thriftconfig.h" 20 | #ifdef HAVE_RECENT_THRIFT 21 | using std::shared_ptr; 22 | #else 23 | using boost::shared_ptr; 24 | #endif 25 | 26 | using namespace eos; 27 | 28 | int main(int argc, char **argv) { 29 | po::options_description desc("Program options"); 30 | int port; 31 | std::string server; 32 | std::string intf; 33 | desc.add_options() 34 | ("help,h", "Prints this help message") 35 | ("server", po::value(&server)->default_value("localhost"), 36 | "IP or hostname of the server") 37 | ("port", po::value(&port)->default_value(9090), "Port of the server") 38 | // Operations: 39 | ("interface", po::value(&intf)->required(), 40 | "Interface on which to carry the operation") 41 | ("exists", "Checks whether the given interface exists") 42 | ("set-description", po::value(), 43 | "Sets the interface description") 44 | ; 45 | po::variables_map flags; 46 | po::store(po::parse_command_line(argc, argv, desc), flags); 47 | if(flags.count("help")) { 48 | std::cout << desc << std::endl; 49 | return 0; 50 | } 51 | po::notify(flags); 52 | 53 | shared_ptr socket(new TSocket(server, port)); 54 | shared_ptr transport(new TFramedTransport(socket)); 55 | shared_ptr protocol(new TBinaryProtocol(transport)); 56 | 57 | ThriftSdkClient client(protocol); 58 | transport->open(); 59 | if(flags.count("exists")) { 60 | bool res = client.exists(intf); 61 | std::cout << "exists(" << intf << "): " << res << std::endl; 62 | } 63 | if(flags.count("set-description")) { 64 | std::string description = flags["set-description"].as(); 65 | client.descriptionIs(intf, description); 66 | } 67 | transport->close(); 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /examples/eossdk_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | from functools import wraps 6 | import pdb 7 | import sys 8 | import traceback 9 | import types 10 | 11 | # This file provides a utility to automatically wrap all EOS SDK 12 | # handlers in debug code. 13 | 14 | # Because exceptions that escape handlers are caught by the SDK's 15 | # underlying event loop, Python agents can be tricky to debug. These 16 | # helper utilities will print out the stacktrace of the error and, if 17 | # the agent is run from a TTY, will then drop the user in a debug 18 | # session at the point where the error occurred. 19 | 20 | # To use, simply inherit from EosSdkAgent: 21 | # 22 | # import eossdk_utils 23 | # class MyAgent(eossdk_utils.EosSdkAgent, eossdk.AgentHandler, etc): 24 | # def on_initialized(self): 25 | # ... 26 | # 27 | 28 | 29 | # Implementation: 30 | def debug_fn(func): 31 | """ This wrapper tries to run the wrapped function. If the function 32 | raises an Exception, print the traceback, and, if the user is at a 33 | TTY, drop the user into an interactive debug session. """ 34 | @wraps(func) 35 | def wrapped_fn(*args, **kwargs): 36 | try: 37 | return func(*args, **kwargs) 38 | except Exception as e: 39 | traceback.print_exc() 40 | if sys.stdout.isatty(): 41 | pdb.post_mortem() 42 | raise e 43 | return wrapped_fn 44 | 45 | 46 | class SdkAgentMetaClass(type): 47 | def __new__(mcs, classname, bases, classDict): 48 | """ Wraps all functions in this class that start with "on_" with 49 | the above debug_fn """ 50 | newClassDict = {} 51 | for attributeName, attribute in classDict.items(): 52 | if (isinstance(attribute, types.FunctionType) and 53 | attributeName.startswith("on_")): 54 | # Wrap all "on_" handler functions with debugging helper code. 55 | attribute = debug_fn(attribute) 56 | newClassDict[attributeName] = attribute 57 | return type.__new__(mcs, classname, bases, newClassDict) 58 | 59 | 60 | # Class to inherit from: 61 | 62 | class EosSdkAgent(object): 63 | """ To add debgging capabilities to your agent, subclass this EosSdkAgent. """ 64 | __metaclass__ = SdkAgentMetaClass 65 | -------------------------------------------------------------------------------- /examples/MultiThreadedExample.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | // This simple program tests how the SDK deals with multiple 16 | // threads. In it, we start the main loop, and once on_initialized is 17 | // called, we start a thread (via the function run_child). If no lock 18 | // is used, the the program will likely crash due to multiple threads 19 | // writing to the Sysdb connection simultaneously. No crashes are 20 | // observed when the sdk_scoped_lock is used. 21 | 22 | // If the following #define is set, we will use the SDK lock. 23 | #define USE_SDK_LOCK 1 24 | 25 | 26 | static pthread_t thread; 27 | 28 | void *run_child(void *mgr) { 29 | std::cout << "[child] Starting iterations!" << std::endl; 30 | for(int i = 0; i < 1000; i++) { 31 | #if USE_SDK_LOCK 32 | eos::sdk_scoped_lock ssl; 33 | #endif 34 | std::stringstream ss; 35 | ss << "Iteration #" << i; 36 | std::string status = ss.str(); 37 | ((eos::agent_mgr *) mgr)->status_set("index", status); 38 | std::cout << "[child] " << status << std::endl; 39 | } 40 | std::cout << "[child] Done!" << std::endl; 41 | sleep(2); 42 | pthread_exit(NULL); 43 | } 44 | 45 | 46 | class parent_handler_agent : public eos::agent_handler { 47 | public: 48 | explicit parent_handler_agent(eos::agent_mgr * mgr) 49 | : eos::agent_handler(mgr) { 50 | std::cout << "[parent_handler] Constructing" << std::endl; 51 | } 52 | 53 | void on_initialized() { 54 | std::cout << "[parent_handler] Initialized" << std::endl; 55 | int rc = pthread_create(& thread, NULL, 56 | run_child, (void *)get_agent_mgr()); 57 | if (rc){ 58 | std::cout << "Error:unable to create thread," << rc << std::endl; 59 | } 60 | } 61 | }; 62 | 63 | 64 | int main(int argc, char ** argv) { 65 | eos::sdk sdk; 66 | eos::agent_mgr * mgr = sdk.get_agent_mgr(); 67 | parent_handler_agent hwa(mgr); 68 | std::cout << "[parent] I'm the parent process" << std::endl; 69 | std::cout << "[parent] Starting main loop" << std::endl; 70 | sdk.main_loop(argc, argv); 71 | } 72 | -------------------------------------------------------------------------------- /eos/types/mpls_vrf_label.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_MPLS_VRF_LABEL_H 5 | #define EOS_TYPES_MPLS_VRF_LABEL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef SWIG 14 | %ignore eos::mpls_vrf_label_t(eos::mpls_vrf_label_t &&) noexcept; 15 | %ignore eos::mpls_vrf_label_t::operator=(eos::mpls_vrf_label_t &&) noexcept; 16 | #endif 17 | 18 | namespace eos { 19 | 20 | class mpls_vrf_label_impl_t; 21 | /** A static VRF label decap route configuration model. */ 22 | class EOS_SDK_PUBLIC mpls_vrf_label_t { 23 | public: 24 | mpls_vrf_label_t(); 25 | mpls_vrf_label_t(mpls_label_t label, std::string vrf_name); 26 | mpls_vrf_label_t(const mpls_vrf_label_t& other); 27 | mpls_vrf_label_t& operator=( 28 | mpls_vrf_label_t const & other); 29 | 30 | mpls_vrf_label_t(mpls_vrf_label_t && other) noexcept; 31 | mpls_vrf_label_t & operator=(mpls_vrf_label_t && other) noexcept; 32 | static void * operator new( std::size_t, void * ptr ) { 33 | return ptr; 34 | } 35 | static void * operator new( std::size_t ); 36 | static void operator delete( void * ) noexcept; 37 | 38 | /** Getter for 'label': the decap label. */ 39 | mpls_label_t label() const; 40 | 41 | /** Getter for 'vrf_name': the name of the VRF. */ 42 | std::string vrf_name() const; 43 | 44 | bool operator==(mpls_vrf_label_t const & other) const; 45 | bool operator!=(mpls_vrf_label_t const & other) const; 46 | bool operator<(mpls_vrf_label_t const & other) const; 47 | /** The hash function for type mpls_vrf_label_t. */ 48 | uint32_t hash() const; 49 | /** The hash mix function for type mpls_vrf_label_t. */ 50 | void mix_me(hash_mix & h) const; 51 | /** Returns a string representation of the current object's values. */ 52 | std::string to_string() const; 53 | /** 54 | * A utility stream operator that adds a string representation of 55 | * mpls_vrf_label_t to the ostream. 56 | */ 57 | friend std::ostream& operator<<(std::ostream& os, const mpls_vrf_label_t& obj); 58 | 59 | private: 60 | std::shared_ptr pimpl; 61 | }; 62 | 63 | EOS_SDK_PUBLIC 64 | std::ostream& operator<<(std::ostream& os, const mpls_vrf_label_t& obj); 65 | } 66 | 67 | #endif // EOS_TYPES_MPLS_VRF_LABEL_H 68 | -------------------------------------------------------------------------------- /eth_intf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include "eos/eth_intf.h" 6 | #include "impl.h" 7 | 8 | namespace eos { 9 | 10 | eth_intf_handler::eth_intf_handler(eth_intf_mgr * mgr) : 11 | base_handler(mgr) { 12 | } 13 | 14 | void 15 | eth_intf_handler::watch_all_eth_intfs(bool all) { 16 | // TODO: No op impl. 17 | } 18 | 19 | void 20 | eth_intf_handler::watch_eth_intf(intf_id_t, bool) { 21 | // TODO: No op impl. 22 | } 23 | 24 | void eth_intf_handler::on_eth_intf_create(intf_id_t) { 25 | // No-op impl. 26 | } 27 | 28 | void eth_intf_handler::on_eth_intf_delete(intf_id_t) { 29 | // No-op impl. 30 | } 31 | 32 | void eth_intf_handler::on_eth_addr(intf_id_t, eth_addr_t) { 33 | // No-op impl. 34 | } 35 | 36 | class eth_intf_mgr_impl : public eth_intf_mgr { 37 | public: 38 | eth_intf_mgr_impl() { 39 | } 40 | 41 | eth_intf_iter_t eth_intf_iter() const { 42 | eth_intf_iter_t * nop = 0; 43 | return *nop; // TODO: No op impl. 44 | } 45 | 46 | bool exists(intf_id_t) const { 47 | return false; 48 | } 49 | 50 | eth_addr_t eth_addr(intf_id_t) const { 51 | return eth_addr_t(); // TODO: No-op impl. 52 | } 53 | 54 | eth_addr_t configured_eth_addr(intf_id_t) const { 55 | return eth_addr_t(); // TODO: No-op impl. 56 | } 57 | 58 | void eth_addr_is(intf_id_t, eth_addr_t) { 59 | } 60 | 61 | switchport_mode_t switchport_mode(intf_id_t) const { 62 | return SWITCHPORT_MODE_ACCESS; 63 | } 64 | 65 | void switchport_mode_is(intf_id_t, switchport_mode_t) { 66 | // TODO: No-op impl. 67 | } 68 | 69 | vlan_id_t default_vlan(intf_id_t) const { 70 | return 0; // TODO: No-op impl. 71 | } 72 | 73 | void default_vlan_is(intf_id_t, vlan_id_t) { 74 | // TODO: No-op impl. 75 | } 76 | 77 | vlan_set_t trunk_vlans(intf_id_t) const { 78 | vlan_set_t vlans; 79 | // TODO: No-op impl. 80 | return vlans; 81 | } 82 | 83 | void trunk_vlan_set(intf_id_t, vlan_id_t) { 84 | // TODO: No-op impl. 85 | } 86 | 87 | void trunk_vlan_is(intf_id_t, vlan_set_t const &) { 88 | // TODO: No-op impl. 89 | } 90 | 91 | void trunk_vlan_del(intf_id_t, vlan_id_t) { 92 | // TODO: No-op impl. 93 | } 94 | }; 95 | 96 | DEFINE_STUB_MGR_CTOR(eth_intf_mgr) 97 | 98 | } 99 | -------------------------------------------------------------------------------- /examples/SimpleIntfAgent.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | import sys 6 | 7 | import eossdk 8 | 9 | 10 | # Listens to standard input and shuts down an interface when it 11 | # receives a "shutdown" message. To exit, enter a blank line. 12 | class MyTestAgent(eossdk.AgentHandler, eossdk.FdHandler): 13 | def __init__(self, agentMgr, intfMgr, interfaceName): 14 | print( "This program controls the admin enabled state of the given interface" ) 15 | print( " - 'shutdown' will disable the interface" ) 16 | print( " - any other text will enable the interface" ) 17 | print( " - an empty line will quit this program" ) 18 | self.agentMgr_ = agentMgr 19 | self.intfMgr_ = intfMgr 20 | self.intfObj_ = eossdk.IntfId(interfaceName) 21 | eossdk.AgentHandler.__init__(self, agentMgr) 22 | eossdk.FdHandler.__init__(self) 23 | self.eventCount = 0 24 | 25 | def on_initialized(self): 26 | print( "Initialized!" ) 27 | self.watch_readable(0, True) 28 | self.intfMgr_.admin_enabled_is(self.intfObj_, True) 29 | self._printPrompt() 30 | 31 | def on_readable(self, fd): 32 | print( "- Fd %d is readable" % fd ) 33 | curEnabledStatus = ("enabled" if self.intfMgr_.admin_enabled(self.intfObj_) 34 | else "disabled") 35 | print( f"- {self.intfObj_.to_string()} is currently {curEnabledStatus}" ) 36 | msg = sys.stdin.readline() 37 | if msg.startswith("shut"): 38 | print( "Shutting down %s" % self.intfObj_.to_string() ) 39 | self.intfMgr_.admin_enabled_is(self.intfObj_, False) 40 | self.eventCount += 1 41 | elif msg.strip(): 42 | print( "Enabling %s" % self.intfObj_.to_string() ) 43 | self.intfMgr_.admin_enabled_is(self.intfObj_, True) 44 | self.eventCount += 1 45 | else: 46 | print( "Exiting!" ) 47 | self.agentMgr_.exit() 48 | self._printPrompt() 49 | 50 | def _printPrompt(self): 51 | print( '> ', end=" " ) 52 | sys.stdout.flush() 53 | 54 | 55 | def main(args): 56 | sdk = eossdk.Sdk() 57 | testAgent = MyTestAgent(sdk.get_agent_mgr(), sdk.get_intf_mgr(), "Ethernet1") 58 | sdk.main_loop(args) 59 | print( "Handled %d events" % testAgent.eventCount ) 60 | 61 | if __name__ == '__main__': 62 | sys.exit(main(sys.argv)) 63 | -------------------------------------------------------------------------------- /eos/inline/types/bgp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_BGP_H 5 | #define EOS_INLINE_TYPES_BGP_H 6 | 7 | namespace eos { 8 | 9 | std::string 10 | bgp_peer_key_t::vrf_name() const { 11 | return pimpl->vrf_name(); 12 | } 13 | void 14 | bgp_peer_key_t::vrf_name_is(std::string const & vrf_name) { 15 | pimpl->vrf_name_is(vrf_name); 16 | } 17 | void 18 | bgp_peer_key_t::vrf_name_is(std::string && vrf_name) { 19 | pimpl->vrf_name_is(std::move(vrf_name)); 20 | } 21 | ip_addr_t 22 | bgp_peer_key_t::peer_addr() const { 23 | return pimpl->peer_addr(); 24 | } 25 | void 26 | bgp_peer_key_t::peer_addr_is(ip_addr_t const & peer_addr) { 27 | pimpl->peer_addr_is(peer_addr); 28 | } 29 | void 30 | bgp_peer_key_t::peer_addr_is(ip_addr_t && peer_addr) { 31 | pimpl->peer_addr_is(std::move(peer_addr)); 32 | } 33 | bool 34 | bgp_peer_key_t::operator==(bgp_peer_key_t const & other) const { 35 | return pimpl->operator==(*other.pimpl); 36 | } 37 | bool 38 | bgp_peer_key_t::operator!=(bgp_peer_key_t const & other) const { 39 | return pimpl->operator!=(*other.pimpl); 40 | } 41 | bool 42 | bgp_peer_key_t::operator<(bgp_peer_key_t const & other) const { 43 | return pimpl->operator<(*other.pimpl); 44 | } 45 | uint32_t 46 | bgp_peer_key_t::hash() const { 47 | return pimpl->hash(); 48 | } 49 | void 50 | bgp_peer_key_t::mix_me(hash_mix & h) const { 51 | pimpl->mix_me(h); 52 | } 53 | std::string 54 | bgp_peer_key_t::to_string() const { 55 | return pimpl->to_string(); 56 | } 57 | std::ostream& 58 | operator<<(std::ostream& os, const bgp_peer_key_t& obj) { 59 | return operator<<(os, *obj.pimpl); 60 | } 61 | 62 | 63 | EOS_SDK_PUBLIC std::ostream& 64 | operator<<(std::ostream& os, const bgp_peer_state_t & enum_val) { 65 | if (enum_val==PEER_UNKNOWN) { 66 | os << "PEER_UNKNOWN"; 67 | } else if (enum_val==PEER_IDLE) { 68 | os << "PEER_IDLE"; 69 | } else if (enum_val==PEER_CONNECT) { 70 | os << "PEER_CONNECT"; 71 | } else if (enum_val==PEER_ACTIVE) { 72 | os << "PEER_ACTIVE"; 73 | } else if (enum_val==PEER_OPENSENT) { 74 | os << "PEER_OPENSENT"; 75 | } else if (enum_val==PEER_OPENCONFIRM) { 76 | os << "PEER_OPENCONFIRM"; 77 | } else if (enum_val==PEER_ESTABLISHED) { 78 | os << "PEER_ESTABLISHED"; 79 | } else { 80 | os << "Unknown value"; 81 | } 82 | return os; 83 | } 84 | 85 | } 86 | 87 | #endif // EOS_INLINE_TYPES_BGP_H 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arista's EOS SDK 2 | 3 | ![EOS SDK logo](http://i.imgur.com/fNQ07mr.png) 4 | 5 | The EOS Software Development Kit (EOS SDK) lets you program native, 6 | high-performance apps that run on your Arista switch. These apps, or 7 | "agents," harness the full power of EOS, including event-driven, 8 | asynchronous behavior, high availability, and complete access to both 9 | Linux and EOS's APIs. 10 | 11 | This package provides a self-contained implementation of stubs for the EOS 12 | SDK. The stubs mock how the real EOS SDK behaves on a real switch, to a 13 | certain extent. They are useful to build and test software in your favorite 14 | Linux environment, with your preferred build tools. 15 | 16 | 17 | ## Documentation 18 | Documentation is hosted on this project's [wiki](https://github.com/aristanetworks/EosSdk/wiki). It includes a [quickstart guide](https://github.com/aristanetworks/EosSdk/wiki/Quickstart%3A-Hello-World), [build](https://github.com/aristanetworks/EosSdk/wiki/Build-and-Development-Environment) and [install](https://github.com/aristanetworks/EosSdk/wiki/Downloading-and-Installing-the-SDK) instructions, along with an [EOS overview](https://github.com/aristanetworks/EosSdk/wiki/Understanding-EOS-and-Sysdb) and high-level [SDK usage](https://github.com/aristanetworks/EosSdk/wiki/Using-the-SDK) information. 19 | 20 | Detailed, per-release API Documentation is also available via the 21 | release page. 22 | 23 | ## Releases 24 | 25 | Releases are available via the [GitHub release 26 | page](https://github.com/aristanetworks/EosSdk/releases). From that 27 | page you can download specific tarballs for a given release so you can 28 | build your agent. The corresponding EosSdk RPMs (that provide the 29 | functionality for interacting with Arista devices) for a given EOS SDK 30 | release is available via the [Arista download 31 | page](https://www.arista.com/en/support/software-download) on a 32 | per-EOS-release basis. 33 | 34 | ## Exploring the code 35 | 36 | The directory structure is as follows: `eos/` contains the headers 37 | that define the APIs you'll be using. In this directory, each `.h` 38 | file is a module that provides access to a specific subset of EOS's 39 | functionality. Most modules also have a companion file in 40 | `eos/types/.h`. This file defines the various value types 41 | used by the module. 42 | 43 | For a variety of `C++` and `Python` examples, see the `examples/` 44 | directory. The stub `.cpp` files at the top level directory can be 45 | ignored or extended to provide mock functionality, as you'd like. 46 | 47 | 48 | -------------------------------------------------------------------------------- /macsec.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/macsec.h" 5 | #include "impl.h" 6 | 7 | namespace eos{ 8 | 9 | // macsec_handler methods 10 | macsec_handler::macsec_handler(macsec_mgr * mgr) : 11 | base_handler(mgr) { 12 | } 13 | 14 | void macsec_handler::watch_all_intfs(bool interest) { 15 | // TODO: No op impl. 16 | } 17 | 18 | void macsec_handler::watch_intf(intf_id_t intf_id, bool interest) { 19 | // TODO: No op impl. 20 | } 21 | 22 | void macsec_handler::on_intf_status(intf_id_t intf_id, 23 | macsec_intf_status_t const & status) { 24 | } 25 | 26 | // macsec_mgr methods 27 | class macsec_mgr_impl : public macsec_mgr { 28 | public: 29 | macsec_mgr_impl() { 30 | } 31 | 32 | bool exists(macsec_profile_name_t const & profile_name) const { 33 | return false; 34 | } 35 | 36 | macsec_profile_t profile(macsec_profile_name_t const & profile_name) const { 37 | macsec_profile_t * nop = 0; 38 | return *nop; // TODO: No op impl 39 | } 40 | 41 | void profile_set(macsec_profile_t const & profile) { 42 | return; // TODO: No op impl 43 | } 44 | 45 | void profile_del(macsec_profile_name_t const & profile_name) { 46 | return; // TODO: No op impl 47 | } 48 | 49 | macsec_profile_name_t intf_profile(intf_id_t intf_id) const { 50 | macsec_profile_name_t * nop = 0; 51 | return *nop; // TODO: No op impl 52 | } 53 | 54 | void intf_profile_is(intf_id_t intf_id, 55 | macsec_profile_name_t const & profile_name) { 56 | return; // TODO: No op impl 57 | } 58 | 59 | macsec_intf_status_t intf_status(intf_id_t intf_id) const { 60 | macsec_intf_status_t * nop = 0; 61 | return *nop; // TODO: No op impl 62 | } 63 | 64 | bool macsec_capable(intf_id_t intf_id) const { 65 | return false; // TODO: No op impl 66 | } 67 | 68 | macsec_intf_counters_t intf_counters(intf_id_t intf_id) { 69 | macsec_intf_counters_t * nop = 0; 70 | return *nop; // TODO: No op impl 71 | } 72 | 73 | macsec_profile_iter_t macsec_profile_iter() const { 74 | macsec_profile_iter_t *nop = 0; 75 | return *nop; // TODO: No op impl 76 | } 77 | 78 | macsec_intf_status_iter_t macsec_intf_status_iter() const { 79 | macsec_intf_status_iter_t *nop = 0; 80 | return *nop; // TODO: No op impl 81 | } 82 | }; 83 | 84 | DEFINE_STUB_MGR_CTOR(macsec_mgr) 85 | 86 | } 87 | -------------------------------------------------------------------------------- /eos/types/eapi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_EAPI_H 5 | #define EOS_TYPES_EAPI_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef SWIG 13 | %ignore eos::eapi_response_t(eos::eapi_response_t &&) noexcept; 14 | %ignore eos::eapi_response_t::operator=(eos::eapi_response_t &&) noexcept; 15 | #endif 16 | 17 | namespace eos { 18 | 19 | class eapi_response_impl_t; 20 | /** An eAPI response from the Cli server. */ 21 | class EOS_SDK_PUBLIC eapi_response_t { 22 | public: 23 | /** Default constructor. */ 24 | eapi_response_t(); 25 | /** Full constructor. */ 26 | eapi_response_t(bool success, uint32_t error_code, 27 | std::string const & error_message, 28 | std::vector const & responses); 29 | eapi_response_t(const eapi_response_t& other); 30 | eapi_response_t& operator=( 31 | eapi_response_t const & other); 32 | 33 | eapi_response_t(eapi_response_t && other) noexcept; 34 | eapi_response_t & operator=(eapi_response_t && other) noexcept; 35 | static void * operator new( std::size_t, void * ptr ) { 36 | return ptr; 37 | } 38 | static void * operator new( std::size_t ); 39 | static void operator delete( void * ) noexcept; 40 | 41 | /** Getter for 'success': indicates if a response was received. */ 42 | bool success() const; 43 | 44 | /** Getter for 'error_code': error code from eAPI response. */ 45 | uint32_t error_code() const; 46 | 47 | /** Getter for 'error_message': error message from response. */ 48 | std::string error_message() const; 49 | 50 | /** 51 | * Getter for 'responses': the set of strings that constitute an eAPI response. 52 | */ 53 | std::vector const & responses() const; 54 | 55 | /** Getter for 'raw_response': raw eAPI response (if requested). */ 56 | std::string raw_response() const; 57 | 58 | /** Returns a string representation of the current object's values. */ 59 | std::string to_string() const; 60 | /** 61 | * A utility stream operator that adds a string representation of 62 | * eapi_response_t to the ostream. 63 | */ 64 | friend std::ostream& operator<<(std::ostream& os, const eapi_response_t& obj); 65 | 66 | private: 67 | std::shared_ptr pimpl; 68 | }; 69 | 70 | EOS_SDK_PUBLIC 71 | std::ostream& operator<<(std::ostream& os, const eapi_response_t& obj); 72 | } 73 | 74 | #endif // EOS_TYPES_EAPI_H 75 | -------------------------------------------------------------------------------- /eos/types/decap_group_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_DECAP_GROUP_IMPL_H 5 | #define EOS_TYPES_DECAP_GROUP_IMPL_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace eos { 14 | 15 | /** 16 | * An IP decap group configuration model. At this time, all decap groups are 17 | * configured in the default VRF. 18 | */ 19 | class EOS_SDK_PUBLIC decap_group_impl_t { 20 | public: 21 | decap_group_impl_t(); 22 | decap_group_impl_t(std::string const & group_name, 23 | ip_addr_t const & destination_addr, 24 | decap_protocol_type_t protocol_type); 25 | 26 | /** 27 | * Getter for 'group_name': the decap group name. Used to uniquely identify this 28 | * group. 29 | */ 30 | std::string group_name() const; 31 | 32 | /** 33 | * Getter for 'destination_addr': match this destination IP on the outermost IP 34 | * header. 35 | */ 36 | ip_addr_t destination_addr() const; 37 | /** Setter for 'destination_addr'. */ 38 | void destination_addr_is(ip_addr_t const & destination_addr); 39 | /** Moving Setter for 'destination_addr'. */ 40 | void destination_addr_is(ip_addr_t && destination_addr); 41 | 42 | /** 43 | * Getter for 'protocol_type': decapsulate only packets matching this outer IP 44 | * protocol type. 45 | */ 46 | decap_protocol_type_t protocol_type() const; 47 | /** Setter for 'protocol_type'. */ 48 | void protocol_type_is(decap_protocol_type_t protocol_type); 49 | 50 | bool operator==(decap_group_impl_t const & other) const; 51 | bool operator!=(decap_group_impl_t const & other) const; 52 | bool operator<(decap_group_impl_t const & other) const; 53 | /** The hash function for type decap_group_t. */ 54 | uint32_t hash() const; 55 | /** The hash mix function for type decap_group_t. */ 56 | void mix_me(hash_mix & h) const; 57 | /** Returns a string representation of the current object's values. */ 58 | std::string to_string() const; 59 | /** 60 | * A utility stream operator that adds a string representation of decap_group_t 61 | * to the ostream. 62 | */ 63 | friend std::ostream& operator<<(std::ostream& os, const decap_group_impl_t& obj); 64 | 65 | private: 66 | std::string group_name_; 67 | ip_addr_t destination_addr_; 68 | decap_protocol_type_t protocol_type_; 69 | }; 70 | } 71 | 72 | #endif // EOS_TYPES_DECAP_GROUP_IMPL_H 73 | -------------------------------------------------------------------------------- /eos/eapi.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_EAPI_H 5 | #define EOS_EAPI_H 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @file 12 | * EOS eAPI interaction module. 13 | * This module allows interaction with the CLI via eAPI command requests. 14 | * This allows EOS SDK applications access to configuration and status of EOS state 15 | * for which EOS SDK APIs do not yet exist. 16 | * Note that each method is a synchronous call, and opens a unix-domain socket. 17 | * Therefore, this is not intended to be a replacement for other EosSdk modules. 18 | * 19 | * For more information about eAPI, please visit 20 | * https://eos.arista.com/arista-eapi-101/ 21 | * 22 | * The following snippet shows how to load an eAPI response into a json_t object from 23 | * the jansson library, although any json library to convert from json-formatted text 24 | * will do. 25 | * Based on the jansson library documentation: 26 | * https://jansson.readthedocs.io/en/2.10/tutorial.html 27 | * @code 28 | * eapi_response_t show_interfaces = eapiMgr->run_show_cmd("show interfaces"); 29 | * json_t* root; 30 | * json_error_t error; 31 | * if (show_interfaces.success()) { 32 | * root = json_loads(show_interfaces.responses()[0], 0, &error); 33 | * } 34 | * if (!root) { 35 | * fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); 36 | * } 37 | * json_t* interfaces = json_object_get(root, "interfaces"); 38 | * json_t* intf1 = json_object_get(interfaces, "Ethernet1"); 39 | * json_t* desc1 = json_object_get(intf1, "description"); 40 | * 41 | * printf("Ethernet1's description: " << json_string_value(desc1)); 42 | * ... 43 | * @endcode 44 | */ 45 | 46 | namespace eos { 47 | /** 48 | * eAPI manager. 49 | */ 50 | class EOS_SDK_PUBLIC eapi_mgr { 51 | public: 52 | virtual ~eapi_mgr(); 53 | 54 | /// Executes a "show" CLI command in enable mode. 55 | virtual eapi_response_t run_show_cmd(std::string const &) const = 0; 56 | 57 | /// Executes one or many CLI commands in configuration mode. 58 | virtual eapi_response_t run_config_cmds( 59 | std::vector const &) const = 0; 60 | 61 | /// like "run_show_cmd" but returns "text" formatted output (instead of json) 62 | virtual eapi_response_t run_show_cmd_text(std::string const &) const = 0; 63 | 64 | protected: 65 | eapi_mgr() EOS_SDK_PRIVATE; 66 | private: 67 | EOS_SDK_DISALLOW_COPY_CTOR(eapi_mgr); 68 | }; 69 | 70 | } // end namespace eos 71 | 72 | #endif // EOS_EAPI_H 73 | -------------------------------------------------------------------------------- /examples/InterfaceMonitor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2016 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | 6 | import eossdk 7 | import re 8 | import sys 9 | import time 10 | 11 | # This is a simple example agent which reacts to changes to an 12 | # interface's operational status. It keeps track of total number of 13 | # status changes, along with the last changed interface and last 14 | # change time. Additionally, when an interface's status changes, this 15 | # agent will update the interface's description with a timestamp of 16 | # when the interface changed. 17 | 18 | 19 | class InterfaceMonitor(eossdk.AgentHandler, eossdk.IntfHandler): 20 | def __init__(self, intfMgr, agentMgr): 21 | eossdk.AgentHandler.__init__(self, agentMgr) 22 | eossdk.IntfHandler.__init__(self, intfMgr) 23 | self.tracer = eossdk.Tracer("EosSdkInterfaceMonitor") 24 | self.intfMgr_ = intfMgr 25 | self.agentMgr_ = agentMgr 26 | 27 | # Keep track of the total number of state changes. This number 28 | # gets reset whenever the agent is restarted. 29 | self.numIntfChanges_ = 0 30 | 31 | self.tracer.trace0("Constructed") 32 | 33 | def on_initialized(self): 34 | """ Callback provided by AgentHandler when all state is synchronized """ 35 | self.tracer.trace0("We are initialized!") 36 | self.agentMgr_.status_set("Total intf changes", "0") 37 | self.watch_all_intfs(True) 38 | 39 | def on_oper_status(self, intfId, operState): 40 | """ Callback provided by IntfHandler when an interface's 41 | configuration changes """ 42 | self.numIntfChanges_ += 1 43 | intfState = 'up' if operState == eossdk.INTF_OPER_UP else 'down' 44 | lastChangeTime = re.sub( ' +', ' ', time.ctime() ) 45 | self.tracer.trace5("The state of " + intfId.to_string() + 46 | " is now " + intfState) 47 | 48 | # Update the interface's description with the latest change timestamp 49 | self.intfMgr_.description_is(intfId, 50 | "Last status change at " + lastChangeTime) 51 | 52 | # Update this agent's status with new statistics: 53 | self.agentMgr_.status_set("Total intf changes", str(self.numIntfChanges_)) 54 | self.agentMgr_.status_set("Last change of " + intfId.to_string(), intfState) 55 | self.agentMgr_.status_set("Last change time of " + intfId.to_string(), 56 | lastChangeTime) 57 | 58 | 59 | if __name__ == "__main__": 60 | sdk = eossdk.Sdk() 61 | _ = InterfaceMonitor(sdk.get_intf_mgr(), sdk.get_agent_mgr()) 62 | sdk.main_loop(sys.argv) 63 | -------------------------------------------------------------------------------- /eth_phy_intf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include "eos/eth_phy_intf.h" 5 | #include "impl.h" 6 | 7 | namespace eos { 8 | 9 | eth_phy_intf_handler::eth_phy_intf_handler(eth_phy_intf_mgr * mgr) 10 | : base_handler(mgr) { 11 | } 12 | 13 | void 14 | eth_phy_intf_handler::watch_all_eth_phy_intfs(bool all) { 15 | // TODO: No op impl. 16 | } 17 | 18 | void 19 | eth_phy_intf_handler::watch_eth_phy_intf(intf_id_t, bool) { 20 | // TODO: No op impl. 21 | } 22 | 23 | void 24 | eth_phy_intf_handler::on_eth_phy_intf_create(intf_id_t) { 25 | // TODO: No op impl. 26 | } 27 | 28 | void 29 | eth_phy_intf_handler::on_eth_phy_intf_delete(intf_id_t) { 30 | // TODO: No op impl. 31 | } 32 | 33 | void 34 | eth_phy_intf_handler::on_eth_phy_intf_hardware_present(intf_id_t, bool) { 35 | // TODO: No op impl. 36 | } 37 | 38 | void 39 | eth_phy_intf_handler::on_eth_phy_intf_link_speed(intf_id_t, eth_link_speed_t) { 40 | // TODO: No op impl. 41 | } 42 | 43 | void 44 | eth_phy_intf_handler::on_eth_phy_intf_transceiver_present(intf_id_t, bool) { 45 | // TODO: No op impl. 46 | } 47 | 48 | class eth_phy_intf_mgr_impl : public eth_phy_intf_mgr { 49 | public: 50 | eth_phy_intf_mgr_impl() { 51 | } 52 | 53 | eth_phy_intf_iter_t eth_phy_intf_iter() const { 54 | eth_phy_intf_iter_t * nop = 0; 55 | return *nop; // TODO: No op impl. 56 | } 57 | 58 | bool exists(intf_id_t) const { 59 | return false; 60 | } 61 | 62 | bool hardware_present(intf_id_t) const { 63 | return false; 64 | } 65 | 66 | // Read the "burned in" address 67 | eth_addr_t burned_in_eth_addr(intf_id_t) const { 68 | return eth_addr_t(); 69 | } 70 | 71 | eth_link_speed_t link_speed(intf_id_t intf_id) const { 72 | return LINK_SPEED_UNKNOWN; // TODO: No op impl. 73 | } 74 | 75 | bool transceiver_present(intf_id_t intf_id) const { 76 | return false; // TODO: No op impl. 77 | } 78 | 79 | }; 80 | 81 | DEFINE_STUB_MGR_CTOR(eth_phy_intf_mgr) 82 | 83 | class eth_phy_intf_counter_mgr_impl : public eth_phy_intf_counter_mgr { 84 | public: 85 | eth_phy_intf_counter_mgr_impl() { 86 | } 87 | 88 | eth_phy_intf_counters_t counters(intf_id_t) const { 89 | return eth_phy_intf_counters_t(); 90 | } 91 | 92 | eth_phy_intf_bin_counters_t bin_counters(intf_id_t) const { 93 | return eth_phy_intf_bin_counters_t(); 94 | } 95 | 96 | }; 97 | 98 | DEFINE_STUB_MGR_CTOR(eth_phy_intf_counter_mgr) 99 | 100 | } 101 | -------------------------------------------------------------------------------- /eos/timer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TIMER_H 5 | #define EOS_TIMER_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @file 13 | * Periodic timeout support. 14 | * 15 | * This module allows timeouts to be set for a callback to be called 16 | * as soon as possible after some future time. 17 | */ 18 | 19 | namespace eos { 20 | 21 | /** 22 | * Monotonically increasing time in seconds. 23 | * 24 | * Corresponds to the number of seconds since system boot plus an 25 | * arbitrary offset. As such, this value does not permit derivation of 26 | * a wallclock time (use time() from time.h for that). 27 | * 28 | * Instead, now() provides a monotonically increasing value unaffected 29 | * by leap seconds. 30 | */ 31 | seconds_t now() EOS_SDK_PUBLIC; 32 | 33 | /// 'never' represents a future time that now() can never reach. 34 | static const seconds_t never = 0; 35 | 36 | class timer_internal; 37 | class timeout_mgr; 38 | 39 | /** 40 | * The 'timeout_handler' class manages a single instance of a timer. 41 | * 42 | * To schedule a timeout, call timeout_time_is() using an absolute 43 | * time greater than now(). When the timeout_time has been exceeded, 44 | * on_timeout() is called and the timer is unset. To cancel a timer, 45 | * set the timeout to the 'never' constant. 46 | * 47 | * There are no guarantees that on_timeout() will be called exactly at 48 | * the configured timeout, though we guarantee this will never be 49 | * called *before* the configured timeout 50 | */ 51 | class EOS_SDK_PUBLIC timeout_handler : public base_handler { 53 | public: 54 | explicit timeout_handler(timeout_mgr * mgr); 55 | virtual ~timeout_handler(); 56 | 57 | /** 58 | * Sets the next time on_timeout() will be called. 59 | * 60 | * The on_timeout() callback will be called as soon as possible 61 | * after the provided time. 62 | */ 63 | void timeout_time_is(seconds_t); 64 | /// Returns the next timeout value. 65 | virtual void on_timeout() = 0; 66 | 67 | private: 68 | friend class timer_internal; 69 | timer_internal * timer_; 70 | }; 71 | 72 | class EOS_SDK_PUBLIC timeout_mgr : public base_mgr { 73 | public: 74 | virtual ~timeout_mgr(); 75 | 76 | protected: 77 | virtual void init_handler(timeout_handler *) = 0; 78 | timeout_mgr() EOS_SDK_PRIVATE; 79 | friend class timeout_handler; 80 | 81 | private: 82 | EOS_SDK_DISALLOW_COPY_CTOR(timeout_mgr); 83 | }; 84 | 85 | } 86 | 87 | #endif // EOS_TIMER_H 88 | -------------------------------------------------------------------------------- /eos/types/vrf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_TYPES_VRF_H 5 | #define EOS_TYPES_VRF_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef SWIG 13 | %ignore eos::vrf_t(eos::vrf_t &&) noexcept; 14 | %ignore eos::vrf_t::operator=(eos::vrf_t &&) noexcept; 15 | #endif 16 | 17 | namespace eos { 18 | 19 | /** VRF state. */ 20 | enum vrf_state_t { 21 | /** VRF does not exist. */ 22 | VRF_NULL, 23 | /** VRF is being initialized. */ 24 | VRF_INITIALIZING, 25 | /** VRF is active. */ 26 | VRF_ACTIVE, 27 | /** VRF is being deleted. */ 28 | VRF_DELETING, 29 | }; 30 | /** Appends a string representation of enum vrf_state_t value to the ostream. */ 31 | EOS_SDK_PUBLIC std::ostream& operator<<(std::ostream& os, 32 | const vrf_state_t & enum_val); 33 | 34 | class vrf_impl_t; 35 | /** @deprecated. This data structure is used to describe a VRF on a switch. */ 36 | class EOS_SDK_PUBLIC vrf_t { 37 | public: 38 | vrf_t(); 39 | vrf_t(std::string name, vrf_state_t state, uint64_t rd); 40 | vrf_t(const vrf_t& other); 41 | vrf_t& operator=( 42 | vrf_t const & other); 43 | 44 | vrf_t(vrf_t && other) noexcept; 45 | vrf_t & operator=(vrf_t && other) noexcept; 46 | static void * operator new( std::size_t, void * ptr ) { 47 | return ptr; 48 | } 49 | static void * operator new( std::size_t ); 50 | static void operator delete( void * ) noexcept; 51 | 52 | /** Getter for 'name': the name of the VRF. */ 53 | std::string name() const; 54 | 55 | /** Getter for 'state': the state of this VRF. */ 56 | vrf_state_t state() const; 57 | 58 | /** Getter for 'rd': the route distinguisher of the VRF. */ 59 | uint64_t rd() const; 60 | 61 | bool operator==(vrf_t const & other) const; 62 | bool operator!=(vrf_t const & other) const; 63 | bool operator<(vrf_t const & other) const; 64 | /** The hash function for type vrf_t. */ 65 | uint32_t hash() const; 66 | /** The hash mix function for type vrf_t. */ 67 | void mix_me(hash_mix & h) const; 68 | /** Returns a string representation of the current object's values. */ 69 | std::string to_string() const; 70 | /** 71 | * A utility stream operator that adds a string representation of vrf_t to the 72 | * ostream. 73 | */ 74 | friend std::ostream& operator<<(std::ostream& os, const vrf_t& obj); 75 | 76 | private: 77 | std::shared_ptr pimpl; 78 | }; 79 | 80 | EOS_SDK_PUBLIC 81 | std::ostream& operator<<(std::ostream& os, const vrf_t& obj); 82 | } 83 | 84 | #endif // EOS_TYPES_VRF_H 85 | -------------------------------------------------------------------------------- /examples/CliPlugin/CustomMoveAccessInterfaceCli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2015 Arista Networks, Inc. All rights reserved. 3 | # Arista Networks, Inc. Confidential and Proprietary. 4 | 5 | """A sample custom CLI to change the default vlan of an interface in access mode. 6 | 7 | To create a custom CLI, user will need to define their CLI plugin as following: 8 | 9 | @EosSdkCli.CustomCli(myCliName) 10 | def Plugin(sdk): 11 | global mySdk, ethIntfMgr 12 | mySdk = sdk 13 | ethIntfMgr = mySdk.get_eth_intf_mgr() 14 | 15 | Note a manager, such as ethIntfMgr, needs to be obtained in this function and then 16 | used by the CLI implementation, as shown in 'class MoveAccessInterfaceCmd'. 17 | 18 | User can pass in a name to sdk binding in this CLI plugin via the decorator argument. 19 | 20 | After creating the CLI file, such as CustomMoveAccessInterfaceCli.py, it needs to be 21 | installed at /usr/lib/python2.7/site-packages/CliPlugin/ on switch, then user will 22 | need to issue "killall FastCli" to reload all CLIs so the new CLI will take effect. 23 | """ 24 | 25 | import BasicCli 26 | import CliMatcher 27 | import CliCommand 28 | import eossdk 29 | import EosSdkCli 30 | 31 | ethIntfMgr = None 32 | mySdk = None 33 | 34 | 35 | class MoveAccessInterfaceCmd(CliCommand.CliCommandClass): 36 | syntax = 'move access interfaces SRC_VLAN DST_VLAN' 37 | data = { 38 | 'move': 'Move command', 39 | 'access': 'Access interface', 40 | 'interfaces': 'Interface', 41 | 'SRC_VLAN': CliMatcher.IntegerMatcher( 42 | 1, 4094, 43 | helpdesc='The original default VLAN ID to be moved'), 44 | 'DST_VLAN': CliMatcher.IntegerMatcher( 45 | 1, 4094, 46 | helpdesc='The new default VLAN ID to be moved to'), 47 | } 48 | 49 | @staticmethod 50 | def handler(mode, args): 51 | original_vlan_id = args['SRC_VLAN'] 52 | new_vlan_id = args['DST_VLAN'] 53 | lock = eossdk.SdkScopedLock() 54 | for intf in ethIntfMgr.eth_intf_iter(): 55 | if (ethIntfMgr.switchport_mode(intf) == eossdk.SWITCHPORT_MODE_ACCESS and 56 | ethIntfMgr.default_vlan(intf) == original_vlan_id): 57 | ethIntfMgr.default_vlan_is(intf, new_vlan_id) 58 | print("moved interface %s default VLAN from %s to %s." % 59 | (intf.to_string(), original_vlan_id, new_vlan_id)) 60 | return 61 | print("no default VLAN ID moved.") 62 | print() 63 | del lock 64 | 65 | BasicCli.GlobalConfigMode.addCommandClass( MoveAccessInterfaceCmd ) 66 | 67 | 68 | @EosSdkCli.CustomCli("MyCustomMoveAccessInterfaceCli") 69 | def Plugin(sdk): 70 | global mySdk, ethIntfMgr 71 | mySdk = sdk 72 | ethIntfMgr = mySdk.get_eth_intf_mgr() 73 | -------------------------------------------------------------------------------- /examples/MplsNexthopGroups.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | class my_agent : public eos::agent_handler { 14 | public: 15 | eos::agent_mgr * agentMgr_; 16 | eos::ip_route_mgr * ipMgr_; 17 | eos::nexthop_group_mgr * nhgMgr_; 18 | 19 | explicit my_agent(eos::sdk & sdk) 20 | : eos::agent_handler(sdk.get_agent_mgr()), 21 | agentMgr_(sdk.get_agent_mgr()), 22 | ipMgr_(sdk.get_ip_route_mgr()), 23 | nhgMgr_(sdk.get_nexthop_group_mgr()) { 24 | printf("Constructing my agent...\n"); 25 | } 26 | 27 | void create_nexthop_group(std::string name) { 28 | printf("Creating nexthop group\n"); 29 | eos::nexthop_group_t nhg = eos::nexthop_group_t(name, 30 | eos::NEXTHOP_GROUP_MPLS); 31 | 32 | eos::nexthop_group_mpls_action_t mplsActionA( 33 | eos::MPLS_ACTION_PUSH, {eos::mpls_label_t(30), eos::mpls_label_t(31)}); 34 | eos::nexthop_group_mpls_action_t mplsActionB( 35 | eos::MPLS_ACTION_PUSH, {eos::mpls_label_t(40), eos::mpls_label_t(41)}); 36 | 37 | // Send 2/3rds of traffic to nexthop 10.0.0.33 with the [30, 31] 38 | // label stack: 39 | 40 | eos::nexthop_group_entry_t nhe1(eos::ip_addr_t("10.0.0.33")); 41 | nhe1.mpls_action_is(mplsActionA); 42 | nhg.nexthop_set(1, nhe1); 43 | nhg.nexthop_set(2, nhe1); 44 | 45 | // Send 1/3rd of traffic to nexthop 10.0.0.44 with the [40, 41] 46 | // label stack: 47 | eos::nexthop_group_entry_t nhe2(eos::ip_addr_t("10.0.0.44")); 48 | nhe2.mpls_action_is(mplsActionB); 49 | nhg.nexthop_set(3, nhe2); 50 | 51 | // And commit it to Sysdb! 52 | nhgMgr_->nexthop_group_set(nhg); 53 | } 54 | 55 | void on_initialized() { 56 | printf("Initializing my agent...\n"); 57 | 58 | create_nexthop_group("MplsNhg1"); 59 | eos::ip_route_key_t routeKey( 60 | eos::ip_prefix_t(eos::ip_addr_t("172.1.1.4"), 32)); 61 | eos::ip_route_t route(routeKey); 62 | eos::ip_route_via_t via(routeKey); 63 | via.nexthop_group_is("MplsNhg1"); 64 | 65 | ipMgr_->ip_route_set(route); 66 | ipMgr_->ip_route_via_set(via); 67 | 68 | printf("Done!\n"); 69 | agentMgr_->exit(); // (we'll just exit after this demo) 70 | } 71 | }; 72 | 73 | int main(int argc, char ** argv) { 74 | eos::sdk sdk; 75 | my_agent agent(sdk); 76 | sdk.main_loop(argc, argv); 77 | } 78 | -------------------------------------------------------------------------------- /eos/inline/exception.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_EXCEPTION_H 5 | #define EOS_INLINE_EXCEPTION_H 6 | 7 | namespace eos { 8 | 9 | inline 10 | error::error(std::string const & msg) noexcept : msg_(msg) { 11 | } 12 | 13 | inline 14 | error::~error() noexcept { 15 | } 16 | 17 | inline std::string const & 18 | error::msg() const noexcept { 19 | return msg_; 20 | } 21 | 22 | inline const char * 23 | error::what() const noexcept { 24 | return msg_.c_str(); 25 | } 26 | 27 | inline 28 | invalid_argument_error::~invalid_argument_error() noexcept { 29 | } 30 | 31 | inline void 32 | invalid_argument_error::raise() const { 33 | throw *this; 34 | } 35 | 36 | inline std::string 37 | invalid_argument_error::argument_name() const noexcept { 38 | return argument_name_; 39 | } 40 | 41 | inline 42 | invalid_range_error::~invalid_range_error() noexcept { 43 | } 44 | 45 | inline void 46 | invalid_range_error::raise() const { 47 | throw *this; 48 | } 49 | 50 | inline uint32_t 51 | invalid_range_error::min_valid() const noexcept { 52 | return min_valid_; 53 | } 54 | 55 | inline uint32_t 56 | invalid_range_error::max_valid() const noexcept { 57 | return max_valid_; 58 | } 59 | 60 | inline 61 | configuration_error::configuration_error(std::string const & name) noexcept 62 | : error(name) { 63 | } 64 | 65 | inline 66 | configuration_error::~configuration_error() noexcept { 67 | } 68 | 69 | inline void 70 | configuration_error::raise() const { 71 | throw *this; 72 | } 73 | 74 | inline unconfigured_agent_error::~unconfigured_agent_error() noexcept { 75 | } 76 | 77 | inline void unconfigured_agent_error::raise() const { 78 | throw *this; 79 | } 80 | 81 | inline std::string unconfigured_agent_error::agent_name() const noexcept { 82 | return agent_name_; 83 | } 84 | 85 | inline 86 | unsupported_error::unsupported_error(std::string const & msg) noexcept : error(msg) { 87 | } 88 | 89 | inline 90 | unsupported_error::~unsupported_error() noexcept { 91 | } 92 | 93 | inline void 94 | unsupported_error::raise() const { 95 | throw *this; 96 | } 97 | 98 | inline 99 | no_scoped_lock_obtained_error::no_scoped_lock_obtained_error() noexcept : 100 | error("eos::sdk_scoped_lock not grabbed when calling an api while " 101 | "multithreaded") { 102 | } 103 | 104 | inline 105 | no_scoped_lock_obtained_error::~no_scoped_lock_obtained_error() noexcept { 106 | } 107 | 108 | inline void 109 | no_scoped_lock_obtained_error::raise() const { 110 | throw *this; 111 | } 112 | 113 | } 114 | 115 | #endif // EOS_INLINE_EXCEPTION_H 116 | -------------------------------------------------------------------------------- /eos/inline/types/bgp_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_BGP_IMPL_H 5 | #define EOS_INLINE_TYPES_BGP_IMPL_H 6 | 7 | namespace eos { 8 | 9 | bgp_peer_key_impl_t::bgp_peer_key_impl_t() : 10 | vrf_name_(), peer_addr_() { 11 | } 12 | 13 | bgp_peer_key_impl_t::bgp_peer_key_impl_t(std::string const & vrf_name, 14 | ip_addr_t const & peer_addr) : 15 | vrf_name_(vrf_name), peer_addr_(peer_addr) { 16 | } 17 | 18 | std::string 19 | bgp_peer_key_impl_t::vrf_name() const { 20 | return vrf_name_; 21 | } 22 | 23 | void 24 | bgp_peer_key_impl_t::vrf_name_is(std::string const & vrf_name) { 25 | vrf_name_ = vrf_name; 26 | } 27 | 28 | void 29 | bgp_peer_key_impl_t::vrf_name_is(std::string && vrf_name) { 30 | vrf_name_ = std::move(vrf_name); 31 | } 32 | 33 | ip_addr_t 34 | bgp_peer_key_impl_t::peer_addr() const { 35 | return peer_addr_; 36 | } 37 | 38 | void 39 | bgp_peer_key_impl_t::peer_addr_is(ip_addr_t const & peer_addr) { 40 | peer_addr_ = peer_addr; 41 | } 42 | 43 | void 44 | bgp_peer_key_impl_t::peer_addr_is(ip_addr_t && peer_addr) { 45 | peer_addr_ = std::move(peer_addr); 46 | } 47 | 48 | bool 49 | bgp_peer_key_impl_t::operator==(bgp_peer_key_impl_t const & other) const { 50 | return vrf_name_ == other.vrf_name_ && 51 | peer_addr_ == other.peer_addr_; 52 | } 53 | 54 | bool 55 | bgp_peer_key_impl_t::operator!=(bgp_peer_key_impl_t const & other) const { 56 | return !operator==(other); 57 | } 58 | 59 | bool 60 | bgp_peer_key_impl_t::operator<(bgp_peer_key_impl_t const & other) const { 61 | if(vrf_name_ != other.vrf_name_) { 62 | return vrf_name_ < other.vrf_name_; 63 | } else if(peer_addr_ != other.peer_addr_) { 64 | return peer_addr_ < other.peer_addr_; 65 | } 66 | return false; 67 | } 68 | 69 | uint32_t 70 | bgp_peer_key_impl_t::hash() const { 71 | hash_mix h; 72 | mix_me(h); 73 | return h.result(); 74 | } 75 | 76 | void 77 | bgp_peer_key_impl_t::mix_me(hash_mix & h) const { 78 | h.mix(vrf_name_); // std::string 79 | h.mix(peer_addr_); // ip_addr_t 80 | } 81 | 82 | std::string 83 | bgp_peer_key_impl_t::to_string() const { 84 | std::ostringstream ss; 85 | ss << "bgp_peer_key_t("; 86 | ss << "vrf_name='" << vrf_name_ << "'"; 87 | ss << ", peer_addr=" << peer_addr_; 88 | ss << ")"; 89 | return ss.str(); 90 | } 91 | 92 | std::ostream& 93 | operator<<(std::ostream& os, const bgp_peer_key_impl_t& obj) { 94 | os << obj.to_string(); 95 | return os; 96 | } 97 | 98 | 99 | 100 | 101 | } 102 | 103 | #include 104 | 105 | #endif // EOS_INLINE_TYPES_BGP_IMPL_H 106 | -------------------------------------------------------------------------------- /eos/inline/types/class_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | #ifndef EOS_INLINE_TYPES_CLASS_MAP_H 5 | #define EOS_INLINE_TYPES_CLASS_MAP_H 6 | 7 | namespace eos { 8 | 9 | acl_key_t 10 | class_map_rule_t::acl_key() const { 11 | return pimpl->acl_key(); 12 | } 13 | bool 14 | class_map_rule_t::operator==(class_map_rule_t const & other) const { 15 | return pimpl->operator==(*other.pimpl); 16 | } 17 | bool 18 | class_map_rule_t::operator!=(class_map_rule_t const & other) const { 19 | return pimpl->operator!=(*other.pimpl); 20 | } 21 | uint32_t 22 | class_map_rule_t::hash() const { 23 | return pimpl->hash(); 24 | } 25 | void 26 | class_map_rule_t::mix_me(hash_mix & h) const { 27 | pimpl->mix_me(h); 28 | } 29 | std::string 30 | class_map_rule_t::to_string() const { 31 | return pimpl->to_string(); 32 | } 33 | std::ostream& 34 | operator<<(std::ostream& os, const class_map_rule_t& obj) { 35 | return operator<<(os, *obj.pimpl); 36 | } 37 | 38 | 39 | class_map_key_t 40 | class_map_t::key() const { 41 | return pimpl->key(); 42 | } 43 | void 44 | class_map_t::key_is(class_map_key_t const & key) { 45 | pimpl->key_is(key); 46 | } 47 | void 48 | class_map_t::key_is(class_map_key_t && key) { 49 | pimpl->key_is(std::move(key)); 50 | } 51 | std::map const & 52 | class_map_t::rules() const { 53 | return pimpl->rules(); 54 | } 55 | void 56 | class_map_t::rules_is(std::map const & rules) { 57 | pimpl->rules_is(rules); 58 | } 59 | void 60 | class_map_t::rules_is(std::map && rules) { 61 | pimpl->rules_is(std::move(rules)); 62 | } 63 | void 64 | class_map_t::rule_set(uint32_t key, class_map_rule_t const & value) { 65 | pimpl->rule_set(key, value); 66 | } 67 | void 68 | class_map_t::rule_set(uint32_t key, class_map_rule_t && value) { 69 | pimpl->rule_set(key, std::move(value)); 70 | } 71 | void 72 | class_map_t::rule_del(uint32_t key) { 73 | pimpl->rule_del(key); 74 | } 75 | bool 76 | class_map_t::operator==(class_map_t const & other) const { 77 | return pimpl->operator==(*other.pimpl); 78 | } 79 | bool 80 | class_map_t::operator!=(class_map_t const & other) const { 81 | return pimpl->operator!=(*other.pimpl); 82 | } 83 | uint32_t 84 | class_map_t::hash() const { 85 | return pimpl->hash(); 86 | } 87 | void 88 | class_map_t::mix_me(hash_mix & h) const { 89 | pimpl->mix_me(h); 90 | } 91 | std::string 92 | class_map_t::to_string() const { 93 | return pimpl->to_string(); 94 | } 95 | std::ostream& 96 | operator<<(std::ostream& os, const class_map_t& obj) { 97 | return operator<<(os, *obj.pimpl); 98 | } 99 | 100 | } 101 | 102 | #endif // EOS_INLINE_TYPES_CLASS_MAP_H 103 | -------------------------------------------------------------------------------- /eos/route_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | /** 5 | * @file 6 | * Route Map management module. 7 | * 8 | * Route map is a ordered set of route map entry statement that manage the 9 | * redistribution of IP routes into the protocol domain and modify the attrbutes of 10 | * routes. 11 | * 12 | * This module provides APIs to query Route Map information. 13 | * 14 | */ 15 | 16 | #ifndef EOS_ROUTE_MAP_H 17 | #define EOS_ROUTE_MAP_H 18 | 19 | #include 20 | #include 21 | 22 | namespace eos { 23 | 24 | /** 25 | * A manager of route map configurations. 26 | * 27 | * A example of the API usage is in example/RouteMapAgent.cpp 28 | * 29 | */ 30 | class EOS_SDK_PUBLIC route_map_mgr { 31 | public: 32 | virtual ~route_map_mgr(); 33 | 34 | #if !GUARD_ROUTE_MAP_SUPPORT 35 | /// Returns the priority value of eossdk route map configuration. 36 | virtual uint8_t priority() const = 0; 37 | 38 | /// Configures the priority value of eossdk route map configuration. 39 | virtual void priority_is(uint8_t) = 0; 40 | 41 | /** 42 | * Returns a eossdk route map with corresponding route map name, which contains 43 | * route map entries. Returns an empty route_map_t if no matching route map was 44 | * found. 45 | */ 46 | virtual route_map_t route_map(route_map_name_t const &) const = 0; 47 | 48 | /** 49 | * Returns a route map entry with the corresponding sequence number in 50 | * corresponding route map. Returns an empty route_map_entry_t if no matching 51 | * route map entry was found. 52 | */ 53 | virtual route_map_entry_t 54 | route_map_entry(route_map_name_t const &, 55 | route_map_sequence_number_t) const = 0; 56 | 57 | /// Creates or updates a route map. 58 | virtual void route_map_set(route_map_name_t const &, 59 | route_map_t const &) = 0; 60 | 61 | /// Creates or updates a route map entry in corresponding route map. 62 | virtual void route_map_entry_set(route_map_name_t const &, 63 | route_map_sequence_number_t, 64 | route_map_entry_t const &) = 0; 65 | 66 | /// Removes the corresponding route map from the configuration if exists. 67 | virtual void route_map_del(route_map_name_t const &) = 0; 68 | 69 | /// Removes the corresponding route map entry from a given route map. 70 | virtual void route_map_entry_del(route_map_name_t const &, 71 | route_map_sequence_number_t) = 0; 72 | #endif 73 | 74 | protected: 75 | route_map_mgr() EOS_SDK_PRIVATE; 76 | 77 | private: 78 | EOS_SDK_DISALLOW_COPY_CTOR(route_map_mgr); 79 | }; 80 | 81 | } // namespace eos 82 | 83 | #endif // EOS_ROUTE_MAP_H 84 | 85 | -------------------------------------------------------------------------------- /eos/bgp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Arista Networks, Inc. All rights reserved. 2 | // Arista Networks, Inc. Confidential and Proprietary. 3 | 4 | /** 5 | * @file 6 | * BGP management module. 7 | * 8 | * Border Gateway Protocol (BGP) is a standardized exterior gateway routing protocol 9 | * designed to exchange routing and reachability information among autonomous 10 | * systems (AS). In EOS, BGP follows RFC4271. 11 | * 12 | * This module provides APIs to query BGP information including BGP peer state. 13 | * 14 | * An example of the API usage is in examples/BgpAgent.cpp 15 | * 16 | */ 17 | 18 | #ifndef EOS_BGP_H 19 | #define EOS_BGP_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace eos { 28 | 29 | class bgp_mgr; 30 | 31 | /** 32 | * The BGP peer handler. 33 | * 34 | * This class provides handler APIs to react to a BGP peer's session state change. 35 | */ 36 | class EOS_SDK_PUBLIC bgp_peer_handler : public base_handler { 38 | public: 39 | explicit bgp_peer_handler(bgp_mgr *mgr); 40 | bgp_mgr * get_bgp_mgr() const; 41 | 42 | 43 | /// Register to receive notifications when any peer changes state. 44 | void watch_all_peers(bool); 45 | 46 | /// Register to receive notifications when the specified peer changes state. 47 | void watch_peer(bgp_peer_key_t const & peer_key, bool); 48 | 49 | /// Called when BGP peer state change 50 | virtual void on_peer_state(bgp_peer_key_t const & peer_key, 51 | bgp_peer_state_t peer_state); 52 | 53 | /// Called when a BGP peer is created 54 | virtual void on_peer_set(bgp_peer_key_t const & peer_key); 55 | 56 | /// Called when a BGP peer is deleted 57 | virtual void on_peer_del(bgp_peer_key_t const & peer_key); 58 | }; 59 | 60 | /** 61 | * A manager of BGP configurations. 62 | */ 63 | class EOS_SDK_PUBLIC bgp_mgr : public base_mgr { 64 | public: 65 | virtual ~bgp_mgr(); 66 | 67 | /** 68 | * Test for existence of a BGP peer. 69 | */ 70 | virtual bool exists(bgp_peer_key_t const & peer_key) const = 0; 71 | 72 | /** 73 | * Returns the state of a peer session. 74 | * 75 | * If the given peer does not have a valid status or it didn't match any peers 76 | * in the system, this would returns PEER_UNKNOWN; 77 | */ 78 | virtual bgp_peer_state_t peer_state(bgp_peer_key_t const & peer_key) const = 0; 79 | 80 | protected: 81 | bgp_mgr() EOS_SDK_PRIVATE; 82 | friend class bgp_peer_handler; 83 | 84 | private: 85 | EOS_SDK_DISALLOW_COPY_CTOR(bgp_mgr); 86 | 87 | }; 88 | 89 | } // namespace eos 90 | 91 | #include 92 | 93 | #endif // EOS_BGP_H 94 | 95 | --------------------------------------------------------------------------------