2 *------------------------------------------------------------------
3 * cnat_config.h - configuration database definitions
5 * Copyright (c) 2007-2013 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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
20 #ifndef __CNAT_CONFIG_H__
21 #define __CNAT_CONFIG_H__
23 #include <vlib/vlib.h>
24 #include <vnet/vnet.h>
26 #include "cnat_bulk_port_defs.h"
28 /* default policy value */
29 #define V4_DEF_ICMP_S_TO 60 /*icmp session timeout */
30 #define V4_DEF_UDP_IS_TO 30 /*udp init session timeout */
31 #define V4_DEF_UDP_AS_TO 120 /*udp active session timeout */
32 #define V4_DEF_TCP_IS_TO 120 /*tcp init session timeout */
33 #define V4_DEF_TCP_AS_TO 1800 /*tcp active session timeout, 30 min */
34 #define V4_DEF_TCP_MSS 1460 /*tcp mss */
35 #define V4_DEF_MAX_PORTS 100 /*max port limit per user */
36 #define DEF_RATE_LIMIT PLATFORM_MAX_CORES /* No of packets/sec icmp generated */
37 #define DEF_RATE_LIMIT_CORE 1 /* No of packets/sec icmp generated (per core) */
38 #define RATE_LIMIT_UDP_CORE 1000 /* Max allowed udp crc zero packets/sec/core */
40 #define NAT44_RESERVED_INST_ID 1
41 #define DSLITE_START_ID (NAT44_RESERVED_INST_ID + 1)
42 #define V4_DEF_VRF_MAX_PORTS 0 /*max port limit per vrf user;
43 0 means use the global port limit for user*/
44 /*Hardcoded . TBD - can be made configurable */
46 #define V4_DEF_ENABLE 1 /* feature enable */
47 #define V4_DEF_DISABLE 0 /* feature disable */
49 #define CNAT_DEF_STATIC_PORT_RANGE 1024 /* Default range for static ports */
51 * If TCP MSS is not configured, store the maximum possible value
53 #define V4_TCP_MSS_NOT_CONFIGURED_VALUE 0xffff
55 /* default timeout for fragments in seconds set to 2
56 * in case its not configured
58 #define CNAT_IPV4_FRAG_TIMEOUT_DEF 2
60 /* max db entries to be scaned */
61 #define MAX_DB_ENTRY_PER_SCAN PLATFORM_MAX_DB_ENTRY_PER_SCAN
62 /* max db entries selected per scan */
63 #define MAX_DB_ENTRY_SELECTED_PER_SCAN PLATFORM_MAX_DB_ENTRY_SELECTED_PER_SCAN
65 #define ICMP_MSG_RATE_LIMIT 3 /* rate limit for icmp message */
66 #define V4_CONFIG_DELETE_TO 600 /* timeout for entry to be deleted */
70 extern u16 tcp_initial_setup_timeout;
71 extern u16 tcp_active_timeout;
72 extern u16 udp_init_session_timeout;
73 extern u16 udp_act_session_timeout;
74 extern u16 icmp_session_timeout;
76 extern u8 timeout_dirty_flag;
78 /* mapping refresh direction,
79 * 0 outbound only refresh,
80 * 1 inbound and outbound refresh
82 extern u8 mapping_refresh_both_direction;
85 extern u16 cnat_main_db_max_ports_per_user;
86 extern u32 cnat_main_db_icmp_rate_limit;
87 extern u32 cnat_main_db_icmp_rate_limit_core;
88 extern u32 crc_zero_udp_rate_limit_core;
90 extern u16 cnat_static_port_range;
93 LOG_FORMAT_UNDEFINED =0,
96 LOG_FORMAT_MAX, /* keep this as last */
100 CNAT_CONFIG_DEL_OP = 0,
104 extern u8 ftp_alg_enabled;
105 extern u16 rtsp_alg_port_num;
108 * load balancing debug mode
110 extern u8 lb_debug_enable;
113 * 0 endpoint-independnet filter, good mode
114 * 1 address depedent filter, evil mode
116 extern u8 address_dependent_filtering;
118 extern u16 per_user_icmp_msg_limit;
120 /* vrfmap or portmap holding time
123 extern u16 config_delete_timeout;
126 * Bit map for various configuration in the POLICY KNOB case
128 #define BIDIR_REFRESH_ENABLE 0x01
129 #define BIDIR_REFRESH_DISABLE 0x02
130 #define FTP_ALG_ENABLE 0x04
131 #define FTP_ALG_DISABLE 0x08
132 #define DEFAULT_NFV9_LOGGING_SERVER_ENABLE 0x10
133 #define DEFAULT_NFV9_LOGGING_SERVER_DISABLE 0x20
137 * This structure contains a single VRF map configuration
138 * from a bulk message. This structure is in conformanace
139 * with the following structures defined in cnat_config_api.h
140 * - spp_api_cnat_v4_bulk_vrf_map_t
142 * Any change in the above structures should be propagated here
144 typedef struct _spp_api_cnat_v4_single_vrf_map_req {
154 u16 vrf_policy_enable;
155 #define TCP_MSS_ENABLE 0x0001
156 #define TCP_MSS_DISABLE 0x0002
157 #define NFV9_LOGGING_ENABLE 0x0004
158 #define NFV9_LOGGING_DISABLE 0x0008
159 #define VRF_MAP_DELETE 0x0010
160 #define VRF_MAP_ADD 0x0020
161 #define BULK_ALLOC_CHANGE 0x0040
164 u32 vrf_nfv9_logging_ipv4_address;
165 u16 vrf_nfv9_logging_udp_port;
166 u16 vrf_nfv9_refresh_rate;
167 u16 vrf_nfv9_timeout_rate;
168 u16 vrf_nfv9_path_mtu;
169 #ifndef NO_BULK_LOGGING
170 bulk_alloc_size_t bulk_size;
171 #endif /* NO_BULK_LOGGING */
172 } spp_api_cnat_v4_single_vrf_map_req;
174 typedef struct _spp_api_cnat_v4_single_vrf_map_rc {
179 } spp_api_cnat_v4_single_vrf_map_rc;
182 * Bulk Response for the VRF map request
184 typedef struct _spp_api_cnat_v4_bulk_vrf_map_resp {
189 u32 num_vrfmap_entries;
191 spp_api_cnat_v4_single_vrf_map_rc vrf_map_rc;
193 } spp_api_cnat_v4_bulk_vrf_map_resp;
196 * Bulk Response for the Policy Knob request
198 typedef struct _spp_api_cnat_v4_bulk_policy_knob_resp {
200 u8 bulk_rc; /* Global rc code */
205 u8 udp_init_timeout_rc;
206 u8 udp_act_timeout_rc;
208 u8 tcp_init_timeout_rc;
209 u8 tcp_act_timeout_rc;
212 } spp_api_cnat_v4_bulk_policy_knob_resp;
215 /* PPTP ALG defs and structures */
217 /* dont change the order..
218 maintened at offset mapped to msg ids */
220 typedef struct pptp_ctrl_msg_ctrs_t {
237 }pptp_ctrl_msg_ctrs_t;
239 #define PPTP_INCR(ctr) pptp_cfg.counters.pptp_##ctr++
240 #define PPTP_DECR(ctr) pptp_cfg.counters.pptp_##ctr--
242 typedef struct pptp_counters_t {
244 u64 pptp_ctrl_msg_drops;
245 u64 pptp_active_tunnels;
246 u64 pptp_active_channels;
247 u64 pptp_in2out_gre_drops;
248 u64 pptp_out2in_gre_drops;
249 u64 pptp_in2out_gre_fwds;
250 u64 pptp_out2in_gre_fwds;
251 pptp_ctrl_msg_ctrs_t ctrl_ctrs;
255 #define CNAT_PPTP_ENABLE 1
256 #define CNAT_PPTP_DEF_TIMEOUT 60 /* secs */
258 typedef struct cnat_pptp_config_t {
261 pptp_counters_t counters;
263 } cnat_pptp_config_t;
266 #define CNAT_PPTP_ENABLE_FLAG 0x01
267 #define CNAT_PPTP_TIMEOUT_FLAG 0x02
269 /* pptp config msg resp */
270 typedef struct _spp_api_cnat_v4_config_pptp_alg_resp {
275 } spp_api_cnat_v4_config_pptp_alg_resp_t;
282 /* better to have a group structures rather than individual
283 variables, any change in counters is will automatically
285 pptp_counters_t counters;
286 } pptp_show_counters_resp_t ;
289 extern cnat_pptp_config_t pptp_cfg;
292 /* ========= 6RD declarations =============================== */
294 #define V6RD_ENTRY_DELETE 0x00
295 #define IPV4_TUNNEL_SRC_CONFIG 0x04
296 #define TUNNEL_MTU_CONFIG 0x08
297 #define IPV4_PREFIXMASK_LEN_CONFIG 0x10
298 #define IPV4_SUFFIXMASK_LEN_CONFIG 0x20
299 #define TTL_CONFIG 0x40
300 #define TOS_CONFIG 0x80
301 #define V6RD_IPV6_PREFIX_CONFIG 0x100
302 #define V6RD_RESET_DF_BIT_CONFIG 0x200
303 #define V6RD_UNICAST_ADDR_CONFIG 0x400
304 #define V6RD_REASSEMB_CONFIG 0x800
306 #define TTL_ENABLE 0x1
307 #define TOS_ENABLE 0x2
308 #define RESET_DF_BIT 0x4
309 #define REASSEMBLY_ENABLE 0x8
311 /* ========= 6RD declarations =============================== */
314 * Single Request for XLAT config
316 typedef struct _spp_api_cnat_v4_single_xlat_config_req {
319 * Indicates the xlat instance id - How big will this value be
320 * Can we restrict it between 0..255, that way the APP code
321 * can use an array to store the xlat instances.
325 #define XLAT_ENTRY_DELETE 0x0000
326 #define IPV6_SVI_IF_NUM_CONFIG 0x0001
327 #define IPV4_SVI_IF_NUM_CONFIG 0x0002
328 #define IPV4_TO_IPV6_TCP_MSS_CONFIG 0x0004
329 #define IPV6_TO_IPV4_TCP_MSS_CONFIG 0x0008
330 #define IPV6_PREFIX_CONFIG 0x0010
331 #define IPV6_UBIT_ON_CONFIG 0x0020
332 #define IPV6_NON_TRANSLATABLE_PREFIX_MAP_CONFIG 0x0040
333 #define IPV4_TOS_SETTING_CONFIG 0x0080
334 #define IPV6_TOS_SETTING_CONFIG 0x0100
335 #define IPV4_DFBIT_CLEAR_CONFIG 0x0200
336 #define ICMPV6_PTB_MTU_SET_CONFIG 0x0400
337 #define IPV6_NON_TRANSLATABLE_PREFIX_MAP_ALG_CONFIG 0x0800
338 #define CPE_V4_PREFIX_CONFIG 0x1000 /* for map-t */
339 #define CPE_V6_PREFIX_CONFIG 0x2000 /* for map-t */
340 #define EXTERNAL_V6_PREFIX_CONFIG 0x4000 /* for map-t */
341 #define PORT_SHARING_RATIO_CONFIG 0x8000 /* for map-t */
342 #define CONSECUTIVE_PORTS_CONFIG 0x10000 /* for map-t */
344 u32 xlat_config_fields_enable;
347 * If numbers of the IPv6 and IPv4 SVI interfaces
353 * TCP MSS values for the 2 XLAT directions
355 u16 v4_to_v6_tcp_mss;
356 u16 v6_to_v4_tcp_mss;
364 * XLAT IPv6 prefix mask
366 u8 v6_prefix_mask_len;
369 * Set to non-zero if UBITs are reserved
371 #define UBITS_ON 0x01
372 #define IPV4_DF_BIT_CLEAR 0x02
373 #define ICMPV6_MTU_SET 0x04
374 #define IPV4_TOS_SET_ENABLED 0x08
375 #define IPV6_TC_SET_ENABLED 0x10
377 u8 feature_enable_bits;
379 u8 v4_prefix_mask_len;
381 #define IPV6_NON_TRANSLATABLE_PREFIX_MAP_ALG_HASH 0x1
382 #define IPV6_NON_TRANSLATABLE_PREFIX_MAP_ALG_TTL 0x2
383 #define IPV6_NON_TRANSLATABLE_PREFIX_MAP_ALG_RANDOM 0x3
384 u8 non_translatable_v6_prefix_v4_map_prefix_alg;
397 * MAP-T/MAP-E specific parameters
401 u32 cpe_domain_v6_prefix[4];
402 u8 cpe_domain_v6_prefix_len;
404 u32 cpe_domain_v4_prefix;
405 u8 cpe_domain_v4_prefix_len;
407 u32 external_domain_v6_prefix[4];
408 u8 external_domain_v6_prefix_len;
410 u8 port_sharing_ratio_bits;
411 u8 consecutive_ports_bits;
413 } spp_api_cnat_v4_single_xlat_config_req;
416 * Single Response for the xlat config request
418 typedef struct _spp_api_cnat_v4_single_xlat_config_resp {
421 u8 v4_to_v6_tcp_mss_rc;
422 u8 v6_to_v4_tcp_mss_rc;
429 u8 non_translatable_v6_prefix_v4_map_alg_rc;
430 u8 ipv4_dfbit_clear_rc;
431 u8 icmpv6_ptb_mtu_set_rc;
438 } spp_api_cnat_v4_single_xlat_config_resp;
441 * Bulk Response for the xlat config request
443 typedef struct _spp_api_cnat_v4_bulk_xlat_config_resp {
449 u32 num_xlat_entries;
451 spp_api_cnat_v4_single_xlat_config_resp xlat_config_resp;
453 } spp_api_cnat_v4_bulk_xlat_config_resp;
455 typedef struct _spp_api_v6rd_v4_single_v6rd_config_resp {
461 u8 ipv4masklen_prefix_rc;
462 u8 ipv4masklen_suffix_rc;
472 } spp_api_v6rd_v4_single_v6rd_config_resp_t;
474 typedef struct _spp_api_v6rd_v4_bulk_v6rd_config_resp {
478 u32 num_v6rd_entries;
479 spp_api_v6rd_v4_single_v6rd_config_resp_t v6rd_config_resp[0];
480 } spp_api_v6rd_v4_bulk_v6rd_config_resp_t;
483 * Single Request for MAPE config
485 typedef struct _spp_api_mape_single_config_req {
488 * Indicates the mape instance id - How big will this value be
489 * Can we restrict it between 0..255, that way the APP code
490 * can use an array to store the xlat instances.
494 #define MAPE_ENTRY_DELETE 0x0000
495 #define MAPE_IPV4_SVI_IF_NUM_CONFIG 0x0001
496 #define MAPE_IPV6_SVI_IF_NUM_CONFIG 0x0002
497 #define MAPE_IPV4_TO_IPV6_TCP_MSS_CONFIG 0x0004
498 #define MAPE_IPV6_TO_IPV4_TCP_MSS_CONFIG 0x0008
499 #define MAPE_CPE_V4_PREFIX_CONFIG 0x0010
500 #define MAPE_CPE_V6_PREFIX_CONFIG 0x0020
501 #define MAPE_PORT_SHARING_RATIO_CONFIG 0x0040
502 #define MAPE_CONSECUTIVE_PORTS_CONFIG 0x0080
503 #define MAPE_PATH_MTU 0x0100
504 #define MAPE_TUNNEL_ENDPOINT_V6_CONFIG 0x0200
506 u32 mape_config_fields_enable;
509 * If numbers of the IPv6 and IPv4 SVI interfaces
515 * TCP MSS values for the 2 XLAT directions
517 u16 v4_to_v6_tcp_mss;
518 u16 v6_to_v4_tcp_mss;
526 * CPE IPv6 prefix and mask len.
528 u32 cpe_domain_v6_prefix[4];
529 u8 cpe_domain_v6_prefix_len;
532 * CPE IPv4 prefix and mask len.
534 u32 cpe_domain_v4_prefix;
535 u8 cpe_domain_v4_prefix_len;
538 * BR IPv6 tunnel end point V6 prefix and mask len.
540 u32 aftr_tunnel_endpoint_address_v6[4];
541 u8 aftr_tunnel_endpoint_address_v6_len;
544 * BR IPv6 tunnel end point V6 prefix and mask len.
546 u8 port_sharing_ratio_bits;
547 u8 consecutive_ports_bits;
549 } spp_api_mape_single_config_req;
553 * Single Response for the mape config response
555 typedef struct _spp_api_mape_single_config_resp {
558 u8 v4_to_v6_tcp_mss_rc;
559 u8 v6_to_v4_tcp_mss_rc;
564 u8 tunnel_endpoint_prefix_rc;
565 u8 port_sharing_ratio_rc;
566 u8 port_contiguous_rc;
568 } spp_api_mape_single_config_resp;
571 * Bulk Response for the mape config request
573 typedef struct _spp_api_mape_bulk_config_resp {
577 u32 num_mape_entries;
578 spp_api_mape_single_config_resp mape_config_resp;
579 } spp_api_mape_bulk_config_resp;
582 #endif /* __CNAT_CONFIG_H__ */