]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
simplified hook function, to apply only to post-processing or generation of messages.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 26 Jun 2013 07:43:05 +0000 (09:43 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 26 Jun 2013 07:43:05 +0000 (09:43 +0200)
lib/gnutls_handshake.c
lib/gnutls_state.c
lib/includes/gnutls/gnutls.h.in

index e440c9b807f8a64af53c6a4dd5a8aba97f6e5227..e6b8dbfcf802974b9fa1cd0d2f4dd2b5ad8967ae 100644 (file)
@@ -1143,14 +1143,14 @@ _gnutls_send_empty_handshake (gnutls_session_t session,
 
 inline
 static int call_hook_func(gnutls_session_t session, gnutls_handshake_description_t type,
-                          unsigned post, unsigned incoming)
+                          unsigned incoming)
 {
   if (session->internals.h_hook == NULL)
     return 0;
   else 
     {
       if (session->internals.h_type == type || session->internals.h_type == GNUTLS_HANDSHAKE_ANY)
-        return session->internals.h_hook(session, type, post, incoming);
+        return session->internals.h_hook(session, type, incoming);
 
       return 0;
     }
@@ -1222,16 +1222,15 @@ _gnutls_send_handshake (gnutls_session_t session, mbuffer_st * bufel,
         return ret;
       }
 
-  ret = call_hook_func(session, type, 0, 0);
+  session->internals.last_handshake_out = type;
+
+  ret = call_hook_func(session, type, 0);
   if (ret < 0)
     {
       gnutls_assert ();
-      _mbuffer_xfree(&bufel);
       return ret;
     }
 
-  session->internals.last_handshake_out = type;
-
   ret = _gnutls_handshake_io_cache_int (session, type, bufel);
   if (ret < 0)
     {
@@ -1264,13 +1263,6 @@ _gnutls_send_handshake (gnutls_session_t session, mbuffer_st * bufel,
       break;
     }
 
-  ret = call_hook_func(session, type, 1, 0);
-  if (ret < 0)
-    {
-      gnutls_assert ();
-      return ret;
-    }
-
   return ret;
 }
 
@@ -1397,13 +1389,6 @@ _gnutls_recv_handshake (gnutls_session_t session,
 
   session->internals.last_handshake_in = hsk.htype;
 
-  ret = call_hook_func(session, hsk.htype, 0, 1);
-  if (ret < 0)
-    {
-      gnutls_assert ();
-      goto cleanup;
-    }
-
   ret = _gnutls_handshake_hash_add_recvd (session, hsk.htype,
                                               hsk.header, hsk.header_size,
                                               hsk.data.data, hsk.data.length);
@@ -1473,7 +1458,7 @@ _gnutls_recv_handshake (gnutls_session_t session,
       goto cleanup;
     }
 
-  ret = call_hook_func(session, hsk.htype, 1, 1);
+  ret = call_hook_func(session, hsk.htype, 1);
   if (ret < 0)
     {
       gnutls_assert ();
index a5b8ec8c99b37db6b8dc6cb671323a58c9d6b4b4..bc7abae4e363c87519fb8d32c3b44d5674e0d8a4 100644 (file)
@@ -1414,7 +1414,7 @@ gnutls_handshake_set_random (gnutls_session_t session, const gnutls_datum_t* ran
  * @htype: the %gnutls_handshake_description_t of the message to hook at.
  * @func: is the function to be called
  *
- * This function will set a callback to be called after or before the specified
+ * This function will set a callback to be called after the specified
  * handshake message has been received or generated. This is a
  * generalization of gnutls_handshake_set_post_client_hello_function().
  *
index 724ee8a438806a5386a0cad27e082ee2535b5203..69a435b7e8ce3a084e3cad0794c14e4496de2384 100644 (file)
@@ -1176,7 +1176,6 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
    * gnutls_handshake_hook_func:
    * @session: the current session
    * @htype: the type of the handshake message (%gnutls_handshake_description_t)
-   * @post: non zero if this is an post-process/generation call and zero otherwise
    * @incoming: non zero if this is an incoming message and zero if this is an outgoing message
    *
    * Function prototype for handshake hooks. It is set using
@@ -1185,7 +1184,7 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
    * Returns: Non zero on error.
    */
 
-  typedef int (*gnutls_handshake_hook_func) (gnutls_session_t, unsigned int htype, unsigned int post, unsigned int incoming);
+  typedef int (*gnutls_handshake_hook_func) (gnutls_session_t, unsigned int htype, unsigned int incoming);
   void gnutls_handshake_set_hook_function (gnutls_session_t session,
                                           unsigned int htype,
                                           gnutls_handshake_hook_func func);