OpenSDN source code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xmpp_channel.h
Go to the documentation of this file.
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,
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 &)>
36  typedef boost::function<
37  void(const XmppStanza::XmppMessage *, xmps::PeerState state)
39  typedef boost::function<bool(const std::string &,
40  int,
41  int,
42  const std::string &,
43  const XmppStanza::XmppMessage * msg)
45  typedef boost::function<bool(const std::string &,
46  int,
47  int,
48  const std::string &,
49  const XmppStanza::XmppMessage * msg)
51 
52  virtual ~XmppChannel() { }
53 
54  virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb) = 0;
55  virtual bool Send(const uint8_t *msg, size_t msg_size,
56  const std::string *msg_str, xmps::PeerId id,
57  SendReadyCb cb) {
58  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  virtual void RegisterReferer(xmps::PeerId) { }
64  virtual void UnRegisterReferer(xmps::PeerId) { }
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__
virtual const XmppConnection * connection() const =0
virtual void RegisterReceive(xmps::PeerId, ReceiveCb)=0
virtual void RegisterTxMessageTraceCallback(TxMessageTraceCb cb)=0
boost::function< void(const boost::system::error_code &)> SendReadyCb
Definition: xmpp_channel.h:35
virtual ~XmppChannel()
Definition: xmpp_channel.h:52
virtual void Close()=0
virtual xmps::PeerState GetPeerState() const =0
virtual int GetTaskInstance() const =0
boost::function< bool(const std::string &, int, int, const std::string &, const XmppStanza::XmppMessage *msg) > RxMessageTraceCb
Definition: xmpp_channel.h:44
virtual std::string AuthType() const =0
virtual bool Send(const uint8_t *, size_t, xmps::PeerId, SendReadyCb)=0
virtual std::string LastStateChangeAt() const =0
virtual void RegisterReferer(xmps::PeerId)
Definition: xmpp_channel.h:63
virtual bool LastReceived(time_t duration) const =0
virtual uint32_t rx_update() const =0
virtual std::string StateName() const =0
virtual uint32_t tx_keepalive() const =0
virtual bool Send(const uint8_t *msg, size_t msg_size, const std::string *msg_str, xmps::PeerId id, SendReadyCb cb)
Definition: xmpp_channel.h:55
virtual void RegisterRxMessageTraceCallback(RxMessageTraceCb cb)=0
virtual std::string LastEvent() const =0
virtual const std::string & ToString() const =0
virtual void UnRegisterReceive(xmps::PeerId)=0
virtual std::string LastStateName() const =0
virtual const std::string & FromString() const =0
string PeerIdToName(PeerId id)
Definition: xmpp_channel.cc:11
virtual uint32_t FlapCount() const =0
virtual bool LastSent(time_t duration) const =0
boost::function< bool(const std::string &, int, int, const std::string &, const XmppStanza::XmppMessage *msg) > TxMessageTraceCb
Definition: xmpp_channel.h:50
boost::function< void(const XmppStanza::XmppMessage *, xmps::PeerState state) > ReceiveCb
Definition: xmpp_channel.h:38
virtual uint32_t tx_close() const =0
virtual uint32_t rx_open() const =0
virtual void UnRegisterWriteReady(xmps::PeerId id)=0
virtual void UnRegisterReferer(xmps::PeerId)
Definition: xmpp_channel.h:64
virtual uint32_t tx_update() const =0
virtual std::string PeerAddress() const =0
virtual uint32_t tx_open() const =0
virtual uint32_t rx_close() const =0
virtual uint32_t rx_keepalive() const =0
virtual std::string LastFlap() const =0