8 #include <boost/cast.hpp>
15 #include <vnc_cfg_types.h>
16 #include <agent_types.h>
32 std::vector<AclEntryMatch *>::iterator it;
39 ActionList::iterator ial;
48 id_ = acl_entry_spec.
id;
113 if (acl_entry_spec.
protocol.size() > 0) {
115 std::vector<RangeSpec>::const_iterator it;
116 for (it = acl_entry_spec.
protocol.begin();
117 it != acl_entry_spec.
protocol.end(); it++) {
123 if (acl_entry_spec.
dst_port.size() > 0) {
125 std::vector<RangeSpec>::const_iterator it;
126 for (it = acl_entry_spec.
dst_port.begin();
127 it != acl_entry_spec.
dst_port.end(); it++) {
133 if (acl_entry_spec.
src_port.size() > 0) {
135 std::vector<RangeSpec>::const_iterator it;
136 for (it = acl_entry_spec.
src_port.begin();
137 it != acl_entry_spec.
src_port.end(); it++) {
146 matches_.push_back(service_group_match);
149 if (acl_entry_spec.
action_l.size() > 0) {
150 std::vector<ActionSpec>::const_iterator it;
151 for (it = acl_entry_spec.
action_l.begin();
152 it != acl_entry_spec.
action_l.end(); ++it) {
172 (*it).vrf_translate.ignore_acl());
179 qos_config_table()->FindByName((*it).qos_config_action.name());
199 ActionList::iterator al;
213 ActionList::iterator al;
218 qos_config_table()->FindByName(act->
name());
235 std::vector<AclEntryMatch *>::const_iterator it;
237 if (!((*it)->Match(&packet_header, info))) {
247 std::vector<AclEntryMatch *>::const_iterator mit;
249 (*mit)->SetAclEntryMatchSandeshData(data);
253 ActionList::const_iterator ait;
255 (*ait)->SetActionSandeshData(data.action_l);
260 data.rule_type =
"Terminal";
262 data.rule_type =
"Non-Terminal";
264 data.rule_type =
"Unknown";
282 data.ether_type =
"IPv4";
284 data.ether_type =
"IPv6";
309 std::vector<AclEntryMatch *>::const_iterator it =
matches_.begin();
310 std::vector<AclEntryMatch *>::const_iterator rhs_it = rhs.
matches_.begin();
313 if (**it == **rhs_it) {
325 ActionList::const_iterator action_it =
actions_.begin();
326 ActionList::const_iterator rhs_action_it = rhs.
actions_.begin();
327 while (action_it !=
actions_.end() &&
328 rhs_action_it != rhs.
actions_.end()) {
329 if (**action_it == **rhs_action_it) {
390 SecurityGroupList::const_iterator it;
391 for (it = sg_l->begin(); it != sg_l->end(); ++it) {
392 if (*it ==
id)
return true;
403 SecurityGroupList::const_iterator it;
404 for (it = sg_l.begin(); it != sg_l.end(); ++it) {
405 if (*it ==
id)
return true;
411 TagList::const_iterator it =
tags_.begin();
412 TagList::const_iterator pkt_it = pkt_tag_list.begin();
414 while(it !=
tags_.end() && pkt_it != pkt_tag_list.end()) {
416 if (*pkt_it == *it) {
433 if (it ==
tags_.end()) {
441 TagList::const_iterator it =
tags_.begin();
442 TagList::const_iterator pkt_it = pkt_tag_list.begin();
448 if(it ==
tags_.end() || pkt_it == pkt_tag_list.end())
451 while(it !=
tags_.end()) {
452 while(pkt_it != pkt_tag_list.end()) {
458 pkt_it = pkt_tag_list.begin();
466 if (list.size() == 0) {
470 std::vector<AclAddressInfo>::const_iterator it = list.begin();
471 while (it != list.end()) {
474 if (data.is_v4() && ip.is_v4()) {
475 if((mask.to_v4().to_ulong() & data.to_v4().to_ulong()) ==
476 ip.to_v4().to_ulong()) {
481 if (data.is_v6() && ip.is_v6()) {
485 Ip6Address::bytes_type ip6_bytes = ip6.to_bytes();
486 Ip6Address::bytes_type data6_bytes = data6.to_bytes();
487 Ip6Address::bytes_type mask6_bytes = mask6.to_bytes();
488 const uint32_t *ip6_words = (
const uint32_t *)ip6_bytes.data();
489 const uint32_t *data6_words = (
const uint32_t *)data6_bytes.data();
490 const uint32_t *mask6_words = (
const uint32_t *)mask6_bytes.data();
492 for (
int i = 0; i < 4; i++) {
493 if ((data6_words[i] & mask6_words[i]) != ip6_words[i]) {
509 const TagList &tag_list)
const {
534 VnListType::iterator it =
557 VnListType::iterator it =
585 if (
src_ != rhs_address_match.
src_) {
624 (
const std::vector<AclAddressInfo> &list) {
625 std::vector<AclAddressInfo>::const_iterator it = list.begin();
626 std::stringstream ss;
627 while (it != list.end()) {
630 ss << ip.to_string();
632 ss << mask.to_string();
634 if (it != list.end()) {
643 TagList::const_iterator it = list.begin();
644 std::stringstream ss;
646 if (it == list.end()) {
650 while (it != list.end()) {
653 if (it != list.end()) {
664 std::string *addr_type_str;
668 addr_type_str = &data.src_type;
671 addr_type_str = &data.dst_type;
676 *addr_type_str =
"ip";
679 *addr_type_str =
"network";
681 std::ostringstream ss;
684 *addr_type_str =
"sg";
686 *addr_type_str =
"tags";
689 *addr_type_str =
"AddressGroup";
690 std::ostringstream ss;
695 *str =
"Unknown Address Type";
696 *addr_type_str =
"unknown";
703 const uint16_t max_protocol)
705 Range *protocol_range =
new Range(min_protocol, max_protocol);
713 RangeSList::const_iterator rhs_it =
717 if (*it == *rhs_it) {
736 if(packet_header->
protocol < (*it).min ||
737 packet_header->
protocol > (*it).max) {
750 class SandeshRange proto;
751 proto.min = (*it).min;
752 proto.max = (*it).max;
753 data.proto_l.push_back(proto);
776 if (packet_header->
protocol < it->protocol.min ||
777 packet_header->
protocol > it->protocol.max) {
781 if (packet_header->
protocol != IPPROTO_TCP &&
782 packet_header->
protocol != IPPROTO_UDP &&
783 packet_header->
protocol != IPPROTO_SCTP) {
808 class SandeshRange proto;
809 proto.min = it->protocol.min;
810 proto.max = it->protocol.max;
811 data.proto_l.push_back(proto);
813 class SandeshRange port;
814 port.min = it->src_port.min;
815 port.max = it->src_port.max;
816 data.src_port_l.push_back(port);
818 port.min = it->dst_port.min;
819 port.max = it->dst_port.max;
820 data.dst_port_l.push_back(port);
834 TagList::const_iterator tag_type_it =
tag_list_.begin();
835 TagList::const_iterator src_tag_it = packet_header->
src_tags_.begin();
836 TagList::const_iterator dst_tag_it = packet_header->
dst_tags_.begin();
839 src_tag_it != packet_header->
src_tags_.end() &&
840 dst_tag_it != packet_header->
dst_tags_.end()) {
846 if (*tag_type_it < src_tag_type || *tag_type_it < dst_tag_type) {
850 if (*tag_type_it == src_tag_type &&
851 *tag_type_it == dst_tag_type) {
853 if (*src_tag_it == *dst_tag_it) {
862 if (*src_tag_it < *dst_tag_it) {
871 if (*tag_type_it > src_tag_type) {
875 if (*tag_type_it > dst_tag_type) {
898 std::stringstream str;
899 TagList::const_iterator it =
tag_list_.begin();
904 data.set_match_condition(str.str());
909 Range *port_range =
new Range(min_port, max_port);
914 const uint16_t max_port)
const {
917 if ((min_port == (*it).min) && (max_port == (*it).max)) {
928 RangeSList::const_iterator rhs_it = rhs_port_match.
port_ranges_.begin();
931 if (*it == *rhs_it) {
948 if (packet_header->
protocol != IPPROTO_TCP &&
949 packet_header->
protocol != IPPROTO_UDP) {
953 for (RangeSList::const_iterator it =
port_ranges_.begin();
955 if(packet_header->
src_port < (*it).min ||
956 packet_header->
src_port > (*it).max) {
967 for (RangeSList::const_iterator it =
port_ranges_.begin();
969 class SandeshRange port;
970 port.min = (*it).min;
971 port.max = (*it).max;
972 data.src_port_l.push_back(port);
980 if (packet_header->
protocol != IPPROTO_TCP &&
981 packet_header->
protocol != IPPROTO_UDP) {
985 for (RangeSList::const_iterator it =
port_ranges_.begin();
987 if(packet_header->
dst_port < (*it).min ||
988 packet_header->
dst_port > (*it).max) {
999 for (RangeSList::const_iterator it =
port_ranges_.begin();
1001 class SandeshRange port;
1002 port.min = (*it).min;
1003 port.max = (*it).max;
1004 data.dst_port_l.push_back(port);
bool Match(const PacketHeader *packet_header, FlowPolicyInfo *info) const
bool TagsMatch(const TagList &tags) const
const ActionList & Actions() const
std::string dst_policy_id_str
static std::string BuildTags(const TagList &list)
bool IsQosConfigResolved()
void SetAclEntryMatchSandeshData(AclEntrySandeshData &data)
void SetAclEntryMatchSandeshData(AclEntrySandeshData &data)
bool Match(const PacketHeader *packet_header, FlowPolicyInfo *info) const
static Agent * GetInstance()
AddressMatch::AddressType dst_addr_type
void SetIPAddress(const std::vector< AclAddressInfo > &list)
static const std::string & GetTypeStr(uint32_t tag_type)
void SetNetworkID(const uuid id)
std::list< TrafficAction * > ActionList
boost::asio::ip::address IpAddress
const AgentQosConfig * qos_config_ref() const
void SetSGId(const uint32_t id)
bool stringToInteger(const std::string &str, NumberType &num)
std::vector< int > SecurityGroupList
MirrorEntryRef mirror_entry_
bool operator==(const AclEntry &rhs) const
void SetAclEntryMatchSandeshData(AclEntrySandeshData &data)
std::vector< RangeSpec > protocol
std::vector< AclAddressInfo > dst_ip_list
const std::string & name() const
std::vector< ActionSpec > action_l
void SetAclEntrySandeshData(AclEntrySandeshData &data) const
ServiceGroupMatch::ServicePortList service_group
void SetTags(const TagList &tags)
bool AddressGroupMatch(const IpAddress &ip, const TagList &tags) const
std::vector< RangeSpec > src_port
static ActionList kEmptyActionList
#define ACL_TRACE(obj,...)
std::vector< AclAddressInfo > ip_list_
virtual bool Compare(const AclEntryMatch &rhs) const
const TagList & tags() const
virtual bool Compare(const AclEntryMatch &rhs) const
void SetNetworkIDStr(const std::string id)
static const std::string integerToString(const NumberType &num)
boost::asio::ip::address_v6 Ip6Address
const AclEntryID & id() const
static std::string BuildIpMaskList(const std::vector< AclAddressInfo > &list)
bool Match(const PacketHeader *packet_header, FlowPolicyInfo *info) const
void set_qos_config_ref(const AgentQosConfig *config)
RangeSList protocol_ranges_
bool Match(const PacketHeader *packet_header, FlowPolicyInfo *info) const
bool PortMatch(uint32_t sport, uint32_t dport) const
static bool SubnetMatch(const std::vector< AclAddressInfo > &list, const IpAddress &data)
bool SGMatch(const SecurityGroupList &sg_l, int id) const
void SetAclEntryMatchSandeshData(AclEntrySandeshData &data)
void SetPortRange(const uint16_t min_port, const uint16_t max_port)
virtual bool Compare(const AclEntryMatch &rhs) const
void SetAddressGroup(const std::vector< AclAddressInfo > &list, const TagList &tags)
bool ResyncQosConfigEntries()
std::vector< AclEntryMatch * > matches_
bool TagsMatchAG(const TagList &tags) const
bool Match(const PacketHeader *packet_header, FlowPolicyInfo *info) const
void SetProtocolRange(const uint16_t min, const uint16_t max)
void PopulateAclEntry(const AclEntrySpec &acl_entry_spec)
boost::intrusive_ptr< MirrorEntry > MirrorEntryRef
void SetAclEntryMatchSandeshData(AclEntrySandeshData &data)
static const uint32_t kTagTypeBitShift
AddressMatch::AddressType src_addr_type
ServicePortList service_port_list_
const ActionList & PacketMatch(const PacketHeader &packet_header, FlowPolicyInfo *info) const
virtual bool Compare(const AclEntryMatch &rhs) const
std::string src_policy_id_str
std::vector< AclAddressInfo > src_ip_list
bool CheckPortRanges(const uint16_t min_port, const uint16_t max_port) const
void set_mirror_entry(MirrorEntryRef me)
std::vector< RangeSpec > dst_port
std::vector< int > TagList