diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-05-07 14:53:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2019-05-07 14:53:39 +0000 |
commit | c8e6bdf4282c34fd3199cdeec42895cbbc05d9c1 (patch) | |
tree | 58651402197fe0cf73561d6c639317b5d940b6f2 /utils/sysrepo-plugins/hicn-light | |
parent | 3ba9071c6899d64b36e910943f109ddc7c7e0809 (diff) | |
parent | e9a02cb3a565daab16e295c551dff80501f94974 (diff) |
Merge "[HICN-153] vapi definition warning"
Diffstat (limited to 'utils/sysrepo-plugins/hicn-light')
8 files changed, 179 insertions, 634 deletions
diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c index e5b1bf56d..ae436a8ad 100644 --- a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c +++ b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c @@ -48,7 +48,6 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) { void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx) { HICN_INVOKE_BEGIN; - /* subscription was set as our private context */ sr_unsubscribe(session, private_ctx); HICN_LOG_DBG_MSG("hicn light unload plugin ok."); diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c index a1b4d7ad2..6c4f938ce 100644 --- a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c +++ b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c @@ -17,12 +17,14 @@ hc_sock_t * hsocket; int hicn_connect_light() { + hsocket = hc_sock_create(); if (!hsocket) HICN_LOG_ERR_MSG("Error creating socket\n"); if (hc_sock_connect(hsocket) < 0) HICN_LOG_ERR_MSG("Error connecting to the forwarder\n"); return 0; + } int hicn_disconnect_light() { diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h index d424ebf3a..adb7737aa 100644 --- a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h +++ b/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h @@ -72,6 +72,9 @@ ARG_CHECK(retval, arg4); \ ARG_CHECK(retval, arg5) + +#define MEM_ALIGN 4096 + int hicn_connect_light(); int hicn_disconnect_light(); extern hc_sock_t * hsocket; diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c index 0c34325d6..7cfb8363a 100644 --- a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c +++ b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c @@ -21,13 +21,186 @@ #include "hicn_model.h" #include "tlock.h" #include "../hicn_light.h" +#include "../hicn_light_comm.h" + + + +/** + * @brief API to add hicn face ip in hicn-light. + */ +static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, + const size_t input_cnt, sr_val_t **output, + size_t *output_cnt, void *private_ctx) { + + SRP_LOG_DBG_MSG("hicn face ip add received successfully"); + + hc_face_t face; + + if(strcmp(input[0].data.string_val,"-1")){ + + struct sockaddr_in sa; + // store this IP address in sa: + inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr)); + face.face.hicn.family=AF_INET; + face.face.hicn.local_addr.v4.as_inaddr=sa.sin_addr; + + + }else if(strcmp(input[1].data.string_val,"-1")){ + + struct in6_addr *dst = malloc(sizeof(struct in6_addr)); + inet_pton(AF_INET6, input[1].data.string_val, dst); + face.face.hicn.family=AF_INET6; + face.face.hicn.local_addr.v6.as_in6addr = *dst; + + }else{ + SRP_LOG_DBG_MSG("Invalid local IP address"); + return SR_ERR_OPERATION_FAILED; + } + + if(strcmp(input[2].data.string_val,"-1")){ + + struct sockaddr_in sa; + // store this IP address in sa: + inet_pton(AF_INET, input[2].data.string_val, &(sa.sin_addr)); + face.face.hicn.family=AF_INET; + face.face.hicn.remote_addr.v4.as_inaddr=sa.sin_addr; + + + }else if(strcmp(input[3].data.string_val,"-1")){ + + struct in6_addr *dst = malloc(sizeof(struct in6_addr)); + inet_pton(AF_INET6, input[3].data.string_val, dst); + face.face.hicn.family=AF_INET6; + face.face.hicn.remote_addr.v6.as_in6addr = *dst; + + }else{ + SRP_LOG_DBG_MSG("Invalid local IP address"); + return SR_ERR_OPERATION_FAILED; + } + + + // strncpy(face.face.hicn.netdevice.name,"ens39"); // Can we work only with Idx number ? + face.face.hicn.netdevice.index = input[4].data.uint32_val; // This is the idx number of interface + + + face.id=0;//can be empty + face.face.tags=0;//can be empty + strcpy(face.name,"hicn_face"); + face.face.type=1; + + int rc; + rc = hc_face_create(hsocket, &face); + if (rc > 0) { + SRP_LOG_DBG_MSG("Face added successfully"); + return SR_ERR_OK; + } + + SRP_LOG_DBG_MSG("Operation Failed"); + return SR_ERR_OPERATION_FAILED; +} + +/** + * @brief API to del hicn face ip in vpp. + */ +static int hicn_face_ip_del_cb(const char *xpath, const sr_val_t *input, + const size_t input_cnt, sr_val_t **output, + size_t *output_cnt, void *private_ctx) { + + SRP_LOG_DBG_MSG("hicn face ip del received successfully"); + face_t * face=NULL; + + // msg->payload.faceid = input[0].data.uint16_val; + //lookup(face); + face_free(face); + + // if(!resp->payload.retval){ + // SRP_LOG_DBG_MSG("Successfully Done"); + // return SR_ERR_OK; + // } + + SRP_LOG_DBG_MSG("Operation Failed"); + return SR_ERR_OPERATION_FAILED; + +} + + +/** + * @brief API to del hicn face ip in vpp. + */ +static int hicn_route_add_cb(const char *xpath, const sr_val_t *input, + const size_t input_cnt, sr_val_t **output, + size_t *output_cnt, void *private_ctx) { + +/* + + SRP_LOG_DBG_MSG("hicn route add received successfully"); + + hc_route_t * route; + + if(strcmp(input[0].data.string_val,"-1")){ + + struct sockaddr_in sa; + // store this IP address in sa: + inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr)); + route.family=AF_INET; + route.face.hicn.local_addr.v4.as_inaddr=sa.sin_addr; + + + }else if(strcmp(input[1].data.string_val,"-1")){ + + struct in6_addr *dst = malloc(sizeof(struct in6_addr)); + inet_pton(AF_INET6, input[1].data.string_val, dst); + face.face.hicn.family=AF_INET6; + face.face.hicn.local_addr.v6.as_in6addr = *dst; + + }else{ + SRP_LOG_DBG_MSG("Invalid local IP address"); + return SR_ERR_OPERATION_FAILED; + } + + +hc_route_create(hsocket, route); +*/ + return SR_ERR_OK; +} int hicn_subscribe_events(sr_session_ctx_t *session, sr_subscription_ctx_t **subscription) { - SRP_LOG_INF_MSG("hicn light plugin initialized successfully."); + + int rc; + rc = sr_rpc_subscribe(session, "/hicn:face-ip-add", hicn_face_ip_add_cb, + session, SR_SUBSCR_CTX_REUSE, subscription); + if (rc != SR_ERR_OK) { + SRP_LOG_DBG_MSG("Problem in subscription stat-get\n"); + goto error; + } + + + rc = sr_rpc_subscribe(session, "/hicn:face-ip-del", hicn_face_ip_del_cb, + session, SR_SUBSCR_CTX_REUSE, subscription); + if (rc != SR_ERR_OK) { + SRP_LOG_DBG_MSG("Problem in subscription face-ip-del\n"); + goto error; + } + + + rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add", + hicn_route_add_cb, session, SR_SUBSCR_CTX_REUSE, subscription); + if (rc!= SR_ERR_OK) { + SRP_LOG_DBG_MSG("Problem in subscription route-nhops-add\n"); + goto error; + } + + + SRP_LOG_INF_MSG("hicn light initialized successfully."); return SR_ERR_OK; +error: + SRP_LOG_ERR_MSG("Error by initialization of the hicn plugin."); + sr_plugin_cleanup_cb(session, hsocket); + return rc; + }
\ No newline at end of file diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h index 59befe68c..e6e857bff 100644 --- a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h +++ b/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h @@ -36,8 +36,6 @@ enum locks_name {lstate, lstrategy, lstrategies, lroute, lface_ip_params}; #define NROUTE_LEAVES 2 #define NFACE_IP_PARAMS_LEAVES 3 - - int hicn_subscribe_events(sr_session_ctx_t *session, sr_subscription_ctx_t **subscription); diff --git a/utils/sysrepo-plugins/hicn-light/plugin/yang/controler_rpcs_instances.xml b/utils/sysrepo-plugins/hicn-light/plugin/yang/controler_rpcs_instances.xml deleted file mode 100644 index c5d24e4f6..000000000 --- a/utils/sysrepo-plugins/hicn-light/plugin/yang/controler_rpcs_instances.xml +++ /dev/null @@ -1,73 +0,0 @@ -<node-params-get xmlns="urn:sysrepo:hicn"/> - -<node-stat-get xmlns="urn:sysrepo:hicn"/> - -<strategy-get xmlns="urn:sysrepo:hicn"> - <strategy_id>0</strategy_id> -</strategy-get> - -<strategies-get xmlns="urn:sysrepo:hicn"/> - - -<route-get xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> -</route-get> - -<route-del xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> -</route-del> - -<route-nhops-add xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> - <face_ids0>40</face_ids0> - <face_ids1>50</face_ids1> - <face_ids2>60</face_ids2> - <face_ids3>70</face_ids3> - <face_ids4>80</face_ids4> - <face_ids5>90</face_ids5> - <face_ids6>100</face_ids6> - <n_faces>110</n_faces> -</route-nhops-add> - -<route-nhops-del xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> - <faceid>40</faceid> -</route-nhops-del> - - -<face-ip-params-get xmlns="urn:sysrepo:hicn"> - <faceid>10</faceid> -</face-ip-params-get> - -<face-ip-add xmlns="urn:sysrepo:hicn"> - <nh_addr0>10</nh_addr0> - <nh_addr1>20</nh_addr1> - <swif>30</swif> -</face-ip-add> - -<face-ip-del xmlns="urn:sysrepo:hicn"> - <faceid>0</faceid> -</face-ip-del> - -<punting-add xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> - <swif>40</swif> -</punting-add> - - -<punting-del xmlns="urn:sysrepo:hicn"> - <prefix0>10</prefix0> - <prefix1>20</prefix1> - <len>30</len> - <swif>40</swif> -</punting-del> diff --git a/utils/sysrepo-plugins/hicn-light/plugin/yang/model/hicn.yang b/utils/sysrepo-plugins/hicn-light/plugin/yang/model/hicn.yang deleted file mode 100644 index 928e5cdc6..000000000 --- a/utils/sysrepo-plugins/hicn-light/plugin/yang/model/hicn.yang +++ /dev/null @@ -1,546 +0,0 @@ -module hicn { - namespace "urn:sysrepo:hicn"; - prefix hcn; - - revision 2019-02-06 { - description "Initial revision."; - } - -/* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */ - - typedef float { - type decimal64 { - fraction-digits 2; - } - } - - - grouping params { - - leaf enable_disable { - description "Enable / disable ICN forwarder in forwarder."; - type boolean; - default false; - } - - leaf pit_max_size { - description "PIT maximum size, otherwise -1 to assign default value."; - type int32; - default -1; - } - - leaf cs_max_size { - description "CS maximum size, otherwise -1 to assign default value."; - type int32; - default -1; - } - - leaf cs_reserved_app { - description "Portion of CS reserved to application, otherwise -1 to assign default value."; - type int32; - default -1; - } - - leaf pit_dflt_lifetime_sec { - description "Default PIT entry lifetime, otherwise -1 to assign default value."; - type float; - default -1; - } - - leaf pit_max_lifetime_sec { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value."; - type float; - default -1; - } - - leaf pit_min_lifetime_sec { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type float; - default -1; - } -} - - grouping face_ip_add { - - leaf nh_addr0 { - description "IP local address."; - type uint64; - } - - leaf nh_addr1 { - description "IP local address."; - type uint64; - } - - leaf swif { - description "IPv4 local port number."; - type uint32; - } - } - - grouping route_nhops_add { - - leaf prefix0 { - description "Prefix0 to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix1 to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - - leaf face_ids0 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids1 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids2 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids3 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids4 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids5 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf face_ids6 { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint32; - } - - leaf n_faces { - description "Number of face to add."; - type uint8; - } - } - - - grouping route_nhops_del { - - leaf prefix0 { - description "Prefix0 to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix1 to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - - leaf faceid { - description "A Face ID to the next hop forwarder for the specified prefix."; - type uint16; - } - - } - - - grouping route_add { - - leaf prefix0 { - description "Prefix0 to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix1 to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - } - - - grouping route_del { - - leaf prefix0 { - description "Prefix0 to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix1 to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - } - - - grouping route_get { - - - leaf prefix0 { - description "Prefix0 to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix1 to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - } - - grouping punting_add { - - leaf prefix0 { - description "Prefix to be added to the FIB."; - type uint64; - } - - leaf prefix1 { - description "Prefix to be added to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - - leaf swif { - description "Interface id."; - type uint32; - } - } - - grouping register_prod_app { - - leaf-list prefix { - description "Prefix to be matched to the FIB."; - type uint64; - } - - leaf len { - description "Length of the prefix."; - type uint8; - } - - leaf swif { - description "Interface id."; - type uint32; - } - - leaf cs_reserved { - description "CS memory reserved -- in number of packets."; - type uint32; - } - - } - -/* new data types and grouping definition to backward the remote response hicn--to-->controler */ - - - grouping states-reply { - - leaf pkts_processed { - description "ICN packets processed."; - type uint64; - } - - leaf pkts_interest_count { - description "PIT maximum size, otherwise -1 to assign default value."; - type uint64; - } - - leaf pkts_data_count { - description "CS maximum size, otherwise -1 to assign default value."; - type uint64; - } - - leaf pkts_from_cache_count { - description "Portion of CS reserved to application, otherwise -1 to assign default value."; - type uint64; - } - - leaf pkts_no_pit_count { - description "Default PIT entry lifetime, otherwise -1 to assign default value."; - type uint64; - } - - leaf pit_expired_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value."; - type uint64; - } - - leaf cs_expired_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf cs_lru_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf pkts_drop_no_buf { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf interests_aggregated { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf interests_retx { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf interests_hash_collision { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf pit_entries_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf cs_entries_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - - leaf cs_entries_ntw_count { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint64; - } - -} - - - - grouping strategy-reply { - - leaf description { - description "Enable / disable ICN forwarder in forwarder."; - type uint8; - } - } - - grouping route-reply { - - leaf faceids { - description "Enable / disable ICN forwarder in forwarder."; - type uint16; - - } - - leaf strategy_id { - description "compile-time plugin features."; - type uint32; - } - } - - grouping strategies-reply { - leaf n_strategies { - description "Enable / disable ICN forwarder in forwarder."; - type uint8; - } - leaf strategy_id { - description "Enable / disable ICN forwarder in forwarder."; - type uint32; - } - - } - - grouping face-ip-params-reply { - - leaf nh_addr { - description "Enable / disable ICN forwarder in forwarder."; - type uint64; - } - - leaf swif { - description "compile-time plugin features."; - type uint32; - } - - leaf flags { - description "compile-time plugin features."; - type uint32; - } - - } - - -/* Hicn configuration */ - - container hicn-conf { - config true; - description "config data container for the hicn-forwarder."; - - container params{ - uses params; - } - } - - -/* Hicn operational data */ - - container hicn-state { - config false; - description "operational data container for the hicn."; - - container states{ - uses states-reply; - } - container strategy{ - uses strategy-reply; - } - container route{ - uses route-reply; - } - container strategies{ - uses strategies-reply; - } - container face-ip-params{ - uses face-ip-params-reply; - } - - } - -/* RPC Definitions */ - - - rpc node-params-set { - description "Operation to set hicn params in forwarder."; - input { - uses params; - } - } - - rpc node-params-get { - description "Operation to get hicn parameter in forwarder."; - } - - - rpc node-stat-get { - description "Operation to get hicn status in forwarder."; - } - - - rpc strategy-get { - description "Operation to get hicn strategy."; - input { - leaf strategy_id { - description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value ."; - type uint32; - } - } - } - - rpc strategies-get { - description "Operation to get hicn strategies."; - } - - rpc route-get { - description "Operation to get hicn route."; - input { - uses route_get; - } - } - - rpc route-del { - description "Operation to del hicn route."; - input { - uses route_del; - } - } - - rpc route-nhops-add { - description "Operation to add hicn route nhops."; - input { - uses route_nhops_add; - } - } - - rpc route-nhops-del { - description "Operation to add hicn face ip punt."; - input { - uses route_nhops_del; - } - } - - rpc face-ip-params-get { - description "Operation to del hicn route."; - input { - leaf faceid { - description "Face to be retrieved ."; - type uint16; - } - } - } - - rpc face-ip-add { - description "Operation to add hicn face ip."; - input { - uses face_ip_add; - } - } - - rpc face-ip-del { - description "Operation to del hicn face ip."; - input { - leaf faceid { - description "Face to be deleted ."; - type uint16; - } - } - } - - rpc punting-add { - description "Operation to add hicn punt."; - input { - uses punting_add; - } - } - - rpc punting-del { - description "Operation to del hicn punt."; - input { - uses punting_add; /* It uses the same payload as the add*/ - } - } - -}
\ No newline at end of file diff --git a/utils/sysrepo-plugins/hicn-light/plugin/yang/startup.xml b/utils/sysrepo-plugins/hicn-light/plugin/yang/startup.xml deleted file mode 100644 index f88e13ea2..000000000 --- a/utils/sysrepo-plugins/hicn-light/plugin/yang/startup.xml +++ /dev/null @@ -1,11 +0,0 @@ -<hicn-conf xmlns="urn:sysrepo:hicn"> -<params> - <enable_disable>false</enable_disable> - <pit_max_size>-1</pit_max_size> - <cs_max_size>-1</cs_max_size> - <cs_reserved_app>-1</cs_reserved_app> - <pit_dflt_lifetime_sec>-1</pit_dflt_lifetime_sec> - <pit_max_lifetime_sec>-1</pit_max_lifetime_sec> - <pit_min_lifetime_sec>-1</pit_min_lifetime_sec> -</params> -</hicn-conf>
\ No newline at end of file |