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>
22 #define vl_endianfun /* define message structures */
23 #include <acl/acl_types.api.h>
26 /* Macro to finish up custom dump fns */
29 vl_print (handle, (char *)s); \
33 vl_api_acl_rule_t_array_endian(vl_api_acl_rule_t *rules, u32 count)
36 for(i=0; i<count; i++) {
37 vl_api_acl_rule_t_endian (&rules[i]);
42 vl_api_macip_acl_rule_t_array_endian(vl_api_macip_acl_rule_t *rules, u32 count)
45 for(i=0; i<count; i++) {
46 vl_api_macip_acl_rule_t_endian (&rules[i]);
51 vl_api_acl_details_t_endian (vl_api_acl_details_t * a)
53 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
54 a->context = clib_net_to_host_u32 (a->context);
55 a->acl_index = clib_net_to_host_u32 (a->acl_index);
56 /* a->tag[0..63] = a->tag[0..63] (no-op) */
57 a->count = clib_net_to_host_u32 (a->count);
58 vl_api_acl_rule_t_array_endian (a->r, a->count);
62 vl_api_macip_acl_details_t_endian (vl_api_macip_acl_details_t * a)
64 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
65 a->context = clib_net_to_host_u32 (a->context);
66 a->acl_index = clib_net_to_host_u32 (a->acl_index);
67 /* a->tag[0..63] = a->tag[0..63] (no-op) */
68 a->count = clib_net_to_host_u32 (a->count);
69 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
74 vl_api_acl_add_replace_t_endian (vl_api_acl_add_replace_t * a)
76 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
77 a->client_index = clib_net_to_host_u32 (a->client_index);
78 a->context = clib_net_to_host_u32 (a->context);
79 a->acl_index = clib_net_to_host_u32 (a->acl_index);
80 /* a->tag[0..63] = a->tag[0..63] (no-op) */
81 a->count = clib_net_to_host_u32 (a->count);
82 vl_api_acl_rule_t_array_endian (a->r, a->count);
86 vl_api_macip_acl_add_t_endian (vl_api_macip_acl_add_t * a)
88 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
89 a->client_index = clib_net_to_host_u32 (a->client_index);
90 a->context = clib_net_to_host_u32 (a->context);
91 /* a->tag[0..63] = a->tag[0..63] (no-op) */
92 a->count = clib_net_to_host_u32 (a->count);
93 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
97 vl_api_macip_acl_add_replace_t_endian (vl_api_macip_acl_add_replace_t * a)
99 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
100 a->client_index = clib_net_to_host_u32 (a->client_index);
101 a->context = clib_net_to_host_u32 (a->context);
102 a->acl_index = clib_net_to_host_u32 (a->acl_index);
103 /* a->tag[0..63] = a->tag[0..63] (no-op) */
104 a->count = clib_net_to_host_u32 (a->count);
105 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
109 format_acl_action(u8 *s, u8 action)
113 s = format (s, "deny");
116 s = format (s, "permit");
119 s = format (s, "permit+reflect");
122 s = format (s, "action %d", action);
128 vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
132 s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
133 s = format_acl_action (s, a->is_permit);
134 s = format (s, " \\\n");
137 s = format (s, " src %U/%d dst %U/%d \\\n",
138 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len,
139 format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len);
141 s = format (s, " src %U/%d dst %U/%d \\\n",
142 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len,
143 format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len);
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)
162 s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
163 a->is_permit ? "permit" : "deny");
165 s = format (s, " src mac %U mask %U \\\n",
166 format_ethernet_address, a->src_mac,
167 format_ethernet_address, a->src_mac_mask);
170 s = format (s, " src ip %U/%d, \\",
171 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len);
173 s = format (s, " src ip %U/%d, \\",
174 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len);
181 vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
185 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
186 u32 count = clib_net_to_host_u32 (a->count);
187 if (count > 0x100000)
189 s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
193 s = format (s, "SCRIPT: acl_add_replace %d count %d ",
197 s = format (s, "tag %s ", a->tag);
199 s = format(s, "\\\n");
202 for (i = 0; i < count; i++)
203 vl_api_acl_rule_t_print (&a->r[i], handle);
211 vl_api_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
215 s = format (0, "SCRIPT: acl_del %d ",
216 clib_host_to_net_u32 (a->acl_index));
224 vl_api_acl_details_t_print (vl_api_acl_details_t * a, void *handle)
228 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
229 u32 count = clib_net_to_host_u32 (a->count);
230 if (count > 0x100000)
232 s = format (s, "WARN: acl_details count endianness wrong? Fixup to avoid long loop.\n");
236 s = format (s, "acl_details index %d count %d ",
240 s = format (s, "tag %s ", a->tag);
245 for (i = 0; i < count; i++)
246 vl_api_acl_rule_t_print (&a->r[i], handle);
252 vl_api_macip_acl_details_t_print (vl_api_macip_acl_details_t * a,
257 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
258 u32 count = clib_net_to_host_u32 (a->count);
259 if (count > 0x100000)
261 s = format (s, "WARN: macip_acl_details count endianness wrong? Fixup to avoid long loop.\n");
265 s = format (s, "macip_acl_details index %d count %d ",
269 s = format (s, "tag %s ", a->tag);
274 for (i = 0; i < count; i++)
275 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
281 vl_api_macip_acl_add_t_print (vl_api_macip_acl_add_t * a, void *handle)
285 u32 count = clib_net_to_host_u32 (a->count);
286 if (count > 0x100000)
288 s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
292 s = format (s, "SCRIPT: macip_acl_add ");
294 s = format (s, "tag %s ", a->tag);
296 s = format (s, "count %d \\\n", count);
300 for (i = 0; i < count; i++)
301 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
303 s = format (0, "\n");
310 vl_api_macip_acl_add_replace_t_print (vl_api_macip_acl_add_replace_t * a, void *handle)
314 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
315 u32 count = clib_net_to_host_u32 (a->count);
316 if (count > 0x100000)
318 s = format (s, "WARN: macip_acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
322 s = format (s, "SCRIPT: macip_acl_add_replace %d count %d ",
325 s = format (s, "tag %s ", a->tag);
327 s = format (s, "count %d \\\n", count);
331 for (i = 0; i < count; i++)
332 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
334 s = format (0, "\n");
341 vl_api_acl_interface_set_acl_list_t_print (vl_api_acl_interface_set_acl_list_t
348 (0, "SCRIPT: acl_interface_set_acl_list sw_if_index %d count %d\n",
349 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
351 s = format (s, " input ");
353 for (i = 0; i < a->count; i++)
356 s = format (s, "output ");
357 s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
365 vl_api_acl_interface_set_etype_whitelist_t_print (vl_api_acl_interface_set_etype_whitelist_t
372 (0, "SCRIPT: acl_interface_set_etype_whitelist sw_if_index %d count %d\n",
373 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
375 s = format (s, " input ");
377 for (i = 0; i < a->count; i++)
380 s = format (s, "output ");
381 s = format (s, "%x ", clib_net_to_host_u16 (a->whitelist[i]));
389 vl_api_acl_interface_add_del_t_print (vl_api_acl_interface_add_del_t * a,
394 s = format (0, "SCRIPT: acl_interface_add_del sw_if_index %d acl %d ",
395 clib_net_to_host_u32 (a->sw_if_index),
396 clib_net_to_host_u32 (a->acl_index));
397 s = format (s, "%s %s",
398 a->is_input ? "input" : "output", a->is_add ? "add" : "del");
404 static inline void *vl_api_macip_acl_interface_add_del_t_print
405 (vl_api_macip_acl_interface_add_del_t * a, void *handle)
411 "SCRIPT: macip_acl_interface_add_del sw_if_index %d acl_index %d ",
412 clib_net_to_host_u32 (a->sw_if_index),
413 clib_net_to_host_u32 (a->acl_index));
414 s = format (s, "%s", a->is_add ? "add" : "del");
422 vl_api_macip_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
426 s = format (0, "SCRIPT: macip_acl_del %d ",
427 clib_host_to_net_u32 (a->acl_index));
434 #endif /* included_manual_fns_h */