OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cfg_mirror.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __AGENT_MIRROR_CFG_H__
6 #define __AGENT_MIRROR_CFG_H__
7 
8 #include <map>
9 #include <cmn/agent_cmn.h>
10 #include <cmn/agent.h>
11 #include <agent_types.h>
12 
13 class MirrorCfgDisplayResp;
14 struct MirrorCfgKey {
15  std::string handle;
16 };
17 
18 struct MirrorCfgData {
23  ip(), udp_port(0), time_period(60) {};
25 
26  std::string apply_vn;
27  std::string src_vn;
28  std::string src_ip_prefix;
30 
31  // Destination
32  std::string dst_vn;
33  std::string dst_ip_prefix;
35 
36  // -1 on both start and end means any
37  // if there is no end_src_port, end_src_port will be same as start_src_port
40 
41  // Dest port, -1 means any
42  // if there is no end_dst_port, end_dst_port will be same as start_dst_port
45 
46  // Protocol, -1 means any
47  int protocol;
48 
49  // Mirror destination
50  std::string ip;
51  int udp_port;
52  // Time period for mirroring in seconds
54  std::string mirror_vrf;
55 };
56 
57 struct AceInfo {
58  AceInfo() : acl_id(boost::uuids::nil_uuid()), id(0) {}
59 
61  int id;
62 };
63 
68 };
69 
71  bool operator()(const MirrorCfgKey &lhs, const MirrorCfgKey &rhs) const {
72  return lhs.handle < rhs.handle;
73  }
74 };
75 
76 struct AclIdInfo {
78  id(boost::uuids::nil_uuid()), num_of_entries(0), ace_id_latest(0) {}
79 
83 };
84 
86 public:
87  typedef std::string VnIdStr;
89  // Config Tree
90  typedef std::map<MirrorCfgKey, MirrorCfgEntry *, MirrorCfgKeyCmp> MirrorCfgTree;
91  typedef std::map<VnIdStr, AclIdInfo> VnAclMap;
92 
94  agent_cfg_(cfg), mc_tree_(), vn_acl_map_() {};
96 
97  void Shutdown();
98  void Init();
99  void SetMirrorCfgSandeshData(std::string &handle,
100  MirrorCfgDisplayResp &resp);
101  void SetMirrorCfgVnSandeshData(std::string &vn_name,
102  MirrorCfgVnInfoResp &resp);
103  const boost::uuids::uuid GetMirrorUuid(const std::string &vn_name) const;
104 
105  const char *Add(const MirrorCreateReq &cfg);
106  void Delete(MirrorCfgKey &key);
107 private:
111 
112  const char *UpdateAclEntry(AclUuid &id, bool create, MirrorCfgEntry *e,
113  int ace_id);
114 
116 };
117 
119  std::string handle;
121  uint16_t sport;
122  // Mirror destination
124  uint16_t dport;
125  // Time period for mirroring in seconds
127  std::string mirror_vrf;
128 };
129 
131  IntfMirrorCfgData() : intf_id(boost::uuids::nil_uuid()) {}
132 
134  std::string intf_name;
136 };
137 
141 };
142 
144 public:
147  typedef std::map<MirrorCfgKey, IntfMirrorCfgEntry *, MirrorCfgKeyCmp> IntfMirrorCfgTree;
148  const char *Add(const IntfMirrorCreateReq &cfg);
149  void Delete(MirrorCfgKey &key);
151  void Init();
152  void Shutdown();
153  void SetIntfMirrorCfgSandeshData(std::string &handle,
154  IntfMirrorCfgDisplayResp &resp);
155 private:
159 };
160 
161 #endif // __AGENT_MIRROR_CFG_H__
void SetMirrorCfgVnSandeshData(std::string &vn_name, MirrorCfgVnInfoResp &resp)
Definition: cfg_mirror.cc:378
MirrorCfgKey key
Definition: cfg_mirror.h:65
int ace_id_latest
Definition: cfg_mirror.h:82
std::string handle
Definition: cfg_mirror.h:119
std::string mirror_vrf
Definition: cfg_mirror.h:127
const char * Add(const MirrorCreateReq &cfg)
Definition: cfg_mirror.cc:50
IntfMirrorCfgTable(AgentConfig *cfg)
Definition: cfg_mirror.h:145
void SetMirrorCfgSandeshData(std::string &handle, MirrorCfgDisplayResp &resp)
Definition: cfg_mirror.cc:345
MirrorCfgKey key
Definition: cfg_mirror.h:139
IntfMirrorCfgTree intf_mc_tree_
Definition: cfg_mirror.h:157
AceInfo()
Definition: cfg_mirror.h:58
int src_ip_prefix_len
Definition: cfg_mirror.h:29
int end_src_port
Definition: cfg_mirror.h:39
std::string src_ip_prefix
Definition: cfg_mirror.h:28
std::string dst_vn
Definition: cfg_mirror.h:32
boost::asio::ip::address IpAddress
Definition: address.h:13
int id
Definition: cfg_mirror.h:61
std::string apply_vn
Definition: cfg_mirror.h:24
DISALLOW_COPY_AND_ASSIGN(MirrorCfgTable)
boost::uuids::uuid uuid
MirrorCfgTable(AgentConfig *cfg)
Definition: cfg_mirror.h:93
int start_dst_port
Definition: cfg_mirror.h:43
std::string handle
Definition: cfg_mirror.h:15
std::string src_vn
Definition: cfg_mirror.h:27
void SetIntfMirrorCfgSandeshData(std::string &handle, IntfMirrorCfgDisplayResp &resp)
Definition: cfg_mirror.cc:601
DISALLOW_COPY_AND_ASSIGN(IntfMirrorCfgTable)
int dst_ip_prefix_len
Definition: cfg_mirror.h:34
int num_of_entries
Definition: cfg_mirror.h:81
boost::uuids::uuid intf_id
Definition: cfg_mirror.h:133
std::string VnIdStr
Definition: cfg_mirror.h:87
bool operator()(const MirrorCfgKey &lhs, const MirrorCfgKey &rhs) const
Definition: cfg_mirror.h:71
void Delete(MirrorCfgKey &key)
Definition: cfg_mirror.cc:548
std::map< MirrorCfgKey, IntfMirrorCfgEntry *, MirrorCfgKeyCmp > IntfMirrorCfgTree
Definition: cfg_mirror.h:146
std::string ip
Definition: cfg_mirror.h:50
boost::uuids::uuid AclUuid
Definition: cfg_mirror.h:88
int start_src_port
Definition: cfg_mirror.h:38
std::map< MirrorCfgKey, MirrorCfgEntry *, MirrorCfgKeyCmp > MirrorCfgTree
Definition: cfg_mirror.h:90
void Delete(MirrorCfgKey &key)
Definition: cfg_mirror.cc:279
AgentConfig * agent_cfg_
Definition: cfg_mirror.h:108
void Shutdown()
Definition: cfg_mirror.cc:43
int end_dst_port
Definition: cfg_mirror.h:44
std::string mirror_vrf
Definition: cfg_mirror.h:54
std::string intf_name
Definition: cfg_mirror.h:134
const char * UpdateAclEntry(AclUuid &id, bool create, MirrorCfgEntry *e, int ace_id)
Definition: cfg_mirror.cc:196
std::map< VnIdStr, AclIdInfo > VnAclMap
Definition: cfg_mirror.h:91
std::string dst_ip_prefix
Definition: cfg_mirror.h:33
AgentConfig * agent_cfg_
Definition: cfg_mirror.h:156
IntfMirrorCfgTable * CreateIntfMirrorCfgTable()
VnAclMap vn_acl_map_
Definition: cfg_mirror.h:110
MirrorCfgData data
Definition: cfg_mirror.h:66
AceInfo ace_info
Definition: cfg_mirror.h:67
const char * Add(const IntfMirrorCreateReq &cfg)
Definition: cfg_mirror.cc:442
boost::uuids::uuid id
Definition: cfg_mirror.h:80
IntfMirrorCfgData data
Definition: cfg_mirror.h:140
MirrorDestination mirror_dest
Definition: cfg_mirror.h:135
const boost::uuids::uuid GetMirrorUuid(const std::string &vn_name) const
Definition: cfg_mirror.cc:335
boost::uuids::uuid acl_id
Definition: cfg_mirror.h:60
MirrorCfgTree mc_tree_
Definition: cfg_mirror.h:109