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_api.c - UDP Ping related APIs to create
18 * and maintain ping flows
19 *------------------------------------------------------------------
22 #include <vnet/vnet.h>
23 #include <vnet/ip/ip.h>
24 #include <ioam/udp-ping/udp_ping.h>
26 #include <vlibapi/api.h>
27 #include <vlibmemory/api.h>
30 /* define message IDs */
31 #include <ioam/udp-ping/udp_ping.api_enum.h>
32 #include <ioam/udp-ping/udp_ping.api_types.h>
34 #define REPLY_MSG_ID_BASE sm->msg_id_base
35 #include <vlibapi/api_helper_macros.h>
38 vl_api_udp_ping_add_del_t_handler (vl_api_udp_ping_add_del_t * mp)
40 ip46_address_t dst, src;
42 udp_ping_main_t *sm = &udp_ping_main;
43 vl_api_udp_ping_add_del_reply_t *rmp;
47 rv = -1; //Not supported
51 clib_memcpy ((void *) &src.ip6, (void *) mp->src_ip_address,
52 sizeof (ip6_address_t));
53 clib_memcpy ((void *) &dst.ip6, (void *) mp->dst_ip_address,
54 sizeof (ip6_address_t));
56 ip46_udp_ping_set_flow (src, dst,
57 ntohs (mp->start_src_port),
58 ntohs (mp->end_src_port),
59 ntohs (mp->start_dst_port),
60 ntohs (mp->end_dst_port),
61 ntohs (mp->interval), mp->fault_det, mp->dis);
65 REPLY_MACRO (VL_API_UDP_PING_ADD_DEL_REPLY);
69 vl_api_udp_ping_export_t_handler (vl_api_udp_ping_export_t * mp)
71 udp_ping_main_t *sm = &udp_ping_main;
73 vl_api_udp_ping_export_reply_t *rmp;
75 (void) udp_ping_flow_create (!mp->enable);
78 REPLY_MACRO (VL_API_UDP_PING_EXPORT_REPLY);
81 #include <ioam/udp-ping/udp_ping.api.c>
83 udp_ping_api_init (vlib_main_t * vm)
85 udp_ping_main_t *sm = &udp_ping_main;
87 /* Ask for a correctly-sized block of API message decode slots */
88 sm->msg_id_base = setup_message_id_table ();
93 VLIB_INIT_FUNCTION (udp_ping_api_init);
96 * fd.io coding-style-patch-verification: ON
99 * eval: (c-set-style "gnu")