LCOV - code coverage report
Current view: top level - vnsw/agent/oper - sg.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 22 22 100.0 %
Date: 2026-11-09 02:10:49 Functions: 20 20 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14