2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 *------------------------------------------------------------------
17 * pot_test.c - test harness for pot plugin
18 *------------------------------------------------------------------
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
25 #include <vppinfra/error.h>
27 #define __plugin_msg_base pot_test_main.msg_id_base
28 #include <vlibapi/vat_helper_macros.h>
30 /* Declare message IDs */
31 #include <ioam/lib-pot/pot.api_enum.h>
32 #include <ioam/lib-pot/pot.api_types.h>
35 /* API message ID base */
40 pot_test_main_t pot_test_main;
42 static int api_pot_profile_add (vat_main_t *vam)
45 unformat_input_t *input = vam->input;
46 vl_api_pot_profile_add_t *mp;
52 u64 lpc = 0, poly2 = 0;
57 while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
59 if (unformat(input, "name %s", &name))
61 else if(unformat(input, "id %d", &id))
63 else if (unformat(input, "validator-key 0x%Lx", &secret_key))
65 else if (unformat(input, "prime-number 0x%Lx", &prime))
67 else if (unformat(input, "secret-share 0x%Lx", &secret_share))
69 else if (unformat(input, "polynomial-public 0x%Lx", &poly2))
71 else if (unformat(input, "lpc 0x%Lx", &lpc))
73 else if (unformat(input, "bits-in-random %u", &bits))
84 errmsg ("name required\n");
89 M2(POT_PROFILE_ADD, mp, sizeof(vl_api_string_t) + vec_len(name));
91 vl_api_to_api_string(vec_len(name), (const char *)name, &mp->list_name);
92 mp->secret_share = clib_host_to_net_u64(secret_share);
93 mp->polynomial_public = clib_host_to_net_u64(poly2);
94 mp->lpc = clib_host_to_net_u64(lpc);
95 mp->prime = clib_host_to_net_u64(prime);
98 mp->secret_key = clib_host_to_net_u64(secret_key);
117 static int api_pot_profile_activate (vat_main_t *vam)
120 unformat_input_t *input = vam->input;
121 vl_api_pot_profile_activate_t *mp;
127 while (unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
129 if (unformat(input, "name %s", &name))
131 else if(unformat(input, "id %d", &id))
139 errmsg ("name required\n");
144 M2(POT_PROFILE_ACTIVATE, mp, sizeof(vl_api_string_t) + vec_len(name));
145 vl_api_to_api_string(vec_len(name), (const char *)name, &mp->list_name);
158 static int api_pot_profile_del (vat_main_t *vam)
160 vl_api_pot_profile_del_t *mp;
163 M(POT_PROFILE_DEL, mp);
169 static int api_pot_profile_show_config_dump (vat_main_t *vam)
171 unformat_input_t *input = vam->input;
172 vl_api_pot_profile_show_config_dump_t *mp;
176 while(unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
178 if(unformat(input,"id %d",&id));
182 M(POT_PROFILE_SHOW_CONFIG_DUMP, mp);
190 static int vl_api_pot_profile_show_config_details_t_handler (vat_main_t *vam)
195 /* Override generated plugin register symbol */
196 #define vat_plugin_register pot_vat_plugin_register
197 #include <ioam/lib-pot/pot.api_test.c>