FD.io VPP  v21.06-3-gbb25fbf28
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 <vnet/fib/fib_table.h>
24 #include <vppinfra/bihash_24_8.h>
25 
26 typedef struct
27 {
28  ip6_address_t l_addr;
29  ip6_address_t e_addr;
32 
33 typedef struct
34 {
35  union
36  {
37  struct
38  {
39  ip6_address_t addr;
42  };
43  u64 as_u64[3];
44  };
46 
47 typedef struct
48 {
52 
53 #define NAT66_INTERFACE_FLAG_IS_INSIDE 1
54 #define NAT66_INTERFACE_FLAG_IS_OUTSIDE 2
55 #define nat66_interface_is_inside(i) i->flags & NAT66_INTERFACE_FLAG_IS_INSIDE
56 #define nat66_interface_is_outside(i) i->flags & NAT66_INTERFACE_FLAG_IS_OUTSIDE
57 
58 typedef struct
59 {
60  /** Interface pool */
62  /** Static mapping pool */
64  /** Static mapping by local address lookup table */
65  clib_bihash_24_8_t sm_l;
66  /** Static mapping by external address lookup table */
67  clib_bihash_24_8_t sm_e;
68  /** Session counters */
70 
74 
77 
79 
82 } nat66_main_t;
83 
84 #define nat66_elog(_level, _str) \
85 do \
86  { \
87  nat66_main_t *nm = &nat66_main; \
88  if (PREDICT_FALSE (nm->log_level >= _level)) \
89  { \
90  ELOG_TYPE_DECLARE (e) = \
91  { \
92  .format = "nat66-msg " _str, \
93  .format_args = "", \
94  }; \
95  ELOG_DATA (&vlib_global_main.elog_main, e); \
96  } \
97  } while (0);
98 
99 #define nat66_elog_warn(nat_elog_str) \
100  nat66_elog(0x02, "[warning] " nat_elog_str)
101 
102 
103 extern nat66_main_t nat66_main;
106 
109 int nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add);
111  void *ctx);
113  void *ctx);
115  u32 fib_index, u8 is_local);
116 int nat66_static_mapping_add_del (ip6_address_t * l_addr,
117  ip6_address_t * e_addr, u32 vrf_id,
118  u8 is_add);
119 int nat66_plugin_enable (u32 outside_vrf);
120 int nat66_plugin_disable ();
121 
122 #endif /* __included_nat66_h__ */
123 
124 /*
125  * fd.io coding-style-patch-verification: ON
126  *
127  * Local Variables:
128  * eval: (c-set-style "gnu")
129  * End:
130  */
bihash_24_8.h
nat66_static_mapping_t::e_addr
ip6_address_t e_addr
Definition: nat66.h:29
nat66_main_t::enabled
u8 enabled
Definition: nat66.h:78
nat66_main_t::log_level
u8 log_level
Definition: nat66.h:76
nat66_main_t::msg_id_base
u16 msg_id_base
Definition: nat66.h:75
nat66_static_mappings_walk
void nat66_static_mappings_walk(nat66_static_mapping_walk_fn_t fn, void *ctx)
Definition: nat66.c:320
nat66_static_mapping_t::l_addr
ip6_address_t l_addr
Definition: nat66.h:28
nat66_sm_key_t::rsvd
u32 rsvd
Definition: nat66.h:41
fib_table.h
nat66_static_mapping_t::fib_index
u32 fib_index
Definition: nat66.h:30
u16
unsigned short u16
Definition: types.h:57
nat66_static_mapping_walk_fn_t
int(* nat66_static_mapping_walk_fn_t)(nat66_static_mapping_t *sm, void *ctx)
Definition: nat66.h:110
nat66_main_t::session_counters
vlib_combined_counter_main_t session_counters
Session counters.
Definition: nat66.h:69
nat66_main_t::nat_fib_src_hi
fib_source_t nat_fib_src_hi
Definition: nat66.h:73
nat66_sm_key_t
Definition: nat66.h:33
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
nat66_plugin_enable
int nat66_plugin_enable(u32 outside_vrf)
Definition: nat66.c:86
nat66_sm_key_t::addr
ip6_address_t addr
Definition: nat66.h:39
nat66_interface_walk_fn_t
int(* nat66_interface_walk_fn_t)(nat66_interface_t *i, void *ctx)
Definition: nat66.h:107
nat66_main_t::outside_fib_index
u32 outside_fib_index
Definition: nat66.h:72
nat66_plugin_disable
int nat66_plugin_disable()
Definition: nat66.c:108
nat66_interface_add_del
int nat66_interface_add_del(u32 sw_if_index, u8 is_inside, u8 is_add)
Definition: nat66.c:156
nat66_interface_t::flags
u8 flags
Definition: nat66.h:50
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
nat66_main_t
Definition: nat66.h:58
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
nat66_static_mapping_get
nat66_static_mapping_t * nat66_static_mapping_get(ip6_address_t *addr, u32 fib_index, u8 is_local)
Definition: nat66.c:215
nat66_main_t::sm_l
clib_bihash_24_8_t sm_l
Static mapping by local address lookup table.
Definition: nat66.h:65
u64
unsigned long u64
Definition: types.h:89
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
ip.h
u32
unsigned int u32
Definition: types.h:88
nat66_in2out_node
vlib_node_registration_t nat66_in2out_node
(constructor) VLIB_REGISTER_NODE (nat66_in2out_node)
Definition: nat66_in2out.c:239
nat66_static_mapping_add_del
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:239
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
as_u64
u64 as_u64
Definition: bihash_doc.h:63
nat66_main_t::interfaces
nat66_interface_t * interfaces
Interface pool.
Definition: nat66.h:61
nat66_main_t::sm_e
clib_bihash_24_8_t sm_e
Static mapping by external address lookup table.
Definition: nat66.h:67
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
u8
unsigned char u8
Definition: types.h:56
nat66_interfaces_walk
void nat66_interfaces_walk(nat66_interface_walk_fn_t fn, void *ctx)
Definition: nat66.c:202
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
nat66_interface_t
Definition: nat66.h:47
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
nat66_interface_t::sw_if_index
u32 sw_if_index
Definition: nat66.h:49
is_local
bool is_local
Definition: ikev2_types.api:33
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
nat66_static_mapping_t
Definition: nat66.h:26
nat66_main_t::outside_vrf_id
u32 outside_vrf_id
Definition: nat66.h:71
nat66_main_t::sm
nat66_static_mapping_t * sm
Static mapping pool.
Definition: nat66.h:63
nat66_main_t::out2in_packets
vlib_simple_counter_main_t out2in_packets
Definition: nat66.h:81
nat66_main_t::in2out_packets
vlib_simple_counter_main_t in2out_packets
Definition: nat66.h:80
nat66_main
nat66_main_t nat66_main
Definition: nat66.c:25
nat66_sm_key_t::fib_index
u32 fib_index
Definition: nat66.h:40
nat66_out2in_node
vlib_node_registration_t nat66_out2in_node
(constructor) VLIB_REGISTER_NODE (nat66_out2in_node)
Definition: nat66_out2in.c:197