1 /* 2 * ngtcp2 3 * 4 * Copyright (c) 2017 ngtcp2 contributors 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be 15 * included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 #ifndef NGTCP2_CONN_H 26 #define NGTCP2_CONN_H 27 28 #ifdef HAVE_CONFIG_H 29 # include <config.h> 30 #endif /* HAVE_CONFIG_H */ 31 32 #include <ngtcp2/ngtcp2.h> 33 34 #include "ngtcp2_mem.h" 35 #include "ngtcp2_crypto.h" 36 #include "ngtcp2_acktr.h" 37 #include "ngtcp2_rtb.h" 38 #include "ngtcp2_strm.h" 39 #include "ngtcp2_idtr.h" 40 #include "ngtcp2_str.h" 41 #include "ngtcp2_pkt.h" 42 #include "ngtcp2_log.h" 43 #include "ngtcp2_pq.h" 44 #include "ngtcp2_cc.h" 45 #include "ngtcp2_bbr.h" 46 #include "ngtcp2_bbr2.h" 47 #include "ngtcp2_pv.h" 48 #include "ngtcp2_pmtud.h" 49 #include "ngtcp2_cid.h" 50 #include "ngtcp2_buf.h" 51 #include "ngtcp2_ppe.h" 52 #include "ngtcp2_qlog.h" 53 #include "ngtcp2_rst.h" 54 55 typedef enum { 56 /* Client specific handshake states */ 57 NGTCP2_CS_CLIENT_INITIAL, 58 NGTCP2_CS_CLIENT_WAIT_HANDSHAKE, 59 NGTCP2_CS_CLIENT_TLS_HANDSHAKE_FAILED, 60 /* Server specific handshake states */ 61 NGTCP2_CS_SERVER_INITIAL, 62 NGTCP2_CS_SERVER_WAIT_HANDSHAKE, 63 NGTCP2_CS_SERVER_TLS_HANDSHAKE_FAILED, 64 /* Shared by both client and server */ 65 NGTCP2_CS_POST_HANDSHAKE, 66 NGTCP2_CS_CLOSING, 67 NGTCP2_CS_DRAINING, 68 } ngtcp2_conn_state; 69 70 /* NGTCP2_MAX_STREAMS is the maximum number of streams. */ 71 #define NGTCP2_MAX_STREAMS (1LL << 60) 72 73 /* NGTCP2_MAX_NUM_BUFFED_RX_PKTS is the maximum number of buffered 74 reordered packets. */ 75 #define NGTCP2_MAX_NUM_BUFFED_RX_PKTS 4 76 77 /* NGTCP2_MAX_REORDERED_CRYPTO_DATA is the maximum offset of crypto 78 data which is not continuous. In other words, there is a gap of 79 unreceived data. */ 80 #define NGTCP2_MAX_REORDERED_CRYPTO_DATA 65536 81 82 /* NGTCP2_MAX_RX_INITIAL_CRYPTO_DATA is the maximum offset of received 83 crypto stream in Initial packet. We set this hard limit here 84 because crypto stream is unbounded. */ 85 #define NGTCP2_MAX_RX_INITIAL_CRYPTO_DATA 65536 86 /* NGTCP2_MAX_RX_HANDSHAKE_CRYPTO_DATA is the maximum offset of 87 received crypto stream in Handshake packet. We set this hard limit 88 here because crypto stream is unbounded. */ 89 #define NGTCP2_MAX_RX_HANDSHAKE_CRYPTO_DATA 65536 90 91 /* NGTCP2_MAX_RETRIES is the number of Retry packet which client can 92 accept. */ 93 #define NGTCP2_MAX_RETRIES 3 94 95 /* NGTCP2_MAX_BOUND_DCID_POOL_SIZE is the maximum number of 96 destination connection ID which have been bound to a particular 97 path, but not yet used as primary path and path validation is not 98 performed from the local endpoint. */ 99 #define NGTCP2_MAX_BOUND_DCID_POOL_SIZE 4 100 /* NGTCP2_MAX_DCID_POOL_SIZE is the maximum number of destination 101 connection ID the remote endpoint provides to store. It must be 102 the power of 2. */ 103 #define NGTCP2_MAX_DCID_POOL_SIZE 8 104 /* NGTCP2_MAX_DCID_RETIRED_SIZE is the maximum number of retired DCID 105 kept to catch in-flight packet on retired path. */ 106 #define NGTCP2_MAX_DCID_RETIRED_SIZE 2 107 /* NGTCP2_MAX_SCID_POOL_SIZE is the maximum number of source 108 connection ID the local endpoint provides to the remote endpoint. 109 The chosen value was described in old draft. Now a remote endpoint 110 tells the maximum value. The value can be quite large, and we have 111 to put the sane limit.*/ 112 #define NGTCP2_MAX_SCID_POOL_SIZE 8 113 114 /* NGTCP2_MAX_NON_ACK_TX_PKT is the maximum number of continuous non 115 ACK-eliciting packets. */ 116 #define NGTCP2_MAX_NON_ACK_TX_PKT 3 117 118 /* NGTCP2_ECN_MAX_NUM_VALIDATION_PKTS is the maximum number of ECN marked 119 packets sent in NGTCP2_ECN_STATE_TESTING period. */ 120 #define NGTCP2_ECN_MAX_NUM_VALIDATION_PKTS 10 121 122 /* NGTCP2_CONNECTION_CLOSE_ERROR_MAX_REASONLEN is the maximum length 123 of reason phrase to remember. If the received reason phrase is 124 longer than this value, it is truncated. */ 125 #define NGTCP2_CONNECTION_CLOSE_ERROR_MAX_REASONLEN 1024 126 127 /* NGTCP2_WRITE_PKT_FLAG_NONE indicates that no flag is set. */ 128 #define NGTCP2_WRITE_PKT_FLAG_NONE 0x00u 129 /* NGTCP2_WRITE_PKT_FLAG_REQUIRE_PADDING indicates that packet other 130 than Initial packet should be padded. Initial packet might be 131 padded based on QUIC requirement regardless of this flag. */ 132 #define NGTCP2_WRITE_PKT_FLAG_REQUIRE_PADDING 0x01u 133 /* NGTCP2_WRITE_PKT_FLAG_MORE indicates that more frames might come 134 and it should be encoded into the current packet. */ 135 #define NGTCP2_WRITE_PKT_FLAG_MORE 0x02u 136 137 /* 138 * ngtcp2_max_frame is defined so that it covers the largest ACK 139 * frame. 140 */ 141 typedef union ngtcp2_max_frame { 142 ngtcp2_frame fr; 143 struct { 144 ngtcp2_ack ack; 145 /* ack includes 1 ngtcp2_ack_blk. */ 146 ngtcp2_ack_blk blks[NGTCP2_MAX_ACK_BLKS - 1]; 147 } ackfr; 148 } ngtcp2_max_frame; 149 150 typedef struct ngtcp2_path_challenge_entry { 151 ngtcp2_path_storage ps; 152 uint8_t data[8]; 153 } ngtcp2_path_challenge_entry; 154 155 void ngtcp2_path_challenge_entry_init(ngtcp2_path_challenge_entry *pcent, 156 const ngtcp2_path *path, 157 const uint8_t *data); 158 159 /* NGTCP2_CONN_FLAG_NONE indicates that no flag is set. */ 160 #define NGTCP2_CONN_FLAG_NONE 0x00u 161 /* NGTCP2_CONN_FLAG_HANDSHAKE_COMPLETED is set when TLS stack declares 162 that TLS handshake has completed. The condition of this 163 declaration varies between TLS implementations and this flag does 164 not indicate the completion of QUIC handshake. Some 165 implementations declare TLS handshake completion as server when 166 they write off Server Finished and before deriving application rx 167 secret. */ 168 #define NGTCP2_CONN_FLAG_HANDSHAKE_COMPLETED 0x01u 169 /* NGTCP2_CONN_FLAG_CONN_ID_NEGOTIATED is set if connection ID is 170 negotiated. This is only used for client. */ 171 #define NGTCP2_CONN_FLAG_CONN_ID_NEGOTIATED 0x02u 172 /* NGTCP2_CONN_FLAG_TRANSPORT_PARAM_RECVED is set if transport 173 parameters are received. */ 174 #define NGTCP2_CONN_FLAG_TRANSPORT_PARAM_RECVED 0x04u 175 /* NGTCP2_CONN_FLAG_LOCAL_TRANSPORT_PARAMS_COMMITTED is set when a 176 local transport parameters are applied. */ 177 #define NGTCP2_CONN_FLAG_LOCAL_TRANSPORT_PARAMS_COMMITTED 0x08u 178 /* NGTCP2_CONN_FLAG_RECV_RETRY is set when a client receives Retry 179 packet. */ 180 #define NGTCP2_CONN_FLAG_RECV_RETRY 0x10u 181 /* NGTCP2_CONN_FLAG_EARLY_DATA_REJECTED is set when 0-RTT packet is 182 rejected by a peer. */ 183 #define NGTCP2_CONN_FLAG_EARLY_DATA_REJECTED 0x20u 184 /* NGTCP2_CONN_FLAG_KEEP_ALIVE_CANCELLED is set when the expired 185 keep-alive timer has been cancelled. */ 186 #define NGTCP2_CONN_FLAG_KEEP_ALIVE_CANCELLED 0x40u 187 /* NGTCP2_CONN_FLAG_HANDSHAKE_CONFIRMED is set when an endpoint 188 confirmed completion of handshake. */ 189 #define NGTCP2_CONN_FLAG_HANDSHAKE_CONFIRMED 0x80u 190 /* NGTCP2_CONN_FLAG_HANDSHAKE_COMPLETED_HANDLED is set when the 191 library transitions its state to "post handshake". */ 192 #define NGTCP2_CONN_FLAG_HANDSHAKE_COMPLETED_HANDLED 0x0100u 193 /* NGTCP2_CONN_FLAG_HANDSHAKE_EARLY_RETRANSMIT is set when the early 194 handshake retransmission has done when server receives overlapping 195 Initial crypto data. */ 196 #define NGTCP2_CONN_FLAG_HANDSHAKE_EARLY_RETRANSMIT 0x0200u 197 /* NGTCP2_CONN_FLAG_CLEAR_FIXED_BIT indicates that the local endpoint 198 sends a QUIC packet without Fixed Bit set if a remote endpoint 199 supports Greasing QUIC Bit extension. */ 200 #define NGTCP2_CONN_FLAG_CLEAR_FIXED_BIT 0x0400u 201 /* NGTCP2_CONN_FLAG_KEY_UPDATE_NOT_CONFIRMED is set when key update is 202 not confirmed by the local endpoint. That is, it has not received 203 ACK frame which acknowledges packet which is encrypted with new 204 key. */ 205 #define NGTCP2_CONN_FLAG_KEY_UPDATE_NOT_CONFIRMED 0x0800u 206 /* NGTCP2_CONN_FLAG_PPE_PENDING is set when 207 NGTCP2_WRITE_STREAM_FLAG_MORE is used and the intermediate state of 208 ngtcp2_ppe is stored in pkt struct of ngtcp2_conn. */ 209 #define NGTCP2_CONN_FLAG_PPE_PENDING 0x1000u 210 /* NGTCP2_CONN_FLAG_RESTART_IDLE_TIMER_ON_WRITE is set when idle timer 211 should be restarted on next write. */ 212 #define NGTCP2_CONN_FLAG_RESTART_IDLE_TIMER_ON_WRITE 0x2000u 213 /* NGTCP2_CONN_FLAG_SERVER_ADDR_VERIFIED indicates that server as peer 214 verified client address. This flag is only used by client. */ 215 #define NGTCP2_CONN_FLAG_SERVER_ADDR_VERIFIED 0x4000u 216 /* NGTCP2_CONN_FLAG_EARLY_KEY_INSTALLED indicates that an early key is 217 installed. conn->early.ckm cannot be used for this purpose because 218 it might be discarded when a certain condition is met. */ 219 #define NGTCP2_CONN_FLAG_EARLY_KEY_INSTALLED 0x8000u 220 /* NGTCP2_CONN_FLAG_KEY_UPDATE_INITIATOR is set when the local 221 endpoint has initiated key update. */ 222 #define NGTCP2_CONN_FLAG_KEY_UPDATE_INITIATOR 0x10000u 223 224 typedef struct ngtcp2_crypto_data { 225 ngtcp2_buf buf; 226 /* pkt_type is the type of packet to send data in buf. If it is 0, 227 it must be sent in Short packet. Otherwise, it is sent the long 228 packet type denoted by pkt_type. */ 229 uint8_t pkt_type; 230 } ngtcp2_crypto_data; 231 232 typedef struct ngtcp2_pktns { 233 struct { 234 /* last_pkt_num is the packet number which the local endpoint sent 235 last time.*/ 236 int64_t last_pkt_num; 237 ngtcp2_frame_chain *frq; 238 /* num_non_ack_pkt is the number of continuous non ACK-eliciting 239 packets. */ 240 size_t num_non_ack_pkt; 241 242 struct { 243 /* ect0 is the number of QUIC packets, not UDP datagram, which 244 are sent in UDP datagram with ECT0 marking. */ 245 size_t ect0; 246 /* start_pkt_num is the lowest packet number that are sent 247 during ECN validation period. */ 248 int64_t start_pkt_num; 249 /* validation_pkt_sent is the number of QUIC packets sent during 250 validation period. */ 251 size_t validation_pkt_sent; 252 /* validation_pkt_lost is the number of QUIC packets lost during 253 validation period. */ 254 size_t validation_pkt_lost; 255 } ecn; 256 } tx; 257 258 struct { 259 /* pngap tracks received packet number in order to suppress 260 duplicated packet number. */ 261 ngtcp2_gaptr pngap; 262 /* max_pkt_num is the largest packet number received so far. */ 263 int64_t max_pkt_num; 264 /* max_pkt_ts is the timestamp when max_pkt_num packet is 265 received. */ 266 ngtcp2_tstamp max_pkt_ts; 267 /* max_ack_eliciting_pkt_num is the largest ack-eliciting packet 268 number received so far. */ 269 int64_t max_ack_eliciting_pkt_num; 270 /* 271 * buffed_pkts is buffered packets which cannot be decrypted with 272 * the current encryption level. 273 * 274 * In server Initial encryption level, 0-RTT packet may be buffered. 275 * In server Handshake encryption level, Short packet may be buffered. 276 * 277 * In client Initial encryption level, Handshake or Short packet may 278 * be buffered. In client Handshake encryption level, Short packet 279 * may be buffered. 280 * 281 * - 0-RTT packet is only buffered in server Initial encryption 282 * level ngtcp2_pktns. 283 * 284 * - Handshake packet is only buffered in client Handshake 285 * encryption level ngtcp2_pktns. 286 * 287 * - Short packet is only buffered in Short encryption level 288 * ngtcp2_pktns. 289 */ 290 ngtcp2_pkt_chain *buffed_pkts; 291 292 struct { 293 /* ect0, ect1, and ce are the number of QUIC packets received 294 with those markings. */ 295 size_t ect0; 296 size_t ect1; 297 size_t ce; 298 struct { 299 /* ect0, ect1, ce are the ECN counts received in the latest 300 ACK frame. */ 301 uint64_t ect0; 302 uint64_t ect1; 303 uint64_t ce; 304 } ack; 305 } ecn; 306 } rx; 307 308 struct { 309 struct { 310 /* frq contains crypto data sorted by their offset. */ 311 ngtcp2_ksl frq; 312 /* offset is the offset of crypto stream in this packet number 313 space. */ 314 uint64_t offset; 315 /* ckm is a cryptographic key, and iv to encrypt outgoing 316 packets. */ 317 ngtcp2_crypto_km *ckm; 318 /* hp_ctx is cipher context for packet header protection. */ 319 ngtcp2_crypto_cipher_ctx hp_ctx; 320 /* data is the submitted crypto data. */ 321 ngtcp2_buf_chain *data; 322 } tx; 323 324 struct { 325 /* ckm is a cryptographic key, and iv to decrypt incoming 326 packets. */ 327 ngtcp2_crypto_km *ckm; 328 /* hp_ctx is cipher context for packet header protection. */ 329 ngtcp2_crypto_cipher_ctx hp_ctx; 330 } rx; 331 332 ngtcp2_strm strm; 333 ngtcp2_crypto_ctx ctx; 334 } crypto; 335 336 ngtcp2_acktr acktr; 337 ngtcp2_rtb rtb; 338 } ngtcp2_pktns; 339 340 typedef enum ngtcp2_ecn_state { 341 NGTCP2_ECN_STATE_TESTING, 342 NGTCP2_ECN_STATE_UNKNOWN, 343 NGTCP2_ECN_STATE_FAILED, 344 NGTCP2_ECN_STATE_CAPABLE, 345 } ngtcp2_ecn_state; 346 347 ngtcp2_static_ringbuf_def(dcid_bound, NGTCP2_MAX_BOUND_DCID_POOL_SIZE, 348 sizeof(ngtcp2_dcid)); 349 ngtcp2_static_ringbuf_def(dcid_unused, NGTCP2_MAX_DCID_POOL_SIZE, 350 sizeof(ngtcp2_dcid)); 351 ngtcp2_static_ringbuf_def(dcid_retired, NGTCP2_MAX_DCID_RETIRED_SIZE, 352 sizeof(ngtcp2_dcid)); 353 ngtcp2_static_ringbuf_def(path_challenge, 4, 354 sizeof(ngtcp2_path_challenge_entry)); 355 356 ngtcp2_objalloc_def(strm, ngtcp2_strm, oplent); 357 358 struct ngtcp2_conn { 359 ngtcp2_objalloc frc_objalloc; 360 ngtcp2_objalloc rtb_entry_objalloc; 361 ngtcp2_objalloc strm_objalloc; 362 ngtcp2_conn_state state; 363 ngtcp2_callbacks callbacks; 364 /* rcid is a connection ID present in Initial or 0-RTT packet from 365 client as destination connection ID. Server uses this field to 366 check that duplicated Initial or 0-RTT packet are indeed sent to 367 this connection. Client uses this field to validate 368 original_destination_connection_id transport parameter. */ 369 ngtcp2_cid rcid; 370 /* oscid is the source connection ID initially used by the local 371 endpoint. */ 372 ngtcp2_cid oscid; 373 /* retry_scid is the source connection ID from Retry packet. Client 374 records it in order to verify retry_source_connection_id 375 transport parameter. Server does not use this field. */ 376 ngtcp2_cid retry_scid; 377 ngtcp2_pktns *in_pktns; 378 ngtcp2_pktns *hs_pktns; 379 ngtcp2_pktns pktns; 380 381 struct { 382 /* current is the current destination connection ID. */ 383 ngtcp2_dcid current; 384 /* bound is a set of destination connection IDs which are bound to 385 particular paths. These paths are not validated yet. */ 386 ngtcp2_static_ringbuf_dcid_bound bound; 387 /* unused is a set of unused CID received from peer. */ 388 ngtcp2_static_ringbuf_dcid_unused unused; 389 /* retired is a set of CID retired by local endpoint. Keep them 390 in 3*PTO to catch packets in flight along the old path. */ 391 ngtcp2_static_ringbuf_dcid_retired retired; 392 /* seqgap tracks received sequence numbers in order to ignore 393 retransmitted duplicated NEW_CONNECTION_ID frame. */ 394 ngtcp2_gaptr seqgap; 395 /* retire_prior_to is the largest retire_prior_to received so 396 far. */ 397 uint64_t retire_prior_to; 398 struct { 399 /* seqs contains sequence number of Connection ID whose 400 retirement is not acknowledged by the remote endpoint yet. */ 401 uint64_t seqs[NGTCP2_MAX_DCID_POOL_SIZE * 2]; 402 /* len is the number of sequence numbers that seq contains. */ 403 size_t len; 404 } retire_unacked; 405 /* zerolen_seq is a pseudo sequence number of zero-length 406 Destination Connection ID in order to distinguish between 407 them. */ 408 uint64_t zerolen_seq; 409 } dcid; 410 411 struct { 412 /* set is a set of CID sent to peer. The peer can use any CIDs in 413 this set. This includes used CID as well as unused ones. */ 414 ngtcp2_ksl set; 415 /* used is a set of CID used by peer. The sort function of this 416 priority queue takes timestamp when CID is retired and sorts 417 them in ascending order. */ 418 ngtcp2_pq used; 419 /* last_seq is the last sequence number of connection ID. */ 420 uint64_t last_seq; 421 /* num_retired is the number of retired Connection ID still 422 included in set. */ 423 size_t num_retired; 424 } scid; 425 426 struct { 427 /* strmq contains ngtcp2_strm which has frames to send. */ 428 ngtcp2_pq strmq; 429 /* strmq_nretrans is the number of entries in strmq which has 430 stream data to resent. */ 431 size_t strmq_nretrans; 432 /* ack is ACK frame. The underlying buffer is reused. */ 433 ngtcp2_frame *ack; 434 /* max_ack_blks is the number of additional ngtcp2_ack_blk which 435 ack can contain. */ 436 size_t max_ack_blks; 437 /* offset is the offset the local endpoint has sent to the remote 438 endpoint. */ 439 uint64_t offset; 440 /* max_offset is the maximum offset that local endpoint can 441 send. */ 442 uint64_t max_offset; 443 /* last_max_data_ts is the timestamp when last MAX_DATA frame is 444 sent. */ 445 ngtcp2_tstamp last_max_data_ts; 446 447 struct { 448 /* state is the state of ECN validation */ 449 ngtcp2_ecn_state state; 450 /* validation_start_ts is the timestamp when ECN validation is 451 started. It is UINT64_MAX if it has not started yet. */ 452 ngtcp2_tstamp validation_start_ts; 453 /* dgram_sent is the number of UDP datagram sent during ECN 454 validation period. */ 455 size_t dgram_sent; 456 } ecn; 457 458 struct { 459 /* pktlen is the number of bytes written before calling 460 ngtcp2_conn_update_pkt_tx_time which resets this field to 461 0. */ 462 size_t pktlen; 463 /* next_ts is the time to send next packet. It is UINT64_MAX if 464 packet pacing is disabled or expired.*/ 465 ngtcp2_tstamp next_ts; 466 } pacing; 467 } tx; 468 469 struct { 470 /* unsent_max_offset is the maximum offset that remote endpoint 471 can send without extending MAX_DATA. This limit is not yet 472 notified to the remote endpoint. */ 473 uint64_t unsent_max_offset; 474 /* offset is the cumulative sum of stream data received for this 475 connection. */ 476 uint64_t offset; 477 /* max_offset is the maximum offset that remote endpoint can 478 send. */ 479 uint64_t max_offset; 480 /* window is the connection-level flow control window size. */ 481 uint64_t window; 482 /* path_challenge stores received PATH_CHALLENGE data. */ 483 ngtcp2_static_ringbuf_path_challenge path_challenge; 484 /* ccerr is the received connection close error. */ 485 ngtcp2_connection_close_error ccerr; 486 } rx; 487 488 struct { 489 ngtcp2_crypto_km *ckm; 490 ngtcp2_crypto_cipher_ctx hp_ctx; 491 ngtcp2_crypto_ctx ctx; 492 /* discard_started_ts is the timestamp when the timer to discard 493 early key has started. Used by server only. */ 494 ngtcp2_tstamp discard_started_ts; 495 /* transport_params is the values remembered by client from the 496 previous session. These are set by 497 ngtcp2_conn_set_early_remote_transport_params(). Server does 498 not use this field. Server must not set values for these 499 parameters that are smaller than the remembered values. */ 500 struct { 501 uint64_t initial_max_streams_bidi; 502 uint64_t initial_max_streams_uni; 503 uint64_t initial_max_stream_data_bidi_local; 504 uint64_t initial_max_stream_data_bidi_remote; 505 uint64_t initial_max_stream_data_uni; 506 uint64_t initial_max_data; 507 uint64_t active_connection_id_limit; 508 uint64_t max_datagram_frame_size; 509 } transport_params; 510 } early; 511 512 struct { 513 ngtcp2_settings settings; 514 /* transport_params is the local transport parameters. It is used 515 for Short packet only. */ 516 ngtcp2_transport_params transport_params; 517 struct { 518 /* max_streams is the maximum number of bidirectional streams which 519 the local endpoint can open. */ 520 uint64_t max_streams; 521 /* next_stream_id is the bidirectional stream ID which the local 522 endpoint opens next. */ 523 int64_t next_stream_id; 524 } bidi; 525 526 struct { 527 /* max_streams is the maximum number of unidirectional streams 528 which the local endpoint can open. */ 529 uint64_t max_streams; 530 /* next_stream_id is the unidirectional stream ID which the 531 local endpoint opens next. */ 532 int64_t next_stream_id; 533 } uni; 534 } local; 535 536 struct { 537 /* transport_params is the received transport parameters during 538 handshake. It is used for Short packet only. */ 539 ngtcp2_transport_params *transport_params; 540 /* pending_transport_params is received transport parameters 541 during handshake. It is copied to transport_params when 1RTT 542 key is available. */ 543 ngtcp2_transport_params *pending_transport_params; 544 struct { 545 ngtcp2_idtr idtr; 546 /* unsent_max_streams is the maximum number of streams of peer 547 initiated bidirectional stream which the local endpoint can 548 accept. This limit is not yet notified to the remote 549 endpoint. */ 550 uint64_t unsent_max_streams; 551 /* max_streams is the maximum number of streams of peer 552 initiated bidirectional stream which the local endpoint can 553 accept. */ 554 uint64_t max_streams; 555 } bidi; 556 557 struct { 558 ngtcp2_idtr idtr; 559 /* unsent_max_streams is the maximum number of streams of peer 560 initiated unidirectional stream which the local endpoint can 561 accept. This limit is not yet notified to the remote 562 endpoint. */ 563 uint64_t unsent_max_streams; 564 /* max_streams is the maximum number of streams of peer 565 initiated unidirectional stream which the local endpoint can 566 accept. */ 567 uint64_t max_streams; 568 } uni; 569 } remote; 570 571 struct { 572 struct { 573 /* new_tx_ckm is a new sender 1RTT key which has not been 574 used. */ 575 ngtcp2_crypto_km *new_tx_ckm; 576 /* new_rx_ckm is a new receiver 1RTT key which has not 577 successfully decrypted incoming packet yet. */ 578 ngtcp2_crypto_km *new_rx_ckm; 579 /* old_rx_ckm is an old receiver 1RTT key. */ 580 ngtcp2_crypto_km *old_rx_ckm; 581 /* confirmed_ts is the time instant when the key update is 582 confirmed by the local endpoint last time. UINT64_MAX means 583 undefined value. */ 584 ngtcp2_tstamp confirmed_ts; 585 } key_update; 586 587 /* tls_native_handle is a native handle to TLS session object. */ 588 void *tls_native_handle; 589 /* decrypt_hp_buf is a buffer which is used to write unprotected 590 packet header. */ 591 ngtcp2_vec decrypt_hp_buf; 592 /* decrypt_buf is a buffer which is used to write decrypted data. */ 593 ngtcp2_vec decrypt_buf; 594 /* retry_aead is AEAD to verify Retry packet integrity. It is 595 used by client only. */ 596 ngtcp2_crypto_aead retry_aead; 597 /* retry_aead_ctx is AEAD cipher context to verify Retry packet 598 integrity. It is used by client only. */ 599 ngtcp2_crypto_aead_ctx retry_aead_ctx; 600 /* tls_error is TLS related error. */ 601 int tls_error; 602 /* tls_alert is TLS alert generated by the local endpoint. */ 603 uint8_t tls_alert; 604 /* decryption_failure_count is the number of received packets that 605 fail authentication. */ 606 uint64_t decryption_failure_count; 607 } crypto; 608 609 /* pkt contains the packet intermediate construction data to support 610 NGTCP2_WRITE_STREAM_FLAG_MORE */ 611 struct { 612 ngtcp2_crypto_cc cc; 613 ngtcp2_pkt_hd hd; 614 ngtcp2_ppe ppe; 615 ngtcp2_frame_chain **pfrc; 616 int pkt_empty; 617 int hd_logged; 618 /* flags is bitwise OR of zero or more of 619 NGTCP2_RTB_ENTRY_FLAG_*. */ 620 uint16_t rtb_entry_flags; 621 ngtcp2_ssize hs_spktlen; 622 int require_padding; 623 } pkt; 624 625 struct { 626 /* last_ts is a timestamp when a last packet is sent or received 627 on a current path. */ 628 ngtcp2_tstamp last_ts; 629 /* timeout is keep-alive timeout. When it expires, a packet 630 should be sent to a current path to keep connection alive. It 631 might be used to keep NAT binding intact. If 0 is set, 632 keep-alive timer is disabled. */ 633 ngtcp2_duration timeout; 634 } keep_alive; 635 636 struct { 637 /* Initial keys for negotiated version. If original version == 638 negotiated version, these fields are not used. */ 639 struct { 640 ngtcp2_crypto_km *ckm; 641 ngtcp2_crypto_cipher_ctx hp_ctx; 642 } rx; 643 struct { 644 ngtcp2_crypto_km *ckm; 645 ngtcp2_crypto_cipher_ctx hp_ctx; 646 } tx; 647 /* version is QUIC version that the above Initial keys are created 648 for. */ 649 uint32_t version; 650 /* preferred_versions is the array of versions that are preferred 651 by the local endpoint. Server negotiates one of those versions 652 in this array if a client initially selects a less preferred 653 version. Client uses this field and original_version field to 654 prevent version downgrade attack if it reacted upon Version 655 Negotiation packet. */ 656 uint32_t *preferred_versions; 657 /* preferred_versionslen is the number of versions stored in the 658 array pointed by preferred_versions. This field is only used 659 by server. */ 660 size_t preferred_versionslen; 661 /* other_versions is the versions that the local endpoint sends in 662 version_information transport parameter. This is the wire 663 image of other_versions field of version_information transport 664 parameter. */ 665 uint8_t *other_versions; 666 /* other_versionslen is the length of data pointed by 667 other_versions field. */ 668 size_t other_versionslen; 669 } vneg; 670 671 ngtcp2_map strms; 672 ngtcp2_conn_stat cstat; 673 ngtcp2_pv *pv; 674 ngtcp2_pmtud *pmtud; 675 ngtcp2_log log; 676 ngtcp2_qlog qlog; 677 ngtcp2_rst rst; 678 ngtcp2_cc_algo cc_algo; 679 ngtcp2_cc cc; 680 const ngtcp2_mem *mem; 681 /* idle_ts is the time instant when idle timer started. */ 682 ngtcp2_tstamp idle_ts; 683 void *user_data; 684 uint32_t client_chosen_version; 685 uint32_t negotiated_version; 686 /* flags is bitwise OR of zero or more of NGTCP2_CONN_FLAG_*. */ 687 uint32_t flags; 688 int server; 689 }; 690 691 typedef enum ngtcp2_vmsg_type { 692 NGTCP2_VMSG_TYPE_STREAM, 693 NGTCP2_VMSG_TYPE_DATAGRAM, 694 } ngtcp2_vmsg_type; 695 696 typedef struct ngtcp2_vmsg_stream { 697 /* strm is a stream that data is sent to. */ 698 ngtcp2_strm *strm; 699 /* flags is bitwise OR of zero or more of 700 NGTCP2_WRITE_STREAM_FLAG_*. */ 701 uint32_t flags; 702 /* data is the pointer to ngtcp2_vec array which contains the stream 703 data to send. */ 704 const ngtcp2_vec *data; 705 /* datacnt is the number of ngtcp2_vec pointed by data. */ 706 size_t datacnt; 707 /* pdatalen is the pointer to the variable which the number of bytes 708 written is assigned to if pdatalen is not NULL. */ 709 ngtcp2_ssize *pdatalen; 710 } ngtcp2_vmsg_stream; 711 712 typedef struct ngtcp2_vmsg_datagram { 713 /* data is the pointer to ngtcp2_vec array which contains the data 714 to send. */ 715 const ngtcp2_vec *data; 716 /* datacnt is the number of ngtcp2_vec pointed by data. */ 717 size_t datacnt; 718 /* dgram_id is an opaque identifier chosen by an application. */ 719 uint64_t dgram_id; 720 /* flags is bitwise OR of zero or more of 721 NGTCP2_WRITE_DATAGRAM_FLAG_*. */ 722 uint32_t flags; 723 /* paccepted is the pointer to the variable which, if it is not 724 NULL, is assigned nonzero if data is written to a packet. */ 725 int *paccepted; 726 } ngtcp2_vmsg_datagram; 727 728 typedef struct ngtcp2_vmsg { 729 ngtcp2_vmsg_type type; 730 union { 731 ngtcp2_vmsg_stream stream; 732 ngtcp2_vmsg_datagram datagram; 733 }; 734 } ngtcp2_vmsg; 735 736 /* 737 * ngtcp2_conn_sched_ack stores packet number |pkt_num| and its 738 * reception timestamp |ts| in order to send its ACK. 739 * 740 * It returns 0 if it succeeds, or one of the following negative error 741 * codes: 742 * 743 * NGTCP2_ERR_NOMEM 744 * Out of memory 745 * NGTCP2_ERR_PROTO 746 * Same packet number has already been added. 747 */ 748 int ngtcp2_conn_sched_ack(ngtcp2_conn *conn, ngtcp2_acktr *acktr, 749 int64_t pkt_num, int active_ack, ngtcp2_tstamp ts); 750 751 /* 752 * ngtcp2_conn_find_stream returns a stream whose stream ID is 753 * |stream_id|. If no such stream is found, it returns NULL. 754 */ 755 ngtcp2_strm *ngtcp2_conn_find_stream(ngtcp2_conn *conn, int64_t stream_id); 756 757 /* 758 * conn_init_stream initializes |strm|. Its stream ID is |stream_id|. 759 * This function adds |strm| to conn->strms. |strm| must be allocated 760 * by the caller. 761 * 762 * This function returns 0 if it succeeds, or one of the following 763 * negative error codes: 764 * 765 * NGTCP2_ERR_NOMEM 766 * Out of memory 767 * NGTCP2_ERR_CALLBACK_FAILURE 768 * User-callback function failed. 769 */ 770 int ngtcp2_conn_init_stream(ngtcp2_conn *conn, ngtcp2_strm *strm, 771 int64_t stream_id, void *stream_user_data); 772 773 /* 774 * ngtcp2_conn_close_stream closes stream |strm|. 775 * 776 * This function returns 0 if it succeeds, or one of the following 777 * negative error codes: 778 * 779 * NGTCP2_ERR_INVALID_ARGUMENT 780 * Stream is not found. 781 * NGTCP2_ERR_CALLBACK_FAILURE 782 * User-defined callback function failed. 783 */ 784 int ngtcp2_conn_close_stream(ngtcp2_conn *conn, ngtcp2_strm *strm); 785 786 /* 787 * ngtcp2_conn_close_stream closes stream |strm| if no further 788 * transmission and reception are allowed, and all reordered incoming 789 * data are emitted to the application, and the transmitted data are 790 * acked. 791 * 792 * This function returns 0 if it succeeds, or one of the following 793 * negative error codes: 794 * 795 * NGTCP2_ERR_INVALID_ARGUMENT 796 * Stream is not found. 797 * NGTCP2_ERR_CALLBACK_FAILURE 798 * User-defined callback function failed. 799 */ 800 int ngtcp2_conn_close_stream_if_shut_rdwr(ngtcp2_conn *conn, ngtcp2_strm *strm); 801 802 /* 803 * ngtcp2_conn_update_rtt updates RTT measurements. |rtt| is a latest 804 * RTT which is not adjusted by ack delay. |ack_delay| is unscaled 805 * ack_delay included in ACK frame. |ack_delay| is actually tainted 806 * (sent by peer), so don't assume that |ack_delay| is always smaller 807 * than, or equals to |rtt|. 808 * 809 * This function returns 0 if it succeeds, or one of the following 810 * negative error codes: 811 * 812 * NGTCP2_ERR_INVALID_ARGUMENT 813 * RTT sample is ignored. 814 */ 815 int ngtcp2_conn_update_rtt(ngtcp2_conn *conn, ngtcp2_duration rtt, 816 ngtcp2_duration ack_delay, ngtcp2_tstamp ts); 817 818 void ngtcp2_conn_set_loss_detection_timer(ngtcp2_conn *conn, ngtcp2_tstamp ts); 819 820 int ngtcp2_conn_on_loss_detection_timer(ngtcp2_conn *conn, ngtcp2_tstamp ts); 821 822 /* 823 * ngtcp2_conn_detect_lost_pkt detects lost packets. 824 * 825 * This function returns 0 if it succeeds, or one of the following 826 * negative error codes: 827 * 828 * NGTCP2_ERR_NOMEM 829 * Out of memory. 830 */ 831 int ngtcp2_conn_detect_lost_pkt(ngtcp2_conn *conn, ngtcp2_pktns *pktns, 832 ngtcp2_conn_stat *cstat, ngtcp2_tstamp ts); 833 834 /* 835 * ngtcp2_conn_tx_strmq_top returns the ngtcp2_strm which sits on the 836 * top of queue. tx_strmq must not be empty. 837 */ 838 ngtcp2_strm *ngtcp2_conn_tx_strmq_top(ngtcp2_conn *conn); 839 840 /* 841 * ngtcp2_conn_tx_strmq_pop pops the ngtcp2_strm from the queue. 842 * tx_strmq must not be empty. 843 */ 844 void ngtcp2_conn_tx_strmq_pop(ngtcp2_conn *conn); 845 846 /* 847 * ngtcp2_conn_tx_strmq_push pushes |strm| into tx_strmq. 848 * 849 * This function returns 0 if it succeeds, or one of the following 850 * negative error codes: 851 * 852 * NGTCP2_ERR_NOMEM 853 * Out of memory. 854 */ 855 int ngtcp2_conn_tx_strmq_push(ngtcp2_conn *conn, ngtcp2_strm *strm); 856 857 /* 858 * ngtcp2_conn_internal_expiry returns the minimum expiry time among 859 * all timers in |conn|. 860 */ 861 ngtcp2_tstamp ngtcp2_conn_internal_expiry(ngtcp2_conn *conn); 862 863 ngtcp2_ssize ngtcp2_conn_write_vmsg(ngtcp2_conn *conn, ngtcp2_path *path, 864 int pkt_info_version, ngtcp2_pkt_info *pi, 865 uint8_t *dest, size_t destlen, 866 ngtcp2_vmsg *vmsg, ngtcp2_tstamp ts); 867 868 /* 869 * ngtcp2_conn_write_single_frame_pkt writes a packet which contains 870 * |fr| frame only in the buffer pointed by |dest| whose length if 871 * |destlen|. |type| is a long packet type to send. If |type| is 0, 872 * Short packet is used. |dcid| is used as a destination connection 873 * ID. |flags| is zero or more of NGTCP2_WRITE_PKT_FLAG_*. Only 874 * NGTCP2_WRITE_PKT_FLAG_REQUIRE_PADDING is recognized. 875 * 876 * The packet written by this function will not be retransmitted. 877 * 878 * This function returns the number of bytes written in |dest| if it 879 * succeeds, or one of the following negative error codes: 880 * 881 * NGTCP2_ERR_CALLBACK_FAILURE 882 * User-defined callback function failed. 883 */ 884 ngtcp2_ssize ngtcp2_conn_write_single_frame_pkt( 885 ngtcp2_conn *conn, ngtcp2_pkt_info *pi, uint8_t *dest, size_t destlen, 886 uint8_t type, uint8_t flags, const ngtcp2_cid *dcid, ngtcp2_frame *fr, 887 uint16_t rtb_entry_flags, const ngtcp2_path *path, ngtcp2_tstamp ts); 888 889 /* 890 * ngtcp2_conn_commit_local_transport_params commits the local 891 * transport parameters, which is currently set to 892 * conn->local.settings.transport_params. This function will do some 893 * amends on transport parameters for adjusting default values. 894 * 895 * This function returns 0 if it succeeds, or one of the following 896 * negative error codes: 897 * 898 * NGTCP2_ERR_NOMEM 899 * Out of memory. 900 * NGTCP2_ERR_INVALID_ARGUMENT 901 * CID in preferred address equals to the original SCID. 902 */ 903 int ngtcp2_conn_commit_local_transport_params(ngtcp2_conn *conn); 904 905 /* 906 * ngtcp2_conn_lost_pkt_expiry returns the earliest expiry time of 907 * lost packet. 908 */ 909 ngtcp2_tstamp ngtcp2_conn_lost_pkt_expiry(ngtcp2_conn *conn); 910 911 /* 912 * ngtcp2_conn_remove_lost_pkt removes the expired lost packet. 913 */ 914 void ngtcp2_conn_remove_lost_pkt(ngtcp2_conn *conn, ngtcp2_tstamp ts); 915 916 /* 917 * ngtcp2_conn_resched_frames reschedules frames linked from |*pfrc| 918 * for retransmission. 919 * 920 * This function returns 0 if it succeeds, or one of the following 921 * negative error codes: 922 * 923 * NGTCP2_ERR_NOMEM 924 * Out of memory. 925 */ 926 int ngtcp2_conn_resched_frames(ngtcp2_conn *conn, ngtcp2_pktns *pktns, 927 ngtcp2_frame_chain **pfrc); 928 929 uint64_t ngtcp2_conn_tx_strmq_first_cycle(ngtcp2_conn *conn); 930 931 /** 932 * @function 933 * 934 * `ngtcp2_conn_ack_delay_expiry` returns the expiry time point of 935 * delayed protected ACK. One should call 936 * `ngtcp2_conn_cancel_expired_ack_delay_timer` and 937 * `ngtcp2_conn_write_pkt` (or `ngtcp2_conn_writev_stream`) when it 938 * expires. It returns UINT64_MAX if there is no expiry. 939 */ 940 ngtcp2_tstamp ngtcp2_conn_ack_delay_expiry(ngtcp2_conn *conn); 941 942 /** 943 * @function 944 * 945 * `ngtcp2_conn_cancel_expired_ack_delay_timer` stops expired ACK 946 * delay timer. |ts| is the current time. This function must be 947 * called when `ngtcp2_conn_ack_delay_expiry` <= ts. 948 */ 949 void ngtcp2_conn_cancel_expired_ack_delay_timer(ngtcp2_conn *conn, 950 ngtcp2_tstamp ts); 951 952 /** 953 * @function 954 * 955 * `ngtcp2_conn_loss_detection_expiry` returns the expiry time point 956 * of loss detection timer. One should call 957 * `ngtcp2_conn_on_loss_detection_timer` and `ngtcp2_conn_write_pkt` 958 * (or `ngtcp2_conn_writev_stream`) when it expires. It returns 959 * UINT64_MAX if loss detection timer is not armed. 960 */ 961 ngtcp2_tstamp ngtcp2_conn_loss_detection_expiry(ngtcp2_conn *conn); 962 963 /** 964 * @function 965 * 966 * `ngtcp2_conn_get_idle_expiry` returns the time when a connection 967 * should be closed if it continues to be idle. If idle timeout is 968 * disabled, this function returns ``UINT64_MAX``. 969 */ 970 ngtcp2_tstamp ngtcp2_conn_get_idle_expiry(ngtcp2_conn *conn); 971 972 ngtcp2_duration ngtcp2_conn_compute_pto(ngtcp2_conn *conn, ngtcp2_pktns *pktns); 973 974 /* 975 * ngtcp2_conn_track_retired_dcid_seq tracks the sequence number |seq| 976 * of unacknowledged retiring Destination Connection ID. 977 * 978 * This function returns 0 if it succeeds, or one of the following 979 * negative error codes: 980 * 981 * NGTCP2_ERR_CONNECTION_ID_LIMIT 982 * The number of unacknowledged retirement exceeds the limit. 983 */ 984 int ngtcp2_conn_track_retired_dcid_seq(ngtcp2_conn *conn, uint64_t seq); 985 986 /* 987 * ngtcp2_conn_untrack_retired_dcid_seq deletes the sequence number 988 * |seq| of unacknowledged retiring Destination Connection ID. It is 989 * fine if such sequence number is not found. 990 */ 991 void ngtcp2_conn_untrack_retired_dcid_seq(ngtcp2_conn *conn, uint64_t seq); 992 993 /* 994 * ngtcp2_conn_server_negotiate_version negotiates QUIC version. It 995 * is compatible version negotiation. It returns the negotiated QUIC 996 * version. This function must not be called by client. 997 */ 998 uint32_t 999 ngtcp2_conn_server_negotiate_version(ngtcp2_conn *conn, 1000 const ngtcp2_version_info *version_info); 1001 1002 /** 1003 * @function 1004 * 1005 * `ngtcp2_conn_write_connection_close_pkt` writes a packet which 1006 * contains a CONNECTION_CLOSE frame (type 0x1c) in the buffer pointed 1007 * by |dest| whose capacity is |datalen|. 1008 * 1009 * If |path| is not ``NULL``, this function stores the network path 1010 * with which the packet should be sent. Each addr field must point 1011 * to the buffer which should be at least ``sizeof(struct 1012 * sockaddr_storage)`` bytes long. The assignment might not be done 1013 * if nothing is written to |dest|. 1014 * 1015 * If |pi| is not ``NULL``, this function stores packet metadata in it 1016 * if it succeeds. The metadata includes ECN markings. 1017 * 1018 * This function must not be called from inside the callback 1019 * functions. 1020 * 1021 * At the moment, successful call to this function makes connection 1022 * close. We may change this behaviour in the future to allow 1023 * graceful shutdown. 1024 * 1025 * This function returns the number of bytes written in |dest| if it 1026 * succeeds, or one of the following negative error codes: 1027 * 1028 * :macro:`NGTCP2_ERR_NOMEM` 1029 * Out of memory 1030 * :macro:`NGTCP2_ERR_NOBUF` 1031 * Buffer is too small 1032 * :macro:`NGTCP2_ERR_INVALID_STATE` 1033 * The current state does not allow sending CONNECTION_CLOSE. 1034 * :macro:`NGTCP2_ERR_PKT_NUM_EXHAUSTED` 1035 * Packet number is exhausted, and cannot send any more packet. 1036 * :macro:`NGTCP2_ERR_CALLBACK_FAILURE` 1037 * User callback failed 1038 */ 1039 ngtcp2_ssize ngtcp2_conn_write_connection_close_pkt( 1040 ngtcp2_conn *conn, ngtcp2_path *path, ngtcp2_pkt_info *pi, uint8_t *dest, 1041 size_t destlen, uint64_t error_code, const uint8_t *reason, 1042 size_t reasonlen, ngtcp2_tstamp ts); 1043 1044 /** 1045 * @function 1046 * 1047 * `ngtcp2_conn_write_application_close_pkt` writes a packet which 1048 * contains a CONNECTION_CLOSE frame (type 0x1d) in the buffer pointed 1049 * by |dest| whose capacity is |datalen|. 1050 * 1051 * If |path| is not ``NULL``, this function stores the network path 1052 * with which the packet should be sent. Each addr field must point 1053 * to the buffer which should be at least ``sizeof(struct 1054 * sockaddr_storage)`` bytes long. The assignment might not be done 1055 * if nothing is written to |dest|. 1056 * 1057 * If |pi| is not ``NULL``, this function stores packet metadata in it 1058 * if it succeeds. The metadata includes ECN markings. 1059 * 1060 * If handshake has not been confirmed yet, CONNECTION_CLOSE (type 1061 * 0x1c) with error code :macro:`NGTCP2_APPLICATION_ERROR` is written 1062 * instead. 1063 * 1064 * This function must not be called from inside the callback 1065 * functions. 1066 * 1067 * At the moment, successful call to this function makes connection 1068 * close. We may change this behaviour in the future to allow 1069 * graceful shutdown. 1070 * 1071 * This function returns the number of bytes written in |dest| if it 1072 * succeeds, or one of the following negative error codes: 1073 * 1074 * :macro:`NGTCP2_ERR_NOMEM` 1075 * Out of memory 1076 * :macro:`NGTCP2_ERR_NOBUF` 1077 * Buffer is too small 1078 * :macro:`NGTCP2_ERR_INVALID_STATE` 1079 * The current state does not allow sending CONNECTION_CLOSE. 1080 * :macro:`NGTCP2_ERR_PKT_NUM_EXHAUSTED` 1081 * Packet number is exhausted, and cannot send any more packet. 1082 * :macro:`NGTCP2_ERR_CALLBACK_FAILURE` 1083 * User callback failed 1084 */ 1085 ngtcp2_ssize ngtcp2_conn_write_application_close_pkt( 1086 ngtcp2_conn *conn, ngtcp2_path *path, ngtcp2_pkt_info *pi, uint8_t *dest, 1087 size_t destlen, uint64_t app_error_code, const uint8_t *reason, 1088 size_t reasonlen, ngtcp2_tstamp ts); 1089 1090 int ngtcp2_conn_start_pmtud(ngtcp2_conn *conn); 1091 1092 void ngtcp2_conn_stop_pmtud(ngtcp2_conn *conn); 1093 1094 /** 1095 * @function 1096 * 1097 * `ngtcp2_conn_set_remote_transport_params` sets transport parameter 1098 * |params| from a remote endpoint to |conn|. 1099 * 1100 * This function returns 0 if it succeeds, or one of the following 1101 * negative error codes: 1102 * 1103 * :macro:`NGTCP2_ERR_TRANSPORT_PARAM` 1104 * Failed to validate a remote transport parameters. 1105 * :macro:`NGTCP2_ERR_VERSION_NEGOTIATION_FAILURE` 1106 * Version negotiation failure. 1107 * :macro:`NGTCP2_ERR_CALLBACK_FAILURE` 1108 * User callback failed 1109 * :macro:`NGTCP2_ERR_NOMEM` 1110 * Out of memory. 1111 */ 1112 int ngtcp2_conn_set_remote_transport_params( 1113 ngtcp2_conn *conn, const ngtcp2_transport_params *params); 1114 1115 #endif /* NGTCP2_CONN_H */ 1116