diff options
Diffstat (limited to 'src/ipcpd/ipcp.h')
| -rw-r--r-- | src/ipcpd/ipcp.h | 103 |
1 files changed, 38 insertions, 65 deletions
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index 84e0386a..26a780a3 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -1,10 +1,10 @@ /* - * Ouroboros - Copyright (C) 2016 - 2020 + * Ouroboros - Copyright (C) 2016 - 2026 * * IPC process structure * - * Dimitri Staessens <dimitri.staessens@ugent.be> - * Sander Vrijders <sander.vrijders@ugent.be> + * Dimitri Staessens <dimitri@ouroboros.rocks> + * Sander Vrijders <sander@ouroboros.rocks> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -26,21 +26,18 @@ #include <ouroboros/hash.h> #include <ouroboros/ipcp.h> #include <ouroboros/list.h> +#include <ouroboros/protobuf.h> +#include <ouroboros/qos.h> #include <ouroboros/sockets.h> #include <ouroboros/tpm.h> #include <pthread.h> #include <time.h> -enum ipcp_state { - IPCP_NULL = 0, - IPCP_INIT, - IPCP_OPERATIONAL, - IPCP_SHUTDOWN -}; +#define ipcp_dir_hash_strlen() (ipcp_dir_hash_len() * 2) struct ipcp_ops { - int (* ipcp_bootstrap)(const struct ipcp_config * conf); + int (* ipcp_bootstrap)(struct ipcp_config * conf); int (* ipcp_enroll)(const char * dst, struct layer_info * info); @@ -58,83 +55,59 @@ struct ipcp_ops { int (* ipcp_query)(const uint8_t * hash); - int (* ipcp_flow_alloc)(int fd, - const uint8_t * dst, - qosspec_t qs, - const void * data, - size_t len); + int (* ipcp_flow_alloc)(int fd, + const uint8_t * dst, + qosspec_t qs, + const buffer_t * data); int (* ipcp_flow_join)(int fd, - const uint8_t * dst, - qosspec_t qs); + const uint8_t * dst); - int (* ipcp_flow_alloc_resp)(int fd, - int response, - const void * data, - size_t len); + int (* ipcp_flow_alloc_resp)(int fd, + int response, + const buffer_t * data); int (* ipcp_flow_dealloc)(int fd); }; -#define ipcp_dir_hash_strlen() (hash_len(ipcpi.dir_hash_algo) * 2) -#define ipcp_dir_hash_len() (hash_len(ipcpi.dir_hash_algo)) - -extern struct ipcp { - pid_t irmd_pid; - char * name; - - enum ipcp_type type; - char * layer_name; - - uint64_t dt_addr; - - enum hash_algo dir_hash_algo; - - struct ipcp_ops * ops; - int irmd_fd; - - enum ipcp_state state; - pthread_rwlock_t state_lock; - pthread_mutex_t state_mtx; - pthread_cond_t state_cond; - - int sockfd; - char * sock_path; - - struct list_head cmds; - pthread_cond_t cmd_cond; - pthread_mutex_t cmd_lock; +int ipcp_init(int argc, + char ** argv, + struct ipcp_ops * ops, + enum ipcp_type type); - int alloc_id; - pthread_cond_t alloc_cond; - pthread_mutex_t alloc_lock; +int ipcp_start(void); - struct tpm * tpm; +void ipcp_sigwait(void); - pthread_t acceptor; -} ipcpi; +void ipcp_stop(void); -int ipcp_init(int argc, - char ** argv, - struct ipcp_ops * ops); +void ipcp_fini(void); -int ipcp_boot(void); +enum ipcp_type ipcp_get_type(void); -void ipcp_shutdown(void); +const char * ipcp_get_name(void); -void ipcp_fini(void); +/* TODO: Only specify hash algorithm in directory policy */ +void ipcp_set_dir_hash_algo(enum hash_algo algo); void ipcp_set_state(enum ipcp_state state); enum ipcp_state ipcp_get_state(void); -int ipcp_wait_state(enum ipcp_state state, - const struct timespec * timeout); +/* Helper functions to handle races during flow allocation */ +int ipcp_wait_flow_req_arr(const uint8_t * dst, + qosspec_t qs, + time_t mpl, + const buffer_t * data); + +int ipcp_wait_flow_resp(const int fd); -int ipcp_parse_arg(int argc, - char * argv[]); /* Helper functions for directory entries, could be moved */ +size_t ipcp_dir_hash_len(void); + +int ipcp_get_layer_name(char * layer); + uint8_t * ipcp_hash_dup(const uint8_t * hash); void ipcp_hash_str(char buf[], |
