FD.io VPP  v21.01.1
Vector Packet Processing
inlines.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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  * @brief The NAT44 inline functions
17  */
18 
19 #ifndef included_nat44_inlines_h__
20 #define included_nat44_inlines_h__
21 
22 #include <vnet/fib/ip4_fib.h>
23 #include <nat/nat.h>
24 
27 {
28  if (pool_elts (sm->per_thread_data[thread_index].sessions) >=
30  return 1;
31  return 0;
32 }
33 
36  u32 fib_index, u32 thread_index)
37 {
38  u32 translations;
39  translations = pool_elts (sm->per_thread_data[thread_index].sessions);
40  if (vec_len (sm->max_translations_per_fib) <= fib_index)
41  fib_index = 0;
42  return translations >= sm->max_translations_per_fib[fib_index];
43 }
44 
45 #endif /* included_nat44_inlines_h__ */
46 
47 /*
48  * fd.io coding-style-patch-verification: ON
49  *
50  * Local Variables:
51  * eval: (c-set-style "gnu")
52  * End:
53  */
u32 * max_translations_per_fib
Definition: nat.h:643
u32 max_translations_per_thread
Definition: nat.h:642
unsigned char u8
Definition: types.h:56
#define static_always_inline
Definition: clib.h:109
unsigned int u32
Definition: types.h:88
static_always_inline u8 nat44_maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
The NAT44 inline functions.
Definition: inlines.h:26
static_always_inline u8 nat44_ed_maximum_sessions_exceeded(snat_main_t *sm, u32 fib_index, u32 thread_index)
Definition: inlines.h:35
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
snat_main_per_thread_data_t * per_thread_data
Definition: nat.h:529
snat_session_t * sessions
Definition: nat.h:453
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127