LCOV - code coverage report
Current view: top level - vnsw/agent/oper - physical_device.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 41 0.0 %
Date: 2026-06-22 02:21:21 Functions: 0 31 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : #ifndef SRC_VNSW_AGENT_OPER_PHYSICAL_DEVICE_H_
       5             : #define SRC_VNSW_AGENT_OPER_PHYSICAL_DEVICE_H_
       6             : 
       7             : #include <cmn/agent_cmn.h>
       8             : #include <cmn/agent.h>
       9             : #include <nexthop.h>
      10             : #include <agent_types.h>
      11             : #include <oper_db.h>
      12             : #include <string>
      13             : 
      14             : class IFMapDependencyManager;
      15             : class PhysicalDevice;
      16             : class PhysicalDeviceTable;
      17             : 
      18             : struct PhysicalDeviceKey : public AgentOperDBKey {
      19           0 :     PhysicalDeviceKey(const boost::uuids::uuid &id) :
      20           0 :         AgentOperDBKey(), uuid_(id) { }
      21           0 :     PhysicalDeviceKey(const boost::uuids::uuid &id, DBSubOperation sub_op) :
      22           0 :         AgentOperDBKey(sub_op), uuid_(id) { }
      23           0 :     virtual ~PhysicalDeviceKey() { }
      24             : 
      25             :     boost::uuids::uuid uuid_;
      26             : };
      27             : 
      28             : struct PhysicalDeviceDataBase : public AgentOperDBData {
      29           0 :     PhysicalDeviceDataBase(Agent *agent, IFMapNode *ifmap_node) :
      30           0 :         AgentOperDBData(agent, ifmap_node) {
      31           0 :     }
      32           0 :     virtual ~PhysicalDeviceDataBase() { }
      33             : };
      34             : 
      35             : struct PhysicalDeviceData : public PhysicalDeviceDataBase {
      36           0 :     PhysicalDeviceData(Agent *agent, const std::string &fq_name,
      37             :                        const std::string &name, const std::string &vendor,
      38             :                        const IpAddress &ip, const IpAddress &mgmt_ip,
      39           0 :                        const std::string &protocol, IFMapNode *ifmap_node) :
      40           0 :         PhysicalDeviceDataBase(agent, ifmap_node), fq_name_(fq_name),
      41           0 :         name_(name), vendor_(vendor), ip_(ip), management_ip_(mgmt_ip),
      42           0 :         protocol_(protocol) {
      43           0 :     }
      44           0 :     virtual ~PhysicalDeviceData() { }
      45             : 
      46             :     std::string fq_name_;
      47             :     std::string name_;
      48             :     std::string vendor_;
      49             :     IpAddress ip_;
      50             :     IpAddress management_ip_;
      51             :     std::string protocol_;
      52             : };
      53             : 
      54             : struct PhysicalDeviceTsnManagedData : public PhysicalDeviceDataBase {
      55           0 :     PhysicalDeviceTsnManagedData(Agent *agent, bool master) :
      56           0 :         PhysicalDeviceDataBase(agent, NULL), master_(master) {
      57           0 :     }
      58           0 :     virtual ~PhysicalDeviceTsnManagedData() { }
      59             : 
      60             :     bool master_;
      61             : };
      62             : 
      63             : class PhysicalDevice : AgentRefCount<PhysicalDevice>, public AgentOperDBEntry {
      64             :  public:
      65             :     typedef enum {
      66             :         INVALID,
      67             :         OVS
      68             :     } ManagementProtocol;
      69             : 
      70           0 :     explicit PhysicalDevice(const boost::uuids::uuid &id) :
      71           0 :         AgentOperDBEntry(), uuid_(id), name_(""), vendor_(""), ip_(),
      72           0 :         protocol_(INVALID), master_(false) { }
      73           0 :     virtual ~PhysicalDevice() { }
      74             : 
      75             :     virtual bool IsLess(const DBEntry &rhs) const;
      76             :     virtual KeyPtr GetDBRequestKey() const;
      77             :     virtual void SetKey(const DBRequestKey *key);
      78             :     virtual std::string ToString() const;
      79           0 :     uint32_t GetRefCount() const {
      80           0 :         return AgentRefCount<PhysicalDevice>::GetRefCount();
      81             :     }
      82             : 
      83             :     bool Copy(PhysicalDeviceTable *table, const PhysicalDeviceData *data);
      84           0 :     const boost::uuids::uuid &uuid() const { return uuid_; }
      85           0 :     const std::string &fq_name() const { return fq_name_; }
      86           0 :     const std::string &name() const { return name_; }
      87           0 :     const std::string &vendor() const { return vendor_; }
      88           0 :     const IpAddress &ip() const { return ip_; }
      89             :     const IpAddress &management_ip() const { return management_ip_; }
      90           0 :     ManagementProtocol protocol() const { return protocol_; }
      91           0 :     bool master() const { return master_; }
      92           0 :     void set_master(bool value) { master_ = value; }
      93             : 
      94             :     void SendObjectLog(AgentLogEvent::type event) const;
      95             :     bool DBEntrySandesh(Sandesh *resp, std::string &name) const;
      96             : 
      97             :  private:
      98             :     friend class PhysicalDeviceTable;
      99             :     boost::uuids::uuid uuid_;
     100             :     std::string fq_name_;
     101             :     std::string name_;
     102             :     std::string vendor_;
     103             :     IpAddress ip_;
     104             :     IpAddress management_ip_;
     105             :     ManagementProtocol protocol_;
     106             :     bool master_;
     107             :     DISALLOW_COPY_AND_ASSIGN(PhysicalDevice);
     108             : };
     109             : 
     110             : class PhysicalDeviceTable : public AgentOperDBTable {
     111             :  public:
     112             :     typedef std::set<boost::uuids::uuid> PhysicalDeviceSet;
     113             :     typedef std::map<const std::string, PhysicalDeviceSet> VrfDevicesMap;
     114             :     typedef std::pair<const std::string, PhysicalDeviceSet> VrfDevicesPair;
     115             :     typedef std::set<std::string> VrfSet;
     116             :     typedef std::map<const boost::uuids::uuid, VrfSet> DeviceVrfMap;
     117             :     typedef std::pair<const boost::uuids::uuid, VrfSet> DeviceVrfPair;
     118             :     typedef std::map<IpAddress, PhysicalDevice *> IpToDeviceMap;
     119             :     typedef std::pair<IpAddress, PhysicalDevice *> IpToDevicePair;
     120             : 
     121           0 :     PhysicalDeviceTable(DB *db, const std::string &name) :
     122           0 :         AgentOperDBTable(db, name), ip_tree_(), managed_pd_set_(),
     123           0 :         vrf2devices_map_(), device2vrf_map_() { }
     124           0 :     virtual ~PhysicalDeviceTable() { }
     125             : 
     126             :     virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
     127           0 :     virtual size_t Hash(const DBEntry *entry) const {return 0;}
     128           0 :     virtual size_t Hash(const DBRequestKey *key) const {return 0;}
     129             : 
     130             :     virtual DBEntry *OperDBAdd(const DBRequest *req);
     131             :     virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req);
     132             :     virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req);
     133             :     virtual bool OperDBResync(DBEntry *entry, const DBRequest *req);
     134             :     virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req,
     135             :             const boost::uuids::uuid &u);
     136             :     bool ProcessConfig(IFMapNode *node, DBRequest &req,
     137             :             const boost::uuids::uuid &u);
     138             :     virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
     139             :     virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
     140             :                                             const std::string &context);
     141             : 
     142             :     PhysicalDevice *Find(const boost::uuids::uuid &u);
     143             : 
     144             :     void RegisterDBClients(IFMapDependencyManager *dep);
     145             :     static DBTableBase *CreateTable(DB *db, const std::string &name);
     146             :     void UpdateIpToDevMap(IpAddress old, IpAddress new_ip, PhysicalDevice *p);
     147             :     void DeleteIpToDevEntry(IpAddress ip);
     148             :     PhysicalDevice *IpToPhysicalDevice(IpAddress ip);
     149           0 :     const PhysicalDeviceSet &managed_pd_set() const { return managed_pd_set_; }
     150             :     void EnqueueDeviceChange(const boost::uuids::uuid &u, bool master);
     151             :     void UpdateDeviceMastership(const std::string &vrf, ComponentNHList clist,
     152             :                                 bool del);
     153             : 
     154             :  private:
     155             :     void ResetDeviceMastership(const boost::uuids::uuid &u,
     156             :                                const std::string &vrf);
     157             :     void AddDeviceToVrfEntry(const boost::uuids::uuid &u,
     158             :                              const std::string &vrf);
     159             :     bool RemoveDeviceToVrfEntry(const boost::uuids::uuid &u,
     160             :                                 const std::string &vrf);
     161             :     IpToDeviceMap ip_tree_;
     162             :     PhysicalDeviceSet managed_pd_set_;
     163             :     VrfDevicesMap vrf2devices_map_;
     164             :     DeviceVrfMap device2vrf_map_;
     165             :     DISALLOW_COPY_AND_ASSIGN(PhysicalDeviceTable);
     166             : };
     167             : 
     168             : #endif  // SRC_VNSW_AGENT_OPER_PHYSICAL_DEVICE_H_

Generated by: LCOV version 1.14