LCOV - code coverage report
Current view: top level - vnsw/agent/kstate - kstate_handler.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 165 0.0 %
Date: 2026-11-09 02:10:49 Functions: 0 15 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 "route_kstate.h"
       9             : #include "nh_kstate.h"
      10             : #include "mpls_kstate.h"
      11             : #include "flow_kstate.h"
      12             : #include "mirror_kstate.h"
      13             : #include "vxlan_kstate.h"
      14             : #include "vrf_assign_kstate.h"
      15             : #include "vrf_stats_kstate.h"
      16             : #include "drop_stats_kstate.h"
      17             : #include "forwarding_class_kstate.h"
      18             : #include "qos_config_kstate.h"
      19             : #include "vrf_kstate.h"
      20             : 
      21           0 : void KInterfaceReq::HandleRequest() const {
      22           0 :     vr_interface_req req;
      23           0 :     KInterfaceResp *resp = new KInterfaceResp();
      24           0 :     resp->set_context(context());
      25             : 
      26           0 :     InterfaceKState *kstate = new InterfaceKState(resp, context(), req,
      27           0 :                                                   get_if_id());
      28           0 :     kstate->EncodeAndSend(req);
      29           0 : }
      30             : 
      31           0 : void KRouteReq::HandleRequest() const {
      32           0 :     vr_route_req req;
      33             :     int prefix_size, family_id;
      34           0 :     std::string family = get_family();
      35             : 
      36           0 :     if(family == "inet6") {
      37           0 :         prefix_size = 16;
      38           0 :         family_id = AF_INET6;
      39           0 :     } else if(family == "bridge") {
      40           0 :         prefix_size = 6;
      41           0 :         family_id = AF_BRIDGE;
      42           0 :     } else if(family == "inet") {
      43           0 :         prefix_size = 4;
      44           0 :         family_id = AF_INET;
      45             :     } else {
      46           0 :         std::string msg("Allowed options for family are inet, inet6, bridge");
      47           0 :         ErrResp *resp = new ErrResp();
      48           0 :         resp->set_resp(msg);
      49           0 :         resp->set_context(context());
      50           0 :         resp->Response();
      51           0 :         return;
      52           0 :     }
      53             : 
      54           0 :     std::vector<int8_t> marker(prefix_size, 0);
      55           0 :     if(family_id == AF_BRIDGE) {
      56           0 :         req.set_rtr_mac(marker);
      57             :     } else {
      58             :         // rtr_prefix needs to be initialized
      59           0 :         req.set_rtr_prefix(marker);
      60           0 :         req.set_rtr_marker_plen(0);
      61             :     }
      62           0 :     req.set_rtr_marker(marker);
      63           0 :     KRouteResp *resp = new KRouteResp();
      64           0 :     resp->set_context(context());
      65             : 
      66           0 :     RouteKState *kstate = new RouteKState(resp, context(), req, get_vrf_id(), family_id, sandesh_op::DUMP, prefix_size);
      67           0 :     kstate->EncodeAndSend(req);
      68           0 : }
      69             : 
      70           0 : void KRouteGetReq::HandleRequest() const {
      71           0 :     vr_route_req req;
      72             :     int family_id, prefix_size;
      73           0 :     boost::system::error_code ec;
      74           0 :     IpAddress addr(IpAddress::from_string(get_prefix(), ec));
      75             : 
      76           0 :     if(addr.is_v4()) {
      77           0 :         family_id = AF_INET;
      78           0 :         prefix_size = 4;
      79           0 :         Ip4Address::bytes_type bytes = addr.to_v4().to_bytes();
      80           0 :         std::vector<int8_t> rtr_prefix(bytes.begin(), bytes.end());
      81           0 :         req.set_rtr_prefix(rtr_prefix);
      82           0 :     } else if(addr.is_v6()) {
      83           0 :         family_id = AF_INET6;
      84           0 :         prefix_size = 16;
      85           0 :         Ip6Address::bytes_type bytes = addr.to_v6().to_bytes();
      86           0 :         std::vector<int8_t> rtr_prefix(bytes.begin(), bytes.end());
      87           0 :         req.set_rtr_prefix(rtr_prefix);
      88           0 :     } else {
      89           0 :         std::string msg("Allowed options for family are inet, inet6");
      90           0 :         ErrResp *resp = new ErrResp();
      91           0 :         resp->set_resp(msg);
      92           0 :         resp->set_context(context());
      93           0 :         resp->Response();
      94           0 :         return;
      95           0 :     }
      96           0 :     std::vector<int8_t> marker(prefix_size, 0);
      97             :     // rtr_prefix needs to be initialized
      98           0 :     req.set_rtr_marker(marker);
      99           0 :     req.set_rtr_marker_plen(0);
     100           0 :     req.set_rtr_prefix_len(get_prefix_len());
     101           0 :     KRouteResp *resp = new KRouteResp();
     102           0 :     resp->set_context(context());
     103             : 
     104           0 :     RouteKState *kstate = new RouteKState(resp, context(), req, get_vrf_id(), family_id, sandesh_op::GET, 0);
     105           0 :     kstate->EncodeAndSend(req);
     106           0 : }
     107             : 
     108           0 : void KNHReq::HandleRequest() const {
     109           0 :     vr_nexthop_req req;
     110           0 :     KNHResp *resp = new KNHResp();
     111           0 :     resp->set_context(context());
     112             : 
     113           0 :     NHKState *kstate = new NHKState(resp, context(), req, get_nh_id());
     114           0 :     kstate->EncodeAndSend(req);
     115           0 : }
     116             : 
     117           0 : void KMplsReq::HandleRequest() const {
     118           0 :     vr_mpls_req req;
     119           0 :     KMplsResp *resp = new KMplsResp();
     120           0 :     resp->set_context(context());
     121             : 
     122           0 :     MplsKState *kstate = new MplsKState(resp, context(), req, get_mpls_label());
     123           0 :     kstate->EncodeAndSend(req);
     124           0 : }
     125             : 
     126           0 : void NextKFlowReq::HandleRequest() const {
     127           0 :     FlowKState *task = new FlowKState(Agent::GetInstance(), context(),
     128           0 :                                       get_flow_handle());
     129           0 :     vector<string> tokens;
     130           0 :     boost::split(tokens, get_flow_handle(), boost::is_any_of(" "));
     131           0 :     if (tokens.size() == 2) {
     132           0 :         task->set_evicted_flag(true);
     133             :     }
     134           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     135           0 :     scheduler->Enqueue(task);
     136           0 : }
     137             : 
     138           0 : void KFlowReq::HandleRequest() const {
     139           0 :     FlowKState *task = new FlowKState(Agent::GetInstance(), context(),
     140           0 :                                       get_flow_idx());
     141           0 :     task->set_evicted_flag(get_show_evicted());
     142           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     143           0 :     scheduler->Enqueue(task);
     144           0 : }
     145             : 
     146           0 : void KMirrorReq::HandleRequest() const {
     147           0 :     vr_mirror_req req;
     148           0 :     KMirrorResp *resp = new KMirrorResp();
     149           0 :     resp->set_context(context());
     150             : 
     151           0 :     MirrorKState *kstate = new MirrorKState(resp, context(), req,
     152           0 :                                             get_mirror_id());
     153           0 :     kstate->EncodeAndSend(req);
     154           0 : }
     155             : 
     156           0 : void KVrfAssignReq::HandleRequest() const {
     157           0 :     vr_vrf_assign_req req;
     158           0 :     KVrfAssignResp *resp = new KVrfAssignResp();
     159           0 :     resp->set_context(context());
     160             : 
     161           0 :     VrfAssignKState *kstate = new VrfAssignKState(resp, context(), req,
     162           0 :                                                   get_vif_index());
     163           0 :     kstate->EncodeAndSend(req);
     164           0 : }
     165             : 
     166           0 : void KVrfReq::HandleRequest() const {
     167           0 :     vr_vrf_req req;
     168           0 :     KVrfResp *resp = new KVrfResp();
     169           0 :     resp->set_context(context());
     170             : 
     171           0 :     VrfKState *kstate = new VrfKState(resp, context(), req,
     172           0 :                                           get_vrf_idx());
     173           0 :     kstate->EncodeAndSend(req);
     174           0 : }
     175             : 
     176           0 : void KVrfStatsReq::HandleRequest() const {
     177           0 :     vr_vrf_stats_req req;
     178           0 :     KVrfStatsResp *resp = new KVrfStatsResp();
     179           0 :     resp->set_context(context());
     180             : 
     181           0 :     VrfStatsKState *kstate = new VrfStatsKState(resp, context(), req,
     182           0 :                                                 get_vrf_index());
     183           0 :     kstate->EncodeAndSend(req);
     184           0 : }
     185             : 
     186           0 : void KDropStatsReq::HandleRequest() const {
     187           0 :     vr_drop_stats_req req;
     188           0 :     KDropStatsResp *resp = new KDropStatsResp();
     189           0 :     resp->set_context(context());
     190             : 
     191           0 :     DropStatsKState *kstate = new DropStatsKState(resp, context(), req);
     192           0 :     kstate->EncodeAndSend(req);
     193           0 : }
     194             : 
     195           0 : void KVxLanReq::HandleRequest() const {
     196           0 :     vr_vxlan_req req;
     197           0 :     KVxLanResp *resp = new KVxLanResp();
     198           0 :     resp->set_context(context());
     199             : 
     200           0 :     VxLanKState *kstate = new VxLanKState(resp, context(), req,
     201           0 :                                           get_vxlan_label());
     202           0 :     kstate->EncodeAndSend(req);
     203           0 : }
     204             : 
     205           0 : void KQosConfigReq::HandleRequest() const {
     206             : 
     207           0 :     vr_qos_map_req req;
     208           0 :     KQosConfigResp *resp = new KQosConfigResp();
     209           0 :     resp->set_context(context());
     210             : 
     211           0 :     QosConfigKState *kstate = new QosConfigKState(resp, context(), req,
     212           0 :                                                   get_index());
     213           0 :     kstate->EncodeAndSend(req);
     214           0 : }
     215             : 
     216           0 : void KForwardingClassReq::HandleRequest() const {
     217           0 :     vr_fc_map_req req;
     218           0 :     KForwardingClassResp *resp = new KForwardingClassResp();
     219           0 :     resp->set_context(context());
     220             : 
     221           0 :     ForwardingClassKState *kstate = new ForwardingClassKState(resp, context(),
     222             :                                                   req,
     223           0 :                                                   get_index());
     224           0 :     kstate->EncodeAndSend(req);
     225           0 : }

Generated by: LCOV version 1.14