From f18bb8544137d9d796902e08b0942d814f8a7474 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Date: Tue, 14 Jul 2020 22:28:06 +0900 Subject: [PATCH] Use struct sockaddr Pass struct sockaddr to ngtcp2 so that it knows how to deal with address change in more detailed manner (e.g., just compare IP address without port). --- examples/client.cc | 19 +- examples/network.h | 8 +- examples/server.cc | 16 +- lib/includes/ngtcp2/ngtcp2.h | 26 +-- lib/ngtcp2_addr.c | 32 ++- lib/ngtcp2_addr.h | 3 +- lib/ngtcp2_conn.c | 4 +- lib/ngtcp2_path.c | 20 +- tests/main.c | 2 + tests/ngtcp2_conn_test.c | 367 ++++++++++++++++++----------------- tests/ngtcp2_conn_test.h | 2 + tests/ngtcp2_pv_test.c | 5 +- tests/ngtcp2_test_helper.c | 20 ++ tests/ngtcp2_test_helper.h | 7 + 14 files changed, 301 insertions(+), 230 deletions(-) diff --git a/examples/client.cc b/examples/client.cc index e01ba6e1..2d5a9180 100644 --- a/examples/client.cc +++ b/examples/client.cc @@ -970,10 +970,8 @@ int Client::init(int fd, const Address &local_addr, const Address &remote_addr, params.active_connection_id_limit = 7; auto path = ngtcp2_path{ - {local_addr.len, const_cast<uint8_t *>( - reinterpret_cast<const uint8_t *>(&local_addr.su))}, - {remote_addr.len, const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>( - &remote_addr.su))}}; + {local_addr.len, const_cast<sockaddr *>(&local_addr.su.sa)}, + {remote_addr.len, const_cast<sockaddr *>(&remote_addr.su.sa)}}; auto rv = ngtcp2_conn_client_new(&conn_, &dcid, &scid, &path, version, &callbacks, &settings, nullptr, this); @@ -1019,9 +1017,9 @@ int Client::init(int fd, const Address &local_addr, const Address &remote_addr, int Client::feed_data(const sockaddr *sa, socklen_t salen, uint8_t *data, size_t datalen) { - auto path = ngtcp2_path{ - {local_addr_.len, reinterpret_cast<uint8_t *>(&local_addr_.su)}, - {salen, const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(sa))}}; + auto path = + ngtcp2_path{{local_addr_.len, const_cast<sockaddr *>(&local_addr_.su.sa)}, + {salen, const_cast<sockaddr *>(sa)}}; if (auto rv = ngtcp2_conn_read_pkt(conn_, &path, data, datalen, util::timestamp(loop_)); rv != 0) { @@ -1398,11 +1396,10 @@ int Client::change_local_addr() { ngtcp2_addr addr; ngtcp2_conn_set_local_addr( conn_, - ngtcp2_addr_init(&addr, &local_addr.su, local_addr.len, nullptr)); + ngtcp2_addr_init(&addr, &local_addr.su.sa, local_addr.len, nullptr)); } else { - auto path = ngtcp2_path{ - {local_addr.len, reinterpret_cast<uint8_t *>(&local_addr.su)}, - {remote_addr.len, reinterpret_cast<uint8_t *>(&remote_addr.su)}}; + auto path = ngtcp2_path{{local_addr.len, &local_addr.su.sa}, + {remote_addr.len, &remote_addr.su.sa}}; if (auto rv = ngtcp2_conn_initiate_migration(conn_, &path, util::timestamp(loop_)); rv != 0) { diff --git a/examples/network.h b/examples/network.h index ba946a03..cfc923ab 100644 --- a/examples/network.h +++ b/examples/network.h @@ -69,13 +69,13 @@ struct Address { struct PathStorage { PathStorage() { - path.local.addr = local_addrbuf.data(); - path.remote.addr = remote_addrbuf.data(); + path.local.addr = reinterpret_cast<sockaddr *>(&local_addrbuf); + path.remote.addr = reinterpret_cast<sockaddr *>(&remote_addrbuf); } ngtcp2_path path; - std::array<uint8_t, sizeof(sockaddr_storage)> local_addrbuf; - std::array<uint8_t, sizeof(sockaddr_storage)> remote_addrbuf; + sockaddr_storage local_addrbuf; + sockaddr_storage remote_addrbuf; }; } // namespace ngtcp2 diff --git a/examples/server.cc b/examples/server.cc index 799133b0..d5cce5be 100644 --- a/examples/server.cc +++ b/examples/server.cc @@ -1595,11 +1595,9 @@ int Handler::init(const Endpoint &ep, const sockaddr *sa, socklen_t salen, params.preferred_address.cid = pscid_; } - auto path = ngtcp2_path{ - {ep.addr.len, - const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(&ep.addr.su)), - const_cast<Endpoint *>(&ep)}, - {salen, const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(sa))}}; + auto path = ngtcp2_path{{ep.addr.len, const_cast<sockaddr *>(&ep.addr.su.sa), + const_cast<Endpoint *>(&ep)}, + {salen, const_cast<sockaddr *>(sa)}}; if (auto rv = ngtcp2_conn_server_new(&conn_, dcid, &scid_, &path, version, &callbacks, &settings, nullptr, this); rv != 0) { @@ -1643,11 +1641,9 @@ void Handler::update_remote_addr(const ngtcp2_addr *addr) { int Handler::feed_data(const Endpoint &ep, const sockaddr *sa, socklen_t salen, uint8_t *data, size_t datalen) { - auto path = ngtcp2_path{ - {ep.addr.len, - const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(&ep.addr.su)), - const_cast<Endpoint *>(&ep)}, - {salen, const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(sa))}}; + auto path = ngtcp2_path{{ep.addr.len, const_cast<sockaddr *>(&ep.addr.su.sa), + const_cast<Endpoint *>(&ep)}, + {salen, const_cast<sockaddr *>(sa)}}; if (auto rv = ngtcp2_conn_read_pkt(conn_, &path, data, datalen, util::timestamp(loop_)); diff --git a/lib/includes/ngtcp2/ngtcp2.h b/lib/includes/ngtcp2/ngtcp2.h index 78aee911..5a9d5995 100644 --- a/lib/includes/ngtcp2/ngtcp2.h +++ b/lib/includes/ngtcp2/ngtcp2.h @@ -46,6 +46,7 @@ extern "C" { # include <inttypes.h> #endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */ #include <sys/types.h> +#include <sys/socket.h> #include <stdarg.h> #include <stddef.h> @@ -767,9 +768,9 @@ typedef struct ngtcp2_settings { typedef struct ngtcp2_addr { /* addrlen is the length of addr. */ size_t addrlen; - /* addr points to the buffer which contains endpoint address. It is - opaque to the ngtcp2 library. It must not be NULL. */ - uint8_t *addr; + /* addr points to the buffer which contains endpoint address. It + must not be NULL. */ + struct sockaddr *addr; /* user_data is an arbitrary data and opaque to the library. */ void *user_data; } ngtcp2_addr; @@ -794,8 +795,8 @@ typedef struct ngtcp2_path { * the longest addresses. */ typedef struct ngtcp2_path_storage { - uint8_t local_addrbuf[128]; - uint8_t remote_addrbuf[128]; + struct sockaddr_storage local_addrbuf; + struct sockaddr_storage remote_addrbuf; ngtcp2_path path; } ngtcp2_path_storage; @@ -3219,7 +3220,8 @@ NGTCP2_EXTERN uint64_t ngtcp2_err_infer_quic_transport_error_code(int liberr); * `ngtcp2_addr_init` initializes |dest| with the given arguments and * returns |dest|. */ -NGTCP2_EXTERN ngtcp2_addr *ngtcp2_addr_init(ngtcp2_addr *dest, const void *addr, +NGTCP2_EXTERN ngtcp2_addr *ngtcp2_addr_init(ngtcp2_addr *dest, + const struct sockaddr *addr, size_t addrlen, void *user_data); /** @@ -3228,11 +3230,13 @@ NGTCP2_EXTERN ngtcp2_addr *ngtcp2_addr_init(ngtcp2_addr *dest, const void *addr, * `ngtcp2_path_storage_init` initializes |ps| with the given * arguments. This function copies |local_addr| and |remote_addr|. */ -NGTCP2_EXTERN void -ngtcp2_path_storage_init(ngtcp2_path_storage *ps, const void *local_addr, - size_t local_addrlen, void *local_user_data, - const void *remote_addr, size_t remote_addrlen, - void *remote_user_data); +NGTCP2_EXTERN void ngtcp2_path_storage_init(ngtcp2_path_storage *ps, + const struct sockaddr *local_addr, + size_t local_addrlen, + void *local_user_data, + const struct sockaddr *remote_addr, + size_t remote_addrlen, + void *remote_user_data); /** * @function diff --git a/lib/ngtcp2_addr.c b/lib/ngtcp2_addr.c index 13a787bd..cf7a4f31 100644 --- a/lib/ngtcp2_addr.c +++ b/lib/ngtcp2_addr.c @@ -25,11 +25,13 @@ #include "ngtcp2_addr.h" #include <string.h> +#include <assert.h> +#include <netinet/ip.h> -ngtcp2_addr *ngtcp2_addr_init(ngtcp2_addr *dest, const void *addr, +ngtcp2_addr *ngtcp2_addr_init(ngtcp2_addr *dest, const struct sockaddr *addr, size_t addrlen, void *user_data) { dest->addrlen = addrlen; - dest->addr = (uint8_t *)addr; + dest->addr = (struct sockaddr *)addr; dest->user_data = user_data; return dest; } @@ -42,7 +44,7 @@ void ngtcp2_addr_copy(ngtcp2_addr *dest, const ngtcp2_addr *src) { dest->user_data = src->user_data; } -void ngtcp2_addr_copy_byte(ngtcp2_addr *dest, const void *addr, +void ngtcp2_addr_copy_byte(ngtcp2_addr *dest, const struct sockaddr *addr, size_t addrlen) { dest->addrlen = addrlen; if (addrlen) { @@ -50,8 +52,30 @@ void ngtcp2_addr_copy_byte(ngtcp2_addr *dest, const void *addr, } } +static int sockaddr_eq(const struct sockaddr *a, const struct sockaddr *b) { + assert(a->sa_family == b->sa_family); + + switch (a->sa_family) { + case AF_INET: { + const struct sockaddr_in *ai = (const struct sockaddr_in *)(void *)a, + *bi = (const struct sockaddr_in *)(void *)b; + return ai->sin_port == bi->sin_port && + memcmp(&ai->sin_addr, &bi->sin_addr, sizeof(ai->sin_addr)) == 0; + } + case AF_INET6: { + const struct sockaddr_in6 *ai = (const struct sockaddr_in6 *)(void *)a, + *bi = (const struct sockaddr_in6 *)(void *)b; + return ai->sin6_port == bi->sin6_port && + memcmp(&ai->sin6_addr, &bi->sin6_addr, sizeof(ai->sin6_addr)) == 0; + } + default: + assert(0); + } +} + int ngtcp2_addr_eq(const ngtcp2_addr *a, const ngtcp2_addr *b) { - return a->addrlen == b->addrlen && memcmp(a->addr, b->addr, a->addrlen) == 0; + return a->addr->sa_family == b->addr->sa_family && + sockaddr_eq(a->addr, b->addr); } int ngtcp2_addr_empty(const ngtcp2_addr *addr) { return addr->addrlen == 0; } diff --git a/lib/ngtcp2_addr.h b/lib/ngtcp2_addr.h index db8b7144..238bb435 100644 --- a/lib/ngtcp2_addr.h +++ b/lib/ngtcp2_addr.h @@ -44,7 +44,8 @@ void ngtcp2_addr_copy(ngtcp2_addr *dest, const ngtcp2_addr *src); * |addrlen|. This function assumes that dest->addr points to a * buffer which have sufficient size to store the copy. */ -void ngtcp2_addr_copy_byte(ngtcp2_addr *dest, const void *addr, size_t addrlen); +void ngtcp2_addr_copy_byte(ngtcp2_addr *dest, const struct sockaddr *addr, + size_t addrlen); /* * ngtcp2_addr_eq returns nonzero if |a| equals |b|. diff --git a/lib/ngtcp2_conn.c b/lib/ngtcp2_conn.c index 5d0c4a6c..6226fc32 100644 --- a/lib/ngtcp2_conn.c +++ b/lib/ngtcp2_conn.c @@ -6204,14 +6204,14 @@ static int conn_recv_new_token(ngtcp2_conn *conn, const ngtcp2_new_token *fr) { * User-defined callback function failed. */ static int conn_select_preferred_addr(ngtcp2_conn *conn) { - uint8_t buf[128]; + struct sockaddr_storage buf; ngtcp2_addr addr; int rv; ngtcp2_duration timeout; ngtcp2_pv *pv; ngtcp2_dcid *dcid; - ngtcp2_addr_init(&addr, buf, 0, NULL); + ngtcp2_addr_init(&addr, (struct sockaddr *)&buf, 0, NULL); if (ngtcp2_ringbuf_len(&conn->dcid.unused) == 0) { return 0; diff --git a/lib/ngtcp2_path.c b/lib/ngtcp2_path.c index ebda947c..3f35f28e 100644 --- a/lib/ngtcp2_path.c +++ b/lib/ngtcp2_path.c @@ -44,12 +44,16 @@ int ngtcp2_path_eq(const ngtcp2_path *a, const ngtcp2_path *b) { ngtcp2_addr_eq(&a->remote, &b->remote); } -void ngtcp2_path_storage_init(ngtcp2_path_storage *ps, const void *local_addr, +void ngtcp2_path_storage_init(ngtcp2_path_storage *ps, + const struct sockaddr *local_addr, size_t local_addrlen, void *local_user_data, - const void *remote_addr, size_t remote_addrlen, - void *remote_user_data) { - ngtcp2_addr_init(&ps->path.local, ps->local_addrbuf, 0, local_user_data); - ngtcp2_addr_init(&ps->path.remote, ps->remote_addrbuf, 0, remote_user_data); + const struct sockaddr *remote_addr, + size_t remote_addrlen, void *remote_user_data) { + ngtcp2_addr_init(&ps->path.local, (const struct sockaddr *)&ps->local_addrbuf, + 0, local_user_data); + ngtcp2_addr_init(&ps->path.remote, + (const struct sockaddr *)&ps->remote_addrbuf, 0, + remote_user_data); ngtcp2_addr_copy_byte(&ps->path.local, local_addr, local_addrlen); ngtcp2_addr_copy_byte(&ps->path.remote, remote_addr, remote_addrlen); @@ -63,6 +67,8 @@ void ngtcp2_path_storage_init2(ngtcp2_path_storage *ps, } void ngtcp2_path_storage_zero(ngtcp2_path_storage *ps) { - ngtcp2_addr_init(&ps->path.local, ps->local_addrbuf, 0, NULL); - ngtcp2_addr_init(&ps->path.remote, ps->remote_addrbuf, 0, NULL); + ngtcp2_addr_init(&ps->path.local, (const struct sockaddr *)&ps->local_addrbuf, + 0, NULL); + ngtcp2_addr_init(&ps->path.remote, + (const struct sockaddr *)&ps->remote_addrbuf, 0, NULL); } diff --git a/tests/main.c b/tests/main.c index e4a2efad..ad203124 100644 --- a/tests/main.c +++ b/tests/main.c @@ -68,6 +68,8 @@ int main() { return (int)CU_get_error(); } + init_static_path(); + /* add the tests to the suite */ if (!CU_add_test(pSuite, "pkt_decode_version_cid", test_ngtcp2_pkt_decode_version_cid) || diff --git a/tests/ngtcp2_conn_test.c b/tests/ngtcp2_conn_test.c index 8c4cea7f..cdedd806 100644 --- a/tests/ngtcp2_conn_test.c +++ b/tests/ngtcp2_conn_test.c @@ -119,10 +119,14 @@ static int get_new_connection_id(ngtcp2_conn *conn, ngtcp2_cid *cid, static uint8_t null_secret[32]; static uint8_t null_iv[16]; static uint8_t null_data[4096]; -static ngtcp2_path null_path = {{1, (uint8_t *)"0", NULL}, - {1, (uint8_t *)"0", NULL}}; -static ngtcp2_path new_path = {{1, (uint8_t *)"1", NULL}, - {1, (uint8_t *)"2", NULL}}; + +static ngtcp2_path_storage null_path; +static ngtcp2_path_storage new_path; + +void init_static_path(void) { + path_init(&null_path, 0, 0, 0, 0); + path_init(&new_path, 1, 0, 2, 0); +} static ngtcp2_vec *null_datav(ngtcp2_vec *datav, size_t len) { datav->base = null_data; @@ -411,8 +415,9 @@ static void setup_default_server(ngtcp2_conn **pconn) { cb.update_key = update_key; server_default_settings(&settings); - ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_rx_handshake_key(*pconn, &aead_ctx, null_iv, sizeof(null_iv), &hp_ctx); ngtcp2_conn_install_tx_handshake_key(*pconn, &aead_ctx, null_iv, @@ -461,8 +466,9 @@ static void setup_default_client(ngtcp2_conn **pconn) { cb.update_key = update_key; client_default_settings(&settings); - ngtcp2_conn_client_new(pconn, &dcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_client_new(pconn, &dcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_rx_handshake_key(*pconn, &aead_ctx, null_iv, sizeof(null_iv), &hp_ctx); ngtcp2_conn_install_tx_handshake_key(*pconn, &aead_ctx, null_iv, @@ -512,8 +518,9 @@ static void setup_handshake_server(ngtcp2_conn **pconn) { cb.rand = genrand; server_default_settings(&settings); - ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_initial_key(*pconn, &aead_ctx, null_iv, &hp_ctx, &aead_ctx, null_iv, &hp_ctx, sizeof(null_iv)); ngtcp2_conn_install_rx_handshake_key(*pconn, &aead_ctx, null_iv, @@ -543,8 +550,9 @@ static void setup_handshake_client(ngtcp2_conn **pconn) { cb.get_new_connection_id = get_new_connection_id; client_default_settings(&settings); - ngtcp2_conn_client_new(pconn, &rcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_client_new(pconn, &rcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_initial_key(*pconn, &aead_ctx, null_iv, &hp_ctx, &aead_ctx, null_iv, &hp_ctx, sizeof(null_iv)); ngtcp2_conn_set_retry_aead(*pconn, &retry_aead, &aead_ctx); @@ -571,8 +579,9 @@ static void setup_early_server(ngtcp2_conn **pconn) { cb.rand = genrand; server_default_settings(&settings); - ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_server_new(pconn, &dcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_initial_key(*pconn, &aead_ctx, null_iv, &hp_ctx, &aead_ctx, null_iv, &hp_ctx, sizeof(null_iv)); ngtcp2_conn_set_aead_overhead(*pconn, NGTCP2_FAKE_AEAD_OVERHEAD); @@ -608,8 +617,9 @@ static void setup_early_client(ngtcp2_conn **pconn) { cb.get_new_connection_id = get_new_connection_id; client_default_settings(&settings); - ngtcp2_conn_client_new(pconn, &rcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_client_new(pconn, &rcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_initial_key(*pconn, &aead_ctx, null_iv, &hp_ctx, &aead_ctx, null_iv, &hp_ctx, sizeof(null_iv)); ngtcp2_conn_set_aead_overhead(*pconn, NGTCP2_FAKE_AEAD_OVERHEAD); @@ -648,7 +658,7 @@ void test_ngtcp2_conn_stream_open_close(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -662,7 +672,7 @@ void test_ngtcp2_conn_stream_open_close(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(NGTCP2_STRM_FLAG_SHUT_RD == strm->flags); @@ -691,7 +701,7 @@ void test_ngtcp2_conn_stream_open_close(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 3, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 3); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 3); CU_ASSERT(0 == rv); @@ -743,7 +753,7 @@ void test_ngtcp2_conn_stream_rx_flow_control(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, (int64_t)i, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -808,7 +818,7 @@ void test_ngtcp2_conn_stream_rx_flow_control_error(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -872,7 +882,7 @@ void test_ngtcp2_conn_stream_tx_flow_control(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 4); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 4); CU_ASSERT(0 == rv); CU_ASSERT(2048 == strm->tx.max_offset); @@ -930,7 +940,7 @@ void test_ngtcp2_conn_rx_flow_control(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -949,7 +959,7 @@ void test_ngtcp2_conn_rx_flow_control(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); @@ -989,7 +999,7 @@ void test_ngtcp2_conn_rx_flow_control_error(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -1051,7 +1061,7 @@ void test_ngtcp2_conn_tx_flow_control(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 5); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 5); CU_ASSERT(0 == rv); CU_ASSERT(3072 == conn->tx.max_offset); @@ -1126,7 +1136,7 @@ void test_ngtcp2_conn_shutdown_stream_write(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 890, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, stream_id)); @@ -1139,7 +1149,7 @@ void test_ngtcp2_conn_shutdown_stream_write(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 899, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, stream_id)); @@ -1160,7 +1170,7 @@ void test_ngtcp2_conn_shutdown_stream_write(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 119, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, stream_id)); @@ -1182,7 +1192,7 @@ void test_ngtcp2_conn_shutdown_stream_write(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 121, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, stream_id)); @@ -1196,7 +1206,7 @@ void test_ngtcp2_conn_shutdown_stream_write(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 332, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 3); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 3); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, stream_id)); @@ -1227,7 +1237,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1240,7 +1250,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 955; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 3); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 3); CU_ASSERT(0 == rv); @@ -1264,7 +1274,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1279,7 +1289,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 955; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 4); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 4); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -1299,7 +1309,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1314,7 +1324,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 955; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 4); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 4); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -1326,7 +1336,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.ack.num_blks = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 3, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 5); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 5); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, 4)); @@ -1346,7 +1356,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1358,7 +1368,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 3); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 3); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -1373,7 +1383,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 955; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 3, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 4); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 4); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -1385,7 +1395,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.ack.num_blks = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 4, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 5); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 5); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, 4)); @@ -1405,7 +1415,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1415,7 +1425,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 954; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(NGTCP2_ERR_FINAL_SIZE == rv); @@ -1435,7 +1445,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1445,7 +1455,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 956; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(NGTCP2_ERR_FINAL_SIZE == rv); @@ -1460,7 +1470,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -1475,7 +1485,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1999; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, 0)); @@ -1493,7 +1503,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_STREAM_LIMIT == rv); @@ -1509,7 +1519,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT( @@ -1531,7 +1541,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1 << 20; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -1550,7 +1560,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1 << 20; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -1573,7 +1583,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1583,7 +1593,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1024 * 1024; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -1604,7 +1614,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1614,7 +1624,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1024 * 1024; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(NGTCP2_ERR_FLOW_CONTROL == rv); @@ -1634,7 +1644,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 0; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_PROTO == rv); @@ -1653,7 +1663,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1663,7 +1673,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 1024; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(128 * 1024 + 1024 == conn->rx.unsent_max_offset); @@ -1684,7 +1694,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.stream.data[0].base = null_data; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1701,7 +1711,7 @@ void test_ngtcp2_conn_recv_reset_stream(void) { fr.reset_stream.final_size = 957; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 4); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 4); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -1737,7 +1747,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -1773,7 +1783,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -1783,7 +1793,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, stream_id)); @@ -1810,7 +1820,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL == ngtcp2_conn_find_stream(conn, stream_id)); @@ -1826,7 +1836,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); @@ -1846,7 +1856,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -1864,7 +1874,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NGTCP2_FRAME_RESET_STREAM == conn->pktns.tx.frq->fr.type); @@ -1880,7 +1890,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -1903,7 +1913,7 @@ void test_ngtcp2_conn_recv_stop_sending(void) { fr.stop_sending.app_error_code = NGTCP2_APP_ERR01; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NULL == conn->pktns.tx.frq); @@ -1935,7 +1945,7 @@ void test_ngtcp2_conn_recv_conn_id_omitted(void) { pktlen = write_single_frame_pkt_without_conn_id(conn, buf, sizeof(buf), 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); /* packet is just ignored */ CU_ASSERT(0 == rv); @@ -1953,7 +1963,7 @@ void test_ngtcp2_conn_recv_conn_id_omitted(void) { pktlen = write_single_frame_pkt_without_conn_id(conn, buf, sizeof(buf), 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -2161,7 +2171,7 @@ void test_ngtcp2_conn_recv_stateless_reset(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, 1); CU_ASSERT(NGTCP2_ERR_DRAINING == rv); CU_ASSERT(NGTCP2_CS_DRAINING == conn->state); @@ -2180,7 +2190,7 @@ void test_ngtcp2_conn_recv_stateless_reset(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, 1); CU_ASSERT(NGTCP2_ERR_DRAINING == rv); CU_ASSERT(NGTCP2_CS_DRAINING == conn->state); @@ -2202,7 +2212,7 @@ void test_ngtcp2_conn_recv_stateless_reset(void) { /* long packet */ buf[0] |= NGTCP2_HEADER_FORM_BIT; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, 1); CU_ASSERT(NGTCP2_ERR_DRAINING == rv); CU_ASSERT(NGTCP2_CS_DRAINING == conn->state); @@ -2230,7 +2240,7 @@ void test_ngtcp2_conn_recv_stateless_reset(void) { /* Make largest CID so that ngtcp2_pkt_decode_hd_long fails */ buf[5] = 0xff; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, 1); CU_ASSERT(NGTCP2_ERR_DRAINING == rv); CU_ASSERT(NGTCP2_CS_DRAINING == conn->state); @@ -2247,7 +2257,7 @@ void test_ngtcp2_conn_recv_stateless_reset(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(NGTCP2_CS_DRAINING != conn->state); @@ -2286,7 +2296,7 @@ void test_ngtcp2_conn_recv_retry(void) { CU_ASSERT(spktlen > 0); for (i = 0; i < 2; ++i) { - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, ++t); CU_ASSERT(0 == rv); @@ -2322,7 +2332,7 @@ void test_ngtcp2_conn_recv_retry(void) { /* Change tag */ buf[spktlen - 1] = 1; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, ++t); CU_ASSERT(0 == rv); @@ -2360,7 +2370,7 @@ void test_ngtcp2_conn_recv_retry(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, ++t); CU_ASSERT(0 == rv); @@ -2405,7 +2415,7 @@ void test_ngtcp2_conn_recv_delayed_handshake_pkt(void) { pktlen = write_single_frame_handshake_pkt( conn, buf, sizeof(buf), NGTCP2_PKT_HANDSHAKE, &conn->oscid, ngtcp2_conn_get_dcid(conn), 1, NGTCP2_PROTO_VER_MAX, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(1 == ngtcp2_ksl_len(&conn->hs_pktns->acktr.ents)); @@ -2426,7 +2436,7 @@ void test_ngtcp2_conn_recv_max_streams(void) { fr.max_streams.max_streams = 999; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 1, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 1); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 1); CU_ASSERT(0 == rv); CU_ASSERT(999 == conn->local.uni.max_streams); @@ -2435,7 +2445,7 @@ void test_ngtcp2_conn_recv_max_streams(void) { fr.max_streams.max_streams = 997; pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, 2, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, 2); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, 2); CU_ASSERT(0 == rv); CU_ASSERT(997 == conn->local.bidi.max_streams); @@ -2467,7 +2477,7 @@ void test_ngtcp2_conn_handshake(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2508,7 +2518,7 @@ void test_ngtcp2_conn_handshake_error(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &conn->oscid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_CRYPTO == rv); @@ -2528,7 +2538,7 @@ void test_ngtcp2_conn_handshake_error(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_CRYPTO == rv); @@ -2548,7 +2558,7 @@ void test_ngtcp2_conn_handshake_error(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, 0xffff, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_DROP_CONN == rv); @@ -2649,7 +2659,7 @@ void test_ngtcp2_conn_send_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2679,7 +2689,7 @@ void test_ngtcp2_conn_send_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2710,7 +2720,7 @@ void test_ngtcp2_conn_send_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2745,7 +2755,7 @@ void test_ngtcp2_conn_send_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2757,7 +2767,7 @@ void test_ngtcp2_conn_send_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -2798,7 +2808,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2818,7 +2828,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2845,7 +2855,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2862,7 +2872,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2890,7 +2900,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2901,7 +2911,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ud.stream_data.stream_id); @@ -2926,7 +2936,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ud.stream_data.stream_id); @@ -2943,7 +2953,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -2969,7 +2979,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ud.stream_data.stream_id); @@ -2986,7 +2996,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -3012,7 +3022,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(3 == ud.stream_data.stream_id); @@ -3039,7 +3049,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_LIMIT == rv); @@ -3064,7 +3074,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -3083,7 +3093,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_CRYPTO == rv); @@ -3101,7 +3111,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -3123,7 +3133,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 4)); @@ -3145,7 +3155,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); ud.stream_data.stream_id = 0; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ud.stream_data.stream_id); @@ -3172,7 +3182,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 0)); @@ -3184,7 +3194,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != ngtcp2_conn_find_stream(conn, 0)); @@ -3202,7 +3212,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); ud.stream_data.stream_id = -1; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(-1 == ud.stream_data.stream_id); @@ -3220,7 +3230,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); ud.stream_data.stream_id = -1; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(-1 == ud.stream_data.stream_id); @@ -3248,7 +3258,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ud.stream_data.stream_id); @@ -3265,7 +3275,7 @@ void test_ngtcp2_conn_recv_stream_data(void) { ++pkt_num, &fr); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -3290,7 +3300,7 @@ void test_ngtcp2_conn_recv_ping(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL == conn->pktns.tx.frq); @@ -3319,7 +3329,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -3336,7 +3346,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -3353,7 +3363,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_LIMIT == rv); @@ -3370,7 +3380,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -3392,7 +3402,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_STREAM_STATE == rv); @@ -3410,7 +3420,7 @@ void test_ngtcp2_conn_recv_max_stream_data(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(1000000009 == strm->tx.max_offset); @@ -3547,7 +3557,7 @@ void test_ngtcp2_conn_recv_early_data(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -3568,7 +3578,7 @@ void test_ngtcp2_conn_recv_early_data(void) { conn->version, &fr, null_iv, sizeof(null_iv)); memset(&ud, 0, sizeof(ud)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(4 == ud.stream_data.stream_id); @@ -3600,7 +3610,7 @@ void test_ngtcp2_conn_recv_early_data(void) { conn, buf, sizeof(buf), &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr, null_iv, sizeof(null_iv)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_RETRY == rv); @@ -3632,7 +3642,7 @@ void test_ngtcp2_conn_recv_early_data(void) { &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr, null_iv, sizeof(null_iv)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -3677,7 +3687,7 @@ void test_ngtcp2_conn_recv_compound_pkt(void) { conn, buf + pktlen, sizeof(buf) - pktlen, NGTCP2_PKT_INITIAL, &conn->oscid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -3718,7 +3728,7 @@ void test_ngtcp2_conn_recv_compound_pkt(void) { pktlen += write_single_frame_pkt(conn, buf + pktlen, sizeof(buf) - pktlen, &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -3769,7 +3779,7 @@ void test_ngtcp2_conn_pkt_payloadlen(void) { /* This first packet which does not increase initial packet number space CRYPTO offset or it does not get buffered as 0RTT is an error. But it is unsecured Initial, so we just ignore it. */ - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_DROP_CONN == rv); CU_ASSERT(NGTCP2_CS_SERVER_INITIAL == conn->state); @@ -3948,7 +3958,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(1 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -3969,7 +3979,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4011,7 +4021,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4037,7 +4047,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4081,7 +4091,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { sizeof(token3)); pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 4); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4101,7 +4111,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4140,7 +4150,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { memcpy(frs[1].new_connection_id.stateless_reset_token, token, sizeof(token)); pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 2); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4160,7 +4170,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(2 == conn->dcid.current.seq); @@ -4199,7 +4209,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { memcpy(frs[1].new_connection_id.stateless_reset_token, token, sizeof(token)); pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 2); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4225,7 +4235,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(3 == conn->dcid.current.seq); @@ -4275,7 +4285,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { sizeof(token3)); pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 3); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_CONNECTION_ID_LIMIT == rv); @@ -4306,7 +4316,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 3); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4326,7 +4336,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL == conn->pv); @@ -4334,7 +4344,7 @@ void test_ngtcp2_conn_recv_new_connection_id(void) { /* Receive NEW_CONNECTION_ID seq=1 again, which should be ignored. */ pktlen = write_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, frs, 2); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(0 == ngtcp2_ringbuf_len(&conn->dcid.unused)); @@ -4378,7 +4388,7 @@ void test_ngtcp2_conn_recv_retire_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NGTCP2_SCID_FLAG_RETIRED == scid->flags); @@ -4422,7 +4432,7 @@ void test_ngtcp2_conn_recv_retire_connection_id(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_PROTO == rv); @@ -4441,12 +4451,12 @@ void test_ngtcp2_conn_server_path_validation(void) { const uint8_t raw_cid[] = {0x0f, 0x00, 0x00, 0x00}; ngtcp2_cid cid, *new_cid; const uint8_t token[NGTCP2_STATELESS_RESET_TOKENLEN] = {0xff}; - ngtcp2_path new_path1 = {{1, (uint8_t *)"0", NULL}, - {1, (uint8_t *)"2", NULL}}; - ngtcp2_path new_path2 = {{1, (uint8_t *)"0", NULL}, - {1, (uint8_t *)"3", NULL}}; + ngtcp2_path_storage new_path1, new_path2; ngtcp2_ksl_it it; + path_init(&new_path1, 0, 0, 2, 0); + path_init(&new_path2, 0, 0, 3, 0); + ngtcp2_cid_init(&cid, raw_cid, sizeof(raw_cid)); setup_default_server(&conn); @@ -4466,7 +4476,7 @@ void test_ngtcp2_conn_server_path_validation(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4475,7 +4485,7 @@ void test_ngtcp2_conn_server_path_validation(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path1, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path1.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != conn->pv); @@ -4491,10 +4501,10 @@ void test_ngtcp2_conn_server_path_validation(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path1, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path1.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); - CU_ASSERT(ngtcp2_path_eq(&new_path1, &conn->dcid.current.ps.path)); + CU_ASSERT(ngtcp2_path_eq(&new_path1.path, &conn->dcid.current.ps.path)); /* DCID does not change because the client does not change its DCID. */ CU_ASSERT(!ngtcp2_cid_eq(&cid, &conn->dcid.current.cid)); @@ -4511,7 +4521,7 @@ void test_ngtcp2_conn_server_path_validation(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), new_cid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path2, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path2.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != conn->pv); @@ -4527,10 +4537,10 @@ void test_ngtcp2_conn_server_path_validation(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), new_cid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path2, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path2.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); - CU_ASSERT(ngtcp2_path_eq(&new_path2, &conn->dcid.current.ps.path)); + CU_ASSERT(ngtcp2_path_eq(&new_path2.path, &conn->dcid.current.ps.path)); CU_ASSERT(ngtcp2_cid_eq(&cid, &conn->dcid.current.cid)); ngtcp2_conn_del(conn); @@ -4561,15 +4571,15 @@ void test_ngtcp2_conn_client_connection_migration(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); - rv = ngtcp2_conn_initiate_migration(conn, &new_path, ++t); + rv = ngtcp2_conn_initiate_migration(conn, &new_path.path, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL == conn->pv); - CU_ASSERT(ngtcp2_path_eq(&new_path, &conn->dcid.current.ps.path)); + CU_ASSERT(ngtcp2_path_eq(&new_path.path, &conn->dcid.current.ps.path)); CU_ASSERT(ngtcp2_cid_eq(&cid, &conn->dcid.current.cid)); ngtcp2_conn_del(conn); @@ -4603,7 +4613,7 @@ void test_ngtcp2_conn_recv_path_challenge(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4613,7 +4623,7 @@ void test_ngtcp2_conn_recv_path_challenge(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &new_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &new_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(ngtcp2_ringbuf_len(&conn->rx.path_challenge) > 0); @@ -4650,7 +4660,7 @@ void test_ngtcp2_conn_key_update(void) { NGTCP2_PKT_FLAG_KEY_PHASE, &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(NULL != conn->crypto.key_update.old_rx_ckm); @@ -4674,7 +4684,7 @@ void test_ngtcp2_conn_key_update(void) { NGTCP2_PKT_FLAG_KEY_PHASE, &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(t == conn->crypto.key_update.confirmed_ts); @@ -4721,7 +4731,7 @@ void test_ngtcp2_conn_key_update(void) { NGTCP2_PKT_FLAG_KEY_PHASE, &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(t == conn->crypto.key_update.confirmed_ts); @@ -4750,7 +4760,7 @@ void test_ngtcp2_conn_crypto_buffer_exceeded(void) { pktlen = write_single_frame_pkt(conn, buf, sizeof(buf), &conn->oscid, ++pkt_num, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_CRYPTO_BUFFER_EXCEEDED == rv); @@ -4799,7 +4809,7 @@ void test_ngtcp2_conn_handshake_probe(void) { pktlen = write_single_frame_handshake_pkt( conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &conn->oscid, ngtcp2_conn_get_dcid(conn), 0, NGTCP2_PROTO_VER_MAX, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(1 == conn->in_pktns->rtb.num_ack_eliciting); @@ -4897,7 +4907,7 @@ void test_ngtcp2_conn_handshake_loss(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, cfr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -4957,7 +4967,7 @@ void test_ngtcp2_conn_handshake_loss(void) { ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); t += 8; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, t); CU_ASSERT(0 == rv); @@ -4999,7 +5009,7 @@ void test_ngtcp2_conn_handshake_loss(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, cfr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); @@ -5065,7 +5075,7 @@ void test_ngtcp2_conn_handshake_loss(void) { ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); t += 8; - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, t); CU_ASSERT(0 == rv); @@ -5121,7 +5131,7 @@ void test_ngtcp2_conn_recv_client_initial_retry(void) { conn, buf, sizeof(buf), NGTCP2_PKT_INITIAL, &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_RETRY == rv); @@ -5162,7 +5172,7 @@ void test_ngtcp2_conn_recv_client_initial_token(void) { conn, buf, sizeof(buf), &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr, raw_token, sizeof(raw_token)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(0 == rv); CU_ASSERT(45 == ngtcp2_strm_rx_offset(&conn->in_pktns->crypto.strm)); @@ -5189,7 +5199,7 @@ void test_ngtcp2_conn_recv_client_initial_token(void) { conn, buf, sizeof(buf), &rcid, ngtcp2_conn_get_dcid(conn), ++pkt_num, conn->version, &fr, raw_token, sizeof(raw_token)); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, pktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, pktlen, ++t); CU_ASSERT(NGTCP2_ERR_DROP_CONN == rv); CU_ASSERT(0 == ngtcp2_strm_rx_offset(&conn->in_pktns->crypto.strm)); @@ -5211,7 +5221,7 @@ void test_ngtcp2_conn_get_active_dcid(void) { CU_ASSERT(1 == ngtcp2_conn_get_active_dcid(conn, cid_token)); CU_ASSERT(0 == cid_token[0].seq); CU_ASSERT(ngtcp2_cid_eq(&dcid, &cid_token[0].cid)); - CU_ASSERT(ngtcp2_path_eq(&null_path, &cid_token[0].ps.path)); + CU_ASSERT(ngtcp2_path_eq(&null_path.path, &cid_token[0].ps.path)); CU_ASSERT(1 == cid_token[0].token_present); CU_ASSERT(0 == memcmp(token, cid_token[0].token, NGTCP2_STATELESS_RESET_TOKENLEN)); @@ -5244,7 +5254,7 @@ void test_ngtcp2_conn_recv_version_negotiation(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, ++t); CU_ASSERT(NGTCP2_ERR_RECV_VERSION_NEGOTIATION == rv); @@ -5269,7 +5279,7 @@ void test_ngtcp2_conn_recv_version_negotiation(void) { CU_ASSERT(spktlen > 0); - rv = ngtcp2_conn_read_pkt(conn, &null_path, buf, (size_t)spktlen, ++t); + rv = ngtcp2_conn_read_pkt(conn, &null_path.path, buf, (size_t)spktlen, ++t); CU_ASSERT(0 == rv); @@ -5305,8 +5315,9 @@ void test_ngtcp2_conn_send_initial_token(void) { settings.token.base = token; settings.token.len = sizeof(token); - ngtcp2_conn_client_new(&conn, &rcid, &scid, &null_path, NGTCP2_PROTO_VER_MAX, - &cb, &settings, /* mem = */ NULL, NULL); + ngtcp2_conn_client_new(&conn, &rcid, &scid, &null_path.path, + NGTCP2_PROTO_VER_MAX, &cb, &settings, /* mem = */ NULL, + NULL); ngtcp2_conn_install_initial_key(conn, &aead_ctx, null_iv, &hp_ctx, &aead_ctx, null_iv, &hp_ctx, sizeof(null_iv)); ngtcp2_conn_set_retry_aead(conn, &retry_aead, &aead_ctx); diff --git a/tests/ngtcp2_conn_test.h b/tests/ngtcp2_conn_test.h index f57bda44..1034056c 100644 --- a/tests/ngtcp2_conn_test.h +++ b/tests/ngtcp2_conn_test.h @@ -29,6 +29,8 @@ # include <config.h> #endif /* HAVE_CONFIG_H */ +void init_static_path(void); + void test_ngtcp2_conn_stream_open_close(void); void test_ngtcp2_conn_stream_rx_flow_control(void); void test_ngtcp2_conn_stream_rx_flow_control_error(void); diff --git a/tests/ngtcp2_pv_test.c b/tests/ngtcp2_pv_test.c index 6018c393..77c8150f 100644 --- a/tests/ngtcp2_pv_test.c +++ b/tests/ngtcp2_pv_test.c @@ -91,11 +91,12 @@ void test_ngtcp2_pv_validate(void) { uint8_t data[8]; ngtcp2_duration timeout = 100ULL * NGTCP2_SECONDS; ngtcp2_tstamp t = 1; - ngtcp2_path path = {{1, (uint8_t *)"1", NULL}, {1, (uint8_t *)"2", NULL}}; + ngtcp2_path_storage path; + path_init(&path, 1, 0, 2, 0); dcid_init(&cid); ngtcp2_dcid_init(&dcid, 1000000007, &cid, token); - ngtcp2_path_copy(&dcid.ps.path, &path); + ngtcp2_path_copy(&dcid.ps.path, &path.path); ngtcp2_log_init(&log, NULL, NULL, 0, NULL); rv = ngtcp2_pv_new(&pv, &dcid, timeout, NGTCP2_PV_FLAG_NONE, &log, mem); diff --git a/tests/ngtcp2_test_helper.c b/tests/ngtcp2_test_helper.c index 87f14c39..3115a853 100644 --- a/tests/ngtcp2_test_helper.c +++ b/tests/ngtcp2_test_helper.c @@ -519,3 +519,23 @@ ngtcp2_ssize pkt_decode_hd_short_mask(ngtcp2_pkt_hd *dest, const uint8_t *pkt, return nread + (ngtcp2_ssize)dest->pkt_numlen; } + +static void addr_init(struct sockaddr_in *dest, uint32_t addr, uint16_t port) { + memset(dest, 0, sizeof(*dest)); + + dest->sin_family = AF_INET; + dest->sin_port = port; + dest->sin_addr.s_addr = addr; +} + +void path_init(ngtcp2_path_storage *path, uint32_t local_addr, + uint16_t local_port, uint32_t remote_addr, + uint16_t remote_port) { + struct sockaddr_in la, ra; + + addr_init(&la, local_addr, local_port); + addr_init(&ra, remote_addr, remote_port); + + ngtcp2_path_storage_init(path, (struct sockaddr *)&la, sizeof(la), NULL, + (struct sockaddr *)&ra, sizeof(ra), NULL); +} diff --git a/tests/ngtcp2_test_helper.h b/tests/ngtcp2_test_helper.h index f283cbe2..1615bded 100644 --- a/tests/ngtcp2_test_helper.h +++ b/tests/ngtcp2_test_helper.h @@ -228,4 +228,11 @@ ngtcp2_ssize pkt_decode_hd_short(ngtcp2_pkt_hd *dest, const uint8_t *pkt, ngtcp2_ssize pkt_decode_hd_short_mask(ngtcp2_pkt_hd *dest, const uint8_t *pkt, size_t pktlen, size_t dcidlen); +/* + * path_init initializes |path| with the given arguments. They form + * IPv4 addresses. + */ +void path_init(ngtcp2_path_storage *path, uint32_t local_addr, + uint16_t local_port, uint32_t remote_addr, uint16_t remote_port); + #endif /* NGTCP2_TEST_HELPER_H */ -- GitLab