LCOV - code coverage report
Current view: top level - ifmap - ifmap_client.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 8 30 26.7 %
Date: 2026-11-09 02:10:49 Functions: 7 24 29.2 %
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 __DB_IFMAP_CLIENT_H__
       7             : #define __DB_IFMAP_CLIENT_H__
       8             : 
       9             : #include <inttypes.h>
      10             : #include <map>
      11             : #include <string>
      12             : #include <vector>
      13             : #include <boost/unordered_set.hpp>
      14             : 
      15             : class IFMapExporter;
      16             : class IFMapState;
      17             : 
      18             : // An XmppPeer that receives IFMap updates from the server component
      19             : class IFMapClient {
      20             : public:
      21             :     typedef std::map<std::string, std::string> VmMap;
      22             :     static const int kIndexInvalid = -1;
      23             : 
      24             :     IFMapClient();
      25             :     virtual ~IFMapClient();
      26             : 
      27             :     virtual const std::string &identifier() const = 0;
      28             :     virtual bool SendUpdate(const std::string &msg) = 0;
      29         892 :     virtual const std::string &name() const { return name_; }
      30           7 :     virtual void SetName(const std::string &name) { name_ = name; }
      31             : 
      32         397 :     int index() const { return index_; }
      33           0 :     uint64_t msgs_sent() const { return msgs_sent_; }
      34           0 :     uint64_t msgs_blocked() const { return msgs_blocked_; }
      35           0 :     uint64_t bytes_sent() const { return bytes_sent_; }
      36           0 :     uint64_t update_nodes_sent() const { return update_nodes_sent_; }
      37           0 :     uint64_t delete_nodes_sent() const { return delete_nodes_sent_; }
      38           0 :     uint64_t update_links_sent() const { return update_links_sent_; }
      39           0 :     uint64_t delete_links_sent() const { return delete_links_sent_; }
      40           0 :     bool send_is_blocked() const { return send_is_blocked_; }
      41           6 :     uint64_t created_at() const { return created_at_; }
      42             : 
      43           0 :     void incr_msgs_sent() { ++msgs_sent_; }
      44           0 :     void incr_msgs_blocked() { ++msgs_blocked_; }
      45           0 :     void incr_bytes_sent(uint64_t bytes) { bytes_sent_ += bytes; }
      46         434 :     void incr_update_nodes_sent() { ++update_nodes_sent_; }
      47           0 :     void incr_delete_nodes_sent() { ++delete_nodes_sent_; }
      48         458 :     void incr_update_links_sent() { ++update_links_sent_; }
      49           0 :     void incr_delete_links_sent() { ++delete_links_sent_; }
      50           0 :     void set_send_is_blocked(bool is_blocked) { send_is_blocked_ = is_blocked; }
      51             : 
      52             :     void Initialize(IFMapExporter *exporter, int index);
      53             : 
      54             :     // Called when the switch register for a specific network.
      55             :     void OnRegister(const std::string &vnet);
      56             : 
      57             :     // Called when the switch unregisters from a virtual network.
      58             :     void OnUnregister(const std::string &vnet);
      59             : 
      60           0 :     void AddVm(const std::string &vm_uuid) {
      61           0 :         vm_map_.insert(make_pair(vm_uuid, vm_uuid));
      62           0 :     }
      63           0 :     void DeleteVm(const std::string &vm_uuid) {
      64           0 :         vm_map_.erase(vm_uuid);
      65           0 :     }
      66           0 :     bool HasAddedVm(const std::string &vm_uuid) {
      67           0 :         return ((vm_map_.count(vm_uuid) == 1) ? true : false);
      68             :     }
      69          14 :     bool HasVms() {
      70          14 :         return (vm_map_.size() != 0);
      71             :     }
      72             :     size_t VmCount() {
      73             :         return vm_map_.size();
      74             :     }
      75             :     // return vm_map_ as a list of strings
      76             :     std::vector<std::string> vm_list() const;
      77             : 
      78             : private:
      79             :     int index_;
      80             :     IFMapExporter *exporter_;
      81             :     uint64_t msgs_sent_;
      82             :     uint64_t msgs_blocked_;
      83             :     uint64_t bytes_sent_;
      84             :     uint64_t update_nodes_sent_;
      85             :     uint64_t delete_nodes_sent_;
      86             :     uint64_t update_links_sent_;
      87             :     uint64_t delete_links_sent_;
      88             :     bool send_is_blocked_;
      89             :     VmMap vm_map_;
      90             :     std::string name_;
      91             :     uint64_t created_at_;
      92             : };
      93             : 
      94             : #endif

Generated by: LCOV version 1.14