◐ Shell
clean mode source ↗

src: cleanup quic TransportParams class · nodejs/node@c9d4a44

@@ -1704,7 +1704,8 @@ typedef enum ngtcp2_token_type {

1704170417051705

#define NGTCP2_SETTINGS_V1 1

17061706

#define NGTCP2_SETTINGS_V2 2

1707-

#define NGTCP2_SETTINGS_VERSION NGTCP2_SETTINGS_V2

1707+

#define NGTCP2_SETTINGS_V3 3

1708+

#define NGTCP2_SETTINGS_VERSION NGTCP2_SETTINGS_V3

1708170917091710

/**

17101711

* @struct

@@ -1917,6 +1918,23 @@ typedef struct ngtcp2_settings {

19171918

* field has been available since v1.4.0.

19181919

*/

19191920

size_t pmtud_probeslen;

1921+

/* The following fields have been added since NGTCP2_SETTINGS_V3. */

1922+

/**

1923+

* :member:`glitch_ratelim_burst` is the maximum number of tokens

1924+

* available to "glitch" rate limiter. "glitch" is a suspicious

1925+

* activity from a remote endpoint. If detected, certain amount of

1926+

* tokens are consumed. If no tokens are available to consume, the

1927+

* connection is closed. The rate of token generation is specified

1928+

* by :member:`glitch_ratelim_rate`. This field has been available

1929+

* since v1.15.0.

1930+

*/

1931+

uint64_t glitch_ratelim_burst;

1932+

/**

1933+

* :member:`glitch_ratelim_rate` is the number of tokens generated

1934+

* per second. See :member:`glitch_ratelim_burst` for "glitch" rate

1935+

* limiter. This field has been available since v1.15.0.

1936+

*/

1937+

uint64_t glitch_ratelim_rate;

19201938

} ngtcp2_settings;

1921193919221940

/**

@@ -3000,9 +3018,8 @@ typedef int (*ngtcp2_begin_path_validation)(ngtcp2_conn *conn, uint32_t flags,

30003018

* an application the outcome of path validation. |flags| is zero or

30013019

* more of :macro:`NGTCP2_PATH_VALIDATION_FLAG_*

30023020

* <NGTCP2_PATH_VALIDATION_FLAG_NONE>`. |path| is the path that was

3003-

* validated. |old_path| is the path that is previously used before a

3004-

* local endpoint has migrated to |path| if |old_path| is not NULL.

3005-

* If |res| is

3021+

* validated. |fallback_path|, if not NULL, is the path that is used

3022+

* if the path validation failed. If |res| is

30063023

* :enum:`ngtcp2_path_validation_result.NGTCP2_PATH_VALIDATION_RESULT_SUCCESS`,

30073024

* the path validation succeeded. If |res| is

30083025

* :enum:`ngtcp2_path_validation_result.NGTCP2_PATH_VALIDATION_RESULT_FAILURE`,

@@ -3014,7 +3031,7 @@ typedef int (*ngtcp2_begin_path_validation)(ngtcp2_conn *conn, uint32_t flags,

30143031

*/

30153032

typedef int (*ngtcp2_path_validation)(ngtcp2_conn *conn, uint32_t flags,

30163033

const ngtcp2_path *path,

3017-

const ngtcp2_path *old_path,

3034+

const ngtcp2_path *fallback_path,

30183035

ngtcp2_path_validation_result res,

30193036

void *user_data);

30203037

@@ -5598,6 +5615,77 @@ NGTCP2_EXTERN size_t ngtcp2_conn_get_send_quantum(ngtcp2_conn *conn);

55985615

NGTCP2_EXTERN size_t ngtcp2_conn_get_stream_loss_count(ngtcp2_conn *conn,

55995616

int64_t stream_id);

560056175618+

