SSL object refactoring using SSL_CONNECTION object
[openssl.git] / ssl / statem / extensions_cust.c
index 401a4c5c76b104269106140ec2fc833021c14807..a2c563b86b7e285daa2814abb15afc42606a3d0e 100644 (file)
@@ -110,7 +110,8 @@ void custom_ext_init(custom_ext_methods *exts)
 }
 
 /* Pass received custom extension data to the application for parsing. */
-int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
+int custom_ext_parse(SSL_CONNECTION *s, unsigned int context,
+                     unsigned int ext_type,
                      const unsigned char *ext_data, size_t ext_size, X509 *x,
                      size_t chainidx)
 {
@@ -154,11 +155,11 @@ int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
         meth->ext_flags |= SSL_EXT_FLAG_RECEIVED;
 
     /* If no parse function set return success */
-    if (!meth->parse_cb)
+    if (meth->parse_cb == NULL)
         return 1;
 
-    if (meth->parse_cb(s, ext_type, context, ext_data, ext_size, x, chainidx,
-                       &al, meth->parse_arg) <= 0) {
+    if (meth->parse_cb(SSL_CONNECTION_GET_SSL(s), ext_type, context, ext_data,
+                       ext_size, x, chainidx, &al, meth->parse_arg) <= 0) {
         SSLfatal(s, al, SSL_R_BAD_EXTENSION);
         return 0;
     }
@@ -170,8 +171,8 @@ int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type,
  * Request custom extension data from the application and add to the return
  * buffer.
  */
-int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
-                   int maxversion)
+int custom_ext_add(SSL_CONNECTION *s, int context, WPACKET *pkt, X509 *x,
+                   size_t chainidx, int maxversion)
 {
     custom_ext_methods *exts = &s->cert->custext;
     custom_ext_method *meth;
@@ -204,7 +205,8 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
             continue;
 
         if (meth->add_cb != NULL) {
-            int cb_retval = meth->add_cb(s, meth->ext_type, context, &out,
+            int cb_retval = meth->add_cb(SSL_CONNECTION_GET_SSL(s),
+                                         meth->ext_type, context, &out,
                                          &outlen, x, chainidx, &al,
                                          meth->add_arg);
 
@@ -239,7 +241,8 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
             meth->ext_flags |= SSL_EXT_FLAG_SENT;
         }
         if (meth->free_cb != NULL)
-            meth->free_cb(s, meth->ext_type, context, out, meth->add_arg);
+            meth->free_cb(SSL_CONNECTION_GET_SSL(s), meth->ext_type, context,
+                          out, meth->add_arg);
     }
     return 1;
 }