summaryrefslogtreecommitdiff
path: root/src/ipcpd/local
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-21 09:11:38 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-21 09:11:38 +0000
commit5b242e7207483860143d3c84438134430ac1448f (patch)
treea04a750b802436a4e244d8224b800a2f26071091 /src/ipcpd/local
parentafe8b6f496dd4e0e3aaaa5dec0d6fb32253a49f7 (diff)
parent8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e (diff)
downloadouroboros-5b242e7207483860143d3c84438134430ac1448f.tar.gz
ouroboros-5b242e7207483860143d3c84438134430ac1448f.zip
Merged in dstaesse/ouroboros/be-build (pull request #557)
build: Revise the build system
Diffstat (limited to 'src/ipcpd/local')
-rw-r--r--src/ipcpd/local/CMakeLists.txt2
-rw-r--r--src/ipcpd/local/main.c34
2 files changed, 25 insertions, 11 deletions
diff --git a/src/ipcpd/local/CMakeLists.txt b/src/ipcpd/local/CMakeLists.txt
index 824b4ca6..925092bd 100644
--- a/src/ipcpd/local/CMakeLists.txt
+++ b/src/ipcpd/local/CMakeLists.txt
@@ -12,7 +12,7 @@ include_directories(${CURRENT_BINARY_PARENT_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
-set(IPCP_LOCAL_TARGET ipcpd-local CACHE STRING "IPCP_LOCAL")
+set(IPCP_LOCAL_TARGET ipcpd-local CACHE INTERNAL "")
set(SHIM_LOCAL_SOURCES
# Add source files here
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 241a47eb..37d23fc3 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "ipcpd-local"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
@@ -33,6 +36,7 @@
#include <ouroboros/local-dev.h>
#include "ipcp.h"
+#include "shim-data.h"
#include <string.h>
#include <stdlib.h>
@@ -44,18 +48,20 @@
#define THIS_TYPE IPCP_LOCAL
struct {
- int in_out[IRMD_MAX_FLOWS];
- flow_set_t * flows;
- fqueue_t * fq;
+ struct shim_data * shim_data;
- pthread_rwlock_t lock;
- pthread_t sduloop;
+ int in_out[SYS_MAX_FLOWS];
+ flow_set_t * flows;
+ fqueue_t * fq;
+
+ pthread_rwlock_t lock;
+ pthread_t sduloop;
} local_data;
static int local_data_init(void)
{
int i;
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
local_data.in_out[i] = -1;
local_data.flows = flow_set_create();
@@ -68,12 +74,20 @@ static int local_data_init(void)
return -ENOMEM;
}
+ local_data.shim_data = shim_data_create();
+ if (local_data.shim_data == NULL) {
+ fqueue_destroy(local_data.fq);
+ flow_set_destroy(local_data.flows);
+ return -ENOMEM;
+ }
+
pthread_rwlock_init(&local_data.lock, NULL);
return 0;
}
static void local_data_fini(void){
+ shim_data_destroy(local_data.shim_data);
flow_set_destroy(local_data.flows);
fqueue_destroy(local_data.fq);
pthread_rwlock_destroy(&local_data.lock);
@@ -142,7 +156,7 @@ static int ipcp_local_reg(const uint8_t * hash)
return -ENOMEM;
}
- if (shim_data_reg_add_entry(ipcpi.shim_data, hash_dup)) {
+ if (shim_data_reg_add_entry(local_data.shim_data, hash_dup)) {
log_dbg("Failed to add " HASH_FMT " to local registry.",
HASH_VAL(hash));
free(hash_dup);
@@ -156,7 +170,7 @@ static int ipcp_local_reg(const uint8_t * hash)
static int ipcp_local_unreg(const uint8_t * hash)
{
- shim_data_reg_del_entry(ipcpi.shim_data, hash);
+ shim_data_reg_del_entry(local_data.shim_data, hash);
log_info("Unregistered " HASH_FMT ".", HASH_VAL(hash));
@@ -167,7 +181,7 @@ static int ipcp_local_query(const uint8_t * hash)
{
int ret;
- ret = (shim_data_reg_has(ipcpi.shim_data, hash) ? 0 : -1);
+ ret = (shim_data_reg_has(local_data.shim_data, hash) ? 0 : -1);
return ret;
}