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