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