summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/application_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/application_interface.c')
-rw-r--r--src/vnet/session/application_interface.c92
1 files changed, 75 insertions, 17 deletions
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index fd079b5147b..12a5701fdf3 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -22,6 +22,61 @@
VPP's application/session API bind/unbind/connect/disconnect calls
*/
+/*
+ * TLS server cert and keys to be used for testing only
+ */
+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+w3lkvEcf36hIBMJcCAwEAA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LjHVd4HPJ2x0N8CgrBIWOE0q8+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
session_endpoint_is_local (session_endpoint_t * sep)
{
@@ -179,8 +234,8 @@ vnet_unbind_i (u32 app_index, session_handle_t handle)
}
int
-vnet_connect_i (u32 client_index, u32 api_context, session_endpoint_t * sep,
- void *mp)
+application_connect (u32 client_index, u32 api_context,
+ session_endpoint_t * sep)
{
application_t *server, *client;
u32 table_index, server_index, li;
@@ -277,22 +332,23 @@ uword
unformat_vnet_uri (unformat_input_t * input, va_list * args)
{
session_endpoint_t *sep = va_arg (*args, session_endpoint_t *);
- u32 transport_proto = 0;
- if (unformat (input, "%U://%U/%d", unformat_transport_proto,
- &transport_proto, unformat_ip4_address, &sep->ip.ip4,
- &sep->port))
+ u32 transport_proto = 0, port;
+
+ if (unformat
+ (input, "%U://%U/%d", unformat_transport_proto, &transport_proto,
+ unformat_ip4_address, &sep->ip.ip4, &port))
{
sep->transport_proto = transport_proto;
- sep->port = clib_host_to_net_u16 (sep->port);
+ sep->port = clib_host_to_net_u16 (port);
sep->is_ip4 = 1;
return 1;
}
- if (unformat (input, "%U://%U/%d", unformat_transport_proto,
- &transport_proto, unformat_ip6_address, &sep->ip.ip6,
- &sep->port))
+ else if (unformat (input, "%U://%U/%d", unformat_transport_proto,
+ &transport_proto, unformat_ip6_address, &sep->ip.ip6,
+ &port))
{
sep->transport_proto = transport_proto;
- sep->port = clib_host_to_net_u16 (sep->port);
+ sep->port = clib_host_to_net_u16 (port);
sep->is_ip4 = 0;
return 1;
}
@@ -440,8 +496,8 @@ vnet_bind_uri (vnet_bind_args_t * a)
int
vnet_unbind_uri (vnet_unbind_args_t * a)
{
- stream_session_t *listener;
session_endpoint_t sep = SESSION_ENDPOINT_NULL;
+ stream_session_t *listener;
int rv;
rv = parse_uri (a->uri, &sep);
@@ -459,15 +515,15 @@ vnet_unbind_uri (vnet_unbind_args_t * a)
clib_error_t *
vnet_connect_uri (vnet_connect_args_t * a)
{
- session_endpoint_t sep_null = SESSION_ENDPOINT_NULL;
+ session_endpoint_t sep = SESSION_ENDPOINT_NULL;
int rv;
/* Parse uri */
- a->sep = sep_null;
- rv = parse_uri (a->uri, &a->sep);
+ rv = parse_uri (a->uri, &sep);
if (rv)
return clib_error_return_code (0, rv, 0, "app init: %d", rv);
- if ((rv = vnet_connect_i (a->app_index, a->api_context, &a->sep, a->mp)))
+
+ if ((rv = application_connect (a->app_index, a->api_context, &sep)))
return clib_error_return_code (0, rv, 0, "connect failed");
return 0;
}
@@ -523,8 +579,10 @@ vnet_unbind (vnet_unbind_args_t * a)
clib_error_t *
vnet_connect (vnet_connect_args_t * a)
{
+ session_endpoint_t *sep = &a->sep;
int rv;
- if ((rv = vnet_connect_i (a->app_index, a->api_context, &a->sep, a->mp)))
+
+ if ((rv = application_connect (a->app_index, a->api_context, sep)))
return clib_error_return_code (0, rv, 0, "connect failed");
return 0;
}