OpenSDN source code
bgp_rib_policy.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #include "bgp/bgp_rib_policy.h"
7 
8 using std::string;
9 using std::vector;
10 
12  : enabled(false),
13  all(false),
14  replace(false),
15  peer_loop_check(false) {
16 }
17 
19  : type(BgpProto::IBGP),
20  encoding(BGP),
21  as_number(0),
22  local_as_number(0),
23  as_override(false),
24  affinity(-1),
25  llgr(false),
26  as4_supported(false),
27  cluster_id(0) {
28 }
29 
31  : type(BgpProto::IBGP),
32  encoding(BGP),
33  as_number(0),
34  local_as_number(0),
35  as_override(false),
36  affinity(-1),
37  llgr(false),
38  as4_supported(false),
39  cluster_id(cluster_id) {
40 }
41 
43  int affinity, uint32_t cluster_id)
44  : type(type),
45  encoding(encoding),
46  as_number(0),
47  local_as_number(0),
48  as_override(false),
49  affinity(affinity),
50  llgr(false),
51  as4_supported(false),
52  cluster_id(cluster_id) {
53  if (encoding == XMPP)
54  assert(type == BgpProto::XMPP);
55  if (encoding == BGP)
56  assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
57 }
58 
60  as_t as_number, bool as_override, bool llgr, bool as4, int affinity,
61  uint32_t cluster_id, as_t local_as_number)
62  : type(type),
63  encoding(encoding),
64  as_number(as_number),
65  local_as_number(local_as_number),
66  as_override(as_override),
67  affinity(affinity),
68  llgr(llgr),
69  as4_supported(as4),
70  cluster_id(cluster_id) {
71  if (encoding == XMPP)
72  assert(type == BgpProto::XMPP);
73  if (encoding == BGP)
74  assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
75 }
76 
77 
79  as_t as_number, bool as_override, bool llgr, bool as4, IpAddress nexthop,
80  int affinity, uint32_t cluster_id,
81  vector<string> &default_tunnel_encap_list, as_t local_as_number) :
82  type(type),
83  encoding(BGP),
84  as_number(as_number),
85  local_as_number(local_as_number),
86  as_override(as_override),
87  nexthop(nexthop),
88  affinity(affinity),
89  llgr(llgr),
90  as4_supported(as4),
91  cluster_id(cluster_id),
92  default_tunnel_encap_list(default_tunnel_encap_list) {
93  assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
94  assert(encoding == BGP);
95 }
96 
97 void RibExportPolicy::SetRemovePrivatePolicy(bool all, bool replace,
98  bool peer_loop_check) {
99  remove_private.enabled = true;
100  remove_private.all = all;
101  remove_private.replace = replace;
102  remove_private.peer_loop_check = peer_loop_check;
103 }
104 
105 //
106 // Implement operator< for RibExportPolicy by comparing each of the fields.
107 //
110  BOOL_KEY_COMPARE(type, rhs.type);
116  BOOL_KEY_COMPARE(llgr, rhs.llgr);
125  return false;
126 }
boost::asio::ip::address IpAddress
Definition: address.h:14
uint32_t as_t
Definition: bgp_common.h:22
uint8_t type
Definition: load_balance.h:2
IpAddress nexthop
std::vector< std::string > default_tunnel_encap_list
void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check)
BgpProto::BgpPeerType type
RemovePrivatePolicy remove_private
uint32_t cluster_id
bool operator<(const RibExportPolicy &rhs) const
#define BOOL_KEY_COMPARE(x, y)
Definition: util.h:65