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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef included_manual_fns_h
17 #define included_manual_fns_h
19 #include <vnet/ip/format.h>
20 #include <vnet/ethernet/ethernet.h>
21 #include <vnet/ip/ip_types_api.h>
23 #define vl_endianfun /* define message structures */
24 #include <acl/acl_types.api.h>
27 /* Macro to finish up custom dump fns */
30 vl_print (handle, (char *)s); \
34 vl_api_acl_rule_t_array_endian(vl_api_acl_rule_t *rules, u32 count)
37 for(i=0; i<count; i++) {
38 vl_api_acl_rule_t_endian (&rules[i]);
43 vl_api_macip_acl_rule_t_array_endian(vl_api_macip_acl_rule_t *rules, u32 count)
46 for(i=0; i<count; i++) {
47 vl_api_macip_acl_rule_t_endian (&rules[i]);
52 vl_api_acl_details_t_endian (vl_api_acl_details_t * a)
54 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
55 a->context = clib_net_to_host_u32 (a->context);
56 a->acl_index = clib_net_to_host_u32 (a->acl_index);
57 /* a->tag[0..63] = a->tag[0..63] (no-op) */
58 a->count = clib_net_to_host_u32 (a->count);
59 vl_api_acl_rule_t_array_endian (a->r, a->count);
63 vl_api_macip_acl_details_t_endian (vl_api_macip_acl_details_t * a)
65 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
66 a->context = clib_net_to_host_u32 (a->context);
67 a->acl_index = clib_net_to_host_u32 (a->acl_index);
68 /* a->tag[0..63] = a->tag[0..63] (no-op) */
69 a->count = clib_net_to_host_u32 (a->count);
70 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
75 vl_api_acl_add_replace_t_endian (vl_api_acl_add_replace_t * a)
77 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
78 a->client_index = clib_net_to_host_u32 (a->client_index);
79 a->context = clib_net_to_host_u32 (a->context);
80 a->acl_index = clib_net_to_host_u32 (a->acl_index);
81 /* a->tag[0..63] = a->tag[0..63] (no-op) */
82 a->count = clib_net_to_host_u32 (a->count);
83 vl_api_acl_rule_t_array_endian (a->r, a->count);
87 vl_api_macip_acl_add_t_endian (vl_api_macip_acl_add_t * a)
89 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
90 a->client_index = clib_net_to_host_u32 (a->client_index);
91 a->context = clib_net_to_host_u32 (a->context);
92 /* a->tag[0..63] = a->tag[0..63] (no-op) */
93 a->count = clib_net_to_host_u32 (a->count);
94 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
98 vl_api_macip_acl_add_replace_t_endian (vl_api_macip_acl_add_replace_t * a)
100 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
101 a->client_index = clib_net_to_host_u32 (a->client_index);
102 a->context = clib_net_to_host_u32 (a->context);
103 a->acl_index = clib_net_to_host_u32 (a->acl_index);
104 /* a->tag[0..63] = a->tag[0..63] (no-op) */
105 a->count = clib_net_to_host_u32 (a->count);
106 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
110 format_acl_action(u8 *s, u8 action)
114 s = format (s, "deny");
117 s = format (s, "permit");
120 s = format (s, "permit+reflect");
123 s = format (s, "action %d", action);
129 vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
132 fib_prefix_t src, dst;
134 ip_prefix_decode (&a->src_prefix, &src);
135 ip_prefix_decode (&a->dst_prefix, &dst);
137 s = format (0, " %s ", a->src_prefix.address.af ? "ipv6" : "ipv4");
138 s = format_acl_action (s, a->is_permit);
139 s = format (s, " \\\n");
141 s = format (s, " src %U dst %U \\\n",
142 format_fib_prefix, &src,
143 format_fib_prefix, &dst);
144 s = format (s, " proto %d \\\n", a->proto);
145 s = format (s, " sport %d-%d dport %d-%d \\\n",
146 clib_net_to_host_u16 (a->srcport_or_icmptype_first),
147 clib_net_to_host_u16 (a->srcport_or_icmptype_last),
148 clib_net_to_host_u16 (a->dstport_or_icmpcode_first),
149 clib_net_to_host_u16 (a->dstport_or_icmpcode_last));
151 s = format (s, " tcpflags %u mask %u, \\",
152 a->tcp_flags_value, a->tcp_flags_mask);
158 vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle)
163 ip_prefix_decode (&a->src_prefix, &src);
165 s = format (0, " %s %s \\\n", a->src_prefix.address.af ? "ipv6" : "ipv4",
166 a->is_permit ? "permit" : "deny");
168 s = format (s, " src mac %U mask %U \\\n",
169 format_ethernet_address, a->src_mac,
170 format_ethernet_address, a->src_mac_mask);
172 s = format (s, " src ip %U, \\",
173 format_fib_prefix, &src);
180 vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
184 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
185 u32 count = clib_net_to_host_u32 (a->count);
186 if (count > 0x100000)
188 s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
192 s = format (s, "SCRIPT: acl_add_replace %d count %d ",
196 s = format (s, "tag %s ", a->tag);
198 s = format(s, "\\\n");
201 for (i = 0; i < count; i++)
202 vl_api_acl_rule_t_print (&a->r[i], handle);
210 vl_api_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
214 s = format (0, "SCRIPT: acl_del %d ",
215 clib_host_to_net_u32 (a->acl_index));
223 vl_api_acl_details_t_print (vl_api_acl_details_t * a, void *handle)
227 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
228 u32 count = clib_net_to_host_u32 (a->count);
229 if (count > 0x100000)
231 s = format (s, "WARN: acl_details count endianness wrong? Fixup to avoid long loop.\n");
235 s = format (s, "acl_details index %d count %d ",
239 s = format (s, "tag %s ", a->tag);
244 for (i = 0; i < count; i++)
245 vl_api_acl_rule_t_print (&a->r[i], handle);
251 vl_api_macip_acl_details_t_print (vl_api_macip_acl_details_t * a,
256 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
257 u32 count = clib_net_to_host_u32 (a->count);
258 if (count > 0x100000)
260 s = format (s, "WARN: macip_acl_details count endianness wrong? Fixup to avoid long loop.\n");
264 s = format (s, "macip_acl_details index %d count %d ",
268 s = format (s, "tag %s ", a->tag);
273 for (i = 0; i < count; i++)
274 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
280 vl_api_macip_acl_add_t_print (vl_api_macip_acl_add_t * a, void *handle)
284 u32 count = clib_net_to_host_u32 (a->count);
285 if (count > 0x100000)
287 s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
291 s = format (s, "SCRIPT: macip_acl_add ");
293 s = format (s, "tag %s ", a->tag);
295 s = format (s, "count %d \\\n", count);
299 for (i = 0; i < count; i++)
300 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
302 s = format (0, "\n");
309 vl_api_macip_acl_add_replace_t_print (vl_api_macip_acl_add_replace_t * a, void *handle)
313 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
314 u32 count = clib_net_to_host_u32 (a->count);
315 if (count > 0x100000)
317 s = format (s, "WARN: macip_acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
321 s = format (s, "SCRIPT: macip_acl_add_replace %d count %d ",
324 s = format (s, "tag %s ", a->tag);
326 s = format (s, "count %d \\\n", count);
330 for (i = 0; i < count; i++)
331 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
333 s = format (0, "\n");
340 vl_api_acl_interface_set_acl_list_t_print (vl_api_acl_interface_set_acl_list_t
347 (0, "SCRIPT: acl_interface_set_acl_list sw_if_index %d count %d\n",
348 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
350 s = format (s, " input ");
352 for (i = 0; i < a->count; i++)
355 s = format (s, "output ");
356 s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
364 vl_api_acl_interface_set_etype_whitelist_t_print (vl_api_acl_interface_set_etype_whitelist_t
371 (0, "SCRIPT: acl_interface_set_etype_whitelist sw_if_index %d count %d\n",
372 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
374 s = format (s, " input ");
376 for (i = 0; i < a->count; i++)
379 s = format (s, "output ");
380 s = format (s, "%x ", clib_net_to_host_u16 (a->whitelist[i]));
388 vl_api_acl_interface_add_del_t_print (vl_api_acl_interface_add_del_t * a,
393 s = format (0, "SCRIPT: acl_interface_add_del sw_if_index %d acl %d ",
394 clib_net_to_host_u32 (a->sw_if_index),
395 clib_net_to_host_u32 (a->acl_index));
396 s = format (s, "%s %s",
397 a->is_input ? "input" : "output", a->is_add ? "add" : "del");
403 static inline void *vl_api_macip_acl_interface_add_del_t_print
404 (vl_api_macip_acl_interface_add_del_t * a, void *handle)
410 "SCRIPT: macip_acl_interface_add_del sw_if_index %d acl_index %d ",
411 clib_net_to_host_u32 (a->sw_if_index),
412 clib_net_to_host_u32 (a->acl_index));
413 s = format (s, "%s", a->is_add ? "add" : "del");
421 vl_api_macip_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
425 s = format (0, "SCRIPT: macip_acl_del %d ",
426 clib_host_to_net_u32 (a->acl_index));
433 #endif /* included_manual_fns_h */