diff options
author | Dave Wallace <dwallacelf@gmail.com> | 2017-10-09 01:43:42 -0400 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2017-10-10 22:05:52 +0000 |
commit | 35830af800aefdcc6a3767bc101b4c300a74651b (patch) | |
tree | a3bef29c3fe466a7bd45e61cb53568b9557cf0d9 /src/uri/sock_test_server.c | |
parent | cea194d8f973a2f2b5ef72d212533057174cc70a (diff) |
Add VCL session get/set attributes api function.
Change-Id: I72b0c063e89bf8299699dafec2a7e0395b86c8b9
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src/uri/sock_test_server.c')
-rw-r--r-- | src/uri/sock_test_server.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/uri/sock_test_server.c b/src/uri/sock_test_server.c index e5b5a56e8d6..bb95b950ad8 100644 --- a/src/uri/sock_test_server.c +++ b/src/uri/sock_test_server.c @@ -22,13 +22,25 @@ #include <time.h> #include <ctype.h> #include <uri/sock_test.h> +#include <sys/stat.h> +#include <fcntl.h> #define SOCK_SERVER_USE_EPOLL 1 +#define VPPCOM_SESSION_ATTR_UNIT_TEST 0 #if SOCK_SERVER_USE_EPOLL #include <sys/epoll.h> #endif +#ifdef VCL_TEST +#if VPPCOM_SESSION_ATTR_UNIT_TEST +#define BUFLEN sizeof (uint64_t) * 16 +uint64_t buffer[16]; +uint32_t buflen = BUFLEN; +uint32_t *flags = (uint32_t *) buffer; +#endif +#endif + typedef struct { uint8_t is_alloc; @@ -411,6 +423,40 @@ main (int argc, char **argv) errno = -rv; rv = -1; } + +#if VPPCOM_SESSION_ATTR_UNIT_TEST + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_GET_FLAGS, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_FLAGS0: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + buflen = BUFLEN; + *flags = O_RDWR | O_NONBLOCK; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_SET_FLAGS, + buffer, &buflen) != VPPCOM_OK) + printf ("\nSET_FLAGS1: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_GET_FLAGS, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_FLAGS1:Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + *flags = O_RDWR; + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_SET_FLAGS, + buffer, &buflen) != VPPCOM_OK) + printf ("\nSET_FLAGS2: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_GET_FLAGS, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_FLAGS2:Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_GET_PEER_ADDR, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_PEER_ADDR: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + buflen = BUFLEN; + if (vppcom_session_attr (ssm->listen_fd, VPPCOM_ATTR_GET_LCL_ADDR, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_LCL_ADDR: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); +#endif #else rv = bind (ssm->listen_fd, (struct sockaddr *) &servaddr, sizeof (servaddr)); @@ -561,6 +607,24 @@ main (int argc, char **argv) if (EPOLLIN & ssm->wait_events[i].events) #endif { +#ifdef VCL_TEST +#if VPPCOM_SESSION_ATTR_UNIT_TEST + buflen = BUFLEN; + if (vppcom_session_attr (client_fd, VPPCOM_ATTR_GET_NREAD, + buffer, &buflen) < VPPCOM_OK) + printf ("\nNREAD: Oh no, Mr. Biiiiiiiiiiiilllllll ! ! ! !\n"); + if (vppcom_session_attr (client_fd, + VPPCOM_ATTR_GET_PEER_ADDR, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_PEER_ADDR: Oh no, Mr. " + "Biiiiiiiiiiiilllllll ! ! ! !\n"); + buflen = BUFLEN; + if (vppcom_session_attr (client_fd, VPPCOM_ATTR_GET_LCL_ADDR, + buffer, &buflen) != VPPCOM_OK) + printf ("\nGET_LCL_ADDR: Oh no, Mr. " + "Biiiiiiiiiiiilllllll ! ! ! !\n"); +#endif +#endif rx_bytes = sock_test_read (client_fd, conn->buf, conn->buf_size, &conn->stats); if (rx_bytes > 0) |