LCOV - code coverage report
Current view: top level - bgp/ermvpn - ermvpn_route.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 11 11 100.0 %
Date: 2026-11-09 02:10:49 Functions: 8 8 100.0 %
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             : #ifndef SRC_BGP_ERMVPN_ERMVPN_ROUTE_H_
       7             : #define SRC_BGP_ERMVPN_ERMVPN_ROUTE_H_
       8             : 
       9             : #include <boost/system/error_code.hpp>
      10             : 
      11             : #include <set>
      12             : #include <string>
      13             : #include <vector>
      14             : 
      15             : #include "base/util.h"
      16             : #include "base/address.h"
      17             : #include "bgp/bgp_attr.h"
      18             : #include "bgp/bgp_attr_base.h"
      19             : #include "bgp/bgp_route.h"
      20             : #include "net/bgp_af.h"
      21             : #include "net/rd.h"
      22             : 
      23             : class ErmVpnPrefix {
      24             : public:
      25             :     enum RouteType {
      26             :         NativeRoute = 0,
      27             :         LocalTreeRoute = 1,
      28             :         GlobalTreeRoute = 2,
      29             :         Invalid = 255,
      30             :     };
      31             : 
      32             :     ErmVpnPrefix();
      33             :     ErmVpnPrefix(uint8_t type, const RouteDistinguisher &rd,
      34             :                  const Ip4Address &group, const Ip4Address &source);
      35             :     ErmVpnPrefix(uint8_t type, const RouteDistinguisher &rd,
      36             :                  const Ip4Address &router_id,
      37             :                  const Ip4Address &group, const Ip4Address &source);
      38             :     const std::string GetType() const;
      39             : 
      40             :     static int FromProtoPrefix(const BgpProtoPrefix &proto_prefix,
      41             :                                ErmVpnPrefix *prefix);
      42             :     static int FromProtoPrefix(BgpServer *server,
      43             :                                const BgpProtoPrefix &proto_prefix,
      44             :                                const BgpAttr *attr,
      45             :                                const Address::Family family,
      46             :                                ErmVpnPrefix *prefix, BgpAttrPtr *new_attr,
      47             :                                uint32_t *label, uint32_t *l3_label);
      48             :     static ErmVpnPrefix FromString(const std::string &str,
      49             :                                    boost::system::error_code *errorp = NULL);
      50             : 
      51             :     std::string ToString() const;
      52             :     std::string ToXmppIdString() const;
      53             :     static bool IsValidForBgp(uint8_t type);
      54             :     static bool IsValid(uint8_t type);
      55             :     bool operator==(const ErmVpnPrefix &rhs) const;
      56             : 
      57      604476 :     uint8_t type() const { return type_; }
      58      403101 :     const RouteDistinguisher &route_distinguisher() const { return rd_; }
      59      309447 :     Ip4Address router_id() const { return router_id_; }
      60     1137402 :     Ip4Address group() const { return group_; }
      61     1027263 :     Ip4Address source() const { return source_; }
      62       10287 :     void set_route_distinguisher(const RouteDistinguisher &rd) { rd_ = rd; }
      63             : 
      64             :     void BuildProtoPrefix(BgpProtoPrefix *prefix) const;
      65             : 
      66             : private:
      67             :     uint8_t type_;
      68             :     RouteDistinguisher rd_;
      69             :     Ip4Address router_id_;
      70             :     Ip4Address group_;
      71             :     Ip4Address source_;
      72             : };
      73             : 
      74             : class ErmVpnRoute : public BgpRoute {
      75             : public:
      76             :     explicit ErmVpnRoute(const ErmVpnPrefix &prefix);
      77             :     virtual int CompareTo(const Route &rhs) const;
      78             :     virtual std::string ToString() const;
      79             :     virtual std::string ToXmppIdString() const;
      80             :     virtual bool IsValid() const;
      81             : 
      82      509137 :     const ErmVpnPrefix &GetPrefix() const { return prefix_; }
      83             : 
      84             :     virtual KeyPtr GetDBRequestKey() const;
      85             :     virtual void SetKey(const DBRequestKey *reqkey);
      86             :     virtual void BuildProtoPrefix(BgpProtoPrefix *prefix,
      87             :                                   const BgpAttr *attr = NULL,
      88             :                                   uint32_t label = 0,
      89             :                                   uint32_t l3_label = 0) const;
      90             :     virtual void BuildBgpProtoNextHop(std::vector<uint8_t> &nh,
      91             :                                       IpAddress nexthop) const;
      92             : 
      93      242423 :     virtual bool IsLess(const DBEntry &genrhs) const {
      94      242423 :         const ErmVpnRoute &rhs = static_cast<const ErmVpnRoute &>(genrhs);
      95      242423 :         int cmp = CompareTo(rhs);
      96      242418 :         return (cmp < 0);
      97             :     }
      98             : 
      99             :     const std::string GetType() const;
     100             : 
     101             : private:
     102             :     ErmVpnPrefix prefix_;
     103             :     mutable std::string xmpp_id_str_;
     104             : 
     105             :     DISALLOW_COPY_AND_ASSIGN(ErmVpnRoute);
     106             : };
     107             : 
     108             : #endif  // SRC_BGP_ERMVPN_ERMVPN_ROUTE_H_

Generated by: LCOV version 1.14