static int handshake_callback(gnutls_session_t session, unsigned int htype, unsigned post, unsigned int incoming, const gnutls_datum_t *rawmsg) { static unsigned idx = 0; unsigned int msg; if (msg_order[idx] != htype) { fail("%s: %s, expected %s\n", incoming != 0 ? "Received" : "Sent", gnutls_handshake_description_get_name(htype), gnutls_handshake_description_get_name(msg_order [idx])); exit(1); } idx++; if (incoming != 0) { msg = gnutls_handshake_get_last_in(session); if (msg != htype) { fail("last input message was not recorded (exp: %d, found: %d) \n", msg, htype); exit(1); } } else { msg = gnutls_handshake_get_last_out(session); if (msg != htype) { fail("last output message was not recorded (exp: %d, found: %d) \n", msg, htype); exit(1); } } return 0; }
static int handshake_hook_func(gnutls_session_t session, unsigned int htype, unsigned int post, unsigned int incoming) { if (!session) { return 0; } auto* tls = reinterpret_cast<CTlsSocket*>(gnutls_session_get_ptr(session)); if (!tls) { return 0; } char const* prefix; if (incoming) { if (post) { prefix = "Processed"; } else { prefix = "Received"; } } else { if (post) { prefix = "Sent"; } else { prefix = "About to send"; } } char const* name = gnutls_handshake_description_get_name(static_cast<gnutls_handshake_description_t>(htype)); tls->m_pOwner->LogMessage(MessageType::Debug_Debug, _T("TLS handshake: %s %s"), prefix, name); return 0; }