LCOV - code coverage report
Current view: top level - vnsw/agent/kstate - interface_kstate.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 62 0.0 %
Date: 2026-11-09 02:10:49 Functions: 0 7 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 "kstate.h"
       7             : #include "interface_kstate.h"
       8             : #include <iomanip>
       9             : #include <sstream>
      10             : #include "vr_interface.h"
      11             : 
      12             : using namespace std;
      13             : 
      14           0 : InterfaceKState::InterfaceKState(KInterfaceResp *obj, const std::string &ctx,
      15           0 :                                  vr_interface_req &req, int id) :
      16           0 :                                  KState(ctx, obj) {
      17           0 :     if (id >= 0) {
      18           0 :         req.set_h_op(sandesh_op::GET);
      19           0 :         req.set_vifr_idx(id);
      20             :     } else {
      21           0 :         InitDumpRequest(req);
      22           0 :         req.set_vifr_marker(-1);
      23             :     }
      24           0 : }
      25             : 
      26           0 : void InterfaceKState::InitDumpRequest(vr_interface_req &req) const {
      27           0 :     req.set_h_op(sandesh_op::DUMP);
      28           0 :     req.set_vifr_idx(0);
      29           0 : }
      30             : 
      31           0 : void InterfaceKState::Handler() {
      32           0 :     KInterfaceResp *resp = static_cast<KInterfaceResp *>(response_object_);
      33           0 :     if (resp) {
      34           0 :         if (MoreData()) {
      35             :             /* There are more interfaces in Kernel. We need to query them from
      36             :              * Kernel and send it to Sandesh.
      37             :              */
      38           0 :             SendResponse();
      39           0 :             SendNextRequest();
      40             :         } else {
      41           0 :             resp->set_context(response_context_);
      42           0 :             resp->Response();
      43           0 :             more_context_ = boost::any();
      44             :         }
      45             :     }
      46           0 : }
      47             : 
      48           0 : void InterfaceKState::SendNextRequest() {
      49           0 :     vr_interface_req req;
      50           0 :     InitDumpRequest(req);
      51           0 :     int32_t idx = boost::any_cast<int32_t>(more_context_);
      52           0 :     req.set_vifr_marker(idx);
      53           0 :     EncodeAndSend(req);
      54           0 : }
      55             : 
      56           0 : void InterfaceKState::SendResponse() {
      57             : 
      58           0 :     KInterfaceResp *resp = static_cast<KInterfaceResp *>(response_object_);
      59           0 :     resp->set_context(response_context_);
      60           0 :     resp->set_more(true);
      61           0 :     resp->Response();
      62             : 
      63           0 :     response_object_ = new KInterfaceResp();
      64           0 : }
      65             : 
      66           0 : const string InterfaceKState::TypeToString(int if_type) const {
      67           0 :     unsigned short type = if_type;
      68           0 :     switch(type) {
      69           0 :         case VIF_TYPE_HOST:
      70           0 :             return "HOST";
      71           0 :         case VIF_TYPE_AGENT:
      72           0 :             return "AGENT";
      73           0 :         case VIF_TYPE_PHYSICAL:
      74           0 :             return "PHYSICAL";
      75           0 :         case VIF_TYPE_VIRTUAL:
      76           0 :             return "VIRTUAL";
      77           0 :         default:
      78           0 :             return "INVALID";
      79             :     }
      80             : }
      81             : 
      82           0 : const string InterfaceKState::FlagsToString(int flags) const {
      83           0 :     string str("");;
      84           0 :     if (flags == 0) {
      85           0 :         return "NIL";
      86             :     }
      87           0 :     if (flags & VIF_FLAG_POLICY_ENABLED) {
      88           0 :         str += "POLICY ";
      89             :     }
      90           0 :     if (flags & VIF_FLAG_MIRROR_RX) {
      91           0 :         str += "MIRR_RX ";
      92             :     }
      93           0 :     if (flags & VIF_FLAG_MIRROR_TX) {
      94           0 :         str += "MIRR_TX ";
      95             :     }
      96           0 :     return str;
      97           0 : }

Generated by: LCOV version 1.14