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-06-11 01:56:02 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             :  */
       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          21 :     SgKey(boost::uuids::uuid sg_uuid) : AgentOperDBKey(), sg_uuid_(sg_uuid) {}
      15          39 :     virtual ~SgKey() {}
      16             : 
      17             :     boost::uuids::uuid sg_uuid_;
      18             : };
      19             : 
      20             : struct SgData : public AgentOperDBData {
      21          12 :     SgData(Agent *agent, IFMapNode *node, const uint32_t &sg_id,
      22             :            const boost::uuids::uuid &egress_acl_id,
      23          12 :            const boost::uuids::uuid &ingress_acl_id) :
      24          12 :                    AgentOperDBData(agent, node), sg_id_(sg_id),
      25          12 :                    egress_acl_id_(egress_acl_id),
      26          12 :                    ingress_acl_id_(ingress_acl_id) {
      27          12 :     }
      28          24 :     virtual ~SgData() { }
      29             : 
      30             :     uint32_t sg_id_;
      31             :     boost::uuids::uuid egress_acl_id_;
      32             :     boost::uuids::uuid ingress_acl_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          23 :     SgEntry(boost::uuids::uuid sg_uuid) : sg_uuid_(sg_uuid) {}
      41          46 :     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          18 :     const boost::uuids::uuid &GetSgUuid() const {return sg_uuid_;};
      49          27 :     const uint32_t &GetSgId() const {return sg_id_;};
      50          58 :     const AclDBEntry *GetIngressAcl() const {return ingress_acl_.get();};
      51          46 :     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          32 :     bool IsAclSet() const { return (egress_acl_ != NULL || ingress_acl_ != NULL);};
      55             : 
      56          20 :     uint32_t GetRefCount() const {
      57          20 :         return AgentRefCount<SgEntry>::GetRefCount();
      58             :     }
      59             : 
      60             :     bool DBEntrySandesh(Sandesh *sresp, std::string &name) const;
      61             :     void SendObjectLog(SandeshTraceBufferPtr ptr,
      62             :                        AgentLogEvent::type event) const;
      63             : private:
      64             :     friend class SgTable;
      65             :     boost::uuids::uuid sg_uuid_;
      66             :     uint32_t sg_id_;
      67             :     AclDBEntryRef egress_acl_;
      68             :     AclDBEntryRef ingress_acl_;
      69             :     DISALLOW_COPY_AND_ASSIGN(SgEntry);
      70             : };
      71             : 
      72             : class SgTable : public AgentOperDBTable {
      73             : public:
      74             :     static const uint32_t kInvalidSgId = 0;
      75           2 :     SgTable(DB *db, const std::string &name) : AgentOperDBTable(db, name) { }
      76           4 :     virtual ~SgTable() { }
      77             : 
      78             :     virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
      79           6 :     virtual size_t Hash(const DBEntry *entry) const {return 0;};
      80          21 :     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);
      89             :     virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
      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);
     100             :     DISALLOW_COPY_AND_ASSIGN(SgTable);
     101             : };
     102             : 
     103             : #endif // vnsw_agent_sg_hpp

Generated by: LCOV version 1.14