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

Generated by: LCOV version 1.14