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 format_acl_action(u8 *s, u8 action)
97 s = format (s, "deny");
100 s = format (s, "permit");
103 s = format (s, "permit+reflect");
106 s = format (s, "action %d", action);
112 vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle)
116 s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4");
117 s = format_acl_action (s, a->is_permit);
118 s = format (s, " \\\n");
121 s = format (s, " src %U/%d dst %U/%d \\\n",
122 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len,
123 format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len);
125 s = format (s, " src %U/%d dst %U/%d \\\n",
126 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len,
127 format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len);
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));
135 s = format (s, " tcpflags %u mask %u, \\",
136 a->tcp_flags_value, a->tcp_flags_mask);
144 vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle)
148 s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4",
149 a->is_permit ? "permit" : "deny");
151 s = format (s, " src mac %U mask %U \\\n",
152 format_ethernet_address, a->src_mac,
153 format_ethernet_address, a->src_mac_mask);
156 s = format (s, " src ip %U/%d, \\",
157 format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len);
159 s = format (s, " src ip %U/%d, \\",
160 format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len);
167 vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle)
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)
175 s = format (s, "WARN: acl_add_replace count endianness wrong? Fixup to avoid long loop.\n");
179 s = format (s, "SCRIPT: acl_add_replace %d count %d ",
183 s = format (s, "tag %s ", a->tag);
185 s = format(s, "\\\n");
188 for (i = 0; i < count; i++)
189 vl_api_acl_rule_t_print (&a->r[i], handle);
197 vl_api_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
201 s = format (0, "SCRIPT: acl_del %d ",
202 clib_host_to_net_u32 (a->acl_index));
210 vl_api_acl_details_t_print (vl_api_acl_details_t * a, void *handle)
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)
218 s = format (s, "WARN: acl_defails count endianness wrong? Fixup to avoid long loop.\n");
222 s = format (s, "acl_details index %d count %d ",
226 s = format (s, "tag %s ", a->tag);
231 for (i = 0; i < count; i++)
232 vl_api_acl_rule_t_print (&a->r[i], handle);
238 vl_api_macip_acl_details_t_print (vl_api_macip_acl_details_t * a,
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)
247 s = format (s, "WARN: macip_acl_defails count endianness wrong? Fixup to avoid long loop.\n");
251 s = format (s, "macip_acl_details index %d count %d ",
255 s = format (s, "tag %s ", a->tag);
260 for (i = 0; i < count; i++)
261 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
267 vl_api_macip_acl_add_t_print (vl_api_macip_acl_add_t * a, void *handle)
271 u32 count = clib_net_to_host_u32 (a->count);
272 if (count > 0x100000)
274 s = format (s, "WARN: macip_acl_add count endianness wrong? Fixup to avoid long loop.\n");
278 s = format (s, "SCRIPT: macip_acl_add ");
280 s = format (s, "tag %s ", a->tag);
282 s = format (s, "count %d \\\n", count);
286 for (i = 0; i < count; i++)
287 vl_api_macip_acl_rule_t_print (&a->r[i], handle);
289 s = format (0, "\n");
297 vl_api_acl_interface_set_acl_list_t_print (vl_api_acl_interface_set_acl_list_t
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);
307 s = format (s, " input ");
309 for (i = 0; i < a->count; i++)
312 s = format (s, "output ");
313 s = format (s, "%d ", clib_net_to_host_u32 (a->acls[i]));
321 vl_api_acl_interface_add_del_t_print (vl_api_acl_interface_add_del_t * a,
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");
336 static inline void *vl_api_macip_acl_interface_add_del_t_print
337 (vl_api_macip_acl_interface_add_del_t * a, void *handle)
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");
354 vl_api_macip_acl_del_t_print (vl_api_macip_acl_del_t * a, void *handle)
358 s = format (0, "SCRIPT: macip_acl_del %d ",
359 clib_host_to_net_u32 (a->acl_index));
366 #endif /* included_manual_fns_h */