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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 *------------------------------------------------------------------
17 * udp_ping_test.c - test harness for udp ping plugin
18 *------------------------------------------------------------------
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
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>
30 #define __plugin_msg_base udp_ping_test_main.msg_id_base
31 #include <vlibapi/vat_helper_macros.h>
33 /* Declare message IDs */
34 #include <ioam/udp-ping/udp_ping.api_enum.h>
35 #include <ioam/udp-ping/udp_ping.api_types.h>
39 /* API message ID base */
42 } udp_ping_test_main_t;
44 udp_ping_test_main_t udp_ping_test_main;
47 api_udp_ping_add_del (vat_main_t * vam)
49 unformat_input_t *input = vam->input;
50 vl_api_udp_ping_add_del_t *mp;
52 ip46_address_t dst, src;
53 u32 start_src_port, end_src_port;
54 u32 start_dst_port, end_dst_port;
58 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
60 if (unformat (input, "src %U", unformat_ip46_address, &src))
62 else if (unformat (input, "start-src-port %d", &start_src_port))
64 else if (unformat (input, "end-src-port %d", &end_src_port))
66 else if (unformat (input, "start-dst-port %d", &start_dst_port))
68 else if (unformat (input, "end-dst-port %d", &end_dst_port))
70 else if (unformat (input, "dst %U", unformat_ip46_address, &dst))
72 else if (unformat (input, "interval %d", &interval))
74 else if (unformat (input, "disable"))
80 M (UDP_PING_ADD_DEL, mp);
82 ip_address_encode (&src, IP46_TYPE_IP6, &mp->src_ip_address);
83 ip_address_encode (&dst, IP46_TYPE_IP6, &mp->dst_ip_address);
84 mp->start_src_port = (u16) start_src_port;
85 mp->end_src_port = (u16) end_src_port;
86 mp->start_dst_port = (u16) start_dst_port;
87 mp->end_dst_port = (u16) end_dst_port;
88 mp->interval = (u16) interval;
98 api_udp_ping_export (vat_main_t * vam)
100 unformat_input_t *input = vam->input;
101 vl_api_udp_ping_export_t *mp;
105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
107 if (unformat (input, "export"))
109 else if (unformat (input, "disable"))
115 M (UDP_PING_EXPORT, mp);
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>
130 * fd.io coding-style-patch-verification: ON
133 * eval: (c-set-style "gnu")