@@ -345,8 +345,8 @@ typedef struct ngtcp2_vec {
345
345
*
346
346
* `ngtcp2_cid_init` initializes Connection ID |cid| with the byte
347
347
* 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 `.
350
350
*/
351
351
NGTCP2_EXTERN void ngtcp2_cid_init (ngtcp2_cid *cid, const uint8_t *data,
352
352
size_t datalen);
@@ -1403,6 +1403,37 @@ typedef int (*ngtcp2_select_preferred_addr)(ngtcp2_conn *conn,
1403
1403
const ngtcp2_preferred_addr *paddr,
1404
1404
void *user_data);
1405
1405
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
+
1406
1437
typedef struct ngtcp2_conn_callbacks {
1407
1438
/* *
1408
1439
* client_initial is a callback function which is invoked when
@@ -1571,6 +1602,12 @@ typedef struct ngtcp2_conn_callbacks {
1571
1602
* is increased. This callback function is optional.
1572
1603
*/
1573
1604
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;
1574
1611
} ngtcp2_conn_callbacks;
1575
1612
1576
1613
/*
@@ -2350,6 +2387,45 @@ NGTCP2_EXTERN size_t ngtcp2_conn_get_num_scid(ngtcp2_conn *conn);
2350
2387
*/
2351
2388
NGTCP2_EXTERN size_t ngtcp2_conn_get_scid (ngtcp2_conn *conn, ngtcp2_cid *dest);
2352
2389
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
+
2353
2429
/* *
2354
2430
* @function
2355
2431
*
0 commit comments