OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
acl_entry_spec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __AGENT_ACL_ENTRY_SPEC_H__
6 #define __AGENT_ACL_ENTRY_SPEC_H__
7 
8 #include <vector>
9 #include <boost/uuid/uuid.hpp>
10 
11 #include <base/address.h>
12 #include <cmn/agent_cmn.h>
13 #include <cmn/agent.h>
14 #include <vnc_cfg_types.h>
15 #include <filter/traffic_action.h>
16 #include <filter/acl_entry.h>
17 #include <filter/acl_entry_match.h>
18 #include <vnc_cfg_types.h>
19 
20 struct RangeSpec {
21  uint16_t min;
22  uint16_t max;
23 };
24 
27  uint32_t vni;
29 };
30 
33  juniper_header(true), nh_mode(""), nic_assisted_mirroring(false) { }
34  bool operator == (const MirrorActionSpec &rhs) const {
35  return analyzer_name == rhs.analyzer_name;
36  }
37  std::string analyzer_name;
38  std::string vrf_name;
41  uint16_t port;
42  std::string encap;
44  std::string nh_mode;
48 };
49 
53  vrf_name_(vrf_name), ignore_acl_(ignore_acl) { }
54  const std::string& vrf_name() const { return vrf_name_;}
55  bool ignore_acl() const { return ignore_acl_;}
56  void set_vrf_name(const std::string &vrf_name) {
58  }
61  }
62  std::string vrf_name_;
64 };
65 
67  QosConfigActionSpec() : name_(""), id_(-1) {}
68  QosConfigActionSpec(const std::string &qos_config_name):
69  name_(qos_config_name), id_(-1) {}
70  void set_name(const std::string &name) {
71  name_ = name;
72  }
73  const std::string& name() const {
74  return name_;
75  }
76 
77  void set_id(uint32_t id) {
78  id_ = id;
79  }
80 
81  uint32_t id() const {
82  return id_;
83  }
84 
85  void clear() {
86  name_ = "";
87  id_ = -1;
88  }
89  std::string name_;
90  uint32_t id_;
91 };
92 
93 struct ActionSpec {
94  /* For actions log, alert and host_based_service we don't have any specific field.
95  * Only ta_type of
96  * TrafficAction::LOG_ACTION
97  * TrafficAction::ALERT_ACTION and
98  * TrafficAction::HBF_ACTION is enough
99  */
107 };
108 
109 typedef enum AclTypeSpec {
110  NOT_USED = 0,
111  TERM = 1,
112  NON_TERM = 2,
113 } AclTypeSpecT;
114 
116 public:
117  //XXX Any field addition update Reverse API also
118  //so that bidirectionaly ACL spec can be update
120  dst_addr_type(AddressMatch::UNKNOWN_TYPE), terminal(true), family(Address::UNSPEC) { }
121  //AclEntrySpec(const AclEntrySpec &rhs);
125 
126  // Address
128  std::vector<AclAddressInfo> src_ip_list;
130  std::string src_policy_id_str;
132 
134  std::vector<AclAddressInfo> dst_ip_list;
136  std::string dst_policy_id_str;
138 
139  // Protocol
140  std::vector<RangeSpec> protocol;
141 
142  // Source port range
143  std::vector<RangeSpec> src_port;
144 
145  // Destination port range
146  std::vector<RangeSpec> dst_port;
147 
148  bool terminal;
151 
154 
155  // Action
156  std::vector<ActionSpec> action_l;
157 
158  // AddressFamily based on EtherType
160 
161  //XXX Any field addition update Reverse API also
162  //so that bidirectionaly ACL spec can be update
163 
164  // Rule-UUID
165  std::string rule_uuid;
166  bool Populate(const autogen::MatchConditionType *match_condition);
167  bool Populate(Agent *agent, IFMapNode *node,
168  const autogen::FirewallRule *fw_rule);
169  bool PopulateServiceGroup(const autogen::ServiceGroup *service_group);
170  void PopulateAction(const AclTable *acl_table,
171  const autogen::ActionListType &action_list);
172  void AddMirrorEntry(Agent *agent) const;
173  void BuildAddressInfo(const std::string &prefix, int plen,
174  std::vector<AclAddressInfo> *list);
175  void Reverse(AclEntrySpec *ace_spec, AclEntryID::Type type,
176  bool swap_address, bool swap_port);
177  void ReverseAddress(AclEntrySpec *ace_spec);
178  void ReversePort(AclEntrySpec *ace_spec);
179  bool BuildAddressGroup(Agent *agent, IFMapNode *node,
180  const std::string &name, bool source);
181  IFMapNode* GetAddressGroup(Agent *agent, IFMapNode *node,
182  const std::string &name);
183  void PopulateServiceType(const autogen::FirewallServiceType *fst);
184 };
185 
186 struct AclSpec {
187  AclSpec() : dynamic_acl(false) { };
188  typedef boost::uuids::uuid uuid;
190  // Dynamic
192  std::vector<AclEntrySpec> acl_entry_specs_;
193 };
194 
195 #endif
TagList dst_tags
bool ignore_acl() const
std::string dst_policy_id_str
void ReversePort(AclEntrySpec *ace_spec)
Definition: acl.cc:1120
void ReverseAddress(AclEntrySpec *ace_spec)
Definition: acl.cc:1104
VrfTranslateActionSpec vrf_translate
AddressMatch::AddressType dst_addr_type
std::vector< AclEntrySpec > acl_entry_specs_
std::string nh_mode
void set_name(const std::string &name)
Definition: acl.h:147
Family
Definition: address.h:24
void PopulateServiceType(const autogen::FirewallServiceType *fst)
Definition: acl.cc:1062
boost::asio::ip::address IpAddress
Definition: address.h:13
QosConfigActionSpec qos_config_action
void set_id(uint32_t id)
boost::uuids::uuid uuid
std::string vrf_name
std::vector< RangeSpec > protocol
std::vector< AclAddressInfo > dst_ip_list
uint32_t id() const
std::vector< ActionSpec > action_l
const std::string & vrf_name() const
ServiceGroupMatch::ServicePortList service_group
std::vector< RangeSpec > src_port
boost::uuids::uuid uuid
QosConfigActionSpec(const std::string &qos_config_name)
TagList src_tags
VrfTranslateActionSpec(std::string vrf_name, bool ignore_acl)
uint8_t type
Definition: load_balance.h:109
AclTypeSpecT type
MirrorActionSpec ma
MacAddress vtep_dst_mac
Definition: agent.h:358
void BuildAddressInfo(const std::string &prefix, int plen, std::vector< AclAddressInfo > *list)
Definition: acl.cc:1042
void Reverse(AclEntrySpec *ace_spec, AclEntryID::Type type, bool swap_address, bool swap_port)
Definition: acl.cc:1137
bool Populate(const autogen::MatchConditionType *match_condition)
std::string encap
bool BuildAddressGroup(Agent *agent, IFMapNode *node, const std::string &name, bool source)
Definition: acl.cc:1184
std::string rule_uuid
AclTypeSpec
bool PopulateServiceGroup(const autogen::ServiceGroup *service_group)
Definition: acl.cc:1091
bool operator==(const MirrorActionSpec &rhs) const
uint16_t nic_assisted_mirroring_vlan
void PopulateAction(const AclTable *acl_table, const autogen::ActionListType &action_list)
Definition: acl.cc:1475
StaticMirrorNhData staticnhdata
uint16_t max
std::string analyzer_name
TrafficAction::Action simple_action
void AddMirrorEntry(Agent *agent) const
Definition: acl.cc:1434
void set_ignore_acl(bool ignore_acl)
ActionSpec(TrafficAction::TrafficActionType type)
enum AclTypeSpec AclTypeSpecT
std::vector< ServicePort > ServicePortList
boost::uuids::uuid uuid
AclEntryID id
uint16_t min
const std::string & name() const
AddressMatch::AddressType src_addr_type
Address::Family family
IFMapNode * GetAddressGroup(Agent *agent, IFMapNode *node, const std::string &name)
Definition: acl.cc:1161
TrafficAction::TrafficActionType ta_type
void set_vrf_name(const std::string &vrf_name)
std::string src_policy_id_str
std::vector< AclAddressInfo > src_ip_list
bool dynamic_acl
TagList match_tags
std::vector< RangeSpec > dst_port
std::vector< int > TagList
Definition: agent.h:202