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_details_t_endian (vl_api_acl_details_t * a)
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);
40 vl_api_macip_acl_details_t_endian (vl_api_macip_acl_details_t * a)
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);
52 vl_api_acl_add_replace_t_endian (vl_api_acl_add_replace_t * a)
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);
64 vl_api_macip_acl_add_t_endian (vl_api_macip_acl_add_t * a)
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);
75 format_acl_action(u8 *s, u8 action)
79 s = format (s, "deny");
82 s = format (s, "permit");
85 s = format (s, "permit+reflect");
88 s = format (s, "action %d", action);
94 vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
98 s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
99 s = format_acl_action (s, a->is_permit);
100 s = format (s, " \\\n");
103 s = format (s, " src %U/%d dst %U/%d \\\n",
104 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len,
105 format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len);
107 s = format (s, " src %U/%d dst %U/%d \\\n",
108 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len,
109 format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len);
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));
117 s = format (s, " tcpflags %u mask %u, \\",
118 a->tcp_flags_value, a->tcp_flags_mask);
126 vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle)
130 s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
131 a->is_permit ? "permit" : "deny");
133 s = format (s, " src mac %U mask %U \\\n",
134 format_ethernet_address, a->src_mac,
135 format_ethernet_address, a->src_mac_mask);
138 s = format (s, " src ip %U/%d, \\",
139 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len);
141 s = format (s, " src ip %U/%d, \\",
142 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len);
149 vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
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)
157 s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
161 s = format (s, "SCRIPT: acl_add_replace %d count %d ",
165 s = format (s, "tag %s ", a->tag);
167 s = format(s, "\\\n");
170 for (i = 0; i < count; i++)
171 vl_api_acl_rule_t_print (&a->r[i], handle);
179 vl_api_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
183 s = format (0, "SCRIPT: acl_del %d ",
184 clib_host_to_net_u32 (a->acl_index));
192 vl_api_acl_details_t_print (vl_api_acl_details_t * a, void *handle)
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)
200 s = format (s, "WARN: acl_defails count endianness wrong? Fixup to avoid long loop.\n");
204 s = format (s, "acl_details index %d count %d ",
208 s = format (s, "tag %s ", a->tag);
213 for (i = 0; i < count; i++)
214 vl_api_acl_rule_t_print (&a->r[i], handle);
220 vl_api_macip_acl_details_t_print (vl_api_macip_acl_details_t * a,
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)
229 s = format (s, "WARN: macip_acl_defails count endianness wrong? Fixup to avoid long loop.\n");
233 s = format (s, "macip_acl_details index %d count %d ",
237 s = format (s, "tag %s ", a->tag);
242 for (i = 0; i < count; i++)
243 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
249 vl_api_macip_acl_add_t_print (vl_api_macip_acl_add_t * a, void *handle)
253 u32 count = clib_net_to_host_u32 (a->count);
254 if (count > 0x100000)
256 s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
260 s = format (0, "SCRIPT: macip_acl_add ");
262 s = format (s, "tag %s ", a->tag);
264 s = format (s, "count %d \\\n", count);
268 for (i = 0; i < count; i++)
269 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
271 s = format (0, "\n");
279 vl_api_acl_interface_set_acl_list_t_print (vl_api_acl_interface_set_acl_list_t
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);
289 s = format (s, " input ");
291 for (i = 0; i < a->count; i++)
294 s = format (s, "output ");
295 s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
303 vl_api_acl_interface_add_del_t_print (vl_api_acl_interface_add_del_t * a,
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");
318 static inline void *vl_api_macip_acl_interface_add_del_t_print
319 (vl_api_macip_acl_interface_add_del_t * a, void *handle)
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");
336 vl_api_macip_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
340 s = format (0, "SCRIPT: macip_acl_del %d ",
341 clib_host_to_net_u32 (a->acl_index));
348 #endif /* included_manual_fns_h */