2 *------------------------------------------------------------------
3 * Copyright (c) 2021 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
21 #include <vpp/api/types.h>
22 #include <vnet/ip/ip_types_api.h>
24 #define __plugin_msg_base sr_test_main.msg_id_base
25 #include <vlibapi/vat_helper_macros.h>
27 /* Declare message IDs */
28 #include <vnet/format_fns.h>
29 #include <vnet/srv6/sr.api_enum.h>
30 #include <vnet/srv6/sr.api_types.h>
32 #define vl_endianfun /* define message structures */
33 #include <vnet/srv6/sr.api.h>
38 /* API message ID base */
44 static sr_test_main_t sr_test_main;
47 api_sr_steering_add_del (vat_main_t *vam)
53 api_sr_set_encap_hop_limit (vat_main_t *vam)
59 api_sr_set_encap_source (vat_main_t *vam)
65 api_sr_policy_del (vat_main_t *vam)
71 api_sr_policy_mod (vat_main_t *vam)
77 api_sr_policy_add (vat_main_t *vam)
83 api_sr_policy_mod_v2 (vat_main_t *vam)
89 api_sr_policy_add_v2 (vat_main_t *vam)
95 api_sr_localsids_dump (vat_main_t *vam)
101 api_sr_policies_dump (vat_main_t *vam)
107 api_sr_policies_v2_dump (vat_main_t *vam)
113 api_sr_policies_with_sl_index_dump (vat_main_t *vam)
119 api_sr_steering_pol_dump (vat_main_t *vam)
125 vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
130 vl_api_sr_policies_v2_details_t_handler (vl_api_sr_policies_v2_details_t *mp)
135 vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
140 vl_api_sr_policies_with_sl_index_details_t_handler (
141 vl_api_sr_policies_with_sl_index_details_t *mp)
146 vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
151 api_sr_localsid_add_del (vat_main_t *vam)
153 unformat_input_t *i = vam->input;
154 vl_api_sr_localsid_add_del_t *mp;
157 ip6_address_t localsid;
161 u32 fib_table = ~(u32) 0;
162 ip46_address_t nh_addr;
163 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
165 bool nexthop_set = 0;
169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
171 if (unformat (i, "del"))
173 else if (unformat (i, "address %U", unformat_ip6_address, &localsid))
175 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
177 else if (unformat (i, "behavior %u", &behavior))
179 else if (unformat (i, "sw_if_index %u", &sw_if_index))
181 else if (unformat (i, "fib-table %u", &fib_table))
183 else if (unformat (i, "end.psp %u", &behavior))
189 M (SR_LOCALSID_ADD_DEL, mp);
191 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
195 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
197 mp->behavior = behavior;
198 mp->sw_if_index = ntohl (sw_if_index);
199 mp->fib_table = ntohl (fib_table);
200 mp->end_psp = end_psp;
208 #include <vnet/srv6/sr.api_test.c>
210 VAT_REGISTER_FEATURE_FUNCTION (vat_sr_plugin_register);
213 * fd.io coding-style-patch-verification: ON
216 * eval: (c-set-style "gnu")