X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=ssl%2Fd1_meth.c;h=734077493f843b96be9316f7f40fcee674f5e883;hp=dc4c8ede8667b17d243ceae9d7600f164b53415b;hb=ab97b2cd4301074fd88fd2f13b8c79342593dae4;hpb=36d16f8ee0845d932e250286e8e236580470e35b diff --git a/ssl/d1_meth.c b/ssl/d1_meth.c index dc4c8ede86..734077493f 100644 --- a/ssl/d1_meth.c +++ b/ssl/d1_meth.c @@ -1,7 +1,7 @@ /* ssl/d1_meth.h */ -/* +/* * DTLS implementation written by Nagendra Modadugu - * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. @@ -11,7 +11,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -61,36 +61,28 @@ #include #include "ssl_locl.h" -static SSL_METHOD *dtls1_get_method(int ver); -static SSL_METHOD *dtls1_get_method(int ver) - { - if (ver == DTLS1_VERSION) - return(DTLSv1_method()); - else - return(NULL); - } +static const SSL_METHOD *dtls1_get_method(int ver); +static const SSL_METHOD *dtls1_get_method(int ver) +{ + if (ver == DTLS1_VERSION) + return (DTLSv1_method()); + else if (ver == DTLS1_2_VERSION) + return (DTLSv1_2_method()); + else + return (NULL); +} -SSL_METHOD *DTLSv1_method(void) - { - static int init=1; - static SSL_METHOD DTLSv1_data; +IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, + DTLSv1_method, + dtls1_accept, + dtls1_connect, dtls1_get_method, DTLSv1_enc_data) - if (init) - { - CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); - - if (init) - { - memcpy((char *)&DTLSv1_data,(char *)dtlsv1_base_method(), - sizeof(SSL_METHOD)); - DTLSv1_data.ssl_connect=dtls1_connect; - DTLSv1_data.ssl_accept=dtls1_accept; - DTLSv1_data.get_ssl_method=dtls1_get_method; - init=0; - } + IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, + DTLSv1_2_method, + dtls1_accept, + dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data) - CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); - } - - return(&DTLSv1_data); - } + IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, + DTLS_method, + dtls1_accept, + dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data)