OpenSDN source code
rtarget_route.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
8 
9 #include <algorithm>
10 
11 using std::copy;
12 using std::string;
13 using std::vector;
14 
16  : prefix_(prefix) {
17 }
18 
19 int RTargetRoute::CompareTo(const Route &rhs) const {
20  const RTargetRoute &rt_rhs = static_cast<const RTargetRoute &>(rhs);
21  return prefix_.CompareTo(rt_rhs.prefix_);
22 }
23 
24 string RTargetRoute::ToString() const {
25  return prefix_.ToString();
26 }
27 
28 void RTargetRoute::SetKey(const DBRequestKey *reqkey) {
29  const RTargetTable::RequestKey *key =
30  static_cast<const RTargetTable::RequestKey *>(reqkey);
31  prefix_ = key->prefix;
32 }
33 
35  const BgpAttr *attr,
36  uint32_t label,
37  uint32_t l3_label) const {
38  prefix_.BuildProtoPrefix(prefix);
39 }
40 
41 void RTargetRoute::BuildBgpProtoNextHop(vector<uint8_t> &nh,
42  IpAddress nexthop) const {
43  nh.resize(4);
44  const Ip4Address::bytes_type &addr_bytes = nexthop.to_v4().to_bytes();
45  copy(addr_bytes.begin(), addr_bytes.end(), nh.begin());
46 }
47 
51  return KeyPtr(key);
52 }
boost::asio::ip::address IpAddress
Definition: address.h:14
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
std::string ToString() const
int CompareTo(const RTargetPrefix &rhs) const
void BuildProtoPrefix(BgpProtoPrefix *prefix) const
RTargetRoute(const RTargetPrefix &prefix)
virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, const BgpAttr *attr=NULL, uint32_t label=0, uint32_t l3_label=0) const
virtual std::string ToString() const
virtual KeyPtr GetDBRequestKey() const
RTargetPrefix prefix_
Definition: rtarget_route.h:48
virtual void SetKey(const DBRequestKey *reqkey)
virtual void BuildBgpProtoNextHop(std::vector< uint8_t > &nh, IpAddress nexthop) const
const RTargetPrefix & GetPrefix() const
Definition: rtarget_route.h:28
virtual int CompareTo(const Route &rhs) const
Definition: route.h:15