LCOV - code coverage report
Current view: top level - bgp/routing-instance - peer_manager.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 5 5 100.0 %
Date: 2026-11-09 02:10:49 Functions: 6 6 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_ROUTING_INSTANCE_PEER_MANAGER_H_
       7             : #define SRC_BGP_ROUTING_INSTANCE_PEER_MANAGER_H_
       8             : 
       9             : #include <boost/asio/ip/tcp.hpp>
      10             : 
      11             : #include <map>
      12             : #include <string>
      13             : #include <vector>
      14             : 
      15             : #include "bgp/bgp_peer_key.h"
      16             : #include "bgp/ipeer.h"
      17             : #include "io/tcp_session.h"
      18             : 
      19             : class BgpPeer;
      20             : class BgpServer;
      21             : class RoutingInstance;
      22             : class BgpNeighborResp;
      23             : class BgpSandeshContext;
      24             : 
      25             : class PeerManager {
      26             : public:
      27             :     typedef std::multimap<BgpPeerKey, BgpPeer *> BgpPeerKeyMap;
      28             :     typedef std::map<std::string, BgpPeer *> BgpPeerNameMap;
      29             : 
      30        8350 :     explicit PeerManager(RoutingInstance *instance) : instance_(instance) { }
      31       10465 :     virtual ~PeerManager() { }
      32             : 
      33             :     virtual BgpPeer *PeerFind(std::string address) const;
      34             :     virtual BgpPeer *PeerLookup(std::string name) const;
      35             :     virtual BgpPeer *PeerLookup(TcpSession::Endpoint remote_endpoint) const;
      36             :     virtual BgpPeer *PeerLocate(BgpServer *server,
      37             :                                 const BgpNeighborConfig *config);
      38             :     void PeerResurrect(std::string name);
      39             :     BgpPeer *TriggerPeerDeletion(const BgpNeighborConfig *config);
      40             :     virtual void DestroyIPeer(IPeer *ipeer);
      41             :     void ClearAllPeers();
      42             :     void ClearAllInternalPeers();
      43             : 
      44             :     const BgpPeer *NextPeer(const BgpPeerKey &key) const;
      45             :     size_t GetNeighborCount(std::string up_or_down);
      46             : 
      47          34 :     size_t size() { return peers_by_key_.size(); }
      48             :     const std::string &name() const;
      49             :     const RoutingInstance *instance() const { return instance_; }
      50        9567 :     RoutingInstance *instance() { return instance_; }
      51             :     BgpServer *server() const;
      52             : 
      53             :     const BgpPeerKeyMap &peer_map() const { return peers_by_key_; }
      54       17164 :     BgpPeerKeyMap *peer_map_mutable() { return &peers_by_key_; }
      55             : 
      56             : private:
      57             :     friend class PeerManagerTest;
      58             :     friend class BgpServerTest;
      59             : 
      60             :     void InsertPeerByKey(BgpPeerKey key, BgpPeer *peer);
      61             :     void RemovePeerByKey(BgpPeerKey key, BgpPeer *peer);
      62             :     void InsertPeerByName(const std::string name, BgpPeer *peer);
      63             :     void RemovePeerByName(const std::string name, BgpPeer *peer);
      64             : 
      65             :     BgpPeerKeyMap peers_by_key_;
      66             :     BgpPeerNameMap peers_by_name_;
      67             :     RoutingInstance *instance_;
      68             : };
      69             : 
      70             : #endif  // SRC_BGP_ROUTING_INSTANCE_PEER_MANAGER_H_

Generated by: LCOV version 1.14