2 *------------------------------------------------------------------
3 * sctp_api.c - 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 <vlib/vlib.h>
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip_types_api.h>
25 #include <vnet/format_fns.h>
27 #include <sctp/sctp.h>
29 #include <sctp/sctp.api_enum.h>
30 #include <sctp/sctp.api_types.h>
32 #define REPLY_MSG_ID_BASE sctp_main.msg_id_base
33 #include <vlibapi/api_helper_macros.h>
36 vl_api_sctp_add_src_dst_connection_t_handler
37 (vl_api_sctp_add_src_dst_connection_t * mp)
39 vlib_main_t *vm = vlib_get_main ();
40 vl_api_sctp_add_src_dst_connection_reply_t *rmp;
42 ip46_address_t src, dst;
44 ip_address_decode (&mp->src_address, &src);
45 ip_address_decode (&mp->dst_address, &dst);
47 if (ip46_address_is_ip4 (&src) && ip46_address_is_ip4 (&dst))
48 rv = sctp_sub_connection_add_ip4 (vm, &src.ip4, &dst.ip4);
50 rv = sctp_sub_connection_add_ip6 (vm, &src.ip6, &dst.ip6);
52 REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
56 vl_api_sctp_del_src_dst_connection_t_handler
57 (vl_api_sctp_del_src_dst_connection_t * mp)
59 vl_api_sctp_del_src_dst_connection_reply_t *rmp;
61 ip46_address_t src, dst;
63 ip_address_decode (&mp->src_address, &src);
64 ip_address_decode (&mp->dst_address, &dst);
66 if (ip46_address_is_ip4 (&src) && ip46_address_is_ip4 (&dst))
67 rv = sctp_sub_connection_del_ip4 (&src.ip4, &dst.ip4);
69 rv = sctp_sub_connection_del_ip6 (&src.ip6, &dst.ip6);
71 REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
75 vl_api_sctp_config_t_handler (vl_api_sctp_config_t * mp)
77 sctp_user_configuration_t config;
78 vl_api_sctp_config_reply_t *rmp;
81 config.never_delay_sack = mp->never_delay_sack;
82 config.never_bundle = mp->never_bundle;
83 rv = sctp_configure (config);
85 REPLY_MACRO (VL_API_SCTP_CONFIG_REPLY);
88 #include <sctp/sctp.api.c>
90 sctp_plugin_api_hookup (vlib_main_t * vm)
92 /* Ask for a correctly-sized block of API message decode slots */
93 sctp_main.msg_id_base = setup_message_id_table ();
99 * fd.io coding-style-patch-verification: ON
102 * eval: (c-set-style "gnu")