pnat: coverity errors
[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 };
30
31 enum pnat_attachment_point
32 {
33     PNAT_IP4_INPUT = 0,
34     PNAT_IP4_OUTPUT,
35     PNAT_ATTACHMENT_POINT_MAX,
36 };
37
38 typedef pnat_match_tuple
39 {
40     vl_api_ip4_address_t src;
41     vl_api_ip4_address_t dst;
42     vl_api_ip_proto_t proto;
43     u16 sport;
44     u16 dport;
45     vl_api_pnat_mask_t mask;
46 };
47
48 typedef pnat_rewrite_tuple
49 {
50     vl_api_ip4_address_t src;
51     vl_api_ip4_address_t dst;
52     u16 sport;
53     u16 dport;
54     vl_api_pnat_mask_t mask; // needed?
55     u8 from_offset;
56     u8 to_offset;
57     u8 clear_offset;
58 };
59
60 autoendian define pnat_binding_add
61 {
62     u32 client_index;
63     u32 context;
64     vl_api_pnat_match_tuple_t match;
65     vl_api_pnat_rewrite_tuple_t rewrite;
66 };
67
68 autoendian define pnat_binding_add_reply
69 {
70     u32 context;
71     i32 retval;
72     u32 binding_index;
73 };
74
75 autoendian autoreply define pnat_binding_del
76 {
77     u32 client_index;
78     u32 context;
79     u32 binding_index;
80 };
81
82 autoendian autoreply define pnat_binding_attach
83 {
84   u32 client_index;
85   u32 context;
86   vl_api_interface_index_t sw_if_index;
87   vl_api_pnat_attachment_point_t attachment;
88   u32 binding_index;
89 };
90
91 autoendian autoreply define pnat_binding_detach
92 {
93   u32 client_index;
94   u32 context;
95   vl_api_interface_index_t sw_if_index;
96   vl_api_pnat_attachment_point_t attachment;
97   u32 binding_index;
98 };
99
100 service {
101   rpc pnat_bindings_get returns pnat_bindings_get_reply
102     stream pnat_bindings_details;
103   rpc pnat_interfaces_get returns pnat_interfaces_get_reply
104     stream pnat_interfaces_details;
105 };
106
107 define pnat_bindings_get
108 {
109   u32 client_index;
110   u32 context;
111   u32 cursor;
112 };
113
114 define pnat_bindings_get_reply
115 {
116   u32 context;
117   i32 retval;
118   u32 cursor;
119 };
120
121 define pnat_bindings_details
122 {
123   u32 context;
124   vl_api_pnat_match_tuple_t match;
125   vl_api_pnat_rewrite_tuple_t rewrite;
126 };
127
128 define pnat_interfaces_get
129 {
130   u32 client_index;
131   u32 context;
132   u32 cursor;
133 };
134
135 define pnat_interfaces_get_reply
136 {
137   u32 context;
138   i32 retval;
139   u32 cursor;
140 };
141
142 define pnat_interfaces_details
143 {
144   u32 context;
145   vl_api_interface_index_t sw_if_index;
146   bool enabled[2]; /* PNAT_ATTACHMENT_POINT_MAX */
147   vl_api_pnat_mask_t lookup_mask[2]; /* PNAT_ATTACHMENT_POINT_MAX */
148 };
149
150 counters pnat {
151   none {
152     severity info;
153     type counter64;
154     units "packets";
155     description "successfully rewritten";
156   };
157
158   rewrite {
159     severity error;
160     type counter64;
161     units "packets";
162     description "rewrite failed";
163   };
164   tooshort {
165     severity info;
166     type counter64;
167     units "packets";
168     description "packet too short for rewrite";
169   };
170 };
171
172 paths {
173   "/err/pnat-input" "pnat";
174   "/err/pnat-output" "pnat";
175 };