/**

5619+

* @functypedef

5620+

*

5621+

* :type:`ngtcp2_write_pkt` is a callback function to write a single

5622+

* packet in the buffer pointed by |dest| of length |destlen|. The

5623+

* implementation should use `ngtcp2_conn_write_pkt`,

5624+

* `ngtcp2_conn_writev_stream`, `ngtcp2_conn_writev_datagram`, or

5625+

* their variants to write the packet. |path|, |pi|, |dest|,

5626+

* |destlen|, and |ts| should be directly passed to those functions.

5627+

* If the callback succeeds, it should return the number of bytes

5628+

* written to the buffer. In general, this callback function should

5629+

* return the value that the above mentioned functions returned except

5630+

* for the following error codes:

5631+

*

5632+

* - :macro:`NGTCP2_ERR_STREAM_DATA_BLOCKED`

5633+

* - :macro:`NGTCP2_ERR_STREAM_SHUT_WR`

5634+

* - :macro:`NGTCP2_ERR_STREAM_NOT_FOUND`

5635+

*

5636+

* Those error codes should be handled by an application. If any

5637+

* error occurred outside those functions, return

5638+

* :macro:`NGTCP2_ERR_CALLBACK_FAILURE`. If no packet is produced,

5639+

* return 0.

5640+

*

5641+

* Because GSO requires that the aggregated packets have the same

5642+

* length, :macro:`NGTCP2_WRITE_STREAM_FLAG_PADDING` (or

5643+

* :macro:`NGTCP2_WRITE_DATAGRAM_FLAG_PADDING` if

5644+

* `ngtcp2_conn_writev_datagram` is used) is recommended.

5645+

*

5646+

* This callback function has been available since v1.15.0.

5647+

*/

5648+

typedef ngtcp2_ssize (*ngtcp2_write_pkt)(ngtcp2_conn *conn, ngtcp2_path *path,

5649+

ngtcp2_pkt_info *pi, uint8_t *dest,

5650+

size_t destlen, ngtcp2_tstamp ts,

5651+

void *user_data);

5652+5653+

/**

5654+

* @function

5655+

*

5656+

* `ngtcp2_conn_write_aggregate_pkt` is a helper function to write

5657+

* multiple packets in the provided buffer, which is suitable to be

5658+

* sent at once in GSO. This function returns the number of bytes

5659+

* written to the buffer pointed by |buf| of length |buflen|.

5660+

* |buflen| must be at least

5661+

* `ngtcp2_conn_get_path_max_tx_udp_payload_size(conn)

5662+

* <ngtcp2_conn_get_path_max_tx_udp_payload_size>` bytes long. It is

5663+

* recommended to pass the buffer at least

5664+

* `ngtcp2_conn_get_max_tx_udp_payload_size(conn)

5665+

* <ngtcp2_conn_get_max_tx_udp_payload_size>` bytes in order to send a

5666+

* PMTUD packet. This function only writes multiple packets if the

5667+

* first packet is `ngtcp2_conn_get_path_max_tx_udp_payload_size(conn)

5668+

* <ngtcp2_conn_get_path_max_tx_udp_payload_size>` bytes long. The

5669+

* application can adjust the length of the buffer to limit the number

5670+

* of packets to aggregate. If this function returns positive

5671+

* integer, all packets share the same :type:`ngtcp2_path` and

5672+

* :type:`ngtcp2_pkt_info` values, and they are assigned to the

5673+

* objects pointed by |path| and |pi| respectively. The length of all

5674+

* packets other than the last packet is assigned to |*pgsolen|. The

5675+

* length of last packet is equal to or less than |*pgsolen|.

5676+

* |write_pkt| must write a single packet. After all packets are

5677+

* written, this function calls `ngtcp2_conn_update_pkt_tx_time`.

5678+

*

5679+

* This function returns the number of bytes written to the buffer, or

5680+

* a negative error code returned by |write_pkt|.

5681+

*

5682+

* This function has been available since v1.15.0.

5683+

*/

5684+

NGTCP2_EXTERN ngtcp2_ssize ngtcp2_conn_write_aggregate_pkt_versioned(

5685+

ngtcp2_conn *conn, ngtcp2_path *path, int pkt_info_version,

5686+

ngtcp2_pkt_info *pi, uint8_t *buf, size_t buflen, size_t *pgsolen,

5687+

ngtcp2_write_pkt write_pkt, ngtcp2_tstamp ts);

5688+56015689

