From: Nikos Mavrogiannopoulos Date: Wed, 26 Jun 2013 07:43:05 +0000 (+0200) Subject: simplified hook function, to apply only to post-processing or generation of messages. X-Git-Tag: gnutls_3_2_2~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b14a8217b78aaf3367d13181237bf937292f5ba;p=thirdparty%2Fgnutls.git simplified hook function, to apply only to post-processing or generation of messages. --- diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index e440c9b807..e6b8dbfcf8 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -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 (); diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index a5b8ec8c99..bc7abae4e3 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -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(). * diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 724ee8a438..69a435b7e8 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -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);