OpenSDN source code
inetvpn_address.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef SRC_BGP_L3VPN_INETVPN_ADDRESS_H_
7 #define SRC_BGP_L3VPN_INETVPN_ADDRESS_H_
8 
9 #include <boost/system/error_code.hpp>
10 
11 #include <string>
12 
13 #include "bgp/bgp_attr.h"
14 #include "base/address.h"
15 #include "net/rd.h"
16 
17 class BgpServer;
18 
20 public:
21  InetVpnPrefix();
22  explicit InetVpnPrefix(const BgpProtoPrefix &prefix);
24  : rd_(rd), addr_(ip), prefixlen_(prefixlen) {
25  }
26 
27  static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix,
28  InetVpnPrefix *prefix,
29  const BgpAttr *attr, uint32_t *label);
30  static int FromProtoPrefix(BgpServer *server,
31  const BgpProtoPrefix &proto_prefix,
32  const BgpAttr *attr,
33  const Address::Family family,
34  InetVpnPrefix *prefix,
35  BgpAttrPtr *new_attr, uint32_t *label,
36  uint32_t *l3_label);
37  static InetVpnPrefix FromString(const std::string &str,
38  boost::system::error_code *errorp = NULL);
39 
40  std::string ToString() const;
41  bool IsMoreSpecific(const InetVpnPrefix &rhs) const;
42  bool operator==(const InetVpnPrefix &rhs) const;
43 
44  const RouteDistinguisher &route_distinguisher() const { return rd_; }
45  Ip4Address addr() const { return addr_; }
46  int prefixlen() const { return prefixlen_; }
47  void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *proto_prefix,
48  const BgpAttr *attr = NULL) const;
49 
50 private:
54 };
55 
56 #endif // SRC_BGP_L3VPN_INETVPN_ADDRESS_H_
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:15
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
Definition: bgp_attr.h:999
Family
Definition: address.h:25
RouteDistinguisher rd_
Ip4Address addr_
bool operator==(const InetVpnPrefix &rhs) const
static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix, InetVpnPrefix *prefix, const BgpAttr *attr, uint32_t *label)
bool IsMoreSpecific(const InetVpnPrefix &rhs) const
static InetVpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
int prefixlen() const
const RouteDistinguisher & route_distinguisher() const
std::string ToString() const
InetVpnPrefix(const RouteDistinguisher &rd, Ip4Address ip, int prefixlen)
Ip4Address addr() const
InetVpnPrefix(const BgpProtoPrefix &prefix)
void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *proto_prefix, const BgpAttr *attr=NULL) const