LCOV - code coverage report
Current view: top level - plugins/arping - arping_api.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 22 22 100.0 %
Date: 2023-07-05 22:20:52 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *------------------------------------------------------------------
       3             :  * Copyright (c) 2021 Cisco and/or its affiliates.
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at:
       7             :  *
       8             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  *------------------------------------------------------------------
      16             :  */
      17             : 
      18             : #include <vlib/vlib.h>
      19             : #include <vlib/unix/unix.h>
      20             : #include <vlib/pci/pci.h>
      21             : #include <vnet/ethernet/ethernet.h>
      22             : #include <vnet/format_fns.h>
      23             : #include <vnet/ip/ip_types_api.h>
      24             : 
      25             : #include <arping/arping.h>
      26             : 
      27             : #include <vlibapi/api.h>
      28             : #include <vlibmemory/api.h>
      29             : 
      30             : /* define message IDs */
      31             : #include <arping/arping.api_enum.h>
      32             : #include <arping/arping.api_types.h>
      33             : 
      34             : #define REPLY_MSG_ID_BASE (am->msg_id_base)
      35             : #include <vlibapi/api_helper_macros.h>
      36             : 
      37             : static void
      38           8 : vl_api_arping_t_handler (vl_api_arping_t *mp)
      39             : {
      40           8 :   vlib_main_t *vm = vlib_get_main ();
      41           8 :   arping_main_t *am = &arping_main;
      42             :   vl_api_arping_reply_t *rmp;
      43           8 :   arping_args_t args = { 0 };
      44             :   int rv;
      45             : 
      46           8 :   if (mp->sw_if_index != ~0)
      47           8 :     VALIDATE_SW_IF_INDEX (mp);
      48             : 
      49           8 :   ip_address_decode2 (&mp->address, &args.address);
      50           8 :   args.interval = clib_net_to_host_f64 (mp->interval);
      51           8 :   args.repeat = ntohl (mp->repeat);
      52           8 :   args.is_garp = mp->is_garp;
      53           8 :   args.sw_if_index = ntohl (mp->sw_if_index);
      54           8 :   args.silence = 1;
      55             : 
      56           8 :   arping_run_command (vm, &args);
      57           8 :   rv = args.rv;
      58             : 
      59           8 :   BAD_SW_IF_INDEX_LABEL;
      60             : 
      61           8 :   REPLY_MACRO2 (VL_API_ARPING_REPLY,
      62             :                 ({ rmp->reply_count = ntohl (args.reply_count); }));
      63             : }
      64             : 
      65             : /* set tup the API message handling tables */
      66             : #include <arping/arping.api.c>
      67             : clib_error_t *
      68         559 : arping_plugin_api_hookup (vlib_main_t *vm)
      69             : {
      70         559 :   arping_main_t *am = &arping_main;
      71         559 :   api_main_t *vam = vlibapi_get_main ();
      72             : 
      73             :   /* ask for a correctly-sized block of API message decode slots */
      74         559 :   am->msg_id_base = setup_message_id_table ();
      75             : 
      76             :   /* Mark API as mp safe */
      77         559 :   vl_api_set_msg_thread_safe (vam, am->msg_id_base + VL_API_ARPING, 1);
      78             : 
      79         559 :   return 0;
      80             : }
      81             : 
      82             : /*
      83             :  * fd.io coding-style-patch-verification: ON
      84             :  *
      85             :  * Local Variables:
      86             :  * eval: (c-set-style "gnu")
      87             :  * End:
      88             :  */

Generated by: LCOV version 1.14