diff options
author | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-04-07 11:43:39 +0200 |
---|---|---|
committer | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-05-04 11:16:59 +0200 |
commit | c61e2e149421b849888bea0239c50607edce35ac (patch) | |
tree | f1191d338c9e27c77484c0d8bed6118c6d4612b6 /ctrl | |
parent | dee66271e7f84cb756dae31d154982d5b6bb9807 (diff) |
[HICN-590] Removed andjacency type specific face implementation
Changes in the new implementation are:
- the adjacency index is replaced with a dpo that allows the single face node
to dispatch the packet to the right vlib node.
- local and remote address in the face are replaced with a single nat address
which is used to perform the nat operation when rewriting an interest or a
data (in case of tunnels the nat address will be equal to 0)
- the list of next hop in the load balance is no longer a list of dpos but
a list of face id (this makes the code easier and increases the number of
next hop we supports)
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Change-Id: I4ac2b4eb09425bfe1b3ca9f82d7d0ff564297b0d
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/libhicnctrl/src/hicn_plugin_api.c | 506 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c | 143 |
2 files changed, 265 insertions, 384 deletions
diff --git a/ctrl/libhicnctrl/src/hicn_plugin_api.c b/ctrl/libhicnctrl/src/hicn_plugin_api.c index 406f43404..63509312a 100644 --- a/ctrl/libhicnctrl/src/hicn_plugin_api.c +++ b/ctrl/libhicnctrl/src/hicn_plugin_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2017-2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -94,10 +94,6 @@ struct hc_sock_s { _(hicn_api_node_params_set_reply) \ _(hicn_api_node_params_get_reply) \ _(hicn_api_node_stats_get_reply) \ - _(hicn_api_face_add) \ - _(hicn_api_face_add_reply) \ - _(hicn_api_face_del) \ - _(hicn_api_face_del_reply) \ _(hicn_api_face_get) \ _(hicn_api_faces_details) \ _(hicn_api_face_stats_details) \ @@ -115,6 +111,7 @@ struct hc_sock_s { _(hicn_api_strategy_get) \ _(hicn_api_strategy_get_reply) + typedef vapi_type_msg_header2_t hc_msg_header_t; typedef union { @@ -881,277 +878,282 @@ int hc_connection_to_local_listener(const hc_connection_t *connection, } /* FACE CREATE */ -vapi_error_e parse_face_create( vapi_ctx_t ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_face_add_reply *reply) { +// vapi_error_e parse_face_create( vapi_ctx_t ctx, +// void *callback_ctx, +// vapi_error_e rv, +// bool is_last, +// vapi_payload_hicn_api_face_add_reply *reply) { - if (reply == NULL || rv != VAPI_OK) - return rv; +// if (reply == NULL || rv != VAPI_OK) +// return rv; - if (reply->retval != VAPI_OK) - return reply->retval; +// if (reply->retval != VAPI_OK) +// return reply->retval; - hc_data_t *data = (hc_data_t *)callback_ctx; +// hc_data_t *data = (hc_data_t *)callback_ctx; - hc_face_t *output = (hc_face_t *)data->buffer; +// hc_face_t *output = (hc_face_t *)data->buffer; - output->id = reply->faceid; - return reply->retval; -} +// output->id = reply->faceid; +// return reply->retval; +// } int hc_face_create(hc_sock_t *s, hc_face_t *face) { - vapi_lock(); - vapi_msg_hicn_api_face_add *hicnp_msg; - hicnp_msg = vapi_alloc_hicn_api_face_add(s->g_vapi_ctx_instance); - - int retval = VAPI_OK; - if (!hicnp_msg) { - retval = VAPI_ENOMEM; - goto END; - } - - switch(face->face.type) { - case FACE_TYPE_HICN: - { - u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr)); - if (!check) { - retval = -1; - goto END; - } - - hicnp_msg->payload.type = IP_FACE; - if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr))) - { - memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4); - memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4); - hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP4; - hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP4; - } - else - { - memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16); - memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16); - hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP6; - hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP6; - } - hicnp_msg->payload.face.ip.swif = face->face.netdevice.index; - memcpy(hicnp_msg->payload.face.ip.if_name, face->face.netdevice.name, IFNAMSIZ); - break; - } - case FACE_TYPE_UDP: - { - u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr)); - if (!check) { - retval = -1; - goto END; - } - - hicnp_msg->payload.type = UDP_FACE; - if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr))) - { - memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4); - memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4); - hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP4; - hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP4; - } - else - { - memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16); - memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16); - hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP6; - hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP6; - } - hicnp_msg->payload.face.udp.lport = face->face.local_port; - hicnp_msg->payload.face.udp.rport = face->face.remote_port; - hicnp_msg->payload.face.udp.swif = face->face.netdevice.index; - memcpy(hicnp_msg->payload.face.udp.if_name, face->face.netdevice.name, IFNAMSIZ); - break; - } - default: - { - retval = -1; - goto END; - } - } - - hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL); - - if (!data) { - retval = -1; - goto END; - } - - data->buffer = malloc(sizeof(hc_face_t)); - data->out_element_size = sizeof(hc_face_t); - - if (!data->buffer) { - free (data); - retval = -1; - goto END; - } - - retval = vapi_hicn_api_face_add(s->g_vapi_ctx_instance, hicnp_msg, parse_face_create, data); - - if (retval != VAPI_OK) - goto END; - - face->id = ((hc_face_t *)data->buffer)->id; - - END: - vapi_unlock(); - return retval; + // vapi_lock(); + // vapi_msg_hicn_api_face_add *hicnp_msg; + // hicnp_msg = vapi_alloc_hicn_api_face_add(s->g_vapi_ctx_instance); + + // int retval = VAPI_OK; +// if (!hicnp_msg) { +// retval = VAPI_ENOMEM; +// goto END; +// } + +// switch(face->face.type) { +// case FACE_TYPE_HICN: +// { +// u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr)); +// if (!check) { +// retval = -1; +// goto END; +// } + +// hicnp_msg->payload.type = IP_FACE; +// if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr))) +// { +// memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4); +// memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4); +// hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP4; +// hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP4; +// } +// else +// { +// memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16); +// memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16); +// hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP6; +// hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP6; +// } +// hicnp_msg->payload.face.ip.swif = face->face.netdevice.index; +// memcpy(hicnp_msg->payload.face.ip.if_name, face->face.netdevice.name, IFNAMSIZ); +// break; +// } +// case FACE_TYPE_UDP: +// { +// u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr)); +// if (!check) { +// retval = -1; +// goto END; +// } + +// hicnp_msg->payload.type = UDP_FACE; +// if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr))) +// { +// memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4); +// memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4); +// hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP4; +// hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP4; +// } +// else +// { +// memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16); +// memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16); +// hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP6; +// hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP6; +// } +// hicnp_msg->payload.face.udp.lport = face->face.local_port; +// hicnp_msg->payload.face.udp.rport = face->face.remote_port; +// hicnp_msg->payload.face.udp.swif = face->face.netdevice.index; +// memcpy(hicnp_msg->payload.face.udp.if_name, face->face.netdevice.name, IFNAMSIZ); +// break; +// } +// default: +// { +// retval = -1; +// goto END; +// } +// } + +// hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL); + +// if (!data) { +// retval = -1; +// goto END; +// } + +// data->buffer = malloc(sizeof(hc_face_t)); +// data->out_element_size = sizeof(hc_face_t); + +// if (!data->buffer) { +// free (data); +// retval = -1; +// goto END; +// } + +// retval = vapi_hicn_api_face_add(s->g_vapi_ctx_instance, hicnp_msg, parse_face_create, data); + +// if (retval != VAPI_OK) +// goto END; + +// face->id = ((hc_face_t *)data->buffer)->id; + +// END: +// vapi_unlock(); + ERROR("hc_punting_snprintf not (yet) implemented."); + return -1; } -vapi_error_e parse_face_delete( vapi_ctx_t ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_face_del_reply *reply) { +// vapi_error_e parse_face_delete( vapi_ctx_t ctx, +// void *callback_ctx, +// vapi_error_e rv, +// bool is_last, +// vapi_payload_hicn_api_face_del_reply *reply) { - if (reply == NULL || rv != VAPI_OK) - return rv; +// if (reply == NULL || rv != VAPI_OK) +// return rv; - return reply->retval; -} +// return reply->retval; +// } int hc_face_delete(hc_sock_t *s, hc_face_t *face) { - vapi_msg_hicn_api_face_del *hicnp_msg; - vapi_lock(); - hicnp_msg = vapi_alloc_hicn_api_face_del(s->g_vapi_ctx_instance); + // vapi_msg_hicn_api_face_del *hicnp_msg; + // vapi_lock(); + // hicnp_msg = vapi_alloc_hicn_api_face_del(s->g_vapi_ctx_instance); - if (!hicnp_msg) return VAPI_ENOMEM; + // if (!hicnp_msg) return VAPI_ENOMEM; - hicnp_msg->payload.faceid = face->id; + // hicnp_msg->payload.faceid = face->id; - int retval = vapi_hicn_api_face_del(s->g_vapi_ctx_instance, hicnp_msg, parse_face_delete, NULL); - vapi_unlock(); - return retval; + // int retval = vapi_hicn_api_face_del(s->g_vapi_ctx_instance, hicnp_msg, parse_face_delete, NULL); + // vapi_unlock(); + // return retval; + ERROR("hc_punting_snprintf not (yet) implemented."); + return -1; } /* FACE LIST */ -vapi_error_e parse_face_list( vapi_ctx_t ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_faces_details *reply) { - - if (reply == NULL || rv != VAPI_OK) - return rv; - - if (reply->retval != VAPI_OK) - return reply->retval; - - hc_data_t *data = (hc_data_t *)callback_ctx; - - if (data->size == data->current) { - int new_size = data->size *2; - data->buffer = realloc(data->buffer, sizeof(hc_face_t) * (new_size)); - if (!data->buffer) - return VAPI_ENOMEM; - - data->size =new_size; - } - - int retval = VAPI_OK; - - hc_face_t * face = &((hc_face_t *)(data->buffer))[data->current]; - switch(reply->type) - { - case IP_FACE: - { - if (reply->face.ip.local_addr.af == ADDRESS_IP4) - { - memcpy(face->face.local_addr.v4.as_u8, reply->face.ip.local_addr.un.ip4, IPV4_ADDR_LEN); - memcpy(face->face.remote_addr.v4.as_u8, reply->face.ip.remote_addr.un.ip4, IPV4_ADDR_LEN); - } - else - { - memcpy(face->face.local_addr.v6.as_u8, reply->face.ip.local_addr.un.ip6, IPV6_ADDR_LEN); - memcpy(face->face.remote_addr.v6.as_u8, reply->face.ip.remote_addr.un.ip6, IPV6_ADDR_LEN); - } - face->face.type = FACE_TYPE_HICN; - face->id = reply->faceid; - face->face.netdevice.index = reply->face.ip.swif; - memcpy(face->face.netdevice.name, reply->face.ip.if_name, IFNAMSIZ); - break; - } - case UDP_FACE: - { - if (reply->face.ip.local_addr.af == ADDRESS_IP4) - { - memcpy(face->face.local_addr.v4.as_u8, reply->face.udp.local_addr.un.ip4, IPV4_ADDR_LEN); - memcpy(face->face.remote_addr.v4.as_u8, reply->face.udp.remote_addr.un.ip4, IPV4_ADDR_LEN); - } - else - { - memcpy(face->face.local_addr.v6.as_u8, reply->face.udp.local_addr.un.ip6, IPV6_ADDR_LEN); - memcpy(face->face.remote_addr.v6.as_u8, reply->face.udp.remote_addr.un.ip6, IPV6_ADDR_LEN); - } - face->face.local_port = reply->face.udp.lport; - face->face.remote_port = reply->face.udp.rport; - face->face.type = FACE_TYPE_UDP; - face->id = reply->faceid; - face->face.netdevice.index = reply->face.udp.swif; - memcpy(face->face.netdevice.name, reply->face.udp.if_name, IFNAMSIZ); - break; - } - default: - retval = -1; - } - if (!retval) - data->current++; - - return reply->retval; -} +// vapi_error_e parse_face_list( vapi_ctx_t ctx, +// void *callback_ctx, +// vapi_error_e rv, +// bool is_last, +// vapi_payload_hicn_api_faces_details *reply) { + +// if (reply == NULL || rv != VAPI_OK) +// return rv; + +// if (reply->retval != VAPI_OK) +// return reply->retval; + +// hc_data_t *data = (hc_data_t *)callback_ctx; + +// if (data->size == data->current) { +// int new_size = data->size *2; +// data->buffer = realloc(data->buffer, sizeof(hc_face_t) * (new_size)); +// if (!data->buffer) +// return VAPI_ENOMEM; + +// data->size =new_size; +// } + +// int retval = VAPI_OK; + +// hc_face_t * face = &((hc_face_t *)(data->buffer))[data->current]; +// switch(reply->type) +// { +// case IP_FACE: +// { +// if (reply->face.ip.local_addr.af == ADDRESS_IP4) +// { +// memcpy(face->face.local_addr.v4.as_u8, reply->face.ip.local_addr.un.ip4, IPV4_ADDR_LEN); +// memcpy(face->face.remote_addr.v4.as_u8, reply->face.ip.remote_addr.un.ip4, IPV4_ADDR_LEN); +// } +// else +// { +// memcpy(face->face.local_addr.v6.as_u8, reply->face.ip.local_addr.un.ip6, IPV6_ADDR_LEN); +// memcpy(face->face.remote_addr.v6.as_u8, reply->face.ip.remote_addr.un.ip6, IPV6_ADDR_LEN); +// } +// face->face.type = FACE_TYPE_HICN; +// face->id = reply->faceid; +// face->face.netdevice.index = reply->face.ip.swif; +// memcpy(face->face.netdevice.name, reply->face.ip.if_name, IFNAMSIZ); +// break; +// } +// case UDP_FACE: +// { +// if (reply->face.ip.local_addr.af == ADDRESS_IP4) +// { +// memcpy(face->face.local_addr.v4.as_u8, reply->face.udp.local_addr.un.ip4, IPV4_ADDR_LEN); +// memcpy(face->face.remote_addr.v4.as_u8, reply->face.udp.remote_addr.un.ip4, IPV4_ADDR_LEN); +// } +// else +// { +// memcpy(face->face.local_addr.v6.as_u8, reply->face.udp.local_addr.un.ip6, IPV6_ADDR_LEN); +// memcpy(face->face.remote_addr.v6.as_u8, reply->face.udp.remote_addr.un.ip6, IPV6_ADDR_LEN); +// } +// face->face.local_port = reply->face.udp.lport; +// face->face.remote_port = reply->face.udp.rport; +// face->face.type = FACE_TYPE_UDP; +// face->id = reply->faceid; +// face->face.netdevice.index = reply->face.udp.swif; +// memcpy(face->face.netdevice.name, reply->face.udp.if_name, IFNAMSIZ); +// break; +// } +// default: +// retval = -1; +// } +// if (!retval) +// data->current++; + +// return reply->retval; +// } int hc_face_list(hc_sock_t *s, hc_data_t **pdata) { - vapi_lock(); - vapi_msg_hicn_api_faces_dump *hicnp_msg; - hicnp_msg = vapi_alloc_hicn_api_faces_dump(s->g_vapi_ctx_instance); - - int retval = 0; - if (!hicnp_msg) { - retval = VAPI_ENOMEM; - goto END; - } - - hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL); - - if (!data) { - retval = -1; - goto END; - } - - data->buffer = malloc(sizeof(hc_face_t)); - data->size = 1; - - if (!data->buffer) { - free (data); - retval = -1; - goto err; - } - - - retval = vapi_hicn_api_faces_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_face_list, data); - *pdata = data; - - if (retval != VAPI_OK) - goto err; - - data->size = data->current; - vapi_unlock(); - return retval; - - err: - free(data); - END: - vapi_unlock(); - return retval; +// vapi_lock(); +// vapi_msg_hicn_api_faces_dump *hicnp_msg; +// hicnp_msg = vapi_alloc_hicn_api_faces_dump(s->g_vapi_ctx_instance); + +// int retval = 0; +// if (!hicnp_msg) { +// retval = VAPI_ENOMEM; +// goto END; +// } + +// hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL); + +// if (!data) { +// retval = -1; +// goto END; +// } + +// data->buffer = malloc(sizeof(hc_face_t)); +// data->size = 1; + +// if (!data->buffer) { +// free (data); +// retval = -1; +// goto err; +// } + + +// retval = vapi_hicn_api_faces_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_face_list, data); +// *pdata = data; + +// if (retval != VAPI_OK) +// goto err; + +// data->size = data->current; +// vapi_unlock(); +// return retval; + +// err: +// free(data); +// END: +// vapi_unlock(); +// return retval; +ERROR("hc_punting_snprintf not (yet) implemented."); +return -1; } int hc_connection_parse_to_face(void *in, hc_face_t *face) { return 0; } diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c index 2a486f599..0e0a9104b 100644 --- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c +++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c @@ -162,11 +162,11 @@ if(!reply->retval){ return VAPI_EUSER; } -static vapi_error_e call_hicn_api_face_ip_params_get(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_face_params_get(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, - vapi_payload_hicn_api_face_ip_params_get_reply *reply){ + vapi_payload_hicn_api_face_params_get_reply *reply){ if(!reply->retval){ if (callback_ctx!=NULL){ struct hicn_faces_s * tmp; @@ -190,32 +190,6 @@ if(!reply->retval){ return VAPI_EUSER; } -static vapi_error_e call_hicn_api_face_ip_del(struct vapi_ctx_s *ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_face_ip_del_reply *reply){ -if(!reply->retval){ - SRP_LOG_DBGMSG("Successfully done"); - return VAPI_OK; - }else - return VAPI_EUSER; -} - - -static vapi_error_e call_hicn_api_face_ip_add(struct vapi_ctx_s *ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_face_ip_add_reply *reply){ -if(!reply->retval){ - SRP_LOG_DBGMSG("Successfully done"); - return VAPI_OK; - }else - return VAPI_EUSER; - -} - static vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, @@ -411,13 +385,13 @@ static inline int faces_update(sr_val_t * vals, uint32_t nleaves, struct lyd_no for(int count=0; count<nleaves; count++){ - vapi_msg_hicn_api_face_ip_params_get *msg; - msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance); + vapi_msg_hicn_api_face_params_get *msg; + msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance); msg->payload.faceid = temp->face.faceid; - if(vapi_hicn_api_face_ip_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_ip_params_get, (void *)temp)!=VAPI_OK){ + if(vapi_hicn_api_face_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_params_get, (void *)temp)!=VAPI_OK){ SRP_LOG_DBGMSG("Operation failed"); return SR_ERR_OPERATION_FAILED; } @@ -711,17 +685,17 @@ if(vapi_hicn_api_route_del(g_vapi_ctx_instance,msg,call_hicn_api_route_del,NULL) return SR_ERR_OK; } -static int hicn_face_ip_params_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, +static int hicn_face_params_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) { SRP_LOG_DBGMSG("hicn face ip params get received successfully"); - vapi_msg_hicn_api_face_ip_params_get *msg; + vapi_msg_hicn_api_face_params_get *msg; - msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance); + msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance); msg->payload.faceid = input[0].data.uint32_val; -if (vapi_hicn_api_face_ip_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_ip_params_get,NULL)!=VAPI_OK){ +if (vapi_hicn_api_face_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_params_get,NULL)!=VAPI_OK){ SRP_LOG_DBGMSG("Operation failed"); return SR_ERR_OPERATION_FAILED; } @@ -773,86 +747,6 @@ if (vapi_hicn_api_route_nhop_del(g_vapi_ctx_instance, msg, call_hicn_api_route_n return SR_ERR_OK; } -static int hicn_face_ip_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, - sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) { - - SRP_LOG_DBGMSG("hicn face ip del received successfully"); - // allocate memory msg - vapi_msg_hicn_api_face_ip_del *msg; - - msg = vapi_alloc_hicn_api_face_ip_del(g_vapi_ctx_instance); - msg->payload.faceid = input[0].data.uint32_val; - - -if(vapi_hicn_api_face_ip_del(g_vapi_ctx_instance,msg, call_hicn_api_face_ip_del,NULL)!=VAPI_OK){ - SRP_LOG_DBGMSG("Operation failed"); - return SR_ERR_OPERATION_FAILED; -} -return SR_ERR_OK; -} - - -static int hicn_face_ip_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, - sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) { - - SRP_LOG_DBGMSG("hicn face ip add received successfully"); - - - vapi_msg_hicn_api_face_ip_add *msg; - - msg = vapi_alloc_hicn_api_face_ip_add(g_vapi_ctx_instance); - if(strcmp(input[0].data.string_val,"-1")){ - struct sockaddr_in sa; - inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr)); - unsigned char * tmp = (unsigned char *) &sa.sin_addr.s_addr; - memcpy(&msg->payload.face.local_addr.un.ip4[0],tmp,B32); - msg->payload.face.local_addr.af = ADDRESS_IP4; - - }else if(strcmp(input[1].data.string_val,"-1")){ - - void *dst = malloc(sizeof(struct in6_addr)); - inet_pton(AF_INET6, input[1].data.string_val, dst); - unsigned char * tmp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr; - memcpy(&msg->payload.face.local_addr.un.ip6[0],tmp,B128); - msg->payload.face.local_addr.af = ADDRESS_IP6; - - }else{ - SRP_LOG_DBGMSG("Invalid local IP address"); - return SR_ERR_OPERATION_FAILED; - } - - if(strcmp(input[2].data.string_val,"-1")){ - - struct sockaddr_in sa; - inet_pton(AF_INET, input[2].data.string_val, &(sa.sin_addr)); - unsigned char * tmp = (unsigned char *)&sa.sin_addr.s_addr; - memcpy(&msg->payload.face.remote_addr.un.ip4[0],tmp,B32); - msg->payload.face.remote_addr.af = ADDRESS_IP4; - - - }else if(strcmp(input[3].data.string_val,"-1")){ - - void *dst = malloc(sizeof(struct in6_addr)); - inet_pton(AF_INET6, input[3].data.string_val, dst); - unsigned char * tmp =(unsigned char *) ((struct in6_addr *)dst)->s6_addr; - memcpy(&msg->payload.face.remote_addr.un.ip6[0],tmp,B128); - msg->payload.face.remote_addr.af = ADDRESS_IP6; - - }else{ - SRP_LOG_DBGMSG("Invalid local IP address"); - return SR_ERR_OPERATION_FAILED; - } - - msg->payload.face.swif = input[4].data.uint32_val; // This is the idx number of interface - - -if(vapi_hicn_api_face_ip_add(g_vapi_ctx_instance,msg,call_hicn_api_face_ip_add,NULL)!=VAPI_OK){ - SRP_LOG_DBGMSG("Operation failed"); - return SR_ERR_OPERATION_FAILED; -} -return SR_ERR_OK; -} - static vapi_error_e hicn_api_routes_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -1073,28 +967,13 @@ int hicn_subscribe_events(sr_session_ctx_t *session, // face ip subscriptions - rc = sr_rpc_subscribe(session, "/hicn:face-ip-params-get", - hicn_face_ip_params_get_cb, session, 93,SR_SUBSCR_CTX_REUSE, subscription); + rc = sr_rpc_subscribe(session, "/hicn:face-params-get", + hicn_face_params_get_cb, session, 93,SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) { SRP_LOG_DBGMSG("Problem in subscription face-ip-params-get\n"); goto error; } - - rc = sr_rpc_subscribe(session, "/hicn:face-ip-add", hicn_face_ip_add_cb, - session, 92,SR_SUBSCR_CTX_REUSE, subscription); - if (rc != SR_ERR_OK) { - SRP_LOG_DBGMSG("Problem in subscription face-ip-add\n"); - goto error; - } - - rc = sr_rpc_subscribe(session, "/hicn:face-ip-del", hicn_face_ip_del_cb, - session, 91,SR_SUBSCR_CTX_REUSE, subscription); - if (rc != SR_ERR_OK) { - SRP_LOG_DBGMSG("Problem in subscription face-ip-del\n"); - goto error; - } - // subscribe as hicn state data provider rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/states", |