Line data Source code
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_ROUTE_H_ 7 : #define SRC_BGP_L3VPN_INETVPN_ROUTE_H_ 8 : 9 : #include <set> 10 : #include <string> 11 : #include <vector> 12 : 13 : #include "base/util.h" 14 : #include "base/address.h" 15 : #include "bgp/bgp_attr.h" 16 : #include "bgp/bgp_attr_base.h" 17 : #include "bgp/bgp_route.h" 18 : #include "bgp/l3vpn/inetvpn_address.h" 19 : #include "net/bgp_af.h" 20 : 21 : class InetVpnRoute : public BgpRoute { 22 : public: 23 : explicit InetVpnRoute(const InetVpnPrefix &prefix); 24 : virtual int CompareTo(const Route &rhs) const; 25 : 26 : virtual std::string ToString() const; 27 : 28 2539131 : const InetVpnPrefix &GetPrefix() const { 29 2539131 : return prefix_; 30 : } 31 1 : virtual RouteDistinguisher GetRouteDistinguisher() const { 32 1 : return prefix_.route_distinguisher(); 33 : } 34 : 35 : virtual KeyPtr GetDBRequestKey() const; 36 : virtual void SetKey(const DBRequestKey *reqkey); 37 : virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, 38 : const BgpAttr *attr = NULL, 39 : uint32_t label = 0, 40 : uint32_t l3_label = 0) const; 41 : virtual void BuildBgpProtoNextHop(std::vector<uint8_t> &nh, 42 : IpAddress nexthop) const; 43 : 44 2031794 : virtual bool IsLess(const DBEntry &genrhs) const { 45 2031794 : const InetVpnRoute &rhs = static_cast<const InetVpnRoute &>(genrhs); 46 2031794 : int cmp = CompareTo(rhs); 47 2031461 : return (cmp < 0); 48 : } 49 : 50 : virtual bool IsMoreSpecific(const std::string &match) const; 51 : virtual bool IsLessSpecific(const std::string &match) const; 52 : 53 : private: 54 : InetVpnPrefix prefix_; 55 : DISALLOW_COPY_AND_ASSIGN(InetVpnRoute); 56 : }; 57 : 58 : #endif // SRC_BGP_L3VPN_INETVPN_ROUTE_H_