Skip to content

Commit 9311dc5

Browse files
committed
deps: update ngtcp2
PR-URL: nodejs#276 Reviewed-By: Anna Henningsen <[email protected]>
1 parent c3dcb22 commit 9311dc5

File tree

7 files changed

+436
-54
lines changed

7 files changed

+436
-54
lines changed

deps/ngtcp2/lib/includes/ngtcp2/ngtcp2.h

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ typedef struct ngtcp2_vec {
345345
*
346346
* `ngtcp2_cid_init` initializes Connection ID |cid| with the byte
347347
* string pointed by |data| and its length is |datalen|. |datalen|
348-
* must be at least :enum:`NGTCP2_MIN_CDLEN`, and at most
349-
* :enum:`NGTCP2_MAX_CDLEN`.
348+
* must be at least :enum:`NGTCP2_MIN_CIDLEN`, and at most
349+
* :enum:`NGTCP2_MAX_CIDLEN`.
350350
*/
351351
NGTCP2_EXTERN void ngtcp2_cid_init(ngtcp2_cid *cid, const uint8_t *data,
352352
size_t datalen);
@@ -1403,6 +1403,37 @@ typedef int (*ngtcp2_select_preferred_addr)(ngtcp2_conn *conn,
14031403
const ngtcp2_preferred_addr *paddr,
14041404
void *user_data);
14051405

1406+
typedef enum ngtcp2_connection_id_status_type {
1407+
/* NGTCP2_CONNECTION_ID_STATUS_TYPE_ACTIVATE indicates that a local
1408+
endpoint starts using new destination Connection ID. */
1409+
NGTCP2_CONNECTION_ID_STATUS_TYPE_ACTIVATE,
1410+
/* NGTCP2_CONNECTION_ID_STATUS_TYPE_DEACTIVATE indicates that a
1411+
local endpoint stops using a given destination Connection ID. */
1412+
NGTCP2_CONNECTION_ID_STATUS_TYPE_DEACTIVATE
1413+
} ngtcp2_connection_id_status_type;
1414+
1415+
/**
1416+
* @functypedef
1417+
*
1418+
* :type:`ngtcp2_connection_id_status` is a callback function which is
1419+
* called when the status of Connection ID changes.
1420+
*
1421+
* |token| is the associated stateless reset token and it is NULL if
1422+
* no token is present.
1423+
*
1424+
* |type| is the one of the value defined in
1425+
* :enum:`ngtcp2_connection_id_status_type`. The new value might be
1426+
* added in the future release.
1427+
*
1428+
* The callback function must return 0 if it succeeds. Returning
1429+
* :enum:`NGTCP2_ERR_CALLBACK_FAILURE` makes the library call return
1430+
* immediately.
1431+
*/
1432+
typedef int (*ngtcp2_connection_id_status)(ngtcp2_conn *conn, int type,
1433+
uint64_t seq, const ngtcp2_cid *cid,
1434+
const uint8_t *token,
1435+
void *user_data);
1436+
14061437
typedef struct ngtcp2_conn_callbacks {
14071438
/**
14081439
* client_initial is a callback function which is invoked when
@@ -1571,6 +1602,12 @@ typedef struct ngtcp2_conn_callbacks {
15711602
* is increased. This callback function is optional.
15721603
*/
15731604
ngtcp2_extend_max_stream_data extend_max_stream_data;
1605+
/**
1606+
* dcid_status is a callback function which is invoked when the new
1607+
* destination Connection ID is activated or the activated
1608+
* destination Connection ID is now deactivated.
1609+
*/
1610+
ngtcp2_connection_id_status dcid_status;
15741611
} ngtcp2_conn_callbacks;
15751612

15761613
/*
@@ -2350,6 +2387,45 @@ NGTCP2_EXTERN size_t ngtcp2_conn_get_num_scid(ngtcp2_conn *conn);
23502387
*/
23512388
NGTCP2_EXTERN size_t ngtcp2_conn_get_scid(ngtcp2_conn *conn, ngtcp2_cid *dest);
23522389

2390+
/**
2391+
* @function
2392+
*
2393+
* `ngtcp2_conn_get_num_active_dcid` returns the number of the active
2394+
* destination connection ID.
2395+
*/
2396+
NGTCP2_EXTERN size_t ngtcp2_conn_get_num_active_dcid(ngtcp2_conn *conn);
2397+
2398+
/**
2399+
* @struct
2400+
*
2401+
* :type:`ngtcp2_cid_token` is the convenient struct to store
2402+
* Connection ID, its associated path, and stateless reset token.
2403+
*/
2404+
typedef struct ngtcp2_cid_token {
2405+
/* seq is the sequence number of this Connection ID. */
2406+
uint64_t seq;
2407+
/* cid is Connection ID. */
2408+
ngtcp2_cid cid;
2409+
/* ps is the path which is associated to this Connection ID. */
2410+
ngtcp2_path_storage ps;
2411+
/* token is the stateless reset token for this Connection ID. */
2412+
uint8_t token[NGTCP2_STATELESS_RESET_TOKENLEN];
2413+
/* token_resent is nonzero if token contains stateless reset
2414+
token. */
2415+
uint8_t token_present;
2416+
} ngtcp2_cid_token;
2417+
2418+
/**
2419+
* @function
2420+
*
2421+
* `ngtcp2_conn_get_active_dcid` writes the all active destination
2422+
* connection IDs and tokens to |dest|. The buffer pointed by |dest|
2423+
* must have ``sizeof(ngtcp2_cid_token) * n`` bytes available, where n
2424+
* is the return value of `ngtcp2_conn_get_num_active_dcid()`.
2425+
*/
2426+
NGTCP2_EXTERN size_t ngtcp2_conn_get_active_dcid(ngtcp2_conn *conn,
2427+
ngtcp2_cid_token *dest);
2428+
23532429
/**
23542430
* @function
23552431
*

deps/ngtcp2/lib/ngtcp2_cid.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ void ngtcp2_dcid_copy(ngtcp2_dcid *dest, const ngtcp2_dcid *src) {
9595
dest->ts_retired = src->ts_retired;
9696
}
9797

98+
void ngtcp2_dcid_copy_no_path(ngtcp2_dcid *dest, const ngtcp2_dcid *src) {
99+
dest->seq = src->seq;
100+
dest->cid = src->cid;
101+
memcpy(dest->token, src->token, NGTCP2_STATELESS_RESET_TOKENLEN);
102+
103+
dest->ts_retired = src->ts_retired;
104+
}
105+
98106
int ngtcp2_dcid_verify_uniqueness(ngtcp2_dcid *dcid, uint64_t seq,
99107
const ngtcp2_cid *cid, const uint8_t *token) {
100108

deps/ngtcp2/lib/ngtcp2_cid.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ void ngtcp2_dcid_init(ngtcp2_dcid *dcid, uint64_t seq, const ngtcp2_cid *cid,
125125
*/
126126
void ngtcp2_dcid_copy(ngtcp2_dcid *dest, const ngtcp2_dcid *src);
127127

128+
/*
129+
* ngtcp2_dcid_copy_no_path behaves like ngtcp2_dcid_copy, but it does
130+
* not copy path.
131+
*/
132+
void ngtcp2_dcid_copy_no_path(ngtcp2_dcid *dest, const ngtcp2_dcid *src);
133+
128134
/*
129135
* ngtcp2_dcid_verify_uniqueness verifies uniqueness of (|seq|, |cid|,
130136
* |token|) tuple against |dcid|.

0 commit comments

Comments
 (0)