LCOV - code coverage report
Current view: top level - xmpp - xmpp_config.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 25 47 53.2 %
Date: 2026-11-09 02:10:49 Functions: 5 7 71.4 %
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             : #include "xmpp/xmpp_config.h"
       7             : 
       8             : #include "base/logging.h"
       9             : #include <boost/algorithm/string.hpp>
      10             : 
      11             : using namespace boost::asio::ip;
      12             : using namespace boost::property_tree;
      13             : using namespace std;
      14             : 
      15       12020 : XmppChannelConfig::XmppChannelConfig(bool isClient) :
      16       12020 :      ToAddr(""), FromAddr(""), NodeAddr(""), logUVE(false), auth_enabled(false),
      17       12020 :      path_to_server_cert(""), path_to_server_priv_key(""), path_to_ca_cert(""),
      18       12020 :      tcp_hold_time(XmppChannelConfig::kTcpHoldTime), gr_helper_disable(false),
      19       24040 :      xmpp_hold_time(90), dscp_value(0), isClient_(isClient)  {
      20       12020 : }
      21             : 
      22           0 : int XmppChannelConfig::CompareTo(const XmppChannelConfig &rhs) const {
      23             :     int res;
      24             : 
      25           0 :     if (endpoint < rhs.endpoint) return -1;
      26           0 :     if (endpoint > rhs.endpoint) return 1;
      27           0 :     res = name.compare(rhs.name);
      28           0 :     if (res) return res;
      29             : 
      30           0 :     return 0;
      31             : }
      32             : 
      33        5002 : void XmppConfigManager::PeerConfigDiff(PeerDiffObserver obs) const {
      34             :     const XmppConfigData::XmppChannelConfigMap &n_current =
      35        5002 :         current_->neighbors();
      36        5002 :     if (future_.get() == NULL) {
      37           0 :         return;
      38             :     }
      39        5002 :     const XmppConfigData::XmppChannelConfigMap &n_future = future_->neighbors();
      40             : 
      41             :     XmppConfigData::XmppChannelConfigMap::const_iterator icurr =
      42        5002 :         n_current.begin();
      43             :     XmppConfigData::XmppChannelConfigMap::const_iterator inext =
      44        5002 :         n_future.begin();
      45             : 
      46        5002 :     while (icurr != n_current.end() && inext != n_future.end()) {
      47           0 :         if (icurr->first < inext->first) {
      48           0 :             obs(DF_DELETE, icurr->second, NULL);
      49           0 :             ++icurr;
      50           0 :         } else if (icurr->first > inext->first) {
      51           0 :             obs(DF_ADD, NULL, inext->second);
      52           0 :             ++inext;
      53             :         } else {
      54           0 :             int cmp = icurr->second->CompareTo(*inext->second);
      55           0 :             if (cmp != 0) {
      56           0 :                 obs(DF_CHANGE, icurr->second, inext->second);
      57             :             }
      58           0 :             ++icurr;
      59           0 :             ++inext;
      60             :         }
      61             :     }
      62        5011 :     for (; icurr != n_current.end(); ++icurr) {
      63           9 :         obs(DF_DELETE, icurr->second, NULL);
      64             :     }
      65        9995 :     for (; inext != n_future.end(); ++inext) {
      66        4993 :         obs(DF_ADD, NULL, inext->second);
      67             :     }
      68             : }
      69             : 
      70        5002 : void XmppConfigManager::SetFuture(const XmppConfigData *future) {
      71        5002 :     future_.reset(future);
      72        5002 : }
      73             : 
      74        5002 : void XmppConfigManager::AcceptFuture() {
      75        5002 :     current_.reset(future_.release());
      76        5002 : }
      77             : 
      78           0 : void XmppConfigManager::Terminate() {
      79           0 :     current_.reset();
      80           0 :     future_.reset();
      81           0 : }
      82             : 
      83        5038 : XmppConfigManager::XmppConfigManager() : current_(new XmppConfigData()) {
      84        5038 : }

Generated by: LCOV version 1.14