aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagar Srivastav <sagsriva@cisco.com>2016-11-29 19:39:07 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-09 20:12:55 +0000
commitb4bc55b9d7c0b2880d562f7dee3680ced52ecf65 (patch)
tree31d0cd3530879d9f80936e52313610c82bb33ba4
parentd24625fbd1775a45ed0f262faf62cb6452aabb45 (diff)
ioam: pot plugin - pot profile read API
Addition of read API to ioam-pot plugin which returns the current pot profile(s) configured Change-Id: I188e53811391e053860009dde3719612a2446521 Signed-off-by: Sagar Srivastav <sagsriva@cisco.com>
-rw-r--r--plugins/ioam-plugin/ioam/lib-pot/pot.api36
-rw-r--r--plugins/ioam-plugin/ioam/lib-pot/pot_api.c48
-rw-r--r--plugins/ioam-plugin/ioam/lib-pot/pot_test.c56
3 files changed, 137 insertions, 3 deletions
diff --git a/plugins/ioam-plugin/ioam/lib-pot/pot.api b/plugins/ioam-plugin/ioam/lib-pot/pot.api
index 7fd06b512f2..fa2fc126b7e 100644
--- a/plugins/ioam-plugin/ioam/lib-pot/pot.api
+++ b/plugins/ioam-plugin/ioam/lib-pot/pot.api
@@ -95,3 +95,39 @@ define pot_profile_del_reply {
u32 context;
i32 retval;
};
+
+/** \brief Show POT Profiles
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param id - id of the profile
+*/
+define pot_profile_show_config_dump {
+ u32 client_index;
+ u32 context;
+ u8 id;
+};
+
+/** \brief Show POT profile reply
+ @param id - id of the profile
+ @param validator - True/False to indicate if this is verifier
+ @param secret_key - Verification key
+ @param secret_share - Share of the 1st polynomial
+ @param prime - Prime number used for modulo operation
+ @param max_bits - Max bits to be used for Random number generation
+ @param lpc - Lagrange basis polynomial
+ @param polynomial_public - pre-evaluated public polynomial
+ @param list_name_len - length of the name of this profile list
+ @param list_name - name of this profile list
+*/
+define pot_profile_show_config_details {
+ u32 context;
+ i32 retval;
+ u8 id;
+ u8 validator;
+ u64 secret_key;
+ u64 secret_share;
+ u64 prime;
+ u64 bit_mask;
+ u64 lpc;
+ u64 polynomial_public;
+};
diff --git a/plugins/ioam-plugin/ioam/lib-pot/pot_api.c b/plugins/ioam-plugin/ioam/lib-pot/pot_api.c
index f82badf447c..d3af7b4036a 100644
--- a/plugins/ioam-plugin/ioam/lib-pot/pot_api.c
+++ b/plugins/ioam-plugin/ioam/lib-pot/pot_api.c
@@ -83,7 +83,7 @@ do { \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
- rmp->_vl_msg_id = ntohs((t)); \
+ rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
@@ -96,6 +96,7 @@ do { \
_(POT_PROFILE_ADD, pot_profile_add) \
_(POT_PROFILE_ACTIVATE, pot_profile_activate) \
_(POT_PROFILE_DEL, pot_profile_del) \
+_(POT_PROFILE_SHOW_CONFIG_DUMP, pot_profile_show_config_dump) \
static void vl_api_pot_profile_add_t_handler
(vl_api_pot_profile_add_t *mp)
@@ -132,6 +133,51 @@ static void vl_api_pot_profile_add_t_handler
REPLY_MACRO(VL_API_POT_PROFILE_ADD_REPLY);
}
+static void send_pot_profile_details(vl_api_pot_profile_show_config_dump_t *mp, u8 id)
+{
+ vl_api_pot_profile_show_config_details_t * rmp;
+ pot_main_t * sm = &pot_main;
+ pot_profile *profile = pot_profile_find(id);
+ int rv = 0;
+ if(profile){
+ REPLY_MACRO2(VL_API_POT_PROFILE_SHOW_CONFIG_DETAILS,
+ rmp->id=id;
+ rmp->validator=profile->validator;
+ rmp->secret_key=clib_host_to_net_u64(profile->secret_key);
+ rmp->secret_share=clib_host_to_net_u64(profile->secret_share);
+ rmp->prime=clib_host_to_net_u64(profile->prime);
+ rmp->bit_mask=clib_host_to_net_u64(profile->bit_mask);
+ rmp->lpc=clib_host_to_net_u64(profile->lpc);
+ rmp->polynomial_public=clib_host_to_net_u64(profile->poly_pre_eval);
+ );
+ }
+ else{
+ REPLY_MACRO2(VL_API_POT_PROFILE_SHOW_CONFIG_DETAILS,
+ rmp->id=id;
+ rmp->validator=0;
+ rmp->secret_key=0;
+ rmp->secret_share=0;
+ rmp->prime=0;
+ rmp->bit_mask=0;
+ rmp->lpc=0;
+ rmp->polynomial_public=0;
+ );
+ }
+}
+
+static void vl_api_pot_profile_show_config_dump_t_handler
+(vl_api_pot_profile_show_config_dump_t *mp)
+{
+ u8 id = mp->id;
+ u8 dump_call_id = ~0;
+ if(dump_call_id==id){
+ for(id=0;id<MAX_POT_PROFILES;id++)
+ send_pot_profile_details(mp,id);
+ }
+ else
+ send_pot_profile_details(mp,id);
+}
+
static void vl_api_pot_profile_activate_t_handler
(vl_api_pot_profile_activate_t *mp)
{
diff --git a/plugins/ioam-plugin/ioam/lib-pot/pot_test.c b/plugins/ioam-plugin/ioam/lib-pot/pot_test.c
index 8e728cea325..2e87023896e 100644
--- a/plugins/ioam-plugin/ioam/lib-pot/pot_test.c
+++ b/plugins/ioam-plugin/ioam/lib-pot/pot_test.c
@@ -63,6 +63,18 @@ _(pot_profile_add_reply) \
_(pot_profile_activate_reply) \
_(pot_profile_del_reply)
+#define foreach_custom_reply_retval_handler \
+_(pot_profile_show_config_details, \
+ errmsg(" ID:%d\n",mp->id); \
+ errmsg(" Validator:%d\n",mp->validator); \
+ errmsg(" secret_key:%Lx\n",clib_net_to_host_u64(mp->secret_key)); \
+ errmsg(" secret_share:%Lx\n",clib_net_to_host_u64(mp->secret_share)); \
+ errmsg(" prime:%Lx\n",clib_net_to_host_u64(mp->prime)); \
+ errmsg(" bitmask:%Lx\n",clib_net_to_host_u64(mp->bit_mask)); \
+ errmsg(" lpc:%Lx\n",clib_net_to_host_u64(mp->lpc)); \
+ errmsg(" public poly:%Lx\n",clib_net_to_host_u64(mp->polynomial_public)); \
+ )
+
#define _(n) \
static void vl_api_##n##_t_handler \
(vl_api_##n##_t * mp) \
@@ -79,6 +91,23 @@ _(pot_profile_del_reply)
foreach_standard_reply_retval_handler;
#undef _
+#define _(n,body) \
+ static void vl_api_##n##_t_handler \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = pot_test_main.vat_main; \
+ i32 retval = ntohl(mp->retval); \
+ if (vam->async_mode) { \
+ vam->async_errors += (retval < 0); \
+ } else { \
+ vam->retval = retval; \
+ vam->result_ready = 1; \
+ } \
+ do{body;}while(0); \
+ }
+foreach_custom_reply_retval_handler;
+#undef _
+
/*
* Table of message reply handlers, must include boilerplate handlers
* we just generated
@@ -87,6 +116,7 @@ foreach_standard_reply_retval_handler;
_(POT_PROFILE_ADD_REPLY, pot_profile_add_reply) \
_(POT_PROFILE_ACTIVATE_REPLY, pot_profile_activate_reply) \
_(POT_PROFILE_DEL_REPLY, pot_profile_del_reply) \
+_(POT_PROFILE_SHOW_CONFIG_DETAILS, pot_profile_show_config_details)
/* M: construct, but don't yet send a message */
@@ -255,6 +285,28 @@ static int api_pot_profile_del (vat_main_t *vam)
return 0;
}
+static int api_pot_profile_show_config_dump (vat_main_t *vam)
+{
+ pot_test_main_t * sm = &pot_test_main;
+ unformat_input_t *input = vam->input;
+ vl_api_pot_profile_show_config_dump_t *mp;
+ f64 timeout;
+ u8 id = 0;
+
+ while(unformat_check_input(input) != UNFORMAT_END_OF_INPUT)
+ {
+ if(unformat(input,"id %d",&id));
+ else
+ break;
+ }
+ M(POT_PROFILE_SHOW_CONFIG_DUMP, pot_profile_show_config_dump);
+
+ mp->id = id;
+
+ S; W;
+ return 0;
+}
+
/*
* List of messages that the api test plugin sends,
* and that the data plane plugin processes
@@ -266,7 +318,7 @@ _(pot_profile_add, "name <name> id [0-1] " \
"[validator-key <0xu64>] [validity <0xu64>]") \
_(pot_profile_activate, "name <name> id [0-1] ") \
_(pot_profile_del, "[id <nn>]") \
-
+_(pot_profile_show_config_dump, "id [0-1]")
void vat_api_hookup (vat_main_t *vam)
{
@@ -301,7 +353,7 @@ clib_error_t * vat_plugin_register (vat_main_t *vam)
sm->vat_main = vam;
- name = format (0, "pot_%08x%c", api_version, 0);
+ name = format (0, "ioam_pot_%08x%c", api_version, 0);
sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
if (sm->msg_id_base != (u16) ~0)