FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
nat66.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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  * @file
17  * @brief NAT66 global declarations
18  */
19 #ifndef __included_nat66_h__
20 #define __included_nat66_h__
21 
22 #include <vnet/ip/ip.h>
23 #include <vppinfra/bihash_24_8.h>
24 
25 typedef struct
26 {
27  ip6_address_t l_addr;
28  ip6_address_t e_addr;
31 
32 typedef struct
33 {
34  union
35  {
36  struct
37  {
38  ip6_address_t addr;
41  };
42  u64 as_u64[3];
43  };
45 
46 typedef struct
47 {
51 #define NAT66_INTERFACE_FLAG_IS_INSIDE 1
52 #define NAT66_INTERFACE_FLAG_IS_OUTSIDE 2
53 #define nat66_interface_is_inside(i) i->flags & NAT66_INTERFACE_FLAG_IS_INSIDE
54 #define nat66_interface_is_outside(i) i->flags & NAT66_INTERFACE_FLAG_IS_OUTSIDE
55 
56 typedef struct
57 {
58  /** Interface pool */
60  /** Static mapping pool */
62  /** Static mapping by local address lookup table */
63  clib_bihash_24_8_t sm_l;
64  /** Static mapping by external address lookup table */
65  clib_bihash_24_8_t sm_e;
66  /** Session counters */
68  /** node index **/
71 
74 
77 
80 } nat66_main_t;
81 
82 #define nat66_elog(_level, _str) \
83 do \
84  { \
85  nat66_main_t *nm = &nat66_main; \
86  if (PREDICT_FALSE (nm->log_level >= _level)) \
87  { \
88  ELOG_TYPE_DECLARE (e) = \
89  { \
90  .format = "nat66-msg " _str, \
91  .format_args = "", \
92  }; \
93  ELOG_DATA (&vlib_global_main.elog_main, e); \
94  } \
95  } while (0);
96 
97 #define nat66_elog_warn(nat_elog_str) \
98  nat66_elog(0x02, "[warning] " nat_elog_str)
99 
100 
101 extern nat66_main_t nat66_main;
104 
107 int nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add);
109  void *ctx);
111  void *ctx);
113  u32 fib_index, u8 is_local);
114 int nat66_static_mapping_add_del (ip6_address_t * l_addr,
115  ip6_address_t * e_addr, u32 vrf_id,
116  u8 is_add);
117 
118 #endif /* __included_nat66_h__ */
119 
120 /*
121  * fd.io coding-style-patch-verification: ON
122  *
123  * Local Variables:
124  * eval: (c-set-style "gnu")
125  * End:
126  */
int(* nat66_interface_walk_fn_t)(nat66_interface_t *i, void *ctx)
Definition: nat66.h:105
u32 rsvd
Definition: nat66.h:40
u64 as_u64
Definition: bihash_doc.h:63
unsigned long u64
Definition: types.h:89
vlib_simple_counter_main_t in2out_packets
Definition: nat66.h:78
u16 msg_id_base
Definition: nat66.h:75
u32 fib_index
Definition: nat66.h:39
u32 out2in_node_index
Definition: nat66.h:70
nat66_interface_t * interfaces
Interface pool.
Definition: nat66.h:59
clib_bihash_24_8_t sm_e
Static mapping by external address lookup table.
Definition: nat66.h:65
vhost_vring_addr_t addr
Definition: vhost_user.h:111
unsigned char u8
Definition: types.h:56
int nat66_static_mapping_add_del(ip6_address_t *l_addr, ip6_address_t *e_addr, u32 vrf_id, u8 is_add)
Definition: nat66.c:175
void nat66_static_mappings_walk(nat66_static_mapping_walk_fn_t fn, void *ctx)
Definition: nat66.c:254
u32 sw_if_index
Definition: nat66.h:48
unsigned int u32
Definition: types.h:88
A collection of simple counters.
Definition: counter.h:57
vlib_node_registration_t nat66_in2out_node
(constructor) VLIB_REGISTER_NODE (nat66_in2out_node)
Definition: nat66_in2out.c:239
u8 log_level
Definition: nat66.h:76
long ctx[MAX_CONNS]
Definition: main.c:144
unsigned short u16
Definition: types.h:57
vlib_simple_counter_main_t out2in_packets
Definition: nat66.h:79
vlib_node_registration_t nat66_out2in_node
(constructor) VLIB_REGISTER_NODE (nat66_out2in_node)
Definition: nat66_out2in.c:197
nat66_main_t nat66_main
Definition: nat66.c:26
int(* nat66_static_mapping_walk_fn_t)(nat66_static_mapping_t *sm, void *ctx)
Definition: nat66.h:108
nat66_static_mapping_t * nat66_static_mapping_get(ip6_address_t *addr, u32 fib_index, u8 is_local)
Definition: nat66.c:151
bool is_local
Definition: ikev2_types.api:33
void nat66_interfaces_walk(nat66_interface_walk_fn_t fn, void *ctx)
Definition: nat66.c:136
ip6_address_t e_addr
Definition: nat66.h:28
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
clib_bihash_24_8_t sm_l
Static mapping by local address lookup table.
Definition: nat66.h:63
struct _vlib_node_registration vlib_node_registration_t
ip6_address_t l_addr
Definition: nat66.h:27
vlib_combined_counter_main_t session_counters
Session counters.
Definition: nat66.h:67
u32 outside_fib_index
Definition: nat66.h:73
A collection of combined counters.
Definition: counter.h:188
ip6_address_t addr
Definition: nat66.h:38
u32 outside_vrf_id
Definition: nat66.h:72
nat66_static_mapping_t * sm
Static mapping pool.
Definition: nat66.h:61
u32 vrf_id
Definition: nat.api:944
u32 in2out_node_index
node index
Definition: nat66.h:69
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:33
int nat66_interface_add_del(u32 sw_if_index, u8 is_inside, u8 is_add)
Definition: nat66.c:90