LCOV - code coverage report
Current view: top level - plugins/ioam/udp-ping - udp_ping_test.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 42 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Cisco and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : /*
      16             :  *------------------------------------------------------------------
      17             :  * udp_ping_test.c - test harness for udp ping plugin
      18             :  *------------------------------------------------------------------
      19             :  */
      20             : 
      21             : #include <vat/vat.h>
      22             : #include <vlibapi/api.h>
      23             : #include <vlibmemory/api.h>
      24             : 
      25             : #include <vppinfra/error.h>
      26             : #include <vnet/ip/ip.h>
      27             : #include <vnet/format_fns.h>
      28             : #include <vnet/ip/ip_types_api.h>
      29             : 
      30             : #define __plugin_msg_base udp_ping_test_main.msg_id_base
      31             : #include <vlibapi/vat_helper_macros.h>
      32             : 
      33             : /* Declare message IDs */
      34             : #include <ioam/udp-ping/udp_ping.api_enum.h>
      35             : #include <ioam/udp-ping/udp_ping.api_types.h>
      36             : 
      37             : typedef struct
      38             : {
      39             :   /* API message ID base */
      40             :   u16 msg_id_base;
      41             :   vat_main_t *vat_main;
      42             : } udp_ping_test_main_t;
      43             : 
      44             : udp_ping_test_main_t udp_ping_test_main;
      45             : 
      46             : static int
      47           0 : api_udp_ping_add_del (vat_main_t * vam)
      48             : {
      49           0 :   unformat_input_t *input = vam->input;
      50             :   vl_api_udp_ping_add_del_t *mp;
      51           0 :   int rv = 0;
      52             :   ip46_address_t dst, src;
      53             :   u32 start_src_port, end_src_port;
      54             :   u32 start_dst_port, end_dst_port;
      55             :   u32 interval;
      56           0 :   u8 is_disable = 0;
      57             : 
      58           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
      59             :     {
      60           0 :       if (unformat (input, "src %U", unformat_ip46_address, &src))
      61             :         ;
      62           0 :       else if (unformat (input, "start-src-port %d", &start_src_port))
      63             :         ;
      64           0 :       else if (unformat (input, "end-src-port %d", &end_src_port))
      65             :         ;
      66           0 :       else if (unformat (input, "start-dst-port %d", &start_dst_port))
      67             :         ;
      68           0 :       else if (unformat (input, "end-dst-port %d", &end_dst_port))
      69             :         ;
      70           0 :       else if (unformat (input, "dst %U", unformat_ip46_address, &dst))
      71             :         ;
      72           0 :       else if (unformat (input, "interval %d", &interval))
      73             :         ;
      74           0 :       else if (unformat (input, "disable"))
      75           0 :         is_disable = 1;
      76             :       else
      77           0 :         break;
      78             :     }
      79             : 
      80           0 :   M (UDP_PING_ADD_DEL, mp);
      81             : 
      82           0 :   ip_address_encode (&src, IP46_TYPE_IP6, &mp->src_ip_address);
      83           0 :   ip_address_encode (&dst, IP46_TYPE_IP6, &mp->dst_ip_address);
      84           0 :   mp->start_src_port = (u16) start_src_port;
      85           0 :   mp->end_src_port = (u16) end_src_port;
      86           0 :   mp->start_dst_port = (u16) start_dst_port;
      87           0 :   mp->end_dst_port = (u16) end_dst_port;
      88           0 :   mp->interval = (u16) interval;
      89           0 :   mp->dis = is_disable;
      90             : 
      91           0 :   S (mp);
      92           0 :   W (rv);
      93             : 
      94           0 :   return (rv);
      95             : }
      96             : 
      97             : static int
      98           0 : api_udp_ping_export (vat_main_t * vam)
      99             : {
     100           0 :   unformat_input_t *input = vam->input;
     101             :   vl_api_udp_ping_export_t *mp;
     102           0 :   int rv = 0;
     103           0 :   int is_add = 1;
     104             : 
     105           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     106             :     {
     107           0 :       if (unformat (input, "export"))
     108           0 :         is_add = 1;
     109           0 :       else if (unformat (input, "disable"))
     110           0 :         is_add = 0;
     111             :       else
     112           0 :         break;
     113             :     }
     114             : 
     115           0 :   M (UDP_PING_EXPORT, mp);
     116             : 
     117           0 :   mp->enable = is_add;
     118             : 
     119           0 :   S (mp);
     120           0 :   W (rv);
     121             : 
     122           0 :   return (rv);
     123             : }
     124             : 
     125             : /* Override generated plugin register symbol */
     126             : #define vat_plugin_register udp_ping_vat_plugin_register
     127             : #include <ioam/udp-ping/udp_ping.api_test.c>
     128             : 
     129             : /*
     130             :  * fd.io coding-style-patch-verification: ON
     131             :  *
     132             :  * Local Variables:
     133             :  * eval: (c-set-style "gnu")
     134             :  * End:
     135             :  */

Generated by: LCOV version 1.14