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>
23 #define __plugin_msg_base sr_mpls_test_main.msg_id_base
24 #include <vlibapi/vat_helper_macros.h>
26 /* Declare message IDs */
27 #include <vnet/format_fns.h>
28 #include <vnet/srmpls/sr_mpls.api_enum.h>
29 #include <vnet/srmpls/sr_mpls.api_types.h>
31 #define vl_endianfun /* define message structures */
32 #include <vnet/srmpls/sr_mpls.api.h>
37 /* API message ID base */
41 } sr_mpls_test_main_t;
43 static sr_mpls_test_main_t sr_mpls_test_main;
46 api_sr_mpls_policy_mod (vat_main_t *vam)
52 api_sr_mpls_steering_add_del (vat_main_t *vam)
58 api_sr_mpls_policy_assign_endpoint_color (vat_main_t *vam)
64 api_sr_mpls_policy_add (vat_main_t *vam)
66 unformat_input_t *i = vam->input;
67 vl_api_sr_mpls_policy_add_t *mp;
76 /* Parse args required to build the message */
77 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
79 if (unformat (i, "bsid %d", &bsid))
81 else if (unformat (i, "weight %d", &weight))
83 else if (unformat (i, "spray"))
85 else if (unformat (i, "next %d", &sid))
88 vec_add1 (segments, htonl (sid));
92 clib_warning ("parse error '%U'", format_unformat_error, i);
99 errmsg ("bsid not set");
105 errmsg ("no sid in segment stack");
109 /* Construct the API message */
110 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
112 mp->bsid = htonl (bsid);
113 mp->weight = htonl (weight);
115 mp->n_segments = n_segments;
116 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
122 /* Wait for a reply... */
128 api_sr_mpls_policy_del (vat_main_t *vam)
130 unformat_input_t *i = vam->input;
131 vl_api_sr_mpls_policy_del_t *mp;
135 /* Parse args required to build the message */
136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
138 if (unformat (i, "bsid %d", &bsid))
142 clib_warning ("parse error '%U'", format_unformat_error, i);
149 errmsg ("bsid not set");
153 /* Construct the API message */
154 M (SR_MPLS_POLICY_DEL, mp);
156 mp->bsid = htonl (bsid);
161 /* Wait for a reply... */
166 #include <vnet/srmpls/sr_mpls.api_test.c>
169 * fd.io coding-style-patch-verification: ON
172 * eval: (c-set-style "gnu")