summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/vnet/session/tcp_echo.c113
1 files changed, 102 insertions, 11 deletions
diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c
index a925384b6e4..7cfd0ea025c 100644
--- a/src/tests/vnet/session/tcp_echo.c
+++ b/src/tests/vnet/session/tcp_echo.c
@@ -135,6 +135,58 @@ echo_main_t echo_main;
#define NITER 4000000
#endif
+const char test_srv_crt_rsa[] =
+ "-----BEGIN CERTIFICATE-----\r\n"
+ "MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n"
+ "MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n"
+ "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n"
+ "A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n"
+ "AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n"
+ "owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n"
+ "NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n"
+ "tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n"
+ "hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n"
+ "HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n"
+ "VR0TB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q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n"
+ "3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n"
+ "ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n"
+ "4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n"
+ "TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n"
+ "-----END RSA PRIVATE KEY-----\r\n";
+const u32 test_srv_key_rsa_len = sizeof (test_srv_key_rsa);
+
static u8 *
format_api_error (u8 * s, va_list * args)
{
@@ -191,6 +243,9 @@ void
application_send_attach (echo_main_t * em)
{
vl_api_application_attach_t *bmp;
+ vl_api_application_tls_cert_add_t *cert_mp;
+ vl_api_application_tls_key_add_t *key_mp;
+
u32 fifo_size = 4 << 20;
bmp = vl_msg_api_alloc (sizeof (*bmp));
memset (bmp, 0, sizeof (*bmp));
@@ -206,6 +261,24 @@ application_send_attach (echo_main_t * em)
bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
bmp->options[APP_OPTIONS_SEGMENT_SIZE] = 256 << 20;
vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & bmp);
+
+ cert_mp = vl_msg_api_alloc (sizeof (*cert_mp) + test_srv_crt_rsa_len);
+ memset (cert_mp, 0, sizeof (*cert_mp));
+ cert_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_CERT_ADD);
+ cert_mp->client_index = em->my_client_index;
+ cert_mp->context = ntohl (0xfeedface);
+ cert_mp->cert_len = clib_host_to_net_u16 (test_srv_crt_rsa_len);
+ clib_memcpy (cert_mp->cert, test_srv_crt_rsa, test_srv_crt_rsa_len);
+ vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & cert_mp);
+
+ key_mp = vl_msg_api_alloc (sizeof (*key_mp) + test_srv_key_rsa_len);
+ memset (key_mp, 0, sizeof (*key_mp) + test_srv_key_rsa_len);
+ key_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_KEY_ADD);
+ key_mp->client_index = em->my_client_index;
+ key_mp->context = ntohl (0xfeedface);
+ key_mp->key_len = clib_host_to_net_u16 (test_srv_key_rsa_len);
+ clib_memcpy (key_mp->key, test_srv_key_rsa, test_srv_key_rsa_len);
+ vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & key_mp);
}
int
@@ -1218,17 +1291,35 @@ vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
session_print_stats (em, session);
}
-#define foreach_tcp_echo_msg \
-_(BIND_URI_REPLY, bind_uri_reply) \
-_(UNBIND_URI_REPLY, unbind_uri_reply) \
-_(ACCEPT_SESSION, accept_session) \
-_(CONNECT_SESSION_REPLY, connect_session_reply) \
-_(DISCONNECT_SESSION, disconnect_session) \
-_(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \
-_(RESET_SESSION, reset_session) \
-_(APPLICATION_ATTACH_REPLY, application_attach_reply) \
-_(APPLICATION_DETACH_REPLY, application_detach_reply) \
-_(MAP_ANOTHER_SEGMENT, map_another_segment) \
+static void
+ vl_api_application_tls_cert_add_reply_t_handler
+ (vl_api_application_tls_cert_add_reply_t * mp)
+{
+ if (mp->retval)
+ clib_warning ("failed to add tls cert");
+}
+
+static void
+ vl_api_application_tls_key_add_reply_t_handler
+ (vl_api_application_tls_key_add_reply_t * mp)
+{
+ if (mp->retval)
+ clib_warning ("failed to add tls key");
+}
+
+#define foreach_tcp_echo_msg \
+_(BIND_URI_REPLY, bind_uri_reply) \
+_(UNBIND_URI_REPLY, unbind_uri_reply) \
+_(ACCEPT_SESSION, accept_session) \
+_(CONNECT_SESSION_REPLY, connect_session_reply) \
+_(DISCONNECT_SESSION, disconnect_session) \
+_(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \
+_(RESET_SESSION, reset_session) \
+_(APPLICATION_ATTACH_REPLY, application_attach_reply) \
+_(APPLICATION_DETACH_REPLY, application_detach_reply) \
+_(MAP_ANOTHER_SEGMENT, map_another_segment) \
+_(APPLICATION_TLS_CERT_ADD_REPLY, application_tls_cert_add_reply) \
+_(APPLICATION_TLS_KEY_ADD_REPLY, application_tls_key_add_reply) \
void
tcp_echo_api_hookup (echo_main_t * em)