LCOV - code coverage report
Current view: top level - vnsw/agent/oper - multicast_policy.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 3 25 12.0 %
Date: 2026-11-09 02:10:49 Functions: 3 20 15.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_multcast_policy_hpp
       7             : #define vnsw_agent_multcast_policy_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             : using namespace boost::uuids;
      15             : using namespace std;
      16             : 
      17             : struct SourceGroupInfo {
      18             : public:
      19             :     enum Action {
      20             :         ACTION_PASS,
      21             :         ACTION_DENY,
      22             :     };
      23             :     IpAddress source;
      24             :     IpAddress group;
      25             :     Action action;
      26             : };
      27             : 
      28             : struct MulticastPolicyKey : public AgentOperDBKey {
      29           0 :     MulticastPolicyKey(uuid mp_uuid) : AgentOperDBKey(), mp_uuid_(mp_uuid) {} ;
      30           0 :     virtual ~MulticastPolicyKey() { };
      31             : 
      32             :     uuid mp_uuid_;
      33             : };
      34             : 
      35             : struct MulticastPolicyData : public AgentOperDBData {
      36           0 :     MulticastPolicyData(Agent *agent, IFMapNode *node,
      37             :                     const std::string &name,
      38           0 :                     const std::vector<SourceGroupInfo> &lst) :
      39           0 :     AgentOperDBData(agent, node), name_(name), mcast_sg_(lst) {}
      40           0 :     virtual ~MulticastPolicyData() {}
      41             : 
      42             :     std::string name_;
      43             :     std::vector<SourceGroupInfo> mcast_sg_;
      44             : };
      45             : 
      46             : class MulticastPolicyEntry :
      47             :                 AgentRefCount<MulticastPolicyEntry>, public AgentOperDBEntry {
      48             : public:
      49           0 :     MulticastPolicyEntry(uuid mp_uuid) : mp_uuid_(mp_uuid) {};
      50           0 :     virtual ~MulticastPolicyEntry() { };
      51             : 
      52             :     virtual bool IsLess(const DBEntry &rhs) const;
      53             :     virtual KeyPtr GetDBRequestKey() const;
      54             :     virtual void SetKey(const DBRequestKey *key);
      55             :     virtual string ToString() const;
      56             : 
      57           0 :     const uuid &GetMpUuid() const {return mp_uuid_;};
      58           0 :     const std::string& name() const {return name_;}
      59           0 :     void set_name(std::string& name) {
      60           0 :         name_ = name;
      61           0 :     }
      62           0 :     const std::vector<SourceGroupInfo> & mcast_sg() const {
      63           0 :         return mcast_sg_;
      64             :     }
      65           0 :     void set_mcast_sg(std::vector<SourceGroupInfo> &mcast_sg) {
      66           0 :         mcast_sg_ = mcast_sg;
      67           0 :     }
      68             : 
      69           0 :     uint32_t GetRefCount() const {
      70           0 :         return AgentRefCount<MulticastPolicyEntry>::GetRefCount();
      71             :     }
      72             : 
      73             :     SourceGroupInfo::Action GetAction(IpAddress source, IpAddress group) const;
      74             : 
      75             :     bool DBEntrySandesh(Sandesh *sresp, std::string &name) const;
      76             :     void SendObjectLog(SandeshTraceBufferPtr ptr,
      77             :                        AgentLogEvent::type event) const;
      78             : 
      79             : private:
      80             :     friend class MulticastPolicyTable;
      81             :     uuid mp_uuid_;
      82             :     std::string name_;
      83             :     std::vector<SourceGroupInfo> mcast_sg_;
      84             :     DISALLOW_COPY_AND_ASSIGN(MulticastPolicyEntry);
      85             : };
      86             : 
      87             : class MulticastPolicyTable : public AgentOperDBTable {
      88             : public:
      89             :     static const uint32_t kInvalidMpId = 0;
      90           2 :     MulticastPolicyTable(DB *db, const std::string &name) :
      91           2 :                             AgentOperDBTable(db, name) { }
      92           4 :     virtual ~MulticastPolicyTable() { }
      93             : 
      94             :     virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
      95           0 :     virtual size_t Hash(const DBEntry *entry) const {return 0;};
      96           0 :     virtual size_t  Hash(const DBRequestKey *key) const {return 0;};
      97             : 
      98             :     virtual DBEntry *OperDBAdd(const DBRequest *req);
      99             :     virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req);
     100             :     virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req);
     101             : 
     102             :     virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req,
     103             :             const boost::uuids::uuid &u);
     104             :     virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
     105             :     virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
     106             :                                             const std::string &context);
     107             :     bool ProcessConfig(IFMapNode *node, DBRequest &req,
     108             :             const boost::uuids::uuid &u);
     109             : 
     110             :     static DBTableBase *CreateTable(DB *db, const std::string &name);
     111             :     static MulticastPolicyTable *GetInstance() {return mp_table_;};
     112             : 
     113             : private:
     114             :     static MulticastPolicyTable* mp_table_;
     115             :     bool ChangeHandler(DBEntry *entry, const DBRequest *req);
     116             :     bool IsEqual(const std::vector<SourceGroupInfo> &lhs,
     117             :                  const std::vector<SourceGroupInfo> &rhs) const;
     118             :     DISALLOW_COPY_AND_ASSIGN(MulticastPolicyTable);
     119             : };
     120             : 
     121             : #endif // vnsw_agent_multicast_policy_hpp

Generated by: LCOV version 1.14