LCOV - code coverage report
Current view: top level - vnsw/agent/mac_learning - mac_ip_learning.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 23 43.5 %
Date: 2026-11-09 02:10:49 Functions: 6 14 42.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2020 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef SRC_VNSW_AGENT_MAC_IP_LEARNING_MAC_LEARNING_H_
       7             : #define SRC_VNSW_AGENT_MAC_IP_LEARNING_MAC_LEARNING_H_
       8             : 
       9             : #include <mutex>
      10             : 
      11             : #include "cmn/agent.h"
      12             : #include "mac_ip_learning_key.h"
      13             : #include "mac_learning_base.h"
      14             : #include "mac_learning_event.h"
      15             : #include "pkt/flow_token.h"
      16             : #include "health_check.h"
      17             : 
      18             : class MacIpLearningTable;
      19             : class MacIpLearningRequestQueue;
      20             : class MacIpLearningEntry : public MacLearningEntry {
      21             : public:
      22             :     MacIpLearningEntry(MacIpLearningTable *table, uint32_t vrf_id_,
      23             :             const IpAddress &ip, const MacAddress &mac,
      24             :             InterfaceConstRef intf);
      25           0 :     virtual ~MacIpLearningEntry() {}
      26             :     bool Add();
      27             :     void Delete();
      28             :     void Resync();
      29           0 :     uint32_t vrf_id()  {
      30           0 :         return key_.vrf_id_;
      31             :     }
      32           0 :     const Interface* intf() {
      33           0 :         return intf_.get();
      34             :     }
      35           0 :     const VnEntry* Vn() {
      36           0 :         return vn_.get();
      37             :     }
      38         372 :     const HealthCheckService* HcService() {
      39         372 :         return hc_service_;
      40             :     }
      41          33 :     const HealthCheckInstanceBase* HcInstance() {
      42          33 :         return hc_instance_;
      43             :     }
      44             :     MacIpLearningTable *mac_ip_learning_table() const {
      45             :         return mac_ip_learning_table_;
      46             :     }
      47           0 :     const MacIpLearningKey& key() const {
      48           0 :         return key_;
      49             :     }
      50           0 :     IpAddress& IpAddr() {
      51           0 :         return ip_;
      52             :     }
      53           0 :     MacAddress& Mac() {
      54           0 :         return mac_;
      55             :     }
      56             :     void EnqueueToTable(MacLearningEntryRequestPtr req);
      57             :     void AddHealthCheckService(HealthCheckService *service);
      58             :     void UpdateHealthCheckService();
      59             :     HealthCheckService* GetHealthCheckService(const VnEntry *vn);
      60             :  
      61             : private:
      62             :     MacIpLearningTable *mac_ip_learning_table_;
      63             :     MacIpLearningKey key_;
      64             :     IpAddress ip_;
      65             :     MacAddress mac_;
      66             :     InterfaceConstRef intf_;
      67             :     VnEntryConstRef vn_;
      68             :     HealthCheckService *hc_service_;
      69             :     HealthCheckInstanceBase  *hc_instance_;
      70             :     DISALLOW_COPY_AND_ASSIGN(MacIpLearningEntry);
      71             : };
      72             : 
      73             : class MacIpLearningTable {
      74             : public:
      75             :     typedef std::pair<MacIpLearningKey,
      76             :                       MacLearningEntryPtr> MacIpLearningEntryPair;
      77             :     typedef std::map<MacIpLearningKey,
      78             :                      MacLearningEntryPtr,
      79             :                      MacIpLearningKeyCmp> MacIpLearningEntryMap;
      80             : 
      81             :     MacIpLearningTable(Agent *agent, MacLearningProto *proto);
      82           4 :     virtual ~MacIpLearningTable() {}
      83             :     void Add(MacLearningEntryPtr ptr);
      84             :     void Resync(MacLearningEntryPtr ptr);
      85             :     void Delete(MacLearningEntryPtr ptr);
      86             :     void DetectIpMove(MacLearningEntryRequestPtr ptr);
      87             :     void MacIpEntryUnreachable(MacLearningEntryRequestPtr ptr);
      88             :     void MacIpEntryUnreachable(uint32_t vrf_id, IpAddress &ip, MacAddress &mac);
      89             :     void MacIpEntryHcNotify(const HealthCheckInstanceService *instance_service);
      90             :     MacIpLearningEntry* Find(const MacIpLearningKey &key);
      91             :     MacAddress GetPairedMacAddress(uint32_t vrf_id, const IpAddress &ip);
      92             :     //To be used in test cases only
      93             :     //MacLearningEntryPtr TestGet(const MacLearningKey &key);
      94             :     bool RequestHandler(MacLearningEntryRequestPtr ptr);
      95             : 
      96           2 :     Agent* agent() {
      97           2 :         return agent_;
      98             :     }
      99             : 
     100           2 :     void SetQueueDisable(bool disable) {
     101           2 :         work_queue_.SetQueueDisable(disable);
     102           2 :     }
     103             : 
     104             :     void Enqueue(MacLearningEntryRequestPtr req);
     105             :     void EnqueueMgmtReq(MacLearningEntryPtr ptr, bool add);
     106             : 
     107             : private:
     108             :     Agent *agent_;
     109             :     MacIpLearningEntryMap mac_ip_learning_entry_map_;
     110             :     MacIpLearningRequestQueue work_queue_;
     111             :     std::mutex macip_map_mutex_;
     112             :     DISALLOW_COPY_AND_ASSIGN(MacIpLearningTable);
     113             : };
     114             : #endif

Generated by: LCOV version 1.14