Provisional DTLS 1.2 support.
[openssl.git] / ssl / d1_meth.c
index dc4c8ed..64a22d6 100644 (file)
 #include <openssl/objects.h>
 #include "ssl_locl.h"
 
-static SSL_METHOD *dtls1_get_method(int ver);
-static SSL_METHOD *dtls1_get_method(int ver)
+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);
-       }