OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bgp_peer_key.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "bgp/bgp_peer_key.h"
6 
7 
8 #include "base/string_util.h"
9 #include "bgp/bgp_config.h"
10 
11 using boost::asio::ip::address;
12 using boost::system::error_code;
13 using boost::uuids::nil_generator;
14 using std::exception;
15 
17  nil_generator nil;
18  uuid = nil();
19 }
20 
22  error_code ec;
23  endpoint.address(config->peer_address());
24  endpoint.port(config->port());
25 
26  if (!config->uuid().empty()) {
27 #if defined(__EXCEPTIONS)
28  try {
29 #endif
30  uuid = StringToUuid(config->uuid());
31 #if defined(__EXCEPTIONS)
32  } catch (exception &ex) {
33  nil_generator nil;
34  uuid = nil();
35  }
36 #endif
37  } else {
38  boost::uuids::nil_generator nil;
39  uuid = nil();
40  }
41 }
42 
43 bool BgpPeerKey::operator<(const BgpPeerKey &rhs) const {
44  if (endpoint != rhs.endpoint) {
45  return (endpoint < rhs.endpoint);
46  }
47  return uuid < rhs.uuid;
48 }
49 
50 bool BgpPeerKey::operator>(const BgpPeerKey &rhs) const {
51  if (endpoint != rhs.endpoint) {
52  return (endpoint > rhs.endpoint);
53  }
54  return uuid > rhs.uuid;
55 }
56 
57 bool BgpPeerKey::operator==(const BgpPeerKey &rhs) const {
58  return (endpoint == rhs.endpoint && uuid == rhs.uuid);
59 }
60 
61 bool BgpPeerKey::operator!=(const BgpPeerKey &rhs) const {
62  return (endpoint != rhs.endpoint || uuid != rhs.uuid);
63 }
static boost::uuids::uuid StringToUuid(const std::string &str)
Definition: string_util.h:145
bool operator>(const BgpPeerKey &rhs) const
Definition: bgp_peer_key.cc:50
bool operator!=(const BgpPeerKey &rhs) const
Definition: bgp_peer_key.cc:61
bool operator==(const BgpPeerKey &rhs) const
Definition: bgp_peer_key.cc:57
boost::uuids::uuid uuid
boost::asio::ip::tcp::endpoint endpoint
Definition: bgp_peer_key.h:24
uint16_t port() const
Definition: bgp_config.h:216
boost::uuids::uuid uuid
Definition: bgp_peer_key.h:25
const std::string & uuid() const
Definition: bgp_config.h:165
bool operator<(const BgpPeerKey &rhs) const
Definition: bgp_peer_key.cc:43
const IpAddress & peer_address() const
Definition: bgp_config.h:201