LCOV - code coverage report
Current view: top level - bgp/rtarget - rtarget_route.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 19 23 82.6 %
Date: 2026-11-16 02:06:09 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          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             : #include "bgp/rtarget/rtarget_route.h"
       7             : #include "bgp/rtarget/rtarget_table.h"
       8             : 
       9             : #include <algorithm>
      10             : 
      11             : using std::copy;
      12             : using std::string;
      13             : using std::vector;
      14             : 
      15        8002 : RTargetRoute::RTargetRoute(const RTargetPrefix &prefix)
      16        8002 :     : prefix_(prefix) {
      17        8002 : }
      18             : 
      19       60596 : int RTargetRoute::CompareTo(const Route &rhs) const {
      20       60596 :     const RTargetRoute &rt_rhs = static_cast<const RTargetRoute &>(rhs);
      21       60596 :     return prefix_.CompareTo(rt_rhs.prefix_);
      22             : }
      23             : 
      24         556 : string RTargetRoute::ToString() const {
      25         556 :     return prefix_.ToString();
      26             : }
      27             : 
      28           0 : void RTargetRoute::SetKey(const DBRequestKey *reqkey) {
      29           0 :     const RTargetTable::RequestKey *key =
      30             :         static_cast<const RTargetTable::RequestKey *>(reqkey);
      31           0 :     prefix_ = key->prefix;
      32           0 : }
      33             : 
      34        2160 : void RTargetRoute::BuildProtoPrefix(BgpProtoPrefix *prefix,
      35             :                                     const BgpAttr *attr,
      36             :                                     uint32_t label,
      37             :                                     uint32_t l3_label) const {
      38        2160 :     prefix_.BuildProtoPrefix(prefix);
      39        2160 : }
      40             : 
      41        1175 : void RTargetRoute::BuildBgpProtoNextHop(vector<uint8_t> &nh,
      42             :                                         IpAddress nexthop) const {
      43        1175 :     nh.resize(4);
      44        1175 :     const Ip4Address::bytes_type &addr_bytes = nexthop.to_v4().to_bytes();
      45        1175 :     copy(addr_bytes.begin(), addr_bytes.end(), nh.begin());
      46        1175 : }
      47             : 
      48        3052 : DBEntryBase::KeyPtr RTargetRoute::GetDBRequestKey() const {
      49             :     RTargetTable::RequestKey *key =
      50        3052 :         new RTargetTable::RequestKey(GetPrefix(), NULL);
      51        3052 :     return KeyPtr(key);
      52             : }

Generated by: LCOV version 1.14