diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-25 13:22:51 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-26 11:52:53 +0200 |
commit | f0646875d0bc941e339d305d0c68b13543cd6f2a (patch) | |
tree | 0a3dde0e4f6284ece935d6eff99f26234126f1ab /src/ipcpd/local/main.c | |
parent | 1c06b9ff80a2bf7ee6042534fee6098f7e452b59 (diff) | |
download | ouroboros-f0646875d0bc941e339d305d0c68b13543cd6f2a.tar.gz ouroboros-f0646875d0bc941e339d305d0c68b13543cd6f2a.zip |
lib, irmd, ipcpd: Add name querying to IPCPs
This adds the ability to query IPCPs if a name can be reached through
them, e.g. if a name is available in a DIF. This means that in the
shim-udp a DNS query is performed, in the shim-eth-llc an ARP-like
query has been added, in the local a check is done to see if the name
is registered, and in the normal currently no application is reachable
through it.
Diffstat (limited to 'src/ipcpd/local/main.c')
-rw-r--r-- | src/ipcpd/local/main.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 192607c1..b8783d9d 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -20,17 +20,18 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define OUROBOROS_PREFIX "ipcpd/local" + #include <ouroboros/config.h> -#include "ipcp.h" +#include <ouroboros/logs.h> #include <ouroboros/errno.h> #include <ouroboros/dev.h> #include <ouroboros/fcntl.h> #include <ouroboros/fqueue.h> #include <ouroboros/ipcp-dev.h> #include <ouroboros/local-dev.h> -#define OUROBOROS_PREFIX "ipcpd/local" -#include <ouroboros/logs.h> +#include "ipcp.h" #include <string.h> #include <signal.h> @@ -176,7 +177,7 @@ static int ipcp_local_name_reg(char * name) { pthread_rwlock_rdlock(&ipcpi.state_lock); - if (ipcp_data_add_reg_entry(ipcpi.data, name)) { + if (ipcp_data_reg_add_entry(ipcpi.data, name)) { pthread_rwlock_unlock(&ipcpi.state_lock); LOG_DBG("Failed to add %s to local registry.", name); return -1; @@ -193,7 +194,7 @@ static int ipcp_local_name_unreg(char * name) { pthread_rwlock_rdlock(&ipcpi.state_lock); - ipcp_data_del_reg_entry(ipcpi.data, name); + ipcp_data_reg_del_entry(ipcpi.data, name); pthread_rwlock_unlock(&ipcpi.state_lock); @@ -202,6 +203,19 @@ static int ipcp_local_name_unreg(char * name) return 0; } +static int ipcp_local_name_query(char * name) +{ + int ret; + + pthread_rwlock_rdlock(&ipcpi.state_lock); + + ret = (ipcp_data_reg_has(ipcpi.data, name) ? 0 : -1); + + pthread_rwlock_unlock(&ipcpi.state_lock); + + return ret; +} + static int ipcp_local_flow_alloc(int fd, char * dst_name, char * src_ae_name, @@ -302,6 +316,7 @@ static struct ipcp_ops local_ops = { .ipcp_enroll = NULL, /* shim */ .ipcp_name_reg = ipcp_local_name_reg, .ipcp_name_unreg = ipcp_local_name_unreg, + .ipcp_name_query = ipcp_local_name_query, .ipcp_flow_alloc = ipcp_local_flow_alloc, .ipcp_flow_alloc_resp = ipcp_local_flow_alloc_resp, .ipcp_flow_dealloc = ipcp_local_flow_dealloc |