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

Generated by: LCOV version 1.14