LCOV - code coverage report
Current view: top level - vnsw/agent/diag - diag.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 17 0.0 %
Date: 2026-06-04 02:06:09 Functions: 0 12 0.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_diag_hpp
       6             : #define vnsw_agent_diag_diag_hpp
       7             : 
       8             : #include <base/logging.h>
       9             : #include <base/address.h>
      10             : #include <base/timer.h>
      11             : #include <base/queue_task.h>
      12             : #include "boost/date_time/posix_time/posix_time.hpp"
      13             : 
      14             : class Agent;
      15             : struct AgentDiagPktData;
      16             : struct OverlayOamPktData;
      17             : class DiagProto;
      18             : class DiagTable;
      19             : class DiagPktHandler;
      20             : 
      21             : class DiagEntry {
      22             : public:
      23             :     typedef uint16_t DiagKey;
      24             :     typedef Timer DiagTimer;
      25             : 
      26             :     DiagEntry(const std::string &sip, const std::string &dip, uint8_t proto,
      27             :               uint16_t sport, uint16_t dport, const std::string &vrf_name,
      28             :               int timeout, int count, DiagTable *diag_table);
      29             :     virtual ~DiagEntry();
      30             :     void Init();
      31             :     void EnqueueForceDelete();
      32             :     virtual void SendRequest() = 0;
      33             :     virtual void HandleReply(DiagPktHandler *handler) = 0;
      34             :     virtual void RequestTimedOut(uint32_t seq_no) = 0;
      35           0 :     virtual void SendSummary() { };
      36             :     bool TimerExpiry(uint32_t seqno);
      37             :     void RestartTimer();
      38             :     virtual bool IsDone();
      39           0 :     virtual bool ResendOnTimerExpiry() { return true; }
      40           0 :     DiagKey GetKey() { return key_;};
      41           0 :     uint32_t GetSeqNo() {return seq_no_;};
      42           0 :     uint32_t GetMaxAttempts() {return max_attempts_;};
      43           0 :     void SetKey(DiagKey key) {key_ = key;};
      44             :     virtual void Retry();
      45           0 :     bool TimerCancel() {
      46           0 :         return timer_->Cancel();
      47             :     }
      48           0 :     DiagTable* diag_table() const {
      49           0 :         return diag_table_;
      50             :     }
      51             :     uint32_t HashValUdpSourcePort();
      52             :     void FillOamPktHeader(OverlayOamPktData *pktdata, uint32_t vxlan_id,
      53             :                           const boost::posix_time::ptime &time);
      54             : 
      55             : protected:
      56             :     IpAddress sip_;
      57             :     IpAddress dip_;
      58             :     uint8_t    proto_;
      59             :     uint16_t   sport_;
      60             :     uint16_t   dport_;
      61             :     std::string vrf_name_;
      62             :     boost::system::error_code ec_;
      63             : 
      64             :     DiagTable *diag_table_;
      65             :     DiagKey key_;
      66             : 
      67             :     int timeout_;
      68             :     DiagTimer *timer_;
      69             :     uint32_t max_attempts_;
      70             :     uint32_t seq_no_;
      71             : };
      72             : 
      73             : struct AgentDiagPktData {
      74             :     enum Op {
      75             :         DIAG_REQUEST = 1,
      76             :         DIAG_REPLY
      77             :     };
      78             : 
      79           0 :     AgentDiagPktData() {
      80           0 :         memset(data_, 0, sizeof(data_));
      81           0 :     }
      82             :     uint32_t op_;
      83             :     DiagEntry::DiagKey key_;
      84             :     uint32_t seq_no_;
      85             :     char data_[8];
      86             :     boost::posix_time::ptime rtt_;
      87             : };
      88             : 
      89             : struct DiagEntryOp {
      90             :     enum Op {
      91             :         ADD = 1,
      92             :         DEL,
      93             :         RETRY,
      94             :         FORCE_DELETE
      95             :     };
      96             : 
      97           0 :     DiagEntryOp(DiagEntryOp::Op op, DiagEntry *de): op_(op), de_(de) {
      98           0 :     }
      99             : 
     100             :     Op op_;
     101             :     DiagEntry *de_;
     102             : };
     103             : 
     104             : class DiagTable {
     105             : public:
     106             :     typedef std::map<DiagEntry::DiagKey, DiagEntry *> DiagEntryTree;
     107             :     static const std::string kDiagData;
     108             :     DiagTable(Agent *agent);
     109             :     ~DiagTable();
     110             :     void Add(DiagEntry *);
     111             :     void Delete(DiagEntry *);
     112             :     DiagEntry* Find(DiagEntry::DiagKey &key);
     113             : 
     114             :     void Shutdown();
     115             :     void Enqueue(DiagEntryOp *op);
     116             :     bool Process(DiagEntryOp *op);
     117           0 :     Agent* agent() const { return agent_; }
     118           0 :     DiagProto *diag_proto() const { return diag_proto_.get(); }
     119             : 
     120             : private:
     121             :     uint16_t index_;
     122             :     DiagEntryTree tree_;
     123             :     boost::scoped_ptr<DiagProto> diag_proto_;
     124             :     WorkQueue<DiagEntryOp *> *entry_op_queue_;
     125             :     Agent *agent_;
     126             : };
     127             : 
     128             : struct OamTlv {
     129             :     enum Type {
     130             :         VXLAN_PING_IPv4 = 1,
     131             :         VXLAN_PING_IPv6 = 2,
     132             :         NVGRE_PING_IPv4 = 3,
     133             :         NVGRE_PING_IPv6 = 4,
     134             :         MPLSoGRE_PING_IPv4 = 5,
     135             :         MPLSoGRE_PING_IPv6 = 6,
     136             :         MPLSoUDP_PING_IPv4 = 7,
     137             :         MPLSoUDP_PING_IPv6 = 8,
     138             :     };
     139             : 
     140             :     struct VxlanOamV4Tlv {
     141             :         uint32_t vxlan_id_;
     142             :         uint32_t sip_;
     143             :     };
     144             : 
     145             :     struct VxlanOamV6Tlv {
     146             :         uint32_t vxlan_id_;
     147             :         uint8_t  sip_[16];
     148             :     };
     149             : 
     150             :     uint16_t type_;
     151             :     uint16_t length_;
     152             :     char data_[1];
     153             : };
     154             : 
     155             : struct SubTlv {
     156             :     enum Type {
     157             :         END_SYSTEM_MAC = 1,
     158             :         END_SYSTEM_IPv4 = 2,
     159             :         END_SYSTEM_IPv6 = 3,
     160             :         END_SYSTEM_MAC_IPv4 = 4,
     161             :         END_SYSTEM_MAC_IPv6 = 5,
     162             :     };
     163             : 
     164             :     enum ReturnCode {
     165             :         END_SYSTEM_PRESENT = 1,
     166             :         END_SYSTEM_NOT_PRESENT = 2,
     167             :     };
     168             : 
     169             :     uint16_t type_;
     170             :     uint16_t length_;
     171             : 
     172             :     struct EndSystemMac {
     173             :         uint8_t mac[6];
     174             :         uint16_t return_code;
     175             :     };
     176             : };
     177             : 
     178             : struct OverlayOamPktData {
     179             :    enum MsgType {
     180             :     OVERLAY_ECHO_REQUEST = 1,
     181             :     OVERLAY_ECHO_REPLY = 2
     182             :    };
     183             : 
     184             :    enum Returncode {
     185             :     NO_RETURN_CODE = 0,
     186             :     MALFORMED_ECHO_REQUEST = 1,
     187             :     OVERLAY_SEGMENT_NOT_PRESENT = 2,
     188             :     OVERLAY_SEGMENT_NOT_OPERATIONAL = 3,
     189             :     RETURN_CODE_OK = 4,
     190             :    };
     191             : 
     192             :    enum Replymode {
     193             :     DONT_REPLY = 1,
     194             :     REPLY_IPV4ORV6_UDP = 2,
     195             :     REPLY_OVERLAY_SEGMENT = 3,
     196             :    };
     197             : 
     198             :    uint8_t msg_type_;
     199             :    uint8_t reply_mode_;
     200             :    uint8_t return_code_;
     201             :    uint8_t return_subcode_;
     202             :    uint32_t org_handle_;
     203             :    uint32_t seq_no_;
     204             :    uint32_t timesent_sec_;
     205             :    uint32_t timesent_misec_;
     206             :    uint32_t timerecv_sec_;
     207             :    uint32_t timerecv_misec_;
     208             :    OamTlv oamtlv_;
     209             : };
     210             : #endif

Generated by: LCOV version 1.14