From 4b60a6b541db346e870d9b7c5b1d364a05e4bd6f Mon Sep 17 00:00:00 2001 From: Achim Kraus Date: Tue, 24 Jan 2023 20:08:13 +0100 Subject: [PATCH] dtls-client.c: add support_cid option. Signed-off-by: Achim Kraus --- tests/dtls-client.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/dtls-client.c b/tests/dtls-client.c index f5f2809a..a068bd6a 100644 --- a/tests/dtls-client.c +++ b/tests/dtls-client.c @@ -63,7 +63,9 @@ static dtls_context_t *orig_dtls_context = NULL; static const dtls_cipher_t* ciphers = NULL; static unsigned int force_extended_master_secret = 0; static unsigned int force_renegotiation_info = 0; - +#if (DTLS_MAX_CID_LENGTH > 0) +static unsigned int support_cid = 0; +#endif #ifdef DTLS_ECC static const unsigned char ecdsa_priv_key[] = { @@ -240,6 +242,9 @@ get_user_parameters(struct dtls_context_t *ctx, (void) session; user_parameters->force_extended_master_secret = force_extended_master_secret; user_parameters->force_renegotiation_info = force_renegotiation_info; +#if (DTLS_MAX_CID_LENGTH > 0) + user_parameters->support_cid = support_cid; +#endif if (ciphers) { int index = 0; while (index < DTLS_MAX_CIPHER_SUITES) { @@ -354,13 +359,18 @@ usage( const char *program, const char *version) { fprintf(stderr, "%s v%s -- DTLS client implementation\n" "(c) 2011-2014 Olaf Bergmann \n\n" + "usage: %s [-c cipher suites] [-e] " #ifdef DTLS_PSK - "usage: %s [-c cipher suites] [-e] [-i file] [-k file] [-o file]\n" - " %*s [-p port] [-r] [-v num] addr [port]\n", + "[-i file] [-k file] [-o file]\n" + " %*s [-p port] [-r] [-v num]" #else /* DTLS_PSK */ - "usage: %s [-c cipher suites] [-e] [-o file] [-p port] [-r]\n" - " %*s [-v num] addr [port]\n", + "[-o file] [-p port] [-r]\n" + " %*s [-v num]" #endif /* DTLS_PSK */ +#if (DTLS_MAX_CID_LENGTH > 0) + " [-z]" +#endif /* DTLS_MAX_CID_LENGTH > 0*/ + " addr [port]\n", program, version, program, (int)strlen(program), ""); cipher_suites_usage(stderr, "\t"); fprintf(stderr, "\t-e\t\tforce extended master secret (RFC7627)\n" @@ -372,7 +382,10 @@ usage( const char *program, const char *version) { "\t \t\t(use '-' for STDOUT)\n" "\t-p port\t\tlisten on specified port (default is %d)\n" "\t-r\t\tforce renegotiation info (RFC5746)\n" - "\t-v num\t\tverbosity level (default: 3)\n", + "\t-v num\t\tverbosity level (default: 3)\n" +#if (DTLS_MAX_CID_LENGTH > 0) + "\t-z\t\tsupport CID (RFC9146)\n", +#endif /* DTLS_MAX_CID_LENGTH > 0*/ DEFAULT_PORT); } @@ -428,7 +441,7 @@ main(int argc, char **argv) { memcpy(psk_key, PSK_DEFAULT_KEY, psk_key_length); #endif /* DTLS_PSK */ - while ((opt = getopt(argc, argv, "c:eo:p:rv:" PSK_OPTIONS)) != -1) { + while ((opt = getopt(argc, argv, "c:eo:p:rv:z" PSK_OPTIONS)) != -1) { switch (opt) { #ifdef DTLS_PSK case 'i' : @@ -476,6 +489,9 @@ main(int argc, char **argv) { case 'v' : log_level = strtol(optarg, NULL, 10); break; + case 'z' : + support_cid = 1; + break; default: usage(argv[0], dtls_package_version()); exit(1);