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 /* Macro to finish up custom dump fns */
25 vl_print (handle, (char *)s); \
29 vl_api_acl_rule_t_array_endian(vl_api_acl_rule_t *rules, u32 count)
32 for(i=0; i<count; i++) {
33 vl_api_acl_rule_t_endian (&rules[i]);
38 vl_api_macip_acl_rule_t_array_endian(vl_api_macip_acl_rule_t *rules, u32 count)
41 for(i=0; i<count; i++) {
42 vl_api_macip_acl_rule_t_endian (&rules[i]);
47 vl_api_acl_details_t_endian (vl_api_acl_details_t * a)
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);
54 vl_api_acl_rule_t_array_endian (a->r, a->count);
58 vl_api_macip_acl_details_t_endian (vl_api_macip_acl_details_t * a)
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);
65 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
70 vl_api_acl_add_replace_t_endian (vl_api_acl_add_replace_t * a)
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);
78 vl_api_acl_rule_t_array_endian (a->r, a->count);
82 vl_api_macip_acl_add_t_endian (vl_api_macip_acl_add_t * a)
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);
89 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
93 vl_api_macip_acl_add_replace_t_endian (vl_api_macip_acl_add_replace_t * a)
95 a->_vl_msg_id = clib_net_to_host_u16 (a->_vl_msg_id);
96 a->client_index = clib_net_to_host_u32 (a->client_index);
97 a->context = clib_net_to_host_u32 (a->context);
98 a->acl_index = clib_net_to_host_u32 (a->acl_index);
99 /* a->tag[0..63] = a->tag[0..63] (no-op) */
100 a->count = clib_net_to_host_u32 (a->count);
101 vl_api_macip_acl_rule_t_array_endian (a->r, a->count);
105 format_acl_action(u8 *s, u8 action)
109 s = format (s, "deny");
112 s = format (s, "permit");
115 s = format (s, "permit+reflect");
118 s = format (s, "action %d", action);
124 vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
128 s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
129 s = format_acl_action (s, a->is_permit);
130 s = format (s, " \\\n");
133 s = format (s, " src %U/%d dst %U/%d \\\n",
134 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len,
135 format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len);
137 s = format (s, " src %U/%d dst %U/%d \\\n",
138 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len,
139 format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len);
140 s = format (s, " proto %d \\\n", a->proto);
141 s = format (s, " sport %d-%d dport %d-%d \\\n",
142 clib_net_to_host_u16 (a->srcport_or_icmptype_first),
143 clib_net_to_host_u16 (a->srcport_or_icmptype_last),
144 clib_net_to_host_u16 (a->dstport_or_icmpcode_first),
145 clib_net_to_host_u16 (a->dstport_or_icmpcode_last));
147 s = format (s, " tcpflags %u mask %u, \\",
148 a->tcp_flags_value, a->tcp_flags_mask);
154 vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle)
158 s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
159 a->is_permit ? "permit" : "deny");
161 s = format (s, " src mac %U mask %U \\\n",
162 format_ethernet_address, a->src_mac,
163 format_ethernet_address, a->src_mac_mask);
166 s = format (s, " src ip %U/%d, \\",
167 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len);
169 s = format (s, " src ip %U/%d, \\",
170 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len);
177 vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
181 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
182 u32 count = clib_net_to_host_u32 (a->count);
183 if (count > 0x100000)
185 s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
189 s = format (s, "SCRIPT: acl_add_replace %d count %d ",
193 s = format (s, "tag %s ", a->tag);
195 s = format(s, "\\\n");
198 for (i = 0; i < count; i++)
199 vl_api_acl_rule_t_print (&a->r[i], handle);
207 vl_api_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
211 s = format (0, "SCRIPT: acl_del %d ",
212 clib_host_to_net_u32 (a->acl_index));
220 vl_api_acl_details_t_print (vl_api_acl_details_t * a, void *handle)
224 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
225 u32 count = clib_net_to_host_u32 (a->count);
226 if (count > 0x100000)
228 s = format (s, "WARN: acl_details count endianness wrong? Fixup to avoid long loop.\n");
232 s = format (s, "acl_details index %d count %d ",
236 s = format (s, "tag %s ", a->tag);
241 for (i = 0; i < count; i++)
242 vl_api_acl_rule_t_print (&a->r[i], handle);
248 vl_api_macip_acl_details_t_print (vl_api_macip_acl_details_t * a,
253 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
254 u32 count = clib_net_to_host_u32 (a->count);
255 if (count > 0x100000)
257 s = format (s, "WARN: macip_acl_details count endianness wrong? Fixup to avoid long loop.\n");
261 s = format (s, "macip_acl_details index %d count %d ",
265 s = format (s, "tag %s ", a->tag);
270 for (i = 0; i < count; i++)
271 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
277 vl_api_macip_acl_add_t_print (vl_api_macip_acl_add_t * a, void *handle)
281 u32 count = clib_net_to_host_u32 (a->count);
282 if (count > 0x100000)
284 s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
288 s = format (s, "SCRIPT: macip_acl_add ");
290 s = format (s, "tag %s ", a->tag);
292 s = format (s, "count %d \\\n", count);
296 for (i = 0; i < count; i++)
297 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
299 s = format (0, "\n");
306 vl_api_macip_acl_add_replace_t_print (vl_api_macip_acl_add_replace_t * a, void *handle)
310 u32 acl_index = clib_net_to_host_u32 (a->acl_index);
311 u32 count = clib_net_to_host_u32 (a->count);
312 if (count > 0x100000)
314 s = format (s, "WARN: macip_acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
318 s = format (s, "SCRIPT: macip_acl_add_replace %d count %d ",
321 s = format (s, "tag %s ", a->tag);
323 s = format (s, "count %d \\\n", count);
327 for (i = 0; i < count; i++)
328 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
330 s = format (0, "\n");
337 vl_api_acl_interface_set_acl_list_t_print (vl_api_acl_interface_set_acl_list_t
344 (0, "SCRIPT: acl_interface_set_acl_list sw_if_index %d count %d\n",
345 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
347 s = format (s, " input ");
349 for (i = 0; i < a->count; i++)
352 s = format (s, "output ");
353 s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
361 vl_api_acl_interface_set_etype_whitelist_t_print (vl_api_acl_interface_set_etype_whitelist_t
368 (0, "SCRIPT: acl_interface_set_etype_whitelist sw_if_index %d count %d\n",
369 clib_net_to_host_u32 (a->sw_if_index), (u32) a->count);
371 s = format (s, " input ");
373 for (i = 0; i < a->count; i++)
376 s = format (s, "output ");
377 s = format (s, "%x ", clib_net_to_host_u16 (a->whitelist[i]));
385 vl_api_acl_interface_add_del_t_print (vl_api_acl_interface_add_del_t * a,
390 s = format (0, "SCRIPT: acl_interface_add_del sw_if_index %d acl %d ",
391 clib_net_to_host_u32 (a->sw_if_index),
392 clib_net_to_host_u32 (a->acl_index));
393 s = format (s, "%s %s",
394 a->is_input ? "input" : "output", a->is_add ? "add" : "del");
400 static inline void *vl_api_macip_acl_interface_add_del_t_print
401 (vl_api_macip_acl_interface_add_del_t * a, void *handle)
407 "SCRIPT: macip_acl_interface_add_del sw_if_index %d acl_index %d ",
408 clib_net_to_host_u32 (a->sw_if_index),
409 clib_net_to_host_u32 (a->acl_index));
410 s = format (s, "%s", a->is_add ? "add" : "del");
418 vl_api_macip_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
422 s = format (0, "SCRIPT: macip_acl_del %d ",
423 clib_host_to_net_u32 (a->acl_index));
430 #endif /* included_manual_fns_h */