FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
tcp_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * tcp_api.c - vnet tcp-layer apis
4  *
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:
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 <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/tcp/tcp.h>
24 #include <vnet/ip/ip_types_api.h>
25 
26 #include <vnet/format_fns.h>
27 
28 #include <vnet/tcp/tcp.api_enum.h>
29 #include <vnet/tcp/tcp.api_types.h>
30 
31 #define REPLY_MSG_ID_BASE tcp_main.msg_id_base
33 
34 static void
37 {
39  vl_api_tcp_configure_src_addresses_reply_t *rmp;
40  u32 vrf_id;
41  int rv;
42  ip46_address_t first_address, last_address;
43  ip46_type_t fa_af, la_af;
44 
45  vrf_id = clib_net_to_host_u32 (mp->vrf_id);
46 
47  fa_af = ip_address_decode (&mp->first_address, &first_address);
48  la_af = ip_address_decode (&mp->last_address, &last_address);
49 
50  if (fa_af != la_af)
51  {
52  rv = VNET_API_ERROR_INVALID_VALUE;
53  goto error;
54  }
55 
56  if (fa_af == IP46_TYPE_IP6)
58  (vm, &first_address.ip6, &last_address.ip6, vrf_id);
59  else
61  (vm, &first_address.ip4, &last_address.ip4, vrf_id);
62 
63 error:
64  REPLY_MACRO (VL_API_TCP_CONFIGURE_SRC_ADDRESSES_REPLY);
65 }
66 
67 #include <vnet/tcp/tcp.api.c>
68 static clib_error_t *
70 {
71  /*
72  * Set up the (msg_name, crc, message-id) table
73  */
75 
76  return 0;
77 }
78 
80 
81 /*
82  * fd.io coding-style-patch-verification: ON
83  *
84  * Local Variables:
85  * eval: (c-set-style "gnu")
86  * End:
87  */
api.h
tcp_api_hookup
static clib_error_t * tcp_api_hookup(vlib_main_t *vm)
Definition: tcp_api.c:69
vl_api_tcp_configure_src_addresses_t::last_address
vl_api_address_t last_address
Definition: tcp.api:43
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_tcp_configure_src_addresses_t
Configure TCP source addresses, for active-open TCP sessions.
Definition: tcp.api:38
error
Definition: cJSON.c:88
ip_address_decode
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:172
tcp_configure_v4_source_address_range
int tcp_configure_v4_source_address_range(vlib_main_t *vm, ip4_address_t *start, ip4_address_t *end, u32 table_id)
Configure an ipv4 source address range.
Definition: tcp_cli.c:377
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
vl_api_tcp_configure_src_addresses_t_handler
static void vl_api_tcp_configure_src_addresses_t_handler(vl_api_tcp_configure_src_addresses_t *mp)
Definition: tcp_api.c:36
vl_api_tcp_configure_src_addresses_t::first_address
vl_api_address_t first_address
Definition: tcp.api:42
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: tcp_api.c:31
format_fns.h
u32
unsigned int u32
Definition: types.h:88
tcp.h
api_helper_macros.h
vlib_main_t
Definition: main.h:102
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
clib_error_t
Definition: clib_error.h:21
ip46_type_t
ip46_type_t
Definition: ip46_address.h:22
rv
int __clib_unused rv
Definition: application.c:491
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(tcp_api_hookup)
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
vnet.h
ip_types_api.h
tcp_configure_v6_source_address_range
int tcp_configure_v6_source_address_range(vlib_main_t *vm, ip6_address_t *start, ip6_address_t *end, u32 table_id)
Configure an ipv6 source address range.
Definition: tcp_cli.c:464
vl_api_tcp_configure_src_addresses_t::vrf_id
u32 vrf_id
Definition: tcp.api:41