tls: init session for accepted ctx
[vpp.git] / src / vnet / srv6 / sr_test.c
1 /*
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
36 typedef 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
44 static sr_test_main_t sr_test_main;
45
46 static int
47 api_sr_steering_add_del (vat_main_t *vam)
48 {
49   return -1;
50 }
51
52 static int
53 api_sr_set_encap_hop_limit (vat_main_t *vam)
54 {
55   return -1;
56 }
57
58 static int
59 api_sr_set_encap_source (vat_main_t *vam)
60 {
61   return -1;
62 }
63
64 static int
65 api_sr_policy_del (vat_main_t *vam)
66 {
67   return -1;
68 }
69
70 static int
71 api_sr_policy_mod (vat_main_t *vam)
72 {
73   return -1;
74 }
75
76 static int
77 api_sr_policy_add (vat_main_t *vam)
78 {
79   return -1;
80 }
81
82 static int
83 api_sr_policy_mod_v2 (vat_main_t *vam)
84 {
85   return -1;
86 }
87
88 static int
89 api_sr_policy_add_v2 (vat_main_t *vam)
90 {
91   return -1;
92 }
93
94 static int
95 api_sr_localsids_dump (vat_main_t *vam)
96 {
97   return -1;
98 }
99
100 static int
101 api_sr_policies_dump (vat_main_t *vam)
102 {
103   return -1;
104 }
105
106 static int
107 api_sr_policies_v2_dump (vat_main_t *vam)
108 {
109   return -1;
110 }
111
112 static int
113 api_sr_policies_with_sl_index_dump (vat_main_t *vam)
114 {
115   return -1;
116 }
117
118 static int
119 api_sr_steering_pol_dump (vat_main_t *vam)
120 {
121   return -1;
122 }
123
124 static void
125 vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
126 {
127 }
128
129 static void
130 vl_api_sr_policies_v2_details_t_handler (vl_api_sr_policies_v2_details_t *mp)
131 {
132 }
133
134 static void
135 vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
136 {
137 }
138
139 static void
140 vl_api_sr_policies_with_sl_index_details_t_handler (
141   vl_api_sr_policies_with_sl_index_details_t *mp)
142 {
143 }
144
145 static void
146 vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
147 {
148 }
149
150 static int
151 api_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
210 VAT_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  */