7 #include <vnc_cfg_types.h>
8 #include <agent_types.h>
44 return (str.find(sub_str) != string::npos);
48 const std::string &name,
50 const std::string &vxlan_id,
51 const std::string &ipam_name) :
53 vxlan_id_(vxlan_id), ipam_name_(ipam_name) {
55 boost::system::error_code ec;
74 resp_ =
new VnListResp();
93 const std::vector<VnIpam> VnIpams = vn->
GetVnIpam();
94 std::vector<VnIpam>::const_iterator pos;
95 bool ipam_flag =
true;
96 if (VnIpams.size() == 0) {
99 for(pos=VnIpams.begin();pos < VnIpams.end();pos++) {
104 if (ipam_flag ==
true) {
125 resp_ =
new SgListResp();
133 resp_ =
new VmListResp();
137 const std::string &
type,
138 const std::string &name,
139 const std::string &u,
140 const std::string &vn,
141 const std::string &mac,
142 const std::string &v4,
143 const std::string &v6,
144 const std::string &parent,
145 const std::string &ip_active,
146 const std::string &ip6_active,
147 const std::string &l2_active) :
149 vn_(vn), mac_str_(mac), v4_str_(v4), v6_str_(v6),
150 parent_uuid_str_(parent), ip_active_str_(ip_active),
151 ip6_active_str_(ip6_active), l2_active_str_(l2_active) {
153 boost::system::error_code ec;
155 v4_ = Ip4Address::from_string(v4, ec);
156 v6_ = Ip6Address::from_string(v6, ec);
165 resp_ =
new ItfResp();
175 if (
type_.empty() ==
false) {
176 if (
type_ ==
"physical" &&
194 if (
vn_.empty() ==
false ||
mac_str_.empty() ==
false ||
236 if (
vn_.empty() ==
false && vmi->
vn()) {
244 if (
v4_str_.empty() ==
false) {
250 if (
v6_str_.empty() ==
false) {
279 resp_ =
new NhListResp();
283 const std::string &
type,
284 const std::string &nh_index,
285 const std::string &policy_enabled) :
286 AgentSandesh(context,
""), type_(type), nh_index_(nh_index),
287 policy_enabled_(policy_enabled) {
295 if (
type_.empty() ==
false) {
297 if (
type_ ==
"invalid" &&
300 if (
type_ ==
"discard" &&
303 if (
type_ ==
"l2-receive" &&
306 if (
type_ ==
"receive" &&
309 if (
type_ ==
"resolve" &&
312 if (
type_ ==
"arp" &&
315 if (
type_ ==
"vrf" &&
318 if (
type_ ==
"interface" &&
321 if (
type_ ==
"tunnel" &&
324 if (
type_ ==
"mirror" &&
327 if (
type_ ==
"composite" &&
330 if (
type_ ==
"vlan" &&
337 bool policy_flag =
true;
346 if (((nh->
id()) == boost::lexical_cast<uint32_t>(
nh_index_)) ==
false)
365 resp_ =
new MplsResp();
369 const std::string &
type,
370 const std::string &label) :
379 if (
label_.empty() ==
false) {
380 if (((mplsl->
label()) == boost::lexical_cast<uint32_t>(
label_)) ==
false)
383 if (
type_ ==
"invalid" &&
386 if (
type_ ==
"interface" &&
389 if (
type_ ==
"vlan" &&
392 if (
type_ ==
"vrf" &&
395 if (
type_ ==
"composite" &&
413 resp_ =
new VrfListResp();
421 resp_ =
new Inet4UcRouteResp();
437 resp_ =
new Inet4MplsUcRouteResp();
453 resp_ =
new Inet6UcRouteResp();
469 resp_ =
new Inet4McRouteResp();
485 resp_ =
new EvpnRouteResp();
498 resp_ =
new Layer2RouteResp();
511 resp_ =
new BridgeRouteResp();
528 resp_ =
new AclResp();
541 resp_ =
new MirrorEntryResp();
545 const std::string &analyzer_name) :
546 AgentSandesh(context,
""), analyzer_name_(analyzer_name) {
572 resp_ =
new VrfAssignResp();
580 resp_ =
new VxLanResp();
584 const std::string &vxlan_id):
594 if (((identry->
vxlan_id()) == boost::lexical_cast<uint32_t>(
vxlan_id_)) ==
false) {
613 resp_ =
new ServiceInstanceResp();
622 ArgumentMap::iterator it =
arguments_.find(key);
633 std::stringstream ss;
635 ArgumentMap::iterator it =
arguments_.find(key);
637 it->second = ss.str();
646 ArgumentMap::iterator it =
arguments_.find(key);
656 ArgumentMap::const_iterator it =
arguments_.find(key);
666 ArgumentMap::const_iterator it =
arguments_.find(key);
674 ArgumentMap::const_iterator it =
arguments_.find(key);
679 *val = strtoul(it->second.c_str(), NULL, 0);
684 ArgumentMap::const_iterator it =
arguments_.find(key);
688 return (strtoul(it->second.c_str(), NULL, 0));
692 ArgumentMap::iterator it =
arguments_.begin();
694 *str += it->first +
':' + it->second;
702 static int Split(
const string &s,
char delim, vector<string> &tokens) {
703 std::stringstream ss(s);
706 while(getline(ss, item, delim)) {
707 tokens.push_back(item);
715 vector<string> token_list;
716 int count =
Split(str,
',', token_list);
718 for (vector<string>::iterator it = token_list.begin();
719 it != token_list.end(); ++it) {
721 if (
Split((*it),
':', args) < 2) {
724 string val = (*it).substr(args[0].length() + 1);
735 if (first < 0 || first > len)
749 return first + AgentSandesh::kEntriesPerPage - 1;
755 if (first < 0 || last < 0)
760 return (last - first + 1);
764 const std::string &context) {
765 ErrorResp *resp =
new ErrorResp();
769 s << table->
name() <<
":" << msg;
770 resp->set_resp(s.str());
774 resp->set_context(context);
783 args.
Add(
"table", table->
name());
784 args.
Add(
"begin", begin);
785 args.
Add(
"end", end);
790 filter->
Del(
"table");
791 filter->
Del(
"begin");
797 void PageReq::HandleRequest()
const {
824 const string &context) {
835 if (args.
Get(
"table", &table_name) ==
false ||
836 args.
Get(
"begin", &first) ==
false ||
837 args.
Get(
"end", &last) ==
false) {
854 sandesh->DoSandesh(sandesh, first, last);
866 sandesh->DoSandesh(sandesh, first, last);
881 int first,
int count,
int match_count,
882 int table_size,
int page_size) {
888 int len = table->
Size();
889 req->set_table_size(len);
892 int last = first + count - 1;
893 std::stringstream entries_ss;
894 if (match_count >= 0) {
896 entries_ss <<
" 0 / " << match_count;
898 entries_ss << first <<
"-" << last <<
"/" << match_count;
901 entries_ss << first <<
"-" << last;
903 req->set_entries(entries_ss.str());
906 int next_page_first = last + 1;
907 int next_page_last = next_page_first + page_size - 1;
908 if (match_count >= 0 && next_page_last > match_count) {
909 next_page_last = match_count - 1;
912 if (next_page_last >= table_size) {
913 next_page_last = table_size - 1;
916 if ((match_count >= 0 && next_page_first < match_count) ||
917 (match_count < 0 && next_page_first < table_size)) {
919 EncodeOne(&s, table, next_page_first, next_page_last, &filter);
920 req->set_next_page(s);
929 prev_page_first = first - page_size;
932 if (prev_page_first < 0)
940 prev_page_last = prev_page_first + page_size;
943 if (prev_page_last >= first)
944 prev_page_last = first - 1;
946 EncodeOne(&s, table, prev_page_first, prev_page_last, &filter);
947 req->set_prev_page(s);
955 EncodeOne(&s, table, 0, (page_size - 1), &filter);
958 req->set_first_page(s);
972 if (table == NULL || part == NULL) {
977 int len = (int)table->
Size();
991 sandesh->DoSandeshInternal(sandesh, first, last);
1009 if (
Filter(entry) ==
false)
1033 (
static_cast<DBTable *
>(partition))->ReleaseWalker(walk_ref);
1037 Pagination *page =
new Pagination();
1044 table->
Size(), page_size);
1049 void AgentInitStateReq::HandleRequest()
const {
1050 AgentInitState *resp =
new AgentInitState();
1051 resp->set_context(context());
1054 resp->set_state(
"InitDone");
1056 resp->set_state(
"InProgress");
1061 void VrouterObjectLimitsReq::HandleRequest()
const {
1062 VrouterObjectLimitsResp *resp =
new VrouterObjectLimitsResp();
1063 resp->set_context(context());
1068 resp->set_vrouter_object_limit(vr_limits);
1073 const std::string &u) :
1075 boost::system::error_code ec;
1084 resp_ =
new HealthCheckSandeshResp();
1104 const std::string &u,
1105 const std::string &name,
1106 const std::string &
id) :
1115 resp_ =
new AgentQosConfigSandeshResp();
1127 if (
id_.empty() ==
false) {
1130 if (qos->
id() != id) {
1135 if (
name_.empty() ==
false &&
1155 const std::string &u,
1156 const std::string &name,
1157 const std::string &
id) :
1166 resp_ =
new ForwardingClassSandeshResp();
1178 if (
id_.empty() ==
false) {
1181 if (fc->
id() != id) {
1186 if (
name_.empty() ==
false &&
1206 const std::string &u,
1207 const std::string &name,
1208 const std::string &
id) :
1217 resp_ =
new QosQueueSandeshResp();
1228 if (
id_.empty() ==
false) {
1231 if (qos_queue->
id() != id) {
1236 if (
name_.empty() ==
false &&
1256 const std::string &u,
1257 const std::string &name) :
1259 boost::system::error_code ec;
1268 resp_ =
new BridgeDomainSandeshResp();
1279 if (
name_.empty() ==
false &&
1298 const std::string &u,
1299 const std::string &name) :
1301 boost::system::error_code ec;
1306 resp_ =
new ApplicationPolicySetResp();
1329 if (
name_.empty() ==
false &&
1338 const std::string &u,
1339 const std::string &name) :
1341 boost::system::error_code ec;
1350 resp_ =
new TagSandeshResp();
1355 dynamic_cast<const TagEntry *
>(entry);
1361 if (
name_.empty() ==
false &&
1380 resp_ =
new SLOListResp();
1388 resp_ =
new CryptTunnelResp();
1392 const std::string &remote_ip) :
1409 assert(crypt_tunnel_entry);
1421 resp_ =
new MulticastPolicyResp();
AgentMirrorSandesh(const std::string &context, const std::string &analyzer_name)
AgentVnSandesh(const std::string &context, const std::string &name, const std::string &u, const std::string &vxlan_id, const std::string &ipam_name)
DBTable * AgentGetTable()
DBTable * AgentGetTable()
virtual bool FilterToArgs(AgentSandeshArguments *args)
static void DoSandesh(AgentSandeshPtr sandesh, int start, int count)
const MacAddress & vm_mac() const
bool EntrySandesh(DBEntryBase *entry, int first, int last)
static Agent * GetInstance()
static boost::uuids::uuid StringToUuid(const std::string &str)
BridgeDomainSandesh(const std::string &context, const std::string &u, const std::string &name)
bool Run(PageRequest req)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
int Encode(std::string *str)
DBTable * AgentGetTable()
AgentRouteTable * GetInet4MulticastRouteTable() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
virtual bool Filter(const DBEntryBase *entry)
AgentRouteTable * GetEvpnRouteTable() const
std::string parent_uuid_str_
const std::string & name() const
virtual bool Filter(const DBEntryBase *entry)
bool UpdateResp(DBEntryBase *entry)
virtual bool FilterToArgs(AgentSandeshArguments *args)
std::string GetString(const std::string &key) const
const boost::uuids::uuid & GetUuid() const
DBTable * AgentGetTable()
bool UpdateResp(DBEntryBase *entry)
NextHopTable * nexthop_table() const
bool UpdateResp(DBEntryBase *entry)
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
bool DBEntrySandesh(Sandesh *resp, std::string &name) const
const NextHop * nexthop() const
DBTable * AgentGetTable()
bool stringToInteger(const std::string &str, NumberType &num)
const std::string & name() const
static int ComputeLast(int first, int last, int len)
DBTable * AgentGetTable()
DBTableWalkRef AllocWalker(WalkFn walk_fn, WalkCompleteFn walk_complete)
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
bool UpdateResp(DBEntryBase *entry)
const std::string & name() const
WorkQueue< PageRequest > page_request_queue_
InterfaceTable * interface_table() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
VnTable * vn_table() const
InetUnicastAgentRouteTable * GetInet4MplsUnicastRouteTable() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
DBTable * AgentGetTable()
virtual bool FilterToArgs(AgentSandeshArguments *args)
Interface * physical_interface() const
std::string policy_enabled_
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
static const uint16_t kEntriesPerPage
ForwardingClassSandesh(const std::string &context, const std::string &u, const std::string &name, const std::string &idx)
DBTable * AgentGetTable()
virtual bool FilterToArgs(AgentSandeshArguments *args)
DBTable * AgentGetTable()
MplsTable * mpls_table() const
Base class for all Route entries in agent.
DBTable * AgentGetTable()
bool UpdateResp(DBEntryBase *entry)
DBTable * AgentGetTable()
TagTable * tag_table() const
QosQueueTable * qos_queue_table() const
DBTable * AgentGetTable()
AgentHealthCheckSandesh(const std::string &context, const std::string &u)
DBTable * AgentGetTable()
MirrorTable * mirror_table() const
std::string ToString() const
bool Del(const std::string &key)
virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const =0
AgentPolicySetSandesh(const std::string &context, const std::string &uuid, const std::string &name)
DBTable * AgentGetTable()
virtual bool Filter(const DBEntryBase *entry)
DBTable * AgentGetTable()
void WalkAgain(DBTableWalkRef walk)
ServiceInstanceTable * service_instance_table() const
virtual size_t Size() const
static bool MatchUuid(const string &uuid_str, const boost::uuids::uuid &u, const boost::uuids::uuid val)
void MakeSandeshPageReq(PageReqData *req, DBTable *table, int first, int last, int end, int count, int page_size)
virtual bool FilterToArgs(AgentSandeshArguments *args)
virtual bool Filter(const DBEntryBase *entry)
PolicySetTable * policy_set_table() const
bool Get(const std::string &key, std::string *val) const
std::string ip6_active_str_
static void EncodeOne(string *s, DBTable *table, int begin, int end, AgentSandeshArguments *filter)
bool UpdateResp(DBEntryBase *entry)
QosQueueSandesh(const std::string &context, const std::string &u, const std::string &name, const std::string &id)
virtual bool Filter(const DBEntryBase *entry)
BridgeDomainTable * bridge_domain_table() const
AgentVxLanSandesh(const std::string &context, const std::string &vxlan_id)
const std::string & name() const
virtual bool Filter(const DBEntryBase *entry)
std::string analyzer_name_
boost::uuids::uuid parent_uuid_
VrfAssignTable * vrf_assign_table() const
virtual bool Filter(const DBEntryBase *entry)
DBTable * AgentGetTable()
AgentNhSandesh(const std::string &context, const std::string &type, const std::string &nh_index, const std::string &policy_enabled)
const boost::uuids::uuid & tag_uuid() const
AgentRouteTable * GetBridgeRouteTable() const
virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const
bool DBEntrySandesh(Sandesh *resp, std::string &name) const
DBTable * AgentGetTable()
const std::vector< VnIpam > & GetVnIpam() const
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
const VnEntry * vn() const
AgentCryptTunnelSandesh(const std::string &context, const std::string &name)
const std::string & name() const
CryptTunnelTable * crypt_tunnel_table() const
AgentSandeshManager * agent_sandesh_manager()
std::string l2_active_str_
bool UpdateResp(DBEntryBase *entry)
bool Add(const std::string &key, const std::string &val)
const boost::uuids::uuid & uuid() const
virtual bool Filter(const DBEntryBase *entry)
void AddPageRequest(const std::string &key, const std::string &context)
virtual bool FilterToArgs(AgentSandeshArguments *args)
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
DBTable * AgentGetTable()
virtual bool UpdateResp(DBEntryBase *entry)
virtual bool Filter(const DBEntryBase *entry)
VrfTable * vrf_table() const
const boost::uuids::uuid & uuid() const
const Ip4Address & primary_ip_addr() const
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
const boost::uuids::uuid & uuid() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
void DoSandeshInternal(AgentSandeshPtr sandesh, int start, int count)
const boost::uuids::uuid & uuid() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
virtual string ToString() const
int GetInt(const std::string &key) const
virtual DBTable * AgentGetTable()=0
uint32_t vxlan_id() const
HealthCheckTable * health_check_table() const
AgentQosConfigTable * qos_config_table() const
VxLanTable * vxlan_table() const
static const uint8_t entries_per_sandesh
SecurityLoggingObjectTable * slo_table() const
DBTable * AgentGetTable()
std::string ip_active_str_
static int Split(const string &s, char delim, vector< string > &tokens)
DBTable * AgentGetTable()
const Ip6Address & primary_ip6_addr() const
void set_context(std::string context)
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
boost::uuids::uuid uuid() const
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
AgentIntfSandesh(const std::string &context, const std::string &type, const std::string &name, const std::string &u, const std::string &vn, const std::string &mac, const std::string &v4, const std::string &v6, const std::string &parent, const std::string &ip_active, const std::string &ip6_active, const std::string &l2_active)
virtual bool Filter(const DBEntryBase *entry)
virtual bool Filter(const DBEntryBase *entry)
DBTable * AgentGetTable()
virtual bool DBEntrySandesh(Sandesh *resp, std::string &name) const =0
DBTable * AgentGetTable()
virtual bool FilterToArgs(AgentSandeshArguments *args)
static bool MatchSubString(const string &str, const string &sub_str)
bool UpdateResp(DBEntryBase *entry)
const std::string & name() const
static int ComputePageSize(int first, int last)
SgTable * sg_table() const
virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const
const std::string GetAnalyzerName() const
DBTable * AgentGetTable()
const std::string & name() const
#define AGENT_SANDESH_TASKNAME
AgentQosConfigSandesh(const std::string &context, const std::string &u, const std::string &name, const std::string &id)
bool PolicyEnabled() const
const boost::uuids::uuid & GetUuid() const
bool UpdateResp(DBEntryBase *entry)
const string & GetName() const
DBTable * AgentGetTable()
AgentMplsSandesh(const std::string &context, const std::string &type, const std::string &label)
AgentSandeshManager(Agent *agent)
const boost::uuids::uuid & uuid() const
ForwardingClassTable * forwarding_class_table() const
boost::intrusive_ptr< DBTableWalk > DBTableWalkRef
MulticastPolicyTable * mp_table() const
void SandeshError(const std::string &msg, const std::string &context)
bool UpdateResp(DBEntryBase *entry)
AclTable * acl_table() const
DBTable * AgentGetTable()
virtual bool Filter(const DBEntryBase *entry)
static int ComputeFirst(int first, int len)
virtual bool FilterToArgs(AgentSandeshArguments *args)
virtual void set_more(const bool val)=0
void SandeshDone(AgentSandeshPtr ptr, int first, int page_size, DBTable::DBTableWalkRef walk_ref, DBTableBase *partition)
bool UpdateResp(DBEntryBase *entry)
VmTable * vm_table() const
virtual bool FilterToArgs(AgentSandeshArguments *args)
DBTable * AgentGetTable()
DBTable * AgentGetTable()
DBTableBase * FindTable(const std::string &name)
virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const
int Decode(const std::string &str)
DBTable * AgentGetTable()
VrouterObjectLimits GetVrouterObjectLimits()
virtual bool Filter(const DBEntryBase *entry)
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
virtual bool Filter(const DBEntryBase *entry)