LCOV - code coverage report
Current view: top level - vnsw/agent/kstate - route_kstate.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 66 0.0 %
Date: 2026-06-18 01:51:13 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             :  */
       4             : 
       5             : #include "kstate.h"
       6             : #include "route_kstate.h"
       7             : #include <base/address.h>
       8             : #include "vr_defs.h"
       9             : 
      10             : using namespace std;
      11             : 
      12           0 : RouteKState::RouteKState(KRouteResp *obj, const std::string &resp_ctx,
      13           0 :                          vr_route_req &req, int id, int family_id, sandesh_op::type op_code, int prefix_size) :
      14           0 :                          KState(resp_ctx, obj), family_id_(family_id), op_code_(op_code), prefix_(prefix_size, 0) {
      15           0 :     InitEncoder(req, id, op_code_);
      16           0 : }
      17             : 
      18           0 : void RouteKState::InitEncoder(vr_route_req &req, int id, sandesh_op::type op_code_) const {
      19           0 :     req.set_rtr_family(family_id_);
      20           0 :     req.set_rtr_vrf_id(id);
      21           0 :     req.set_rtr_rid(0);
      22           0 :     if(op_code_ == sandesh_op::DUMP)
      23           0 :         req.set_rtr_prefix_len(0);
      24           0 :     req.set_h_op(op_code_);
      25           0 : }
      26             : 
      27           0 : void RouteKState::Handler() {
      28           0 :     KRouteResp *resp = static_cast<KRouteResp *>(response_object_);
      29           0 :     if (resp) {
      30           0 :         if (MoreData()) {
      31             :             /* There are more routes in Kernel. We need to query them from
      32             :              * Kernel and send it to Sandesh.
      33             :              */
      34           0 :             SendResponse();
      35           0 :             SendNextRequest();
      36             :         } else {
      37           0 :             resp->set_context(response_context_);
      38           0 :             resp->Response();
      39           0 :             if (!more_context_.empty()) {
      40             :                 RouteContext *rctx =
      41           0 :                     boost::any_cast<RouteContext *>(more_context_);
      42           0 :                 if (rctx) {
      43           0 :                     delete rctx;
      44           0 :                     more_context_ = boost::any();
      45             :                 }
      46             :             }
      47             :         }
      48             :     }
      49           0 : }
      50             : 
      51           0 : void RouteKState::SendNextRequest() {
      52           0 :     vr_route_req req;
      53           0 :     RouteContext *rctx = boost::any_cast<RouteContext *>(more_context_);
      54             : 
      55           0 :     InitEncoder(req, rctx->vrf_id, op_code_);
      56           0 :     if (family_id_ == AF_BRIDGE) {
      57           0 :         req.set_rtr_mac(rctx->marker);
      58             :     } else {
      59             :         // rtr_prefix needs to be initialized
      60           0 :         req.set_rtr_prefix(prefix_);
      61           0 :         req.set_rtr_marker(rctx->marker);
      62           0 :         req.set_rtr_marker_plen(rctx->marker_plen);
      63             :     }
      64           0 :     EncodeAndSend(req);
      65           0 : }
      66             : 
      67           0 : void RouteKState::SendResponse() {
      68             : 
      69           0 :     KRouteResp *resp = static_cast<KRouteResp *>(response_object_);
      70           0 :     resp->set_context(response_context_);
      71           0 :     resp->set_more(true);
      72           0 :     resp->Response();
      73             : 
      74           0 :     response_object_ = new KRouteResp();
      75           0 : }
      76             : 
      77           0 : const string RouteKState::FamilyToString(int nh_family) const {
      78           0 :     unsigned family = nh_family;
      79           0 :     switch(family) {
      80           0 :         case AF_INET:
      81           0 :             return "AF_INET";
      82           0 :         case AF_INET6:
      83           0 :             return "AF_INET6";
      84           0 :         case AF_BRIDGE:
      85           0 :             return "AF_BRIDGE";
      86           0 :         default:
      87           0 :             return "INVALID";
      88             :     }
      89             : }
      90             : 
      91           0 : const string RouteKState::LabelFlagsToString(int flags) const {
      92           0 :     if (flags == 0) {
      93           0 :         return "--NONE--";
      94             :     }
      95             : 
      96           0 :     string str = "";
      97           0 :     if (flags & VR_RT_LABEL_VALID_FLAG) {
      98           0 :         str += "MPLS ";
      99             :     }
     100             : 
     101           0 :     if (flags & VR_RT_ARP_PROXY_FLAG) {
     102           0 :         str += "PROXY-ARP";
     103             :     }
     104           0 :     return str;
     105           0 : }

Generated by: LCOV version 1.14