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