aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_test_server.c
diff options
context:
space:
mode:
authorPing Yu <ping.yu@intel.com>2018-11-30 19:16:17 -0500
committerFlorin Coras <florin.coras@gmail.com>2019-01-04 19:55:47 +0000
commit34a3a08d993cbbb3846b83b69b5338d452463e15 (patch)
tree3613106e74772d42036c0d547aaae81898e5aec2 /src/vcl/vcl_test_server.c
parent33331edd3ab8c2c2109203be7568587664f08abc (diff)
Add TLS support for VCL
Ater this patch, vcl_test_client and vcl_test_server can work happily with TLS connection. "-S" is to indicate TLS connection. Change-Id: I761894b0b5929912691625f0fe63604725b55978 Signed-off-by: Ping Yu <ping.yu@intel.com>
Diffstat (limited to 'src/vcl/vcl_test_server.c')
-rw-r--r--src/vcl/vcl_test_server.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/vcl/vcl_test_server.c b/src/vcl/vcl_test_server.c
index 54f164e43c1..280944156c8 100644
--- a/src/vcl/vcl_test_server.c
+++ b/src/vcl/vcl_test_server.c
@@ -320,7 +320,8 @@ print_usage_and_exit (void)
" -h Print this message and exit.\n"
" -6 Use IPv6\n"
" -w <num> Number of workers\n"
- " -u Use UDP transport layer\n");
+ " -D Use UDP transport layer\n"
+ " -S Use TLS transport layer\n");
exit (1);
}
@@ -370,7 +371,7 @@ vcl_test_server_process_opts (vcl_test_server_main_t * vsm, int argc,
vsm->cfg.proto = VPPCOM_PROTO_TCP;
opterr = 0;
- while ((c = getopt (argc, argv, "6Dsw:")) != -1)
+ while ((c = getopt (argc, argv, "6DSsw:")) != -1)
switch (c)
{
case '6':
@@ -381,6 +382,10 @@ vcl_test_server_process_opts (vcl_test_server_main_t * vsm, int argc,
vsm->cfg.proto = VPPCOM_PROTO_UDP;
break;
+ case 'S':
+ vsm->cfg.proto = VPPCOM_PROTO_TLS;
+ break;
+
case 'w':
v = atoi (optarg);
if (v > 1)
@@ -499,6 +504,15 @@ vts_worker_init (vcl_test_server_worker_t * wrk)
if (wrk->listen_fd < 0)
vtfail ("vppcom_session_create()", wrk->listen_fd);
+
+ if (vsm->cfg.proto == VPPCOM_PROTO_TLS)
+ {
+ vppcom_session_tls_add_cert (wrk->listen_fd, vcl_test_crt_rsa,
+ vcl_test_crt_rsa_len);
+ vppcom_session_tls_add_key (wrk->listen_fd, vcl_test_key_rsa,
+ vcl_test_key_rsa_len);
+ }
+
rv = vppcom_session_bind (wrk->listen_fd, &vsm->cfg.endpt);
if (rv < 0)
vtfail ("vppcom_session_bind()", rv);