LCOV - code coverage report
Current view: top level - vnsw/agent/mac_learning - mac_learning_event.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 37 48 77.1 %
Date: 2026-08-03 02:19:58 Functions: 15 20 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_EVENT_H_
       6             : #define SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_EVENT_H_
       7             : 
       8             : #include "cmn/agent.h"
       9             : #include "mac_learning_key.h"
      10             : #include "mac_learning_base.h"
      11             : 
      12             : class MacLearningPartition;
      13             : class MacIpLearningTable;
      14             : 
      15             : class MacLearningEntryRequest {
      16             : public:
      17             :      enum Event {
      18             :          INVALID,
      19             :          VROUTER_MSG,
      20             :          ADD_MAC,
      21             :          RESYNC_MAC,
      22             :          DELETE_MAC,
      23             :          FREE_DB_ENTRY,
      24             :          DELETE_VRF,
      25             :          REMOTE_MAC_IP,
      26             :          MAC_IP_UNREACHABLE
      27             : 
      28             :      };
      29             : 
      30           0 :      MacLearningEntryRequest(Event event, PktInfoPtr pkt):
      31           0 :          event_(event), pkt_info_(pkt) {}
      32        3578 :      MacLearningEntryRequest(Event event, MacLearningEntryPtr ptr):
      33        3578 :          event_(event), mac_learning_entry_(ptr) {
      34        3578 :      }
      35             : 
      36          12 :      MacLearningEntryRequest(Event event, uint32_t vrf_id):
      37          12 :          event_(event), vrf_id_(vrf_id) {
      38          12 :      }
      39           5 :      MacLearningEntryRequest(Event event, uint32_t vrf_id,
      40           5 :              IpAddress &ip, MacAddress &mac):
      41           5 :          event_(event), vrf_id_(vrf_id), ip_(ip), mac_(mac) {
      42           5 :      }
      43             : 
      44          87 :      MacLearningEntryRequest(Event event, const DBEntry *entry,
      45          87 :                              uint32_t gen_id):
      46          87 :          event_(event), db_entry_(entry), gen_id_(gen_id) {}
      47             : 
      48           0 :      MacLearningEntryPtr mac_learning_entry() {
      49           0 :          return mac_learning_entry_;
      50             :      }
      51             : 
      52         191 :      Event event() {
      53         191 :          return event_;
      54             :      }
      55             : 
      56          87 :      const DBEntry *db_entry() {
      57          87 :          return db_entry_;
      58             :      }
      59             : 
      60           0 :      PktInfoPtr pkt_info() {
      61           0 :          return pkt_info_;
      62             :      }
      63             : 
      64          17 :      uint32_t vrf_id() {
      65          17 :          return vrf_id_;
      66             :      }
      67             : 
      68          87 :      uint32_t gen_id() {
      69          87 :          return gen_id_;
      70             :      }
      71           5 :      IpAddress ip() {
      72           5 :          return ip_;
      73             :      }
      74           0 :      MacAddress mac() {
      75           0 :          return mac_;
      76             :      }
      77             : 
      78             : private:
      79             :     Event event_;
      80             :     MacLearningEntryPtr mac_learning_entry_;
      81             :     PktInfoPtr pkt_info_;
      82             :     uint32_t vrf_id_;
      83             :     const DBEntry *db_entry_;
      84             :     uint32_t gen_id_;
      85             :     IpAddress ip_;
      86             :     MacAddress mac_;
      87             : };
      88             : //typedef boost::shared_ptr<MacLearningEntryRequest> MacLearningEntryRequestPtr;
      89             : 
      90             : class MacLearningRequestQueue {
      91             : public:
      92             :     typedef WorkQueue<MacLearningEntryRequestPtr> Queue;
      93             :     MacLearningRequestQueue(MacLearningPartition *partition,
      94             :                             TokenPool *pool);
      95           9 :     ~MacLearningRequestQueue() {}
      96             :     void Shutdown() {}
      97             :     virtual bool HandleEvent(MacLearningEntryRequestPtr ptr);
      98             :     virtual bool TokenCheck();
      99             : 
     100          87 :     void Enqueue(MacLearningEntryRequestPtr ptr) {
     101          87 :         queue_.Enqueue(ptr);
     102          87 :     }
     103             : 
     104           0 :     void MayBeStartRunner() {
     105           0 :         queue_.MayBeStartRunner();
     106           0 :     }
     107             : 
     108           2 :     void SetQueueDisable(bool disable) {
     109           2 :         queue_.set_disable(disable);
     110           2 :     }
     111             : 
     112             : private:
     113             :     MacLearningPartition *partition_;
     114             :     TokenPool *pool_;
     115             :     Queue queue_;
     116             :     DISALLOW_COPY_AND_ASSIGN(MacLearningRequestQueue);
     117             : };
     118             : class MacIpLearningRequestQueue {
     119             : public:
     120             :     typedef WorkQueue<MacLearningEntryRequestPtr> Queue;
     121             :     MacIpLearningRequestQueue(MacIpLearningTable *table);
     122           3 :     ~MacIpLearningRequestQueue() {}
     123             :     void Shutdown() {}
     124             :     bool HandleEvent(MacLearningEntryRequestPtr ptr);
     125             : 
     126           5 :     void Enqueue(MacLearningEntryRequestPtr ptr) {
     127           5 :         queue_.Enqueue(ptr);
     128           5 :     }
     129             : 
     130             :     void MayBeStartRunner() {
     131             :         queue_.MayBeStartRunner();
     132             :     }
     133             : 
     134           2 :     void SetQueueDisable(bool disable) {
     135           2 :         queue_.set_disable(disable);
     136           2 :     }
     137             : 
     138             : private:
     139             :     MacIpLearningTable *table_;
     140             :     Queue queue_;
     141             :     DISALLOW_COPY_AND_ASSIGN(MacIpLearningRequestQueue);
     142             : };
     143             : #endif

Generated by: LCOV version 1.14