diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-04-01 15:01:51 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-04-01 15:01:51 +0200 |
commit | 65591e5211fb3c44450c52d7534918902e0760d5 (patch) | |
tree | b3f21e0bdb9cf0e773962db73be041bb86d0ee44 /include | |
parent | 3d859bb9a75932a6cffdd37466d510b479c9aa71 (diff) | |
parent | 0e1aeba4f2d2de3ce827bfaeb1d9f2480e628529 (diff) | |
download | ouroboros-65591e5211fb3c44450c52d7534918902e0760d5.tar.gz ouroboros-65591e5211fb3c44450c52d7534918902e0760d5.zip |
Merge branch 'be' of bitbucket.org:ouroboros-rina/ouroboros into be-build
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/CMakeLists.txt | 5 | ||||
-rw-r--r-- | include/ouroboros/config.h.in | 9 | ||||
-rw-r--r-- | include/ouroboros/da.h | 2 | ||||
-rw-r--r-- | include/ouroboros/flow.h | 61 | ||||
-rw-r--r-- | include/ouroboros/instance_name.h (renamed from include/ouroboros/rina_name.h) | 51 | ||||
-rw-r--r-- | include/ouroboros/ipcp.h | 75 | ||||
-rw-r--r-- | include/ouroboros/irm.h | 31 | ||||
-rw-r--r-- | include/ouroboros/shm_du_map.h | 4 | ||||
-rw-r--r-- | include/ouroboros/sockets.h | 82 |
9 files changed, 174 insertions, 146 deletions
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index a196140b..0b52a2bc 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -9,15 +9,16 @@ set(HEADER_FILES da.h dev.h du_buff.h + flow.h + instance_name.h ipcp.h irm.h list.h logs.h - rina_name.h shm_du_map.h sockets.h utils.h ) install(FILES ${HEADER_FILES} "${CMAKE_CURRENT_BINARY_DIR}/config.h" - DESTINATION include/ouroboros) + DESTINATION include/ouroboros) diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in index 0f5c2131..01d7888e 100644 --- a/include/ouroboros/config.h.in +++ b/include/ouroboros/config.h.in @@ -23,9 +23,10 @@ #ifndef OUROBOROS_CONFIG #define OUROBOROS_CONFIG -#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" -#define PROJECT_VERSION "@PACKAGE_VERSION@" -#define INSTALL_DIR "@CMAKE_INSTALL_PREFIX@" -#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" +#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" +#define PROJECT_VERSION "@PACKAGE_VERSION@" +#define INSTALL_DIR "@CMAKE_INSTALL_PREFIX@" +#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" +#define _POSIX_C_SOURCE 199506L #endif diff --git a/include/ouroboros/da.h b/include/ouroboros/da.h index f678007d..9ecd4bd8 100644 --- a/include/ouroboros/da.h +++ b/include/ouroboros/da.h @@ -24,7 +24,7 @@ #define OUROBOROS_DA_H #include "common.h" -#include "rina_name.h" +#include "instance_name.h" char * da_resolve_daf(char * daf_name); /* diff --git a/include/ouroboros/flow.h b/include/ouroboros/flow.h new file mode 100644 index 00000000..7d8c311e --- /dev/null +++ b/include/ouroboros/flow.h @@ -0,0 +1,61 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * Flows + * + * Dimitri Staessens <dimitri.staessens@intec.ugent.be> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef OUROBOROS_FLOW_H +#define OUROBOROS_FLOW_H + +#include <ouroboros/common.h> + +#include <pthread.h> + +/* same values as fcntl.h */ +#define FLOW_O_RDONLY 00000000 +#define FLOW_O_WRONLY 00000001 +#define FLOW_O_RDWR 00000002 +#define FLOW_O_ACCMODE 00000003 + +#define FLOW_O_NONBLOCK 00004000 +#define FLOW_O_DEFAULT 00000002 + +#define FLOW_O_INVALID (FLOW_O_WRONLY | FLOW_O_RDWR) + +enum flow_state { + FLOW_INIT = 0, + FLOW_ALLOCATED, + FLOW_PENDING +}; + +typedef struct flow { + int32_t port_id; + uint16_t oflags; + enum flow_state state; + + pthread_mutex_t lock; +} flow_t; + +flow_t * flow_create(int32_t port_id); +void flow_destroy(flow_t * flow); + +int flow_set_opts(flow_t * flow, uint16_t opts); +uint16_t flow_get_opts(const flow_t * flow); + +#endif /* OUROBOROS_FLOW_H */ diff --git a/include/ouroboros/rina_name.h b/include/ouroboros/instance_name.h index f8af00c2..351b222f 100644 --- a/include/ouroboros/rina_name.h +++ b/include/ouroboros/instance_name.h @@ -19,21 +19,21 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef RINA_NAME_H -#define RINA_NAME_H +#ifndef INSTANCE_NAME_H +#define INSTANCE_NAME_H #include "common.h" typedef struct { - char * ap_name; - unsigned int api_id; -} rina_name_t; + char * name; + uint16_t id; +} instance_name_t; /* * Allocates a new name, returning the allocated object. * In case of an error, a NULL is returned. */ -rina_name_t * name_create(); +instance_name_t * instance_name_create(); /* * Initializes a previously dynamically allocated name (i.e. name_create()) @@ -46,49 +46,44 @@ rina_name_t * name_create(); * * It is allowed to call name_init() over an already initialized object */ -rina_name_t * name_init_from(rina_name_t * dst, - const char * ap_name, - unsigned int api_id); +instance_name_t * instance_name_init_from(instance_name_t * dst, + const char * name, + uint16_t api_id); /* Takes ownership of the passed parameters */ -rina_name_t * name_init_with(rina_name_t * dst, - char * ap_name, - unsigned int api_id); +instance_name_t * instance_name_init_with(instance_name_t * dst, + char * name, + uint16_t id); /* * Finalize a name object, releasing all the embedded resources (without * releasing the object itself). After name_fini() execution the passed * object will be in the same states as at the end of name_init(). */ -void name_fini(rina_name_t * dst); +void instance_name_fini(instance_name_t * dst); /* Releases all the associated resources bound to a name object */ -void name_destroy(rina_name_t * ptr); +void instance_name_destroy(instance_name_t * ptr); /* Duplicates a name object, returning the pointer to the new object */ -rina_name_t * name_dup(const rina_name_t * src); +instance_name_t * instance_name_dup(const instance_name_t * src); /* * Copies the source object contents into the destination object, both must * be previously allocated */ -int name_cpy(const rina_name_t * src, rina_name_t * dst); +int instance_name_cpy(instance_name_t * dst, + const instance_name_t * src); -bool name_is_equal(const rina_name_t * a, const rina_name_t * b); -bool name_is_ok(const rina_name_t * n); +int instance_name_cmp(const instance_name_t * a, + const instance_name_t * b); -#define NAME_CMP_APN 0x01 -#define NAME_CMP_API 0x02 -#define NAME_CMP_ALL (NAME_CMP_APN | NAME_CMP_API) - -bool name_cmp(uint8_t flags, - const rina_name_t * a, - const rina_name_t * b); +bool instance_name_is_valid(const instance_name_t * n); /* Returns a name as a (newly allocated) string */ -char * name_to_string(const rina_name_t * n); +char * instance_name_to_string(const instance_name_t * n); /* Inverse of name_tostring() */ -rina_name_t * string_to_name(const char * s); +instance_name_t * string_to_instance_name(const char * s); -#endif +#endif /* INSTANCE_NAME_H */ diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index b8775fc0..fdaf5c4a 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -23,31 +23,66 @@ #ifndef OUROBOROS_IPCP_H #define OUROBOROS_IPCP_H -#include <sys/types.h> +#include <ouroboros/common.h> +#include <ouroboros/instance_name.h> -#include "common.h" -#include "rina_name.h" +#include <sys/types.h> struct ipcp; /* Returns the process id */ -pid_t ipcp_create(rina_name_t name, - char * ipcp_type); -int ipcp_destroy(pid_t pid); - -int ipcp_reg(pid_t pid, - char ** difs, - size_t difs_size); -int ipcp_unreg(pid_t pid, +pid_t ipcp_create(instance_name_t * api, + char * ipcp_type); +int ipcp_destroy(pid_t pid); + +int ipcp_reg(pid_t pid, char ** difs, - size_t difs_size); + size_t difs_size); +int ipcp_unreg(pid_t pid, + char ** difs, + size_t difs_size); + +int ipcp_bootstrap(pid_t pid, + struct dif_config * conf); +int ipcp_enroll(pid_t pid, + char * member_name, + char * n_1_dif); + +/* Flow related ops, these go from IRMd to IPCP */ + +int ipcp_ap_reg(pid_t pid, + uint32_t reg_api_id, + char * ap_name); +int ipcp_ap_unreg(pid_t pid, + uint32_t reg_api_id); + +int ipcp_flow_alloc(pid_t pid, + uint32_t port_id, + char * dst_ap_name, + char * src_ap_name, + char * src_ae_name, + struct qos_spec * qos); +int ipcp_flow_alloc_resp(pid_t pid, + uint32_t port_id, + int result); + +/* These operations go from the IPCP to the IRMd */ + +/* Returns the port_id */ +int ipcp_flow_req_arr(pid_t pid, + uint32_t reg_api_id, + char * ap_name, + char * ae_name); +int ipcp_flow_alloc_reply(pid_t pid, + uint32_t port_id, + int result); + +/* + * This operation can go both ways + * pid == 0 means the IRMd is the destination + */ +int ipcp_flow_dealloc(pid_t pid, + uint32_t port_id); -int ipcp_bootstrap(pid_t pid, - struct dif_config conf); -int ipcp_enroll(pid_t pid, - char * dif_name, - char * member_name, - char ** n_1_difs, - ssize_t n_1_difs_size); -#endif +#endif /* OUROBOROS_IPCP_H */ diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index a6f0d9f3..780bf77b 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -24,22 +24,21 @@ #define OUROBOROS_IRM_H #include "common.h" -#include "rina_name.h" +#include "instance_name.h" -int irm_create_ipcp(rina_name_t name, - char * ipcp_type); -int irm_destroy_ipcp(rina_name_t name); +int irm_create_ipcp(instance_name_t * api, + char * ipcp_type); +int irm_destroy_ipcp(instance_name_t * api); -int irm_bootstrap_ipcp(rina_name_t name, - struct dif_config conf); -int irm_enroll_ipcp(rina_name_t name, - char * dif_name); +int irm_bootstrap_ipcp(instance_name_t * api, + struct dif_config * conf); +int irm_enroll_ipcp(instance_name_t * api, + char * dif_name); -int irm_reg_ipcp(rina_name_t name, - char ** difs, - size_t difs_size); -int irm_unreg_ipcp(rina_name_t name, - char ** difs, - size_t difs_size); - -#endif +int irm_reg_ipcp(instance_name_t * api, + char ** difs, + size_t difs_size); +int irm_unreg_ipcp(const instance_name_t * api, + char ** difs, + size_t difs_size); +#endif /* OUROBOROS_IRM_H */ diff --git a/include/ouroboros/shm_du_map.h b/include/ouroboros/shm_du_map.h index 68492a91..fb51768d 100644 --- a/include/ouroboros/shm_du_map.h +++ b/include/ouroboros/shm_du_map.h @@ -24,10 +24,6 @@ #ifndef OUROBOROS_SHM_DU_MAP_H #define OUROBOROS_SHM_DU_MAP_H -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199506L -#endif - #ifndef SHM_DU_BUFF_BLOCK_SIZE #define SHM_DU_BUFF_BLOCK_SIZE sysconf(_SC_PAGESIZE) #endif diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h index 45d7a27d..0c517bd4 100644 --- a/include/ouroboros/sockets.h +++ b/include/ouroboros/sockets.h @@ -24,87 +24,27 @@ #define OUROBOROS_SOCKETS_H #include <ouroboros/common.h> -#include <ouroboros/rina_name.h> #include <sys/types.h> +#include "irmd_messages.pb-c.h" +typedef IrmMsg irm_msg_t; + +#include "ipcpd_messages.pb-c.h" +typedef IpcpMsg ipcp_msg_t; + #define IRM_SOCK_PATH "/tmp/irm_sock" #define IRM_MSG_BUF_SIZE 256 #define IPCP_SOCK_PATH_PREFIX "/tmp/ipcp_sock" -#define IPCP_MSG_BUFS_SIZE IRM_MSG_BUF_SIZE - -enum irm_msg_code { - IRM_CREATE_IPCP, - IRM_DESTROY_IPCP, - IRM_BOOTSTRAP_IPCP, - IRM_ENROLL_IPCP, - IRM_REG_IPCP, - IRM_UNREG_IPCP, - IRM_AP_REG, - IRM_AP_REG_R, - IRM_AP_UNREG, - IRM_FLOW_ACCEPT, - IRM_FLOW_ACCEPT_R, - IRM_FLOW_ALLOC_RESP, - IRM_FLOW_ALLOC, - IRM_FLOW_ALLOC_R, - IRM_FLOW_ALLOC_RES, - IRM_FLOW_ALLOC_RES_R, - IRM_FLOW_DEALLOC, - IRM_FLOW_CONTROL, - IRM_FLOW_WRITE, - IRM_FLOW_READ -}; - -struct irm_msg { - enum irm_msg_code code; - rina_name_t * name; - char * ipcp_type; - struct dif_config * conf; - char * dif_name; - char ** difs; - size_t difs_size; - char * ap_name; - char * ae_name; - int fd; - int result; - struct qos_spec * qos; - int oflags; - char * dst_ap_name; - ssize_t count; -}; - -enum ipcp_msg_code { - IPCP_BOOTSTRAP, - IPCP_ENROLL, - IPCP_REG, - IPCP_UNREG -}; - -struct ipcp_msg { - enum ipcp_msg_code code; - struct dif_config * conf; - char * dif_name; - char * ap_name; - char ** difs; - size_t difs_size; -}; +#define IPCP_MSG_BUF_SIZE IRM_MSG_BUF_SIZE /* Returns the full socket path of an IPCP */ -char * ipcp_sock_path(pid_t pid); - -int server_socket_open(char * file_name); -int client_socket_open(char * file_name); +char * ipcp_sock_path(pid_t pid); -int send_irmd_msg(struct irm_msg * msg); -struct irm_msg * send_recv_irmd_msg(struct irm_msg * msg); +int server_socket_open(char * file_name); +int client_socket_open(char * file_name); -/* Caller has to free the buffer */ -buffer_t * serialize_irm_msg(struct irm_msg * msg); -buffer_t * serialize_ipcp_msg(struct ipcp_msg * msg); -/* Caller has to free all the allocated fields in the message */ -struct irm_msg * deserialize_irm_msg(buffer_t * data); -struct ipcp_msg * deserialize_ipcp_msg(buffer_t * data); +irm_msg_t * send_recv_irm_msg(irm_msg_t * msg); #endif |