More janitorial work
[vpp.git] / plugins / plugins / vcgn / cnat_bulk_port.h
1 /* 
2  *------------------------------------------------------------------
3  * cnat_bulk_port_defs.h bulk port alloc definitions
4  *
5  * Copyright (c) 2011-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:
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  */
19
20 #ifndef __CNAT_BULK_PORT_H__
21 #define __CNAT_BULK_PORT_H__
22
23 #ifndef NO_BULK_LOGGING
24 #include "cnat_bulk_port_defs.h"
25
26 cnat_errno_t
27 cnat_dynamic_port_alloc_v2_bulk (
28         cnat_portmap_v2_t    *pm,
29         port_alloc_t          atype,
30         port_pair_t           pair_type,
31         u32                  *index,
32         u32                  *o_ipv4_address,
33         u16                  *o_port,
34         u16                  static_port_range,
35         cnat_user_db_entry_t *udb,
36         bulk_alloc_size_t    bulk_size,
37         int                  *nfv9_log_req,
38         u16                   ip_n_to_1,
39         u32                  *rseed_ip);
40
41 void cnat_update_bulk_range_cache(cnat_user_db_entry_t *udb, u16 o_port,
42         bulk_alloc_size_t bulk_size);
43
44 void cnat_port_free_v2_bulk (
45         cnat_portmap_v2_t    *pm,
46         int                index,
47         port_pair_t        ptype,
48         u16                base_port,
49         cnat_user_db_entry_t *udb,
50         u16               static_port_range,
51         bulk_alloc_size_t    bulk_size,
52         int                *nfv9_log_req);
53
54 cnat_errno_t cnat_static_port_alloc_v2_bulk (
55         cnat_portmap_v2_t    *pm,
56         port_alloc_t         atype,
57         port_pair_t          pair_type,
58         u32                  i_ipv4_address,
59         u16                  i_port,
60         u32                  *index,
61         u32                  *o_ipv4_address,
62         u16                  *o_port,
63         u16                  static_port_range,
64         cnat_user_db_entry_t *udb,
65         bulk_alloc_size_t    bulk_size,
66         int                  *nfv9_log_req,
67         u16                  ip_n_to_1
68         );
69
70 cnat_errno_t cnat_dynamic_port_alloc_rtsp_bulk (
71         cnat_portmap_v2_t    *pm,
72         port_alloc_t         atype,
73         port_pair_t          pair_type,
74         u16                  i_port,
75         u32                  *index,
76         u32                  *o_ipv4_address,
77         u16                  *o_port,
78         u16                  static_port_range,
79         cnat_user_db_entry_t *udb,
80         bulk_alloc_size_t    bulk_size,
81         int                  *nfv9_log_req,
82         u32                  *rseed_ip);
83
84 cnat_errno_t
85 cnat_mapped_static_port_alloc_v2_bulk (
86         cnat_portmap_v2_t    *pm,
87         port_alloc_t         atype,
88         u32                  *index,
89         u32                   ipv4_address,
90         u16                   port,
91         cnat_user_db_entry_t *udb,
92         bulk_alloc_size_t    bulk_size,
93         int                  *nfv9_log_req,
94         u16                  ip_n_to_1
95         );
96
97 #else /* NO_BULK_LOGGING */
98 /* use older code */
99 inline cnat_errno_t
100 cnat_dynamic_port_alloc_v2_bulk (
101         cnat_vrfmap_t        *vrf_map,
102         port_alloc_t          atype,
103         port_pair_t           pair_type,
104         u32                  *index,
105         u32                  *o_ipv4_address,
106         u16                  *o_port,
107         u16                  static_port_range,
108         u16                  ip_n_to_1,
109         u32                  *rseed_ip
110        )
111 {
112     return cnat_dynamic_port_alloc_v2(vrf_map->portmap_list, atype,
113             pair_type, index, o_ipv4_address, o_port, static_port_range,
114            ip_n_to_1, rseed_ip); 
115 }
116
117 inline void cnat_port_free_v2_bulk (
118         cnat_portmap_v2_t  *pm,
119         int                index,
120         port_pair_t        ptype,
121         u16                base_port,
122         cnat_user_db_entry_t *udb, 
123         u16               static_port_range);
124 {
125     return cnat_port_free_v2(pm, index, ptype, base_port,
126             static_port_range);
127 }
128
129 inline cnat_errno_t cnat_static_port_alloc_v2_bulk (
130         cnat_portmap_v2_t    *pm,
131         port_alloc_t         atype,
132         port_pair_t          pair_type,
133         u32                  i_ipv4_address,
134         u16                  i_port,
135         u32                  *index,
136         u32                  *o_ipv4_address,
137         u16                  *o_port,
138         u16                  static_port_range)
139 {
140     return cnat_static_port_alloc_v2 (pm, atype, pair_type,
141             i_ipv4_address, i_port, index, o_ipv4_address, o_port);
142 }
143
144 inline cnat_errno_t
145 cnat_mapped_static_port_alloc_v2_bulk (
146         cnat_portmap_v2_t    *pm,
147         port_alloc_t         atype,
148         u32                  *index,
149         u32                   ipv4_address,
150         u16                   port)
151 {
152     return cnat_mapped_static_port_alloc_v2(pm, atype, index
153             ipv4_address, port);
154 }
155
156 #endif /* NO_BULK_LOGGING */
157 #endif /* __CNAT_BULK_PORT_H__ */