bc7a69673ec712a81cfec3b0294667d53a161c9c
[vpp.git] / src / plugins / sctp / sctp_api.c
1 /*
2  *------------------------------------------------------------------
3  * sctp_api.c - sctp-layer API
4  *
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:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *------------------------------------------------------------------
18  */
19
20 #include <vlib/vlib.h>
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23
24 #include <sctp/sctp.h>
25
26 #include <sctp/sctp.api_enum.h>
27 #include <sctp/sctp.api_types.h>
28
29 #define REPLY_MSG_ID_BASE sctp_main.msg_id_base
30 #include <vlibapi/api_helper_macros.h>
31
32 static void
33   vl_api_sctp_add_src_dst_connection_t_handler
34   (vl_api_sctp_add_src_dst_connection_t * mp)
35 {
36   vlib_main_t *vm = vlib_get_main ();
37   vl_api_sctp_add_src_dst_connection_reply_t *rmp;
38   int rv;
39
40   if (mp->is_ipv6)
41     rv = sctp_sub_connection_add_ip6
42       (vm,
43        (ip6_address_t *) mp->src_address, (ip6_address_t *) mp->dst_address);
44   else
45     rv = sctp_sub_connection_add_ip4
46       (vm,
47        (ip4_address_t *) mp->src_address, (ip4_address_t *) mp->dst_address);
48
49   REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
50 }
51
52 static void
53   vl_api_sctp_del_src_dst_connection_t_handler
54   (vl_api_sctp_del_src_dst_connection_t * mp)
55 {
56   vl_api_sctp_del_src_dst_connection_reply_t *rmp;
57   int rv;
58
59   if (mp->is_ipv6)
60     rv = sctp_sub_connection_del_ip6
61       ((ip6_address_t *) mp->src_address, (ip6_address_t *) mp->dst_address);
62   else
63     rv = sctp_sub_connection_del_ip4
64       ((ip4_address_t *) mp->src_address, (ip4_address_t *) mp->dst_address);
65
66   REPLY_MACRO (VL_API_SCTP_ADD_SRC_DST_CONNECTION_REPLY);
67 }
68
69 static void
70 vl_api_sctp_config_t_handler (vl_api_sctp_config_t * mp)
71 {
72   sctp_user_configuration_t config;
73   vl_api_sctp_config_reply_t *rmp;
74   int rv;
75
76   config.never_delay_sack = mp->never_delay_sack;
77   config.never_bundle = mp->never_bundle;
78   rv = sctp_configure (config);
79
80   REPLY_MACRO (VL_API_SCTP_CONFIG_REPLY);
81 }
82
83 #include <sctp/sctp.api.c>
84 clib_error_t *
85 sctp_plugin_api_hookup (vlib_main_t * vm)
86 {
87   /* Ask for a correctly-sized block of API message decode slots */
88   sctp_main.msg_id_base = setup_message_id_table ();
89
90   return 0;
91 }
92
93 /*
94  * fd.io coding-style-patch-verification: ON
95  *
96  * Local Variables:
97  * eval: (c-set-style "gnu")
98  * End:
99  */