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

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef SRC_BGP_L3VPN_INETVPN_ADDRESS_H_
       6             : #define SRC_BGP_L3VPN_INETVPN_ADDRESS_H_
       7             : 
       8             : #include <boost/system/error_code.hpp>
       9             : 
      10             : #include <string>
      11             : 
      12             : #include "bgp/bgp_attr.h"
      13             : #include "base/address.h"
      14             : #include "net/rd.h"
      15             : 
      16             : class BgpServer;
      17             : 
      18             : class InetVpnPrefix {
      19             : public:
      20             :     InetVpnPrefix();
      21             :     explicit InetVpnPrefix(const BgpProtoPrefix &prefix);
      22       43995 :     InetVpnPrefix(const RouteDistinguisher &rd, Ip4Address ip, int prefixlen)
      23       43995 :         : rd_(rd), addr_(ip), prefixlen_(prefixlen) {
      24       43996 :     }
      25             : 
      26             :     static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix,
      27             :                                InetVpnPrefix *prefix,
      28             :                                const BgpAttr *attr, uint32_t *label);
      29             :     static int FromProtoPrefix(BgpServer *server,
      30             :                                const BgpProtoPrefix &proto_prefix,
      31             :                                const BgpAttr *attr,
      32             :                                const Address::Family family,
      33             :                                InetVpnPrefix *prefix,
      34             :                                BgpAttrPtr *new_attr, uint32_t *label,
      35             :                                uint32_t *l3_label);
      36             :     static InetVpnPrefix FromString(const std::string &str,
      37             :                                     boost::system::error_code *errorp = NULL);
      38             : 
      39             :     std::string ToString() const;
      40             :     bool IsMoreSpecific(const InetVpnPrefix &rhs) const;
      41             :     bool operator==(const InetVpnPrefix &rhs) const;
      42             : 
      43     4792107 :     const RouteDistinguisher &route_distinguisher() const { return rd_; }
      44     4893872 :     Ip4Address addr() const { return addr_; }
      45     3550904 :     int prefixlen() const { return prefixlen_; }
      46             :     void BuildProtoPrefix(uint32_t label, BgpProtoPrefix *proto_prefix,
      47             :         const BgpAttr *attr = NULL) const;
      48             : 
      49             : private:
      50             :     RouteDistinguisher rd_;
      51             :     Ip4Address addr_;
      52             :     int prefixlen_;
      53             : };
      54             : 
      55             : #endif  // SRC_BGP_L3VPN_INETVPN_ADDRESS_H_

Generated by: LCOV version 1.14