-
Notifications
You must be signed in to change notification settings - Fork 390
/
controller_dns.h
63 lines (52 loc) · 2.16 KB
/
controller_dns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef __DNS_XMPP_H__
#define __DNS_XMPP_H__
#include <map>
#include <string>
#include <boost/function.hpp>
#include <boost/system/error_code.hpp>
#include <bind/bind_util.h>
#include <xmpp/xmpp_channel.h>
class XmppChannel;
class Agent;
class VmInterface;
class AgentDnsXmppChannel {
public:
// Packet module is optional. Callback function to update the flow stats
// for ACL. The callback is defined to avoid linking error
// when flow is not enabled
typedef boost::function<void(DnsUpdateData*, DnsAgentXmpp::XmppType,
VmInterface const*, bool)> DnsMessageHandler;
typedef boost::function<void(AgentDnsXmppChannel*)> DnsXmppEventHandler;
explicit AgentDnsXmppChannel(Agent *agent,
std::string xmpp_server, uint8_t xs_idx);
virtual ~AgentDnsXmppChannel();
virtual std::string ToString() const;
virtual bool SendMsg(uint8_t *msg, std::size_t len);
virtual void ReceiveMsg(const XmppStanza::XmppMessage *msg);
std::string GetXmppServer() { return xmpp_server_; }
uint8_t GetXmppServerIdx() { return xs_idx_; }
XmppChannel *GetXmppChannel() { return channel_; }
void UpdateConnectionInfo(xmps::PeerState state);
static void XmppClientChannelEvent(AgentDnsXmppChannel *peer,
xmps::PeerState state);
static void HandleXmppClientChannelEvent(AgentDnsXmppChannel *peer,
xmps::PeerState state);
static void set_dns_message_handler_cb(DnsMessageHandler cb);
static void set_dns_xmpp_event_handler_cb(DnsXmppEventHandler cb);
Agent *agent() const {return agent_;}
void RegisterXmppChannel(XmppChannel *channel);
protected:
virtual void WriteReadyCb(const boost::system::error_code &ec);
private:
void ReceiveInternal(const XmppStanza::XmppMessage *msg);
XmppChannel *channel_;
std::string xmpp_server_;
uint8_t xs_idx_;
static DnsMessageHandler dns_message_handler_cb_;
static DnsXmppEventHandler dns_xmpp_event_handler_cb_;
Agent *agent_;
};
#endif // __DNS_XMPP_H__