nat: Include platform specific headers on FreeBSD
[vpp.git] / src / plugins / nat / pnat / pnat.api
1 /*
2  * Copyright (c) 2021 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 option version = "0.1.1";
17
18 import "vnet/interface_types.api";
19 import "vnet/ip/ip_types.api";
20
21 enum pnat_mask
22 {
23     PNAT_SA = 0x1,
24     PNAT_DA = 0x2,
25     PNAT_SPORT = 0x4,
26     PNAT_DPORT = 0x8,
27     PNAT_COPY_BYTE = 0x10,
28     PNAT_CLEAR_BYTE = 0x20,
29     PNAT_PROTO = 0x40,
30 };
31
32 enum pnat_attachment_point
33 {
34     PNAT_IP4_INPUT = 0,
35     PNAT_IP4_OUTPUT,
36     PNAT_ATTACHMENT_POINT_MAX,
37 };
38
39 typedef pnat_match_tuple
40 {
41     vl_api_ip4_address_t src;
42     vl_api_ip4_address_t dst;
43     vl_api_ip_proto_t proto;
44     u16 sport;
45     u16 dport;
46     vl_api_pnat_mask_t mask;
47 };
48
49 typedef pnat_rewrite_tuple
50 {
51     vl_api_ip4_address_t src;
52     vl_api_ip4_address_t dst;
53     u16 sport;
54     u16 dport;
55     vl_api_pnat_mask_t mask; // needed?
56     u8 from_offset;
57     u8 to_offset;
58     u8 clear_offset;
59 };
60
61 autoendian define pnat_binding_add
62 {
63     u32 client_index;
64     u32 context;
65     vl_api_pnat_match_tuple_t match;
66     vl_api_pnat_rewrite_tuple_t rewrite;
67 };
68
69
70 autoendian define pnat_binding_add_reply
71 {
72     u32 context;
73     i32 retval;
74     u32 binding_index;
75 };
76
77 autoendian define pnat_binding_add_v2
78 {
79     u32 client_index;
80     u32 context;
81     vl_api_pnat_match_tuple_t match;
82     vl_api_pnat_rewrite_tuple_t rewrite;
83 };
84
85
86 autoendian define pnat_binding_add_v2_reply
87 {
88     u32 context;
89     i32 retval;
90     u32 binding_index;
91 };
92
93 autoendian autoreply define pnat_binding_del
94 {
95     u32 client_index;
96     u32 context;
97     u32 binding_index;
98 };
99
100 autoendian autoreply define pnat_binding_attach
101 {
102   u32 client_index;
103   u32 context;
104   vl_api_interface_index_t sw_if_index;
105   vl_api_pnat_attachment_point_t attachment;
106   u32 binding_index;
107 };
108
109 autoendian autoreply define pnat_binding_detach
110 {
111   u32 client_index;
112   u32 context;
113   vl_api_interface_index_t sw_if_index;
114   vl_api_pnat_attachment_point_t attachment;
115   u32 binding_index;
116 };
117
118 service {
119   rpc pnat_bindings_get returns pnat_bindings_get_reply
120     stream pnat_bindings_details;
121   rpc pnat_interfaces_get returns pnat_interfaces_get_reply
122     stream pnat_interfaces_details;
123 };
124
125 define pnat_bindings_get
126 {
127   u32 client_index;
128   u32 context;
129   u32 cursor;
130 };
131
132 define pnat_bindings_get_reply
133 {
134   u32 context;
135   i32 retval;
136   u32 cursor;
137 };
138
139 define pnat_bindings_details
140 {
141   u32 context;
142   vl_api_pnat_match_tuple_t match;
143   vl_api_pnat_rewrite_tuple_t rewrite;
144 };
145
146 define pnat_interfaces_get
147 {
148   u32 client_index;
149   u32 context;
150   u32 cursor;
151 };
152
153 define pnat_interfaces_get_reply
154 {
155   u32 context;
156   i32 retval;
157   u32 cursor;
158 };
159
160 define pnat_interfaces_details
161 {
162   u32 context;
163   vl_api_interface_index_t sw_if_index;
164   bool enabled[2]; /* PNAT_ATTACHMENT_POINT_MAX */
165   vl_api_pnat_mask_t lookup_mask[2]; /* PNAT_ATTACHMENT_POINT_MAX */
166 };
167
168 counters pnat {
169   none {
170     severity info;
171     type counter64;
172     units "packets";
173     description "successfully rewritten";
174   };
175
176   rewrite {
177     severity error;
178     type counter64;
179     units "packets";
180     description "rewrite failed";
181   };
182   tooshort {
183     severity info;
184     type counter64;
185     units "packets";
186     description "packet too short for rewrite";
187   };
188 };
189
190 paths {
191   "/err/pnat-input" "pnat";
192   "/err/pnat-output" "pnat";
193 };