FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
udp_ping_api.c
Go to the documentation of this file.
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_api.c - UDP Ping related APIs to create
18  * and maintain ping flows
19  *------------------------------------------------------------------
20  */
21 
22 #include <vnet/vnet.h>
23 #include <vnet/ip/ip.h>
24 #include <ioam/udp-ping/udp_ping.h>
25 
26 #include <vlibapi/api.h>
27 #include <vlibmemory/api.h>
28 #include <vnet/format_fns.h>
29 #include <vnet/ip/ip_types_api.h>
30 
31 /* define message IDs */
32 #include <ioam/udp-ping/udp_ping.api_enum.h>
33 #include <ioam/udp-ping/udp_ping.api_types.h>
34 
35 #define REPLY_MSG_ID_BASE sm->msg_id_base
37 
38 static void
40 {
41  ip46_address_t dst, src;
42  int rv = 0;
44  vl_api_udp_ping_add_del_reply_t *rmp;
45 
46  if (clib_net_to_host_u32 (mp->src_ip_address.af) == ADDRESS_IP4)
47  {
48  rv = -1; //Not supported
49  goto ERROROUT;
50  }
53 
55  ntohs (mp->start_src_port),
56  ntohs (mp->end_src_port),
57  ntohs (mp->start_dst_port),
58  ntohs (mp->end_dst_port),
59  ntohs (mp->interval), mp->fault_det, mp->dis);
60  rv = 0; //FIXME
61 
62 ERROROUT:
63  REPLY_MACRO (VL_API_UDP_PING_ADD_DEL_REPLY);
64 }
65 
66 static void
68 {
70  int rv = 0;
71  vl_api_udp_ping_export_reply_t *rmp;
72 
73  (void) udp_ping_flow_create (!mp->enable);
74  rv = 0; //FIXME
75 
76  REPLY_MACRO (VL_API_UDP_PING_EXPORT_REPLY);
77 }
78 
79 #include <ioam/udp-ping/udp_ping.api.c>
80 static clib_error_t *
82 {
84 
85  /* Ask for a correctly-sized block of API message decode slots */
87 
88  return 0;
89 }
90 
92 
93 /*
94  * fd.io coding-style-patch-verification: ON
95  *
96  * Local Variables:
97  * eval: (c-set-style "gnu")
98  * End:
99  */
vl_api_udp_ping_add_del_t::dst_ip_address
vl_api_address_t dst_ip_address
Definition: udp_ping.api:35
api.h
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
udp_ping_main_t::msg_id_base
u16 msg_id_base
API message ID base.
Definition: udp_ping.h:120
udp_ping_flow_create
clib_error_t * udp_ping_flow_create(u8 del)
Definition: udp_ping_export.c:228
vl_api_udp_ping_add_del_t
UDP-Probe Add/Delete request.
Definition: udp_ping.api:31
vl_api_udp_ping_add_del_t::start_dst_port
u16 start_dst_port
Definition: udp_ping.api:38
udp_ping_api_init
static clib_error_t * udp_ping_api_init(vlib_main_t *vm)
Definition: udp_ping_api.c:81
vl_api_udp_ping_add_del_t::end_src_port
u16 end_src_port
Definition: udp_ping.api:37
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
vl_api_udp_ping_export_t
Udp-probe export add/del request.
Definition: udp_ping.api:51
vl_api_udp_ping_add_del_t::interval
u16 interval
Definition: udp_ping.api:40
vl_api_udp_ping_add_del_t::end_dst_port
u16 end_dst_port
Definition: udp_ping.api:39
ip_address_decode
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:172
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
udp_ping_main
udp_ping_main_t udp_ping_main
Definition: udp_ping_node.c:58
udp_ping_main_t
udp-ping main data-structure.
Definition: udp_ping.h:105
vl_api_udp_ping_export_t::enable
bool enable
Definition: udp_ping.api:54
src
vl_api_address_t src
Definition: gre.api:54
vl_api_udp_ping_add_del_t_handler
static void vl_api_udp_ping_add_del_t_handler(vl_api_udp_ping_add_del_t *mp)
Definition: udp_ping_api.c:39
format_fns.h
vl_api_udp_ping_export_t_handler
static void vl_api_udp_ping_export_t_handler(vl_api_udp_ping_export_t *mp)
Definition: udp_ping_api.c:67
ip.h
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
api_helper_macros.h
vlib_main_t
Definition: main.h:102
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vl_api_udp_ping_add_del_t::src_ip_address
vl_api_address_t src_ip_address
Definition: udp_ping.api:34
rv
int __clib_unused rv
Definition: application.c:491
udp_ping.h
ip46_udp_ping_set_flow
void ip46_udp_ping_set_flow(ip46_address_t src, ip46_address_t dst, u16 start_src_port, u16 end_src_port, u16 start_dst_port, u16 end_dst_port, u16 interval, u8 fault_det, u8 is_disable)
Definition: udp_ping_node.c:132
vnet.h
ADDRESS_IP4
@ ADDRESS_IP4
Definition: ip_types.api:22
vl_api_udp_ping_add_del_t::start_src_port
u16 start_src_port
Definition: udp_ping.api:36
ip_types_api.h
vl_api_udp_ping_add_del_t::dis
u8 dis
Definition: udp_ping.api:41
vl_api_udp_ping_add_del_t::fault_det
u8 fault_det
Definition: udp_ping.api:42