From cce79395b5a9f75d3fe1b14bf5df44795d680ca4 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 25 Oct 2016 12:57:15 +0200 Subject: lib: API for accepting flows with QoS --- include/ouroboros/dev.h | 5 +++-- src/ipcpd/normal/fmgr.c | 3 ++- src/lib/dev.c | 5 ++++- src/tools/cbr/cbr_server.c | 3 ++- src/tools/echo/echo_server.c | 3 ++- src/tools/oping/oping_server.c | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h index 25299ee3..f2e42d03 100644 --- a/include/ouroboros/dev.h +++ b/include/ouroboros/dev.h @@ -34,8 +34,9 @@ int ap_init(char * ap_name); void ap_fini(void); -/* Returns flow descriptor (> 0) and client AE name. */ -int flow_accept(char ** ae_name); +/* Returns flow descriptor (> 0), client AE name and qos spec. */ +int flow_accept(char ** ae_name, + struct qos_spec * qos); int flow_alloc_resp(int fd, int response); diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 46c72691..b5ae40dd 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -125,6 +125,7 @@ static void * fmgr_nm1_acceptor(void * o) { int fd; char * ae_name; + struct qos_spec qs; (void) o; @@ -140,7 +141,7 @@ static void * fmgr_nm1_acceptor(void * o) pthread_rwlock_unlock(&ipcpi.state_lock); - fd = flow_accept(&ae_name); + fd = flow_accept(&ae_name, &qs); if (fd < 0) { LOG_ERR("Failed to accept flow."); continue; diff --git a/src/lib/dev.c b/src/lib/dev.c index 94fbd394..7fc2e6b3 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -134,6 +134,7 @@ struct flow { struct shm_flow_set * set; int port_id; int oflags; + enum qos_cube qos; pid_t api; @@ -315,12 +316,14 @@ void ap_fini() } -int flow_accept(char ** ae_name) +int flow_accept(char ** ae_name, struct qos_spec * qos) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int fd = -1; + (void) qos; + msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT; msg.has_api = true; diff --git a/src/tools/cbr/cbr_server.c b/src/tools/cbr/cbr_server.c index f1c342d1..eb45a2c6 100644 --- a/src/tools/cbr/cbr_server.c +++ b/src/tools/cbr/cbr_server.c @@ -155,6 +155,7 @@ void * listener(void * o) { int client_fd = 0; int response = 0; + struct qos_spec qs; (void) o; @@ -162,7 +163,7 @@ void * listener(void * o) server_settings.interval, server_settings.timeout); while (true) { - client_fd = flow_accept(NULL); + client_fd = flow_accept(NULL, &qs); if (client_fd < 0) { printf("Failed to accept flow.\n"); break; diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c index 070f0ce3..09575364 100644 --- a/src/tools/echo/echo_server.c +++ b/src/tools/echo/echo_server.c @@ -40,6 +40,7 @@ int server_main(void) int client_fd = 0; char buf[BUF_SIZE]; ssize_t count = 0; + struct qos_spec qs; printf("Starting the server.\n"); @@ -50,7 +51,7 @@ int server_main(void) } while (true) { - client_fd = flow_accept(NULL); + client_fd = flow_accept(NULL, &qs); if (client_fd < 0) { printf("Failed to accept flow.\n"); break; diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c index 720e71b6..8d7ab1db 100644 --- a/src/tools/oping/oping_server.c +++ b/src/tools/oping/oping_server.c @@ -115,13 +115,14 @@ void * accept_thread(void * o) { int fd = 0; struct timespec now = {0, 0}; + struct qos_spec qs; (void) o; printf("Ouroboros ping server started.\n"); while (true) { - fd = flow_accept(NULL); + fd = flow_accept(NULL, &qs); if (fd < 0) { printf("Failed to accept flow.\n"); break; -- cgit v1.2.3