OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xmpp_config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __XMPP_CONFIG_H__
6 #define __XMPP_CONFIG_H__
7 
8 #include <boost/asio/ip/tcp.hpp>
9 #include <boost/function.hpp>
10 #include <boost/property_tree/ptree.hpp>
11 #include <boost/ptr_container/ptr_map.hpp>
12 
13 #include "base/util.h"
14 
15 // Internal representation of Peer configuration
17 public:
18  explicit XmppChannelConfig(bool isClient = false);
19 
20  std::string ToAddr;
21  std::string FromAddr;
22  std::string NodeAddr; // pubsub node
23  std::string name;
24  boost::asio::ip::tcp::endpoint endpoint;
25  boost::asio::ip::tcp::endpoint local_endpoint;
26  bool logUVE;
28  std::string path_to_server_cert;
30  std::string path_to_ca_cert;
33  int xmpp_hold_time; // was uint8_t, but int everywhere
34  uint8_t dscp_value;
35  std::string xmlns;
36 
37  int CompareTo(const XmppChannelConfig &rhs) const;
38  static int const default_client_port = 5269;
39  static int const default_server_port = 5222;
40  static int const kTcpHoldTime = 30; //in secs
41 
42  bool ClientOnly() const { return isClient_; }
43 
44 private:
45  bool isClient_;
46 };
47 
49 public:
50  typedef boost::ptr_map<boost::asio::ip::tcp::endpoint, XmppChannelConfig>
52 
54  }
55 
57  neighbors_.insert(channel->endpoint, channel);
58  }
59 
60  XmppChannelConfig &GetXmppChannelConfig(const boost::asio::ip::tcp::endpoint ep) {
61  return neighbors_[ep];
62  }
63 
64  const XmppChannelConfigMap &neighbors() const { return neighbors_; }
65 
66  void Clear() {
67  neighbors_.clear();
68  }
69 
70 private:
73 };
74 
76 public:
77  enum DiffType {
82  };
83 
85 
86  typedef boost::function<void(DiffType, const XmppChannelConfig *,
88 
89  // stage 1: build the future internal representation
90  bool ParseConfig(const std::string &config, XmppConfigData *);
91 
92  // stage 2: generate a delta
93  void PeerConfigDiff(PeerDiffObserver obs) const;
94 
95  // stage 3: commit
96  void AcceptFuture();
97 
98  // testing API -- begin --
99  void SetFuture(const XmppConfigData *future);
100  // testing API -- end --
101 
102  void Terminate();
103 private:
104  std::unique_ptr<const XmppConfigData> current_;
105  std::unique_ptr<const XmppConfigData> future_;
107 };
108 
109 #endif
boost::asio::ip::tcp::endpoint endpoint
Definition: xmpp_config.h:24
bool ParseConfig(const std::string &config, XmppConfigData *)
DISALLOW_COPY_AND_ASSIGN(XmppConfigManager)
boost::asio::ip::tcp::endpoint local_endpoint
Definition: xmpp_config.h:25
std::string ToAddr
Definition: xmpp_config.h:20
void PeerConfigDiff(PeerDiffObserver obs) const
Definition: xmpp_config.cc:32
XmppChannelConfig & GetXmppChannelConfig(const boost::asio::ip::tcp::endpoint ep)
Definition: xmpp_config.h:60
std::string path_to_ca_cert
Definition: xmpp_config.h:30
std::string FromAddr
Definition: xmpp_config.h:21
static int const kTcpHoldTime
Definition: xmpp_config.h:40
std::string xmlns
Definition: xmpp_config.h:35
XmppChannelConfigMap neighbors_
Definition: xmpp_config.h:71
int CompareTo(const XmppChannelConfig &rhs) const
Definition: xmpp_config.cc:21
std::string path_to_server_cert
Definition: xmpp_config.h:28
const XmppChannelConfigMap & neighbors() const
Definition: xmpp_config.h:64
bool ClientOnly() const
Definition: xmpp_config.h:42
std::unique_ptr< const XmppConfigData > future_
Definition: xmpp_config.h:105
uint8_t dscp_value
Definition: xmpp_config.h:34
std::unique_ptr< const XmppConfigData > current_
Definition: xmpp_config.h:104
XmppChannelConfig(bool isClient=false)
Definition: xmpp_config.cc:14
std::string name
Definition: xmpp_config.h:23
boost::function< void(DiffType, const XmppChannelConfig *, const XmppChannelConfig *)> PeerDiffObserver
Definition: xmpp_config.h:87
boost::ptr_map< boost::asio::ip::tcp::endpoint, XmppChannelConfig > XmppChannelConfigMap
Definition: xmpp_config.h:51
void AddXmppChannelConfig(XmppChannelConfig *channel)
Definition: xmpp_config.h:56
static int const default_client_port
Definition: xmpp_config.h:38
void SetFuture(const XmppConfigData *future)
Definition: xmpp_config.cc:69
DISALLOW_COPY_AND_ASSIGN(XmppConfigData)
std::string path_to_server_priv_key
Definition: xmpp_config.h:29
std::string NodeAddr
Definition: xmpp_config.h:22
static int const default_server_port
Definition: xmpp_config.h:39