summaryrefslogtreecommitdiff
path: root/src/ipcpd/local/main.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-18 15:56:55 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-08-21 10:25:19 +0200
commit8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e (patch)
tree0535742162921dc0d19c16f5b02d2f1c8f4fc493 /src/ipcpd/local/main.c
parenteefae235dd7af96eef3dc4f82f706170c379d260 (diff)
downloadouroboros-8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e.tar.gz
ouroboros-8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e.zip
build: Revise the build system
This revises the build system to have configuration per system component. System settings can now be set using cmake. The standard compliance defines were removed from configuration header and are set in the sources where needed. Also some small code refactors, such as moving the data for shims out of the ipcp structure to the respective shims were performed.
Diffstat (limited to 'src/ipcpd/local/main.c')
-rw-r--r--src/ipcpd/local/main.c34
1 files changed, 24 insertions, 10 deletions
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;
}