MINOR: quic-be: Correct Version Information transp. param encoding
According to the RFC, a QUIC client must encode the QUIC version it supports into the "Available Versions" of "Version Information" transport parameter order by descending preference. This is done defining <quic_version_2> and <quic_version_draft_29> new variables pointers to the corresponding version of <quic_versions> array elements. A client announces its available versions as follows: v1, v2, draft29.
This commit is contained in:
parent
cfa82a8606
commit
acbb56eac6
@ -228,6 +228,9 @@ struct quic_version {
|
||||
extern const struct quic_version quic_versions[];
|
||||
extern const size_t quic_versions_nb;
|
||||
extern const struct quic_version *preferred_version;
|
||||
extern const struct quic_version *quic_version_draft_29;
|
||||
extern const struct quic_version *quic_version_1;
|
||||
extern const struct quic_version *quic_version_2;
|
||||
|
||||
/* unused: 0x01 */
|
||||
/* Flag the packet number space as requiring an ACK frame to be sent. */
|
||||
|
@ -119,6 +119,10 @@ const struct quic_version quic_versions[] = {
|
||||
},
|
||||
};
|
||||
|
||||
const struct quic_version *quic_version_draft_29 = &quic_versions[0];
|
||||
const struct quic_version *quic_version_1 = &quic_versions[1];
|
||||
const struct quic_version *quic_version_2 = &quic_versions[2];
|
||||
|
||||
/* Function pointers, can be used to compute a hash from first generated CID and to derive new CIDs */
|
||||
uint64_t (*quic_hash64_from_cid)(const unsigned char *cid, int size, const unsigned char *secret, size_t secretlen) = NULL;
|
||||
void (*quic_newcid_from_hash64)(unsigned char *cid, int size, uint64_t hash, const unsigned char *secret, size_t secretlen) = NULL;
|
||||
|
@ -513,8 +513,21 @@ static int quic_transport_param_enc_version_info(unsigned char **buf,
|
||||
memcpy(*buf, &ver, sizeof ver);
|
||||
*buf += sizeof ver;
|
||||
/* For servers: all supported version, chosen included */
|
||||
for (i = 0; i < quic_versions_nb; i++) {
|
||||
ver = htonl(quic_versions[i].num);
|
||||
if (server) {
|
||||
for (i = 0; i < quic_versions_nb; i++) {
|
||||
ver = htonl(quic_versions[i].num);
|
||||
memcpy(*buf, &ver, sizeof ver);
|
||||
*buf += sizeof ver;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ver = htonl(quic_version_1->num);
|
||||
memcpy(*buf, &ver, sizeof ver);
|
||||
*buf += sizeof ver;
|
||||
ver = htonl(quic_version_2->num);
|
||||
memcpy(*buf, &ver, sizeof ver);
|
||||
*buf += sizeof ver;
|
||||
ver = htonl(quic_version_draft_29->num);
|
||||
memcpy(*buf, &ver, sizeof ver);
|
||||
*buf += sizeof ver;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user