LCOV - code coverage report
Current view: top level - vnsw/agent/controller - controller_sandesh.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 168 0.0 %
Date: 2026-11-09 02:10:49 Functions: 0 3 0.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             : #include <cmn/agent_cmn.h>
       7             : #include <cmn/agent_db.h>
       8             : #include <controller/controller_sandesh.h>
       9             : #include <controller/controller_types.h>
      10             : #include <controller/controller_peer.h>
      11             : #include <controller/controller_timer.h>
      12             : #include <controller/controller_init.h>
      13             : #include <controller/controller_ifmap.h>
      14             : #include <controller/controller_dns.h>
      15             : #include <xmpp/xmpp_connection.h>
      16             : #include <xmpp/xmpp_session.h>
      17             : 
      18           0 : static uint8_t ChannelToDscp(XmppChannel *xc) {
      19           0 :     const XmppConnection *conn = xc->connection();
      20           0 :     if (conn) {
      21           0 :         const XmppSession *sess = conn->session();
      22           0 :         if (sess) {
      23           0 :             return sess->GetDscpValue();
      24             :         }
      25             :     }
      26           0 :     return 0;
      27             : }
      28             : 
      29           0 : void AgentXmppConnectionStatusReq::HandleRequest() const {
      30           0 :     Agent *agent = Agent::GetInstance();
      31           0 :     uint8_t count = 0;
      32           0 :     AgentXmppConnectionStatus *resp = new AgentXmppConnectionStatus();
      33           0 :     while (count < MAX_XMPP_SERVERS) {
      34           0 :         if (!agent->controller_ifmap_xmpp_server(count).empty()) {
      35             : 
      36           0 :             AgentXmppData data;
      37           0 :             data.set_controller_ip(agent->controller_ifmap_xmpp_server(count));
      38           0 :             AgentXmppChannel *ch = agent->controller_xmpp_channel(count);
      39           0 :             AgentIfMapXmppChannel *ifmap_ch =agent->ifmap_xmpp_channel(count);
      40             : 
      41           0 :             if (ch) {
      42           0 :                 XmppChannel *xc = ch->GetXmppChannel();
      43           0 :                 if (xc->GetPeerState() == xmps::READY) {
      44           0 :                     data.set_state("Established");
      45             :                 } else {
      46           0 :                     data.set_state("Down");
      47             :                 }
      48             : 
      49           0 :                 data.set_last_ready_time(
      50           0 :                     integerToString(UTCUsecToPTime
      51           0 :                         (agent->controller_xmpp_channel_setup_time(count))));
      52             : 
      53             :                 //End of config
      54           0 :                 ConfigStats config_stats;
      55           0 :                 ControllerEndOfConfigStats eoc_stats = config_stats.end_of_config_stats;
      56           0 :                 if (ifmap_ch) {
      57           0 :                     EndOfConfigTimer *eoc_timer = ifmap_ch->end_of_config_timer();
      58             :                     eoc_stats.set_last_config_receive_time
      59           0 :                         (integerToString(UTCUsecToPTime
      60           0 :                              (eoc_timer->last_config_receive_time_)));
      61             :                     eoc_stats.set_inactivity_detected_time
      62           0 :                         (integerToString(UTCUsecToPTime
      63           0 :                              (eoc_timer->inactivity_detected_time_)));
      64             :                     eoc_stats.set_end_of_config_processed_time
      65           0 :                         (integerToString(UTCUsecToPTime
      66           0 :                              (eoc_timer->end_of_config_processed_time_)));
      67           0 :                     if (eoc_timer->fallback_) {
      68           0 :                         eoc_stats.set_end_of_config_reason("fallback");
      69             :                     } else {
      70           0 :                         eoc_stats.set_end_of_config_reason("inactivity");
      71             :                     }
      72           0 :                     eoc_stats.set_last_start_time(
      73           0 :                         integerToString(UTCUsecToPTime(eoc_timer->
      74             :                                                        last_restart_time_)));
      75           0 :                     eoc_stats.set_running(eoc_timer->running());
      76             :                 } else {
      77           0 :                     eoc_stats.set_last_config_receive_time("");
      78           0 :                     eoc_stats.set_inactivity_detected_time("");
      79           0 :                     eoc_stats.set_end_of_config_processed_time("");
      80           0 :                     eoc_stats.set_end_of_config_reason("");
      81           0 :                     eoc_stats.set_last_start_time("");
      82           0 :                     eoc_stats.set_running(false);
      83             :                 }
      84           0 :                 config_stats.set_end_of_config_stats(eoc_stats);
      85             : 
      86             :                 ConfigCleanupStats config_cleanup_stats =
      87           0 :                     config_stats.config_cleanup_stats;
      88           0 :                 if (ifmap_ch) {
      89             :                     ConfigCleanupTimer *cleanup_timer = ifmap_ch->
      90           0 :                         config_cleanup_timer();
      91             :                     config_cleanup_stats.set_last_start_time
      92           0 :                         (integerToString(UTCUsecToPTime
      93           0 :                              (cleanup_timer->last_restart_time_)));
      94             :                     config_cleanup_stats.set_cleanup_sequence_number
      95           0 :                         (cleanup_timer->sequence_number_);
      96           0 :                     config_cleanup_stats.set_running(cleanup_timer->running());
      97             :                 } else {
      98           0 :                     config_cleanup_stats.set_last_start_time("");
      99           0 :                     config_cleanup_stats.set_cleanup_sequence_number(0);
     100           0 :                     config_cleanup_stats.set_running(false);
     101             :                 }
     102           0 :                 config_stats.set_config_cleanup_stats(config_cleanup_stats);
     103           0 :                 data.set_config_stats(config_stats);
     104             : 
     105             :                 //End of rib
     106           0 :                 ControllerEndOfRibStats eor_stats;
     107           0 :                 ControllerEndOfRibTxStats eor_tx;
     108           0 :                 EndOfRibTxTimer *eor_tx_timer = ch->end_of_rib_tx_timer();
     109             :                 eor_tx.set_end_of_rib_tx_time
     110           0 :                     (integerToString(UTCUsecToPTime
     111           0 :                          (eor_tx_timer->end_of_rib_tx_time_)));
     112             :                 eor_tx.set_last_route_published_time
     113           0 :                     (integerToString(UTCUsecToPTime
     114           0 :                          (eor_tx_timer->last_route_published_time_)));
     115           0 :                 if (eor_tx_timer->fallback_) {
     116           0 :                     eor_tx.set_end_of_rib_reason("fallback");
     117             :                 } else {
     118           0 :                     eor_tx.set_end_of_rib_reason("inactivity");
     119             :                 }
     120             :                 eor_tx.set_last_start_time
     121           0 :                     (integerToString(UTCUsecToPTime
     122           0 :                          (eor_tx_timer->last_restart_time_)));
     123           0 :                 eor_tx.set_running(eor_tx_timer->running());
     124           0 :                 eor_stats.set_tx(eor_tx);
     125             : 
     126           0 :                 ControllerEndOfRibRxStats eor_rx;
     127           0 :                 EndOfRibRxTimer *eor_rx_timer = ch->end_of_rib_rx_timer();
     128             :                 eor_rx.set_end_of_rib_rx_time
     129           0 :                     (integerToString(UTCUsecToPTime
     130           0 :                          (eor_rx_timer->end_of_rib_rx_time_)));
     131             :                 eor_rx.set_last_start_time
     132           0 :                     (integerToString(UTCUsecToPTime
     133           0 :                          (eor_tx_timer->last_restart_time_)));
     134           0 :                 if (eor_rx_timer->fallback_) {
     135           0 :                     eor_rx.set_end_of_rib_reason("fallback");
     136             :                 } else {
     137           0 :                     eor_rx.set_end_of_rib_reason("inactivity");
     138             :                 }
     139           0 :                 eor_rx.set_running(eor_rx_timer->running());
     140           0 :                 eor_stats.set_rx(eor_rx);
     141           0 :                 data.set_end_of_rib_stats(eor_stats);
     142             : 
     143           0 :                 data.set_sequence_number(ch->sequence_number());
     144           0 :                 data.set_peer_name(xc->ToString());
     145           0 :                 data.set_peer_address(xc->PeerAddress());
     146           0 :                 if (agent->mulitcast_builder() == ch) {
     147           0 :                     data.set_mcast_controller("Yes");
     148             :                 } else {
     149           0 :                     data.set_mcast_controller("No");
     150             :                 }
     151             : 
     152           0 :                 if (agent->ifmap_active_xmpp_server().compare
     153           0 :                     (agent->controller_ifmap_xmpp_server(count)) == 0) {
     154           0 :                     data.set_cfg_controller("Yes");
     155             :                 } else {
     156           0 :                     data.set_cfg_controller("No");
     157             :                 }
     158             : 
     159           0 :                 data.set_xmpp_auth_type(xc->AuthType());
     160           0 :                 data.set_last_state(xc->LastStateName());
     161           0 :                 data.set_last_event(xc->LastEvent());
     162           0 :                 data.set_last_state_at(xc->LastStateChangeAt());
     163           0 :                 data.set_flap_count(xc->FlapCount());
     164           0 :                 data.set_flap_time(xc->LastFlap());
     165           0 :                 data.set_dscp(ChannelToDscp(xc));
     166             : 
     167           0 :                 ControllerProtoStats rx_proto_stats;
     168           0 :                 rx_proto_stats.open = xc->rx_open();
     169           0 :                 rx_proto_stats.keepalive = xc->rx_keepalive();
     170           0 :                 rx_proto_stats.update = xc->rx_update();
     171           0 :                 rx_proto_stats.close = xc->rx_close();
     172             : 
     173           0 :                 ControllerProtoStats tx_proto_stats;
     174           0 :                 tx_proto_stats.open = xc->tx_open();
     175           0 :                 tx_proto_stats.keepalive = xc->tx_keepalive();
     176           0 :                 tx_proto_stats.update = xc->tx_update();
     177           0 :                 tx_proto_stats.close = xc->tx_close();
     178             : 
     179           0 :                 data.set_rx_proto_stats(rx_proto_stats);
     180           0 :                 data.set_tx_proto_stats(tx_proto_stats);
     181           0 :             }
     182             : 
     183             :             std::vector<AgentXmppData> &list =
     184           0 :                 const_cast<std::vector<AgentXmppData>&>(resp->get_peer());
     185           0 :             list.push_back(data);
     186           0 :         }
     187           0 :         count++;
     188             :     }
     189           0 :     resp->set_context(context());
     190           0 :     resp->set_more(false);
     191           0 :     resp->Response();
     192           0 : }
     193             : 
     194           0 : void AgentDnsXmppConnectionStatusReq::HandleRequest() const {
     195           0 :     uint8_t dns_count = 0;
     196           0 :     Agent *agent = Agent::GetInstance();
     197             : 
     198           0 :     AgentDnsXmppConnectionStatus *resp = new AgentDnsXmppConnectionStatus();
     199           0 :     while (dns_count < MAX_XMPP_SERVERS) {
     200           0 :         if (!agent->dns_server(dns_count).empty()) {
     201             : 
     202           0 :             AgentXmppDnsData data;
     203           0 :             data.set_dns_controller_ip(agent->dns_server(dns_count));
     204             : 
     205           0 :             AgentDnsXmppChannel *ch = agent->dns_xmpp_channel(dns_count);
     206           0 :             if (ch) {
     207           0 :                 XmppChannel *xc = ch->GetXmppChannel();
     208           0 :                 if (xc->GetPeerState() == xmps::READY) {
     209           0 :                     data.set_state("Established");
     210             :                 } else {
     211           0 :                     data.set_state("Down");
     212             :                 }
     213             : 
     214           0 :                 data.set_peer_name(xc->ToString());
     215           0 :                 data.set_peer_address(xc->PeerAddress());
     216           0 :                 data.set_xmpp_auth_type(xc->AuthType());
     217           0 :                 data.set_last_state(xc->LastStateName());
     218           0 :                 data.set_last_event(xc->LastEvent());
     219           0 :                 data.set_last_state_at(xc->LastStateChangeAt());
     220           0 :                 data.set_flap_count(xc->FlapCount());
     221           0 :                 data.set_flap_time(xc->LastFlap());
     222           0 :                 data.set_dscp(ChannelToDscp(xc));
     223             : 
     224           0 :                 ControllerProtoStats rx_proto_stats;
     225           0 :                 rx_proto_stats.open = xc->rx_open();
     226           0 :                 rx_proto_stats.keepalive = xc->rx_keepalive();
     227           0 :                 rx_proto_stats.update = xc->rx_update();
     228           0 :                 rx_proto_stats.close = xc->rx_close();
     229             : 
     230           0 :                 ControllerProtoStats tx_proto_stats;
     231           0 :                 tx_proto_stats.open = xc->tx_open();
     232           0 :                 tx_proto_stats.keepalive = xc->tx_keepalive();
     233           0 :                 tx_proto_stats.update = xc->tx_update();
     234           0 :                 tx_proto_stats.close = xc->tx_close();
     235             : 
     236           0 :                 data.set_rx_proto_stats(rx_proto_stats);
     237           0 :                 data.set_tx_proto_stats(tx_proto_stats);
     238           0 :             }
     239             : 
     240             :             std::vector<AgentXmppDnsData> &list =
     241           0 :                 const_cast<std::vector<AgentXmppDnsData>&>(resp->get_peer());
     242           0 :             list.push_back(data);
     243           0 :         }
     244           0 :         dns_count++;
     245             :     }
     246           0 :     resp->set_context(context());
     247           0 :     resp->set_more(false);
     248           0 :     resp->Response();
     249           0 : }

Generated by: LCOV version 1.14