/* * Copyright (c) 2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ option version = "5.2.0"; import "vnet/ip/ip_types.api"; import "vnet/interface_types.api"; import "plugins/nat/nat_types.api"; /** * @file nat44.api * @brief VPP control-plane API messages. * * This file defines VPP control-plane API messages which are generally * called through a shared memory interface. */ enum nat44_config_flags : u8 { NAT44_IS_ENDPOINT_INDEPENDENT = 0x00, NAT44_IS_ENDPOINT_DEPENDENT = 0x01, NAT44_IS_STATIC_MAPPING_ONLY = 0x02, NAT44_IS_CONNECTION_TRACKING = 0x04, NAT44_IS_OUT2IN_DPO = 0x08, }; /** \brief Enable/disable NAT44 plugin @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param inside_vrf - inside vrf id @param outside_vrf - outside vrf id @param users - maximum number of users per thread (NAT44_IS_ENDPOINT_INDEPENDENT) @param user_memory - overwrite hash allocation parameter (NAT44_IS_ENDPOINT_INDEPENDENT) @param sessions - maximum number of sessions per thread @param session_memory - overwrite hash allocation parameter @param user_sessions - maximum number of sessions per user (NAT44_IS_ENDPOINT_INDEPENDENT) @param enable - true if enable, false if disable @param flags - flag NAT44_IS_ENDPOINT_INDEPENDENT, NAT44_IS_ENDPOINT_DEPENDENT, NAT44_IS_STATIC_MAPPING_ONLY, NAT44_IS_CONNECTION_TRACKING, NAT44_IS_OUT2IN_DPO */ autoreply define nat44_plugin_enable_disable { u32 client_index; u32 context; u32 inside_vrf; u32 outside_vrf; u32 users; u32 user_memory; u32 sessions; u32 session_memory; u32 user_sessions; bool enable; vl_api_nat44_config_flags_t flags; }; /** \brief Control ping from client to api server request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ define nat_control_ping { option deprecated; u32 client_index; u32 context; }; /** \brief Control ping from the client to the server response @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param retval - return code for the request @param vpe_pid - the pid of the vpe, returned by the server */ define nat_control_ping_reply { option deprecated; u32 context; i32 retval; u32 client_index; u32 vpe_pid; }; /** \brief Show NAT plugin startup config @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ define nat_show_config { option deprecated; u32 client_index; u32 context; }; /** \brief DEPRECATED: Show NAT plugin startup config reply @param context - sender context, to match reply w/ request @param retval - return code for the request @param static_mapping_only - if true dynamic translations disabled @param static_mapping_connection_tracking - if true create session data @param deterministic - if true deterministic mapping @param endpoint_dependent - if true endpoint-dependent mode @param out2in_dpo - if true out2in dpo mode @param dslite_ce - if true DS-Lite is CE/B4 element, if false AFTR elemet @param translation_buckets - number of translation hash buckets @param translation_memory_size - translation hash memory size @param user_buckets - number of user hash buckets @param user_memory_size - user hash memory size @param max_translations_per_user - maximum number of translations per user @param outside_vrf_id - outside VRF id @param inside_vrf_id - default inside VRF id @param nat64_bib_buckets - number of NAT64 BIB hash buckets @param nat64_bib_memory_size - memory size of NAT64 BIB hash @param nat64_st_buckets - number of NAT64 session table hash buckets @param nat64_st_memory_size - memory size of NAT64 session table hash */ define nat_show_config_reply { option deprecated; u32 context; i32 retval; bool static_mapping_only; bool static_mapping_connection_tracking; bool deterministic; bool endpoint_dependent; bool out2in_dpo; bool dslite_ce; u32 translation_buckets; u32 translation_memory_size; u32 user_buckets; u64 user_memory_size; u32 max_translations_per_user; u32 outside_vrf_id; u32 inside_vrf_id; u32 nat64_bib_buckets; u64 nat64_bib_memory_size; u32 nat64_st_buckets; u64 nat64_st_memory_size; }; /** \brief Show NAT plugin startup config @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ define nat_show_config_2 { option deprecated; u32 client_index; u32 context; }; /** \brief Show NAT plugin startup config reply @param context - sender context, to match reply w/ request @param retval - return code for the request @param static_mapping_only - if true dynamic translations disabled @param static_mapping_connection_tracking - if true create session data @param deterministic - if true deterministic mapping @param endpoint_dependent - if true endpoint-dependent mode @param out2in_dpo - if true out2in dpo mode @param dslite_ce - if true DS-Lite is CE/B4 element, if false AFTR elemet @param translation_buckets - number of translation hash buckets @param translation_memory_size - translation hash memory size @param user_buckets - number of user hash buckets @param user_memory_size - user hash memory size @param max_translations_per_user - maximum number of translations per user @param outside_vrf_id - outside VRF id @param inside_vrf_id - default inside VRF id @param nat64_bib_buckets - number of NAT64 BIB hash buckets @param nat64_bib_memory_size - memory size of NAT64 BIB hash @param nat64_st_buckets - number of NAT64 session table hash buckets @param nat64_st_memory_size - memory size of NAT64 session table hash @param max_translations_per_thread - max translations per worker thread @param max_users_per_thread - max users per worker thread */ define nat_show_config_2_reply { option deprecated; u32 context; i32 retval; bool static_mapping_only; bool static_mapping_connection_tracking; bool deterministic; bool endpoint_dependent; bool out2in_dpo; bool dslite_ce; u32 translation_buckets; u64 translation_memory_size; u32 user_buckets; u64 user_memory_size; u32 max_translations_per_user; u32 outside_vrf_id; u32 inside_vrf_id; u32 nat64_bib_buckets; u64 nat64_bib_memory_size; u32 nat64_st_buckets; u64 nat64_st_memory_size; u32 max_translations_per_thread; u32 max_users_per_thread; }; /** \brief Show NAT44 plugin running config @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ define nat44_show_running_config { option in_progress; u32 client_index; u32 context; }; /** \brief Show NAT44 plugin running config reply @param context - sender context, to match reply w/ request @param retval - return code for the request @param inside_vrf - default inside VRF id @param outside_vrf - outside VRF id @param users - maximum number of users per worker thread (NAT44_IS_ENDPOINT_INDEPENDENT) @param sessions - maximum number of sessions per worker thread @param user_sessions - maximum number of sessions per user (NAT44_IS_ENDPOINT_INDEPENDENT) @param user_buckets - number of user hash buckets (NAT44_IS_ENDPOINT_INDEPENDENT) @param translation_buckets - number of translation hash buckets @param flags - flag NAT44_IS_ENDPOINT_INDEPENDENT, NAT44_IS_ENDPOINT_DEPENDENT, NAT44_IS_STATIC_MAPPING_ONLY, NAT44_IS_CONNECTION_TRACKING, NAT44_IS_OUT2IN_DPO */ define nat44_show_running_config_reply { option in_progress; u32 context; i32 retval; u32 inside_vrf; u32 outside_vrf; u32 users; u32 sessions; u32 user_sessions; u32 user_buckets; u32 translation_buckets; bool forwarding_enabled; bool ipfix_logging_enabled; vl_api_nat_timeouts_t timeouts; vl_api_nat_log_level_t log_level; vl_api_nat44_config_flags_t flags; }; /** \brief Run nat44 garbage collection @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ autoreply define nat44_session_cleanup { option deprecated; u32 client_index; u32 context; }; /** \brief NAT44 set session limit @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param session_limit - session limit @param vrf_id - vrf id */ autoreply define nat44_set_session_limit { u32 client_index; u32 context; u32 session_limit; u32 vrf_id; }; /** \brief Set NAT logging level @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param log_level - logging level */ autoreply define nat_set_log_level { option deprecated; u32 client_index; u32 context; vl_api_nat_log_level_t log_level; }; /** \brief Set NAT workers @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param worker_mask - NAT workers mask */ autoreply define nat_set_workers { u32 client_index; u32 context; u64 worker_mask; }; /** \brief Dump NAT workers @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request */ define nat_worker_dump { u32 client_index; u32 context; }; /** \brief NAT workers details response @param context - sender context, to match reply w/ request @param worker_index - worker index @param lcore_id - lcore ID @param name - worker name */ define nat_worker_details { u32 context; u32 worker_index; u32 lcore_id; string name[64]; }; /** \brief Enable/disable NAT IPFIX logging @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param domain_id - observation domain ID @param src_port - source port number @param enable - true if enable, false if disable */ autoreply define nat_ipfix_enable_disable { option deprecated; u32 client_index; u32 context; u32 domain_id; u16 src_port; bool enable; }; /**
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
Copyright (c) 2001, 2002, 2003 Eliot Dresselhaus
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef included_clib_vec_bootstrap_h
#define included_clib_vec_bootstrap_h
/** \file
Vector bootsrap header file
*/
/* Bootstrap include so that #include <vppinfra/mem.h> can include e.g.
<vppinfra/mheap.h> which depends on <vppinfra/vec.h>. */
/** \brief vector header structure
Bookeeping header preceding vector elements in memory.
User header information may preceed standard vec header.
If you change u32 len -> u64 len, single vectors can
exceed 2**32 elements. Clib heaps are vectors. */
typedef struct
{
#if CLIB_VEC64 > 0
u64 len;
#else
u32 len; /**< Number of elements in vector (NOT its allocated length). */
#endif
u8 vector_data[0]; /**< Vector data . */
} vec_header_t;
/** \brief Find the vector header
Given the user's pointer to a vector, find the corresponding
vector header
@param v pointer to a vector
@return pointer to the vector's vector_header_t
*/
#define _vec_find(v) ((vec_header_t *) (v) - 1)
#define _vec_round_size(s) \
(((s) + sizeof (uword) - 1) &~ (sizeof (uword) - 1))
always_inline uword
vec_header_bytes (uword header_bytes)
{
return round_pow2 (header_bytes + sizeof (vec_header_t),
sizeof (vec_header_t));
}
/** \brief Find a user vector header
Finds the user header of a vector with unspecified alignment given
the user pointer to the vector.
*/
always_inline void *
vec_header (void *v, uword header_bytes)
{
return v - vec_header_bytes (header_bytes);
}
/** \brief Find the end of user vector header
Finds the end of the user header of a vector with unspecified
alignment given the user pointer to the vector.
*/
always_inline void *
vec_header_end (void *v, uword header_bytes)
{
return v + vec_header_bytes (header_bytes);
}
always_inline uword
vec_aligned_header_bytes (uword header_bytes, uword align)
{
return round_pow2 (header_bytes + sizeof (vec_header_t), align);
}
always_inline void *
vec_aligned_header (void *v, uword header_bytes, uword align)
{
return v - vec_aligned_header_bytes (header_bytes, align);
}
always_inline void *
vec_aligned_header_end (void *v, uword header_bytes, uword align)
{
return v + vec_aligned_header_bytes (header_bytes, align);
}
/** \brief Number of elements in vector (lvalue-capable)
_vec_len (v) does not check for null, but can be used as a lvalue
(e.g. _vec_len (v) = 99).
*/
#define _vec_len(v) (_vec_find(v)->len)
/** \brief Number of elements in vector (rvalue-only, NULL tolerant)
vec_len (v) checks for NULL, but cannot be used as an lvalue.
If in doubt, use vec_len...
*/
#define vec_len(v) ((v) ? _vec_len(v) : 0)
/** \brief Reset vector length to zero
NULL-pointer tolerant
*/
#define vec_reset_length(v) do { if (v) _vec_len (v) = 0; } while (0)
/** \brief Number of data bytes in vector. */
#define vec_bytes(v) (vec_len (v) * sizeof (v[0]))
/** \brief Total number of bytes that can fit in vector with current allocation. */
#define vec_capacity(v,b) \
({ \
void * _vec_capacity_v = (void *) (v); \
uword _vec_capacity_b = (b); \
_vec_capacity_b = sizeof (vec_header_t) + _vec_round_size (_vec_capacity_b); \
_vec_capacity_v ? clib_mem_size (_vec_capacity_v - _vec_capacity_b) : 0; \
})
/** \brief Total number of elements that can fit into vector. */
#define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0]))
/** \brief End (last data address) of vector. */
#define vec_end(v) ((v) + vec_len (v))
/** \brief True if given pointer is within given vector. */
#define vec_is_member(v,e) ((e) >= (v) && (e) < vec_end (v))
/** \brief Get vector value at index i checking that i is in bounds. */
#define vec_elt_at_index(v,i) \
({ \
ASSERT ((i) < vec_len (v)); \
(v) + (i); \
})
/** \brief Get vector value at index i */
#define vec_elt(v,i) (vec_elt_at_index(v,i))[0]
/** \brief Vector iterator */
#define vec_foreach(var,vec) for (var = (vec); var < vec_end (vec); var++)
/** \brief Vector iterator (reverse) */
#define vec_foreach_backwards(var,vec) \
for (var = vec_end (vec) - 1; var >= (vec); var--)
/** \brief Iterate over vector indices. */
#define vec_foreach_index(var,v) for ((var) = 0; (var) < vec_len (v); (var)++)
#endif /* included_clib_vec_bootstrap_h */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/