-
Notifications
You must be signed in to change notification settings - Fork 40
/
SdkImpl.cpp
188 lines (161 loc) · 5.66 KB
/
SdkImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// Copyright (c) 2014 Arista Networks, Inc. All rights reserved.
// Arista Networks, Inc. Confidential and Proprietary.
#include <cassert>
#include <cstring>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include "eos/exception.h"
#include "eos/panic.h"
#include "eos/event_loop.h"
#include "eos/sdk.h"
#include "SdkImpl.h"
#include "impl.h"
namespace eos {
#define SDK_INITIALIZATION_LIST \
acl_mgr_(0), \
agent_mgr_(0), \
aresolve_mgr_(0), \
bfd_session_mgr_(0), \
bgp_mgr_(0), \
bgp_path_mgr_(0), \
class_map_mgr_(0), \
decap_group_mgr_(0), \
directflow_mgr_(0), \
eapi_mgr_(0), \
eth_intf_mgr_(0), \
eth_phy_intf_mgr_(0), \
eth_phy_intf_counter_mgr_(0), \
eth_lag_intf_mgr_(0), \
event_loop_(0), \
fib_mgr_(0), \
hardware_table_mgr_(0), \
intf_mgr_helper_(0), \
intf_mgr_(0), \
intf_counter_mgr_(0), \
ip_intf_mgr_(0), \
ip_route_mgr_(0), \
lldp_mgr_(0), \
macsec_mgr_(0), \
mac_table_mgr_(0), \
mlag_mgr_(0), \
mount_mgr_(0), \
mpls_route_mgr_(0), \
mpls_vrf_label_mgr_(0), \
neighbor_table_mgr_(0), \
nexthop_group_mgr_(0), \
nexthop_group_tunnel_mgr_(0), \
policy_map_mgr_(0), \
route_map_mgr_(0), \
subintf_mgr_(0), \
system_mgr_(0), \
timeout_mgr_(0), \
vrf_mgr_(0), \
xcvr_mgr_(0) \
// this is code we share with the stubs, used to figure out the name of the agent
// based on /proc/self/cmdline (at that point we no longer have access to argv), and
// doing some massaging, like removing .py extensions and replacing wierd chars.
#include "GetAgentProcessName.cpp"
sdk::SdkImpl::SdkImpl() : SDK_INITIALIZATION_LIST {
name_ = get_agent_process_name();
eossdk_context_ = NULL;
impl.register_sdk(this);
print_profiles::set_print_profiles(name_.c_str());
}
sdk::SdkImpl::SdkImpl(std::string const name, void *eossdk_context)
: SDK_INITIALIZATION_LIST {
name_ = name;
eossdk_context_ = eossdk_context;
impl.register_sdk(this);
print_profiles::set_print_profiles(name_.c_str());
}
void
sdk::SdkImpl::main_loop(int argc, char ** argv) {
assert(!name_.empty() && "No agent name set");
impl.agent_name_is(name_.c_str());
print_profiles::write_profiles();
impl.main_loop();
}
void delete_agent_mgr(agent_mgr *);
sdk::SdkImpl::~SdkImpl() {
delete_agent_mgr(agent_mgr_);
}
void sdk::SdkImpl::initialize_context() {
}
INIT_STUB_MGR(acl_mgr)
INIT_STUB_MGR(agent_mgr)
INIT_STUB_MGR(aresolve_mgr)
INIT_STUB_MGR(bfd_session_mgr)
INIT_STUB_MGR(bgp_mgr)
INIT_STUB_MGR(bgp_path_mgr)
INIT_STUB_MGR(class_map_mgr)
INIT_STUB_MGR(decap_group_mgr)
INIT_STUB_MGR(directflow_mgr)
INIT_STUB_MGR(eapi_mgr)
INIT_STUB_MGR(eth_intf_mgr)
INIT_STUB_MGR(eth_phy_intf_mgr)
INIT_STUB_MGR(eth_phy_intf_counter_mgr)
INIT_STUB_MGR(eth_lag_intf_mgr)
INIT_STUB_MGR(hardware_table_mgr)
INIT_STUB_MGR(intf_mgr)
INIT_STUB_MGR(ip_intf_mgr)
INIT_STUB_MGR(ip_route_mgr)
INIT_STUB_MGR(lldp_mgr)
INIT_STUB_MGR(macsec_mgr)
INIT_STUB_MGR(mac_table_mgr)
INIT_STUB_MGR(mlag_mgr)
INIT_STUB_MGR(mpls_route_mgr)
INIT_STUB_MGR(mpls_vrf_label_mgr)
INIT_STUB_MGR(neighbor_table_mgr)
INIT_STUB_MGR(nexthop_group_mgr)
INIT_STUB_MGR(nexthop_group_tunnel_mgr)
INIT_STUB_MGR(policy_map_mgr)
INIT_STUB_MGR(route_map_mgr)
INIT_STUB_MGR(subintf_mgr)
INIT_STUB_MGR(system_mgr)
INIT_STUB_MGR(timeout_mgr)
INIT_STUB_MGR(vrf_mgr)
INIT_STUB_MGR(xcvr_mgr)
void sdk::SdkImpl::init_event_loop() {
if(!event_loop_) {
event_loop_ = new event_loop(0);
}
}
void sdk::SdkImpl::init_fib_mgr(mgr_mode_type_t mode) {
// TODO: No op impl.
}
// Explicit definition for counter manager init with arguments
intf_counter_mgr * new_intf_counter_mgr();
void sdk::SdkImpl::init_intf_counter_mgr( mgr_mode_type_t ) {
if(!intf_counter_mgr_) {
intf_counter_mgr_ = new_intf_counter_mgr();
}
}
void sdk::SdkImpl::init_mount_mgr() {
// BUG86400 - Not a public function
}
void sdk::SdkImpl::init_intf_mgr_helper() {
// BUG86400 - Not a public function
}
void default_signal_handler(int signo) {
// TODO: No op impl.
}
void internal_connection_buffer_size_is(uint32_t bytes) {
}
void api_trace_enable_is(bool new_api_trace) {
}
void param_trace_enable_is(bool new_param_trace) {
}
void api_trace_buffer_sizes_is(int(&size_spec)[10]) {
}
// Real functions to facilitate the making of customized sysdb-mount-profiles
// (to use in place of the brute-force one called "EosSdk", see
// /usr/lib/SysdbMountProfiles/EosSdkAll), an app can be started with the env var
// EOS_PRINT_PROFILES_AND_EXIT pointing to a filename where the profile should be
// written, then exit.
#include "MaybePrintProfilesAndExit.cpp"
sdk_scoped_lock::sdk_scoped_lock() {
}
sdk_scoped_lock::~sdk_scoped_lock() {
}
}