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