diff options
Diffstat (limited to 'include/ouroboros')
-rw-r--r-- | include/ouroboros/CMakeLists.txt | 3 | ||||
-rw-r--r-- | include/ouroboros/dev.h | 19 | ||||
-rw-r--r-- | include/ouroboros/select.h | 50 | ||||
-rw-r--r-- | include/ouroboros/shm_ap_rbuff.h | 35 | ||||
-rw-r--r-- | include/ouroboros/wrap/ouroboros.i | 2 |
5 files changed, 96 insertions, 13 deletions
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index ae922b89..78a7bb9c 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -10,7 +10,8 @@ set(HEADER_FILES irm.h irm_config.h nsm.h - qos.h) + qos.h + select.h) install(FILES ${HEADER_FILES} DESTINATION usr/include/ouroboros) diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h index d5fb744b..fe5ff4b5 100644 --- a/include/ouroboros/dev.h +++ b/include/ouroboros/dev.h @@ -22,7 +22,6 @@ #include <unistd.h> #include <stdint.h> -#include <time.h> #include <ouroboros/qos.h> #include <ouroboros/flow.h> @@ -34,10 +33,12 @@ /* These calls should be removed once we write the ouroboros OS. */ int ap_init(char * ap_name); + void ap_fini(void); /* Returns file descriptor (> 0) and client AE name. */ int flow_accept(char ** ae_name); + int flow_alloc_resp(int fd, int result); /* @@ -47,13 +48,21 @@ int flow_alloc_resp(int fd, int result); int flow_alloc(char * dst_name, char * src_ae_name, struct qos_spec * qos); + int flow_alloc_res(int fd); int flow_dealloc(int fd); -int flow_cntl(int fd, int cmd, int oflags); -ssize_t flow_write(int fd, void * buf, size_t count); -ssize_t flow_read(int fd, void * buf, size_t count); -int flow_select(const struct timespec * timeout); +int flow_cntl(int fd, + int cmd, + int oflags); + +ssize_t flow_write(int fd, + void * buf, + size_t count); + +ssize_t flow_read(int fd, + void * buf, + size_t count); #endif diff --git a/include/ouroboros/select.h b/include/ouroboros/select.h new file mode 100644 index 00000000..9e0b8fec --- /dev/null +++ b/include/ouroboros/select.h @@ -0,0 +1,50 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * A select call for flows + * + * Dimitri Staessens <dimitri.staessens@intec.ugent.be> + * Sander Vrijders <sander.vrijders@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_SELECT_H +#define OUROBOROS_SELECT_H + +#include <stdbool.h> +#include <time.h> + +struct flow_set; + +struct flow_set * flow_set_create(); + +void flow_set_destroy(struct flow_set * set); + +void flow_set_zero(struct flow_set * set); + +void flow_set_add(struct flow_set * set, + int fd); + +void flow_set_del(struct flow_set * set, + int fd); + +bool flow_set_has(struct flow_set * set, + int fd); + +int flow_select(struct flow_set * set, + const struct timespec * timeout); + +#endif /* OUROBOROS_SELECT_H */ diff --git a/include/ouroboros/shm_ap_rbuff.h b/include/ouroboros/shm_ap_rbuff.h index 9dad0863..6b11fd2d 100644 --- a/include/ouroboros/shm_ap_rbuff.h +++ b/include/ouroboros/shm_ap_rbuff.h @@ -24,6 +24,7 @@ #ifndef OUROBOROS_SHM_AP_RBUFF_H #define OUROBOROS_SHM_AP_RBUFF_H +#include <ouroboros/select.h> #include <sys/types.h> #include <sys/time.h> #include <stdbool.h> @@ -35,20 +36,40 @@ struct rb_entry { int port_id; }; -struct shm_ap_rbuff * shm_ap_rbuff_create(); -struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t api); +/* recv SDUs from N + 1 */ +struct shm_ap_rbuff * shm_ap_rbuff_create_n(); + +/* recv SDUs from N - 1 */ +struct shm_ap_rbuff * shm_ap_rbuff_create_s(); + +/* write SDUs to N - 1 */ +struct shm_ap_rbuff * shm_ap_rbuff_open_n(pid_t api); + +/* write SDUs to N + 1 */ +struct shm_ap_rbuff * shm_ap_rbuff_open_s(pid_t api); + void shm_ap_rbuff_close(struct shm_ap_rbuff * rb); + void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb); + int shm_ap_rbuff_write(struct shm_ap_rbuff * rb, - struct rb_entry * e); + struct rb_entry * e); + struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb); + int shm_ap_rbuff_peek_idx(struct shm_ap_rbuff * rb); -int shm_ap_rbuff_peek_b(struct shm_ap_rbuff * rb, + +int shm_ap_rbuff_peek_b(struct shm_ap_rbuff * rb, + bool * set, const struct timespec * timeout); + ssize_t shm_ap_rbuff_read_port(struct shm_ap_rbuff * rb, - int port_id); -ssize_t shm_ap_rbuff_read_port_b(struct shm_ap_rbuff * rb, - int port_id, + int port_id); + +ssize_t shm_ap_rbuff_read_port_b(struct shm_ap_rbuff * rb, + int port_id, const struct timespec * timeout); + void shm_ap_rbuff_reset(struct shm_ap_rbuff * rb); + #endif /* OUROBOROS_SHM_AP_RBUFF_H */ diff --git a/include/ouroboros/wrap/ouroboros.i b/include/ouroboros/wrap/ouroboros.i index 386c21cc..2f66aa16 100644 --- a/include/ouroboros/wrap/ouroboros.i +++ b/include/ouroboros/wrap/ouroboros.i @@ -30,6 +30,7 @@ #include "ouroboros/irm_config.h" #include "ouroboros/nsm.h" #include "ouroboros/qos.h" +#include "ouroboros/select.h" %} typedef int pid_t; @@ -42,3 +43,4 @@ typedef int pid_t; %include "ouroboros/irm_config.h" %include "ouroboros/nsm.h" %include "ouroboros/qos.h" +%include "ouroboros/select.h" |