diff --git a/programs/Makefile b/programs/Makefile index 8bb7f2bff1..1a2726b430 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -268,12 +268,13 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP) $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ SSL_TEST_OBJECTS = test/query_config.o ssl/ssl_test_lib.o +SSL_TEST_DEPS = $(SSL_TEST_OBJECTS) ssl/ssl_test_lib.h ssl/ssl_test_common_source.c $(DEP) ssl/ssl_test_lib.o: ssl/ssl_test_lib.c ssl/ssl_test_lib.h $(DEP) echo " CC ssl/ssl_test_lib.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c ssl/ssl_test_lib.c -o $@ -ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(SSL_TEST_OBJECTS) ssl/ssl_test_lib.h $(DEP) +ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(SSL_TEST_DEPS) echo " CC ssl/ssl_client2.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ @@ -281,7 +282,7 @@ ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP) echo " CC ssl/ssl_server.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(SSL_TEST_OBJECTS) $(DEP) +ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(SSL_TEST_DEPS) echo " CC ssl/ssl_server2.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 1ddfb804cf..7979e395a4 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -987,6 +987,7 @@ static int send_cb( void *ctx, unsigned char const *buf, size_t len ) return( mbedtls_net_send( io_ctx->net, buf, len ) ); } +#include "ssl_test_common_source.c" #if defined(MBEDTLS_X509_CRT_PARSE_C) static unsigned char peer_crt_info[1024]; diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 4e11cb3a0c..a1fbca6dca 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1088,6 +1088,7 @@ static int send_cb( void *ctx, unsigned char const *buf, size_t len ) return( mbedtls_net_send( io_ctx->net, buf, len ) ); } +#include "ssl_test_common_source.c" /* * Return authmode from string, or -1 on error diff --git a/programs/ssl/ssl_test_common_source.c b/programs/ssl/ssl_test_common_source.c new file mode 100644 index 0000000000..78b9331a41 --- /dev/null +++ b/programs/ssl/ssl_test_common_source.c @@ -0,0 +1,25 @@ +/* + * Common source code for SSL test programs. This file is included by + * both ssl_client2.c and ssl_server2.c and is intended for source + * code that is textually identical in both programs, but that cannot be + * compiled separately because it refers to types or macros that are + * different in the two programs, or because it would have an incomplete + * type. + * + * This file is meant to be #include'd and cannot be compiled separately. + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/programs/ssl/ssl_test_lib.c b/programs/ssl/ssl_test_lib.c index e3645f354b..897afc68bc 100644 --- a/programs/ssl/ssl_test_lib.c +++ b/programs/ssl/ssl_test_lib.c @@ -1,5 +1,8 @@ /* - * Common code for SSL test programs + * Common code library for SSL test programs. + * + * In addition to the functions in this file, there is shared source code + * that cannot be compiled separately in "ssl_test_common_source.c". * * Copyright The Mbed TLS Contributors * SPDX-License-Identifier: Apache-2.0