summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_test_client.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_client.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_client.c')
-rw-r--r--src/vcl/vcl_test_client.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/vcl/vcl_test_client.c b/src/vcl/vcl_test_client.c
index e1d7b3b3a81..70fe75d9acd 100644
--- a/src/vcl/vcl_test_client.c
+++ b/src/vcl/vcl_test_client.c
@@ -711,10 +711,11 @@ print_usage_and_exit (void)
" OPTIONS\n"
" -h Print this message and exit.\n"
" -6 Use IPv6\n"
- " -u Use UDP transport layer\n"
" -c Print test config before test.\n"
" -w <dir> Write test results to <dir>.\n"
" -X Exit after running test.\n"
+ " -D Use UDP transport layer\n"
+ " -S Use TLS transport layer\n"
" -E Run Echo test.\n"
" -N <num-writes> Test Cfg: number of writes.\n"
" -R <rxbuf-size> Test Cfg: rx buffer size.\n"
@@ -732,7 +733,7 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv)
int c, v;
opterr = 0;
- while ((c = getopt (argc, argv, "chn:w:XE:I:N:R:T:UBV6D")) != -1)
+ while ((c = getopt (argc, argv, "chn:w:XE:I:N:R:T:UBV6DS")) != -1)
switch (c)
{
case 'c':
@@ -873,6 +874,10 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv)
ctrl->cfg.transport_udp = 1;
break;
+ case 'S':
+ ctrl->cfg.transport_tls = 1;
+ break;
+
case '?':
switch (optopt)
{
@@ -902,7 +907,19 @@ vtc_process_opts (vcl_test_client_main_t * vcm, int argc, char **argv)
vtwrn ("Insufficient number of arguments!");
print_usage_and_exit ();
}
- vcm->proto = ctrl->cfg.transport_udp ? VPPCOM_PROTO_UDP : VPPCOM_PROTO_TCP;
+
+ if (ctrl->cfg.transport_udp)
+ {
+ vcm->proto = VPPCOM_PROTO_UDP;
+ }
+ else if (ctrl->cfg.transport_tls)
+ {
+ vcm->proto = VPPCOM_PROTO_TLS;
+ }
+ else
+ {
+ vcm->proto = VPPCOM_PROTO_TCP;
+ }
memset (&vcm->server_addr, 0, sizeof (vcm->server_addr));
if (ctrl->cfg.address_ip6)
@@ -988,6 +1005,15 @@ main (int argc, char **argv)
if (ctrl->fd < 0)
vtfail ("vppcom_session_create()", ctrl->fd);
+ if (vcm->proto == VPPCOM_PROTO_TLS)
+ {
+ vppcom_session_tls_add_cert (ctrl->fd, vcl_test_crt_rsa,
+ vcl_test_crt_rsa_len);
+ vppcom_session_tls_add_key (ctrl->fd, vcl_test_key_rsa,
+ vcl_test_key_rsa_len);
+ }
+
+
vtinf ("Connecting to server...");
rv = vppcom_session_connect (ctrl->fd, &vcm->server_endpt);
if (rv)