/**

56025690

* @function

56035691

*

@@ -5680,15 +5768,19 @@ NGTCP2_EXTERN void ngtcp2_path_storage_zero(ngtcp2_path_storage *ps);

56805768

* values. First this function fills |settings| with 0, and set the

56815769

* default value to the following fields:

56825770

*

5683-

* * :type:`cc_algo <ngtcp2_settings.cc_algo>` =

5771+

* * :member:`cc_algo <ngtcp2_settings.cc_algo>` =

56845772

* :enum:`ngtcp2_cc_algo.NGTCP2_CC_ALGO_CUBIC`

5685-

* * :type:`initial_rtt <ngtcp2_settings.initial_rtt>` =

5773+

* * :member:`initial_rtt <ngtcp2_settings.initial_rtt>` =

56865774

* :macro:`NGTCP2_DEFAULT_INITIAL_RTT`

5687-

* * :type:`ack_thresh <ngtcp2_settings.ack_thresh>` = 2

5688-

* * :type:`max_tx_udp_payload_size

5775+

* * :member:`ack_thresh <ngtcp2_settings.ack_thresh>` = 2

5776+

* * :member:`max_tx_udp_payload_size

56895777

* <ngtcp2_settings.max_tx_udp_payload_size>` = 1452

5690-

* * :type:`handshake_timeout <ngtcp2_settings.handshake_timeout>` =

5778+

* * :member:`handshake_timeout <ngtcp2_settings.handshake_timeout>` =

56915779

* ``UINT64_MAX``

5780+

* * :member:`glitch_ratelim_burst

5781+

* <ngtcp2_settings.glitch_ratelim_burst>` = 1000

5782+

* * :member:`glitch_ratelim_rate

5783+

* <ngtcp2_settings.glitch_ratelim_rate>` = 33

56925784

*/

56935785

NGTCP2_EXTERN void ngtcp2_settings_default_versioned(int settings_version,

56945786

ngtcp2_settings *settings);

@@ -5700,15 +5792,15 @@ NGTCP2_EXTERN void ngtcp2_settings_default_versioned(int settings_version,

57005792

* default values. First this function fills |params| with 0, and set

57015793

* the default value to the following fields:

57025794

*

5703-

* * :type:`max_udp_payload_size

5795+

* * :member:`max_udp_payload_size

57045796

* <ngtcp2_transport_params.max_udp_payload_size>` =

57055797

* :macro:`NGTCP2_DEFAULT_MAX_RECV_UDP_PAYLOAD_SIZE`

5706-

* * :type:`ack_delay_exponent

5798+

* * :member:`ack_delay_exponent

57075799

* <ngtcp2_transport_params.ack_delay_exponent>` =

57085800

* :macro:`NGTCP2_DEFAULT_ACK_DELAY_EXPONENT`

5709-

* * :type:`max_ack_delay <ngtcp2_transport_params.max_ack_delay>` =

5801+

* * :member:`max_ack_delay <ngtcp2_transport_params.max_ack_delay>` =

57105802

* :macro:`NGTCP2_DEFAULT_MAX_ACK_DELAY`

5711-

* * :type:`active_connection_id_limit

5803+

* * :member:`active_connection_id_limit

57125804

* <ngtcp2_transport_params.active_connection_id_limit>` =

57135805

* :macro:`NGTCP2_DEFAULT_ACTIVE_CONNECTION_ID_LIMIT`

57145806

*/

@@ -5980,6 +6072,17 @@ NGTCP2_EXTERN uint32_t ngtcp2_select_version(const uint32_t *preferred_versions,

59806072

#define ngtcp2_conn_get_conn_info(CONN, CINFO) \

59816073

ngtcp2_conn_get_conn_info_versioned((CONN), NGTCP2_CONN_INFO_VERSION, (CINFO))

598260746075+

/*

6076+

* `ngtcp2_conn_write_aggregate_pkt` is a wrapper around

6077+

* `ngtcp2_conn_write_aggregate_pkt_versioned` to set the correct

6078+

* struct version.

6079+

*/

6080+

#define ngtcp2_conn_write_aggregate_pkt(CONN, PATH, PI, BUF, BUFLEN, PGSOLEN, \

6081+

WRITE_PKT, TS) \

6082+

ngtcp2_conn_write_aggregate_pkt_versioned( \

6083+

(CONN), (PATH), NGTCP2_PKT_INFO_VERSION, (PI), (BUF), (BUFLEN), (PGSOLEN), \

6084+

(WRITE_PKT), (TS))

6085+59836086

/*

59846087

* `ngtcp2_settings_default` is a wrapper around

59856088

* `ngtcp2_settings_default_versioned` to set the correct struct