blob: 85f64e1e2304d8c501b189efee7addcf57a22d00 [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
83api_sr_localsids_dump (vat_main_t *vam)
84{
85 return -1;
86}
87
88static int
89api_sr_policies_dump (vat_main_t *vam)
90{
91 return -1;
92}
93
94static int
95api_sr_policies_with_sl_index_dump (vat_main_t *vam)
96{
97 return -1;
98}
99
100static int
101api_sr_steering_pol_dump (vat_main_t *vam)
102{
103 return -1;
104}
105
106static void
107vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
108{
109}
110
111static void
112vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
113{
114}
115
116static void
117vl_api_sr_policies_with_sl_index_details_t_handler (
118 vl_api_sr_policies_with_sl_index_details_t *mp)
119{
120}
121
122static void
123vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
124{
125}
126
127static int
128api_sr_localsid_add_del (vat_main_t *vam)
129{
130 unformat_input_t *i = vam->input;
131 vl_api_sr_localsid_add_del_t *mp;
132
133 u8 is_del;
134 ip6_address_t localsid;
135 u8 end_psp = 0;
136 u8 behavior = ~0;
137 u32 sw_if_index;
138 u32 fib_table = ~(u32) 0;
139 ip46_address_t nh_addr;
140 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
141
142 bool nexthop_set = 0;
143
144 int ret;
145
146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
147 {
148 if (unformat (i, "del"))
149 is_del = 1;
150 else if (unformat (i, "address %U", unformat_ip6_address, &localsid))
151 ;
152 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
153 nexthop_set = 1;
154 else if (unformat (i, "behavior %u", &behavior))
155 ;
156 else if (unformat (i, "sw_if_index %u", &sw_if_index))
157 ;
158 else if (unformat (i, "fib-table %u", &fib_table))
159 ;
160 else if (unformat (i, "end.psp %u", &behavior))
161 ;
162 else
163 break;
164 }
165
166 M (SR_LOCALSID_ADD_DEL, mp);
167
168 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
169
170 if (nexthop_set)
171 {
172 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
173 }
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;
178 mp->is_del = is_del;
179
180 S (mp);
181 W (ret);
182 return ret;
183}
184
185#include <vnet/srv6/sr.api_test.c>
186
187VAT_REGISTER_FEATURE_FUNCTION (vat_sr_plugin_register);
188
189/*
190 * fd.io coding-style-patch-verification: ON
191 *
192 * Local Variables:
193 * eval: (c-set-style "gnu")
194 * End:
195 */