diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-30 14:12:28 +0000 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-08-30 14:12:28 +0000 |
commit | 399164eff1c6d07056ec93e3afd4079611cf9c7b (patch) | |
tree | befee04fa22eeb818d8710e44fa6a9b669a01745 | |
parent | 8fe0340d2117cf9b5c724ff10621978ef2bee5f1 (diff) | |
parent | a770296c7aa15057602a4e4f5c7744ccfc65b8aa (diff) | |
download | ouroboros-399164eff1c6d07056ec93e3afd4079611cf9c7b.tar.gz ouroboros-399164eff1c6d07056ec93e3afd4079611cf9c7b.zip |
Merged in sandervrijders/ouroboros/be-connect (pull request #582)
Be connect
-rw-r--r-- | src/ipcpd/local/main.c | 9 | ||||
-rw-r--r-- | src/ipcpd/shim-data.c | 17 | ||||
-rw-r--r-- | src/ipcpd/shim-data.h | 2 | ||||
-rw-r--r-- | src/ipcpd/shim-eth-llc/main.c | 11 | ||||
-rw-r--r-- | src/ipcpd/shim-udp/main.c | 12 | ||||
-rw-r--r-- | src/irmd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/irmd/config.h.in | 1 | ||||
-rw-r--r-- | src/irmd/ipcp.c | 4 |
8 files changed, 27 insertions, 31 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index aab82d25..fb4e312b 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -150,16 +150,9 @@ static int ipcp_local_bootstrap(const struct ipcp_config * conf) static int ipcp_local_reg(const uint8_t * hash) { - uint8_t * hash_dup = ipcp_hash_dup(hash); - if (hash_dup == NULL) { - log_err("Failed to duplicate hash."); - return -ENOMEM; - } - - if (shim_data_reg_add_entry(local_data.shim_data, hash_dup)) { + if (shim_data_reg_add_entry(local_data.shim_data, hash)) { log_dbg("Failed to add " HASH_FMT " to local registry.", HASH_VAL(hash)); - free(hash_dup); return -1; } diff --git a/src/ipcpd/shim-data.c b/src/ipcpd/shim-data.c index 355cec68..2d6585b5 100644 --- a/src/ipcpd/shim-data.c +++ b/src/ipcpd/shim-data.c @@ -24,6 +24,10 @@ #include "config.h" +#define OUROBOROS_PREFIX "shim-data" + +#include <ouroboros/endian.h> +#include <ouroboros/logs.h> #include <ouroboros/list.h> #include <ouroboros/time_utils.h> #include <ouroboros/errno.h> @@ -260,9 +264,10 @@ static struct dir_entry * find_dir_entry_any(struct shim_data * data, } int shim_data_reg_add_entry(struct shim_data * data, - uint8_t * hash) + const uint8_t * hash) { struct reg_entry * entry; + uint8_t * hash_dup; assert(data); assert(hash); @@ -271,10 +276,18 @@ int shim_data_reg_add_entry(struct shim_data * data, if (find_reg_entry_by_hash(data, hash)) { pthread_rwlock_unlock(&data->reg_lock); + log_dbg(HASH_FMT " was already in the directory.", + HASH_VAL(hash)); + return 0; + } + + hash_dup = ipcp_hash_dup(hash); + if (hash_dup == NULL) { + pthread_rwlock_unlock(&data->reg_lock); return -1; } - entry = reg_entry_create(hash); + entry = reg_entry_create(hash_dup); if (entry == NULL) { pthread_rwlock_unlock(&data->reg_lock); return -1; diff --git a/src/ipcpd/shim-data.h b/src/ipcpd/shim-data.h index 6380eea7..cd3ff16e 100644 --- a/src/ipcpd/shim-data.h +++ b/src/ipcpd/shim-data.h @@ -63,7 +63,7 @@ struct shim_data * shim_data_create(void); void shim_data_destroy(struct shim_data * data); int shim_data_reg_add_entry(struct shim_data * data, - uint8_t * hash); + const uint8_t * hash); int shim_data_reg_del_entry(struct shim_data * data, const uint8_t * hash); diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 292ecbe7..be29c585 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -993,18 +993,9 @@ static int eth_llc_ipcp_bootstrap(const struct ipcp_config * conf) static int eth_llc_ipcp_reg(const uint8_t * hash) { - uint8_t * hash_dup; - - hash_dup = ipcp_hash_dup(hash); - if (hash_dup == NULL) { - log_err("Failed to duplicate hash."); - return -ENOMEM; - } - - if (shim_data_reg_add_entry(eth_llc_data.shim_data, hash_dup)) { + if (shim_data_reg_add_entry(eth_llc_data.shim_data, hash)) { log_err("Failed to add " HASH_FMT " to local registry.", HASH_VAL(hash)); - free(hash_dup); return -1; } diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index a94472b2..a64c39c4 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -765,22 +765,14 @@ static int ipcp_udp_reg(const uint8_t * hash) uint32_t ip_addr; #endif char hashstr[ipcp_dir_hash_strlen() + 1]; - uint8_t * hash_dup; assert(hash); ipcp_hash_str(hashstr, hash); - hash_dup = ipcp_hash_dup(hash); - if (hash_dup == NULL) { - log_err("Failed to duplicate hash."); - return -ENOMEM; - } - - if (shim_data_reg_add_entry(udp_data.shim_data, hash_dup)) { + if (shim_data_reg_add_entry(udp_data.shim_data, hash)) { log_err("Failed to add " HASH_FMT " to local registry.", HASH_VAL(hash)); - free(hash_dup); return -1; } @@ -806,7 +798,7 @@ static int ipcp_udp_reg(const uint8_t * hash) dnsstr, hashstr, DNS_TTL, ipstr); if (ddns_send(cmd)) { - shim_data_reg_del_entry(udp_data.shim_data, hash_dup); + shim_data_reg_del_entry(udp_data.shim_data, hash); return -1; } } diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt index 3339991a..de883d63 100644 --- a/src/irmd/CMakeLists.txt +++ b/src/irmd/CMakeLists.txt @@ -18,6 +18,8 @@ set(REG_TIMEOUT 10000 CACHE STRING "Timeout for registering a name (ms)") set(QUERY_TIMEOUT 3000 CACHE STRING "Timeout to query a name with an IPCP (ms)") +set(CONNECT_TIMEOUT 5000 CACHE STRING + "Timeout to connect an IPCP to another IPCP (ms)") set(IRMD_MIN_THREADS 8 CACHE STRING "Minimum number of worker threads in the IRMd.") set(IRMD_ADD_THREADS 8 CACHE STRING diff --git a/src/irmd/config.h.in b/src/irmd/config.h.in index eb396bbc..c217fe93 100644 --- a/src/irmd/config.h.in +++ b/src/irmd/config.h.in @@ -39,6 +39,7 @@ #define ENROLL_TIMEOUT @ENROLL_TIMEOUT@ #define REG_TIMEOUT @REG_TIMEOUT@ #define QUERY_TIMEOUT @QUERY_TIMEOUT@ +#define CONNECT_TIMEOUT @CONNECT_TIMEOUT@ #define SYS_MAX_FLOWS @SYS_MAX_FLOWS@ diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index 794d060e..497bff9f 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -96,6 +96,10 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t api, tv.tv_sec = QUERY_TIMEOUT / 1000; tv.tv_usec = (QUERY_TIMEOUT % 1000) * 1000; break; + case IPCP_MSG_CODE__IPCP_CONNECT: + tv.tv_sec = CONNECT_TIMEOUT / 1000; + tv.tv_usec = (CONNECT_TIMEOUT % 1000) * 1000; + break; default: tv.tv_sec = SOCKET_TIMEOUT / 1000; tv.tv_usec = (SOCKET_TIMEOUT % 1000) * 1000; |