diff options
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/libhicnctrl/examples/Makefile | 20 | ||||
-rw-r--r-- | ctrl/libhicnctrl/examples/create_face.c | 134 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/CMakeLists.txt | 8 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake | 6 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h | 2 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c | 23 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c | 2 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c | 86 | ||||
-rw-r--r-- | ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h | 1 |
9 files changed, 216 insertions, 66 deletions
diff --git a/ctrl/libhicnctrl/examples/Makefile b/ctrl/libhicnctrl/examples/Makefile new file mode 100644 index 000000000..a6c6f0570 --- /dev/null +++ b/ctrl/libhicnctrl/examples/Makefile @@ -0,0 +1,20 @@ +EXEC = $(shell basename $$(pwd)) +CC = gcc + +CFLAGS = -std=gnu11 -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -DWITH_POLICY=1 +LDFLAGS = -lhicn -lhicnctrl + +SRC = $(wildcard *.c) +EXEC = $(SRC:.c=) + +all: $(EXEC) + +${EXEC}: $(SRC) + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +.PHONY: clean mrproper + +clean: + @rm -rf $(EXEC) + +mrproper: clean diff --git a/ctrl/libhicnctrl/examples/create_face.c b/ctrl/libhicnctrl/examples/create_face.c new file mode 100644 index 000000000..270ceeab9 --- /dev/null +++ b/ctrl/libhicnctrl/examples/create_face.c @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017-2019 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: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \file examples/create_face.c + * \brief libhicnctrl sample code : IPV4/UDP face creation + * + * NOTES: + * - This sample code is IPv4 only + */ + +#include <stdlib.h> +#include <sys/types.h> // getifaddrs +#include <ifaddrs.h> // getifaddrs +#include <stdio.h> +#include <string.h> /* for strncpy */ +#include <sys/socket.h> // socket +#include <sys/ioctl.h> // ioctl +#include <unistd.h> + +#include <hicn/ctrl.h> +#include <hicn/util/log.h> + +int get_local_info(char * if_name, ip_address_t * local_ip) { + struct ifaddrs *addrs; + struct ifreq ifr = { + .ifr_addr.sa_family = AF_INET, + }; + int ret = -1; + + int fd = socket(AF_INET, SOCK_DGRAM, 0); + + getifaddrs(&addrs); + + for (struct ifaddrs * tmp = addrs; tmp; tmp = tmp->ifa_next) { + if (!tmp->ifa_addr || tmp->ifa_addr->sa_family != AF_PACKET) + continue; + if (strcmp(tmp->ifa_name, "lo") == 0) + continue; + snprintf(if_name, IFNAMSIZ, "%s", tmp->ifa_name); + + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", tmp->ifa_name); + if (ioctl(fd, SIOCGIFADDR, &ifr) == 1) { + perror("ioctl"); + continue; + } + + local_ip->v4.as_inaddr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; + + ret = 0; + break; + } + + freeifaddrs(addrs); + close(fd); + return ret; +} + +int main() { + char remote_ip_str[INET_ADDRSTRLEN] = "1.1.1.1"; + + ip_address_t local_ip; + ip_address_t remote_ip; + char if_name[IFNAMSIZ]; + + /* Retrieving local info */ + + if (get_local_info(if_name, &local_ip) < 0) { + DEBUG("Error getting local information"); + return -1; + } + + char local_ip_str[MAXSZ_IP_ADDRESS]; + ip_address_snprintf(local_ip_str, MAXSZ_IP_ADDRESS, &local_ip, AF_INET); + DEBUG("Local information :"); + DEBUG(" - Interface name : %s", if_name); + DEBUG(" - IP address : %s", local_ip_str); + + if (ip_address_pton (remote_ip_str, &remote_ip) < 0){ + DEBUG("Error parsing remote IP address"); + return -1; + } + + /* Filling face information */ + hc_face_t face = { + .face = { + .type = FACE_TYPE_UDP, + .local_addr = local_ip, + .remote_addr = remote_ip, + .local_port = 6000, + .remote_port = 6000, + }, + }; + if (netdevice_set_name(&face.face.netdevice, if_name) < 0) { + DEBUG("Error setting face netdevice name"); + return -1; + } + + /* Connecting to socket and creating face */ + + hc_sock_t * socket = hc_sock_create(); + if (!socket){ + DEBUG("Error creating libhicnctrl socket"); + return -1; + } + + if (hc_sock_connect(socket) < 0){ + DEBUG("Error connecting to forwarder"); + return -1; + } + + if (hc_face_create(socket, &face) < 0){ + DEBUG("Error creating face"); + return -1; + } + + DEBUG("Face created successfully"); + + hc_sock_free(socket); + + return 0; +} diff --git a/ctrl/sysrepo-plugins/CMakeLists.txt b/ctrl/sysrepo-plugins/CMakeLists.txt index 91726161f..cd7c0a16c 100644 --- a/ctrl/sysrepo-plugins/CMakeLists.txt +++ b/ctrl/sysrepo-plugins/CMakeLists.txt @@ -33,8 +33,12 @@ set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2") set(CMAKE_C_FLAGS_DEBUG "-g -O0") # add subdirectories -add_subdirectory(hicn-plugin) -add_subdirectory(hicn-light) +if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + add_subdirectory(hicn-plugin) +endif () +if (BUILD_HICNLIGHT AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + add_subdirectory(hicn-light) +endif () include(Packaging) include(Packager) make_packages() diff --git a/ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake b/ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake index bce3265fa..7883b09dd 100644 --- a/ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake +++ b/ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake @@ -18,15 +18,15 @@ set(HICNLIGHT_SEARCH_PATH_LIST /usr ) -find_path(HICNLIGHT_INCLUDE_DIR hicn/api/api.h +find_path(HICNLIGHT_INCLUDE_DIR hicn/ctrl/api.h HINTS ${HICNLIGHT_SEARCH_PATH_LIST} PATH_SUFFIXES include DOC "Find the hicn plugin includes" ) -find_library(HICNLIGHT_LIBRARY NAMES libhicn-light-ctrl.so +find_library(HICNLIGHT_LIBRARY NAMES libhicnctrl.so HINTS ${HICNLIGHT_SEARCH_PATH_LIST} - PATH_SUFFIXES lib + PATH_SUFFIXES lib/x86_64-linux-gnu/ DOC "Find the hicn light lib" ) diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h index adb7737aa..100023564 100644 --- a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h +++ b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h @@ -20,7 +20,7 @@ #include <sysrepo/values.h> -#include <hicn/api/api.h> +#include <hicn/ctrl/api.h> #ifndef HICN_THIS_FUNC #ifdef __FUNCTION__ diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c index 7cfb8363a..6f8ece08c 100644 --- a/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c +++ b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c @@ -33,24 +33,22 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, 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; + face.face.family=AF_INET; + face.face.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; + face.face.family=AF_INET6; + face.face.local_addr.v6.as_in6addr = *dst; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -62,16 +60,16 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, 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; + face.face.family=AF_INET; + face.face.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; + face.face.family=AF_INET6; + face.face.remote_addr.v6.as_in6addr = *dst; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -80,11 +78,10 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, // 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.face.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; @@ -203,4 +200,4 @@ error: sr_plugin_cleanup_cb(session, hsocket); return rc; -}
\ No newline at end of file +} diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c index f02605895..0498527cb 100644 --- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c +++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c @@ -302,7 +302,7 @@ static i32 ietf_interface_name2index(const char *name, u32* if_index) dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance); dump->payload.name_filter_valid = true; - memcpy(dump->payload.name_filter, name, sizeof(dump->payload.name_filter)); + memcpy(&dump->payload.name_filter, name, sizeof(dump->payload.name_filter)); while (VAPI_EAGAIN == (rv = vapi_sw_interface_dump(g_vapi_ctx_instance, dump, ietf_sw_interface_dump_cb, &dctx))) ; 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 b49839c53..4bf266ff5 100644 --- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c +++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c @@ -28,7 +28,7 @@ /* Hicn headers */ #include <vapi/hicn.api.vapi.h> -#include <hicn/api/ip_address.h> +#include <hicn/util/ip_address.h> #include "../hicn_plugin.h" #include "../hicn_vpp_comm.h" #include "hicn_model.h" @@ -485,18 +485,6 @@ static int hicn_node_params_set_cb(sr_session_ctx_t *session, const char *xpath, new_val->data.int32_val); msg->payload.cs_reserved_app = new_val->data.int32_val; } else if (!strcmp(new_val->xpath, - "/hicn:hicn-conf/params/pit_dflt_lifetime_sec")) { - SRP_LOG_DBG("A change detected in '%s', op=%d", - new_val ? new_val->xpath : old_val->xpath, - new_val->data.decimal64_val); - msg->payload.pit_dflt_lifetime_sec = new_val->data.decimal64_val; - } else if (!strcmp(new_val->xpath, - "/hicn:hicn-conf/params/pit_min_lifetime_sec")) { - SRP_LOG_DBG("A change detected in '%s', op=%d", - new_val ? new_val->xpath : old_val->xpath, - new_val->data.decimal64_val); - msg->payload.pit_min_lifetime_sec = new_val->data.decimal64_val; - } else if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/pit_max_lifetime_sec")) { SRP_LOG_DBG("A change detected in '%s', op=%d", new_val ? new_val->xpath : old_val->xpath, @@ -675,16 +663,16 @@ static int hicn_route_get_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B32); - + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -693,7 +681,7 @@ static int hicn_route_get_cb(const char *xpath, const sr_val_t *input, - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; vapi_msg_hicn_api_route_get_hton(msg); params_send(msg,resp); @@ -727,23 +715,23 @@ static int hicn_route_nhops_add_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,4); - + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); return SR_ERR_OPERATION_FAILED; } - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; msg->payload.face_ids[0] = input[3].data.uint32_val; msg->payload.face_ids[1] = input[4].data.uint32_val; msg->payload.face_ids[2] = input[5].data.uint32_val; @@ -784,7 +772,8 @@ static int hicn_route_del_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B32); + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.af = ADDRESS_IP4; }else if(strcmp(input[1].data.string_val,"-1")){ @@ -792,8 +781,8 @@ static int hicn_route_del_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -801,7 +790,7 @@ static int hicn_route_del_cb(const char *xpath, const sr_val_t *input, } - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; vapi_msg_hicn_api_route_del_hton(msg); params_send(msg,resp); @@ -869,7 +858,8 @@ static int hicn_punting_add_cb(const char *xpath, const sr_val_t *input, // store this IP address 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.prefix[0],tmp,B32); + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.af = ADDRESS_IP4; }else if(strcmp(input[1].data.string_val,"-1")){ @@ -877,15 +867,15 @@ static int hicn_punting_add_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); return SR_ERR_OPERATION_FAILED; } - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; msg->payload.swif = input[3].data.uint32_val; @@ -924,7 +914,8 @@ static int hicn_route_nhops_del_cb(const char *xpath, const sr_val_t *input, // store this IP address 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.prefix[0],tmp,B32); + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.af = ADDRESS_IP4; }else if(strcmp(input[1].data.string_val,"-1")){ @@ -932,8 +923,8 @@ static int hicn_route_nhops_del_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -941,7 +932,7 @@ static int hicn_route_nhops_del_cb(const char *xpath, const sr_val_t *input, } - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; msg->payload.faceid = input[3].data.uint32_val; vapi_msg_hicn_api_route_nhop_del_hton(msg); @@ -979,7 +970,8 @@ static int hicn_punting_del_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B32); + memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32); + msg->payload.prefix.address.af = ADDRESS_IP4; }else if(strcmp(input[1].data.string_val,"-1")){ @@ -987,8 +979,8 @@ static int hicn_punting_del_cb(const char *xpath, const sr_val_t *input, 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.prefix[0],tmp,B64); - memcpy(&msg->payload.prefix[1],tmp+B64,B64); + memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128); + msg->payload.prefix.address.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -996,7 +988,7 @@ static int hicn_punting_del_cb(const char *xpath, const sr_val_t *input, } - msg->payload.len = input[2].data.uint8_val; + msg->payload.prefix.len = input[2].data.uint8_val; msg->payload.swif = input[3].data.uint32_val; vapi_msg_hicn_api_punting_del_hton(msg); @@ -1061,15 +1053,16 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, 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.local_addr[0],tmp,B32); + memcpy(&msg->payload.local_addr.un.ip4[0],tmp,B32); + msg->payload.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.local_addr[0],tmp,B64); - memcpy(&msg->payload.local_addr[1],tmp+B64,B64); + memcpy(&msg->payload.local_addr.un.ip6[0],tmp,B128); + msg->payload.local_addr.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -1081,7 +1074,8 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, 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.remote_addr[0],tmp,B32); + memcpy(&msg->payload.remote_addr.un.ip4[0],tmp,B32); + msg->payload.remote_addr.af = ADDRESS_IP4; }else if(strcmp(input[3].data.string_val,"-1")){ @@ -1089,8 +1083,8 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input, 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.remote_addr[0],tmp,B64); - memcpy(&msg->payload.remote_addr[1],tmp+B64,B64); + memcpy(&msg->payload.remote_addr.un.ip6[0],tmp,B128); + msg->payload.remote_addr.af = ADDRESS_IP6; }else{ SRP_LOG_DBG_MSG("Invalid local IP address"); @@ -1452,4 +1446,4 @@ error: SRP_LOG_ERR_MSG("Error by initialization of the hicn plugin."); sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance); return rc; -}
\ No newline at end of file +} diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h index 6cb5d2710..02317d5d6 100644 --- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h +++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h @@ -21,6 +21,7 @@ #define MEM_ALIGN 4096 #define B32 4 #define B64 8 +#define B128 16 // Number of locks is equal to number of nodes in hicn-state // It is a coarse grain approach later can be changed to fine grained |