LCOV - code coverage report
Current view: top level - bgp/inet6vpn - inet6vpn_route.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 12 14 85.7 %
Date: 2026-06-22 02:21:21 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_
       6             : #define SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_
       7             : 
       8             : #include <string>
       9             : #include <vector>
      10             : 
      11             : #include "base/util.h"
      12             : #include "base/address.h"
      13             : #include "bgp/bgp_attr.h"
      14             : #include "bgp/bgp_attr_base.h"
      15             : #include "bgp/bgp_route.h"
      16             : #include "net/bgp_af.h"
      17             : #include "net/rd.h"
      18             : 
      19             : class Inet6VpnPrefix {
      20             : public:
      21             :     Inet6VpnPrefix();
      22       20292 :     Inet6VpnPrefix(const RouteDistinguisher &rd, Ip6Address ip, int prefixlen)
      23       20292 :         : rd_(rd), addr_(ip), prefixlen_(prefixlen) {
      24       20291 :     }
      25             : 
      26             :     static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix,
      27             :                                Inet6VpnPrefix *prefix, uint32_t *label);
      28             :     static int FromProtoPrefix(BgpServer *server,
      29             :                                const BgpProtoPrefix &proto_prefix,
      30             :                                const BgpAttr *attr,
      31             :                                const Address::Family family,
      32             :                                Inet6VpnPrefix *prefix,
      33             :                                BgpAttrPtr *new_attr, uint32_t *label,
      34             :                                uint32_t *l3_label);
      35             :     static Inet6VpnPrefix FromString(const std::string &str,
      36             :                                      boost::system::error_code *errorp = NULL);
      37             : 
      38             :     std::string ToString() const;
      39             :     bool IsMoreSpecific(const Inet6VpnPrefix &rhs) const;
      40             :     int CompareTo(const Inet6VpnPrefix &other) const;
      41             :     bool operator==(const Inet6VpnPrefix &rhs) const;
      42             : 
      43     3684054 :     const RouteDistinguisher &route_distinguisher() const { return rd_; }
      44     3198342 :     Ip6Address addr() const { return addr_; }
      45     2865903 :     int prefixlen() const { return prefixlen_; }
      46             :     void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *prefix) const;
      47             : 
      48             : private:
      49             :     RouteDistinguisher rd_;
      50             :     Ip6Address addr_;
      51             :     int prefixlen_;
      52             : };
      53             : 
      54             : class Inet6VpnRoute : public BgpRoute {
      55             : public:
      56             :     explicit Inet6VpnRoute(const Inet6VpnPrefix &prefix);
      57             :     virtual int CompareTo(const Route &rhs) const;
      58             : 
      59             :     virtual std::string ToString() const;
      60             : 
      61     3546566 :     const Inet6VpnPrefix &GetPrefix() const {
      62     3546566 :         return prefix_;
      63             :     }
      64           0 :     virtual RouteDistinguisher GetRouteDistinguisher() const {
      65           0 :         return prefix_.route_distinguisher();
      66             :     }
      67             : 
      68             :     virtual KeyPtr GetDBRequestKey() const;
      69             :     virtual void SetKey(const DBRequestKey *reqkey);
      70             :     virtual void BuildProtoPrefix(BgpProtoPrefix *prefix, const BgpAttr *attr,
      71             :                                   uint32_t label, uint32_t l3_label = 0) const;
      72             :     virtual void BuildBgpProtoNextHop(std::vector<uint8_t> &nh,
      73             :                                       IpAddress nexthop) const;
      74             : 
      75     1496736 :     virtual bool IsLess(const DBEntry &genrhs) const {
      76     1496736 :         const Inet6VpnRoute &rhs = static_cast<const Inet6VpnRoute &>(genrhs);
      77     1496736 :         int cmp = CompareTo(rhs);
      78     1496635 :         return (cmp < 0);
      79             :     }
      80             : 
      81             :     virtual bool IsMoreSpecific(const std::string &other) const;
      82             :     virtual bool IsLessSpecific(const std::string &other) const;
      83             : 
      84             : private:
      85             :     Inet6VpnPrefix prefix_;
      86             :     DISALLOW_COPY_AND_ASSIGN(Inet6VpnRoute);
      87             : };
      88             : 
      89             : #endif  // SRC_BGP_INET6VPN_INET6VPN_ROUTE_H_

Generated by: LCOV version 1.14