aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/facemgr/includes
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-23 17:55:00 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-24 00:21:47 +0200
commit8e12c8e42cc9ea9d12e55a3a0d8fbcb211504c04 (patch)
tree1556919c967bd1b6ea664c1f80d6d43efb805f59 /ctrl/facemgr/includes
parentcf3d6ef0cbda50c9917421213a77097250f3d67b (diff)
[HICN-352] facemgr event loop enhancement; timer support & async hicn-light interface
Change-Id: I920a0eb091d826e1eb0d1f786fb0b437487f7ff7 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr/includes')
-rw-r--r--ctrl/facemgr/includes/CMakeLists.txt2
-rw-r--r--ctrl/facemgr/includes/hicn/facemgr/api.h18
-rw-r--r--ctrl/facemgr/includes/hicn/facemgr/cfg.h6
-rw-r--r--ctrl/facemgr/includes/hicn/facemgr/loop.h90
4 files changed, 112 insertions, 4 deletions
diff --git a/ctrl/facemgr/includes/CMakeLists.txt b/ctrl/facemgr/includes/CMakeLists.txt
index 566424c67..e7265eebb 100644
--- a/ctrl/facemgr/includes/CMakeLists.txt
+++ b/ctrl/facemgr/includes/CMakeLists.txt
@@ -22,8 +22,10 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(TO_INSTALL_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/facemgr.h
+
${CMAKE_CURRENT_SOURCE_DIR}/hicn/facemgr/api.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn/facemgr/cfg.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/hicn/facemgr/loop.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn/util/log.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn/android_utility/android_utility.h
PARENT_SCOPE
diff --git a/ctrl/facemgr/includes/hicn/facemgr/api.h b/ctrl/facemgr/includes/hicn/facemgr/api.h
index c5c29c219..e6151da11 100644
--- a/ctrl/facemgr/includes/hicn/facemgr/api.h
+++ b/ctrl/facemgr/includes/hicn/facemgr/api.h
@@ -26,6 +26,18 @@
#include <hicn/android_utility/android_utility.h>
#endif
+/* facemgr callbacks */
+
+typedef enum {
+ FACEMGR_CB_TYPE_REGISTER_FD,
+ FACEMGR_CB_TYPE_UNREGISTER_FD,
+ FACEMGR_CB_TYPE_REGISTER_TIMER,
+ FACEMGR_CB_TYPE_UNREGISTER_TIMER,
+} facemgr_cb_type_t;
+
+typedef int (*facemgr_cb_t)(void * loop, facemgr_cb_type_t type, void * data);
+
+
/*
* \brief Manual overlay settings (alternative to service discovery)
*/
@@ -64,11 +76,11 @@ facemgr_t * facemgr_create_with_config(facemgr_cfg_t * cfg);
void facemgr_stop(facemgr_t *);
void facemgr_free(facemgr_t *);
+
+void facemgr_set_callback(facemgr_t * facemgr, void * callback_owner, facemgr_cb_t callback);
+
int facemgr_set_config(facemgr_t * facemgr, facemgr_cfg_t * cfg);
int facemgr_reset_config(facemgr_t * facemgr);
-void facemgr_set_event_loop_handler(facemgr_t * facemgr, void * loop,
- void * loop_register_fd,
- void * loop_unregister_event);
int facemgr_bootstrap(facemgr_t * facemgr);
#ifdef __ANDROID__
void facemgr_set_jvm(facemgr_t * facemgr, JavaVM *jvm);
diff --git a/ctrl/facemgr/includes/hicn/facemgr/cfg.h b/ctrl/facemgr/includes/hicn/facemgr/cfg.h
index c121c687f..525e1a9e3 100644
--- a/ctrl/facemgr/includes/hicn/facemgr/cfg.h
+++ b/ctrl/facemgr/includes/hicn/facemgr/cfg.h
@@ -91,7 +91,7 @@ typedef struct {
#define FACEMGR_CFG_DEFAULT_DISCOVERY true
//#define DEFAULT_IGNORE "lo"
#define FACEMGR_CFG_DEFAULT_IPV4 true
-#define FACEMGR_CFG_DEFAULT_IPV6 true
+#define FACEMGR_CFG_DEFAULT_IPV6 false
@@ -140,6 +140,10 @@ int facemgr_cfg_set_face_type(facemgr_cfg_t * cfg, facemgr_face_type_t * face_ty
int facemgr_cfg_unset_face_type(facemgr_cfg_t * cfg);
int facemgr_cfg_set_discovery(facemgr_cfg_t * cfg, bool status);
int facemgr_cfg_unset_discovery(facemgr_cfg_t * cfg);
+int facemgr_cfg_set_ipv4(facemgr_cfg_t * cfg, bool status);
+int facemgr_cfg_unset_ipv4(facemgr_cfg_t * cfg);
+int facemgr_cfg_set_ipv6(facemgr_cfg_t * cfg, bool status);
+int facemgr_cfg_unset_ipv6(facemgr_cfg_t * cfg);
int facemgr_cfg_set_overlay(facemgr_cfg_t * cfg, int family,
ip_address_t * local_addr, uint16_t local_port,
diff --git a/ctrl/facemgr/includes/hicn/facemgr/loop.h b/ctrl/facemgr/includes/hicn/facemgr/loop.h
new file mode 100644
index 000000000..77cbedb21
--- /dev/null
+++ b/ctrl/facemgr/includes/hicn/facemgr/loop.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * \file loop.h
+ * \brief Face manager main loop
+ */
+
+#ifndef FACEMGR_LOOP_H
+#define FACEMGR_LOOP_H
+
+#include <hicn/facemgr/api.h>
+
+/* fd & timer callbacks */
+
+typedef int (*fd_callback_t)(void * owner, int fd, void * data);
+
+typedef struct {
+ int fd;
+ void *owner;
+ fd_callback_t callback;
+ //int (*callback)(void * owner, int fd, void * data);
+ void *data;
+} fd_callback_data_t;
+
+/* timer callbacks */
+typedef struct {
+ unsigned delay_ms;
+ void *owner;
+ fd_callback_t callback;
+ //int (*callback)(void * owner, int fd, void * data);
+ void *data;
+} timer_callback_data_t;
+
+/* loop */
+
+typedef struct loop_s loop_t;
+
+/**
+ * \brief Creates a main loop
+ * \return Pointer to the newly created loop, or NULL in case of error
+ */
+loop_t * loop_create();
+
+/**
+ * \brief Releases a loop instance and frees all associated memory
+ * \param [in] loop - Pointer to the loop instance to free
+ */
+void loop_free(loop_t * loop);
+
+/**
+ * \brief Runs the loop instance to process events
+ * \param [in] loop - Pointer to the loop instance
+ */
+void loop_dispatch(loop_t * loop);
+
+/**
+ * \brief Terminates the dispatching of events
+ * \param [in] loop - Pointer to the loop instance
+ */
+void loop_undispatch(loop_t * loop);
+
+/**
+ * \brief Breaks out of the loop
+ * \param [in] loop - Pointer to the loop instance
+ */
+void loop_break(loop_t * loop);
+
+
+/**
+ * \brief Callback for loop helpers
+ * \param [in] loop - Pointer to the loop instance
+ * \param [in] type - Type of service to be requested
+ * \param [in] data - Service specific data
+ */
+int loop_callback(loop_t * loop, facemgr_cb_type_t type, void * data);
+
+#endif /* FACEMGR_LOOP_H */