diff --git a/examples/client.cc b/examples/client.cc index b674180d59cb82caa6cde58531f45694f92062ae..5eafef1d0f3ca0f088dd07e8c9bb67ca60b6b1b4 100644 --- a/examples/client.cc +++ b/examples/client.cc @@ -621,7 +621,7 @@ int extend_max_streams_bidi(ngtcp2_conn *conn, uint64_t max_streams, } // namespace namespace { -int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx) { +int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_usage usage) { auto dis = std::uniform_int_distribution<uint8_t>(0, 255); std::generate(dest, dest + destlen, [&dis]() { return dis(randgen); }); return 0; diff --git a/examples/h09client.cc b/examples/h09client.cc index d432b56ff32cf2986fb95d5f7ed3fc0659cd046e..b8484316f062c0565c90615e635811036d56bcba 100644 --- a/examples/h09client.cc +++ b/examples/h09client.cc @@ -597,7 +597,7 @@ int extend_max_streams_bidi(ngtcp2_conn *conn, uint64_t max_streams, } // namespace namespace { -int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx) { +int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_usage usage) { auto dis = std::uniform_int_distribution<uint8_t>(0, 255); std::generate(dest, dest + destlen, [&dis]() { return dis(randgen); }); return 0; diff --git a/examples/h09server.cc b/examples/h09server.cc index 4681b84888b3e0ff0441abb2d2d1f9dc4939376c..8e49c9a34e849cf0f75da49ba95f1fd28c180df1 100644 --- a/examples/h09server.cc +++ b/examples/h09server.cc @@ -704,7 +704,7 @@ int stream_close(ngtcp2_conn *conn, int64_t stream_id, uint64_t app_error_code, } // namespace namespace { -int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx) { +int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_usage usage) { auto dis = std::uniform_int_distribution<uint8_t>(0, 255); std::generate(dest, dest + destlen, [&dis]() { return dis(randgen); }); return 0; diff --git a/examples/server.cc b/examples/server.cc index 19c41c60674cdf6780404bcd6e1f9d2e35bdb328..427c57864588d2388f222c6ccf5e8db6cfaf96ff 100644 --- a/examples/server.cc +++ b/examples/server.cc @@ -1064,7 +1064,7 @@ int Handler::on_stream_reset(int64_t stream_id) { } namespace { -int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx) { +int rand(uint8_t *dest, size_t destlen, ngtcp2_rand_usage usage) { auto dis = std::uniform_int_distribution<uint8_t>(0, 255); std::generate(dest, dest + destlen, [&dis]() { return dis(randgen); }); return 0; diff --git a/lib/includes/ngtcp2/ngtcp2.h b/lib/includes/ngtcp2/ngtcp2.h index 3373adb9f91a52c1d0907a68d338da5b81e3d8f9..88d781b2a1711bfd28cb4e9eba13f764eb0e21fb 100644 --- a/lib/includes/ngtcp2/ngtcp2.h +++ b/lib/includes/ngtcp2/ngtcp2.h @@ -439,20 +439,20 @@ typedef enum ngtcp2_transport_params_type { /** * @enum * - * ngtcp2_rand_ctx is a context where generated random value is used. + * ngtcp2_rand_usage describes the usage of the generated random data. */ #if defined(__cplusplus) && __cplusplus >= 201103L -typedef enum ngtcp2_rand_ctx : int { +typedef enum ngtcp2_rand_usage : int { #else -typedef enum ngtcp2_rand_ctx { +typedef enum ngtcp2_rand_usage { #endif - NGTCP2_RAND_CTX_NONE, + NGTCP2_RAND_USAGE_NONE, /** - * NGTCP2_RAND_CTX_PATH_CHALLENGE indicates that random value is + * NGTCP2_RAND_USAGE_PATH_CHALLENGE indicates that random value is * used for PATH_CHALLENGE. */ - NGTCP2_RAND_CTX_PATH_CHALLENGE -} ngtcp2_rand_ctx; + NGTCP2_RAND_USAGE_PATH_CHALLENGE +} ngtcp2_rand_usage; /* * NGTCP2_DEFAULT_MAX_UDP_PAYLOAD_SIZE is the default value of @@ -1523,14 +1523,15 @@ typedef int (*ngtcp2_extend_max_stream_data)(ngtcp2_conn *conn, * * :type:`ngtcp2_rand` is a callback function to get randomized byte * string from application. Application must fill random |destlen| - * bytes to the buffer pointed by |dest|. |ctx| provides the context - * how the provided random byte string is used. + * bytes to the buffer pointed by |dest|. |usage| provides the usage + * of the generated random data. * * The callback function must return 0 if it succeeds. Returning * :enum:`NGTCP2_ERR_CALLBACK_FAILURE` makes the library call return * immediately. */ -typedef int (*ngtcp2_rand)(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx); +typedef int (*ngtcp2_rand)(uint8_t *dest, size_t destlen, + ngtcp2_rand_usage usage); /** * @functypedef diff --git a/lib/ngtcp2_conn.c b/lib/ngtcp2_conn.c index ff8c608b776dac873fa4e187ed83d383929b70b8..7f30cdad2a7dae7dde894e40fa3bcba413c9c97a 100644 --- a/lib/ngtcp2_conn.c +++ b/lib/ngtcp2_conn.c @@ -3618,7 +3618,7 @@ static ngtcp2_ssize conn_write_path_challenge(ngtcp2_conn *conn, assert(conn->callbacks.rand); rv = conn->callbacks.rand(lfr.path_challenge.data, sizeof(lfr.path_challenge.data), - NGTCP2_RAND_CTX_PATH_CHALLENGE); + NGTCP2_RAND_USAGE_PATH_CHALLENGE); if (rv != 0) { return NGTCP2_ERR_CALLBACK_FAILURE; } diff --git a/tests/ngtcp2_conn_test.c b/tests/ngtcp2_conn_test.c index 33f50b34346cc599d6e4ce3a96571f3929891359..f17584568245c305ee1762497aea3cafdad76e9c 100644 --- a/tests/ngtcp2_conn_test.c +++ b/tests/ngtcp2_conn_test.c @@ -341,8 +341,8 @@ static int recv_retry(ngtcp2_conn *conn, const ngtcp2_pkt_hd *hd, return 0; } -static int genrand(uint8_t *dest, size_t destlen, ngtcp2_rand_ctx ctx) { - (void)ctx; +static int genrand(uint8_t *dest, size_t destlen, ngtcp2_rand_usage usage) { + (void)usage; memset(dest, 0, destlen);