summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.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/vppcom.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/vppcom.c')
-rw-r--r--src/vcl/vppcom.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index be7293679f8..70afdce7832 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1191,7 +1191,7 @@ vppcom_session_bind (uint32_t session_handle, vppcom_endpt_t * ep)
format_ip46_address, &session->transport.lcl_ip,
session->transport.is_ip4 ? IP46_TYPE_IP4 : IP46_TYPE_IP6,
clib_net_to_host_u16 (session->transport.lcl_port),
- session->session_type ? "UDP" : "TCP");
+ vppcom_proto_str (session->session_type));
vcl_evt (VCL_EVT_BIND, session);
if (session->session_type == VPPCOM_PROTO_UDP)
@@ -1246,6 +1246,55 @@ vppcom_session_listen (uint32_t listen_sh, uint32_t q_len)
return VPPCOM_OK;
}
+int
+vppcom_session_tls_add_cert (uint32_t session_handle, char *cert,
+ uint32_t cert_len)
+{
+
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ vcl_session_t *session = 0;
+
+ session = vcl_session_get_w_handle (wrk, session_handle);
+ if (!session)
+ return VPPCOM_EBADFD;
+
+ if (cert_len == 0 || cert_len == ~0)
+ return VPPCOM_EBADFD;
+
+ /*
+ * Send listen request to vpp and wait for reply
+ */
+ vppcom_send_application_tls_cert_add (session, cert, cert_len);
+
+ return VPPCOM_OK;
+
+}
+
+int
+vppcom_session_tls_add_key (uint32_t session_handle, char *key,
+ uint32_t key_len)
+{
+
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ vcl_session_t *session = 0;
+
+ session = vcl_session_get_w_handle (wrk, session_handle);
+ if (!session)
+ return VPPCOM_EBADFD;
+
+ if (key_len == 0 || key_len == ~0)
+ return VPPCOM_EBADFD;
+
+ /*
+ * Send listen request to vpp and wait for reply
+ */
+ vppcom_send_application_tls_key_add (session, key, key_len);
+
+ return VPPCOM_OK;
+
+
+}
+
static int
validate_args_session_accept_ (vcl_worker_t * wrk,
vcl_session_t * listen_session)
@@ -1420,7 +1469,7 @@ vppcom_session_connect (uint32_t session_handle, vppcom_endpt_t * server_ep)
&session->transport.rmt_ip, session->transport.is_ip4 ?
IP46_TYPE_IP4 : IP46_TYPE_IP6,
clib_net_to_host_u16 (session->transport.rmt_port),
- session->session_type ? "UDP" : "TCP", session->session_state,
+ vppcom_proto_str (session->session_type), session->session_state,
vppcom_session_state_str (session->session_state));
return VPPCOM_OK;
}
@@ -1442,7 +1491,7 @@ vppcom_session_connect (uint32_t session_handle, vppcom_endpt_t * server_ep)
&session->transport.rmt_ip, session->transport.is_ip4 ?
IP46_TYPE_IP4 : IP46_TYPE_IP6,
clib_net_to_host_u16 (session->transport.rmt_port),
- session->session_type ? "UDP" : "TCP");
+ vppcom_proto_str (session->session_type));
/*
* Send connect request and wait for reply from vpp