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

Generated by: LCOV version 1.14