2 *------------------------------------------------------------------
3 * sctp_api.c - vnet sctp-layer API
5 * Copyright (c) 2018 SUSE LLC.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/sctp/sctp.h>
25 #include <vnet/vnet_msg_enum.h>
27 #define vl_typedefs /* define message structures */
28 #include <vnet/vnet_all_api_h.h>
31 #define vl_endianfun /* define message structures */
32 #include <vnet/vnet_all_api_h.h>
35 /* instantiate all the print functions we know about */
36 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
38 #include <vnet/vnet_all_api_h.h>
41 #include <vlibapi/api_helper_macros.h>
43 #define foreach_sctp_api_msg \
44 _(SCTP_ADD_SRC_DST_CONNECTION, sctp_add_src_dst_connection) \
45 _(SCTP_DEL_SRC_DST_CONNECTION, sctp_del_src_dst_connection) \
46 _(SCTP_CONFIG, sctp_config)
49 vl_api_sctp_add_src_dst_connection_t_handler
50 (vl_api_sctp_add_src_dst_connection_t * mp)
52 vlib_main_t *vm = vlib_get_main ();
53 vl_api_sctp_add_src_dst_connection_reply_t *rmp;
57 rv = sctp_sub_connection_add_ip6
59 (ip6_address_t *) mp->src_address, (ip6_address_t *) mp->dst_address);
61 rv = sctp_sub_connection_add_ip4
63 (ip4_address_t *) mp->src_address, (ip4_address_t *) mp->dst_address);
65 REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
69 vl_api_sctp_del_src_dst_connection_t_handler
70 (vl_api_sctp_del_src_dst_connection_t * mp)
72 vl_api_sctp_del_src_dst_connection_reply_t *rmp;
76 rv = sctp_sub_connection_del_ip6
77 ((ip6_address_t *) mp->src_address, (ip6_address_t *) mp->dst_address);
79 rv = sctp_sub_connection_del_ip4
80 ((ip4_address_t *) mp->src_address, (ip4_address_t *) mp->dst_address);
82 REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
86 vl_api_sctp_config_t_handler (vl_api_sctp_config_t * mp)
88 sctp_user_configuration_t config;
89 vl_api_sctp_config_reply_t *rmp;
92 config.never_delay_sack = mp->never_delay_sack;
93 config.never_bundle = mp->never_bundle;
94 rv = sctp_configure (config);
96 REPLY_MACRO (VL_API_SCTP_CONFIG_REPLY);
99 #define vl_msg_name_crc_list
100 #include <vnet/sctp/sctp.api.h>
101 #undef vl_msg_name_crc_list
104 setup_message_id_table (api_main_t * am)
106 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
107 foreach_vl_msg_name_crc_sctp;
111 static clib_error_t *
112 sctp_api_hookup (vlib_main_t * vm)
114 api_main_t *am = &api_main;
117 vl_msg_api_set_handlers(VL_API_##N, #n, \
118 vl_api_##n##_t_handler, \
120 vl_api_##n##_t_endian, \
121 vl_api_##n##_t_print, \
122 sizeof(vl_api_##n##_t), 1);
123 foreach_sctp_api_msg;
127 * Set up the (msg_name, crc, message-id) table
129 setup_message_id_table (am);
134 VLIB_API_INIT_FUNCTION (sctp_api_hookup);
137 sctp_api_reference (void)
142 * fd.io coding-style-patch-verification: ON
145 * eval: (c-set-style "gnu")