OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_sg_hpp
6 #define vnsw_agent_sg_hpp
7 
8 #include <cmn/agent_cmn.h>
9 #include <cmn/agent.h>
10 #include <agent_types.h>
11 #include <oper/oper_db.h>
12 
13 struct SgKey : public AgentOperDBKey {
14  SgKey(boost::uuids::uuid sg_uuid) : AgentOperDBKey(), sg_uuid_(sg_uuid) {}
15  virtual ~SgKey() {}
16 
18 };
19 
20 struct SgData : public AgentOperDBData {
21  SgData(Agent *agent, IFMapNode *node, const uint32_t &sg_id,
22  const boost::uuids::uuid &egress_acl_id,
23  const boost::uuids::uuid &ingress_acl_id) :
24  AgentOperDBData(agent, node), sg_id_(sg_id),
25  egress_acl_id_(egress_acl_id),
26  ingress_acl_id_(ingress_acl_id) {
27  }
28  virtual ~SgData() { }
29 
30  uint32_t sg_id_;
33 };
34 
35 class SgEntry : AgentRefCount<SgEntry>, public AgentOperDBEntry {
36 public:
37  SgEntry(boost::uuids::uuid sg_uuid, uint32_t sg_id) :
38  sg_uuid_(sg_uuid), sg_id_(sg_id),
39  egress_acl_(NULL), ingress_acl_(NULL) {}
40  SgEntry(boost::uuids::uuid sg_uuid) : sg_uuid_(sg_uuid) {}
41  virtual ~SgEntry() {}
42 
43  virtual bool IsLess(const DBEntry &rhs) const;
44  virtual KeyPtr GetDBRequestKey() const;
45  virtual void SetKey(const DBRequestKey *key);
46  virtual string ToString() const;
47 
48  const boost::uuids::uuid &GetSgUuid() const {return sg_uuid_;};
49  const uint32_t &GetSgId() const {return sg_id_;};
50  const AclDBEntry *GetIngressAcl() const {return ingress_acl_.get();};
51  const AclDBEntry *GetEgressAcl() const {return egress_acl_.get();};
52  bool IsEgressAclSet() const { return (egress_acl_ != NULL);};
53  bool IsIngressAclSet() const { return (ingress_acl_ != NULL);};
54  bool IsAclSet() const { return (egress_acl_ != NULL || ingress_acl_ != NULL);};
55 
56  uint32_t GetRefCount() const {
58  }
59 
60  bool DBEntrySandesh(Sandesh *sresp, std::string &name) const;
62  AgentLogEvent::type event) const;
63 private:
64  friend class SgTable;
66  uint32_t sg_id_;
70 };
71 
72 class SgTable : public AgentOperDBTable {
73 public:
74  static const uint32_t kInvalidSgId = 0;
75  SgTable(DB *db, const std::string &name) : AgentOperDBTable(db, name) { }
76  virtual ~SgTable() { }
77 
78  virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
79  virtual size_t Hash(const DBEntry *entry) const {return 0;};
80  virtual size_t Hash(const DBRequestKey *key) const {return 0;};
81 
82  virtual DBEntry *OperDBAdd(const DBRequest *req);
83  virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req);
84  virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req);
85 
86  virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req,
87  const boost::uuids::uuid &u);
88  virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
90  const std::string &context);
91  bool ProcessConfig(IFMapNode *node, DBRequest &req,
92  const boost::uuids::uuid &u);
93 
94  static DBTableBase *CreateTable(DB *db, const std::string &name);
95  static SgTable *GetInstance() {return sg_table_;};
96 
97 private:
98  static SgTable* sg_table_;
99  bool ChangeHandler(DBEntry *entry, const DBRequest *req);
101 };
102 
103 #endif // vnsw_agent_sg_hpp
AclDBEntryRef egress_acl_
Definition: sg.h:67
static const uint32_t kInvalidSgId
Definition: sg.h:74
DISALLOW_COPY_AND_ASSIGN(SgTable)
Definition: sg.h:13
SgEntry(boost::uuids::uuid sg_uuid)
Definition: sg.h:40
virtual DBEntry * OperDBAdd(const DBRequest *req)
Definition: sg.cc:54
boost::uuids::uuid egress_acl_id_
Definition: sg.h:31
uint32_t GetRefCount() const
Definition: agent_db.h:54
SgTable(DB *db, const std::string &name)
Definition: sg.h:75
const boost::uuids::uuid & GetSgUuid() const
Definition: sg.h:48
bool DBEntrySandesh(Sandesh *sresp, std::string &name) const
Definition: sg.cc:184
boost::uuids::uuid sg_uuid_
Definition: sg.h:17
bool IsAclSet() const
Definition: sg.h:54
DISALLOW_COPY_AND_ASSIGN(SgEntry)
SgEntry(boost::uuids::uuid sg_uuid, uint32_t sg_id)
Definition: sg.h:37
virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
Definition: sg.cc:114
boost::uuids::uuid uuid
virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req)
Definition: sg.cc:62
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
Definition: sg.cc:248
void SendObjectLog(SandeshTraceBufferPtr ptr, AgentLogEvent::type event) const
Definition: sg.cc:208
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
Definition: sandesh_trace.h:18
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
bool IsEgressAclSet() const
Definition: sg.h:52
AclDBEntryRef ingress_acl_
Definition: sg.h:68
Definition: db.h:24
virtual void SetKey(const DBRequestKey *key)
Definition: sg.cc:43
virtual bool IsLess(const DBEntry &rhs) const
Definition: sg.cc:27
uint8_t type
Definition: load_balance.h:109
bool ProcessConfig(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
Definition: sg.cc:132
uint32_t sg_id_
Definition: sg.h:66
Definition: agent.h:358
virtual size_t Hash(const DBRequestKey *key) const
Definition: sg.h:80
virtual size_t Hash(const DBEntry *entry) const
Definition: sg.h:79
boost::intrusive_ptr< AclDBEntry > AclDBEntryRef
Definition: agent.h:141
virtual ~SgKey()
Definition: sg.h:15
virtual KeyPtr GetDBRequestKey() const
Definition: sg.cc:38
const AclDBEntry * GetIngressAcl() const
Definition: sg.h:50
boost::uuids::uuid ingress_acl_id_
Definition: sg.h:32
virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req)
Definition: sg.cc:94
virtual ~SgData()
Definition: sg.h:28
Definition: sg.h:35
virtual ~SgTable()
Definition: sg.h:76
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
Definition: agent_db.h:18
const std::string & name() const
Definition: db_table.h:110
bool IsIngressAclSet() const
Definition: sg.h:53
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
Definition: sg.cc:48
uint32_t sg_id_
Definition: sg.h:30
bool ChangeHandler(DBEntry *entry, const DBRequest *req)
Definition: sg.cc:69
const Agent * agent() const
Definition: oper_db.h:65
SgKey(boost::uuids::uuid sg_uuid)
Definition: sg.h:14
const AclDBEntry * GetEgressAcl() const
Definition: sg.h:51
virtual ~SgEntry()
Definition: sg.h:41
Definition: sg.h:20
static DBTableBase * CreateTable(DB *db, const std::string &name)
Definition: sg.cc:100
static SgTable * sg_table_
Definition: sg.h:95
virtual string ToString() const
Definition: sg.cc:32
static SgTable * GetInstance()
Definition: sg.h:95
const uint32_t & GetSgId() const
Definition: sg.h:49
Definition: sg.h:72
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u)
Definition: sg.cc:106
SgData(Agent *agent, IFMapNode *node, const uint32_t &sg_id, const boost::uuids::uuid &egress_acl_id, const boost::uuids::uuid &ingress_acl_id)
Definition: sg.h:21
boost::uuids::uuid sg_uuid_
Definition: sg.h:65
Definition: acl.h:92
uint32_t GetRefCount() const
Definition: sg.h:56