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_localsids_dump (vat_main_t *vam)
89 api_sr_policies_dump (vat_main_t *vam)
95 api_sr_policies_with_sl_index_dump (vat_main_t *vam)
101 api_sr_steering_pol_dump (vat_main_t *vam)
107 vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
112 vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
117 vl_api_sr_policies_with_sl_index_details_t_handler (
118 vl_api_sr_policies_with_sl_index_details_t *mp)
123 vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
128 api_sr_localsid_add_del (vat_main_t *vam)
130 unformat_input_t *i = vam->input;
131 vl_api_sr_localsid_add_del_t *mp;
134 ip6_address_t localsid;
138 u32 fib_table = ~(u32) 0;
139 ip46_address_t nh_addr;
140 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
142 bool nexthop_set = 0;
146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
148 if (unformat (i, "del"))
150 else if (unformat (i, "address %U", unformat_ip6_address, &localsid))
152 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
154 else if (unformat (i, "behavior %u", &behavior))
156 else if (unformat (i, "sw_if_index %u", &sw_if_index))
158 else if (unformat (i, "fib-table %u", &fib_table))
160 else if (unformat (i, "end.psp %u", &behavior))
166 M (SR_LOCALSID_ADD_DEL, mp);
168 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
172 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
174 mp->behavior = behavior;
175 mp->sw_if_index = ntohl (sw_if_index);
176 mp->fib_table = ntohl (fib_table);
177 mp->end_psp = end_psp;
185 #include <vnet/srv6/sr.api_test.c>
187 VAT_REGISTER_FEATURE_FUNCTION (vat_sr_plugin_register);
190 * fd.io coding-style-patch-verification: ON
193 * eval: (c-set-style "gnu")