LCOV - code coverage report
Current view: top level - bgp - bgp_route.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 14 71.4 %
Date: 2026-06-22 02:21:21 Functions: 6 8 75.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_BGP_ROUTE_H_
       6             : #define SRC_BGP_BGP_ROUTE_H_
       7             : 
       8             : #include <string>
       9             : #include <vector>
      10             : #include <set>
      11             : 
      12             : #include "bgp/bgp_path.h"
      13             : #include "base/address.h"
      14             : #include "route/route.h"
      15             : 
      16             : class BgpAttr;
      17             : struct BgpProtoPrefix;
      18             : class IPeer;
      19             : class BgpTable;
      20             : class ShowRoute;
      21             : class ShowRouteBrief;
      22             : 
      23             : class BgpRoute : public Route {
      24             : public:
      25             :     BgpRoute();
      26             :     ~BgpRoute();
      27             : 
      28       73637 :     bool HasPaths() const { return front() != NULL; }
      29             :     const BgpPath *BestPath() const;
      30             : 
      31             :     void InsertPath(BgpPath *path);
      32             :     void DeletePath(BgpPath *path);
      33             : 
      34             :     const BgpPath *FindPath(BgpPath::PathSource src) const;
      35             :     const BgpPath *FindPath(const IPeer *peer,
      36             :                             bool include_secondary = false) const;
      37             :     BgpPath *FindPath(const IPeer *peer, bool include_secondary = false);
      38             :     BgpPath *FindPath(const IpAddress &nexthop);
      39             :     BgpPath *FindPath(BgpPath::PathSource src, const IPeer *peer,
      40             :                       uint32_t path_id);
      41             :     BgpPath *FindPath(BgpPath::PathSource src, uint32_t path_id);
      42             :     bool RemovePath(BgpPath::PathSource src, const IPeer *peer = NULL,
      43             :                     uint32_t path_id = 0);
      44             :     bool RemovePath(BgpPath::PathSource src, uint32_t path_id);
      45             :     bool RemovePath(const IPeer *peer);
      46             : 
      47             :     bool IsUsable() const;
      48             :     virtual bool IsValid() const;
      49             : 
      50             :     // Check if there's a better path with the same forwarding information.
      51             :     bool DuplicateForwardingPath(const BgpPath *in_path) const;
      52             : 
      53             :     BgpPath *FindSecondaryPath(BgpRoute *src_rt, BgpPath::PathSource src,
      54             :             const IPeer *peer, uint32_t path_id);
      55             :     bool RemoveSecondaryPath(const BgpRoute *src_rt, BgpPath::PathSource src,
      56             :             const IPeer *peer, uint32_t path_id);
      57           1 :     virtual RouteDistinguisher GetRouteDistinguisher() const {
      58           1 :         return RouteDistinguisher::kZeroRd;
      59             :     }
      60             : 
      61             :     void NotifyOrDelete();
      62             :     BgpTable *table();
      63             :     const BgpTable *table() const;
      64             : 
      65      778999 :     virtual std::string ToXmppIdString() const { return ToString(); }
      66             : 
      67           0 :     virtual void BuildProtoPrefix(BgpProtoPrefix *prefix,
      68             :                                   const BgpAttr *attr = NULL,
      69             :                                   uint32_t label = 0,
      70             :                                   uint32_t l3_label = 0) const {
      71           0 :     }
      72           0 :     virtual void BuildBgpProtoNextHop(std::vector<uint8_t> &nh,
      73             :                                       IpAddress nexthop) const {
      74           0 :     }
      75             : 
      76             :     // number of paths
      77             :     size_t count() const;
      78             : 
      79             :     // Fill info needed for introspect
      80             :     void FillRouteInfo(const BgpTable *table, ShowRouteBrief *show_route) const;
      81             :     void FillRouteInfo(const BgpTable *table, ShowRoute *show_route,
      82             :         const std::string &source = "", const std::string &protocol = "") const;
      83             :     uint32_t SubClusterId() const;
      84             :     void AddExtCommunitySubCluster(BgpPath *path);
      85       10627 :     const std::set<std::string> &peer_sources() const { return peer_sources_; }
      86        2762 :     void add_peer_sources(std::string val) { peer_sources_.insert(val); }
      87      154032 :     void del_peer_sources(std::string val) {
      88      154032 :         if (peer_sources_.find(val) != peer_sources_.end()) {
      89        1232 :             peer_sources_.erase(val);
      90             :         };
      91      154006 :     }
      92             : 
      93             : private:
      94             :     std::set<std::string> peer_sources_;
      95             :     DISALLOW_COPY_AND_ASSIGN(BgpRoute);
      96             : };
      97             : 
      98             : #endif  // SRC_BGP_BGP_ROUTE_H_

Generated by: LCOV version 1.14