LCOV - code coverage report
Current view: top level - xmpp - xmpp_channel.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 3 5 60.0 %
Date: 2026-06-22 02:21:21 Functions: 3 5 60.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 __XMPP_CHANNEL_INTERFACE_H__
       6             : #define __XMPP_CHANNEL_INTERFACE_H__
       7             : 
       8             : #include <boost/function.hpp>
       9             : #include <boost/system/error_code.hpp>
      10             : #include "xmpp/xmpp_proto.h"
      11             : 
      12             : class XmppConnection;
      13             : 
      14             : namespace xmps {
      15             :     typedef enum {
      16             :         UNKNOWN = 1,
      17             :         READY = 2,
      18             :         NOT_READY = 3,
      19             :         TIMEDOUT = 4
      20             :     } PeerState;
      21             : 
      22             :     typedef enum {
      23             :         CONFIG = 1,
      24             :         BGP = 2,
      25             :         DNS = 3,
      26             :         OTHER = 4
      27             :     } PeerId;
      28             : 
      29             :     std::string PeerIdToName(PeerId id);
      30             : }
      31             : 
      32             : class XmppChannel {
      33             : public:
      34             :     typedef boost::function<void(const boost::system::error_code &)>
      35             :         SendReadyCb;
      36             :     typedef boost::function<
      37             :         void(const XmppStanza::XmppMessage *, xmps::PeerState state)
      38             :         > ReceiveCb;
      39             :     typedef boost::function<bool(const std::string &,
      40             :                                  int,
      41             :                                  int,
      42             :                                  const std::string &,
      43             :                                  const XmppStanza::XmppMessage * msg)
      44             :         > RxMessageTraceCb;
      45             :     typedef boost::function<bool(const std::string &,
      46             :                                  int,
      47             :                                  int,
      48             :                                  const std::string &,
      49             :                                  const XmppStanza::XmppMessage * msg)
      50             :         > TxMessageTraceCb;
      51             : 
      52       12699 :     virtual ~XmppChannel() { }
      53             : 
      54             :     virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb) = 0;
      55           0 :     virtual bool Send(const uint8_t *msg, size_t msg_size,
      56             :                       const std::string *msg_str, xmps::PeerId id,
      57             :                       SendReadyCb cb) {
      58           0 :         return Send(msg, msg_size, id, cb);
      59             :     }
      60             :     virtual int GetTaskInstance() const = 0;
      61             :     virtual void RegisterReceive(xmps::PeerId, ReceiveCb) = 0;
      62             :     virtual void UnRegisterReceive(xmps::PeerId) = 0;
      63          47 :     virtual void RegisterReferer(xmps::PeerId) { }
      64          47 :     virtual void UnRegisterReferer(xmps::PeerId) { }
      65             :     virtual void RegisterRxMessageTraceCallback(RxMessageTraceCb cb) = 0;
      66             :     virtual void RegisterTxMessageTraceCallback(TxMessageTraceCb cb) = 0;
      67             :     virtual void UnRegisterWriteReady(xmps::PeerId id) = 0;
      68             :     virtual void Close() = 0;
      69             :     virtual const std::string &ToString() const = 0;
      70             :     virtual const std::string &FromString() const = 0;
      71             :     virtual std::string StateName() const = 0;
      72             :     virtual std::string LastStateName() const = 0;
      73             :     virtual std::string LastStateChangeAt() const = 0;
      74             :     virtual std::string LastEvent() const = 0;
      75             :     virtual uint32_t rx_open() const = 0;
      76             :     virtual uint32_t rx_close() const = 0;
      77             :     virtual uint32_t rx_update() const = 0;
      78             :     virtual uint32_t rx_keepalive() const = 0;
      79             :     virtual uint32_t tx_open() const = 0;
      80             :     virtual uint32_t tx_close() const = 0;
      81             :     virtual uint32_t tx_update() const = 0;
      82             :     virtual uint32_t tx_keepalive() const = 0;
      83             :     virtual uint32_t FlapCount() const = 0;
      84             :     virtual std::string LastFlap() const = 0;
      85             :     virtual xmps::PeerState GetPeerState() const = 0;
      86             :     virtual std::string AuthType() const = 0;
      87             :     virtual std::string PeerAddress() const = 0;
      88             :     virtual const XmppConnection *connection() const = 0;
      89             :     virtual XmppConnection *connection() = 0;
      90             :     virtual bool LastReceived(time_t duration) const = 0;
      91             :     virtual bool LastSent(time_t duration) const = 0;
      92             : };
      93             : 
      94             : #endif // __XMPP_CHANNEL_INTERFACE_H__

Generated by: LCOV version 1.14