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

Generated by: LCOV version 1.14