39 : type_(type), rd_(rd), group_(group), source_(source) {
45 : type_(type), rd_(rd), router_id_(router_id),
46 group_(group), source_(source) {
53 size_t nlri_size = proto_prefix.
prefix.size();
54 size_t expected_nlri_size =
59 if (nlri_size != expected_nlri_size)
65 size_t rtid_offset = rd_offset + rd_size;
69 size_t source_offset = rtid_offset + rtid_size + 1;
101 proto_prefix->
prefix.clear();
106 size_t rd_offset = 0;
108 proto_prefix->
prefix.begin() + rd_offset);
110 size_t rtid_offset = rd_offset + rd_size;
111 const Ip4Address::bytes_type &rtid_bytes =
router_id_.to_bytes();
113 proto_prefix->
prefix.begin() + rtid_offset);
115 size_t source_offset = rtid_offset + rtid_size + 1;
117 const Ip4Address::bytes_type &source_bytes =
source_.to_bytes();
119 proto_prefix->
prefix.begin() + source_offset);
123 const Ip4Address::bytes_type &group_bytes =
group_.to_bytes();
125 proto_prefix->
prefix.begin() + group_offset);
129 boost::system::error_code *errorp) {
134 size_t pos1 = str.find(
'-');
135 if (pos1 == string::npos) {
136 if (errorp != NULL) {
137 *errorp = make_error_code(boost::system::errc::invalid_argument);
141 temp_str = str.substr(0, pos1);
144 if (errorp != NULL) {
145 *errorp = make_error_code(boost::system::errc::invalid_argument);
151 size_t pos2 = str.find(
'-', pos1 + 1);
152 if (pos2 == string::npos) {
153 if (errorp != NULL) {
154 *errorp = make_error_code(boost::system::errc::invalid_argument);
158 temp_str = str.substr(pos1 + 1, pos2 - pos1 - 1);
159 boost::system::error_code rd_err;
161 if (rd_err.failed()) {
162 if (errorp != NULL) {
169 size_t pos3 = str.find(
',', pos2 + 1);
170 if (pos3 == string::npos) {
171 if (errorp != NULL) {
172 *errorp = make_error_code(boost::system::errc::invalid_argument);
176 temp_str = str.substr(pos2 + 1, pos3 - pos2 - 1);
177 boost::system::error_code rtid_err;
178 prefix.
router_id_ = Ip4Address::from_string(temp_str, rtid_err);
179 if (rtid_err.failed()) {
180 if (errorp != NULL) {
187 size_t pos4 = str.find(
',', pos3 + 1);
188 if (pos4 == string::npos) {
189 if (errorp != NULL) {
190 *errorp = make_error_code(boost::system::errc::invalid_argument);
194 temp_str = str.substr(pos3 + 1, pos4 - pos3 - 1);
195 boost::system::error_code group_err;
196 prefix.
group_ = Ip4Address::from_string(temp_str, group_err);
197 if (group_err.failed()) {
198 if (errorp != NULL) {
205 temp_str = str.substr(pos4 + 1, string::npos);
206 boost::system::error_code source_err;
207 prefix.
source_ = Ip4Address::from_string(temp_str, source_err);
208 if (source_err.failed()) {
209 if (errorp != NULL) {
210 *errorp = source_err;
222 repr +=
"," +
group_.to_string();
223 repr +=
"," +
source_.to_string();
230 repr +=
":" +
group_.to_string();
231 repr +=
"," +
source_.to_string();
302 const BgpAttr *attr, uint32_t label, uint32_t l3_label)
const {
307 vector<uint8_t> &nh,
IpAddress nexthop)
const {
309 const Ip4Address::bytes_type &addr_bytes = nexthop.to_v4().to_bytes();
310 copy(addr_bytes.begin(), addr_bytes.end(), nh.begin());
322 return "NativeRoute";
324 return "LocalTreeRoute";
326 return "GlobalTreeRoute";
virtual std::string ToXmppIdString() const
void BuildProtoPrefix(BgpProtoPrefix *prefix) const
const BgpPath * BestPath() const
const ErmVpnPrefix & GetPrefix() const
LabelBlockPtr label_block() const
virtual int CompareTo(const Route &rhs) const
std::string ToString() const
#define KEY_COMPARE(x, y)
static bool IsValid(uint8_t type)
boost::asio::ip::address IpAddress
bool stringToInteger(const std::string &str, NumberType &num)
static RouteDistinguisher FromString(const std::string &str, boost::system::error_code *error=NULL)
static const uint8_t kMaxV4PrefixLen
std::string ToXmppIdString() const
std::unique_ptr< DBRequestKey > KeyPtr
static uint64_t get_value(const uint8_t *data, int size)
static ErmVpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
static const size_t kSize
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
const std::string GetType() const
static const std::string integerToString(const NumberType &num)
static const uint8_t kMaxV4Bytes
std::vector< uint8_t > prefix
virtual std::string ToString() const
Ip4Address router_id() const
const RouteDistinguisher & route_distinguisher() const
Ip4Address source() const
boost::asio::ip::address_v4 Ip4Address
static bool IsValidForBgp(uint8_t type)
const std::string GetType() const
virtual KeyPtr GetDBRequestKey() const
bool operator==(const ErmVpnPrefix &rhs) const
const BgpAttr * GetAttr() const
ErmVpnRoute(const ErmVpnPrefix &prefix)
std::string ToString() const
static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix, ErmVpnPrefix *prefix)
const EdgeForwarding * edge_forwarding() const
virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, const BgpAttr *attr=NULL, uint32_t label=0, uint32_t l3_label=0) const
const EdgeDiscovery * edge_discovery() const
const uint8_t * GetData() const
virtual void SetKey(const DBRequestKey *reqkey)
virtual bool IsValid() const
virtual bool IsValid() const
virtual void BuildBgpProtoNextHop(std::vector< uint8_t > &nh, IpAddress nexthop) const