forked from microsoft/msquic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msquic.h
1353 lines (1197 loc) · 47.8 KB
/
msquic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Abstract:
Declarations for the MsQuic API, which enables applications and drivers to
create QUIC connections as a client or server.
For more detailed information, see ../docs/API.md
Supported Platforms:
Windows User mode
Windows Kernel mode
Linux User mode
--*/
#ifndef _MSQUIC_
#define _MSQUIC_
#ifdef _WIN32
#pragma once
#endif
#pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
#pragma warning(disable:4214) // nonstandard extension used: bit field types other than int
#ifdef _KERNEL_MODE
#include "msquic_winkernel.h"
#elif _WIN32
#include "msquic_winuser.h"
#elif __linux__ || __APPLE__
#include "msquic_posix.h"
#else
#error "Unsupported Platform"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct QUIC_HANDLE *HQUIC;
//
// The maximum value that can be encoded in a 62-bit integer.
//
#define QUIC_UINT62_MAX ((1ULL << 62U) - 1)
//
// Represents a 62-bit integer.
//
typedef _In_range_(0, QUIC_UINT62_MAX) uint64_t QUIC_UINT62;
//
// An ALPN must not exceed 255 bytes, and must not be zero-length.
//
#define QUIC_MAX_ALPN_LENGTH 255
//
// A server name must not exceed 65535 bytes.
//
#define QUIC_MAX_SNI_LENGTH 65535
//
// The maximum number of bytes of application data a server application can
// send in a resumption ticket.
//
#define QUIC_MAX_RESUMPTION_APP_DATA_LENGTH 1000
typedef enum QUIC_EXECUTION_PROFILE {
QUIC_EXECUTION_PROFILE_LOW_LATENCY, // Default
QUIC_EXECUTION_PROFILE_TYPE_MAX_THROUGHPUT,
QUIC_EXECUTION_PROFILE_TYPE_SCAVENGER,
QUIC_EXECUTION_PROFILE_TYPE_REAL_TIME,
} QUIC_EXECUTION_PROFILE;
typedef enum QUIC_LOAD_BALANCING_MODE {
QUIC_LOAD_BALANCING_DISABLED, // Default
QUIC_LOAD_BALANCING_SERVER_ID_IP, // Encodes IP address in Server ID
} QUIC_LOAD_BALANCING_MODE;
typedef enum QUIC_CREDENTIAL_TYPE {
QUIC_CREDENTIAL_TYPE_NONE,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_HASH,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_HASH_STORE,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_CONTEXT,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_FILE,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_FILE_PROTECTED,
QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12,
} QUIC_CREDENTIAL_TYPE;
typedef enum QUIC_CREDENTIAL_FLAGS {
QUIC_CREDENTIAL_FLAG_NONE = 0x00000000,
QUIC_CREDENTIAL_FLAG_CLIENT = 0x00000001, // Lack of client flag indicates server.
QUIC_CREDENTIAL_FLAG_LOAD_ASYNCHRONOUS = 0x00000002,
QUIC_CREDENTIAL_FLAG_NO_CERTIFICATE_VALIDATION = 0x00000004,
QUIC_CREDENTIAL_FLAG_ENABLE_OCSP = 0x00000008, // Schannel only currently
QUIC_CREDENTIAL_FLAG_INDICATE_CERTIFICATE_RECEIVED = 0x00000010,
QUIC_CREDENTIAL_FLAG_DEFER_CERTIFICATE_VALIDATION = 0x00000020, // Schannel only currently
QUIC_CREDENTIAL_FLAG_REQUIRE_CLIENT_AUTHENTICATION = 0x00000040, // Schannel only currently
QUIC_CREDENTIAL_FLAG_USE_TLS_BUILTIN_CERTIFICATE_VALIDATION = 0x00000080, // OpenSSL only currently
QUIC_CREDENTIAL_FLAG_REVOCATION_CHECK_END_CERT = 0x00000100, // Schannel only currently
QUIC_CREDENTIAL_FLAG_REVOCATION_CHECK_CHAIN = 0x00000200, // Schannel only currently
QUIC_CREDENTIAL_FLAG_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x00000400, // Schannel only currently
QUIC_CREDENTIAL_FLAG_IGNORE_NO_REVOCATION_CHECK = 0x00000800, // Schannel only currently
QUIC_CREDENTIAL_FLAG_IGNORE_REVOCATION_OFFLINE = 0x00001000, // Schannel only currently
QUIC_CREDENTIAL_FLAG_SET_ALLOWED_CIPHER_SUITES = 0x00002000,
QUIC_CREDENTIAL_FLAG_USE_PORTABLE_CERTIFICATES = 0x00004000, // OpenSSL only currently
} QUIC_CREDENTIAL_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_CREDENTIAL_FLAGS)
typedef enum QUIC_ALLOWED_CIPHER_SUITE_FLAGS {
QUIC_ALLOWED_CIPHER_SUITE_NONE = 0x0,
QUIC_ALLOWED_CIPHER_SUITE_AES_128_GCM_SHA256 = 0x1,
QUIC_ALLOWED_CIPHER_SUITE_AES_256_GCM_SHA384 = 0x2,
QUIC_ALLOWED_CIPHER_SUITE_CHACHA20_POLY1305_SHA256 = 0x4, // Not supported on Schannel
} QUIC_ALLOWED_CIPHER_SUITE_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_ALLOWED_CIPHER_SUITE_FLAGS);
typedef enum QUIC_CERTIFICATE_HASH_STORE_FLAGS {
QUIC_CERTIFICATE_HASH_STORE_FLAG_NONE = 0x0000,
QUIC_CERTIFICATE_HASH_STORE_FLAG_MACHINE_STORE = 0x0001,
} QUIC_CERTIFICATE_HASH_STORE_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_CERTIFICATE_HASH_STORE_FLAGS)
typedef enum QUIC_CONNECTION_SHUTDOWN_FLAGS {
QUIC_CONNECTION_SHUTDOWN_FLAG_NONE = 0x0000,
QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT = 0x0001, // Don't send the close frame over the network.
} QUIC_CONNECTION_SHUTDOWN_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_CONNECTION_SHUTDOWN_FLAGS)
typedef enum QUIC_SERVER_RESUMPTION_LEVEL {
QUIC_SERVER_NO_RESUME,
QUIC_SERVER_RESUME_ONLY,
QUIC_SERVER_RESUME_AND_ZERORTT,
} QUIC_SERVER_RESUMPTION_LEVEL;
typedef enum QUIC_SEND_RESUMPTION_FLAGS {
QUIC_SEND_RESUMPTION_FLAG_NONE = 0x0000,
QUIC_SEND_RESUMPTION_FLAG_FINAL = 0x0001, // Free TLS state after sending this ticket.
} QUIC_SEND_RESUMPTION_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_SEND_RESUMPTION_FLAGS)
typedef enum QUIC_STREAM_SCHEDULING_SCHEME {
QUIC_STREAM_SCHEDULING_SCHEME_FIFO = 0x0000, // Sends stream data first come, first served. (Default)
QUIC_STREAM_SCHEDULING_SCHEME_ROUND_ROBIN = 0x0001, // Sends stream data evenly multiplexed.
QUIC_STREAM_SCHEDULING_SCHEME_COUNT, // The number of stream scheduling schemes.
} QUIC_STREAM_SCHEDULING_SCHEME;
typedef enum QUIC_STREAM_OPEN_FLAGS {
QUIC_STREAM_OPEN_FLAG_NONE = 0x0000,
QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL = 0x0001, // Indicates the stream is unidirectional.
QUIC_STREAM_OPEN_FLAG_0_RTT = 0x0002, // The stream was opened via a 0-RTT packet.
} QUIC_STREAM_OPEN_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_STREAM_OPEN_FLAGS)
typedef enum QUIC_STREAM_START_FLAGS {
QUIC_STREAM_START_FLAG_NONE = 0x0000,
QUIC_STREAM_START_FLAG_FAIL_BLOCKED = 0x0001, // Only opens the stream if flow control allows.
QUIC_STREAM_START_FLAG_IMMEDIATE = 0x0002, // Immediately informs peer that stream is open.
QUIC_STREAM_START_FLAG_ASYNC = 0x0004, // Don't block the API call to wait for completion.
QUIC_STREAM_START_FLAG_SHUTDOWN_ON_FAIL = 0x0008, // Shutdown the stream immediately after start failure.
QUIC_STREAM_START_FLAG_INDICATE_PEER_ACCEPT = 0x0010, // Indicate PEER_ACCEPTED event if not accepted at start.
} QUIC_STREAM_START_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_STREAM_START_FLAGS)
typedef enum QUIC_STREAM_SHUTDOWN_FLAGS {
QUIC_STREAM_SHUTDOWN_FLAG_NONE = 0x0000,
QUIC_STREAM_SHUTDOWN_FLAG_GRACEFUL = 0x0001, // Cleanly closes the send path.
QUIC_STREAM_SHUTDOWN_FLAG_ABORT_SEND = 0x0002, // Abruptly closes the send path.
QUIC_STREAM_SHUTDOWN_FLAG_ABORT_RECEIVE = 0x0004, // Abruptly closes the receive path.
QUIC_STREAM_SHUTDOWN_FLAG_ABORT = 0x0006, // Abruptly closes both send and receive paths.
QUIC_STREAM_SHUTDOWN_FLAG_IMMEDIATE = 0x0008, // Immediately sends completion events to app.
QUIC_STREAM_SHUTDOWN_FLAG_INLINE = 0x0010, // Process the shutdown immediately inline. Only for calls on callbacks.
// WARNING: Can cause reentrant callbacks!
} QUIC_STREAM_SHUTDOWN_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_STREAM_SHUTDOWN_FLAGS)
typedef enum QUIC_RECEIVE_FLAGS {
QUIC_RECEIVE_FLAG_NONE = 0x0000,
QUIC_RECEIVE_FLAG_0_RTT = 0x0001, // Data was encrypted with 0-RTT key.
QUIC_RECEIVE_FLAG_FIN = 0x0002, // FIN was included with this data.
} QUIC_RECEIVE_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_RECEIVE_FLAGS)
typedef enum QUIC_SEND_FLAGS {
QUIC_SEND_FLAG_NONE = 0x0000,
QUIC_SEND_FLAG_ALLOW_0_RTT = 0x0001, // Allows the use of encrypting with 0-RTT key.
QUIC_SEND_FLAG_START = 0x0002, // Asynchronously starts the stream with the sent data.
QUIC_SEND_FLAG_FIN = 0x0004, // Indicates the request is the one last sent on the stream.
QUIC_SEND_FLAG_DGRAM_PRIORITY = 0x0008, // Indicates the datagram is higher priority than others.
QUIC_SEND_FLAG_DELAY_SEND = 0x0010, // Indicates the send should be delayed because more will be queued soon.
} QUIC_SEND_FLAGS;
DEFINE_ENUM_FLAG_OPERATORS(QUIC_SEND_FLAGS)
typedef enum QUIC_DATAGRAM_SEND_STATE {
QUIC_DATAGRAM_SEND_SENT, // Sent and awaiting acknowledegment
QUIC_DATAGRAM_SEND_LOST_SUSPECT, // Suspected as lost, but still tracked
QUIC_DATAGRAM_SEND_LOST_DISCARDED, // Lost and not longer being tracked
QUIC_DATAGRAM_SEND_ACKNOWLEDGED, // Acknowledged
QUIC_DATAGRAM_SEND_ACKNOWLEDGED_SPURIOUS, // Acknowledged after being suspected lost
QUIC_DATAGRAM_SEND_CANCELED, // Canceled before send
} QUIC_DATAGRAM_SEND_STATE;
//
// Helper to determine if a datagrams state is final, and no longer tracked
// by MsQuic.
//
#define QUIC_DATAGRAM_SEND_STATE_IS_FINAL(State) \
((State) >= QUIC_DATAGRAM_SEND_LOST_DISCARDED)
typedef struct QUIC_REGISTRATION_CONFIG { // All fields may be NULL/zero.
const char* AppName;
QUIC_EXECUTION_PROFILE ExecutionProfile;
} QUIC_REGISTRATION_CONFIG;
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
_Function_class_(QUIC_CREDENTIAL_LOAD_COMPLETE)
void
(QUIC_API QUIC_CREDENTIAL_LOAD_COMPLETE)(
_In_ HQUIC Configuration,
_In_opt_ void* Context,
_In_ QUIC_STATUS Status
);
typedef QUIC_CREDENTIAL_LOAD_COMPLETE *QUIC_CREDENTIAL_LOAD_COMPLETE_HANDLER;
typedef struct QUIC_CERTIFICATE_HASH {
uint8_t ShaHash[20];
} QUIC_CERTIFICATE_HASH;
typedef struct QUIC_CERTIFICATE_HASH_STORE {
QUIC_CERTIFICATE_HASH_STORE_FLAGS Flags;
uint8_t ShaHash[20];
char StoreName[128];
} QUIC_CERTIFICATE_HASH_STORE;
typedef struct QUIC_CERTIFICATE_FILE {
const char *PrivateKeyFile;
const char *CertificateFile;
} QUIC_CERTIFICATE_FILE;
typedef struct QUIC_CERTIFICATE_FILE_PROTECTED {
const char *PrivateKeyFile;
const char *CertificateFile;
const char *PrivateKeyPassword;
} QUIC_CERTIFICATE_FILE_PROTECTED;
typedef struct QUIC_CERTIFICATE_PKCS12 {
const uint8_t *Asn1Blob;
uint32_t Asn1BlobLength;
const char *PrivateKeyPassword; // Optional: used if provided. Ignored if NULL
} QUIC_CERTIFICATE_PKCS12;
typedef void QUIC_CERTIFICATE; // Platform specific certificate object
typedef void QUIC_CERTIFICATE_CHAIN; // Platform specific certificate chain object
typedef struct QUIC_CREDENTIAL_CONFIG {
QUIC_CREDENTIAL_TYPE Type;
QUIC_CREDENTIAL_FLAGS Flags;
union {
QUIC_CERTIFICATE_HASH* CertificateHash;
QUIC_CERTIFICATE_HASH_STORE* CertificateHashStore;
QUIC_CERTIFICATE* CertificateContext;
QUIC_CERTIFICATE_FILE* CertificateFile;
QUIC_CERTIFICATE_FILE_PROTECTED* CertificateFileProtected;
QUIC_CERTIFICATE_PKCS12* CertificatePkcs12;
};
const char* Principal;
void* Reserved; // Currently unused
QUIC_CREDENTIAL_LOAD_COMPLETE_HANDLER AsyncHandler; // Optional
QUIC_ALLOWED_CIPHER_SUITE_FLAGS AllowedCipherSuites;// Optional
} QUIC_CREDENTIAL_CONFIG;
//
// The maximum number of QUIC_TICKET_KEY_CONFIG that can be used at one time.
//
#define QUIC_MAX_TICKET_KEY_COUNT 16
//
// TLS New Session Ticket encryption key configuration.
//
typedef struct QUIC_TICKET_KEY_CONFIG {
uint8_t Id[16];
uint8_t Material[64];
uint8_t MaterialLength;
} QUIC_TICKET_KEY_CONFIG;
//
// A single contiguous buffer.
//
typedef struct QUIC_BUFFER {
uint32_t Length;
_Field_size_bytes_(Length)
uint8_t* Buffer;
} QUIC_BUFFER;
//
// All the available information describing a new incoming connection.
//
typedef struct QUIC_NEW_CONNECTION_INFO {
uint32_t QuicVersion;
const QUIC_ADDR* LocalAddress;
const QUIC_ADDR* RemoteAddress;
uint32_t CryptoBufferLength;
uint16_t ClientAlpnListLength;
uint16_t ServerNameLength;
uint8_t NegotiatedAlpnLength;
_Field_size_bytes_(CryptoBufferLength)
const uint8_t* CryptoBuffer;
_Field_size_bytes_(ClientAlpnListLength)
const uint8_t* ClientAlpnList;
_Field_size_bytes_(NegotiatedAlpnLength)
const uint8_t* NegotiatedAlpn;
_Field_size_bytes_opt_(ServerNameLength)
const char* ServerName;
} QUIC_NEW_CONNECTION_INFO;
typedef enum QUIC_TLS_PROTOCOL_VERSION {
QUIC_TLS_PROTOCOL_UNKNOWN = 0,
QUIC_TLS_PROTOCOL_1_3 = 0x3000,
} QUIC_TLS_PROTOCOL_VERSION;
typedef enum QUIC_CIPHER_ALGORITHM {
QUIC_CIPHER_ALGORITHM_NONE = 0,
QUIC_CIPHER_ALGORITHM_AES_128 = 0x660E,
QUIC_CIPHER_ALGORITHM_AES_256 = 0x6610,
QUIC_CIPHER_ALGORITHM_CHACHA20 = 0x6612, // Not supported on Schannel/BCrypt
} QUIC_CIPHER_ALGORITHM;
typedef enum QUIC_HASH_ALGORITHM {
QUIC_HASH_ALGORITHM_NONE = 0,
QUIC_HASH_ALGORITHM_SHA_256 = 0x800C,
QUIC_HASH_ALGORITHM_SHA_384 = 0x800D,
} QUIC_HASH_ALGORITHM;
typedef enum QUIC_KEY_EXCHANGE_ALGORITHM {
QUIC_KEY_EXCHANGE_ALGORITHM_NONE = 0,
} QUIC_KEY_EXCHANGE_ALGORITHM;
typedef enum QUIC_CIPHER_SUITE {
QUIC_CIPHER_SUITE_TLS_AES_128_GCM_SHA256 = 0x1301,
QUIC_CIPHER_SUITE_TLS_AES_256_GCM_SHA384 = 0x1302,
QUIC_CIPHER_SUITE_TLS_CHACHA20_POLY1305_SHA256 = 0x1303, // Not supported on Schannel
} QUIC_CIPHER_SUITE;
typedef enum QUIC_CONGESTION_CONTROL_ALGORITHM {
QUIC_CONGESTION_CONTROL_ALGORITHM_CUBIC,
QUIC_CONGESTION_CONTROL_ALGORITHM_MAX,
} QUIC_CONGESTION_CONTROL_ALGORITHM;
//
// All the available information describing a handshake.
//
typedef struct QUIC_HANDSHAKE_INFO {
QUIC_TLS_PROTOCOL_VERSION TlsProtocolVersion;
QUIC_CIPHER_ALGORITHM CipherAlgorithm;
int32_t CipherStrength;
QUIC_HASH_ALGORITHM Hash;
int32_t HashStrength;
QUIC_KEY_EXCHANGE_ALGORITHM KeyExchangeAlgorithm;
int32_t KeyExchangeStrength;
QUIC_CIPHER_SUITE CipherSuite;
} QUIC_HANDSHAKE_INFO;
//
// All statistics available to query about a connection.
//
typedef struct QUIC_STATISTICS {
uint64_t CorrelationId;
uint32_t VersionNegotiation : 1;
uint32_t StatelessRetry : 1;
uint32_t ResumptionAttempted : 1;
uint32_t ResumptionSucceeded : 1;
uint32_t Rtt; // In microseconds
uint32_t MinRtt; // In microseconds
uint32_t MaxRtt; // In microseconds
struct {
uint64_t Start;
uint64_t InitialFlightEnd; // Processed all peer's Initial packets
uint64_t HandshakeFlightEnd; // Processed all peer's Handshake packets
} Timing;
struct {
uint32_t ClientFlight1Bytes; // Sum of TLS payloads
uint32_t ServerFlight1Bytes; // Sum of TLS payloads
uint32_t ClientFlight2Bytes; // Sum of TLS payloads
} Handshake;
struct {
uint16_t PathMtu; // Current path MTU.
uint64_t TotalPackets; // QUIC packets; could be coalesced into fewer UDP datagrams.
uint64_t RetransmittablePackets;
uint64_t SuspectedLostPackets;
uint64_t SpuriousLostPackets; // Actual lost is (SuspectedLostPackets - SpuriousLostPackets)
uint64_t TotalBytes; // Sum of UDP payloads
uint64_t TotalStreamBytes; // Sum of stream payloads
uint32_t CongestionCount; // Number of congestion events
uint32_t PersistentCongestionCount; // Number of persistent congestion events
} Send;
struct {
uint64_t TotalPackets; // QUIC packets; could be coalesced into fewer UDP datagrams.
uint64_t ReorderedPackets; // Packets where packet number is less than highest seen.
uint64_t DroppedPackets; // Includes DuplicatePackets.
uint64_t DuplicatePackets;
uint64_t TotalBytes; // Sum of UDP payloads
uint64_t TotalStreamBytes; // Sum of stream payloads
uint64_t DecryptionFailures; // Count of packet decryption failures.
uint64_t ValidAckFrames; // Count of receive ACK frames.
} Recv;
struct {
uint32_t KeyUpdateCount;
} Misc;
} QUIC_STATISTICS;
typedef struct QUIC_LISTENER_STATISTICS {
uint64_t TotalAcceptedConnections;
uint64_t TotalRejectedConnections;
struct {
struct {
uint64_t DroppedPackets;
} Recv;
} Binding;
} QUIC_LISTENER_STATISTICS;
typedef enum QUIC_PERFORMANCE_COUNTERS {
QUIC_PERF_COUNTER_CONN_CREATED, // Total connections ever allocated.
QUIC_PERF_COUNTER_CONN_HANDSHAKE_FAIL, // Total connections that failed during handshake.
QUIC_PERF_COUNTER_CONN_APP_REJECT, // Total connections rejected by the application.
QUIC_PERF_COUNTER_CONN_RESUMED, // Total connections resumed.
QUIC_PERF_COUNTER_CONN_ACTIVE, // Connections currently allocated.
QUIC_PERF_COUNTER_CONN_CONNECTED, // Connections currently in the connected state.
QUIC_PERF_COUNTER_CONN_PROTOCOL_ERRORS, // Total connections shutdown with a protocol error.
QUIC_PERF_COUNTER_CONN_NO_ALPN, // Total connection attempts with no matching ALPN.
QUIC_PERF_COUNTER_STRM_ACTIVE, // Current streams allocated.
QUIC_PERF_COUNTER_PKTS_SUSPECTED_LOST, // Total suspected packets lost
QUIC_PERF_COUNTER_PKTS_DROPPED, // Total packets dropped for any reason.
QUIC_PERF_COUNTER_PKTS_DECRYPTION_FAIL, // Total packets with decryption failures.
QUIC_PERF_COUNTER_UDP_RECV, // Total UDP datagrams received.
QUIC_PERF_COUNTER_UDP_SEND, // Total UDP datagrams sent.
QUIC_PERF_COUNTER_UDP_RECV_BYTES, // Total UDP payload bytes received.
QUIC_PERF_COUNTER_UDP_SEND_BYTES, // Total UDP payload bytes sent.
QUIC_PERF_COUNTER_UDP_RECV_EVENTS, // Total UDP receive events.
QUIC_PERF_COUNTER_UDP_SEND_CALLS, // Total UDP send API calls.
QUIC_PERF_COUNTER_APP_SEND_BYTES, // Total bytes sent by applications.
QUIC_PERF_COUNTER_APP_RECV_BYTES, // Total bytes received by applications.
QUIC_PERF_COUNTER_CONN_QUEUE_DEPTH, // Current connections queued for processing.
QUIC_PERF_COUNTER_CONN_OPER_QUEUE_DEPTH,// Current connection operations queued.
QUIC_PERF_COUNTER_CONN_OPER_QUEUED, // Total connection operations queued ever.
QUIC_PERF_COUNTER_CONN_OPER_COMPLETED, // Total connection operations processed ever.
QUIC_PERF_COUNTER_WORK_OPER_QUEUE_DEPTH,// Current worker operations queued.
QUIC_PERF_COUNTER_WORK_OPER_QUEUED, // Total worker operations queued ever.
QUIC_PERF_COUNTER_WORK_OPER_COMPLETED, // Total worker operations processed ever.
QUIC_PERF_COUNTER_PATH_VALIDATED, // Total path challenges that succeed ever.
QUIC_PERF_COUNTER_PATH_FAILURE, // Total path challenges that fail ever.
QUIC_PERF_COUNTER_SEND_STATELESS_RESET, // Total stateless reset packets sent ever.
QUIC_PERF_COUNTER_SEND_STATELESS_RETRY, // Total stateless retry packets sent ever.
QUIC_PERF_COUNTER_MAX,
} QUIC_PERFORMANCE_COUNTERS;
typedef struct QUIC_SETTINGS {
union {
uint64_t IsSetFlags;
struct {
uint64_t MaxBytesPerKey : 1;
uint64_t HandshakeIdleTimeoutMs : 1;
uint64_t IdleTimeoutMs : 1;
uint64_t TlsClientMaxSendBuffer : 1;
uint64_t TlsServerMaxSendBuffer : 1;
uint64_t StreamRecvWindowDefault : 1;
uint64_t StreamRecvBufferDefault : 1;
uint64_t ConnFlowControlWindow : 1;
uint64_t MaxWorkerQueueDelayUs : 1;
uint64_t MaxStatelessOperations : 1;
uint64_t InitialWindowPackets : 1;
uint64_t SendIdleTimeoutMs : 1;
uint64_t InitialRttMs : 1;
uint64_t MaxAckDelayMs : 1;
uint64_t DisconnectTimeoutMs : 1;
uint64_t KeepAliveIntervalMs : 1;
uint64_t PeerBidiStreamCount : 1;
uint64_t PeerUnidiStreamCount : 1;
uint64_t RetryMemoryLimit : 1;
uint64_t LoadBalancingMode : 1;
uint64_t MaxOperationsPerDrain : 1;
uint64_t SendBufferingEnabled : 1;
uint64_t PacingEnabled : 1;
uint64_t MigrationEnabled : 1;
uint64_t DatagramReceiveEnabled : 1;
uint64_t ServerResumptionLevel : 1;
uint64_t DesiredVersionsList : 1;
uint64_t VersionNegotiationExtEnabled : 1;
uint64_t MinimumMtu : 1;
uint64_t MaximumMtu : 1;
uint64_t MtuDiscoverySearchCompleteTimeoutUs : 1;
uint64_t MtuDiscoveryMissingProbeCount : 1;
uint64_t MaxBindingStatelessOperations : 1;
uint64_t StatelessOperationExpirationMs : 1;
uint64_t CongestionControlAlgorithm : 1;
uint64_t RESERVED : 29;
} IsSet;
};
uint64_t MaxBytesPerKey;
uint64_t HandshakeIdleTimeoutMs;
uint64_t IdleTimeoutMs;
uint32_t TlsClientMaxSendBuffer;
uint32_t TlsServerMaxSendBuffer;
uint32_t StreamRecvWindowDefault;
uint32_t StreamRecvBufferDefault;
uint32_t ConnFlowControlWindow;
uint32_t MaxWorkerQueueDelayUs;
uint32_t MaxStatelessOperations;
uint32_t InitialWindowPackets;
uint32_t SendIdleTimeoutMs;
uint32_t InitialRttMs;
uint32_t MaxAckDelayMs;
uint32_t DisconnectTimeoutMs;
uint32_t KeepAliveIntervalMs;
uint16_t PeerBidiStreamCount;
uint16_t PeerUnidiStreamCount;
uint16_t RetryMemoryLimit; // Global only
uint16_t LoadBalancingMode; // Global only
uint8_t MaxOperationsPerDrain;
uint8_t SendBufferingEnabled : 1;
uint8_t PacingEnabled : 1;
uint8_t MigrationEnabled : 1;
uint8_t DatagramReceiveEnabled : 1;
uint8_t ServerResumptionLevel : 2; // QUIC_SERVER_RESUMPTION_LEVEL
uint8_t VersionNegotiationExtEnabled : 1;
uint8_t RESERVED : 1;
const uint32_t* DesiredVersionsList;
uint32_t DesiredVersionsListLength;
uint16_t MinimumMtu;
uint16_t MaximumMtu;
uint64_t MtuDiscoverySearchCompleteTimeoutUs;
uint8_t MtuDiscoveryMissingProbeCount;
uint16_t MaxBindingStatelessOperations;
uint16_t StatelessOperationExpirationMs;
QUIC_CONGESTION_CONTROL_ALGORITHM CongestionControlAlgorithm;
} QUIC_SETTINGS;
//
// Functions for associating application contexts with QUIC handles. MsQuic
// provides no explicit synchronization between parallel calls to these
// functions.
//
typedef
_IRQL_requires_max_(DISPATCH_LEVEL)
void
(QUIC_API * QUIC_SET_CONTEXT_FN)(
_In_ _Pre_defensive_ HQUIC Handle,
_In_opt_ void* Context
);
typedef
_IRQL_requires_max_(DISPATCH_LEVEL)
void*
(QUIC_API * QUIC_GET_CONTEXT_FN)(
_In_ _Pre_defensive_ HQUIC Handle
);
//
// Sets the event handler for the QUIC handle. The type of the handler must be
// appropriate for the type of the handle. MsQuic provides no explicit
// synchronization between parallel calls to this function or the ones above.
//
typedef
_IRQL_requires_max_(DISPATCH_LEVEL)
void
(QUIC_API * QUIC_SET_CALLBACK_HANDLER_FN)(
_In_ _Pre_defensive_ HQUIC Handle,
_In_ void* Handler,
_In_opt_ void* Context
);
//
// Get and Set parameters on a handle.
//
typedef enum QUIC_PARAM_LEVEL {
QUIC_PARAM_LEVEL_GLOBAL,
QUIC_PARAM_LEVEL_REGISTRATION,
QUIC_PARAM_LEVEL_CONFIGURATION,
QUIC_PARAM_LEVEL_LISTENER,
QUIC_PARAM_LEVEL_CONNECTION,
QUIC_PARAM_LEVEL_TLS,
QUIC_PARAM_LEVEL_STREAM,
} QUIC_PARAM_LEVEL;
//
// Top 6 bits of param are Level + 1, bottom 26 bits are parameter Id.
//
//
// Parameters for QUIC_PARAM_LEVEL_GLOBAL.
//
#define QUIC_PARAM_GLOBAL_RETRY_MEMORY_PERCENT 0x4000000 // uint16_t
#define QUIC_PARAM_GLOBAL_SUPPORTED_VERSIONS 0x4000001 // uint32_t[] - network byte order
#define QUIC_PARAM_GLOBAL_LOAD_BALACING_MODE 0x4000002 // uint16_t - QUIC_LOAD_BALANCING_MODE
#define QUIC_PARAM_GLOBAL_PERF_COUNTERS 0x4000003 // uint64_t[] - Array size is QUIC_PERF_COUNTER_MAX
#define QUIC_PARAM_GLOBAL_SETTINGS 0x4000004 // QUIC_SETTINGS
#define QUIC_PARAM_GLOBAL_VERSION 0x4000005 // uint32_t[4]
//
// Parameters for QUIC_PARAM_LEVEL_REGISTRATION.
//
#define QUIC_PARAM_REGISTRATION_CID_PREFIX 0x8000000 // uint8_t[]
//
// Parameters for QUIC_PARAM_LEVEL_CONFIGURATION.
//
#define QUIC_PARAM_CONFIGURATION_SETTINGS 0xC000000 // QUIC_SETTINGS
#define QUIC_PARAM_CONFIGURATION_TICKET_KEYS 0xC000001 // QUIC_TICKET_KEY_CONFIG[]
//
// Parameters for QUIC_PARAM_LEVEL_LISTENER.
//
#define QUIC_PARAM_LISTENER_LOCAL_ADDRESS 0x10000000 // QUIC_ADDR
#define QUIC_PARAM_LISTENER_STATS 0x10000001 // QUIC_LISTENER_STATISTICS
//
// Parameters for QUIC_PARAM_LEVEL_CONNECTION.
//
#define QUIC_PARAM_CONN_QUIC_VERSION 0x14000000 // uint32_t
#define QUIC_PARAM_CONN_LOCAL_ADDRESS 0x14000001 // QUIC_ADDR
#define QUIC_PARAM_CONN_REMOTE_ADDRESS 0x14000002 // QUIC_ADDR
#define QUIC_PARAM_CONN_IDEAL_PROCESSOR 0x14000003 // uint16_t
#define QUIC_PARAM_CONN_SETTINGS 0x14000004 // QUIC_SETTINGS
#define QUIC_PARAM_CONN_STATISTICS 0x14000005 // QUIC_STATISTICS
#define QUIC_PARAM_CONN_STATISTICS_PLAT 0x14000006 // QUIC_STATISTICS
#define QUIC_PARAM_CONN_SHARE_UDP_BINDING 0x14000007 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_LOCAL_BIDI_STREAM_COUNT 0x14000008 // uint16_t
#define QUIC_PARAM_CONN_LOCAL_UNIDI_STREAM_COUNT 0x14000009 // uint16_t
#define QUIC_PARAM_CONN_MAX_STREAM_IDS 0x1400000A // uint64_t[4]
#define QUIC_PARAM_CONN_CLOSE_REASON_PHRASE 0x1400000B // char[]
#define QUIC_PARAM_CONN_STREAM_SCHEDULING_SCHEME 0x1400000C // QUIC_STREAM_SCHEDULING_SCHEME
#define QUIC_PARAM_CONN_DATAGRAM_RECEIVE_ENABLED 0x1400000D // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_DATAGRAM_SEND_ENABLED 0x1400000E // uint8_t (BOOLEAN)
#ifdef QUIC_API_ENABLE_INSECURE_FEATURES
#define QUIC_PARAM_CONN_DISABLE_1RTT_ENCRYPTION 0x1400000F // uint8_t (BOOLEAN)
#endif
#define QUIC_PARAM_CONN_RESUMPTION_TICKET 0x14000010 // uint8_t[]
#define QUIC_PARAM_CONN_PEER_CERTIFICATE_VALID 0x14000011 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_LOCAL_INTERFACE 0x14000012 // uint32_t
//
// Parameters for QUIC_PARAM_LEVEL_TLS.
//
#ifdef WIN32 // Windows Platform specific parameters
typedef struct QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W {
unsigned long Attribute;
void* Buffer;
} QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W;
#define QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W 0x19000000 // QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W
#endif
#define QUIC_PARAM_TLS_HANDSHAKE_INFO 0x18000000 // QUIC_HANDSHAKE_INFO
#define QUIC_PARAM_TLS_NEGOTIATED_ALPN 0x18000001 // uint8_t[] (max 255 bytes)
//
// Parameters for QUIC_PARAM_LEVEL_STREAM.
//
#define QUIC_PARAM_STREAM_ID 0x1C000000 // QUIC_UINT62
#define QUIC_PARAM_STREAM_0RTT_LENGTH 0x1C000001 // uint64_t
#define QUIC_PARAM_STREAM_IDEAL_SEND_BUFFER_SIZE 0x1C000002 // uint64_t - bytes
#define QUIC_PARAM_STREAM_PRIORITY 0x1C000003 // uint16_t - 0 (low) to 0xFFFF (high) - 0x7FFF (default)
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_SET_PARAM_FN)(
_When_(Level == QUIC_PARAM_LEVEL_GLOBAL, _Reserved_)
_When_(Level != QUIC_PARAM_LEVEL_GLOBAL, _In_ _Pre_defensive_)
HQUIC Handle,
_In_ _Pre_defensive_ QUIC_PARAM_LEVEL Level,
_In_ uint32_t Param,
_In_ uint32_t BufferLength,
_In_reads_bytes_(BufferLength)
const void* Buffer
);
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_GET_PARAM_FN)(
_When_(Level == QUIC_PARAM_LEVEL_GLOBAL, _Reserved_)
_When_(Level != QUIC_PARAM_LEVEL_GLOBAL, _In_ _Pre_defensive_)
HQUIC Handle,
_In_ _Pre_defensive_ QUIC_PARAM_LEVEL Level,
_In_ uint32_t Param,
_Inout_ _Pre_defensive_ uint32_t* BufferLength,
_Out_writes_bytes_opt_(*BufferLength)
void* Buffer
);
//
// Registration Context Interface.
//
//
// Opens a new registration.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_REGISTRATION_OPEN_FN)(
_In_opt_ const QUIC_REGISTRATION_CONFIG* Config,
_Outptr_ _At_(*Registration, __drv_allocatesMem(Mem)) _Pre_defensive_
HQUIC* Registration
);
//
// Closes the registration. This function synchronizes the cleanup of all
// child objects. It does this by blocking until all those child objects have
// been closed by the application.
// N.B. This function will deadlock if called in any MsQuic callbacks.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
void
(QUIC_API * QUIC_REGISTRATION_CLOSE_FN)(
_In_ _Pre_defensive_ __drv_freesMem(Mem)
HQUIC Registration
);
//
// Calls shutdown for all connections in this registration. Don't call on a
// MsQuic callback thread or it might deadlock.
//
typedef
_IRQL_requires_max_(DISPATCH_LEVEL)
void
(QUIC_API * QUIC_REGISTRATION_SHUTDOWN_FN)(
_In_ _Pre_defensive_ HQUIC Registration,
_In_ QUIC_CONNECTION_SHUTDOWN_FLAGS Flags,
_In_ _Pre_defensive_ QUIC_UINT62 ErrorCode // Application defined error code
);
//
// Configuration Interface.
//
//
// Opens a new configuration.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_CONFIGURATION_OPEN_FN)(
_In_ _Pre_defensive_ HQUIC Registration,
_In_reads_(AlpnBufferCount) _Pre_defensive_
const QUIC_BUFFER* const AlpnBuffers,
_In_range_(>, 0) uint32_t AlpnBufferCount,
_In_reads_bytes_opt_(SettingsSize)
const QUIC_SETTINGS* Settings,
_In_ uint32_t SettingsSize,
_In_opt_ void* Context,
_Outptr_ _At_(*Configuration, __drv_allocatesMem(Mem)) _Pre_defensive_
HQUIC* Configuration
);
//
// Closes an existing configuration.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
void
(QUIC_API * QUIC_CONFIGURATION_CLOSE_FN)(
_In_ _Pre_defensive_ __drv_freesMem(Mem)
HQUIC Configuration
);
//
// Loads the credentials based on the input configuration.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_CONFIGURATION_LOAD_CREDENTIAL_FN)(
_In_ _Pre_defensive_ HQUIC Configuration,
_In_ _Pre_defensive_ const QUIC_CREDENTIAL_CONFIG* CredConfig
);
//
// Listener Context Interface.
//
typedef enum QUIC_LISTENER_EVENT_TYPE {
QUIC_LISTENER_EVENT_NEW_CONNECTION = 0,
} QUIC_LISTENER_EVENT_TYPE;
typedef struct QUIC_LISTENER_EVENT {
QUIC_LISTENER_EVENT_TYPE Type;
union {
struct {
const QUIC_NEW_CONNECTION_INFO* Info;
HQUIC Connection;
} NEW_CONNECTION;
};
} QUIC_LISTENER_EVENT;
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
_Function_class_(QUIC_LISTENER_CALLBACK)
QUIC_STATUS
(QUIC_API QUIC_LISTENER_CALLBACK)(
_In_ HQUIC Listener,
_In_opt_ void* Context,
_Inout_ QUIC_LISTENER_EVENT* Event
);
typedef QUIC_LISTENER_CALLBACK *QUIC_LISTENER_CALLBACK_HANDLER;
//
// Opens a new listener.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_LISTENER_OPEN_FN)(
_In_ _Pre_defensive_ HQUIC Registration,
_In_ _Pre_defensive_ QUIC_LISTENER_CALLBACK_HANDLER Handler,
_In_opt_ void* Context,
_Outptr_ _At_(*Listener, __drv_allocatesMem(Mem)) _Pre_defensive_
HQUIC* Listener
);
//
// Closes an existing listener. N.B. This function will deadlock if called in
// a QUIC_LISTENER_CALLBACK_HANDLER callback.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
void
(QUIC_API * QUIC_LISTENER_CLOSE_FN)(
_In_ _Pre_defensive_ __drv_freesMem(Mem)
HQUIC Listener
);
//
// Starts the listener processing incoming connections.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_LISTENER_START_FN)(
_In_ _Pre_defensive_ HQUIC Listener,
_In_reads_(AlpnBufferCount) _Pre_defensive_
const QUIC_BUFFER* const AlpnBuffers,
_In_range_(>, 0) uint32_t AlpnBufferCount,
_In_opt_ const QUIC_ADDR* LocalAddress
);
//
// Stops the listener from processing incoming connections.
//
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
void
(QUIC_API * QUIC_LISTENER_STOP_FN)(
_In_ _Pre_defensive_ HQUIC Listener
);
//
// Connections
//
typedef enum QUIC_CONNECTION_EVENT_TYPE {
QUIC_CONNECTION_EVENT_CONNECTED = 0,
QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_TRANSPORT = 1, // The transport started the shutdown process.
QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_PEER = 2, // The peer application started the shutdown process.
QUIC_CONNECTION_EVENT_SHUTDOWN_COMPLETE = 3, // Ready for the handle to be closed.
QUIC_CONNECTION_EVENT_LOCAL_ADDRESS_CHANGED = 4,
QUIC_CONNECTION_EVENT_PEER_ADDRESS_CHANGED = 5,
QUIC_CONNECTION_EVENT_PEER_STREAM_STARTED = 6,
QUIC_CONNECTION_EVENT_STREAMS_AVAILABLE = 7,
QUIC_CONNECTION_EVENT_PEER_NEEDS_STREAMS = 8,
QUIC_CONNECTION_EVENT_IDEAL_PROCESSOR_CHANGED = 9,
QUIC_CONNECTION_EVENT_DATAGRAM_STATE_CHANGED = 10,
QUIC_CONNECTION_EVENT_DATAGRAM_RECEIVED = 11,
QUIC_CONNECTION_EVENT_DATAGRAM_SEND_STATE_CHANGED = 12,
QUIC_CONNECTION_EVENT_RESUMED = 13, // Server-only; provides resumption data, if any.
QUIC_CONNECTION_EVENT_RESUMPTION_TICKET_RECEIVED = 14, // Client-only; provides ticket to persist, if any.
QUIC_CONNECTION_EVENT_PEER_CERTIFICATE_RECEIVED = 15, // Only with QUIC_CREDENTIAL_FLAG_INDICATE_CERTIFICATE_RECEIVED set
} QUIC_CONNECTION_EVENT_TYPE;
typedef struct QUIC_CONNECTION_EVENT {
QUIC_CONNECTION_EVENT_TYPE Type;
union {
struct {
BOOLEAN SessionResumed;
_Field_range_(>, 0)
uint8_t NegotiatedAlpnLength;
_Field_size_(NegotiatedAlpnLength)
const uint8_t* NegotiatedAlpn;
} CONNECTED;
struct {
QUIC_STATUS Status;
} SHUTDOWN_INITIATED_BY_TRANSPORT;
struct {
QUIC_UINT62 ErrorCode;
} SHUTDOWN_INITIATED_BY_PEER;
struct {
BOOLEAN HandshakeCompleted : 1;
BOOLEAN PeerAcknowledgedShutdown : 1;
BOOLEAN AppCloseInProgress : 1;
} SHUTDOWN_COMPLETE;
struct {
const QUIC_ADDR* Address;
} LOCAL_ADDRESS_CHANGED;
struct {
const QUIC_ADDR* Address;
} PEER_ADDRESS_CHANGED;
struct {
HQUIC Stream;
QUIC_STREAM_OPEN_FLAGS Flags;
} PEER_STREAM_STARTED;
struct {
uint16_t BidirectionalCount;
uint16_t UnidirectionalCount;
} STREAMS_AVAILABLE;
struct {
uint16_t IdealProcessor;
} IDEAL_PROCESSOR_CHANGED;
struct {
BOOLEAN SendEnabled;
uint16_t MaxSendLength;
} DATAGRAM_STATE_CHANGED;
struct {
const QUIC_BUFFER* Buffer;
QUIC_RECEIVE_FLAGS Flags;
} DATAGRAM_RECEIVED;
struct {
/* inout */ void* ClientContext;
QUIC_DATAGRAM_SEND_STATE State;
} DATAGRAM_SEND_STATE_CHANGED;
struct {
uint16_t ResumptionStateLength;
const uint8_t* ResumptionState;
} RESUMED;
struct {
_Field_range_(>, 0)
uint32_t ResumptionTicketLength;
_Field_size_(ResumptionTicketLength)
const uint8_t* ResumptionTicket;
} RESUMPTION_TICKET_RECEIVED;
struct {
QUIC_CERTIFICATE* Certificate; // Peer certificate (platform specific). Valid only during QUIC_CONNECTION_EVENT_PEER_CERTIFICATE_RECEIVED callback.
uint32_t DeferredErrorFlags; // Bit flag of errors (only valid with QUIC_CREDENTIAL_FLAG_DEFER_CERTIFICATE_VALIDATION) - Schannel only, zero otherwise.
QUIC_STATUS DeferredStatus; // Most severe error status (only valid with QUIC_CREDENTIAL_FLAG_DEFER_CERTIFICATE_VALIDATION)
QUIC_CERTIFICATE_CHAIN* Chain; // Peer certificate chain (platform specific). Valid only during QUIC_CONNECTION_EVENT_PEER_CERTIFICATE_RECEIVED callback.
} PEER_CERTIFICATE_RECEIVED;
};
} QUIC_CONNECTION_EVENT;
typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
_Function_class_(QUIC_CONNECTION_CALLBACK)
QUIC_STATUS
(QUIC_API QUIC_CONNECTION_CALLBACK)(
_In_ HQUIC Connection,
_In_opt_ void* Context,
_Inout_ QUIC_CONNECTION_EVENT* Event
);
typedef QUIC_CONNECTION_CALLBACK *QUIC_CONNECTION_CALLBACK_HANDLER;
//
// Opens a new connection.
//
typedef
_IRQL_requires_max_(DISPATCH_LEVEL)
QUIC_STATUS
(QUIC_API * QUIC_CONNECTION_OPEN_FN)(
_In_ _Pre_defensive_ HQUIC Registration,
_In_ _Pre_defensive_ QUIC_CONNECTION_CALLBACK_HANDLER Handler,
_In_opt_ void* Context,
_Outptr_ _At_(*Connection, __drv_allocatesMem(Mem)) _Pre_defensive_
HQUIC* Connection
);
//