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_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 36 : #include <vlibapi/api_helper_macros.h> 37 : 38 : static void 39 0 : vl_api_udp_ping_add_del_t_handler (vl_api_udp_ping_add_del_t * mp) 40 : { 41 : ip46_address_t dst, src; 42 0 : int rv = 0; 43 0 : udp_ping_main_t *sm = &udp_ping_main; 44 : vl_api_udp_ping_add_del_reply_t *rmp; 45 : 46 0 : if (clib_net_to_host_u32 (mp->src_ip_address.af) == ADDRESS_IP4) 47 : { 48 0 : rv = -1; //Not supported 49 0 : goto ERROROUT; 50 : } 51 0 : ip_address_decode (&mp->src_ip_address, &src); 52 0 : ip_address_decode (&mp->dst_ip_address, &dst); 53 : 54 0 : ip46_udp_ping_set_flow (src, dst, 55 0 : ntohs (mp->start_src_port), 56 0 : ntohs (mp->end_src_port), 57 0 : ntohs (mp->start_dst_port), 58 0 : ntohs (mp->end_dst_port), 59 0 : ntohs (mp->interval), mp->fault_det, mp->dis); 60 0 : rv = 0; //FIXME 61 : 62 0 : ERROROUT: 63 0 : REPLY_MACRO (VL_API_UDP_PING_ADD_DEL_REPLY); 64 : } 65 : 66 : static void 67 0 : vl_api_udp_ping_export_t_handler (vl_api_udp_ping_export_t * mp) 68 : { 69 0 : udp_ping_main_t *sm = &udp_ping_main; 70 0 : int rv = 0; 71 : vl_api_udp_ping_export_reply_t *rmp; 72 : 73 0 : (void) udp_ping_flow_create (!mp->enable); 74 0 : rv = 0; //FIXME 75 : 76 0 : REPLY_MACRO (VL_API_UDP_PING_EXPORT_REPLY); 77 : } 78 : 79 : #include <ioam/udp-ping/udp_ping.api.c> 80 : static clib_error_t * 81 575 : udp_ping_api_init (vlib_main_t * vm) 82 : { 83 575 : udp_ping_main_t *sm = &udp_ping_main; 84 : 85 : /* Ask for a correctly-sized block of API message decode slots */ 86 575 : sm->msg_id_base = setup_message_id_table (); 87 : 88 575 : return 0; 89 : } 90 : 91 9215 : VLIB_INIT_FUNCTION (udp_ping_api_init); 92 : 93 : /* 94 : * fd.io coding-style-patch-verification: ON 95 : * 96 : * Local Variables: 97 : * eval: (c-set-style "gnu") 98 : * End: 99 : */