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

Generated by: LCOV version 1.14