2 * Copyright (c) 2015 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.
17 #include <vlibapi/api.h>
18 #include <vlibmemory/api.h>
19 #include <vppinfra/error.h>
20 #include <vpp/api/types.h>
22 #include <vnet/ip/ip_format_fns.h>
23 #include <vnet/ethernet/ethernet_format_fns.h>
25 /* define message IDs */
26 #include <ip6-nd/ip6_nd.api_enum.h>
27 #include <ip6-nd/ip6_nd.api_types.h>
28 #include <vpp/api/vpe.api_types.h>
32 /* API message ID base */
38 ip6_nd_test_main_t ip6_nd_test_main;
40 #define __plugin_msg_base ip6_nd_test_main.msg_id_base
41 #include <vlibapi/vat_helper_macros.h>
44 api_want_ip6_ra_events (vat_main_t * vam)
50 api_ip6nd_send_router_solicitation (vat_main_t * vam)
56 api_ip6nd_proxy_add_del (vat_main_t * vam)
58 unformat_input_t *i = vam->input;
59 vl_api_ip6nd_proxy_add_del_t *mp;
61 u8 v6_address_set = 0;
62 vl_api_ip6_address_t v6address;
66 /* Parse args required to build the message */
67 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
69 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
71 else if (unformat (i, "sw_if_index %d", &sw_if_index))
73 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
75 if (unformat (i, "del"))
79 clib_warning ("parse error '%U'", format_unformat_error, i);
84 if (sw_if_index == ~0)
86 errmsg ("missing interface name or sw_if_index");
91 errmsg ("no address set");
95 /* Construct the API message */
96 M (IP6ND_PROXY_ADD_DEL, mp);
99 mp->sw_if_index = ntohl (sw_if_index);
100 clib_memcpy (mp->ip, v6address, sizeof (v6address));
105 /* Wait for a reply, return good/bad news */
111 api_ip6nd_proxy_dump (vat_main_t * vam)
113 vl_api_ip6nd_proxy_dump_t *mp;
114 vl_api_control_ping_t *mp_ping;
117 M (IP6ND_PROXY_DUMP, mp);
121 /* Use a control ping for synchronization */
122 /* Use a control ping for synchronization */
123 mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
124 mp_ping->_vl_msg_id = htons (ip6_nd_test_main.ping_id);
125 mp_ping->client_index = vam->my_client_index;
126 vam->result_ready = 0;
134 static void vl_api_ip6nd_proxy_details_t_handler
135 (vl_api_ip6nd_proxy_details_t * mp)
137 vat_main_t *vam = &vat_main;
139 print (vam->ofp, "host %U sw_if_index %d",
140 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
144 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
146 unformat_input_t *i = vam->input;
147 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
149 u8 sw_if_index_set = 0;
150 u8 v6_address_set = 0;
155 u8 no_autoconfig = 0;
158 u32 val_lifetime = 0;
159 u32 pref_lifetime = 0;
162 /* Parse args required to build the message */
163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
165 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
169 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
171 else if (unformat (i, "val_life %d", &val_lifetime))
173 else if (unformat (i, "pref_life %d", &pref_lifetime))
175 else if (unformat (i, "def"))
177 else if (unformat (i, "noadv"))
179 else if (unformat (i, "offl"))
181 else if (unformat (i, "noauto"))
183 else if (unformat (i, "nolink"))
185 else if (unformat (i, "isno"))
189 clib_warning ("parse error '%U'", format_unformat_error, i);
194 if (sw_if_index_set == 0)
196 errmsg ("missing interface name or sw_if_index");
201 errmsg ("no address set");
205 /* Construct the API message */
206 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
208 mp->sw_if_index = ntohl (sw_if_index);
209 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
210 mp->use_default = use_default;
211 mp->no_advertise = no_advertise;
212 mp->off_link = off_link;
213 mp->no_autoconfig = no_autoconfig;
214 mp->no_onlink = no_onlink;
216 mp->val_lifetime = ntohl (val_lifetime);
217 mp->pref_lifetime = ntohl (pref_lifetime);
222 /* Wait for a reply, return good/bad news */
228 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
230 unformat_input_t *i = vam->input;
231 vl_api_sw_interface_ip6nd_ra_config_t *mp;
233 u8 sw_if_index_set = 0;
241 u8 default_router = 0;
242 u32 max_interval = 0;
243 u32 min_interval = 0;
245 u32 initial_count = 0;
246 u32 initial_interval = 0;
250 /* Parse args required to build the message */
251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
253 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
257 else if (unformat (i, "maxint %d", &max_interval))
259 else if (unformat (i, "minint %d", &min_interval))
261 else if (unformat (i, "life %d", &lifetime))
263 else if (unformat (i, "count %d", &initial_count))
265 else if (unformat (i, "interval %d", &initial_interval))
267 else if (unformat (i, "suppress") || unformat (i, "surpress"))
269 else if (unformat (i, "managed"))
271 else if (unformat (i, "other"))
273 else if (unformat (i, "ll"))
275 else if (unformat (i, "send"))
277 else if (unformat (i, "cease"))
279 else if (unformat (i, "isno"))
281 else if (unformat (i, "def"))
285 clib_warning ("parse error '%U'", format_unformat_error, i);
290 if (sw_if_index_set == 0)
292 errmsg ("missing interface name or sw_if_index");
296 /* Construct the API message */
297 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
299 mp->sw_if_index = ntohl (sw_if_index);
300 mp->max_interval = ntohl (max_interval);
301 mp->min_interval = ntohl (min_interval);
302 mp->lifetime = ntohl (lifetime);
303 mp->initial_count = ntohl (initial_count);
304 mp->initial_interval = ntohl (initial_interval);
305 mp->suppress = suppress;
306 mp->managed = managed;
308 mp->ll_option = ll_option;
309 mp->send_unicast = send_unicast;
312 mp->default_router = default_router;
317 /* Wait for a reply, return good/bad news */
322 #include <ip6-nd/ip6_nd.api_test.c>
325 * fd.io coding-style-patch-verification: ON
328 * eval: (c-set-style "gnu")