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