9 #if __GNUC_PREREQ(4, 5)
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wunused-result"
15 #include <boost/uuid/random_generator.hpp>
18 #if __GNUC_PREREQ(4, 6)
19 #pragma GCC diagnostic pop
28 #include <agent_types.h>
52 boost::system::error_code ec;
56 key.
handle = cfg.get_handle();
58 return "Invalid Handle";
61 MirrorCfgTree::iterator it;
64 return "Update not supported";
69 if (cfg.get_nic_assisted_mirroring()) {
70 if (cfg.get_nic_assisted_mirroring_vlan() == 0 ||
71 cfg.get_nic_assisted_mirroring_vlan() >= 4095) {
73 return "Invalid Vlan";
76 cfg.get_nic_assisted_mirroring_vlan());
97 entry->
data.
ip = cfg.get_ip();
101 if (cfg.get_mirror_vrf().empty()) {
108 dest_ip = IpAddress::from_string(entry->
data.
ip, ec);
109 if (ec.value() != 0) {
111 return "Invalid mirror destination address ";
116 return "Invalid mirror destination port ";
121 cfg.get_juniperheader());
135 dest_ip = IpAddress::from_string(cfg.get_vtep_dst_ip(), ec);
136 if (ec.value() != 0) {
138 return "Invalid mirror destination address ";
144 cfg.get_vni(), mirror_flag,
148 return "Mode not supported";
153 VnAclMap::iterator va_it;
156 const char *str = NULL;
159 dyn_acl_uuid = boost::uuids::random_generator() ();
161 acl_info.
id = dyn_acl_uuid;
168 dyn_acl_uuid = va_it->second.id;
169 va_it->second.num_of_entries++;
170 ace_id = ++va_it->second.ace_id_latest;
182 mc_tree_.insert(std::pair<MirrorCfgKey, MirrorCfgEntry *>(key, entry));
204 ace_spec.
id = ace_id;
229 if ((rs.
min == (uint16_t)-1) && (rs.
max == (uint16_t)-1)) {
236 if ((rs.
min == (uint16_t)-1) && (rs.
max == (uint16_t)-1)) {
252 boost::system::error_code ec;
253 action_spec.
ma.
ip = Ip4Address::from_string(entry->
data.
ip, ec);
254 if (ec.value() != 0) {
255 return "Invalid mirror destination address ";
260 ace_spec.
action_l.push_back(action_spec);
269 LOG(DEBUG,
"Ace add: " << data->
ace_add <<
", Ace spec id:"
273 req.
data.reset(data);
280 MirrorCfgTree::iterator it;
290 VnAclMap::iterator va_it;
292 va_it->second.num_of_entries--;
293 if (va_it->second.num_of_entries) {
299 areq.
key.reset(akey);
300 areq.
data.reset(adata);
312 areq.
key.reset(akey);
313 areq.
data.reset(NULL);
336 VnAclMap::const_iterator va_it;
339 return boost::uuids::nil_uuid();
342 return va_it->second.id;
346 MirrorCfgDisplayResp &resp) {
347 MirrorCfgTree::iterator it;
349 std::vector<MirrorCfgSandesh> mc_l;
352 if (!handle.empty() && (handle != mc_entry->
key.
handle)) {
355 MirrorCfgSandesh mc_s;
369 mc_s.set_ip(mc_entry->
data.
ip);
373 mc_l.push_back(mc_s);
375 resp.set_mcfg_l(mc_l);
379 MirrorCfgVnInfoResp &resp) {
380 VnAclMap::iterator it;
381 std::vector<VnAclInfo> vn_l;
383 if (!vn_name.empty() && (vn_name != it->first)) {
386 VnAclInfo vn_acl_info;
387 vn_acl_info.set_vn_name(it->first);
388 vn_acl_info.set_dyn_acl_uuid(
UuidToString(it->second.id));
389 vn_acl_info.set_num_of_entries(it->second.num_of_entries);
390 vn_l.push_back(vn_acl_info);
392 resp.set_vn_acl_info_l(vn_l);
395 void MirrorCreateReq::HandleRequest()
const {
397 MirrorCfgResp *resp =
new MirrorCfgResp();
398 resp->set_context(context());
407 void MirrorDeleteReq::HandleRequest()
const {
409 key.
handle = get_handle();
411 MirrorCfgResp *resp =
new MirrorCfgResp();
412 resp->set_context(context());
417 void MirrorCfgDisplayReq::HandleRequest()
const {
418 std::string handle = get_handle();
419 MirrorCfgDisplayResp *resp =
new MirrorCfgDisplayResp();
421 resp->set_context(context());
426 void MirrorCfgVnInfoReq::HandleRequest()
const {
427 std::string vn_name = get_vn_name();
428 MirrorCfgVnInfoResp *resp =
new MirrorCfgVnInfoResp();
430 resp->set_context(context());
444 boost::system::error_code ec;
447 key.
handle = intf_mirror.get_handle();
449 return "Invalid Handle";
452 IntfMirrorCfgTree::iterator it;
455 return "Update not supported";
460 if (intf_mirror.get_nic_assisted_mirroring()) {
461 if (intf_mirror.get_nic_assisted_mirroring_vlan() == 0 ||
462 intf_mirror.get_nic_assisted_mirroring_vlan() >= 4095) {
464 return "Invalid Vlan";
467 intf_mirror.get_nic_assisted_mirroring_vlan());
475 if (ec.value() != 0) {
477 return "Invalid mirror destination address ";
479 if (intf_mirror.get_udp_port() == 0) {
481 return "Invald mirror destination port ";
491 intf_mirror.get_juniperheader());
509 IpAddress dst_ip = IpAddress::from_string(intf_mirror.get_vtep_dst_ip(), ec);
510 if (ec.value() != 0) {
512 return "Invalid mirror destination address ";
519 intf_mirror.get_vni(), mirror_flag,
523 return "not supported";
526 intf_mc_tree_.insert(std::pair<MirrorCfgKey, IntfMirrorCfgEntry *>(key, entry));
536 req.
key.reset(intf_key);
539 req.
data.reset(intf_data);
549 IntfMirrorCfgTree::iterator it;
565 req.
key.reset(intf_key);
568 req.
data.reset(intf_data);
578 void IntfMirrorCreateReq::HandleRequest()
const {
580 MirrorCfgResp *resp =
new MirrorCfgResp();
581 resp->set_context(context());
590 void IntfMirrorDeleteReq::HandleRequest()
const {
592 key.
handle = get_handle();
594 MirrorCfgResp *resp =
new MirrorCfgResp();
595 resp->set_context(context());
596 resp->set_resp(
"Success");
602 IntfMirrorCfgDisplayResp &resp) {
603 IntfMirrorCfgTree::iterator it;
604 std::vector<IntfMirrorCfgSandesh> mc_l;
607 if (!handle.empty() && (handle != mc_entry->
key.
handle)) {
610 IntfMirrorCfgSandesh mc_s;
618 mc_l.push_back(mc_s);
620 resp.set_imcfg_l(mc_l);
623 void IntfMirrorCfgDisplayReq::HandleRequest()
const {
624 std::string handle = get_handle();
625 IntfMirrorCfgDisplayResp *resp =
new IntfMirrorCfgDisplayResp();
627 resp->set_context(context());
void SetMirrorCfgVnSandeshData(std::string &vn_name, MirrorCfgVnInfoResp &resp)
static const MacAddress & ZeroMac()
const char * Add(const MirrorCreateReq &cfg)
std::string dst_policy_id_str
IpAddress GetMirrorSourceIp(const IpAddress &dest)
static Agent * GetInstance()
static boost::uuids::uuid StringToUuid(const std::string &str)
AddressMatch::AddressType dst_addr_type
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u)
std::vector< AclEntrySpec > acl_entry_specs_
void SetMirrorCfgSandeshData(std::string &handle, MirrorCfgDisplayResp &resp)
IntfMirrorCfgTree intf_mc_tree_
std::string src_ip_prefix
ConfigManager * config_manager() const
boost::asio::ip::address IpAddress
std::unique_ptr< DBRequestData > data
AgentDBEntry * FindActiveEntry(const DBEntry *key)
InterfaceTable * interface_table() const
bool Enqueue(DBRequest *req)
bool CanUseNode(IFMapNode *node)
VnTable * vn_table() const
std::vector< RangeSpec > protocol
std::vector< AclAddressInfo > dst_ip_list
static std::string UuidToString(const boost::uuids::uuid &id)
std::vector< ActionSpec > action_l
std::vector< RangeSpec > src_port
void SetIntfMirrorCfgSandeshData(std::string &handle, IntfMirrorCfgDisplayResp &resp)
const std::string & fabric_vrf_name() const
boost::uuids::uuid intf_id
void BuildAddressInfo(const std::string &prefix, int plen, std::vector< AclAddressInfo > *list)
IFMapNode * FindNode(const std::string &name)
std::unique_ptr< DBRequestKey > key
void Delete(MirrorCfgKey &key)
static MirrorEntryData::MirrorEntryFlags DecodeMirrorFlag(const std::string &nh_mode, bool juniper_header)
boost::uuids::uuid AclUuid
static void DelMirrorEntry(const std::string &analyzer_name)
std::string analyzer_name
static void AddMirrorEntry(const std::string &analyzer_name, const std::string &vrf_name, const IpAddress &sip, uint16_t sport, const IpAddress &dip, uint16_t dport)
void Delete(MirrorCfgKey &key)
IntfMirrorCfgTable * interface_mirror_cfg_table() const
const char * UpdateAclEntry(AclUuid &id, bool create, MirrorCfgEntry *e, int ace_id)
std::string dst_ip_prefix
MirrorCfgTable * mirror_cfg_table() const
#define LOG(_Level, _Msg)
IFMapAgentTable * cfg_vn_table() const
AddressMatch::AddressType src_addr_type
const char * Add(const IntfMirrorCreateReq &cfg)
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
AclTable * acl_table() const
MirrorDestination mirror_dest
TrafficAction::TrafficActionType ta_type
virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
std::string src_policy_id_str
std::vector< AclAddressInfo > src_ip_list
const boost::uuids::uuid GetMirrorUuid(const std::string &vn_name) const
uint16_t mirror_port() const
boost::uuids::uuid acl_id
std::vector< RangeSpec > dst_port