diff --git a/bssl_perf/src/common.h b/bssl_perf/src/common.h index 34c4145..c3bafe4 100644 --- a/bssl_perf/src/common.h +++ b/bssl_perf/src/common.h @@ -11,6 +11,7 @@ #define PORT 1443 #define SSL_CONN_DATA 0x01 +#define SSL_DEF_CB 0x02 #define SERVER "localhost" #define CLIENT "localhost" #define CACERT "etc/ca/ca.cert.pem" diff --git a/bssl_perf/src/server.c b/bssl_perf/src/server.c index 45b31a0..9d4f800 100644 --- a/bssl_perf/src/server.c +++ b/bssl_perf/src/server.c @@ -113,12 +113,26 @@ static uint64_t time_now() { return ts.tv_sec * 1000000000 + ts.tv_nsec; } -// Starts counting time after key has been generated on client side +typedef void(*ngx_default_info_cb_t)(const SSL *ssl, int type, int value); +static void chained_cb(const SSL *ssl, int type, int value) { + if (!ssl) { + return; + } + + //printf("CHAINED > \n"); + ngx_default_info_cb_t cb = + SSL_CTX_get_ex_data( + SSL_get_SSL_CTX(ssl), SSL_DEF_CB); + + if (cb) { + cb(ssl,type,value); + } +} + static void after_keygen_handshake_time(const SSL *ssl, int type, int value) { static const char* ss_exp = "send_server_hello"; - // OZAPTF: should be static - const size_t ss_exp_len = strlen(ss_exp); + static const size_t ss_exp_len = 17; switch (type) { case SSL_CB_ACCEPT_LOOP: { @@ -181,6 +195,9 @@ static SSL_CTX* setup_server_ctx(const char* cert_name) { } SSL_CTX_set_info_callback(ctx, after_keygen_handshake_time); + ngx_default_info_cb_t cb = SSL_CTX_get_info_callback(ctx); + SSL_CTX_set_ex_data(ctx, SSL_DEF_CB, (void*)cb); + SSL_CTX_set_info_callback(ctx, chained_cb); return ctx; }