2 *------------------------------------------------------------------
3 * tcp_api.c - vnet tcp-layer apis
5 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
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/tcp/tcp.h>
25 #include <vnet/ip/ip_types_api.h>
27 #include <vnet/vnet_msg_enum.h>
29 #define vl_typedefs /* define message structures */
30 #include <vnet/vnet_all_api_h.h>
33 #define vl_endianfun /* define message structures */
34 #include <vnet/vnet_all_api_h.h>
37 /* instantiate all the print functions we know about */
38 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
40 #include <vnet/vnet_all_api_h.h>
43 #include <vlibapi/api_helper_macros.h>
45 #define foreach_tcp_api_msg \
46 _(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses)
49 vl_api_tcp_configure_src_addresses_t_handler
50 (vl_api_tcp_configure_src_addresses_t * mp)
52 vlib_main_t *vm = vlib_get_main ();
53 vl_api_tcp_configure_src_addresses_reply_t *rmp;
56 ip46_address_t first_address, last_address;
57 ip46_type_t fa_af, la_af;
59 vrf_id = clib_net_to_host_u32 (mp->vrf_id);
61 fa_af = ip_address_decode (&mp->first_address, &first_address);
62 la_af = ip_address_decode (&mp->last_address, &last_address);
66 rv = VNET_API_ERROR_INVALID_VALUE;
70 if (fa_af == IP46_TYPE_IP6)
71 rv = tcp_configure_v6_source_address_range
72 (vm, &first_address.ip6, &last_address.ip6, vrf_id);
74 rv = tcp_configure_v4_source_address_range
75 (vm, &first_address.ip4, &last_address.ip4, vrf_id);
78 REPLY_MACRO (VL_API_TCP_CONFIGURE_SRC_ADDRESSES_REPLY);
81 #define vl_msg_name_crc_list
82 #include <vnet/tcp/tcp.api.h>
83 #undef vl_msg_name_crc_list
86 setup_message_id_table (api_main_t * am)
88 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
89 foreach_vl_msg_name_crc_tcp;
94 tcp_api_hookup (vlib_main_t * vm)
96 api_main_t *am = vlibapi_get_main ();
99 vl_msg_api_set_handlers(VL_API_##N, #n, \
100 vl_api_##n##_t_handler, \
102 vl_api_##n##_t_endian, \
103 vl_api_##n##_t_print, \
104 sizeof(vl_api_##n##_t), 1);
109 * Set up the (msg_name, crc, message-id) table
111 setup_message_id_table (am);
116 VLIB_API_INIT_FUNCTION (tcp_api_hookup);
119 * fd.io coding-style-patch-verification: ON
122 * eval: (c-set-style "gnu")