Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Param Id's to not be overlapping #1758

Merged
merged 5 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/core/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,16 @@ MsQuicSetParam(
{
CXPLAT_PASSIVE_CODE();

if ((Param & 0xFC000000) != 0) {
// Has level embedded parameter
ThadHouse marked this conversation as resolved.
Show resolved Hide resolved
QUIC_PARAM_LEVEL ParamContainedLevel = ((Param >> 26) & 0x3F) - 1;
if (ParamContainedLevel != Level) {
return QUIC_STATUS_INVALID_PARAMETER;
ThadHouse marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
Param = QUIC_PARAM_GENERATOR(Level, Param);
}

if ((Handle == NULL) ^ (Level == QUIC_PARAM_LEVEL_GLOBAL)) {
return QUIC_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -1394,6 +1404,16 @@ MsQuicGetParam(
{
CXPLAT_PASSIVE_CODE();

if ((Param & 0xFC000000) != 0) {
// Has level embedded parameter
QUIC_PARAM_LEVEL ParamContainedLevel = ((Param >> 26) & 0x3F) - 1;
if (ParamContainedLevel != Level) {
return QUIC_STATUS_INVALID_PARAMETER;
}
} else {
Param = QUIC_PARAM_GENERATOR(Level, Param);
}

if (((Handle == NULL) ^ (Level == QUIC_PARAM_LEVEL_GLOBAL)) ||
BufferLength == NULL) {
return QUIC_STATUS_INVALID_PARAMETER;
Expand Down
72 changes: 37 additions & 35 deletions src/inc/msquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,56 +593,58 @@ typedef enum QUIC_PARAM_LEVEL {
QUIC_PARAM_LEVEL_STREAM,
} QUIC_PARAM_LEVEL;

#define QUIC_PARAM_GENERATOR(Level, Value) (((Level + 1) & 0x3F) << 26 | (Value & 0x3FFFFFF))

//
// Parameters for QUIC_PARAM_LEVEL_GLOBAL.
//
#define QUIC_PARAM_GLOBAL_RETRY_MEMORY_PERCENT 0 // uint16_t
#define QUIC_PARAM_GLOBAL_SUPPORTED_VERSIONS 1 // uint32_t[] - network byte order
#define QUIC_PARAM_GLOBAL_LOAD_BALACING_MODE 2 // uint16_t - QUIC_LOAD_BALANCING_MODE
#define QUIC_PARAM_GLOBAL_PERF_COUNTERS 3 // uint64_t[] - Array size is QUIC_PERF_COUNTER_MAX
#define QUIC_PARAM_GLOBAL_SETTINGS 4 // QUIC_SETTINGS
#define QUIC_PARAM_GLOBAL_VERSION 5 // uint32_t[4]
#define QUIC_PARAM_GLOBAL_RETRY_MEMORY_PERCENT QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 0) // uint16_t
ThadHouse marked this conversation as resolved.
Show resolved Hide resolved
#define QUIC_PARAM_GLOBAL_SUPPORTED_VERSIONS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 1) // uint32_t[] - network byte order
#define QUIC_PARAM_GLOBAL_LOAD_BALACING_MODE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 2) // uint16_t - QUIC_LOAD_BALANCING_MODE
#define QUIC_PARAM_GLOBAL_PERF_COUNTERS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 3) // uint64_t[] - Array size is QUIC_PERF_COUNTER_MAX
#define QUIC_PARAM_GLOBAL_SETTINGS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 4) // QUIC_SETTINGS
#define QUIC_PARAM_GLOBAL_VERSION QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 5) // uint32_t[4]

//
// Parameters for QUIC_PARAM_LEVEL_REGISTRATION.
//
#define QUIC_PARAM_REGISTRATION_CID_PREFIX 0 // uint8_t[]
#define QUIC_PARAM_REGISTRATION_CID_PREFIX QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_REGISTRATION, 0) // uint8_t[]

//
// Parameters for QUIC_PARAM_LEVEL_CONFIGURATION.
//
#define QUIC_PARAM_CONFIGURATION_SETTINGS 0 // QUIC_SETTINGS
#define QUIC_PARAM_CONFIGURATION_TICKET_KEYS 1 // QUIC_TICKET_KEY_CONFIG[]
#define QUIC_PARAM_CONFIGURATION_SETTINGS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONFIGURATION, 0) // QUIC_SETTINGS
#define QUIC_PARAM_CONFIGURATION_TICKET_KEYS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONFIGURATION, 1) // QUIC_TICKET_KEY_CONFIG[]

//
// Parameters for QUIC_PARAM_LEVEL_LISTENER.
//
#define QUIC_PARAM_LISTENER_LOCAL_ADDRESS 0 // QUIC_ADDR
#define QUIC_PARAM_LISTENER_STATS 1 // QUIC_LISTENER_STATISTICS
#define QUIC_PARAM_LISTENER_LOCAL_ADDRESS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_LISTENER, 0) // QUIC_ADDR
#define QUIC_PARAM_LISTENER_STATS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_LISTENER, 1) // QUIC_LISTENER_STATISTICS

//
// Parameters for QUIC_PARAM_LEVEL_CONNECTION.
//
#define QUIC_PARAM_CONN_QUIC_VERSION 0 // uint32_t
#define QUIC_PARAM_CONN_LOCAL_ADDRESS 1 // QUIC_ADDR
#define QUIC_PARAM_CONN_REMOTE_ADDRESS 2 // QUIC_ADDR
#define QUIC_PARAM_CONN_IDEAL_PROCESSOR 3 // uint16_t
#define QUIC_PARAM_CONN_SETTINGS 4 // QUIC_SETTINGS
#define QUIC_PARAM_CONN_STATISTICS 5 // QUIC_STATISTICS
#define QUIC_PARAM_CONN_STATISTICS_PLAT 6 // QUIC_STATISTICS
#define QUIC_PARAM_CONN_SHARE_UDP_BINDING 7 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_LOCAL_BIDI_STREAM_COUNT 8 // uint16_t
#define QUIC_PARAM_CONN_LOCAL_UNIDI_STREAM_COUNT 9 // uint16_t
#define QUIC_PARAM_CONN_MAX_STREAM_IDS 10 // uint64_t[4]
#define QUIC_PARAM_CONN_CLOSE_REASON_PHRASE 11 // char[]
#define QUIC_PARAM_CONN_STREAM_SCHEDULING_SCHEME 12 // QUIC_STREAM_SCHEDULING_SCHEME
#define QUIC_PARAM_CONN_DATAGRAM_RECEIVE_ENABLED 13 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_DATAGRAM_SEND_ENABLED 14 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_QUIC_VERSION QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 0) // uint32_t
#define QUIC_PARAM_CONN_LOCAL_ADDRESS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 1) // QUIC_ADDR
#define QUIC_PARAM_CONN_REMOTE_ADDRESS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 2) // QUIC_ADDR
#define QUIC_PARAM_CONN_IDEAL_PROCESSOR QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 3) // uint16_t
#define QUIC_PARAM_CONN_SETTINGS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 4) // QUIC_SETTINGS
#define QUIC_PARAM_CONN_STATISTICS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 5) // QUIC_STATISTICS
#define QUIC_PARAM_CONN_STATISTICS_PLAT QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 6) // QUIC_STATISTICS
#define QUIC_PARAM_CONN_SHARE_UDP_BINDING QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 7) // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_LOCAL_BIDI_STREAM_COUNT QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 8) // uint16_t
#define QUIC_PARAM_CONN_LOCAL_UNIDI_STREAM_COUNT QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 9) // uint16_t
#define QUIC_PARAM_CONN_MAX_STREAM_IDS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 10) // uint64_t[4]
#define QUIC_PARAM_CONN_CLOSE_REASON_PHRASE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 11) // char[]
#define QUIC_PARAM_CONN_STREAM_SCHEDULING_SCHEME QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 12) // QUIC_STREAM_SCHEDULING_SCHEME
#define QUIC_PARAM_CONN_DATAGRAM_RECEIVE_ENABLED QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 13) // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_DATAGRAM_SEND_ENABLED QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 14) // uint8_t (BOOLEAN)
#ifdef QUIC_API_ENABLE_INSECURE_FEATURES
#define QUIC_PARAM_CONN_DISABLE_1RTT_ENCRYPTION 15 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_DISABLE_1RTT_ENCRYPTION QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 15) // uint8_t (BOOLEAN)
#endif
#define QUIC_PARAM_CONN_RESUMPTION_TICKET 16 // uint8_t[]
#define QUIC_PARAM_CONN_PEER_CERTIFICATE_VALID 17 // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_RESUMPTION_TICKET QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 16) // uint8_t[]
#define QUIC_PARAM_CONN_PEER_CERTIFICATE_VALID QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 17) // uint8_t (BOOLEAN)

//
// Parameters for QUIC_PARAM_LEVEL_TLS.
Expand All @@ -652,17 +654,17 @@ 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 0x1000000 // QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W
#define QUIC_PARAM_TLS_SCHANNEL_CONTEXT_ATTRIBUTE_W QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_TLS, 0x1000000) // QUIC_SCHANNEL_CONTEXT_ATTRIBUTE_W
#endif
#define QUIC_PARAM_TLS_HANDSHAKE_INFO 0 // QUIC_HANDSHAKE_INFO
#define QUIC_PARAM_TLS_NEGOTIATED_ALPN 1 // uint8_t[] (max 255 bytes)
#define QUIC_PARAM_TLS_HANDSHAKE_INFO QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_TLS, 0) // QUIC_HANDSHAKE_INFO
#define QUIC_PARAM_TLS_NEGOTIATED_ALPN QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_TLS, 1) // uint8_t[] (max 255 bytes)

//
// Parameters for QUIC_PARAM_LEVEL_STREAM.
//
#define QUIC_PARAM_STREAM_ID 0 // QUIC_UINT62
#define QUIC_PARAM_STREAM_0RTT_LENGTH 1 // uint64_t
#define QUIC_PARAM_STREAM_IDEAL_SEND_BUFFER_SIZE 2 // uint64_t - bytes
#define QUIC_PARAM_STREAM_ID QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_STREAM, 0) // QUIC_UINT62
#define QUIC_PARAM_STREAM_0RTT_LENGTH QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_STREAM, 1) // uint64_t
#define QUIC_PARAM_STREAM_IDEAL_SEND_BUFFER_SIZE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_STREAM, 2) // uint64_t - bytes

typedef
_IRQL_requires_max_(PASSIVE_LEVEL)
Expand Down
14 changes: 7 additions & 7 deletions src/inc/msquicp.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ typedef struct CXPLAT_TLS_SECRETS {
// The different private parameters for QUIC_PARAM_LEVEL_GLOBAL.
//

#define QUIC_PARAM_GLOBAL_TEST_DATAPATH_HOOKS 0x80000001 // QUIC_TEST_DATAPATH_HOOKS*
#define QUIC_PARAM_GLOBAL_ALLOC_FAIL_DENOMINATOR 0x80000002 // uint32_t
#define QUIC_PARAM_GLOBAL_ALLOC_FAIL_CYCLE 0x80000003 // uint32_t
#define QUIC_PARAM_GLOBAL_TEST_DATAPATH_HOOKS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 0x1000001) // QUIC_TEST_DATAPATH_HOOKS*
#define QUIC_PARAM_GLOBAL_ALLOC_FAIL_DENOMINATOR QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 0x1000002) // uint32_t
#define QUIC_PARAM_GLOBAL_ALLOC_FAIL_CYCLE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_GLOBAL, 0x1000003) // uint32_t

//
// The different private parameters for QUIC_PARAM_LEVEL_CONNECTION.
//

#define QUIC_PARAM_CONN_FORCE_KEY_UPDATE 0x80000001 // No payload
#define QUIC_PARAM_CONN_FORCE_CID_UPDATE 0x80000002 // No payload
#define QUIC_PARAM_CONN_TEST_TRANSPORT_PARAMETER 0x80000003 // QUIC_PRIVATE_TRANSPORT_PARAMETER
#define QUIC_PARAM_CONN_TLS_SECRETS 0x80000004 // CXPLAT_TLS_SECRETS (SSLKEYLOGFILE compatible)
#define QUIC_PARAM_CONN_FORCE_KEY_UPDATE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 0x1000001) // No payload
#define QUIC_PARAM_CONN_FORCE_CID_UPDATE QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 0x1000002) // No payload
#define QUIC_PARAM_CONN_TEST_TRANSPORT_PARAMETER QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 0x1000003) // QUIC_PRIVATE_TRANSPORT_PARAMETER
#define QUIC_PARAM_CONN_TLS_SECRETS QUIC_PARAM_GENERATOR(QUIC_PARAM_LEVEL_CONNECTION, 0x1000004) // CXPLAT_TLS_SECRETS (SSLKEYLOGFILE compatible)

#if defined(__cplusplus)
}
Expand Down