NAT44: client-IP based session affinity for load-balancing (VPP-1297)
[vpp.git] / src / plugins / nat / nat.h
1
2 /*
3  * nat.h - NAT plugin definitions
4  *
5  * Copyright (c) 2016 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 #ifndef __included_nat_h__
19 #define __included_nat_h__
20
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/ethernet/ethernet.h>
24 #include <vnet/ip/icmp46_packet.h>
25 #include <vnet/api_errno.h>
26 #include <vppinfra/bihash_8_8.h>
27 #include <vppinfra/bihash_16_8.h>
28 #include <vppinfra/dlist.h>
29 #include <vppinfra/error.h>
30 #include <vlibapi/api.h>
31 #include <vlib/log.h>
32
33
34 #define SNAT_UDP_TIMEOUT 300
35 #define SNAT_TCP_TRANSITORY_TIMEOUT 240
36 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440
37 #define SNAT_ICMP_TIMEOUT 60
38
39 #define NAT_FQ_NELTS 64
40
41 #define SNAT_FLAG_HAIRPINNING (1 << 0)
42
43 /* Key */
44 typedef struct {
45   union
46   {
47     struct
48     {
49       ip4_address_t addr;
50       u16 port;
51       u16 protocol:3,
52         fib_index:13;
53     };
54     u64 as_u64;
55   };
56 } snat_session_key_t;
57
58 typedef struct {
59   union
60   {
61     struct
62     {
63       ip4_address_t l_addr;
64       ip4_address_t r_addr;
65       u32 proto:8,
66           fib_index:24;
67       u16 l_port;
68       u16 r_port;
69     };
70     u64 as_u64[2];
71   };
72 } nat_ed_ses_key_t;
73
74 typedef struct {
75   union
76   {
77     struct
78     {
79       ip4_address_t ext_host_addr;
80       u16 ext_host_port;
81       u16 out_port;
82     };
83     u64 as_u64;
84   };
85 } snat_det_out_key_t;
86
87 typedef struct {
88   union
89   {
90     struct
91     {
92       ip4_address_t addr;
93       u32 fib_index;
94     };
95     u64 as_u64;
96   };
97 } snat_user_key_t;
98
99
100 #define foreach_snat_protocol \
101   _(UDP, 0, udp, "udp")       \
102   _(TCP, 1, tcp, "tcp")       \
103   _(ICMP, 2, icmp, "icmp")
104
105 typedef enum {
106 #define _(N, i, n, s) SNAT_PROTOCOL_##N = i,
107   foreach_snat_protocol
108 #undef _
109 } snat_protocol_t;
110
111
112 #define foreach_snat_session_state          \
113   _(0, UNKNOWN, "unknown")                 \
114   _(1, UDP_ACTIVE, "udp-active")           \
115   _(2, TCP_SYN_SENT, "tcp-syn-sent")       \
116   _(3, TCP_ESTABLISHED, "tcp-established") \
117   _(4, TCP_FIN_WAIT, "tcp-fin-wait")       \
118   _(5, TCP_CLOSE_WAIT, "tcp-close-wait")   \
119   _(6, TCP_CLOSING, "tcp-closing")         \
120   _(7, TCP_LAST_ACK, "tcp-last-ack")       \
121   _(8, TCP_CLOSED, "tcp-closed")           \
122   _(9, ICMP_ACTIVE, "icmp-active")
123
124 typedef enum {
125 #define _(v, N, s) SNAT_SESSION_##N = v,
126   foreach_snat_session_state
127 #undef _
128 } snat_session_state_t;
129
130 #define NAT44_SES_I2O_FIN 1
131 #define NAT44_SES_O2I_FIN 2
132 #define NAT44_SES_I2O_FIN_ACK 4
133 #define NAT44_SES_O2I_FIN_ACK 8
134 #define NAT44_SES_I2O_SYN 16
135 #define NAT44_SES_O2I_SYN 32
136
137 #define nat44_is_ses_closed(s) s->state == 0xf
138
139 #define SNAT_SESSION_FLAG_STATIC_MAPPING       1
140 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO        2
141 #define SNAT_SESSION_FLAG_LOAD_BALANCING       4
142 #define SNAT_SESSION_FLAG_TWICE_NAT            8
143 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT   16
144 #define SNAT_SESSION_FLAG_FWD_BYPASS           32
145 #define SNAT_SESSION_FLAG_AFFINITY             64
146
147 #define NAT_INTERFACE_FLAG_IS_INSIDE 1
148 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2
149
150 typedef CLIB_PACKED(struct {
151   snat_session_key_t out2in;    /* 0-15 */
152
153   snat_session_key_t in2out;    /* 16-31 */
154
155   u32 flags;                    /* 32-35 */
156
157   /* per-user translations */
158   u32 per_user_index;           /* 36-39 */
159
160   u32 per_user_list_head_index; /* 40-43 */
161
162   /* Last heard timer */
163   f64 last_heard;               /* 44-51 */
164
165   u64 total_bytes;              /* 52-59 */
166
167   u32 total_pkts;               /* 60-63 */
168
169   /* Outside address */
170   u32 outside_address_index;    /* 64-67 */
171
172   /* External host address and port */
173   ip4_address_t ext_host_addr;  /* 68-71 */
174   u16 ext_host_port;            /* 72-73 */
175
176   /* External host address and port after translation */
177   ip4_address_t ext_host_nat_addr; /* 74-77 */
178   u16 ext_host_nat_port;           /* 78-79 */
179
180   /* TCP session state */
181   u8 state;
182   u32 i2o_fin_seq;
183   u32 o2i_fin_seq;
184 }) snat_session_t;
185
186
187 typedef struct {
188   ip4_address_t addr;
189   u32 fib_index;
190   u32 sessions_per_user_list_head_index;
191   u32 nsessions;
192   u32 nstaticsessions;
193 } snat_user_t;
194
195 typedef struct {
196   ip4_address_t addr;
197   u32 fib_index;
198 #define _(N, i, n, s) \
199   u16 busy_##n##_ports; \
200   u16 * busy_##n##_ports_per_thread; \
201   uword * busy_##n##_port_bitmap;
202   foreach_snat_protocol
203 #undef _
204 } snat_address_t;
205
206 typedef struct {
207   u32 fib_index;
208   u32 refcount;
209 } nat_outside_fib_t;
210
211 typedef struct {
212   u16 in_port;
213   snat_det_out_key_t out;
214   u8 state;
215   u32 expire;
216 } snat_det_session_t;
217
218 typedef struct {
219   ip4_address_t in_addr;
220   u8 in_plen;
221   ip4_address_t out_addr;
222   u8 out_plen;
223   u32 sharing_ratio;
224   u16 ports_per_host;
225   u32 ses_num;
226   /* vector of sessions */
227   snat_det_session_t * sessions;
228 } snat_det_map_t;
229
230 typedef struct {
231   ip4_address_t addr;
232   u16 port;
233   u8 probability;
234   u8 prefix;
235   u32 vrf_id;
236   u32 fib_index;
237 } nat44_lb_addr_port_t;
238
239 typedef enum {
240   TWICE_NAT_DISABLED,
241   TWICE_NAT,
242   TWICE_NAT_SELF,
243 } twice_nat_type_t;
244
245 typedef enum {
246   NO_LB_NAT,
247   LB_NAT,
248   AFFINITY_LB_NAT,
249 } lb_nat_type_t;
250
251 typedef struct {
252   ip4_address_t local_addr;
253   ip4_address_t external_addr;
254   u16 local_port;
255   u16 external_port;
256   u8 addr_only;
257   twice_nat_type_t twice_nat;
258   u8 out2in_only;
259   u32 vrf_id;
260   u32 fib_index;
261   snat_protocol_t proto;
262   u32 affinity;
263   u32 *workers;
264   u8 *tag;
265   nat44_lb_addr_port_t *locals;
266   u32 affinity_per_service_list_head_index;
267 } snat_static_mapping_t;
268
269 typedef struct {
270   u32 sw_if_index;
271   u8 flags;
272 } snat_interface_t;
273
274 typedef struct {
275   ip4_address_t l_addr;
276   u16 l_port;
277   u16 e_port;
278   u32 sw_if_index;
279   u32 vrf_id;
280   snat_protocol_t proto;
281   int addr_only;
282   int twice_nat;
283   int is_add;
284   u8 *tag;
285 } snat_static_map_resolve_t;
286
287 typedef struct {
288   /* Main lookup tables */
289   clib_bihash_8_8_t out2in;
290   clib_bihash_8_8_t in2out;
291
292   /* Endpoint dependent sessions lookup tables */
293   clib_bihash_16_8_t out2in_ed;
294   clib_bihash_16_8_t in2out_ed;
295
296   /* Find-a-user => src address lookup */
297   clib_bihash_8_8_t user_hash;
298
299   /* User pool */
300   snat_user_t * users;
301
302   /* Session pool */
303   snat_session_t * sessions;
304
305   /* Pool of doubly-linked list elements */
306   dlist_elt_t * list_pool;
307
308   u32 snat_thread_index;
309 } snat_main_per_thread_data_t;
310
311 struct snat_main_s;
312
313 typedef u32 snat_icmp_match_function_t (struct snat_main_s *sm,
314                                         vlib_node_runtime_t *node,
315                                         u32 thread_index,
316                                         vlib_buffer_t *b0,
317                                         ip4_header_t *ip0,
318                                         u8 *p_proto,
319                                         snat_session_key_t *p_value,
320                                         u8 *p_dont_translate,
321                                         void *d,
322                                         void *e);
323
324 typedef u32 (snat_get_worker_function_t) (ip4_header_t * ip, u32 rx_fib_index);
325
326 typedef int nat_alloc_out_addr_and_port_function_t (snat_address_t * addresses,
327                                                     u32 fib_index,
328                                                     u32 thread_index,
329                                                     snat_session_key_t * k,
330                                                     u32 * address_indexp,
331                                                     u16 port_per_thread,
332                                                     u32 snat_thread_index);
333
334 typedef struct snat_main_s {
335   snat_icmp_match_function_t * icmp_match_in2out_cb;
336   snat_icmp_match_function_t * icmp_match_out2in_cb;
337
338   u32 num_workers;
339   u32 first_worker_index;
340   u32 * workers;
341   snat_get_worker_function_t * worker_in2out_cb;
342   snat_get_worker_function_t * worker_out2in_cb;
343   u16 port_per_thread;
344   u32 num_snat_thread;
345
346   /* Per thread data */
347   snat_main_per_thread_data_t * per_thread_data;
348
349   /* Find a static mapping by local */
350   clib_bihash_8_8_t static_mapping_by_local;
351
352   /* Find a static mapping by external */
353   clib_bihash_8_8_t static_mapping_by_external;
354
355   /* Static mapping pool */
356   snat_static_mapping_t * static_mappings;
357
358   /* Interface pool */
359   snat_interface_t * interfaces;
360   snat_interface_t * output_feature_interfaces;
361
362   /* Vector of outside addresses */
363   snat_address_t * addresses;
364   nat_alloc_out_addr_and_port_function_t *alloc_addr_and_port;
365   u8 psid_offset;
366   u8 psid_length;
367   u16 psid;
368
369   /* vector of outside fibs */
370   nat_outside_fib_t * outside_fibs;
371
372   /* Vector of twice NAT addresses for extenal hosts */
373   snat_address_t * twice_nat_addresses;
374
375   /* sw_if_indices whose intfc addresses should be auto-added */
376   u32 * auto_add_sw_if_indices;
377   u32 * auto_add_sw_if_indices_twice_nat;
378
379   /* vector of interface address static mappings to resolve. */
380   snat_static_map_resolve_t *to_resolve;
381
382   /* Randomize port allocation order */
383   u32 random_seed;
384
385   /* Worker handoff index */
386   u32 fq_in2out_index;
387   u32 fq_in2out_output_index;
388   u32 fq_out2in_index;
389
390   /* in2out and out2in node index */
391   u32 in2out_node_index;
392   u32 in2out_output_node_index;
393   u32 out2in_node_index;
394   u32 error_node_index;
395
396   /* Deterministic NAT */
397   snat_det_map_t * det_maps;
398
399   /* If forwarding is enabled */
400   u8 forwarding_enabled;
401
402   /* Config parameters */
403   u8 static_mapping_only;
404   u8 static_mapping_connection_tracking;
405   u8 deterministic;
406   u8 out2in_dpo;
407   u8 endpoint_dependent;
408   u32 translation_buckets;
409   u32 translation_memory_size;
410   u32 max_translations;
411   u32 user_buckets;
412   u32 user_memory_size;
413   u32 max_translations_per_user;
414   u32 outside_vrf_id;
415   u32 outside_fib_index;
416   u32 inside_vrf_id;
417   u32 inside_fib_index;
418
419   /* values of various timeouts */
420   u32 udp_timeout;
421   u32 tcp_established_timeout;
422   u32 tcp_transitory_timeout;
423   u32 icmp_timeout;
424
425   /* API message ID base */
426   u16 msg_id_base;
427
428   /* log class */
429   vlib_log_class_t log_class;
430
431   /* convenience */
432   vlib_main_t * vlib_main;
433   vnet_main_t * vnet_main;
434   ip4_main_t * ip4_main;
435   ip_lookup_main_t * ip4_lookup_main;
436   api_main_t * api_main;
437 } snat_main_t;
438
439 typedef struct {
440   u32 thread_index;
441   f64 now;
442 } nat44_is_idle_session_ctx_t;
443
444 extern snat_main_t snat_main;
445 extern vlib_node_registration_t snat_in2out_node;
446 extern vlib_node_registration_t snat_in2out_output_node;
447 extern vlib_node_registration_t snat_out2in_node;
448 extern vlib_node_registration_t snat_in2out_fast_node;
449 extern vlib_node_registration_t snat_out2in_fast_node;
450 extern vlib_node_registration_t snat_in2out_worker_handoff_node;
451 extern vlib_node_registration_t snat_in2out_output_worker_handoff_node;
452 extern vlib_node_registration_t snat_out2in_worker_handoff_node;
453 extern vlib_node_registration_t snat_det_in2out_node;
454 extern vlib_node_registration_t snat_det_out2in_node;
455 extern vlib_node_registration_t snat_hairpin_dst_node;
456 extern vlib_node_registration_t snat_hairpin_src_node;
457 extern vlib_node_registration_t nat44_ed_in2out_node;
458 extern vlib_node_registration_t nat44_ed_in2out_output_node;
459 extern vlib_node_registration_t nat44_ed_out2in_node;
460 extern vlib_node_registration_t nat44_ed_hairpin_dst_node;
461 extern vlib_node_registration_t nat44_ed_hairpin_src_node;
462 extern vlib_node_registration_t nat44_ed_in2out_worker_handoff_node;
463 extern vlib_node_registration_t nat44_ed_in2out_output_worker_handoff_node;
464 extern vlib_node_registration_t nat44_ed_out2in_worker_handoff_node;
465
466 void snat_free_outside_address_and_port (snat_address_t * addresses,
467                                          u32 thread_index,
468                                          snat_session_key_t * k);
469
470 int snat_alloc_outside_address_and_port (snat_address_t * addresses,
471                                          u32 fib_index,
472                                          u32 thread_index,
473                                          snat_session_key_t * k,
474                                          u32 * address_indexp,
475                                          u16 port_per_thread,
476                                          u32 snat_thread_index);
477
478 int snat_static_mapping_match (snat_main_t * sm,
479                                snat_session_key_t match,
480                                snat_session_key_t * mapping,
481                                u8 by_external,
482                                u8 *is_addr_only,
483                                twice_nat_type_t *twice_nat,
484                                lb_nat_type_t *lb,
485                                ip4_address_t * ext_host_addr);
486
487 void snat_add_del_addr_to_fib (ip4_address_t * addr,
488                                u8 p_len,
489                                u32 sw_if_index,
490                                int is_add);
491
492 format_function_t format_snat_user;
493 format_function_t format_snat_static_mapping;
494 format_function_t format_snat_static_map_to_resolve;
495 format_function_t format_snat_session;
496 format_function_t format_det_map_ses;
497
498 typedef struct {
499   u32 cached_sw_if_index;
500   u32 cached_ip4_address;
501 } snat_runtime_t;
502
503 /** \brief Check if SNAT session is created from static mapping.
504     @param s SNAT session
505     @return 1 if SNAT session is created from static mapping otherwise 0
506 */
507 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING)
508
509 /** \brief Check if SNAT session for unknown protocol.
510     @param s SNAT session
511     @return 1 if SNAT session for unknown protocol otherwise 0
512 */
513 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO)
514
515 /** \brief Check if NAT session is twice NAT.
516     @param s NAT session
517     @return 1 if NAT session is twice NAT
518 */
519 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT)
520
521 /** \brief Check if NAT session is load-balancing.
522     @param s NAT session
523     @return 1 if NAT session is load-balancing
524 */
525 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING)
526
527 /** \brief Check if NAT session is forwarding bypass.
528     @param s NAT session
529     @return 1 if NAT session is load-balancing
530 */
531 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS)
532
533 /** \brief Check if NAT session is endpoint dependent.
534     @param s NAT session
535     @return 1 if NAT session is endpoint dependent
536 */
537 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT)
538
539 /** \brief Check if NAT session has affinity record.
540     @param s NAT session
541     @return 1 if NAT session has affinity record
542 */
543 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY)
544
545 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE
546 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE
547
548 #define nat_log_err(...) \
549   vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
550 #define nat_log_warn(...) \
551   vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)
552 #define nat_log_notice(...) \
553   vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)
554 #define nat_log_info(...) \
555   vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)
556 #define nat_log_debug(...)\
557   vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)
558
559 /*
560  * Why is this here? Because we don't need to touch this layer to
561  * simply reply to an icmp. We need to change id to a unique
562  * value to NAT an echo request/reply.
563  */
564
565 typedef struct {
566   u16 identifier;
567   u16 sequence;
568 } icmp_echo_header_t;
569
570 typedef struct {
571   u16 src_port, dst_port;
572 } tcp_udp_header_t;
573
574 u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node,
575                            u32 thread_index, vlib_buffer_t *b0,
576                            ip4_header_t *ip0, u8 *p_proto,
577                            snat_session_key_t *p_value,
578                            u8 *p_dont_translate, void *d, void *e);
579 u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node,
580                            u32 thread_index, vlib_buffer_t *b0,
581                            ip4_header_t *ip0, u8 *p_proto,
582                            snat_session_key_t *p_value,
583                            u8 *p_dont_translate, void *d, void *e);
584 u32 icmp_match_in2out_det(snat_main_t *sm, vlib_node_runtime_t *node,
585                           u32 thread_index, vlib_buffer_t *b0,
586                           ip4_header_t *ip0, u8 *p_proto,
587                           snat_session_key_t *p_value,
588                           u8 *p_dont_translate, void *d, void *e);
589 u32 icmp_match_in2out_ed(snat_main_t *sm, vlib_node_runtime_t *node,
590                          u32 thread_index, vlib_buffer_t *b0,
591                          ip4_header_t *ip0, u8 *p_proto,
592                          snat_session_key_t *p_value,
593                          u8 *p_dont_translate, void *d, void *e);
594 u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node,
595                            u32 thread_index, vlib_buffer_t *b0,
596                            ip4_header_t *ip0, u8 *p_proto,
597                            snat_session_key_t *p_value,
598                            u8 *p_dont_translate, void *d, void *e);
599 u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node,
600                            u32 thread_index, vlib_buffer_t *b0,
601                            ip4_header_t *ip0, u8 *p_proto,
602                            snat_session_key_t *p_value,
603                            u8 *p_dont_translate, void *d, void *e);
604 u32 icmp_match_out2in_det(snat_main_t *sm, vlib_node_runtime_t *node,
605                           u32 thread_index, vlib_buffer_t *b0,
606                           ip4_header_t *ip0, u8 *p_proto,
607                           snat_session_key_t *p_value,
608                           u8 *p_dont_translate, void *d, void *e);
609 u32 icmp_match_out2in_ed(snat_main_t *sm, vlib_node_runtime_t *node,
610                          u32 thread_index, vlib_buffer_t *b0,
611                          ip4_header_t *ip0, u8 *p_proto,
612                          snat_session_key_t *p_value,
613                          u8 *p_dont_translate, void *d, void *e);
614 void increment_v4_address(ip4_address_t * a);
615 int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id,
616                      u8 twice_nat);
617 int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm,
618                      u8 twice_nat);
619 void nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add);
620 int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr,
621                             u16 l_port, u16 e_port, u32 vrf_id, int addr_only,
622                             u32 sw_if_index, snat_protocol_t proto, int is_add,
623                             twice_nat_type_t twice_nat, u8 out2in_only,
624                             u8 *tag);
625 clib_error_t * snat_api_init(vlib_main_t * vm, snat_main_t * sm);
626 int snat_set_workers (uword * bitmap);
627 int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del);
628 int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside,
629                                           int is_del);
630 int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del,
631                                u8 twice_nat);
632 uword unformat_snat_protocol(unformat_input_t * input, va_list * args);
633 u8 * format_snat_protocol(u8 * s, va_list * args);
634 int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port,
635                                      snat_protocol_t proto,
636                                      nat44_lb_addr_port_t *locals, u8 is_add,
637                                      twice_nat_type_t twice_nat, u8 out2in_only,
638                                      u8 *tag, u32 affinity);
639 int nat44_del_session (snat_main_t *sm, ip4_address_t *addr, u16 port,
640                        snat_protocol_t proto, u32 vrf_id, int is_in);
641 int nat44_del_ed_session (snat_main_t *sm, ip4_address_t *addr, u16 port,
642                           ip4_address_t *eh_addr, u16 eh_port, u8 proto,
643                           u32 vrf_id, int is_in);
644 void nat_free_session_data (snat_main_t * sm, snat_session_t * s,
645                             u32 thread_index);
646 snat_user_t * nat_user_get_or_create (snat_main_t *sm, ip4_address_t *addr,
647                                       u32 fib_index, u32 thread_index);
648 snat_session_t * nat_session_alloc_or_recycle (snat_main_t *sm, snat_user_t *u,
649                                                u32 thread_index);
650 snat_session_t * nat_ed_session_alloc (snat_main_t *sm, snat_user_t *u,
651                                        u32 thread_index);
652 void nat_set_alloc_addr_and_port_mape (u16 psid, u16 psid_offset,
653                                        u16 psid_length);
654 void nat_set_alloc_addr_and_port_default (void);
655 int nat44_i2o_ed_is_idle_session_cb (clib_bihash_kv_16_8_t *kv, void *arg);
656 int nat44_o2i_ed_is_idle_session_cb (clib_bihash_kv_16_8_t *kv, void *arg);
657 int nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg);
658 int nat44_o2i_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg);
659
660 #endif /* __included_snat_h__ */