FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
cnat_src_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __CNAT_SRC_POLICY_H__
17 #define __CNAT_SRC_POLICY_H__
18 
19 // #include <vnet/udp/udp.h>
20 #include <cnat/cnat_types.h>
21 #include <cnat/cnat_session.h>
22 #include <cnat/cnat_translation.h>
23 
24 typedef enum
25 {
32 
34 {
38 
40 {
41  /* Source ports bitmap for snat */
43 
44  /* Lock for src_ports access */
47 
48 /* function to use to compute source (IP, port) for a new session to a vip */
51  u32 * rsession_flags, const cnat_translation_t * ct,
53 
54 typedef struct cnat_src_policy_main_
55 {
58 
59  /* Per proto source ports allocator for snat */
62 
64 
67 void cnat_free_port (u16 port, ip_protocol_t iproto);
68 
69 /*
70  * fd.io coding-style-patch-verification: ON
71  *
72  * Local Variables:
73  * eval: (c-set-style "gnu")
74  * End:
75  */
76 
77 #endif
cnat_src_policy_main_t
struct cnat_src_policy_main_ cnat_src_policy_main_t
cnat_sport_proto_t
cnat_sport_proto_t
Definition: cnat_src_policy.h:24
cnat_translation.h
cnat_session.h
clib_bitmap_t
uword clib_bitmap_t
Definition: bitmap.h:50
cnat_node_ctx_
Definition: cnat_types.h:155
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
port
u16 port
Definition: lb_types.api:73
cnat_session_t_
A session represents the memory of a translation.
Definition: cnat_session.h:37
CNAT_SOURCE_ERROR_USE_DEFAULT
@ CNAT_SOURCE_ERROR_USE_DEFAULT
Definition: cnat_src_policy.h:36
CNAT_SOURCE_ERROR_EXHAUSTED_PORTS
@ CNAT_SOURCE_ERROR_EXHAUSTED_PORTS
Definition: cnat_src_policy.h:35
CNAT_SPORT_PROTO_UDP
@ CNAT_SPORT_PROTO_UDP
Definition: cnat_src_policy.h:27
cnat_free_port
void cnat_free_port(u16 port, ip_protocol_t iproto)
Definition: cnat_src_policy.c:97
cnat_types.h
cnat_vip_source_policy_t
cnat_source_policy_errors_t(* cnat_vip_source_policy_t)(vlib_main_t *vm, vlib_buffer_t *b, cnat_session_t *session, u32 *rsession_flags, const cnat_translation_t *ct, cnat_node_ctx_t *ctx)
Definition: cnat_src_policy.h:50
clib_spinlock_s
Definition: lock.h:51
cnat_src_port_allocator_::bmap
clib_bitmap_t * bmap
Definition: cnat_src_policy.h:42
CNAT_N_SPORT_PROTO
@ CNAT_N_SPORT_PROTO
Definition: cnat_src_policy.h:30
cnat_src_policy_main_::src_ports
cnat_src_port_allocator_t * src_ports
Definition: cnat_src_policy.h:60
CNAT_SPORT_PROTO_TCP
@ CNAT_SPORT_PROTO_TCP
Definition: cnat_src_policy.h:26
cnat_src_policy_main_::vip_policy
cnat_vip_source_policy_t vip_policy
Definition: cnat_src_policy.h:56
cnat_src_policy_main
cnat_src_policy_main_t cnat_src_policy_main
Definition: cnat_src_policy.c:22
cnat_src_port_allocator_::lock
clib_spinlock_t lock
Definition: cnat_src_policy.h:45
u32
unsigned int u32
Definition: types.h:88
cnat_src_port_allocator_t
struct cnat_src_port_allocator_ cnat_src_port_allocator_t
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
cnat_src_port_allocator_
Definition: cnat_src_policy.h:39
cnat_src_policy_main_::default_policy
cnat_vip_source_policy_t default_policy
Definition: cnat_src_policy.h:57
CNAT_SPORT_PROTO_ICMP
@ CNAT_SPORT_PROTO_ICMP
Definition: cnat_src_policy.h:28
ip_protocol_t
enum ip_protocol ip_protocol_t
vlib_main_t
Definition: main.h:102
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
CNAT_SPORT_PROTO_ICMP6
@ CNAT_SPORT_PROTO_ICMP6
Definition: cnat_src_policy.h:29
cnat_source_policy_errors_t
enum cnat_source_policy_errors_ cnat_source_policy_errors_t
cnat_source_policy_errors_
cnat_source_policy_errors_
Definition: cnat_src_policy.h:33
cnat_register_vip_src_policy
void cnat_register_vip_src_policy(cnat_vip_source_policy_t fp)
Definition: cnat_src_policy.c:25
cnat_allocate_port
int cnat_allocate_port(u16 *port, ip_protocol_t iproto)
Definition: cnat_src_policy.c:109
cnat_translation_t_
A Translation represents the translation of a VEP to one of a set of real server addresses.
Definition: cnat_translation.h:117
cnat_src_policy_main_
Definition: cnat_src_policy.h:54
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111