From f0646875d0bc941e339d305d0c68b13543cd6f2a Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 25 Oct 2016 13:22:51 +0200 Subject: 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. --- src/ipcpd/ipcp-data.h | 56 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'src/ipcpd/ipcp-data.h') diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h index 4472a1d7..5263b156 100644 --- a/src/ipcpd/ipcp-data.h +++ b/src/ipcpd/ipcp-data.h @@ -26,10 +26,28 @@ #include #include + +#include "ipcp-ops.h" + #include #include -#include "ipcp-ops.h" +enum dir_query_state { + QUERY_INIT = 0, + QUERY_PENDING, + QUERY_RESPONSE, + QUERY_DONE, + QUERY_DESTROY +}; + +struct dir_query { + struct list_head next; + char * name; + enum dir_query_state state; + + pthread_mutex_t lock; + pthread_cond_t cond; +}; struct ipcp_data { enum ipcp_type type; @@ -40,6 +58,9 @@ struct ipcp_data { struct list_head directory; pthread_rwlock_t dir_lock; + + struct list_head dir_queries; + pthread_mutex_t dir_queries_lock; }; struct ipcp_data * ipcp_data_create(void); @@ -49,26 +70,35 @@ struct ipcp_data * ipcp_data_init(struct ipcp_data * dst, void ipcp_data_destroy(struct ipcp_data * data); -int ipcp_data_add_reg_entry(struct ipcp_data * data, +int ipcp_data_reg_add_entry(struct ipcp_data * data, char * name); -int ipcp_data_del_reg_entry(struct ipcp_data * data, +int ipcp_data_reg_del_entry(struct ipcp_data * data, const char * name); -int ipcp_data_add_dir_entry(struct ipcp_data * data, - char * ap_name, +bool ipcp_data_reg_has(struct ipcp_data * data, + const char * name); + +int ipcp_data_dir_add_entry(struct ipcp_data * data, + char * name, uint64_t addr); -int ipcp_data_del_dir_entry(struct ipcp_data * data, - const char * ap_name, +int ipcp_data_dir_del_entry(struct ipcp_data * data, + const char * name, uint64_t addr); -bool ipcp_data_is_in_registry(struct ipcp_data * data, - const char * name); +bool ipcp_data_dir_has(struct ipcp_data * data, + const char * name); + +uint64_t ipcp_data_dir_get_addr(struct ipcp_data * data, + const char * name); + +struct dir_query * ipcp_data_dir_query_create(char * name); + +void ipcp_data_dir_query_respond(struct dir_query * query); -bool ipcp_data_is_in_directory(struct ipcp_data * data, - const char * ap_name); +void ipcp_data_dir_query_destroy(struct dir_query * query); -uint64_t ipcp_data_get_addr(struct ipcp_data * data, - const char * ap_name); +int ipcp_data_dir_query_wait(struct dir_query * query, + const struct timespec * timeout); #endif /* IPCPD_IPCP_DATA_H */ -- cgit v1.2.3