FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
manual_fns.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 #ifndef included_manual_fns_h
17 #define included_manual_fns_h
18 
19 #include <vnet/ip/format.h>
20 #include <vnet/ethernet/ethernet.h>
21 
22 /* Macro to finish up custom dump fns */
23 #define PRINT_S \
24  vec_add1 (s, 0); \
25  vl_print (handle, (char *)s); \
26  vec_free (s);
27 
28 static inline void
30 {
31  a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
32  a->context = clib_net_to_host_u32 (a->context);
33  a->acl_index = clib_net_to_host_u32 (a->acl_index);
34  /* a->tag[0..63] = a->tag[0..63] (no-op) */
35  a->count = clib_net_to_host_u32 (a->count);
36  vl_api_acl_rule_t_endian (a->r);
37 }
38 
39 static inline void
41 {
42  a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
43  a->context = clib_net_to_host_u32 (a->context);
44  a->acl_index = clib_net_to_host_u32 (a->acl_index);
45  /* a->tag[0..63] = a->tag[0..63] (no-op) */
46  a->count = clib_net_to_host_u32 (a->count);
47  vl_api_macip_acl_rule_t_endian (a->r);
48 }
49 
50 
51 static inline void
53 {
54  a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
55  a->client_index = clib_net_to_host_u32 (a->client_index);
56  a->context = clib_net_to_host_u32 (a->context);
57  a->acl_index = clib_net_to_host_u32 (a->acl_index);
58  /* a->tag[0..63] = a->tag[0..63] (no-op) */
59  a->count = clib_net_to_host_u32 (a->count);
60  vl_api_acl_rule_t_endian (a->r);
61 }
62 
63 static inline void
65 {
66  a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
67  a->client_index = clib_net_to_host_u32 (a->client_index);
68  a->context = clib_net_to_host_u32 (a->context);
69  /* a->tag[0..63] = a->tag[0..63] (no-op) */
70  a->count = clib_net_to_host_u32 (a->count);
71  vl_api_macip_acl_rule_t_endian (a->r);
72 }
73 
74 static inline u8 *
75 format_acl_action(u8 *s, u8 action)
76 {
77  switch(action) {
78  case 0:
79  s = format (s, "deny");
80  break;
81  case 1:
82  s = format (s, "permit");
83  break;
84  case 2:
85  s = format (s, "permit+reflect");
86  break;
87  default:
88  s = format (s, "action %d", action);
89  }
90  return(s);
91 }
92 
93 static inline void *
95 {
96  u8 *s;
97 
98  s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
99  s = format_acl_action (s, a->is_permit);
100  s = format (s, " \\\n");
101 
102  if (a->is_ipv6)
103  s = format (s, " src %U/%d dst %U/%d \\\n",
106  else
107  s = format (s, " src %U/%d dst %U/%d \\\n",
110  s = format (s, " proto %d \\\n", a->proto);
111  s = format (s, " sport %d-%d dport %d-%d \\\n",
112  clib_net_to_host_u16 (a->srcport_or_icmptype_first),
113  clib_net_to_host_u16 (a->srcport_or_icmptype_last),
114  clib_net_to_host_u16 (a->dstport_or_icmpcode_first),
115  clib_net_to_host_u16 (a->dstport_or_icmpcode_last));
116 
117  s = format (s, " tcpflags %u mask %u, \\",
119  PRINT_S;
120  return handle;
121 }
122 
123 
124 
125 static inline void *
127 {
128  u8 *s;
129 
130  s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
131  a->is_permit ? "permit" : "deny");
132 
133  s = format (s, " src mac %U mask %U \\\n",
136 
137  if (a->is_ipv6)
138  s = format (s, " src ip %U/%d, \\",
140  else
141  s = format (s, " src ip %U/%d, \\",
143 
144  PRINT_S;
145  return handle;
146 }
147 
148 static inline void *
150 {
151  u8 *s = 0;
152  int i;
153  u32 acl_index = clib_net_to_host_u32 (a->acl_index);
154  u32 count = clib_net_to_host_u32 (a->count);
155  if (count > 0x100000)
156  {
157  s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
158  count = a->count;
159  }
160 
161  s = format (s, "SCRIPT: acl_add_replace %d count %d ",
162  acl_index, count);
163 
164  if (a->tag[0])
165  s = format (s, "tag %s ", a->tag);
166 
167  s = format(s, "\\\n");
168  PRINT_S;
169 
170  for (i = 0; i < count; i++)
171  vl_api_acl_rule_t_print (&a->r[i], handle);
172 
173  s = format(s, "\n");
174  PRINT_S;
175  return handle;
176 }
177 
178 static inline void *
180 {
181  u8 *s;
182 
183  s = format (0, "SCRIPT: acl_del %d ",
184  clib_host_to_net_u32 (a->acl_index));
185 
186  PRINT_S;
187  return handle;
188 }
189 
190 
191 static inline void *
193 {
194  u8 *s = 0;
195  int i;
196  u32 acl_index = clib_net_to_host_u32 (a->acl_index);
197  u32 count = clib_net_to_host_u32 (a->count);
198  if (count > 0x100000)
199  {
200  s = format (s, "WARN: acl_defails count endianness wrong? Fixup to avoid long loop.\n");
201  count = a->count;
202  }
203 
204  s = format (s, "acl_details index %d count %d ",
205  acl_index, count);
206 
207  if (a->tag[0])
208  s = format (s, "tag %s ", a->tag);
209 
210  s = format(s, "\n");
211  PRINT_S;
212 
213  for (i = 0; i < count; i++)
214  vl_api_acl_rule_t_print (&a->r[i], handle);
215 
216  return handle;
217 }
218 
219 static inline void *
221  void *handle)
222 {
223  u8 *s = 0;
224  int i;
225  u32 acl_index = clib_net_to_host_u32 (a->acl_index);
226  u32 count = clib_net_to_host_u32 (a->count);
227  if (count > 0x100000)
228  {
229  s = format (s, "WARN: macip_acl_defails count endianness wrong? Fixup to avoid long loop.\n");
230  count = a->count;
231  }
232 
233  s = format (s, "macip_acl_details index %d count %d ",
234  acl_index, count);
235 
236  if (a->tag[0])
237  s = format (s, "tag %s ", a->tag);
238 
239  s = format(s, "\n");
240  PRINT_S;
241 
242  for (i = 0; i < count; i++)
243  vl_api_macip_acl_rule_t_print (&a->r[i], handle);
244 
245  return handle;
246 }
247 
248 static inline void *
250 {
251  u8 *s = 0;
252  int i;
253  u32 count = clib_net_to_host_u32 (a->count);
254  if (count > 0x100000)
255  {
256  s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
257  count = a->count;
258  }
259 
260  s = format (0, "SCRIPT: macip_acl_add ");
261  if (a->tag[0])
262  s = format (s, "tag %s ", a->tag);
263 
264  s = format (s, "count %d \\\n", count);
265 
266  PRINT_S;
267 
268  for (i = 0; i < count; i++)
269  vl_api_macip_acl_rule_t_print (&a->r[i], handle);
270 
271  s = format (0, "\n");
272  PRINT_S;
273 
274  return handle;
275 }
276 
277 
278 static inline void *
280  * a, void *handle)
281 {
282  u8 *s;
283  int i;
284 
285  s = format
286  (0, "SCRIPT: acl_interface_set_acl_list sw_if_index %d count %d\n",
287  clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
288 
289  s = format (s, " input ");
290 
291  for (i = 0; i < a->count; i++)
292  {
293  if (i == a->n_input)
294  s = format (s, "output ");
295  s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
296  }
297 
298  PRINT_S;
299  return handle;
300 }
301 
302 static inline void *
304  void *handle)
305 {
306  u8 *s;
307 
308  s = format (0, "SCRIPT: acl_interface_add_del sw_if_index %d acl %d ",
309  clib_net_to_host_u32 (a->sw_if_index),
310  clib_net_to_host_u32 (a->acl_index));
311  s = format (s, "%s %s",
312  a->is_input ? "input" : "output", a->is_add ? "add" : "del");
313 
314  PRINT_S;
315  return handle;
316 }
317 
320 {
321  u8 *s;
322 
323  s = format
324  (0,
325  "SCRIPT: macip_acl_interface_add_del sw_if_index %d acl_index %d ",
326  clib_net_to_host_u32 (a->sw_if_index),
327  clib_net_to_host_u32 (a->acl_index));
328  s = format (s, "%s", a->is_add ? "add" : "del");
329 
330  PRINT_S;
331  return handle;
332 }
333 
334 
335 static inline void *
337 {
338  u8 *s;
339 
340  s = format (0, "SCRIPT: macip_acl_del %d ",
341  clib_host_to_net_u32 (a->acl_index));
342 
343  PRINT_S;
344  return handle;
345 }
346 
347 
348 #endif /* included_manual_fns_h */
static void * vl_api_macip_acl_interface_add_del_t_print(vl_api_macip_acl_interface_add_del_t *a, void *handle)
Definition: manual_fns.h:319
Use acl_interface_set_acl_list instead Append/remove an ACL index to/from the list of ACLs checked fo...
Definition: acl.api:193
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
Set the vector of input/output ACLs checked for an interface.
Definition: acl.api:227
u8 tcp_flags_mask
Definition: acl.api:94
vl_api_macip_acl_rule_t r[count]
Definition: acl.api:322
#define PRINT_S
Definition: manual_fns.h:23
u8 src_ip_addr[16]
Definition: acl.api:67
static void * vl_api_acl_details_t_print(vl_api_acl_details_t *a, void *handle)
Definition: manual_fns.h:192
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
Access List Rule entry.
Definition: acl.api:63
u16 dstport_or_icmpcode_last
Definition: acl.api:88
Delete a MACIP ACL.
Definition: acl.api:344
Details about one MACIP ACL.
Definition: acl.api:412
format_function_t format_ip4_address
Definition: format.h:79
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
u16 dstport_or_icmpcode_first
Definition: acl.api:87
u8 src_ip_prefix_len
Definition: acl.api:68
static void * vl_api_acl_interface_set_acl_list_t_print(vl_api_acl_interface_set_acl_list_t *a, void *handle)
Definition: manual_fns.h:279
u8 tcp_flags_value
Definition: acl.api:95
Add or delete a MACIP ACL to/from interface.
Definition: acl.api:370
static u8 * format_acl_action(u8 *s, u8 action)
Definition: manual_fns.h:75
static void * vl_api_acl_interface_add_del_t_print(vl_api_acl_interface_add_del_t *a, void *handle)
Definition: manual_fns.h:303
static void * vl_api_macip_acl_rule_t_print(vl_api_macip_acl_rule_t *a, void *handle)
Definition: manual_fns.h:126
Replace an existing ACL in-place or create a new ACL.
Definition: acl.api:135
vl_api_acl_rule_t r[count]
Definition: acl.api:142
static void vl_api_acl_add_replace_t_endian(vl_api_acl_add_replace_t *a)
Definition: manual_fns.h:52
static void * vl_api_macip_acl_add_t_print(vl_api_macip_acl_add_t *a, void *handle)
Definition: manual_fns.h:249
u8 dst_ip_addr[16]
Definition: acl.api:69
vl_api_acl_rule_t r[count]
Definition: acl.api:275
format_function_t format_ip6_address
Definition: format.h:95
u16 srcport_or_icmptype_first
Definition: acl.api:85
static void * vl_api_acl_rule_t_print(vl_api_acl_rule_t *a, void *handle)
Definition: manual_fns.h:94
static void * vl_api_acl_add_replace_t_print(vl_api_acl_add_replace_t *a, void *handle)
Definition: manual_fns.h:149
u16 srcport_or_icmptype_last
Definition: acl.api:86
static void vl_api_macip_acl_details_t_endian(vl_api_macip_acl_details_t *a)
Definition: manual_fns.h:40
static void vl_api_macip_acl_add_t_endian(vl_api_macip_acl_add_t *a)
Definition: manual_fns.h:64
unsigned int u32
Definition: types.h:88
MACIP Access List Rule entry.
Definition: acl.api:107
u8 dst_ip_prefix_len
Definition: acl.api:70
vl_api_macip_acl_rule_t r[count]
Definition: acl.api:418
unsigned char u8
Definition: types.h:56
Details about a single ACL contents.
Definition: acl.api:269
static void * vl_api_macip_acl_details_t_print(vl_api_macip_acl_details_t *a, void *handle)
Definition: manual_fns.h:220
Add a MACIP ACL.
Definition: acl.api:316
static void * vl_api_acl_del_t_print(vl_api_macip_acl_del_t *a, void *handle)
Definition: manual_fns.h:179
static void * vl_api_macip_acl_del_t_print(vl_api_macip_acl_del_t *a, void *handle)
Definition: manual_fns.h:336
static void vl_api_acl_details_t_endian(vl_api_acl_details_t *a)
Definition: manual_fns.h:29