blob: be898599e966995c50c129e7ff00ae94318584fe [file] [log] [blame]
Filip Tehlar850024b2021-09-02 10:32:40 +00001/*
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:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 *------------------------------------------------------------------
16 */
17#include <vat/vat.h>
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>
23
24#define __plugin_msg_base sr_test_main.msg_id_base
25#include <vlibapi/vat_helper_macros.h>
26
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>
31
32#define vl_endianfun /* define message structures */
33#include <vnet/srv6/sr.api.h>
34#undef vl_endianfun
35
36typedef struct
37{
38 /* API message ID base */
39 u16 msg_id_base;
40 u32 ping_id;
41 vat_main_t *vat_main;
42} sr_test_main_t;
43
44static sr_test_main_t sr_test_main;
45
46static int
47api_sr_steering_add_del (vat_main_t *vam)
48{
49 return -1;
50}
51
52static int
53api_sr_set_encap_hop_limit (vat_main_t *vam)
54{
55 return -1;
56}
57
58static int
59api_sr_set_encap_source (vat_main_t *vam)
60{
61 return -1;
62}
63
64static int
65api_sr_policy_del (vat_main_t *vam)
66{
67 return -1;
68}
69
70static int
71api_sr_policy_mod (vat_main_t *vam)
72{
73 return -1;
74}
75
76static int
77api_sr_policy_add (vat_main_t *vam)
78{
79 return -1;
80}
81
82static int
Takeru Hayasakac4c205b2022-12-30 16:41:44 +090083api_sr_policy_mod_v2 (vat_main_t *vam)
84{
85 return -1;
86}
87
88static int
89api_sr_policy_add_v2 (vat_main_t *vam)
90{
91 return -1;
92}
93
94static int
Filip Tehlar850024b2021-09-02 10:32:40 +000095api_sr_localsids_dump (vat_main_t *vam)
96{
97 return -1;
98}
99
100static int
101api_sr_policies_dump (vat_main_t *vam)
102{
103 return -1;
104}
105
106static int
Takeru Hayasakac4c205b2022-12-30 16:41:44 +0900107api_sr_policies_v2_dump (vat_main_t *vam)
108{
109 return -1;
110}
111
112static int
Filip Tehlar850024b2021-09-02 10:32:40 +0000113api_sr_policies_with_sl_index_dump (vat_main_t *vam)
114{
115 return -1;
116}
117
118static int
119api_sr_steering_pol_dump (vat_main_t *vam)
120{
121 return -1;
122}
123
124static void
125vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
126{
127}
128
129static void
Takeru Hayasakac4c205b2022-12-30 16:41:44 +0900130vl_api_sr_policies_v2_details_t_handler (vl_api_sr_policies_v2_details_t *mp)
131{
132}
133
134static void
Filip Tehlar850024b2021-09-02 10:32:40 +0000135vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
136{
137}
138
139static void
140vl_api_sr_policies_with_sl_index_details_t_handler (
141 vl_api_sr_policies_with_sl_index_details_t *mp)
142{
143}
144
145static void
146vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
147{
148}
149
150static int
151api_sr_localsid_add_del (vat_main_t *vam)
152{
153 unformat_input_t *i = vam->input;
154 vl_api_sr_localsid_add_del_t *mp;
155
156 u8 is_del;
157 ip6_address_t localsid;
158 u8 end_psp = 0;
159 u8 behavior = ~0;
160 u32 sw_if_index;
161 u32 fib_table = ~(u32) 0;
162 ip46_address_t nh_addr;
163 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
164
165 bool nexthop_set = 0;
166
167 int ret;
168
169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
170 {
171 if (unformat (i, "del"))
172 is_del = 1;
173 else if (unformat (i, "address %U", unformat_ip6_address, &localsid))
174 ;
175 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
176 nexthop_set = 1;
177 else if (unformat (i, "behavior %u", &behavior))
178 ;
179 else if (unformat (i, "sw_if_index %u", &sw_if_index))
180 ;
181 else if (unformat (i, "fib-table %u", &fib_table))
182 ;
183 else if (unformat (i, "end.psp %u", &behavior))
184 ;
185 else
186 break;
187 }
188
189 M (SR_LOCALSID_ADD_DEL, mp);
190
191 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
192
193 if (nexthop_set)
194 {
195 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
196 }
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;
201 mp->is_del = is_del;
202
203 S (mp);
204 W (ret);
205 return ret;
206}
207
208#include <vnet/srv6/sr.api_test.c>
209
210VAT_REGISTER_FEATURE_FUNCTION (vat_sr_plugin_register);
211
212/*
213 * fd.io coding-style-patch-verification: ON
214 *
215 * Local Variables:
216 * eval: (c-set-style "gnu")
217 * End:
218 */