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

Generated by: LCOV version 1.14