aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl')
-rw-r--r--ctrl/facemgr/CMakeLists.txt19
-rw-r--r--ctrl/facemgr/cmake/Modules/Packaging.cmake15
-rw-r--r--ctrl/facemgr/config/facemgr.conf194
-rw-r--r--ctrl/facemgr/config/facemgr.service24
-rwxr-xr-xctrl/facemgr/config/post5
-rwxr-xr-xctrl/facemgr/config/postinst3
-rwxr-xr-xctrl/facemgr/config/prerm3
-rwxr-xr-xctrl/facemgr/config/preun3
-rw-r--r--ctrl/facemgr/examples/mobility/Makefile23
-rw-r--r--ctrl/facemgr/examples/mobility/mobility.c88
-rw-r--r--ctrl/facemgr/src/CMakeLists.txt8
-rw-r--r--ctrl/facemgr/src/api.c96
-rw-r--r--ctrl/facemgr/src/facelet.c6
-rw-r--r--ctrl/facemgr/src/interfaces/android_utility/android_utility.c6
-rw-r--r--ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c28
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c146
-rw-r--r--ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h45
-rw-r--r--ctrl/facemgr/src/main.c2
-rw-r--r--ctrl/libhicnctrl/cmake/Modules/Packaging.cmake4
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h5
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/commands.h97
-rw-r--r--ctrl/libhicnctrl/src/CMakeLists.txt8
-rw-r--r--ctrl/libhicnctrl/src/api.c325
-rw-r--r--ctrl/libhicnctrl/src/hicn_plugin_api.c641
-rw-r--r--ctrl/libhicnctrl/src/hicnctrl.c2
-rw-r--r--ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt2
-rw-r--r--ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt2
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt6
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c6
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c13
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox48
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c1739
-rw-r--r--ctrl/sysrepo-plugins/yang/hicn/hicn.yang509
33 files changed, 2113 insertions, 2008 deletions
diff --git a/ctrl/facemgr/CMakeLists.txt b/ctrl/facemgr/CMakeLists.txt
index 4290d9cd6..ba9de9464 100644
--- a/ctrl/facemgr/CMakeLists.txt
+++ b/ctrl/facemgr/CMakeLists.txt
@@ -42,8 +42,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
-message("IN DEBUG MODE")
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3")
endif()
set(CMAKE_MODULE_PATH
@@ -59,7 +58,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
-find_package_wrapper(Config REQUIRED)
+find_package_wrapper(Libconfig REQUIRED)
find_package_wrapper(LibEvent REQUIRED)
set(FACEMGR facemgr CACHE INTERNAL "" FORCE)
@@ -95,6 +94,20 @@ add_subdirectory(src)
include(Packaging)
+# Install service file in linux systems
+include(ServiceScript)
+install_service_script(
+ ${CMAKE_CURRENT_SOURCE_DIR}/config/facemgr.service
+ COMPONENT ${FACEMGR}
+)
+
+# Configuration file
+set(FACEMGR_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/config/facemgr.conf)
+set(FACEMGR_CONF_FOLDER "/etc/facemgr")
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ install (FILES ${FACEMGR_CONF_FILE} DESTINATION ${FACEMGR_CONF_FOLDER} COMPONENT ${FACEMGR})
+endif()
+
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
include(Packager)
make_packages()
diff --git a/ctrl/facemgr/cmake/Modules/Packaging.cmake b/ctrl/facemgr/cmake/Modules/Packaging.cmake
index 3a7e5a85c..bb4fa42fa 100644
--- a/ctrl/facemgr/cmake/Modules/Packaging.cmake
+++ b/ctrl/facemgr/cmake/Modules/Packaging.cmake
@@ -25,7 +25,22 @@ set(${FACEMGR}_DEB_DEPENDENCIES
CACHE STRING "Dependencies for deb/rpm package."
)
+set(${HICN_LIGHT}_DEB_PACKAGE_CONTROL_EXTRA
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/postinst;${CMAKE_CURRENT_SOURCE_DIR}/config/prerm"
+ CACHE STRING "Control scripts conffiles, postinst, postrm, prerm."
+)
+
set(${FACEMGR}_RPM_DEPENDENCIES
"libconfig, libevent-devel, lib${LIBHICNCTRL} >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
)
+
+set(${HICN_LIGHT}_RPM_POST_INSTALL_SCRIPT_FILE
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/post"
+ CACHE STRING "Install script that will be copied in the %post section"
+)
+
+set(${HICN_LIGHT}_RPM_PRE_UNINSTALL_SCRIPT_FILE
+ "${CMAKE_CURRENT_SOURCE_DIR}/config/preun"
+ CACHE STRING "Install script that will be copied in the %post section"
+)
diff --git a/ctrl/facemgr/config/facemgr.conf b/ctrl/facemgr/config/facemgr.conf
new file mode 100644
index 000000000..d9c6f5fa9
--- /dev/null
+++ b/ctrl/facemgr/config/facemgr.conf
@@ -0,0 +1,194 @@
+#
+# hICN facemgr configuration file
+#
+
+################################################################################
+# Global settings
+################################################################################
+
+global = {
+
+# Default type for face creation
+#
+# Values: "auto" | "native-udp" | "native-tcp" | "overlay-udp" | "overlay-tcp"
+# Default "auto"
+#
+#face_type = "auto";
+face_type = "overlay-udp"
+
+# Disable service discovery for overlay creation
+#
+# This is only meaningful for overlay_* face types. If service discovery is
+# disabled, only manually entered overlay information will be used, if any.
+# Otherwise, no face will be created.
+#
+# Values : true | false
+# Default: false
+#
+#disable_discovery = true;
+
+# Disable IPv4 face creation
+#
+# Values : true | false
+# Default: false
+#
+#disable_ipv4 = true;
+
+# Disable IPv6 face creation
+#
+# Values : true | false
+# Default: false
+#
+#disable_ipv6 = true;
+
+# overlay
+#
+# By default, no address is specified, and local and remote ports are set to
+# the standard value for hICN (9695).
+#
+
+};
+
+################################################################################
+# Per-interface rules
+################################################################################
+#
+# Rules allow to override the default behaviour of the face manager.
+#
+# The list of rules must be specified as follows (note that the last one has no
+# coma at the end) :
+#
+# rules = (
+# { ... },
+# { ... },
+# { ... }
+# );
+#
+# A rule is composed of match and override attributes, and has the following
+# syntax:
+#
+# {
+# match = {
+# interface_name = STRING;
+# interface_type = STRING;
+# };
+# override = {
+# face_type = STRING;
+# disable_discovery = BOOL;
+# ignore = BOOL;
+# tags = (STRING, STRING, STRING);
+# overlay = {
+# ipv4 = {
+# local_port = PORT;
+# remote_addr = IP_ADDRESS;
+# remote_port = PORT;
+# };
+# ipv6 = {
+# local_port = PORT;
+# remote_addr = IP_ADDRESS;
+# remote_port = PORT;
+# };
+# };
+# };
+# }
+#
+# Match attributes:
+#
+# Match attributes serve to identify rules and as such defining two rules with
+# similar matches is not allowed. However, overlapping match definitions are
+# possible, in which case only the first matching rule is considered.
+#
+# A match is composed of the name of an interface and/or its type (either
+# attribute is optional but at least one has to be specified).
+#
+# * interface_name - a string representing an interface name
+#
+# * interface_type - the type of interface to match
+#
+# Values: "wired" | "wifi" | "cellular"
+#
+# Override attributes:
+#
+# Those attributes are applied when all specified match attributes correspond,
+# and override general settings or default values.
+#
+# * face_type - type used for face creation
+#
+# Values: "auto" | "native_udp" | "native_tcp" | "overlay_udp" | "overlay_tcp"
+#
+# * disable_discovery - disable service discovery for overlay creation
+#
+# Values : true | false
+#
+# * ignore - a boolean indicating whether that interface should be ignored
+#
+# * TODO tags - a (possibly empty) list of tags to be associated to the created face.
+#
+# Values: "wired" | "wifi" | "cellular" | "trusted"
+#
+# * overlay
+#
+# An overlay specification is used to complement any information retrieved
+# through service discovery (or replace it if service discovery is
+# disabled).
+#
+# It is possible to specify values for IPv4, IPv6 or both.
+#
+# Note that it is not currently possible to set different settings for IPv4 and
+# IPv6 but overlay specifications.
+#
+#
+# Here are a few example of rule definitions:
+#
+# rules = (
+# # Ignore localhost interface
+# {
+# match = {
+# interface_name = "lo";
+# };
+# override = {
+# ignore = true;
+# };
+# },
+# # Set tags for unknown tunnnel interface
+# {
+# match = {
+# interface_name = "utun1";
+# };
+# override = {
+# tags = ("WIRED", "TRUSTED");
+# };
+# },
+# # Force cellular connections to use manually specified overlay faces
+# {
+# match = {
+# interface_type = "cellular",
+# };
+# override = {
+# overlay = {
+# ipv4 = {
+# local_port = 9695;
+# remote_addr = "10.60.16.14";
+# remote_port = 9695;
+# };
+# ipv6 = {
+# local_port = 9695;
+# remote_addr = "2001:420:44f1:10:20c:29ff:fef3:8f8f";
+# remote_port = 9695;
+# };
+# };
+# };
+# }
+# );
+#
+#rules = (
+#);
+
+################################################################################
+# Logging
+################################################################################
+
+log:
+{
+ log_level = "DEBUG";
+}
diff --git a/ctrl/facemgr/config/facemgr.service b/ctrl/facemgr/config/facemgr.service
new file mode 100644
index 000000000..0f9e818ea
--- /dev/null
+++ b/ctrl/facemgr/config/facemgr.service
@@ -0,0 +1,24 @@
+# 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.
+
+[Unit]
+Description=hICN face manager
+
+[Service]
+Environment=CONFIG=/etc/facemgr/facemgr.conf
+Environment=LOGFILE=/var/log/facemgr.log
+ExecStart=/usr/bin/facemgr -c ${CONFIG} 1>${LOGFILE} 2>&1
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/ctrl/facemgr/config/post b/ctrl/facemgr/config/post
new file mode 100755
index 000000000..7b2fd57fe
--- /dev/null
+++ b/ctrl/facemgr/config/post
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+if pidof systemd; then
+ systemctl enable facemgr
+fi
diff --git a/ctrl/facemgr/config/postinst b/ctrl/facemgr/config/postinst
new file mode 100755
index 000000000..4113b0eca
--- /dev/null
+++ b/ctrl/facemgr/config/postinst
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl enable facemgr
diff --git a/ctrl/facemgr/config/prerm b/ctrl/facemgr/config/prerm
new file mode 100755
index 000000000..b5c486ea5
--- /dev/null
+++ b/ctrl/facemgr/config/prerm
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl disable facemgr
diff --git a/ctrl/facemgr/config/preun b/ctrl/facemgr/config/preun
new file mode 100755
index 000000000..b5c486ea5
--- /dev/null
+++ b/ctrl/facemgr/config/preun
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+systemctl disable facemgr
diff --git a/ctrl/facemgr/examples/mobility/Makefile b/ctrl/facemgr/examples/mobility/Makefile
new file mode 100644
index 000000000..3b92d9d5f
--- /dev/null
+++ b/ctrl/facemgr/examples/mobility/Makefile
@@ -0,0 +1,23 @@
+EXEC = $(shell basename $$(pwd))
+CC = gcc
+
+CFLAGS = -std=gnu11 -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing
+
+SRC = $(wildcard *.c)
+OBJ = $(SRC:.c=.o)
+
+all: $(EXEC)
+
+${EXEC}: $(OBJ)
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) -o $@ -c $< $(CFLAGS)
+
+.PHONY: clean mrproper
+
+clean:
+ @rm -rf *.o
+
+mrproper: clean
+ @rm -rf $(EXEC)
diff --git a/ctrl/facemgr/examples/mobility/mobility.c b/ctrl/facemgr/examples/mobility/mobility.c
new file mode 100644
index 000000000..528951446
--- /dev/null
+++ b/ctrl/facemgr/examples/mobility/mobility.c
@@ -0,0 +1,88 @@
+/*
+ * Dummy server sending alternating bytes to all clients.
+ *
+ * This program can be used to trigger mobility events in the hICN forwarder, to
+ * switch from WiFi to LTE and back, at regular intervals.
+ *
+ * Test server using nc: nc -4kvul localhost 9533
+ */
+
+#include <arpa/inet.h> // inet_ntop
+#include <errno.h> // EINTR,. ..
+#include <netinet/in.h> // INET_ADDRSTRLEN, INET6_ADDRSTRLEN
+#include <stdio.h>
+#include <inttypes.h>
+
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/timerfd.h>
+#include <sys/un.h> // sockaddr_un
+#include <unistd.h> // fcntl
+#include <fcntl.h> // fcntl
+
+#define MS2US(x) (x * 1000)
+
+/**
+ * \brief Main function
+ */
+int main(int argc, char **argv)
+{
+ int rc;
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: %s IP PORT INTERVAL\n", argv[0]);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " IP Target hostname\n");
+ fprintf(stderr, " PORT Target port\n");
+ fprintf(stderr, " INTERVAL Interval between mobility events (in ms)\n");
+ fprintf(stderr, "\n");
+ exit(EXIT_FAILURE);
+ }
+
+ int interval = atoi(argv[3]);
+
+ int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (fd < 0) {
+ perror("socket");
+ goto ERR_SOCKET;
+ }
+
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr(argv[1]);
+ addr.sin_port = htons(atoi(argv[2]));
+
+ if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ perror("connect");
+ goto ERR_CONNECT;
+ }
+
+ unsigned state = 0;
+ char buf[1];
+ for(;;) {
+ usleep(MS2US(interval));
+
+ buf[0] = state;
+ rc = send(fd, buf, 1, 0);
+ if (rc < 0) {
+ if (errno == ECONNREFUSED) {
+ continue;
+ }
+ perror("send");
+ goto ERR_SEND;
+ }
+
+ state = 1 - state;
+ }
+
+ close(fd);
+
+ exit(EXIT_SUCCESS);
+
+ERR_SEND:
+ERR_CONNECT:
+ close(fd);
+ERR_SOCKET:
+ exit(EXIT_FAILURE);
+}
diff --git a/ctrl/facemgr/src/CMakeLists.txt b/ctrl/facemgr/src/CMakeLists.txt
index 4bcad475d..cf5606e04 100644
--- a/ctrl/facemgr/src/CMakeLists.txt
+++ b/ctrl/facemgr/src/CMakeLists.txt
@@ -64,10 +64,12 @@ set(LIBRARIES
m
${HICN_LIBRARIES}
${LIBHICNCTRL_LIBRARIES}
- ${CONFIG_LIBRARY}
+ ${LIBCONFIG_LIBRARIES}
${LIBEVENT_LIBRARY}
)
+set(FACEMGR_LIBRARY_LIST "${LIBCONFIG_LIBRARIES};${LIBEVENT_LIBRARY}" CACHE INTERNAL "FACEMGR_LIBRARY_LIST")
+
add_subdirectory(interfaces)
@@ -106,7 +108,7 @@ if (DISABLE_SHARED_LIBRARIES)
LINK_LIBRARIES ${LIBRARIES}
COMPONENT ${FACEMGR}
INCLUDE_DIRS ${INCLUDE_DIRS}
- INSTALL_ROOT_DIR hicn
+ HEADER_ROOT_DIR hicn
DEFINITIONS ${COMPILER_DEFINITIONS}
)
else ()
@@ -118,7 +120,7 @@ else ()
LINK_LIBRARIES ${LIBRARIES}
COMPONENT ${FACEMGR}
INCLUDE_DIRS ${INCLUDE_DIRS}
- INSTALL_ROOT_DIR hicn
+ HEADER_ROOT_DIR hicn
DEFINITIONS ${COMPILER_DEFINITIONS}
)
endif ()
diff --git a/ctrl/facemgr/src/api.c b/ctrl/facemgr/src/api.c
index 5d48e993f..b2e329e0a 100644
--- a/ctrl/facemgr/src/api.c
+++ b/ctrl/facemgr/src/api.c
@@ -21,12 +21,12 @@
#ifdef __ANDROID__
/*
- * Use AndroidUtility to determine interface types
+ * Use FacemgrUtility to determine interface types
*
* NOTE: this is currently disabled as SDK APIs do not allow to determine the
* type of interfaces that are DOWN
*/
-//#define WITH_ANDROID_UTILITY
+//#define WITH_FACEMGR_UTILITY
/*
* Use priority controller interface
@@ -34,6 +34,11 @@
#define WITH_PRIORITY_CONTROLLER
/*
+ * Dump facelets (debug)
+ */
+//#define WITH_DUMP
+
+/*
* Allow priority setting before interface is actually created
*/
#define WITH_DEFAULT_PRIORITIES
@@ -59,9 +64,11 @@
#include "interfaces/bonjour/bonjour.h"
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
#include "interfaces/android_utility/android_utility.h"
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
+
+#include "interfaces/priority_controller/priority_controller.h"
#include <hicn/face.h>
#include <hicn/facemgr/facelet.h>
@@ -100,9 +107,9 @@ extern interface_ops_t network_framework_ops;
extern interface_ops_t netlink_ops;
extern interface_ops_t bonjour_ops;
#endif
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
extern interface_ops_t android_utility_ops;
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
extern interface_ops_t priority_controller_ops;
#endif
@@ -162,9 +169,9 @@ struct facemgr_s {
interface_t * hl;
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
interface_t * au; /* android_utility */
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
interface_t * pc;
@@ -538,7 +545,7 @@ int facemgr_query_bonjour(facemgr_t * facemgr, netdevice_t * netdevice)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
int facemgr_query_android_utility(facemgr_t * facemgr, netdevice_t netdevice)
{
/* Send an event to the interface */
@@ -564,7 +571,7 @@ ERR_ND:
ERR_MALLOC:
return -1;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/**
@@ -640,7 +647,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -650,7 +657,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_facelet_satisfy_rules] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/* Default ignore list */
if ((netdevice_type == NETDEVICE_TYPE_LOOPBACK) || (netdevice_type == NETDEVICE_TYPE_UNDEFINED)) {
@@ -705,7 +712,7 @@ facemgr_facelet_satisfy_rules(facemgr_t * facemgr, facelet_t * facelet)
return 0;
}
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
/**
* \brief Complements facelet information through Android Utility interface
* \return 0 if request was successful, -1 in case of error, and -2 if the
@@ -741,7 +748,7 @@ facemgr_complement_facelet_au(facemgr_t * facemgr, facelet_t * facelet)
facelet_set_au_done(facelet);
return 0;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef __linux__
/**
@@ -763,7 +770,7 @@ facemgr_complement_facelet_bj(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -773,7 +780,7 @@ facemgr_complement_facelet_bj(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_complement_facelet_bj] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
bool discovery;
if (facemgr_cfg_get_discovery(facemgr->cfg, &netdevice, netdevice_type,
@@ -835,7 +842,7 @@ facemgr_complement_facelet_manual(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -845,7 +852,7 @@ facemgr_complement_facelet_manual(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_complement_facelet_manual] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
int family = AF_UNSPEC;
if (facelet_has_family(facelet)) {
@@ -957,11 +964,11 @@ facemgr_complement_facelet(facemgr_t * facemgr, facelet_t * facelet)
if (!facelet_has_key(facelet))
return -2;
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
rc = facemgr_complement_facelet_au(facemgr, facelet);
if (rc != -2)
return rc;
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#if 0
if (!facelet_has_netdevice_type(facelet)) {
@@ -1008,7 +1015,7 @@ int facemgr_assign_face_type(facemgr_t * facemgr, facelet_t * facelet)
}
netdevice_type_t netdevice_type = NETDEVICE_TYPE_UNDEFINED;
-#ifndef WITH_ANDROID_UTILITY
+#ifndef WITH_FACEMGR_UTILITY
/*
* In addition to netdevice, netdevice_type should be present to correctly
* apply rules
@@ -1018,7 +1025,7 @@ int facemgr_assign_face_type(facemgr_t * facemgr, facelet_t * facelet)
ERROR("[facemgr_assign_face_type] Error retrieving netdevice_type from facelet");
return -2;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facemgr_face_type_t face_type = FACEMGR_FACE_TYPE_UNDEFINED;
if (facemgr_cfg_get_face_type(facemgr->cfg, &netdevice, netdevice_type, &face_type) < 0)
@@ -1153,9 +1160,9 @@ facemgr_process_facelet(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_admin_state(facelet);
facelet_unset_state(facelet);
facelet_unset_bj_done(facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facelet_set_status(facelet, FACELET_STATUS_DELETED);
#if 0
@@ -1416,9 +1423,9 @@ facemgr_consider_static_facelet(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_state(new_facelet);
facelet_unset_bj_done(new_facelet);
facelet_clear_routes(new_facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(new_facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
/* We try to apply static_facelet over facelet */
if (!facelet_match(new_facelet, static_facelet)) {
@@ -1650,9 +1657,9 @@ facemgr_process_facelet_delete(facemgr_t * facemgr, facelet_t * facelet)
facelet_unset_admin_state(facelet);
facelet_unset_state(facelet);
facelet_unset_bj_done(facelet);
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facelet_unset_au_done(facelet);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
facelet_unset_error(facelet);
facelet_set_status(facelet, FACELET_STATUS_DELETED);
#if 0
@@ -1787,7 +1794,9 @@ int
facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
{
bool remove_facelet = true;
+#if WITH_DUMP
bool dump = true;
+#endif /* WITH_DUMP */
int ret = 0;
int rc;
assert(facelet_in);
@@ -1877,7 +1886,9 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
rc = facemgr_process_facelet_get(facemgr, facelet_in);
if (rc == 0)
remove_facelet = false;
+#if WITH_DUMP
dump = false;
+#endif
if (rc == -1) {
ERROR("[facemgr_on_event] Error processing GET event");
goto ERR;
@@ -1985,7 +1996,9 @@ facemgr_on_event(facemgr_t * facemgr, facelet_t * facelet_in)
//DEBUG("[facemgr_on_event] GET EXISTING %s", facelet_old_s);
//DEBUG(" WITH %s", facelet_s);
//ERROR("[facemgr_on_event] GET event for a face that already exists...");
+#ifdef WITH_DUMP
dump = false;
+#endif /* WITH_DUMP */
continue;
case FACELET_EVENT_UPDATE:
@@ -2066,7 +2079,7 @@ ERR:
ret = -1;
DUMP_CACHE:
-#if 1
+#if WITH_DUMP
if (dump) {
DEBUG(" <CACHE>");
facelet_set_dump(facemgr->facelet_cache);
@@ -2074,7 +2087,7 @@ DUMP_CACHE:
DEBUG("</EVENT ret=%d>", ret);
DEBUG("----------------------------------");
}
-#endif
+#endif /* WITH_DUMP */
free(cached_facelets);
@@ -2188,13 +2201,13 @@ facemgr_bootstrap(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
rc = interface_register(&android_utility_ops);
if (rc < 0) {
ERROR("[facemgr_bootstrap] Error registering android_utility interface");
goto ERR_REGISTER;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
INFO("[facemgr_bootstrap] registering priority_controller interface");
@@ -2245,7 +2258,7 @@ facemgr_bootstrap(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
android_utility_cfg_t au_cfg = {
.jvm = facemgr->jvm,
};
@@ -2254,11 +2267,16 @@ facemgr_bootstrap(facemgr_t * facemgr)
ERROR("Error creating 'Android Utility' interface\n");
goto ERR_AU_CREATE;
}
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
INFO("[facemgr_bootstrap] creating priority_controller interface");
- rc = facemgr_create_interface(facemgr, "pc", "priority_controller", NULL, &facemgr->pc);
+ priority_controller_cfg_t pc_cfg = {
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ .jvm = facemgr->jvm,
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+ };
+ rc = facemgr_create_interface(facemgr, "pc", "priority_controller", &pc_cfg, &facemgr->pc);
if (rc < 0) {
ERROR("Error creating 'Priority Controller' interface\n");
goto ERR_PC_CREATE;
@@ -2293,10 +2311,10 @@ ERR_UPDOWN_CREATE:
facemgr_delete_interface(facemgr, facemgr->dummy);
ERR_DUMMY_CREATE:
#endif
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facemgr_delete_interface(facemgr, facemgr->au);
ERR_AU_CREATE:
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
facemgr_delete_interface(facemgr, facemgr->pc);
ERR_PC_CREATE:
@@ -2346,9 +2364,9 @@ void facemgr_stop(facemgr_t * facemgr)
}
#endif /* __linux__ */
-#ifdef WITH_ANDROID_UTILITY
+#ifdef WITH_FACEMGR_UTILITY
facemgr_delete_interface(facemgr, facemgr->au);
-#endif /* WITH_ANDROID_UTILITY */
+#endif /* WITH_FACEMGR_UTILITY */
#ifdef WITH_PRIORITY_CONTROLLER
facemgr_delete_interface(facemgr, facemgr->pc);
diff --git a/ctrl/facemgr/src/facelet.c b/ctrl/facemgr/src/facelet.c
index 1958749ae..f51f5802b 100644
--- a/ctrl/facemgr/src/facelet.c
+++ b/ctrl/facemgr/src/facelet.c
@@ -356,8 +356,10 @@ facelet_create_from_face(face_t * face)
facelet->error = 0;
/* TODO Consistency check between face type and found attributes */
- if (facelet_validate_face(facelet) < 0)
+ if (facelet_validate_face(facelet) < 0) {
+ ERROR("[facelet_create_from_face] Cannot validate face");
goto ERR_FACE;
+ }
facelet->bj_done = false;
facelet->au_done = false;
@@ -367,7 +369,7 @@ facelet_create_from_face(face_t * face)
/* We need to get route set */
facelet->routes = route_set_create();
if (!facelet->routes) {
- ERROR("[facelet_create] Cannot create route set");
+ ERROR("[facelet_create_from_face] Cannot create route set");
goto ERR_ROUTE_SET;
}
facelet->routes_done = false;
diff --git a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
index 55468baf8..d8e20659a 100644
--- a/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
+++ b/ctrl/facemgr/src/interfaces/android_utility/android_utility.c
@@ -20,15 +20,15 @@
#include <assert.h>
-#include <hicn/face.h>
#include <hicn/facemgr.h>
+#include <hicn/ctrl/face.h>
#include <hicn/util/log.h>
#include "../../common.h"
#include "../../interface.h"
#include "android_utility.h"
-#define FACEMGR_ANDROID_UTILITY_CLASS "com/cisco/hicn/forwarder/supportlibrary/AndroidUtility"
+#define FACEMGR_UTILITY_CLASS "com/cisco/hicn/facemgrlibrary/supportlibrary/FacemgrUtility"
#define AU_INTERFACE_TYPE_UNDEFINED 0
@@ -89,7 +89,7 @@ int au_on_event(interface_t * interface, facelet_t * facelet)
JNIEnv *env;
JavaVM *jvm = data->cfg.jvm;
(*jvm)->AttachCurrentThread(jvm, &env, NULL);
- jclass cls = (*env)->FindClass(env, FACEMGR_ANDROID_UTILITY_CLASS);
+ jclass cls = (*env)->FindClass(env, FACEMGR_UTILITY_CLASS);
jmethodID getNetworkType = (*env)->GetStaticMethodID(env, cls,
"getNetworkType", "(Ljava/lang/String;)I");
jint interface_type = (*env)->CallStaticIntMethod(env, cls, getNetworkType,
diff --git a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
index 508c0713b..8d3e18cdb 100644
--- a/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
+++ b/ctrl/facemgr/src/interfaces/hicn_light/hicn_light.c
@@ -327,13 +327,12 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
switch(facelet_get_event(facelet)) {
case FACELET_EVENT_CREATE:
-
- /* Create face */
{
+ /* Create face */
char buf[MAXSZ_FACELET];
facelet_snprintf(buf, MAXSZ_FACELET, facelet);
DEBUG("Create facelet %s", buf);
- }
+
hc_face.face = *face;
rc = hc_face_create(data->s, &hc_face);
if (rc < 0) {
@@ -341,7 +340,8 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
ret = -FACELET_ERROR_REASON_UNSPECIFIED_ERROR;
goto ERR;
}
- INFO("Created face id=%d", hc_face.id);
+ INFO("Created face id=%d - %s", hc_face.id, buf);
+ }
hicn_route_t ** route_array;
int n = facelet_get_route_array(facelet, &route_array);
@@ -413,7 +413,6 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
case FACELET_EVENT_DELETE:
/* Removing a face should also remove associated routes */
- /* Create face */
hc_face.face = *face;
rc = hc_face_delete(data->s, &hc_face);
if (rc < 0) {
@@ -421,6 +420,11 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
ret = -FACELET_ERROR_REASON_UNSPECIFIED_ERROR;
goto ERR;
}
+
+ char buf[MAXSZ_FACELET];
+ facelet_snprintf(buf, MAXSZ_FACELET, facelet);
+ INFO("Deleted face id=%d", hc_face.id);
+
break;
case FACELET_EVENT_UPDATE:
@@ -457,7 +461,8 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
goto ERR;
}
facelet_set_admin_state_status(facelet, FACELET_ATTR_STATUS_CLEAN);
- INFO("Admin state updated");
+ INFO("Updated face id=%d - admin_state=%s", hc_face.id,
+ face_state_str(admin_state));
}
#ifdef WITH_POLICY
if (facelet_get_netdevice_type_status(facelet) == FACELET_ATTR_STATUS_DIRTY) {
@@ -517,7 +522,8 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
goto ERR;
}
facelet_set_netdevice_type_status(facelet, FACELET_ATTR_STATUS_CLEAN);
- INFO("Tags updated");
+ INFO("Updated face id=%d - netdevice_type=%s", hc_face.id,
+ netdevice_type_str(netdevice_type));
}
if (facelet_get_priority_status(facelet) == FACELET_ATTR_STATUS_DIRTY) {
INFO("Updating priority...");
@@ -549,7 +555,8 @@ int hl_on_event(interface_t * interface, facelet_t * facelet)
goto ERR;
}
facelet_set_priority_status(facelet, FACELET_ATTR_STATUS_CLEAN);
- INFO("Priority updated");
+
+ INFO("Updated face id=%d - priority=%d", hc_face.id, priority);
}
#endif /* WITH_POLICY */
break;
@@ -642,6 +649,11 @@ int hl_callback(interface_t * interface, int fd, void * unused)
/* We can ignore faces on localhost */
facelet_t * facelet = facelet_create_from_face(&f->face);
+ if (!facelet) {
+ ERROR("[hl_callback] Could not create facelet... skipping");
+ continue;
+ }
+
foreach_route(r, data->polled_routes) {
if (r->face_id != f->id)
continue;
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
index 76538185f..67edc5e39 100644
--- a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.c
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.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:
@@ -27,19 +27,110 @@
#include <hicn/facemgr.h>
+#include "priority_controller.h"
#include "../../common.h"
#include "../../interface.h"
#define PC_DEFAULT_PORT 9533
typedef struct {
+ priority_controller_cfg_t cfg;
int fd;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ unsigned state;
+ JNIEnv * env;
+ jclass cls;
+ jmethodID mid;
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
} pc_data_t;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+#include <jni.h>
+
+#define ERR_STR_JAVA "Java VM parameters are required in the interface configuration."
+
+#define PREFER_CELLULAR 0
+#define PREFER_WIFI 1
+#define PREFER_BOTH 2
+
+#define INTERVAL_MS 500
+
+const char * prefer_str[] = { "Cellular", "WiFi", "both" };
+
+jclass find_class_global(JNIEnv* env, const char *name){
+ jclass c = (*env)->FindClass(env, name);
+ jclass c_global = 0;
+ if (c){
+ c_global = (jclass)(*env)->NewGlobalRef(env, c);
+ (*env)->DeleteLocalRef(env, c);
+ }
+ return c_global;
+}
+
+
+int priority_controller_tick(interface_t * interface, int fd, void * unused)
+{
+ pc_data_t * data = (pc_data_t*)interface->data;
+ unsigned new_state = PREFER_BOTH;
+
+ jint rssi = (*data->env)->CallStaticIntMethod(data->env, data->cls, data->mid);
+ DEBUG("[priority_controller_tick] rssi=%d\n", rssi);
+ if (rssi > -67) {
+ new_state = PREFER_WIFI;
+
+#if 0
+ } else if ((rssi < -67) && (rssi > -70)) {
+ new_state = PREFER_BOTH;
+#endif
+
+ } else { /* rssi < -70 */
+ new_state = PREFER_CELLULAR;
+ }
+
+ if (new_state == data->state)
+ return 0;
+
+ ERROR("[priority_controller_tick] Setting priority to %s", prefer_str[new_state]);
+
+ /* XXX Factor this */
+
+ facelet_t * facelet_w = facelet_create();
+ facelet_t * facelet_c = facelet_create();
+ facelet_set_netdevice_type(facelet_w, NETDEVICE_TYPE_WIFI);
+ facelet_set_netdevice_type(facelet_c, NETDEVICE_TYPE_CELLULAR);
+ facelet_set_attr_clean(facelet_w);
+ facelet_set_attr_clean(facelet_c);
+
+ switch(new_state) {
+ case PREFER_CELLULAR:
+ facelet_set_priority(facelet_w, 0);
+ facelet_set_priority(facelet_c, 10);
+ break;
+ case PREFER_WIFI:
+ facelet_set_priority(facelet_w, 10);
+ facelet_set_priority(facelet_c, 0);
+ break;
+ case PREFER_BOTH:
+ facelet_set_priority(facelet_w, 0);
+ facelet_set_priority(facelet_c, 0);
+ break;
+ }
+
+ facelet_set_event(facelet_w, FACELET_EVENT_UPDATE);
+ facelet_set_event(facelet_c, FACELET_EVENT_UPDATE);
+
+ interface_raise_event(interface, facelet_w);
+ interface_raise_event(interface, facelet_c);
+
+ data->state = new_state;
+
+ return 0;
+}
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+
int priority_controller_initialize(interface_t * interface, void * cfg)
{
INFO("Initializing priority controller");
- struct sockaddr_in addr;
pc_data_t * data = malloc(sizeof(pc_data_t));
if (!data) {
@@ -49,6 +140,33 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
interface->data = data;
+ data->cfg = * (priority_controller_cfg_t *) cfg;
+
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+
+ if (!cfg) {
+ ERROR(ERR_STR_JAVA);
+ goto ERR_CFG;
+ }
+
+ /* Retrieve RSSI information from SDK through AndroidUtility class */
+ (*data->cfg.jvm)->AttachCurrentThread(data->cfg.jvm, &data->env, NULL);
+ data->cls = find_class_global(data->env, FACEMGR_ANDROID_UTILITY_CLASS);
+ if (data->cls == 0)
+ goto ERR_JAVA;
+ data->mid = (*data->env)->GetStaticMethodID(data->env, data->cls, "getWifiRSSI", "()I");
+
+ data->fd = interface_register_timer(interface, INTERVAL_MS,
+ priority_controller_tick, interface);
+ if (data->fd < 0) {
+ ERROR("[priority_controller_initialize] Could not initialize timer");
+ goto ERR_FD;
+ }
+ data->state = PREFER_BOTH;
+
+#else /* PRIORITY_CONTROLLER_INTERNAL */
+ struct sockaddr_in addr;
+
data->fd = socket(AF_INET, SOCK_DGRAM, 0);
//data->fd = socket(AF_INET, SOCK_STREAM, 0);
if (data->fd < 0) {
@@ -67,18 +185,28 @@ int priority_controller_initialize(interface_t * interface, void * cfg)
perror("bind error");
goto ERR_BIND;
}
+
+ DEBUG("[priority_controller_initialize] register fd");
if (interface_register_fd(interface, data->fd, NULL) < 0) {
ERROR("[priority_controller_initialize] Error registering fd");
goto ERR_FD;
}
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+
INFO("Priority controller successfully initialized");
return 0;
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ERR_CFG:
+ERR_JAVA:
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
ERR_FD:
+#ifndef PRIORITY_CONTROLLER_INTERNAL
ERR_BIND:
close(data->fd);
ERR_SOCKET:
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
free(data);
ERR_MALLOC:
return -1;
@@ -88,12 +216,21 @@ int priority_controller_finalize(interface_t * interface)
{
pc_data_t * data = (pc_data_t*)interface->data;
- if (data->fd > 0) {close(data->fd);}
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ DEBUG("[priority_controller_finalize] unregister timer");
+ interface_unregister_timer(interface, data->fd);
+#else
+ if (data->fd > 0) {
+ interface_unregister_fd(interface, data->fd);
+ close(data->fd);
+ }
free(data);
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
return 0;
}
+#ifndef PRIORITY_CONTROLLER_INTERNAL
int priority_controller_callback(interface_t * interface, int fd, void * unused)
{
pc_data_t * data = (pc_data_t*)interface->data;
@@ -148,10 +285,13 @@ int priority_controller_callback(interface_t * interface, int fd, void * unused)
return 0;
}
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
interface_ops_t priority_controller_ops = {
.type = "priority_controller",
.initialize = priority_controller_initialize,
.finalize = priority_controller_finalize,
+#ifndef PRIORITY_CONTROLLER_INTERNAL
.callback = priority_controller_callback,
+#endif /* ! PRIORITY_CONTROLLER_INTERNAL */
};
diff --git a/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h
new file mode 100644
index 000000000..247fc3c57
--- /dev/null
+++ b/ctrl/facemgr/src/interfaces/priority_controller/priority_controller.h
@@ -0,0 +1,45 @@
+/*
+ * 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:
+ *
+ * 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 priority_controller.h
+ * \brief Priority Controller interface
+ */
+
+#ifndef FACEMGR_INTERFACE_PRIORITY_CONTROLLER
+#define FACEMGR_INTERFACE_PRIORITY_CONTROLLER
+
+#define FACEMGR_UTILITY_CLASS "com/cisco/hicn/facemgrlibrary/supportlibrary/FacemgrUtility"
+
+/*
+ * Uncomment this line to use a Priority controller interface internal to the
+ * face manager (only available in Android).
+ */
+// #define PRIORITY_CONTROLLER_INTERNAL
+
+#ifdef __ANDROID__
+#include <jni.h>
+#endif /* __ANDROID__ */
+
+typedef struct {
+#ifdef __ANDROID__
+#ifdef PRIORITY_CONTROLLER_INTERNAL
+ JavaVM * jvm;
+#endif /* PRIORITY_CONTROLLER_INTERNAL */
+#endif /* __ANDROID__ */
+} priority_controller_cfg_t;
+
+
+#endif /* FACEMGR_INTERFACE_PRIORITY_CONTROLLER */
diff --git a/ctrl/facemgr/src/main.c b/ctrl/facemgr/src/main.c
index da5e55943..344b034ae 100644
--- a/ctrl/facemgr/src/main.c
+++ b/ctrl/facemgr/src/main.c
@@ -186,7 +186,7 @@ MAIN_LOOP:
facemgr_set_callback(facemgr, loop, (void*)loop_callback);
#ifdef __ANDROID__
- facemgr_set_jvm(facemgr, NULL, NULL); // FIXME
+ facemgr_set_jvm(facemgr, NULL);
#endif /* __ ANDROID__ */
DEBUG("Bootstrap...");
diff --git a/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake b/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
index 92e9d4adb..bf0a4d504 100644
--- a/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
+++ b/ctrl/libhicnctrl/cmake/Modules/Packaging.cmake
@@ -32,7 +32,7 @@ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
)
set(${LIBHICNCTRL_COMPONENT}-dev_DEB_DEPENDENCIES
- "${LIBHICNCTRL_COMPONENT} (>= stable_version), hicn-plugin-dev (>= stable_version-release), hicn-plugin-dev (<< next_version-release)"
+ "${LIBHICNCTRL_COMPONENT} (>= stable_version), hicn-plugin-dev (>= stable_version)"
CACHE STRING "Dependencies for deb/rpm package."
)
@@ -42,7 +42,7 @@ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
)
set(${LIBHICNCTRL_COMPONENT}-dev_RPM_DEPENDENCIES
- "${LIBHICNCTRL_COMPONENT} >= stable_version, hicn-plugin-dev >= stable_version-release, hicn-plugin-dev < next_version-release"
+ "${LIBHICNCTRL_COMPONENT} >= stable_version, hicn-plugin-dev >= stable_version"
CACHE STRING "Dependencies for deb/rpm package."
)
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index 3771b3abd..ebb4ee007 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -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:
@@ -636,6 +636,7 @@ typedef struct {
ip_address_t remote_addr; /* krw */
u8 len; /* krw */
u16 cost; /* .rw */
+ // XXX hc_face_t face;
} hc_route_t;
int hc_route_parse(void *in, hc_route_t *route);
@@ -743,7 +744,7 @@ typedef struct {
int family; /* Krw */
ip_address_t remote_addr; /* krw */
u8 len; /* krw */
- policy_t policy; /* .rw */
+ hicn_policy_t policy; /* .rw */
} hc_policy_t;
int hc_policy_parse(void *in, hc_policy_t *policy);
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
index 767ef98a3..472c237b4 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/commands.h
@@ -20,8 +20,8 @@
* Header and payload in binary format.
*/
-#ifndef commands_h
-#define commands_h
+#ifndef HICN_CTRL_COMMANDS_H
+#define HICN_CTRL_COMMANDS_H
#ifndef _WIN32
#include <netinet/in.h>
@@ -31,31 +31,14 @@
#include <stdint.h>
#include <stdlib.h>
-#include <hicn/util/ip_address.h>
#ifdef WITH_POLICY
#include <hicn/policy.h>
#endif /* WITH_POLICY */
+#include <hicn/strategy.h>
+#include <hicn/util/ip_address.h>
-#define SYMBOLIC_NAME_LEN 16
-#define MAX_FWD_STRATEGY_RELATED_PREFIXES 10
-
-typedef struct in6_addr ipv6_addr_t;
-typedef uint32_t ipv4_addr_t;
-
-typedef enum {
- ADDR_INET = 1,
- ADDR_INET6,
- ADDR_LINK,
- ADDR_IFACE,
- ADDR_UNIX /* PF_UNIX */
-} address_type;
-typedef enum {
- UDP_CONN,
- TCP_CONN,
- GRE_CONN, // not implemented
- HICN_CONN
-} connection_type;
+#define SYMBOLIC_NAME_LEN 16
typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
@@ -118,14 +101,12 @@ typedef enum {
#define command_type_from_uchar(x) \
(((x) >= COMMAND_TYPE_N) ? COMMAND_TYPE_N : (command_type_t)(x))
-/* Header */
-
/* Should be at least 8 bytes */
typedef struct {
- uint8_t messageType;
- uint8_t commandID ;
+ uint8_t message_type;
+ uint8_t command_id;
uint16_t length; /* Number of structures in the payload */
- uint32_t seqNum;
+ uint32_t seq_num;
} cmd_header_t;
typedef struct {
@@ -134,19 +115,13 @@ typedef struct {
/* Listener */
-typedef enum { ETHER_MODE, IP_MODE, HICN_MODE } listener_mode;
-
typedef struct {
char symbolic[SYMBOLIC_NAME_LEN];
- char interfaceName[SYMBOLIC_NAME_LEN];
+ char interface_name[SYMBOLIC_NAME_LEN];
ip_address_t address;
uint16_t port;
- // uint16_t etherType;
- uint8_t addressType;
- uint8_t listenerMode;
- uint8_t connectionType;
uint8_t family;
- uint8_t listenerType;
+ uint8_t type;
} cmd_listener_add_t;
typedef struct {
@@ -154,13 +129,6 @@ typedef struct {
} cmd_listener_remove_t;
typedef struct {
- ip_address_t address;
- char listenerName[SYMBOLIC_NAME_LEN];
- char interfaceName[SYMBOLIC_NAME_LEN];
- uint32_t connid;
- uint16_t port;
- uint8_t addressType;
- uint8_t encapType;
} cmd_listener_list_t;
typedef struct {
@@ -184,7 +152,6 @@ typedef struct {
uint16_t local_port;
uint8_t family;
uint8_t type;
- uint8_t connection_type;
uint8_t admin_state;
#ifdef WITH_POLICY
uint32_t priority;
@@ -196,27 +163,7 @@ typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
} cmd_connection_remove_t;
-typedef enum {
- CONN_GRE,
- CONN_TCP,
- CONN_UDP,
- CONN_MULTICAST,
- CONN_L2,
- CONN_HICN
-} list_connections_type;
-
-typedef enum {
- IFACE_UP = 0,
- IFACE_DOWN = 1,
- IFACE_UNKNOWN = 2 // not used actually
-} connection_state;
-
typedef struct {
- cmd_connection_add_t connectionData;
- uint32_t connid;
- uint8_t state;
- char interfaceName[SYMBOLIC_NAME_LEN];
- char connectionName[SYMBOLIC_NAME_LEN];
} cmd_connection_list_t;
typedef struct {
@@ -236,7 +183,7 @@ typedef struct {
uint32_t id;
uint8_t state;
char interface_name[SYMBOLIC_NAME_LEN];
- char name[SYMBOLIC_NAME_LEN];
+ char name[SYMBOLIC_NAME_LEN]; // XXX what is this ?
} cmd_connection_list_item_t;
typedef struct {
@@ -268,7 +215,6 @@ typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
ip_address_t address;
uint16_t cost;
- uint8_t addressType;
uint8_t family;
uint8_t len;
} cmd_route_add_t;
@@ -276,17 +222,11 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
ip_address_t address;
- uint8_t addressType;
uint8_t family;
uint8_t len;
} cmd_route_remove_t;
typedef struct {
- ip_address_t address;
- uint32_t connid;
- uint16_t cost;
- uint8_t addressType;
- uint8_t len;
} cmd_route_list_t;
typedef struct {
@@ -322,7 +262,6 @@ typedef struct {
typedef struct {
ip_address_t address;
uint8_t strategy_type;
- uint8_t address_type;
uint8_t family;
uint8_t len;
uint8_t related_prefixes;
@@ -340,7 +279,6 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
ip_address_t address;
- uint8_t addressType;
uint8_t family;
uint8_t len;
} cmd_punting_add_t;
@@ -367,40 +305,31 @@ typedef struct {
uint8_t len;
} cmd_mapme_send_update_t;
-#ifdef WITH_POLICY
/* Policy */
typedef struct {
ip_address_t address;
- uint8_t addressType;
uint8_t family;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} cmd_policy_add_t;
typedef struct {
ip_address_t address;
- uint8_t addressType;
uint8_t family;
uint8_t len;
} cmd_policy_remove_t;
typedef struct {
- ip_address_t address;
- uint8_t addressType;
- uint8_t len;
- policy_t policy;
} cmd_policy_list_t;
typedef struct {
ip_address_t address;
uint8_t family;
uint8_t len;
- policy_t policy;
+ hicn_policy_t policy;
} cmd_policy_list_item_t;
-#endif /* WITH_POLICY */
-
/* Full messages */
#define _(l, u) \
diff --git a/ctrl/libhicnctrl/src/CMakeLists.txt b/ctrl/libhicnctrl/src/CMakeLists.txt
index 1a64296e8..054ae3bd8 100644
--- a/ctrl/libhicnctrl/src/CMakeLists.txt
+++ b/ctrl/libhicnctrl/src/CMakeLists.txt
@@ -16,6 +16,8 @@ list(APPEND COMPILER_DEFINITIONS
)
set(HEADER_FILES
+ api.h
+ cli.h
commands.h
)
@@ -24,8 +26,8 @@ set(UTIL_HEADER_FILES
set(SOURCE_FILES
hicnctrl.c
- cli.c
route.c
+ cli.c
)
if(BUILD_HICNPLUGIN)
@@ -67,7 +69,7 @@ build_library(${LIBHICNCTRL}
DEPENDS ${DEPENDENCIES}
COMPONENT ${LIBHICNCTRL_COMPONENT}
INCLUDE_DIRS ${INCLUDE_DIRS}
- INSTALL_ROOT_DIR hicn
+ HEADER_ROOT_DIR hicn
DEFINITIONS ${COMPILER_DEFINITIONS}
)
@@ -75,7 +77,7 @@ if (NOT DISABLE_EXECUTABLES)
set(LIBRARIES ${LIBRARIES} ${LIBHICN_SHARED} ${LIBHICNCTRL_SHARED})
list(APPEND DAEMON_SRC
- cli.c
+ hicnctrl.c
)
build_executable(${HICNCTRL}
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index ef9f4af65..83c493fe3 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -56,7 +56,7 @@ typedef struct {
} hc_sock_request_t;
/**
- * Messages to the forwarder might be multiplexed thanks to the seqNum fields in
+ * Messages to the forwarder might be multiplexed thanks to the seq_num fields in
* the cmd_header_t structure. The forwarder simply answers back the
* original sequence number. We maintain a map of such sequence number to
* outgoing queries so that replied can be demultiplexed and treated
@@ -184,6 +184,7 @@ connection_type_from_str(const char * str)
#define IS_VALID_LIST_CONNECTIONS_TYPE(x) ((x >= CONN_GRE) && (x <= CONN_HICN))
+#if 0
static const hc_connection_type_t map_from_list_connections_type[] = {
[CONN_GRE] = CONNECTION_TYPE_UNDEFINED,
[CONN_TCP] = CONNECTION_TYPE_TCP,
@@ -224,6 +225,7 @@ static const listener_mode map_to_listener_mode[] = {
};
#define IS_VALID_LIST_CONNECTIONS_STATE(x) ((x >= IFACE_UP) && (x <= IFACE_UNKNOWN))
+#endif
/* /!\ Please update constants in header file upon changes */
const char * connection_state_str[] = {
@@ -242,11 +244,13 @@ static const connection_state map_to_connection_state[] = {
*/
+#if 0
static const hc_connection_state_t map_from_list_connections_state[] = {
[IFACE_UP] = HC_CONNECTION_STATE_UP,
[IFACE_DOWN] = HC_CONNECTION_STATE_DOWN,
[IFACE_UNKNOWN] = HC_CONNECTION_STATE_UNDEFINED,
};
+#endif
#define connection_state_to_face_state(x) ((face_state_t)(x))
@@ -254,6 +258,7 @@ static const hc_connection_state_t map_from_list_connections_state[] = {
#define IS_VALID_ADDR_TYPE(x) ((x >= ADDR_INET) && (x <= ADDR_UNIX))
+#if 0
static const int map_from_addr_type[] = {
[ADDR_INET] = AF_INET,
[ADDR_INET6] = AF_INET6,
@@ -266,6 +271,15 @@ static const address_type map_to_addr_type[] = {
[AF_INET] = ADDR_INET,
[AF_INET6] = ADDR_INET6,
};
+#endif
+
+// XXX Those are always true
+//
+#define IS_VALID_ADDRESS(x) (1)
+#define IS_VALID_CONNECTION_ID(x) (1)
+#define IS_VALID_ROUTE_COST(x) (1)
+#define IS_VALID_PREFIX_LEN(x) (1)
+#define IS_VALID_POLICY(x) (1)
/******************************************************************************
* Message helper types and aliases
@@ -588,7 +602,7 @@ int
hc_sock_send(hc_sock_t * s, hc_msg_t * msg, size_t msglen, int seq)
{
int rc;
- msg->hdr.seqNum = seq;
+ msg->hdr.seq_num = seq;
rc = (int)send(s->fd, msg, msglen, 0);
if (rc < 0) {
perror("hc_sock_send");
@@ -657,7 +671,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
}
hc_sock_request_t * request = NULL;
- if (hc_sock_map_get(s->map, hdr.seqNum, &request) < 0) {
+ if (hc_sock_map_get(s->map, hdr.seq_num, &request) < 0) {
ERROR("[hc_sock_process] Error searching for matching request");
return -99;
}
@@ -667,7 +681,7 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data)
}
s->remaining = hdr.length;
- switch(hdr.messageType) {
+ switch(hdr.message_type) {
case ACK_LIGHT:
DEBUG("ack received");
assert(s->remaining == 1);
@@ -971,19 +985,16 @@ _hc_listener_create(hc_sock_t * s, hc_listener_t * listener, bool async)
msg_listener_add_t msg = {
.header = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_LISTENER_ADD,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_LISTENER_ADD,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = listener->local_addr,
.port = htons(listener->local_port),
- .addressType = (u8)map_to_addr_type[listener->family],
- .listenerMode = (u8)map_to_listener_mode[listener->type],
- .connectionType = (u8)map_to_connection_type[listener->type],
.family = listener->family,
- .listenerType = listener->type,
+ .type = listener->type,
}
};
@@ -991,7 +1002,7 @@ _hc_listener_create(hc_sock_t * s, hc_listener_t * listener, bool async)
if (rc >= SYMBOLIC_NAME_LEN)
WARN("[_hc_listener_create] Unexpected truncation of symbolic name string");
- rc = snprintf(msg.payload.interfaceName, INTERFACE_LEN, "%s", listener->interface_name);
+ rc = snprintf(msg.payload.interface_name, INTERFACE_LEN, "%s", listener->interface_name);
if (rc >= INTERFACE_LEN)
WARN("[_hc_listener_create] Unexpected truncation of interface name string");
@@ -1074,10 +1085,10 @@ _hc_listener_delete(hc_sock_t * s, hc_listener_t * listener, bool async)
cmd_listener_remove_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_LISTENER_REMOVE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_LISTENER_REMOVE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
};
@@ -1136,17 +1147,17 @@ _hc_listener_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
cmd_header_t hdr;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_LISTENER_LIST,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_LISTENER_LIST,
.length = 0,
- .seqNum = 0,
+ .seq_num = 0,
},
};
hc_command_params_t params = {
.cmd = ACTION_LIST,
.cmd_id = COMMAND_TYPE_LISTENER_LIST,
- .size_in = sizeof(cmd_listener_list_t),
+ .size_in = sizeof(cmd_listener_list_item_t),
.size_out = sizeof(hc_listener_t),
.parse = (HC_PARSE)hc_listener_parse,
};
@@ -1217,33 +1228,31 @@ hc_listener_parse(void * in, hc_listener_t * listener)
{
int rc;
- cmd_listener_list_t * cmd = (cmd_listener_list_t *)in;
+ cmd_listener_list_item_t * item = (cmd_listener_list_item_t *)in;
- if (!IS_VALID_LIST_LISTENERS_TYPE(cmd->encapType))
- return -1;
-
- hc_connection_type_t type = map_from_encap_type[cmd->encapType];
- if (type == CONNECTION_TYPE_UNDEFINED)
- return -1;
+ // XXX TODO validate what we received from hicnlight
+ // address
+ // name
+ // interface_name
+ // port
- if (!IS_VALID_ADDR_TYPE(cmd->addressType))
+ if (!(IS_VALID_CONNECTION_TYPE(item->type)))
return -1;
- int family = map_from_addr_type[cmd->addressType];
- if (!IS_VALID_FAMILY(family))
+ if (!IS_VALID_FAMILY(item->family))
return -1;
*listener = (hc_listener_t) {
- .id = cmd->connid,
- .type = type,
- .family = family,
- .local_addr = UNION_CAST(cmd->address, ip_address_t),
- .local_port = ntohs(cmd->port),
+ .id = item->id,
+ .type = item->type,
+ .family = item->family,
+ .local_addr = UNION_CAST(item->address, ip_address_t),
+ .local_port = ntohs(item->port),
};
- rc = snprintf(listener->name, SYMBOLIC_NAME_LEN, "%s", cmd->listenerName);
+ rc = snprintf(listener->name, SYMBOLIC_NAME_LEN, "%s", item->name);
if (rc >= SYMBOLIC_NAME_LEN)
WARN("[hc_listener_parse] Unexpected truncation of symbolic name string");
- rc = snprintf(listener->interface_name, INTERFACE_LEN, "%s", cmd->interfaceName);
+ rc = snprintf(listener->interface_name, INTERFACE_LEN, "%s", item->interface_name);
if (rc >= INTERFACE_LEN)
WARN("[hc_listener_parse] Unexpected truncation of interface name string");
return 0;
@@ -1293,18 +1302,19 @@ _hc_connection_create(hc_sock_t * s, hc_connection_t * connection, bool async)
cmd_connection_add_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_ADD,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_ADD,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
+ // symbolic
.remote_ip = connection->remote_addr,
.local_ip = connection->local_addr,
.remote_port = htons(connection->remote_port),
.local_port = htons(connection->local_port),
- .type = (u8)map_to_addr_type[connection->family],
- .connection_type = (u8)map_to_connection_type[connection->type],
+ .family = connection->family,
+ .type = connection->type,
.admin_state = connection->admin_state,
#ifdef WITH_POLICY
.priority = connection->priority,
@@ -1315,7 +1325,7 @@ _hc_connection_create(hc_sock_t * s, hc_connection_t * connection, bool async)
rc = snprintf(msg.payload.symbolic, SYMBOLIC_NAME_LEN, "%s", connection->name);
if (rc >= SYMBOLIC_NAME_LEN)
WARN("[_hc_connection_create] Unexpected truncation of symbolic name string");
- //snprintf(msg.payload.interfaceName, INTERFACE_NAME_LEN, "%s", connection->interface_name);
+ //snprintf(msg.payload.interface_name, INTERFACE_NAME_LEN, "%s", connection->interface_name);
hc_command_params_t params = {
.cmd = ACTION_CREATE,
@@ -1395,10 +1405,10 @@ _hc_connection_delete(hc_sock_t * s, hc_connection_t * connection, bool async)
cmd_connection_remove_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_REMOVE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_REMOVE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
};
@@ -1456,17 +1466,17 @@ _hc_connection_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
cmd_header_t hdr;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_LIST,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_LIST,
.length = 0,
- .seqNum = 0,
+ .seq_num = 0,
},
};
hc_command_params_t params = {
.cmd = ACTION_LIST,
.cmd_id = COMMAND_TYPE_CONNECTION_LIST,
- .size_in = sizeof(cmd_connection_list_t),
+ .size_in = sizeof(cmd_connection_list_item_t),
.size_out = sizeof(hc_connection_t),
.parse = (HC_PARSE)hc_connection_parse,
};
@@ -1550,50 +1560,46 @@ int
hc_connection_parse(void * in, hc_connection_t * connection)
{
int rc;
- cmd_connection_list_t * cmd = (cmd_connection_list_t *)in;
+ cmd_connection_list_item_t * item = (cmd_connection_list_item_t *)in;
- if (!IS_VALID_LIST_CONNECTIONS_TYPE(cmd->connectionData.connection_type))
- return -1;
+ // XXX validation
+ // symbolic
+ // remote_ip
+ // local_ip
+ // remote_port
+ // local_port
- hc_connection_type_t type = map_from_list_connections_type[cmd->connectionData.connection_type];
- if (type == CONNECTION_TYPE_UNDEFINED)
+ if (!IS_VALID_FAMILY(item->family))
return -1;
- if (!IS_VALID_LIST_CONNECTIONS_STATE(cmd->state))
- return -1;
-
- hc_connection_state_t state = map_from_list_connections_state[cmd->state];
- if (state == HC_CONNECTION_STATE_UNDEFINED)
- return -1;
-
- if (!IS_VALID_ADDR_TYPE(cmd->connectionData.type))
- return -1;
-
- int family = map_from_addr_type[cmd->connectionData.type];
- if (!IS_VALID_FAMILY(family))
- return -1;
+ // type
+ // admin_state
+ // priority
+ // tags
+ // id
+ // state
+ // interface_name
+ // name ???
*connection = (hc_connection_t) {
- .id = cmd->connid,
- .type = type,
- .family = family,
- .local_addr = cmd->connectionData.local_ip,
- //.local_addr = UNION_CAST(cmd->connectionData.localIp, ip_address_t),
- .local_port = ntohs(cmd->connectionData.local_port),
- .remote_addr = cmd->connectionData.remote_ip,
- //.remote_addr = UNION_CAST(cmd->connectionData.remoteIp, ip_address_t),
- .remote_port = ntohs(cmd->connectionData.remote_port),
- .admin_state = cmd->connectionData.admin_state,
+ .id = item->id,
+ .type = item->type,
+ .family = item->family,
+ .local_addr = item->local_ip,
+ .local_port = ntohs(item->local_port),
+ .remote_addr = item->remote_ip,
+ .remote_port = ntohs(item->remote_port),
+ .admin_state = item->admin_state,
#ifdef WITH_POLICY
- .priority = cmd->connectionData.priority,
- .tags = cmd->connectionData.tags,
+ .priority = item->priority,
+ .tags = item->tags,
#endif /* WITH_POLICY */
- .state = state,
+ .state = item->state,
};
- rc = snprintf(connection->name, SYMBOLIC_NAME_LEN, "%s", cmd->connectionData.symbolic);
+ rc = snprintf(connection->name, SYMBOLIC_NAME_LEN, "%s", item->symbolic);
if (rc >= SYMBOLIC_NAME_LEN)
WARN("[hc_connection_parse] Unexpected truncation of symbolic name string");
- rc = snprintf(connection->interface_name, INTERFACE_LEN, "%s", cmd->interfaceName);
+ rc = snprintf(connection->interface_name, INTERFACE_LEN, "%s", item->interface_name);
if (rc >= INTERFACE_LEN)
WARN("[hc_connection_parse] Unexpected truncation of interface name string");
return 0;
@@ -1648,10 +1654,10 @@ _hc_connection_set_admin_state(hc_sock_t * s, const char * conn_id_or_name,
cmd_connection_set_admin_state_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_SET_ADMIN_STATE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_SET_ADMIN_STATE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.admin_state = state,
@@ -1698,10 +1704,10 @@ _hc_connection_set_priority(hc_sock_t * s, const char * conn_id_or_name,
cmd_connection_set_priority_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_SET_PRIORITY,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_SET_PRIORITY,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.priority = priority,
@@ -1748,10 +1754,10 @@ _hc_connection_set_tags(hc_sock_t * s, const char * conn_id_or_name,
cmd_connection_set_tags_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CONNECTION_SET_TAGS,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CONNECTION_SET_TAGS,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.tags = tags,
@@ -1812,15 +1818,15 @@ _hc_route_create(hc_sock_t * s, hc_route_t * route, bool async)
cmd_route_add_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_ROUTE_ADD,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_ROUTE_ADD,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = route->remote_addr,
.cost = route->cost,
- .addressType = (u8)map_to_addr_type[route->family],
+ .family = route->family,
.len = route->len,
}
};
@@ -1875,14 +1881,14 @@ _hc_route_delete(hc_sock_t * s, hc_route_t * route, bool async)
cmd_route_remove_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_ROUTE_REMOVE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_ROUTE_REMOVE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = route->remote_addr,
- .addressType = (u8)map_to_addr_type[route->family],
+ .family = route->family,
.len = route->len,
}
};
@@ -1927,17 +1933,17 @@ _hc_route_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
cmd_header_t hdr;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_ROUTE_LIST,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_ROUTE_LIST,
.length = 0,
- .seqNum = 0,
+ .seq_num = 0,
},
};
hc_command_params_t params = {
.cmd = ACTION_LIST,
.cmd_id = COMMAND_TYPE_ROUTE_LIST,
- .size_in = sizeof(cmd_route_list_t),
+ .size_in = sizeof(cmd_route_list_item_t),
.size_out = sizeof(hc_route_t),
.parse = (HC_PARSE)hc_route_parse,
};
@@ -1962,25 +1968,35 @@ hc_route_list_async(hc_sock_t * s)
int
hc_route_parse(void * in, hc_route_t * route)
{
- cmd_route_list_t * cmd = (cmd_route_list_t *) in;
+ cmd_route_list_item_t * item = (cmd_route_list_item_t *) in;
- if (!IS_VALID_ADDR_TYPE(cmd->addressType)) {
- ERROR("[hc_route_parse] Invalid address type");
+ if (!IS_VALID_ADDRESS(item->address)) {
+ ERROR("[hc_route_parse] Invalid address");
return -1;
}
-
- int family = map_from_addr_type[cmd->addressType];
- if (!IS_VALID_FAMILY(family)) {
+ if (!IS_VALID_CONNECTION_ID(item->connection_id)) {
+ ERROR("[hc_route_parse] Invalid connection id");
+ return -1;
+ }
+ if (!IS_VALID_ROUTE_COST(item->cost)) {
+ ERROR("[hc_route_parse] Invalid cost");
+ return -1;
+ }
+ if (!IS_VALID_FAMILY(item->family)) {
ERROR("[hc_route_parse] Invalid address family");
return -1;
}
+ if (!IS_VALID_PREFIX_LEN(item->len)) {
+ ERROR("[hc_route_parse] Invalid len");
+ return -1;
+ }
*route = (hc_route_t) {
- .face_id = cmd->connid,
- .family = family,
- .remote_addr = UNION_CAST(cmd->address, ip_address_t),
- .len = cmd->len,
- .cost = cmd->cost,
+ .face_id = item->connection_id,
+ .family = item->family,
+ .remote_addr = item->address,
+ .len = item->len,
+ .cost = item->cost,
};
return 0;
}
@@ -2521,17 +2537,17 @@ hc_face_list_async(hc_sock_t * s)
cmd_header_t hdr;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
+ .message_type = REQUEST_LIGHT,
COMMAND_TYPE_CONNECTION_LIST,
.length = 0,
- .seqNum = 0,
+ .seq_num = 0,
},
};
hc_command_params_t params = {
.cmd = ACTION_LIST,
.cmd_id = COMMAND_TYPE_CONNECTION_LIST,
- .size_in = sizeof(cmd_connection_list_t),
+ .size_in = sizeof(cmd_connection_list_item_t),
.size_out = sizeof(hc_face_t),
.parse = (HC_PARSE)hc_connection_parse_to_face,
};
@@ -2662,14 +2678,14 @@ _hc_punting_create(hc_sock_t * s, hc_punting_t * punting, bool async)
cmd_punting_add_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_PUNTING_ADD,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_PUNTING_ADD,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = punting->prefix,
- .addressType = (u8)map_to_addr_type[punting->family],
+ .family = punting->family,
.len = punting->prefix_len,
}
};
@@ -2783,10 +2799,10 @@ _hc_cache_set_store(hc_sock_t * s, int enabled, bool async)
cmd_cache_set_store_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CACHE_SET_STORE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CACHE_SET_STORE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.activate = enabled,
@@ -2824,10 +2840,10 @@ _hc_cache_set_serve(hc_sock_t * s, int enabled, bool async)
cmd_cache_set_serve_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_CACHE_SET_SERVE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_CACHE_SET_SERVE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.activate = enabled,
@@ -2961,14 +2977,14 @@ _hc_policy_create(hc_sock_t * s, hc_policy_t * policy, bool async)
cmd_policy_add_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
+ .message_type = REQUEST_LIGHT,
COMMAND_TYPE_POLICY_ADD,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = policy->remote_addr,
- .addressType = (u8)map_to_addr_type[policy->family],
+ .family = policy->family,
.len = policy->len,
.policy = policy->policy,
}
@@ -3010,14 +3026,14 @@ _hc_policy_delete(hc_sock_t * s, hc_policy_t * policy, bool async)
cmd_policy_remove_t payload;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_POLICY_REMOVE,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_POLICY_REMOVE,
.length = 1,
- .seqNum = 0,
+ .seq_num = 0,
},
.payload = {
.address = policy->remote_addr,
- .addressType = (u8)map_to_addr_type[policy->family],
+ .family = policy->family,
.len = policy->len,
}
};
@@ -3054,17 +3070,17 @@ _hc_policy_list(hc_sock_t * s, hc_data_t ** pdata, bool async)
cmd_header_t hdr;
} msg = {
.hdr = {
- .messageType = REQUEST_LIGHT,
- .commandID = COMMAND_TYPE_POLICY_LIST,
+ .message_type = REQUEST_LIGHT,
+ .command_id = COMMAND_TYPE_POLICY_LIST,
.length = 0,
- .seqNum = 0,
+ .seq_num = 0,
},
};
hc_command_params_t params = {
.cmd = ACTION_LIST,
.cmd_id = COMMAND_TYPE_POLICY_LIST,
- .size_in = sizeof(cmd_policy_list_t),
+ .size_in = sizeof(cmd_policy_list_item_t),
.size_out = sizeof(hc_policy_t),
.parse = (HC_PARSE)hc_policy_parse,
};
@@ -3089,20 +3105,30 @@ hc_policy_list_async(hc_sock_t * s, hc_data_t ** pdata)
int
hc_policy_parse(void * in, hc_policy_t * policy)
{
- cmd_policy_list_t * cmd = (cmd_policy_list_t *) in;
-
- if (!IS_VALID_ADDR_TYPE(cmd->addressType))
- return -1;
+ cmd_policy_list_item_t * item = (cmd_policy_list_item_t *) in;
- int family = map_from_addr_type[cmd->addressType];
- if (!IS_VALID_FAMILY(family))
- return -1;
+ if (!IS_VALID_ADDRESS(item->address)) {
+ ERROR("[hc_policy_parse] Invalid address");
+ return -1;
+ }
+ if (!IS_VALID_FAMILY(item->family)) {
+ ERROR("[hc_policy_parse] Invalid family");
+ return -1;
+ }
+ if (!IS_VALID_PREFIX_LEN(item->len)) {
+ ERROR("[hc_policy_parse] Invalid len");
+ return -1;
+ }
+ if (!IS_VALID_POLICY(item->policy)) {
+ ERROR("[hc_policy_parse] Invalid policy");
+ return -1;
+ }
*policy = (hc_policy_t) {
- .family = family,
- .remote_addr = UNION_CAST(cmd->address, ip_address_t),
- .len = cmd->len,
- .policy = cmd->policy,
+ .family = item->family,
+ .remote_addr = item->address,
+ .len = item->len,
+ .policy = item->policy,
};
return 0;
}
@@ -3159,4 +3185,3 @@ object_from_str(const char * object_str)
#undef _
return OBJECT_UNDEFINED;
}
-
diff --git a/ctrl/libhicnctrl/src/hicn_plugin_api.c b/ctrl/libhicnctrl/src/hicn_plugin_api.c
index 04d01e2a6..231c491ba 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:
@@ -34,13 +34,24 @@
#include <strings.h>
#include <vapi/hicn.api.vapi.h>
#include <vapi/ip.api.vapi.h>
+#include <vapi/udp.api.vapi.h>
#include <vapi/interface.api.vapi.h>
#include <hicn/util/log.h>
#include <hicn/util/map.h>
#include <hicn/error.h>
#include <vnet/ip/ip6_packet.h>
+
+
+#if __GNUC__ >= 9
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
#include <vnet/ip/ip46_address.h>
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
#define APP_NAME "hicn_plugin"
#define MAX_OUTSTANDING_REQUESTS 4
#define RESPONSE_QUEUE_SIZE 2
@@ -48,6 +59,7 @@
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON
DEFINE_VAPI_MSG_IDS_IP_API_JSON
+DEFINE_VAPI_MSG_IDS_UDP_API_JSON
typedef struct {
vapi_ctx_t g_vapi_ctx_instance;
@@ -61,7 +73,7 @@ vapi_skc_ctx_t vapi_skc = {
/**
* Messages to the forwarder might be multiplexed thanks to the seqNum fields in
- * the cmd_header_t structure. The forwarder simply answers back the
+ * the header_control_message structure. The forwarder simply answers back the
* original sequence number. We maintain a map of such sequence number to
* outgoing queries so that replied can be demultiplexed and treated
* appropriately.
@@ -94,20 +106,10 @@ 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) \
_(hicn_api_face_get_reply) \
- _(hicn_api_route_nhops_add) \
- _(hicn_api_route_nhops_add_reply) \
- _(hicn_api_route_del) \
- _(hicn_api_route_del_reply) \
- _(hicn_api_route_nhop_del) \
- _(hicn_api_route_nhop_del_reply) \
_(hicn_api_route_get) \
_(hicn_api_route_get_reply) \
_(hicn_api_routes_details) \
@@ -115,6 +117,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 {
@@ -622,12 +625,29 @@ int hc_connection_set_admin_state_async(hc_sock_t *s,
* Routes
*----------------------------------------------------------------------------*/
+vapi_error_e create_udp_tunnel_cb( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_udp_tunnel_add_del_reply *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ if (reply->retval != VAPI_OK)
+ return reply->retval;
+
+ u32 * uei = (u32*) callback_ctx;
+ *uei = reply->uei;
+
+ return reply->retval;
+}
+
/* ROUTE CREATE */
vapi_error_e parse_route_create( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_route_nhops_add_reply *reply) {
+ vapi_payload_ip_route_add_del_reply *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
@@ -637,31 +657,133 @@ vapi_error_e parse_route_create( vapi_ctx_t ctx,
return reply->retval;
}
+vapi_error_e hicn_enable_cb( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_enable_disable_reply *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ return reply->retval;
+}
+
int _hc_route_create(hc_sock_t *s, hc_route_t *route, bool async) {
if (!IS_VALID_FAMILY(route->family)) return -1;
+ int ret;
vapi_lock();
- vapi_msg_hicn_api_route_nhops_add *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_route_nhops_add(s->g_vapi_ctx_instance);
- if (!hicnp_msg) return VAPI_ENOMEM;
+ vapi_msg_ip_route_add_del *hicnp_msg = vapi_alloc_ip_route_add_del(s->g_vapi_ctx_instance, 1);
+
+ hicnp_msg->payload.is_add = 1;
+ if (route->family == AF_INET) {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP4;
+ }
+ else {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP6;
+ }
+
+ hicnp_msg->payload.route.prefix.len = route->len;
+
+ hicnp_msg->payload.route.paths[0].sw_if_index = ~0;
+ hicnp_msg->payload.route.paths[0].table_id = 0;
+
+ hc_face_t *face = &(route->face);
+ switch (face->face.type) {
+ case FACE_TYPE_HICN:
+ {
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr)))) {
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip4), &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4;
+ }
+ else{
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip6), &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+
+ break;
+ }
+ case FACE_TYPE_UDP:
+ {
+ vapi_msg_hicn_api_udp_tunnel_add_del *msg = NULL;
+ u32 uei = ~0;
+
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr))) &&
+ ip46_address_is_ip4((ip46_address_t *)(&(face->face.local_addr)))) {
+
+ msg = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance);
+ memcpy(msg->payload.src_addr.un.ip4, &face->face.local_addr.v4, sizeof(ip4_address_t));
+ msg->payload.src_addr.af = ADDRESS_IP4;
+
+ memcpy(msg->payload.dst_addr.un.ip4, &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ msg->payload.dst_addr.af = ADDRESS_IP4;
+
+ } else if (!ip46_address_is_ip4((ip46_address_t *)(&(route->face.face.remote_addr))) &&
+ !ip46_address_is_ip4((ip46_address_t *)(&(route->face.face.local_addr)))) {
+
+ msg = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance);
+ memcpy(msg->payload.src_addr.un.ip6, &face->face.local_addr.v6, sizeof(ip6_address_t));
+ msg->payload.src_addr.af = ADDRESS_IP4;
+
+ memcpy(msg->payload.dst_addr.un.ip6, &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ msg->payload.dst_addr.af = ADDRESS_IP6;
+
+ } else {
+ //NOT IMPLEMENTED
+ ret = -1;
+ goto done;
+ }
+
+ msg->payload.src_port = face->face.local_port;
+ msg->payload.dst_port = face->face.remote_port;
+ msg->payload.is_add = 1;
+
+ int ret = vapi_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance, msg, create_udp_tunnel_cb, &uei);
+
+ if(ret) {
+ vapi_msg_free(s->g_vapi_ctx_instance, hicnp_msg);
+ goto done;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_TYPE_UDP_ENCAP;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].nh.obj_id = uei;
+ break;
+ }
+ default:
+ ret = -1;
+ goto done;
+ }
+
+ ret = vapi_ip_route_add_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_create, NULL);
+
+ if (ret)
+ goto done;
+
+ vapi_msg_hicn_api_enable_disable *msg = vapi_alloc_hicn_api_enable_disable(s->g_vapi_ctx_instance);
if (route->family == AF_INET) {
- memcpy(&hicnp_msg->payload.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ memcpy(&msg->payload.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
}
else {
- memcpy(&hicnp_msg->payload.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ memcpy(&msg->payload.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
}
- hicnp_msg->payload.prefix.address.af =
- route->family == AF_INET ? ADDRESS_IP4 : ADDRESS_IP6;
- hicnp_msg->payload.prefix.len = route->len;
- hicnp_msg->payload.face_ids[0] = route->face_id;
- hicnp_msg->payload.n_faces = 1;
- vapi_error_e ret = vapi_hicn_api_route_nhops_add(s->g_vapi_ctx_instance, hicnp_msg, parse_route_create, NULL);
+ msg->payload.prefix.len = route->len;
+ msg->payload.enable_disable = 1;
+
+ ret = vapi_hicn_api_enable_disable(s->g_vapi_ctx_instance, msg, hicn_enable_cb, NULL);
+done:
vapi_unlock();
return ret;
-
}
int hc_route_create(hc_sock_t *s, hc_route_t *route) {
@@ -677,13 +799,10 @@ vapi_error_e parse_route_delete( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_route_nhop_del_reply *reply) {
+ vapi_payload_ip_route_add_del_reply *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
-
return reply->retval;
}
@@ -691,20 +810,56 @@ int _hc_route_delete(hc_sock_t *s, hc_route_t *route, bool async) {
if (!IS_VALID_FAMILY(route->family)) return -1;
vapi_lock();
- vapi_msg_hicn_api_route_nhop_del *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_route_nhop_del(s->g_vapi_ctx_instance);
+ vapi_msg_ip_route_add_del *hicnp_msg = vapi_alloc_ip_route_add_del(s->g_vapi_ctx_instance, 1);
- if (!hicnp_msg) return VAPI_ENOMEM;
+ hicnp_msg->payload.is_add = 0;
+ if (route->family == AF_INET) {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP4;
+ }
+ else {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP6;
+ }
+
+ hicnp_msg->payload.route.prefix.len = route->len;
+
+ hicnp_msg->payload.route.paths[0].sw_if_index = ~0;
+ hicnp_msg->payload.route.paths[0].table_id = 0;
- memcpy(&hicnp_msg->payload.prefix.address.un.ip6[0], &route->remote_addr, 16);
- hicnp_msg->payload.prefix.address.af =
- route->family == AF_INET ? ADDRESS_IP4 : ADDRESS_IP6;
- hicnp_msg->payload.prefix.len = route->len;
- hicnp_msg->payload.faceid = route->face_id;
+ hc_face_t *face = &(route->face);
+ switch (face->face.type) {
+ case FACE_TYPE_HICN:
+ {
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr)))) {
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip4), &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4;
+ }
+ else{
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip6), &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+
+ break;
+ }
+ case FACE_TYPE_UDP:
+ {
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_TYPE_UDP_ENCAP;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].nh.obj_id = face->face.netdevice.index;
+ break;
+ }
+ default:
+ return -1;
+ }
+
+ vapi_error_e ret = vapi_ip_route_add_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_delete, NULL);
- int retval = vapi_hicn_api_route_nhop_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_delete, NULL);
vapi_unlock();
- return retval;
+ return ret;
}
int hc_route_delete(hc_sock_t *s, hc_route_t *route) {
@@ -715,18 +870,121 @@ int hc_route_delete_async(hc_sock_t *s, hc_route_t *route) {
return _hc_route_delete(s, route, true);
}
+vapi_error_e parse_udp_encap_list( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_udp_encap_details *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ hc_face_t * face = (hc_face_t *)callback_ctx;
+
+ if (face->face.netdevice.index == reply->udp_encap.id)
+ {
+ switch(reply->udp_encap.src_ip.af) {
+ case ADDRESS_IP4:
+ {
+ memcpy(&face->face.local_addr.v4, &(reply->udp_encap.src_ip.un.ip4), sizeof(ip4_address_t));
+ memcpy(&face->face.remote_addr.v4, &(reply->udp_encap.dst_ip.un.ip4), sizeof(ip4_address_t));
+ break;
+ }
+ case ADDRESS_IP6:
+ {
+ memcpy(&face->face.local_addr.v6, &(reply->udp_encap.src_ip.un.ip6), sizeof(ip6_address_t));
+ memcpy(&face->face.remote_addr.v6, &(reply->udp_encap.dst_ip.un.ip6), sizeof(ip6_address_t));
+ break;
+ }
+ default:
+ break;
+ }
+
+ face->face.local_port = reply->udp_encap.src_port;
+ face->face.remote_port = reply->udp_encap.dst_port;
+ }
+ return rv;
+}
+
+int fill_face_with_info(hc_face_t * face, vapi_type_fib_path *path, hc_sock_t *s) {
+ switch(path->type){
+ case FIB_API_PATH_FLAG_NONE:
+ {
+ face->face.type = FACE_TYPE_HICN;
+ switch(path->proto){
+ case FIB_API_PATH_NH_PROTO_IP4:
+ memcpy(&face->face.remote_addr.v4, &(path->nh.address.ip4), sizeof(ip4_address_t));
+ break;
+ case FIB_API_PATH_NH_PROTO_IP6:
+ memcpy(&face->face.remote_addr.v6, &(path->nh.address.ip6), sizeof(ip6_address_t));
+ break;
+ default:
+ break;
+ }
+ face->face.netdevice.index = path->sw_if_index;
+ }
+ break;
+ case FIB_API_PATH_TYPE_UDP_ENCAP:
+ {
+ face->face.type = FACE_TYPE_UDP;
+ face->face.netdevice.index = clib_net_to_host_u32(path->nh.obj_id);
+ //vapi_msg_udp_encap_dump *msg;
+ //msg = vapi_alloc_udp_encap_dump(s->g_vapi_ctx_instance);
+ //vapi_udp_encap_dump(s->g_vapi_ctx_instance, msg, parse_udp_encap_list, face);
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
/* ROUTE LIST */
+typedef struct hicn_route_socket_s {
+ hc_data_t *data;
+ hc_sock_t *s;
+} hicn_route_socket_t;
+
vapi_error_e parse_route_list( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_routes_details *reply) {
+ vapi_payload_ip_route_details *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
+ hicn_route_socket_t *rs = (hicn_route_socket_t *)callback_ctx;
+ hc_data_t *data = rs->data;
+
+ u8 found = false;
+ for (int j = 0; j < reply->route.n_paths; j++){
+ for (int i = 0; i < data->size && !found; i++) {
+ hc_route_t * route = &((hc_route_t*)(data->buffer))[i];
+
+ if(ip46_address_is_ip4((ip46_address_t *)&(route->remote_addr)) &&
+ memcmp(route->remote_addr.v4.as_u8, reply->route.prefix.address.un.ip4, sizeof(ip4_address_t)) == 0 &&
+ route->len == reply->route.prefix.len && route->face_id == ~0) {
+ fill_face_with_info(&(route->face), &reply->route.paths[j], rs->s);
+ found = true;
+ } else if (memcmp(route->remote_addr.v6.as_u8, reply->route.prefix.address.un.ip6, sizeof(ip6_address_t)) == 0 &&
+ route->len == reply->route.prefix.len && route->face_id == ~0) {
+ fill_face_with_info(&(route->face), &reply->route.paths[j], rs->s);
+ found = true;
+ }
+ }
+ }
+
+ return rv;
+}
+
+vapi_error_e parse_hicn_route_list( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_routes_details *reply) {
+
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
hc_data_t *data = (hc_data_t *)callback_ctx;
@@ -742,7 +1000,7 @@ vapi_error_e parse_route_list( vapi_ctx_t ctx,
for (int i = 0; i < reply->nfaces; i++) {
hc_route_t * route = &((hc_route_t*)(data->buffer))[data->current];
- route->face_id = reply->faceids[i];
+ route->face_id = ~0;
route->cost = 1;
route->len = reply->prefix.len;
if (reply->prefix.address.af == ADDRESS_IP6)
@@ -757,13 +1015,14 @@ vapi_error_e parse_route_list( vapi_ctx_t ctx,
data->current++;
}
- return reply->retval;
+ return rv;
}
int _hc_route_list(hc_sock_t *s, hc_data_t **pdata, bool async) {
vapi_lock();
- vapi_msg_hicn_api_routes_dump *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_routes_dump(s->g_vapi_ctx_instance);
+
+ vapi_msg_hicn_api_routes_dump *msg;
+ msg = vapi_alloc_hicn_api_routes_dump(s->g_vapi_ctx_instance);
hc_data_t *data = hc_data_create(0, sizeof(hc_route_t),NULL);
int ret = VAPI_OK;
@@ -781,7 +1040,28 @@ int _hc_route_list(hc_sock_t *s, hc_data_t **pdata, bool async) {
goto err_free;
}
- ret = vapi_hicn_api_routes_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, data);
+ ret = vapi_hicn_api_routes_dump(s->g_vapi_ctx_instance, msg, parse_hicn_route_list, data);
+
+ if (ret != VAPI_OK)
+ goto err_free;
+
+ vapi_msg_ip_route_dump *hicnp_msg;
+ hicnp_msg = vapi_alloc_ip_route_dump(s->g_vapi_ctx_instance);
+ hicnp_msg->payload.table.table_id = 0;
+ hicnp_msg->payload.table.is_ip6 = 1;
+
+ hicn_route_socket_t ctx = {
+ .data = data,
+ .s = s,
+ };
+
+ ret = vapi_ip_route_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, &ctx);
+
+ hicnp_msg = vapi_alloc_ip_route_dump(s->g_vapi_ctx_instance);
+ hicnp_msg->payload.table.table_id = 0;
+ hicnp_msg->payload.table.is_ip6 = 0;
+
+ ret = vapi_ip_route_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, &ctx);
if (ret != VAPI_OK)
goto err_free;
@@ -880,278 +1160,23 @@ int hc_connection_to_local_listener(const hc_connection_t *connection,
return 0;
}
-/* 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) {
-
- 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;
-
- hc_face_t *output = (hc_face_t *)data->buffer;
-
- 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_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;
-
- return reply->retval;
+ ERROR("Face creation implemented.");
+ return -1;
}
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);
-
- if (!hicnp_msg) return VAPI_ENOMEM;
-
- 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;
+ ERROR("Face deletion not 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;
-}
-
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;
+ERROR("Face list not implemented.");
+return -1;
}
int hc_connection_parse_to_face(void *in, hc_face_t *face) { return 0; }
diff --git a/ctrl/libhicnctrl/src/hicnctrl.c b/ctrl/libhicnctrl/src/hicnctrl.c
index 4be9f196c..e95b9b0eb 100644
--- a/ctrl/libhicnctrl/src/hicnctrl.c
+++ b/ctrl/libhicnctrl/src/hicnctrl.c
@@ -354,7 +354,7 @@ parse_options(int argc, char *argv[], hc_command_t * command)
switch(command->action) {
case ACTION_CREATE:
if ((argc - optind != 5) && (argc - optind != 6)) {
- usage_face_create(argv[0], true, false);
+ usage_face_create(argv[0], true, false);
goto ERR_PARAM;
}
/* NAME will be autogenerated (and currently not used) */
diff --git a/ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt
index 3739663b5..6be257656 100644
--- a/ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt
+++ b/ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt
@@ -20,7 +20,7 @@ set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set (CMAKE_INSTALL_LIBDIR "/usr/lib")
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
project(sysrepo-light-plugins)
# Cmake find modules
diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt
index e1d3dd39a..220809d71 100644
--- a/ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt
+++ b/ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt
@@ -20,7 +20,7 @@ set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set (CMAKE_INSTALL_LIBDIR "/usr/lib")
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
project(sysrepo-light-plugins)
# Cmake find modules
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt
index 705bd3cee..a89936776 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt
+++ b/ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
# Cmake find modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../cmake/Modules"
@@ -31,11 +31,13 @@ set(SOURCE_FILES
list(APPEND SYSREPO_PLUGIN_INCLUDE_DIRS
${VPP_INCLUDE_DIRS}
${HICNPLUGIN_INCLUDE_DIRS}
+ ${SYSREPO_INCLUDE_DIRS}
)
list(APPEND LIBRARIES
${SYSREPO_LIBRARIES}
- ${VPP_LIBRARIES})
+ ${VPP_LIBRARIES}
+)
build_library(sysrepohicn
SHARED
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
index dc3ac16d4..bbcc2e9bf 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Copyright (c) 2019-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:
@@ -38,8 +38,10 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) {
// HICN subscribe
hicn_subscribe_events(session, &subscription);
+ //sr_subscription_ctx_t *subscription2 = NULL;
+
// IETF subscribe
- ietf_subscribe_events(session, &subscription);
+ //ietf_subscribe_events(session, &subscription2);
/* set subscription as our private context */
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 b46b38b89..3e0c90cf9 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Copyright (c) 2016-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:
@@ -442,7 +442,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *mo
sr_change_oper_t op = SR_OP_CREATED;
sr_val_t *old_val = NULL;
sr_val_t *new_val = NULL;
- sr_xpath_ctx_t xpath_ctx = { 0, };
+ sr_xpath_ctx_t xpath_ctx = { 0 };
bool is_ipv6 = false, has_addr = false, has_prefix = false;
uint8_t addr[16] = { 0, };
uint8_t prefix = 0;
@@ -570,7 +570,8 @@ int ietf_subscribe_events(sr_session_ctx_t *session,
goto error;
}
- rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address", ietf_interface_ipv46_address_change_cb,
+ //rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address", ietf_interface_ipv46_address_change_cb,
+ rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces", ietf_interface_ipv46_address_change_cb,
NULL,
99, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
@@ -579,9 +580,9 @@ int ietf_subscribe_events(sr_session_ctx_t *session,
goto error;
}
- rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address", ietf_interface_ipv46_address_change_cb,
- NULL,
- 98, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
+ //rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address", ietf_interface_ipv46_address_change_cb,
+ // NULL,
+ // 98, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
if (rc != SR_ERR_OK) {
SRP_LOG_DBGMSG("Problem in subscription /ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address\n");
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
index dc4289379..978578039 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
@@ -29,47 +29,13 @@ fi
*Here you can find different examples to run RPC in the yang-model.
```
-<face-ip-add xmlns="urn:sysrepo:hicn">
- <lip4>192.168.1.10</lip4>
- <lip6>-1</lip6>
- <rip4>192.168.1.1</rip4>
- <rip6>-1</rip6>
- <swif>0</swif>
-</face-ip-add>
-
-<route-nhops-add xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <face_ids0>0</face_ids0>
- <face_ids1>0</face_ids1>
- <face_ids2>0</face_ids2>
- <face_ids3>0</face_ids3>
- <face_ids4>0</face_ids4>
- <face_ids5>0</face_ids5>
- <face_ids6>0</face_ids6>
- <n_faces>1</n_faces>
-</route-nhops-add>
-
-<route-nhops-del xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <faceid>0</faceid>
-</route-nhops-del>
-
-
-<face-ip-del xmlns="urn:sysrepo:hicn">
- <faceid>0</faceid>
-</face-ip-del>
-
-
-<punting-del-ip xmlns="urn:sysrepo:hicn">
- <ip4>192.168.0.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <swif>0</swif>
-</punting-del-ip>
+<hicn-enable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-enable>
+
+<hicn-disable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-disable>
```
*/
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..63685e10a 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
@@ -1,1134 +1,875 @@
/*
-* Copyright (c) 2019-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:
-*
-* 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.
-*/
-
-
+ * Copyright (c) 2019-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:
+ *
+ * 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 hicn_model.c
* @brief This file contains implementations of the main calls
*/
-
#define _GNU_SOURCE
-#include <stdio.h>
-#include <malloc.h>
-#include <sysrepo/xpath.h>
#include <inttypes.h>
-#include <unistd.h>
+#include <malloc.h>
#include <pthread.h>
-
-
-
#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <sysrepo/xpath.h>
+#include <unistd.h>
/* Hicn headers */
#include <hicn/util/ip_address.h>
+
#include "../hicn_plugin.h"
#include "../hicn_vpp_comm.h"
#include "hicn_model.h"
#include "tlock.h"
-
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
-
// Shared local variables between state and RPCs
/**
* @brief this shared variable keeps the hicn state
*/
-volatile hicn_state_t * hicn_state = NULL;
+volatile hicn_state_t *hicn_state = NULL;
/**
* @brief this shared variable keeps hicn strategies
*/
-volatile hicn_strategies_t * hicn_strategies =NULL;
+volatile hicn_strategies_t *hicn_strategies = NULL;
/**
* @brief this shared variable keeps statistics of hicn faces
*/
-volatile hicn_faces_t * hicn_faces = NULL;
+volatile hicn_faces_t *hicn_faces = NULL;
/**
* @brief this shared variable keeps routes information in hicn
*/
-volatile hicn_routes_t * hicn_routes = NULL;
+volatile hicn_routes_t *hicn_routes = NULL;
/**
- * @brief this shared variable is the link list to maintain all the faces (up to MAX_FACES)
+ * @brief this shared variable is the link list to maintain all the faces (up to
+ * MAX_FACES)
*/
-struct hicn_faces_s * fcurrent = NULL;
+struct hicn_faces_s *fcurrent = NULL;
/**
* @brief this shared variable is the link list to maintain all the routes
*/
-struct hicn_routes_s * rcurrent = NULL;
-
-
-static int init_buffer(void){
-
- hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t) );
- memset((hicn_state_t *)hicn_state, 0 , sizeof(hicn_state_t) );
+struct hicn_routes_s *rcurrent = NULL;
- hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t) );
- memset((hicn_strategies_t *) hicn_strategies, 0 , sizeof(hicn_strategies_t) );
+static int init_buffer(void) {
+ hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t));
+ memset((hicn_state_t *)hicn_state, 0, sizeof(hicn_state_t));
- hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t) );
- hicn_faces->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
- fcurrent=hicn_faces->next;
+ hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t));
+ memset((hicn_strategies_t *)hicn_strategies, 0, sizeof(hicn_strategies_t));
+ hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t));
+ hicn_faces->next = memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
+ fcurrent = hicn_faces->next;
- hicn_routes = memalign(MEM_ALIGN, sizeof(hicn_routes_t) );
- hicn_routes->next=memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
- rcurrent=hicn_routes->next;
+ hicn_routes = memalign(MEM_ALIGN, sizeof(hicn_routes_t));
+ hicn_routes->next = memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
+ rcurrent = hicn_routes->next;
+ int retval = -1;
+ ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces,
+ hicn_routes);
+ hicn_routes->nroute = 0;
+ hicn_faces->nface = 0;
+ retval = 0;
- int retval=-1;
- ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces, hicn_routes);
- hicn_routes->nroute=0;
- hicn_faces->nface=0;
- retval=0;
-
- return retval;
+ return retval;
}
-static int init_face_pool(struct hicn_faces_s * head){
-
- for(int i=0; i<MAX_FACE_POOL; i++){
- head->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
- head=head->next;
- }
- SRP_LOG_DBGMSG("Face memory pool allocated\n");
- head->next=NULL;
- return 0;
-
+static int init_face_pool(struct hicn_faces_s *head) {
+ for (int i = 0; i < MAX_FACE_POOL; i++) {
+ head->next = memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
+ head = head->next;
+ }
+ SRP_LOG_DBGMSG("Face memory pool allocated\n");
+ head->next = NULL;
+ return 0;
}
-static int init_route_pool(struct hicn_routes_s * head){
-
- for(int i=0; i<MAX_ROUTE_POOL; i++){
- head->next=memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
- head=head->next;
- }
- SRP_LOG_DBGMSG("Route memory pool allocated\n");
- head->next=NULL;
- return 0;
-
+static int init_route_pool(struct hicn_routes_s *head) {
+ for (int i = 0; i < MAX_ROUTE_POOL; i++) {
+ head->next = memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
+ head = head->next;
+ }
+ SRP_LOG_DBGMSG("Route memory pool allocated\n");
+ head->next = NULL;
+ return 0;
}
/* VAPI CALLBACKS */
-static vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_strategies_get_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-static vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_nhops_add_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-static vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_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_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){
-if(!reply->retval){
- if (callback_ctx!=NULL){
- struct hicn_faces_s * tmp;
- tmp = (struct hicn_faces_s *) callback_ctx;
+static vapi_error_e call_hicn_api_strategies_get(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_strategies_get_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_params_get(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_face_params_get_reply *reply) {
+ if (!reply->retval) {
+ if (callback_ctx != NULL) {
+ struct hicn_faces_s *tmp;
+ tmp = (struct hicn_faces_s *)callback_ctx;
tmp->face.intfc = reply->swif;
+ }
+ 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, bool is_last,
+ vapi_payload_hicn_api_node_stats_get_reply *reply) {
+ if (!reply->retval) {
+ hicn_state->pkts_processed = reply->pkts_processed;
+ hicn_state->pkts_interest_count = reply->pkts_interest_count;
+ hicn_state->pkts_data_count = reply->pkts_data_count;
+ hicn_state->pkts_from_cache_count = reply->pkts_from_cache_count;
+ hicn_state->pkts_no_pit_count = reply->pkts_no_pit_count;
+ hicn_state->pit_expired_count = reply->pit_expired_count;
+ hicn_state->cs_expired_count = reply->cs_expired_count;
+ hicn_state->cs_lru_count = reply->cs_lru_count;
+ hicn_state->pkts_drop_no_buf = reply->pkts_drop_no_buf;
+ hicn_state->interests_aggregated = reply->interests_aggregated;
+ hicn_state->interests_retx = reply->interests_retx;
+ hicn_state->pit_entries_count = reply->pit_entries_count;
+ hicn_state->cs_entries_count = reply->cs_entries_count;
+ hicn_state->cs_entries_ntw_count = reply->cs_entries_ntw_count;
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
+}
+
+static inline void state_update(sr_val_t *vals, struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ char buf[20];
+
+ sr_val_set_xpath(&vals[0], "/hicn:hicn-state/states/pkts_processed");
+ vals[0].type = SR_UINT64_T;
+ vals[0].data.uint64_val = hicn_state->pkts_processed;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_processed);
+ *parent =
+ lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)),
+ vals[0].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[1], "/hicn:hicn-state/states/pkts_interest_count");
+ vals[1].type = SR_UINT64_T;
+ vals[1].data.uint64_val = hicn_state->pkts_interest_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_interest_count);
+ lyd_new_path(*parent, NULL, vals[1].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[2], "/hicn:hicn-state/states/pkts_data_count");
+ vals[2].type = SR_UINT64_T;
+ vals[2].data.uint64_val = hicn_state->pkts_data_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_data_count);
+ lyd_new_path(*parent, NULL, vals[2].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[3], "/hicn:hicn-state/states/pkts_from_cache_count");
+ vals[3].type = SR_UINT64_T;
+ vals[3].data.uint64_val = hicn_state->pkts_from_cache_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_from_cache_count);
+ lyd_new_path(*parent, NULL, vals[3].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[4], "/hicn:hicn-state/states/pkts_no_pit_count");
+ vals[4].type = SR_UINT64_T;
+ vals[4].data.uint64_val = hicn_state->pkts_no_pit_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_no_pit_count);
+ lyd_new_path(*parent, NULL, vals[4].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[5], "/hicn:hicn-state/states/pit_expired_count");
+ vals[5].type = SR_UINT64_T;
+ vals[5].data.uint64_val = hicn_state->pit_expired_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pit_expired_count);
+ lyd_new_path(*parent, NULL, vals[5].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[6], "/hicn:hicn-state/states/cs_expired_count");
+ vals[6].type = SR_UINT64_T;
+ vals[6].data.uint64_val = hicn_state->cs_expired_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_expired_count);
+ lyd_new_path(*parent, NULL, vals[6].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[7], "/hicn:hicn-state/states/cs_lru_count");
+ vals[7].type = SR_UINT64_T;
+ vals[7].data.uint64_val = hicn_state->cs_lru_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_lru_count);
+ lyd_new_path(*parent, NULL, vals[7].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[8], "/hicn:hicn-state/states/pkts_drop_no_buf");
+ vals[8].type = SR_UINT64_T;
+ vals[8].data.uint64_val = hicn_state->pkts_drop_no_buf;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_drop_no_buf);
+ lyd_new_path(*parent, NULL, vals[8].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[9], "/hicn:hicn-state/states/interests_aggregated");
+ vals[9].type = SR_UINT64_T;
+ vals[9].data.uint64_val = hicn_state->interests_aggregated;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_aggregated);
+ lyd_new_path(*parent, NULL, vals[9].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[10], "/hicn:hicn-state/states/interests_retx");
+ vals[10].type = SR_UINT64_T;
+ vals[10].data.uint64_val = hicn_state->interests_retx;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_retx);
+ lyd_new_path(*parent, NULL, vals[10].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[11],
+ "/hicn:hicn-state/states/interests_hash_collision");
+ vals[11].type = SR_UINT64_T;
+ vals[11].data.uint64_val = hicn_state->interests_hash_collision;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_hash_collision);
+ lyd_new_path(*parent, NULL, vals[11].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[12], "/hicn:hicn-state/states/pit_entries_count");
+ vals[12].type = SR_UINT64_T;
+ vals[12].data.uint64_val = hicn_state->pit_entries_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pit_entries_count);
+ lyd_new_path(*parent, NULL, vals[12].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[13], "/hicn:hicn-state/states/cs_entries_count");
+ vals[13].type = SR_UINT64_T;
+ vals[13].data.uint64_val = hicn_state->cs_entries_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_entries_count);
+ lyd_new_path(*parent, NULL, vals[13].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[14], "/hicn:hicn-state/states/cs_entries_ntw_count");
+ vals[14].type = SR_UINT64_T;
+ vals[14].data.uint64_val = hicn_state->cs_entries_ntw_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_entries_ntw_count);
+ lyd_new_path(*parent, NULL, vals[14].xpath, buf, 0, 0);
+}
+
+static inline int routes_update(sr_val_t *vals, uint32_t nleaves,
+ struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ struct hicn_routes_s *temp = hicn_routes->next;
+ char buf[20];
+ int route = 0;
+ for (int count = 0; count < nleaves; count++) {
+ sr_val_build_xpath(&vals[route], "%s[routeid='%d']/prefix",
+ "/hicn:hicn-state/routes/route", temp->route.route_id);
+ vals[route].type = SR_STRING_T;
+
+ memset(buf, 0x00, 20);
+ if (temp->route.prefix.address.af == ADDRESS_IP4) {
+ struct sockaddr_in sa;
+ memcpy(&sa.sin_addr.s_addr, temp->route.prefix.address.un.ip4,
+ IPV4_ADDR_LEN);
+ inet_ntop(AF_INET, &(sa.sin_addr), buf, INET_ADDRSTRLEN);
+ vals[route].data.string_val = buf;
+ } else {
+ struct sockaddr_in6 sa;
+ memcpy(&sa.sin6_addr, temp->route.prefix.address.un.ip6, IPV6_ADDR_LEN);
+ inet_ntop(AF_INET6, &(sa.sin6_addr), buf, INET6_ADDRSTRLEN);
+ vals[route].data.string_val = buf;
+ }
+
+ lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
+
+ route++;
+
+ sr_val_build_xpath(&vals[route], "%s[routeid='%d']/strategy_id",
+ "/hicn:hicn-state/routes/route", temp->route.route_id);
+ vals[route].type = SR_UINT32_T;
+ vals[route].data.uint32_val = temp->route.strategy_id;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%d", temp->route.strategy_id);
+ lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
+
+ route++;
+
+ temp = temp->next;
}
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-static vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_nhop_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_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,
- bool is_last,
- vapi_payload_hicn_api_node_stats_get_reply *reply){
-
-
-if(!reply->retval){
- hicn_state->pkts_processed = reply->pkts_processed;
- hicn_state->pkts_interest_count = reply->pkts_interest_count;
- hicn_state->pkts_data_count = reply->pkts_data_count;
- hicn_state->pkts_from_cache_count = reply->pkts_from_cache_count;
- hicn_state->pkts_no_pit_count = reply->pkts_no_pit_count;
- hicn_state->pit_expired_count = reply->pit_expired_count;
- hicn_state->cs_expired_count = reply->cs_expired_count;
- hicn_state->cs_lru_count = reply->cs_lru_count;
- hicn_state->pkts_drop_no_buf = reply->pkts_drop_no_buf;
- hicn_state->interests_aggregated = reply->interests_aggregated;
- hicn_state->interests_retx = reply->interests_retx;
- hicn_state->pit_entries_count = reply->pit_entries_count;
- hicn_state->cs_entries_count = reply->cs_entries_count;
- hicn_state->cs_entries_ntw_count = reply->cs_entries_ntw_count;
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
+ SRP_LOG_DBGMSG("Routes state updated \n");
+ return SR_ERR_OK;
+}
+
+static inline int faces_update(sr_val_t *vals, uint32_t nleaves,
+ struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ struct hicn_faces_s *temp = hicn_faces->next;
+ char buf[20];
+ int face = 0;
+
+ for (int count = 0; count < nleaves; count++) {
+ 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_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;
+ }
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/intfc",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT32_T;
+ vals[face].data.uint32_val = temp->face.intfc;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%u", temp->face.intfc);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.irx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.irx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.irx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.irx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.itx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.itx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.itx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.itx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.drx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.drx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.drx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.drx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.dtx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.dtx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.dtx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.dtx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ temp = temp->next;
+ }
+ SRP_LOG_DBGMSG("Faces state updated \n");
+ return SR_ERR_OK;
+}
+
+static int hicn_state_states_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name state;
+ state = lstate;
+ SRP_LOG_DBGMSG("Requesting state data");
+
+ rc = sr_new_values(NSTATE_LEAVES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
-static inline void state_update(sr_val_t * vals, struct lyd_node **parent, sr_session_ctx_t *session){
- char buf[20];
-
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/states/pkts_processed");
- vals[0].type = SR_UINT64_T;
- vals[0].data.uint64_val = hicn_state->pkts_processed;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_processed);
- * parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), vals[0].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[1], "/hicn:hicn-state/states/pkts_interest_count");
- vals[1].type = SR_UINT64_T;
- vals[1].data.uint64_val = hicn_state->pkts_interest_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_interest_count );
- lyd_new_path(*parent, NULL, vals[1].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[2], "/hicn:hicn-state/states/pkts_data_count");
- vals[2].type = SR_UINT64_T;
- vals[2].data.uint64_val = hicn_state->pkts_data_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_data_count );
- lyd_new_path(*parent, NULL, vals[2].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[3], "/hicn:hicn-state/states/pkts_from_cache_count");
- vals[3].type = SR_UINT64_T;
- vals[3].data.uint64_val = hicn_state->pkts_from_cache_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_from_cache_count );
- lyd_new_path(*parent, NULL, vals[3].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[4], "/hicn:hicn-state/states/pkts_no_pit_count");
- vals[4].type = SR_UINT64_T;
- vals[4].data.uint64_val = hicn_state->pkts_no_pit_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_no_pit_count );
- lyd_new_path(*parent, NULL, vals[4].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[5], "/hicn:hicn-state/states/pit_expired_count");
- vals[5].type = SR_UINT64_T;
- vals[5].data.uint64_val = hicn_state->pit_expired_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pit_expired_count );
- lyd_new_path(*parent, NULL, vals[5].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[6], "/hicn:hicn-state/states/cs_expired_count");
- vals[6].type = SR_UINT64_T;
- vals[6].data.uint64_val = hicn_state->cs_expired_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_expired_count );
- lyd_new_path(*parent, NULL, vals[6].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[7], "/hicn:hicn-state/states/cs_lru_count");
- vals[7].type = SR_UINT64_T;
- vals[7].data.uint64_val = hicn_state->cs_lru_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_lru_count );
- lyd_new_path(*parent, NULL, vals[7].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[8], "/hicn:hicn-state/states/pkts_drop_no_buf");
- vals[8].type = SR_UINT64_T;
- vals[8].data.uint64_val = hicn_state->pkts_drop_no_buf;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_drop_no_buf );
- lyd_new_path(*parent, NULL, vals[8].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[9], "/hicn:hicn-state/states/interests_aggregated");
- vals[9].type = SR_UINT64_T;
- vals[9].data.uint64_val = hicn_state->interests_aggregated;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_aggregated );
- lyd_new_path(*parent, NULL, vals[9].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[10], "/hicn:hicn-state/states/interests_retx");
- vals[10].type = SR_UINT64_T;
- vals[10].data.uint64_val = hicn_state->interests_retx;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_retx );
- lyd_new_path(*parent, NULL, vals[10].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[11],
- "/hicn:hicn-state/states/interests_hash_collision");
- vals[11].type = SR_UINT64_T;
- vals[11].data.uint64_val = hicn_state->interests_hash_collision;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_hash_collision );
- lyd_new_path(*parent, NULL, vals[11].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[12], "/hicn:hicn-state/states/pit_entries_count");
- vals[12].type = SR_UINT64_T;
- vals[12].data.uint64_val = hicn_state->pit_entries_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pit_entries_count );
- lyd_new_path(*parent, NULL, vals[12].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[13], "/hicn:hicn-state/states/cs_entries_count");
- vals[13].type = SR_UINT64_T;
- vals[13].data.uint64_val = hicn_state->cs_entries_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_entries_count );
- lyd_new_path(*parent, NULL, vals[13].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[14], "/hicn:hicn-state/states/cs_entries_ntw_count");
- vals[14].type = SR_UINT64_T;
- vals[14].data.uint64_val = hicn_state->cs_entries_ntw_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_entries_ntw_count );
- lyd_new_path(*parent, NULL, vals[14].xpath, buf, 0, 0);
+ tlock(state);
+ state_update(vals, parent, session);
+ tunlock(state);
+ return SR_ERR_OK;
}
-static inline int routes_update(sr_val_t * vals, uint32_t nleaves, struct lyd_node **parent, sr_session_ctx_t *session){
-
- struct hicn_routes_s * temp = hicn_routes->next;
- char buf[20];
- int route =0;
- for(int count=0; count<nleaves; count++){
-
- sr_val_build_xpath(&vals[route], "%s[routeid='%d']/prefix", "/hicn:hicn-state/routes/route",
- temp->route.route_id);
- vals[route].type = SR_STRING_T;
-
- memset(buf, 0x00, 20);
- if (temp->route.prefix.address.af==ADDRESS_IP4){
- struct sockaddr_in sa;
- memcpy(&sa.sin_addr.s_addr, temp->route.prefix.address.un.ip4, IPV4_ADDR_LEN);
- inet_ntop(AF_INET, &(sa.sin_addr), buf, INET_ADDRSTRLEN);
- vals[route].data.string_val = buf;
- }else{
- struct sockaddr_in6 sa;
- memcpy(&sa.sin6_addr,temp->route.prefix.address.un.ip6, IPV6_ADDR_LEN);
- inet_ntop(AF_INET6, &(sa.sin6_addr), buf, INET6_ADDRSTRLEN);
- vals[route].data.string_val = buf;
- }
-
-
- lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
-
-
- route++;
+static int hicn_state_route_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name route;
+ route = lroute;
+ uint32_t NROUTE_NODES = hicn_routes->nroute * ROUTES_CHILDREN;
- sr_val_build_xpath(&vals[route], "%s[routeid='%d']/strategy_id", "/hicn:hicn-state/routes/route",
- temp->route.route_id);
- vals[route].type = SR_UINT32_T;
- vals[route].data.uint32_val = temp->route.strategy_id;
- memset(buf, 0x00, 20);
- sprintf( buf, "%d", temp->route.strategy_id);
- lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
-
- route++;
-
- temp=temp->next;
+ rc = sr_new_values(NROUTE_NODES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
-}
+ tlock(route);
+ routes_update(vals, NROUTE_NODES / ROUTES_CHILDREN, parent, session);
+ tunlock(route);
- SRP_LOG_DBGMSG("Routes state updated \n");
- return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static inline int faces_update(sr_val_t * vals, uint32_t nleaves, struct lyd_node **parent, sr_session_ctx_t *session){
-
- struct hicn_faces_s * temp = hicn_faces->next;
- char buf[20];
- int face =0;
-
-
- 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);
-
-
- 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){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
- }
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/intfc", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT32_T;
- vals[face].data.uint32_val = temp->face.intfc;
- memset(buf, 0x00, 20);
- sprintf( buf,"%u", temp->face.intfc);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.irx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.irx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.irx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.irx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.itx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.itx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
+static int hicn_state_faces_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name faces;
+ faces = lfaces;
+ uint32_t NFACES_NODES = hicn_faces->nface * FACES_CHILDREN;
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.itx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.itx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.drx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.drx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.drx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.drx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.dtx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.dtx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.dtx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.dtx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
+ rc = sr_new_values(NFACES_NODES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
- temp=temp->next;
+ tlock(faces);
+ faces_update(vals, NFACES_NODES / FACES_CHILDREN, parent, session);
+ tunlock(faces);
- }
- SRP_LOG_DBGMSG("Faces state updated \n");
- return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static int hicn_state_states_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
- sr_val_t *vals;
- int rc;
- enum locks_name state;
- state=lstate;
- SRP_LOG_DBGMSG("Requesting state data");
-
-
- rc = sr_new_values(NSTATE_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+static int hicn_strategies_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 strategies received successfully");
+ vapi_msg_hicn_api_strategies_get *msg;
+ msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
- tlock(state);
- state_update(vals,parent,session);
- tunlock(state);
-
-
- return SR_ERR_OK;
+ if (vapi_hicn_api_strategies_get(g_vapi_ctx_instance, msg,
+ call_hicn_api_strategies_get,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ return SR_ERR_OK;
}
-static int hicn_state_route_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
- sr_val_t *vals;
- int rc;
- enum locks_name route;
- route=lroute;
- uint32_t NROUTE_NODES = hicn_routes->nroute * ROUTES_CHILDREN;
-
-
-
- rc = sr_new_values(NROUTE_NODES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+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_params_get *msg;
- tlock(route);
- routes_update(vals,NROUTE_NODES/ROUTES_CHILDREN, parent, session);
- tunlock(route);
+ msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance);
+ msg->payload.faceid = input[0].data.uint32_val;
- return SR_ERR_OK;
-
- }
-
-
- static int hicn_state_faces_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
-
-
- sr_val_t *vals;
- int rc;
- enum locks_name faces;
- faces=lfaces;
- uint32_t NFACES_NODES = hicn_faces->nface * FACES_CHILDREN;
-
- rc = sr_new_values(NFACES_NODES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
-
- tlock(faces);
- faces_update(vals, NFACES_NODES/FACES_CHILDREN, parent, session);
- tunlock(faces);
-
- return SR_ERR_OK;
-
- }
-
-static int hicn_strategies_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 strategies received successfully");
-vapi_msg_hicn_api_strategies_get *msg;
-
-msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
-
-if (vapi_hicn_api_strategies_get(g_vapi_ctx_instance, msg, call_hicn_api_strategies_get, NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_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;
+ }
+ return SR_ERR_OK;
}
-static int hicn_route_nhops_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 route nhops add received successfully");
- vapi_msg_hicn_api_route_nhops_add *msg;
-
- msg = vapi_alloc_hicn_api_route_nhops_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.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.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
-
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
-
- 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;
- msg->payload.face_ids[3] = input[6].data.uint32_val;
- msg->payload.face_ids[4] = input[7].data.uint32_val;
- msg->payload.face_ids[5] = input[8].data.uint32_val;
- msg->payload.face_ids[6] = input[9].data.uint32_val;
- msg->payload.n_faces = input[10].data.uint8_val;
-
-
-if(vapi_hicn_api_route_nhops_add(g_vapi_ctx_instance,msg,call_hicn_api_route_nhops_add,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
+static vapi_error_e call_hicn_api_enable_disable(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_enable_disable_reply *reply) {
+ if (!reply->retval) {
+ SRP_LOG_DBGMSG("Successfully done");
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
}
-return SR_ERR_OK;
-}
-
-static int hicn_route_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 route del received successfully");
- vapi_msg_hicn_api_route_del *msg;
- msg = vapi_alloc_hicn_api_route_del(g_vapi_ctx_instance);
+static int hicn_enable_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 enable received successfully");
+ vapi_msg_hicn_api_enable_disable *msg;
- if(strcmp(input[0].data.string_val,"-1")){
+ msg = vapi_alloc_hicn_api_enable_disable(g_vapi_ctx_instance);
- 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.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.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
-
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ const char *delim = "/";
+ if (input->type != SR_STRING_T) {
+ SRP_LOG_DBGMSG("Expected prefix of type string");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ char *token;
+
+ /* get the first token */
+ token = strtok(input->data.string_val, delim);
+
+ /* if null the address is ipv4 else ipv6*/
+ if (strrchr(token, ':') == NULL) {
+ struct sockaddr_in sa;
+ inet_pton(AF_INET, token, &(sa.sin_addr));
+ unsigned char *tmp = (unsigned char *)&sa.sin_addr.s_addr;
+ memcpy(&msg->payload.prefix.address.un.ip4[0], tmp, B32);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
+ } else {
+ void *dst = malloc(sizeof(struct in6_addr));
+ inet_pton(AF_INET6, token, dst);
+ unsigned char *tmp = (unsigned char *)((struct in6_addr *)dst)->s6_addr;
+ memcpy(&msg->payload.prefix.address.un.ip6[0], tmp, B128);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
+ }
+ /* The second token is the prefix len*/
+ token = strtok(NULL, delim);
- msg->payload.prefix.len = input[2].data.uint8_val;
+ msg->payload.prefix.len = atoi(token);
+ msg->payload.enable_disable = 1;
+ if (vapi_hicn_api_enable_disable(g_vapi_ctx_instance, msg,
+ call_hicn_api_enable_disable,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
-if(vapi_hicn_api_route_del(g_vapi_ctx_instance,msg,call_hicn_api_route_del,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
+ return SR_ERR_OK;
}
-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,
- 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;
-
- msg = vapi_alloc_hicn_api_face_ip_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){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
-}
+static int hicn_disable_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 disable received successfully");
+ vapi_msg_hicn_api_enable_disable *msg;
-static int hicn_route_nhops_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) {
+ msg = vapi_alloc_hicn_api_enable_disable(g_vapi_ctx_instance);
- SRP_LOG_DBGMSG("hicn route nhop del received successfully");
- // allocate memory msg
- vapi_msg_hicn_api_route_nhop_del *msg;
-
- msg = vapi_alloc_hicn_api_route_nhop_del(g_vapi_ctx_instance);
-
-
- 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));
- unsigned char * tmp = (unsigned char *) &sa.sin_addr.s_addr;
- 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.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
-
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
-
-
- msg->payload.prefix.len = input[2].data.uint8_val;
- msg->payload.faceid = input[3].data.uint32_val;
-
-
-if (vapi_hicn_api_route_nhop_del(g_vapi_ctx_instance, msg, call_hicn_api_route_nhop_del,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-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) {
+ const char *delim = "/";
+ if (input->type != SR_STRING_T) {
+ SRP_LOG_DBGMSG("Expected prefix of type string");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ char *token;
+
+ /* get the first token */
+ token = strtok(input->data.string_val, delim);
+
+ /* if null the address is ipv4 else ipv6*/
+ if (strrchr(token, ':') == NULL) {
+ struct sockaddr_in sa;
+ inet_pton(AF_INET, token, &(sa.sin_addr));
+ unsigned char *tmp = (unsigned char *)&sa.sin_addr.s_addr;
+ memcpy(&msg->payload.prefix.address.un.ip4[0], tmp, B32);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
+ } else {
+ void *dst = malloc(sizeof(struct in6_addr));
+ inet_pton(AF_INET6, token, dst);
+ unsigned char *tmp = (unsigned char *)((struct in6_addr *)dst)->s6_addr;
+ memcpy(&msg->payload.prefix.address.un.ip6[0], tmp, B128);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
+ }
- SRP_LOG_DBGMSG("hicn face ip del received successfully");
- // allocate memory msg
- vapi_msg_hicn_api_face_ip_del *msg;
+ /* The second token is the prefix len*/
+ token = strtok(NULL, delim);
- msg = vapi_alloc_hicn_api_face_ip_del(g_vapi_ctx_instance);
- msg->payload.faceid = input[0].data.uint32_val;
+ msg->payload.prefix.len = atoi(token);
+ msg->payload.enable_disable = 0;
+ if (vapi_hicn_api_enable_disable(g_vapi_ctx_instance, msg,
+ call_hicn_api_enable_disable,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
-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;
+ 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,
+ vapi_payload_hicn_api_routes_details *reply) {
+ static int counter = 0;
-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")){
+ tlock(lroute);
+ if (reply != NULL) {
+ rcurrent->route.route_id = counter;
+ rcurrent->route.prefix = reply->prefix;
+ rcurrent->route.nfaces = reply->nfaces;
+ rcurrent->route.strategy_id = reply->strategy_id;
+ for (int cnt = 0; cnt < rcurrent->route.nfaces; cnt++)
+ rcurrent->route.faceids[cnt] = rcurrent->route.faceids[cnt];
- 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;
+ counter++;
+ rcurrent = rcurrent->next;
+ SRP_LOG_DBG("nfaces %d", reply->nfaces);
+ SRP_LOG_DBG("strategy_id %d", reply->strategy_id);
- }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,
- vapi_payload_hicn_api_routes_details *reply)
-{
-
- static int counter = 0;
-
- tlock(lroute);
- if (reply!=NULL){
- rcurrent->route.route_id = counter;
- rcurrent->route.prefix = reply->prefix;
- rcurrent->route.nfaces = reply->nfaces;
- rcurrent->route.strategy_id = reply->strategy_id;
- for(int cnt=0;cnt<rcurrent->route.nfaces;cnt++)
- rcurrent->route.faceids[cnt] = rcurrent->route.faceids[cnt];
-
- counter++;
- rcurrent = rcurrent->next;
-
- SRP_LOG_DBG("nfaces %d", reply->nfaces);
- SRP_LOG_DBG("strategy_id %d", reply->strategy_id);
-
- }else
- {
- SRP_LOG_DBGMSG("---------Routes------- \n");
- hicn_routes->nroute=counter;
- counter=0;
- rcurrent=hicn_routes->next;
- }
- tunlock(lroute);
- return SR_ERR_OK;
-
-}
-
-
-static vapi_error_e
-hicn_api_face_stats_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_hicn_api_face_stats_details *reply)
-{
-
- static int counter = 0;
-
- tlock(lfaces);
- if (reply!=NULL){
-
- fcurrent->face.faceid = reply->faceid;
- fcurrent->face.intfc = 1;
- fcurrent->face.irx_packets = reply->irx_packets;
- fcurrent->face.irx_bytes = reply->irx_bytes;
- fcurrent->face.itx_packets = reply->itx_packets;
- fcurrent->face.itx_bytes = reply->itx_bytes;
- fcurrent->face.drx_packets = reply->drx_packets;
- fcurrent->face.drx_bytes = reply->drx_bytes;
- fcurrent->face.dtx_packets = reply->dtx_packets;
- fcurrent->face.dtx_bytes = reply->dtx_bytes;
- counter++;
- fcurrent = fcurrent->next;
- SRP_LOG_DBG("faceid %d", reply->faceid);
- SRP_LOG_DBG("drxB %d", reply->drx_bytes);
- SRP_LOG_DBG("dtxB %d", reply->dtx_bytes);
-
- }else
- {
- SRP_LOG_DBGMSG("---------Faces------- \n");
- hicn_faces->nface=counter;
- counter=0;
- fcurrent=hicn_faces->next;
- }
- tunlock(lfaces);
- return SR_ERR_OK;
+ } else {
+ SRP_LOG_DBGMSG("---------Routes------- \n");
+ hicn_routes->nroute = counter;
+ counter = 0;
+ rcurrent = hicn_routes->next;
+ }
+ tunlock(lroute);
+ return SR_ERR_OK;
+}
+
+static vapi_error_e hicn_api_face_stats_dump_cb(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_face_stats_details *reply) {
+ static int counter = 0;
+
+ tlock(lfaces);
+ if (reply != NULL) {
+ fcurrent->face.faceid = reply->faceid;
+ fcurrent->face.intfc = 1;
+ fcurrent->face.irx_packets = reply->irx_packets;
+ fcurrent->face.irx_bytes = reply->irx_bytes;
+ fcurrent->face.itx_packets = reply->itx_packets;
+ fcurrent->face.itx_bytes = reply->itx_bytes;
+ fcurrent->face.drx_packets = reply->drx_packets;
+ fcurrent->face.drx_bytes = reply->drx_bytes;
+ fcurrent->face.dtx_packets = reply->dtx_packets;
+ fcurrent->face.dtx_bytes = reply->dtx_bytes;
+ counter++;
+ fcurrent = fcurrent->next;
+ SRP_LOG_DBG("faceid %d", reply->faceid);
+ SRP_LOG_DBG("drxB %d", reply->drx_bytes);
+ SRP_LOG_DBG("dtxB %d", reply->dtx_bytes);
+
+ } else {
+ SRP_LOG_DBGMSG("---------Faces------- \n");
+ hicn_faces->nface = counter;
+ counter = 0;
+ fcurrent = hicn_faces->next;
+ }
+ tunlock(lfaces);
+ return SR_ERR_OK;
}
-
static void *state_thread(void *arg) {
+ // mapping can be retrieved by cpuinfo
+ int map = 0;
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(map, &cpuset);
+
+ // pin the thread to a core
+ if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
+ SRP_LOG_DBGMSG("Thread pining failed\n");
+ exit(1);
+ }
- // mapping can be retrieved by cpuinfo
- int map = 0;
- cpu_set_t cpuset;
- CPU_ZERO(&cpuset);
- CPU_SET(map, &cpuset);
-
- // pin the thread to a core
- if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset))
- {
- SRP_LOG_DBGMSG("Thread pining failed\n");
- exit(1);
- }
-
- vapi_msg_hicn_api_node_stats_get *msg=NULL;
- enum locks_name state;
- state=lstate;
-
- while(true){
-
- // dump faces
- vapi_msg_hicn_api_face_stats_dump *fmsg;
- fmsg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
- vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, fmsg, hicn_api_face_stats_dump_cb, fcurrent);
-
- // dump routes
- vapi_msg_hicn_api_routes_dump *rmsg;
- rmsg = vapi_alloc_hicn_api_routes_dump(g_vapi_ctx_instance);
- vapi_hicn_api_routes_dump(g_vapi_ctx_instance, rmsg, hicn_api_routes_dump_cb, rcurrent);
+ vapi_msg_hicn_api_node_stats_get *msg = NULL;
+ enum locks_name state;
+ state = lstate;
+ while (true) {
+ tlock(state);
+ // dump faces
+ vapi_msg_hicn_api_face_stats_dump *fmsg;
+ fmsg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, fmsg,
+ hicn_api_face_stats_dump_cb, fcurrent);
+ // dump routes
+ vapi_msg_hicn_api_routes_dump *rmsg;
+ rmsg = vapi_alloc_hicn_api_routes_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_routes_dump(g_vapi_ctx_instance, rmsg,
+ hicn_api_routes_dump_cb, rcurrent);
- msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
+ msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
+ if (vapi_hicn_api_node_stats_get(g_vapi_ctx_instance, msg,
+ call_vapi_hicn_api_node_stats_get,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG(" State operation failed");
+ }
- tlock(state);
+ tunlock(state);
+ sleep(1);
- if(vapi_hicn_api_node_stats_get(g_vapi_ctx_instance,msg,call_vapi_hicn_api_node_stats_get,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG(" State operation failed");
+ SRP_LOG_DBGMSG("state cached");
}
+ return NULL;
+}
+int hicn_subscribe_events(sr_session_ctx_t *session,
+ sr_subscription_ctx_t **subscription) {
+ int rc = SR_ERR_OK;
+ SRP_LOG_DBGMSG("Subscriging hicn.");
+
+ // Initializing the locks
+ for (int i = 0; i < NLOCKS; i++) ticket_init(i, LOCK_INIT);
+
+ // Initializing the buffer
+ rc = init_buffer();
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in initializing the buffers\n");
+ goto error;
+ }
- tunlock(state);
- sleep(1);
-
- SRP_LOG_DBGMSG("state cached");
+ SRP_LOG_DBGMSG("buffer initialized successfully.");
- }
- return NULL;
-}
+ rc = init_face_pool(fcurrent);
+ if (rc) {
+ SRP_LOG_DBGMSG("Problem in initializing the pools\n");
+ goto error;
+ }
+ rc = init_route_pool(rcurrent);
+ if (rc) {
+ SRP_LOG_DBGMSG("Problem in initializing the pools\n");
+ goto error;
+ }
-int hicn_subscribe_events(sr_session_ctx_t *session,
- sr_subscription_ctx_t **subscription) {
- int rc = SR_ERR_OK;
- SRP_LOG_DBGMSG("Subscriging hicn.");
+ SRP_LOG_DBGMSG("pools created successfully.");
- //Initializing the locks
- for (int i=0; i<NLOCKS; i++)
- ticket_init(i,LOCK_INIT);
+ // Create state thread observation
+ pthread_t state_tid;
+ rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
+ if (rc != 0) {
+ SRP_LOG_DBGMSG("Error making hicn state thread");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ SRP_LOG_DBGMSG("State thread created successfully.");
- //Initializing the buffer
- rc=init_buffer();
- if(rc!= SR_ERR_OK){
- SRP_LOG_DBGMSG("Problem in initializing the buffers\n");
- goto error;
- }
+ // strategies subscriptions
- SRP_LOG_DBGMSG("buffer initialized successfully.");
+ rc = sr_rpc_subscribe(session, "/hicn:strategies-get", hicn_strategies_get_cb,
+ session, 98, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription strategies-get\n");
+ goto error;
+ }
+ // face ip subscriptions
- rc=init_face_pool(fcurrent);
- if(rc){
- SRP_LOG_DBGMSG("Problem in initializing the pools\n");
- goto error;
- }
+ 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-params-get\n");
+ goto error;
+ }
+ // hICN enable-disable subscriptions
- rc=init_route_pool(rcurrent);
- if(rc){
- SRP_LOG_DBGMSG("Problem in initializing the pools\n");
- goto error;
- }
+ rc = sr_rpc_subscribe(session, "/hicn:hicn-enable", hicn_enable_cb, session,
+ 94, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription hicn-enable\n");
+ goto error;
+ }
+ rc = sr_rpc_subscribe(session, "/hicn:hicn-disable", hicn_disable_cb, session,
+ 95, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription hicn-enable\n");
+ goto error;
+ }
- SRP_LOG_DBGMSG("pools created successfully.");
+ // subscribe as hicn state data provider
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/states",
+ hicn_state_states_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/states\n");
+ goto error;
+ }
- // Create state thread observation
- pthread_t state_tid;
- rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
- if (rc != 0) {
- SRP_LOG_DBGMSG("Error making hicn state thread");
- return SR_ERR_OPERATION_FAILED;
- }
- SRP_LOG_DBGMSG("State thread created successfully.");
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/routes",
+ hicn_state_route_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/routes\n");
+ goto error;
+ }
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/faces",
+ hicn_state_faces_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/faces\n");
+ goto error;
+ }
-/*
- // subscripe for edit-config
- rc = sr_module_change_subscribe(
- session, "hicn","/hicn:hicn-conf", hicn_node_params_set_cb, g_vapi_ctx_instance,
- 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
- if (SR_ERR_OK != rc) {
- //SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-conf\n");
- perror("Problem in subscription /hicn:hicn-conf\n");
- goto error;
- }
-*/
-
- // strategies subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:strategies-get",
- hicn_strategies_get_cb, session, 98,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription strategies-get\n");
- goto error;
- }
-
- // route nhops subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add",
- hicn_route_nhops_add_cb, session, 95,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-nhops-add\n");
- goto error;
- }
-
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-del",
- hicn_route_nhops_del_cb, session, 94,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-nhops-del\n");
- goto error;
- }
-
- rc = sr_rpc_subscribe(session, "/hicn:route-del", hicn_route_del_cb,
- session, 96,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-del\n");
- goto error;
- }
-
- // 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);
- 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",
- hicn_state_states_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/states\n");
- goto error;
- }
-
-
- rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/routes",
- hicn_state_route_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/routes\n");
- goto error;
- }
-
-
- rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/faces",
- hicn_state_faces_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/faces\n");
- goto error;
- }
-
-
- SRP_LOG_DBGMSG("hicn plugin initialized successfully.\n");
- return SR_ERR_OK;
+ SRP_LOG_DBGMSG("hicn plugin initialized successfully.\n");
+ return SR_ERR_OK;
error:
- SRP_LOG_ERRMSG("Error by initialization of the hicn plugin.");
- sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
- return rc;
+ SRP_LOG_ERRMSG("Error by initialization of the hicn plugin.");
+ sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
+ return rc;
}
diff --git a/ctrl/sysrepo-plugins/yang/hicn/hicn.yang b/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
index de09fcdb9..0514a7a2a 100644
--- a/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
+++ b/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
@@ -1,426 +1,247 @@
module hicn {
-namespace "urn:sysrepo:hicn";
-prefix hcn;
+ namespace "urn:sysrepo:hicn";
+ prefix hcn;
-
-revision 2019-10-30{
- description "revised revision focus on telemetry.";
-}
-
-/* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */
-
-typedef float {
- type decimal64 {
- fraction-digits 2;
- }
-}
-
-grouping face_ip_add {
-
-leaf lip4 {
- description "IP version 4 local address.";
- type string;
- }
-
-leaf lip6 {
- description "IP version 6 local address.";
- type string;
- }
-
-leaf rip4 {
- description "IP version 4 local address.";
- type string;
- }
-
-leaf rip6 {
- description "IP version 6 local address.";
- type string;
- }
-
-leaf swif {
- description "Interface Index.";
- type uint32;
- }
-}
-
-grouping route_nhops_add {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-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 ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-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 uint32;
- }
-
-}
-
-grouping route_del {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
- }
-}
-
-grouping punting_add_ip {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
+ import ietf-inet-types {
+ prefix inet;
}
-leaf swif {
- description "Interface id.";
- type uint32;
+ revision 2020-04-29{
+ description "revised revision focus on telemetry.";
}
-}
-
-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;
- }
+ /* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */
- 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;
+ typedef float {
+ type decimal64 {
+ fraction-digits 2;
}
+ }
- leaf interests_hash_collision {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ grouping states-reply {
- leaf pit_entries_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ leaf pkts_processed {
+ description "ICN packets processed.";
+ type uint64;
+ }
- leaf cs_entries_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ leaf pkts_interest_count {
+ description "PIT maximum size, 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;
- }
+ 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;
+ }
-grouping face-stats-reply {
- list face{
- key faceid;
- leaf faceid {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint32;
+ leaf pkts_no_pit_count {
+ description "Default PIT entry lifetime, otherwise -1 to assign default value.";
+ type uint64;
}
- leaf intfc {
- description "This is the idx number of the faceid.";
- type uint32;
+ leaf pit_expired_count {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value.";
+ type uint64;
}
- leaf irx_packets {
+ leaf cs_expired_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf irx_bytes {
+ leaf cs_lru_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf itx_packets {
+ leaf pkts_drop_no_buf {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf itx_bytes {
+ leaf interests_aggregated {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
-
- leaf drx_packets {
+ leaf interests_retx {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf drx_bytes {
+ leaf interests_hash_collision {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf dtx_packets {
+ 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 dtx_bytes {
+ leaf cs_entries_ntw_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
+
}
-}
-grouping route-reply {
+ grouping face-stats-reply {
+ list face{
+ key faceid;
+ leaf faceid {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint32;
+ }
- list route{
- key routeid;
- leaf routeid {
- description "the unique key for each item.";
- type uint32;
- }
- leaf prefix {
- description "IP address.";
- type string;
-
- }
- leaf strategy_id {
- description "compile-time plugin features.";
- type uint32;
- }
- }
-}
+ leaf intfc {
+ description "This is the idx number of the faceid.";
+ type uint32;
+ }
-grouping strategies-reply {
- leaf n_strategies {
- description "Enable / disable ICN forwarder in VPP.";
- type uint8;
- }
- leaf strategy_id {
- description "Enable / disable ICN forwarder in VPP.";
- type uint32;
- }
+ leaf irx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-}
+ leaf irx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ leaf itx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-/* Hicn operational data */
+ leaf itx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-container hicn-state {
- config false;
- description "operational data container for the hicn.";
- container faces{
- uses face-stats-reply;
- }
- container states{
- uses states-reply;
- }
- container routes{
- uses route-reply;
- }
-}
+ leaf drx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ leaf drx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-/* RPC Definitions */
+ leaf dtx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-rpc strategies-get {
- description "Operation to get hicn strategies.";
-}
-rpc route-del {
- description "Operation to del hicn route.";
- input {
- uses route_del;
+ leaf dtx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ }
}
-}
-rpc route-nhops-add {
- description "Operation to add hicn route nhops.";
- input {
- uses route_nhops_add;
+ grouping route-reply {
+
+ list route{
+ key routeid;
+ leaf routeid {
+ description "the unique key for each item.";
+ type uint32;
+ }
+ leaf prefix {
+ description "IP address.";
+ type string;
+
+ }
+ leaf strategy_id {
+ description "compile-time plugin features.";
+ type uint32;
+ }
}
-}
+ }
+
+ grouping strategies-reply {
+ leaf n_strategies {
+ description "Enable / disable ICN forwarder in VPP.";
+ type uint8;
+ }
+ leaf strategy_id {
+ description "Enable / disable ICN forwarder in VPP.";
+ type uint32;
+ }
-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 uint32;
+ typedef hicn-prefix {
+ description "hICN prefix.";
+ type inet:ip-prefix;
+ }
+
+
+ /* Hicn operational data */
+
+ container hicn-state {
+
+ config false;
+ description "operational data container for the hicn.";
+ container faces{
+ uses face-stats-reply;
+ }
+ container states{
+ uses states-reply;
+ }
+ container routes{
+ uses route-reply;
}
}
-}
-rpc face-ip-add {
- description "Operation to add hicn face ip.";
- input {
- uses face_ip_add;
+
+ /* RPC Definitions */
+
+ rpc strategies-get {
+ description "Operation to get hicn strategies.";
}
-}
-rpc face-ip-del {
- description "Operation to del hicn face ip.";
- input {
- leaf faceid {
- description "Face to be deleted .";
- type uint32;
+ rpc face-params-get {
+ description "Operation to del hicn route.";
+ input {
+ leaf faceid {
+ description "Face to be retrieved .";
+ type uint32;
+ }
}
}
-}
-rpc punting-add-ip {
- description "Operation to add hicn punt.";
- input {
- uses punting_add_ip;
+ rpc hicn-enable {
+ description "Enable hicn on a gie prefix.";
+ input {
+ leaf prefix {
+ type hicn-prefix;
+ }
+ }
}
-}
-rpc punting-del-ip {
- description "Operation to del hicn punt.";
- input {
- uses punting_add_ip; /* It uses the same payload as the add*/
+ rpc hicn-disable {
+ description "Disable hicn on a gie prefix.";
+ input {
+ leaf prefix {
+ type hicn-prefix;
+ }
+ }
}
-}
-
}