OpenSDN source code
inet6vpn_route.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_
7 #define SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_
8 
9 #include <string>
10 #include <vector>
11 
12 #include "base/util.h"
13 #include "base/address.h"
14 #include "bgp/bgp_attr.h"
15 #include "bgp/bgp_attr_base.h"
16 #include "bgp/bgp_route.h"
17 #include "net/bgp_af.h"
18 #include "net/rd.h"
19 
21 public:
24  : rd_(rd), addr_(ip), prefixlen_(prefixlen) {
25  }
26 
27  static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix,
28  Inet6VpnPrefix *prefix, uint32_t *label);
29  static int FromProtoPrefix(BgpServer *server,
30  const BgpProtoPrefix &proto_prefix,
31  const BgpAttr *attr,
32  const Address::Family family,
33  Inet6VpnPrefix *prefix,
34  BgpAttrPtr *new_attr, uint32_t *label,
35  uint32_t *l3_label);
36  static Inet6VpnPrefix FromString(const std::string &str,
37  boost::system::error_code *errorp = NULL);
38 
39  std::string ToString() const;
40  bool IsMoreSpecific(const Inet6VpnPrefix &rhs) const;
41  int CompareTo(const Inet6VpnPrefix &other) const;
42  bool operator==(const Inet6VpnPrefix &rhs) const;
43 
44  const RouteDistinguisher &route_distinguisher() const { return rd_; }
45  Ip6Address addr() const { return addr_; }
46  int prefixlen() const { return prefixlen_; }
47  void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *prefix) const;
48 
49 private:
53 };
54 
55 class Inet6VpnRoute : public BgpRoute {
56 public:
57  explicit Inet6VpnRoute(const Inet6VpnPrefix &prefix);
58  virtual int CompareTo(const Route &rhs) const;
59 
60  virtual std::string ToString() const;
61 
62  const Inet6VpnPrefix &GetPrefix() const {
63  return prefix_;
64  }
67  }
68 
69  virtual KeyPtr GetDBRequestKey() const;
70  virtual void SetKey(const DBRequestKey *reqkey);
71  virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, const BgpAttr *attr,
72  uint32_t label, uint32_t l3_label = 0) const;
73  virtual void BuildBgpProtoNextHop(std::vector<uint8_t> &nh,
74  IpAddress nexthop) const;
75 
76  virtual bool IsLess(const DBEntry &genrhs) const {
77  const Inet6VpnRoute &rhs = static_cast<const Inet6VpnRoute &>(genrhs);
78  int cmp = CompareTo(rhs);
79  return (cmp < 0);
80  }
81 
82  virtual bool IsMoreSpecific(const std::string &other) const;
83  virtual bool IsLessSpecific(const std::string &other) const;
84 
85 private:
88 };
89 
90 #endif // SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:16
boost::asio::ip::address IpAddress
Definition: address.h:14
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
Definition: bgp_attr.h:999
Family
Definition: address.h:25
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
int CompareTo(const Inet6VpnPrefix &other) const
const RouteDistinguisher & route_distinguisher() const
static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix, Inet6VpnPrefix *prefix, uint32_t *label)
std::string ToString() const
Ip6Address addr() const
int prefixlen() const
bool IsMoreSpecific(const Inet6VpnPrefix &rhs) const
bool operator==(const Inet6VpnPrefix &rhs) const
Inet6VpnPrefix(const RouteDistinguisher &rd, Ip6Address ip, int prefixlen)
RouteDistinguisher rd_
Ip6Address addr_
void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *prefix) const
static Inet6VpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
virtual bool IsLess(const DBEntry &genrhs) const
Inet6VpnPrefix prefix_
const Inet6VpnPrefix & GetPrefix() const
virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, const BgpAttr *attr, uint32_t label, uint32_t l3_label=0) const
Inet6VpnRoute(const Inet6VpnPrefix &prefix)
virtual RouteDistinguisher GetRouteDistinguisher() const
virtual bool IsLessSpecific(const std::string &other) const
virtual bool IsMoreSpecific(const std::string &other) const
virtual int CompareTo(const Route &rhs) const
virtual void SetKey(const DBRequestKey *reqkey)
virtual void BuildBgpProtoNextHop(std::vector< uint8_t > &nh, IpAddress nexthop) const
virtual std::string ToString() const
virtual KeyPtr GetDBRequestKey() const
DISALLOW_COPY_AND_ASSIGN(Inet6VpnRoute)
Definition: route.h:15