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