LCOV - code coverage report
Current view: top level - vnsw/agent/diag - diag_proto.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 1 6 16.7 %
Date: 2026-11-09 02:10:49 Functions: 2 4 50.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_diag_proto_hpp
       7             : #define vnsw_agent_diag_proto_hpp
       8             : 
       9             : #include <mutex>
      10             : 
      11             : #include <pkt/pkt_handler.h>
      12             : #include <pkt/proto.h>
      13             : #include <pkt/proto_handler.h>
      14             : #include <oper/health_check.h>
      15             : 
      16             : class SegmentHealthCheckPkt;
      17             : class SegmentHealthCheckPktStatsResp;
      18             : 
      19             : class DiagProto : public Proto {
      20             : public:
      21             :     // map from interface id to segment health check service packet object
      22             :     typedef std::map<uint32_t, SegmentHealthCheckPkt *> SessionMap;
      23             :     typedef std::pair<uint32_t, SegmentHealthCheckPkt *> SessionPair;
      24             : 
      25             :     enum DiagStatsType {
      26             :         REQUESTS_SENT,
      27             :         REQUESTS_RECEIVED,
      28             :         REPLIES_SENT,
      29             :         REPLIES_RECEIVED
      30             :     };
      31             : 
      32             :     struct DiagStats {
      33             :         uint64_t requests_sent;
      34             :         uint64_t requests_received;
      35             :         uint64_t replies_sent;
      36             :         uint64_t replies_received;
      37           0 :         DiagStats() { Reset(); }
      38           0 :         void Reset() {
      39           0 :             requests_sent = requests_received = replies_sent = 0;
      40           0 :             replies_received = 0;
      41           0 :         }
      42             :     };
      43             :     typedef std::map<uint32_t, DiagStats> DiagStatsMap;
      44             :     typedef std::pair<uint32_t, DiagStats> DiagStatsPair;
      45             : 
      46             :     DiagProto(Agent *agent, boost::asio::io_context &io);
      47           4 :     virtual ~DiagProto() {}
      48             : 
      49             :     ProtoHandler *AllocProtoHandler(boost::shared_ptr<PktInfo> info,
      50             :                                     boost::asio::io_context &io);
      51             :     bool SegmentHealthCheckProcess(
      52             :         HealthCheckTable::HealthCheckServiceAction action,
      53             :         HealthCheckInstanceService *service);
      54             :     void IncrementDiagStats(uint32_t itf_id, DiagStatsType type);
      55             :     const DiagStatsMap &stats() const { return stats_; }
      56             :     void FillSandeshHealthCheckResponse(SegmentHealthCheckPktStatsResp *resp);
      57             : 
      58             : private:
      59             :     SessionMap session_map_;
      60             :     /* lock for stats_ field for access between
      61             :      * health-check (which sends first health check packet),
      62             :      * timer-task (which sends periodic health check packets),
      63             :      * Diag task (which receives health-check requests/replies and sends
      64             :      *            health-check replies)
      65             :      * Introspect (which reads stats for filling introspect response)
      66             :      */
      67             :     std::mutex stats_mutex_;
      68             :     DiagStatsMap stats_;
      69             :     DISALLOW_COPY_AND_ASSIGN(DiagProto);
      70             : };
      71             : 
      72             : #endif

Generated by: LCOV version 1.14