Browse Source

Chained callbacks

master
Henry Case 5 years ago
parent
commit
79d0b7cc5a
2 changed files with 21 additions and 3 deletions
  1. +1
    -0
      bssl_perf/src/common.h
  2. +20
    -3
      bssl_perf/src/server.c

+ 1
- 0
bssl_perf/src/common.h View File

@@ -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"


+ 20
- 3
bssl_perf/src/server.c View File

@@ -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;
}



Loading…
Cancel
Save