mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: quic: Add quic_max_int_by_size() function
This function returns the maximum integer which may be encoded with a number of bytes passed as parameter. Useful to precisely compute the number of bytes which may used to fulfill a buffer with lengths as QUIC enteger encoded prefixes for the number of following bytes.
This commit is contained in:
parent
9777ead2ed
commit
4fe7d8a5b2
@ -88,6 +88,23 @@ static inline size_t quic_int_getsize(uint64_t val)
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the maximum integer which may be encoded with <size> bytes */
|
||||
static inline size_t quic_max_int_by_size(int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 1:
|
||||
return QUIC_VARINT_1_BYTE_MAX;
|
||||
case 2:
|
||||
return QUIC_VARINT_2_BYTE_MAX;
|
||||
case 4:
|
||||
return QUIC_VARINT_4_BYTE_MAX;
|
||||
case 8:
|
||||
return QUIC_VARINT_8_BYTE_MAX;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decode a QUIC variable-length integer from <buf> buffer into <val>.
|
||||
* Note that the result is a 64-bits integer but with the less significant
|
||||
* 62 bits as relevant information. The most significant 2 remaining bits encode
|
||||
|
Loading…
x
Reference in New Issue
Block a user