|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2019 Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software; you can redistribute it and/or modify it
|
|
Packit Service |
4684c1 |
* under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful, but
|
|
Packit Service |
4684c1 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
* General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
* along with GnuTLS; if not, write to the Free Software Foundation,
|
|
Packit Service |
4684c1 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
#include <stdint.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <errno.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/dtls.h>
|
|
Packit Service |
4684c1 |
#include <signal.h>
|
|
Packit Service |
4684c1 |
#include <unistd.h>
|
|
Packit Service |
4684c1 |
#ifndef _WIN32
|
|
Packit Service |
4684c1 |
# include <netinet/in.h>
|
|
Packit Service |
4684c1 |
# include <sys/types.h>
|
|
Packit Service |
4684c1 |
# include <sys/socket.h>
|
|
Packit Service |
4684c1 |
# include <sys/wait.h>
|
|
Packit Service |
4684c1 |
# include <pthread.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <assert.h>
|
|
Packit Service |
4684c1 |
#include "utils.h"
|
|
Packit Service |
4684c1 |
#include "cert-common.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define FLAG_CLI_DO_THREADS 1
|
|
Packit Service |
4684c1 |
#define FLAG_FALSE_START 2
|
|
Packit Service |
4684c1 |
#define FLAG_EARLY_START 4
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef _WIN32
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
exit(77);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#else
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Tests whether we can send and receive from different threads
|
|
Packit Service |
4684c1 |
* using DTLS, either as server or client. DTLS is a superset of
|
|
Packit Service |
4684c1 |
* TLS, so correct behavior under fork means TLS would operate too.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
const char *side = "";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void tls_log_func(int level, const char *str)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
fprintf(stderr, "%s|<%d>| %s", side, level, str);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define MSG "hello1111"
|
|
Packit Service |
4684c1 |
#define MSG2 "xxxxxxxxxxxx"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define NO_MSGS 128
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void *recv_thread(void *arg)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
gnutls_session_t session = arg;
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
char buf[64];
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("client: TLS version is: %s\n",
|
|
Packit Service |
4684c1 |
gnutls_protocol_get_name
|
|
Packit Service |
4684c1 |
(gnutls_protocol_get_version(session)));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i=0;i
|
|
Packit Service |
4684c1 |
/* the peer should reflect our messages */
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_recv(session, buf, sizeof(buf));
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
fail("client: recv failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
if (ret != sizeof(MSG)-1 || memcmp(buf, MSG, sizeof(MSG)-1) != 0) {
|
|
Packit Service |
4684c1 |
fail("client: recv failed; not the expected values (got: %d, exp: %d)\n", ret, (int)sizeof(MSG)-1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("%d: client received: %.*s\n", i, ret, buf);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* final MSG is MSG2 */
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_recv(session, buf, sizeof(buf));
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret < 0)
|
|
Packit Service |
4684c1 |
fail("client: recv2 failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret != sizeof(MSG2)-1 || memcmp(buf, MSG2, sizeof(MSG2)-1) != 0) {
|
|
Packit Service |
4684c1 |
fail("client: recv2 failed; not the expected values\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_recv(session, buf, sizeof(buf));
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret != 0)
|
|
Packit Service |
4684c1 |
fail("client: no EOF: %d\n", ret);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
success("client received: %.*s\n", ret, buf);
|
|
Packit Service |
4684c1 |
success("closing recv thread\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
pthread_exit(0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static
|
|
Packit Service |
4684c1 |
void do_thread_stuff(gnutls_session_t session)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
unsigned i;
|
|
Packit Service |
4684c1 |
pthread_t id;
|
|
Packit Service |
4684c1 |
void *rval;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
sec_sleep(1);
|
|
Packit Service |
4684c1 |
/* separate sending from receiving */
|
|
Packit Service |
4684c1 |
ret = pthread_create(&id, NULL, recv_thread, session);
|
|
Packit Service |
4684c1 |
if (ret != 0) {
|
|
Packit Service |
4684c1 |
fail("error in pthread_create\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i=0;i
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_send(session, MSG, sizeof(MSG)-1);
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret != sizeof(MSG)-1) {
|
|
Packit Service |
4684c1 |
fail("client: send failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_send(session, MSG2, sizeof(MSG2)-1);
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret != sizeof(MSG2)-1) {
|
|
Packit Service |
4684c1 |
fail("client: send2 failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("closing sending thread\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_bye(session, GNUTLS_SHUT_WR);
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* the receiving thread will receive the EOF and close */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(pthread_join(id, &rval)==0);
|
|
Packit Service |
4684c1 |
assert(rval == 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void do_reflect_stuff(gnutls_session_t session)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
char buf[64];
|
|
Packit Service |
4684c1 |
unsigned buf_size;
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_recv(session, buf, sizeof(buf));
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
fail("server: recv failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret == 0) {
|
|
Packit Service |
4684c1 |
break;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
buf_size = ret;
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
success("server received: %.*s\n", buf_size, buf);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_record_send(session, buf, buf_size);
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
fail("server: send failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("reflected %d\n", ret);
|
|
Packit Service |
4684c1 |
} while(1);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
gnutls_bye(session, GNUTLS_SHUT_WR);
|
|
Packit Service |
4684c1 |
} while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void client(int fd, const char *prio, unsigned flags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t x509_cred;
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
unsigned init_flags = GNUTLS_CLIENT;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
global_init();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
side = "client";
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(tls_log_func);
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(4711);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&x509_cred)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (flags & FLAG_FALSE_START)
|
|
Packit Service |
4684c1 |
init_flags |= GNUTLS_ENABLE_FALSE_START;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, init_flags) >= 0);
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 60 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_priority_set_direct(session, prio, NULL)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Perform the TLS handshake
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
fail("client: Handshake failed: %s\n", gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("client: Handshake was completed\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (flags & FLAG_CLI_DO_THREADS)
|
|
Packit Service |
4684c1 |
do_thread_stuff(session);
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
do_reflect_stuff(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
close(fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(x509_cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void server(int fd, const char *prio, unsigned flags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t x509_cred;
|
|
Packit Service |
4684c1 |
gnutls_session_t session;
|
|
Packit Service |
4684c1 |
unsigned init_flags = GNUTLS_SERVER;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* this must be called once in the program
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
global_init();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if 0
|
|
Packit Service |
4684c1 |
if (debug) {
|
|
Packit Service |
4684c1 |
side = "server";
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_function(tls_log_func);
|
|
Packit Service |
4684c1 |
gnutls_global_set_log_level(4711);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_allocate_credentials(&x509_cred)>=0);
|
|
Packit Service |
4684c1 |
assert(gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert,
|
|
Packit Service |
4684c1 |
&server_key,
|
|
Packit Service |
4684c1 |
GNUTLS_X509_FMT_PEM)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (flags & FLAG_EARLY_START)
|
|
Packit Service |
4684c1 |
init_flags |= GNUTLS_ENABLE_EARLY_START;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_init(&session, init_flags)>=0);
|
|
Packit Service |
4684c1 |
gnutls_handshake_set_timeout(session, 60 * 1000);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
assert(gnutls_priority_set_direct(session, prio, NULL)>=0);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_transport_set_int(session, fd);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
do {
|
|
Packit Service |
4684c1 |
ret = gnutls_handshake(session);
|
|
Packit Service |
4684c1 |
} while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
close(fd);
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
fail("server: Handshake has failed (%s)\n\n",
|
|
Packit Service |
4684c1 |
gnutls_strerror(ret));
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: Handshake was completed\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: TLS version is: %s\n",
|
|
Packit Service |
4684c1 |
gnutls_protocol_get_name
|
|
Packit Service |
4684c1 |
(gnutls_protocol_get_version(session)));
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (flags & FLAG_CLI_DO_THREADS)
|
|
Packit Service |
4684c1 |
do_reflect_stuff(session);
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
do_thread_stuff(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
close(fd);
|
|
Packit Service |
4684c1 |
gnutls_deinit(session);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(x509_cred);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_global_deinit();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (debug)
|
|
Packit Service |
4684c1 |
success("server: finished\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static
|
|
Packit Service |
4684c1 |
void run(const char *str, const char *prio, unsigned flags)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int fd[2];
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
pid_t child;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (str)
|
|
Packit Service |
4684c1 |
success("running %s\n", str);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
|
|
Packit Service |
4684c1 |
if (ret < 0) {
|
|
Packit Service |
4684c1 |
perror("socketpair");
|
|
Packit Service |
4684c1 |
exit(1);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
child = fork();
|
|
Packit Service |
4684c1 |
if (child < 0) {
|
|
Packit Service |
4684c1 |
perror("fork");
|
|
Packit Service |
4684c1 |
fail("fork");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (child) {
|
|
Packit Service |
4684c1 |
int status;
|
|
Packit Service |
4684c1 |
/* parent */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
close(fd[1]);
|
|
Packit Service |
4684c1 |
client(fd[0], prio, flags);
|
|
Packit Service |
4684c1 |
wait(&status);
|
|
Packit Service |
4684c1 |
check_wait_status(status);
|
|
Packit Service |
4684c1 |
} else {
|
|
Packit Service |
4684c1 |
close(fd[0]);
|
|
Packit Service |
4684c1 |
server(fd[1], prio, flags);
|
|
Packit Service |
4684c1 |
exit(0);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void doit(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
signal(SIGPIPE, SIG_IGN);
|
|
Packit Service |
4684c1 |
run("default, threaded client", "NORMAL", FLAG_CLI_DO_THREADS);
|
|
Packit Service |
4684c1 |
run("default, threaded server", "NORMAL", 0);
|
|
Packit Service |
4684c1 |
run("tls1.2, threaded client", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2", FLAG_CLI_DO_THREADS);
|
|
Packit Service |
4684c1 |
run("tls1.2, threaded server", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2", 0);
|
|
Packit Service |
4684c1 |
run("tls1.2 false start, threaded client", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2", FLAG_CLI_DO_THREADS|FLAG_FALSE_START);
|
|
Packit Service |
4684c1 |
run("tls1.2 false start, threaded server", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2", FLAG_FALSE_START);
|
|
Packit Service |
4684c1 |
run("tls1.3 early start, threaded client", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.3", FLAG_CLI_DO_THREADS|FLAG_EARLY_START);
|
|
Packit Service |
4684c1 |
run("tls1.3 early start, threaded server", "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.3", FLAG_EARLY_START);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif /* _WIN32 */
|