Fix DTLS_VERSION_xx() comparison macros for DTLS1_BAD_VER
DTLS version numbers are strange and backwards, except DTLS1_BAD_VER so we have to make a special case for it. This does leave us with a set of macros which will evaluate their arguments more than once, but it's not a public-facing API and it's not like this is the kind of thing where people will be using DTLS_VERSION_LE(x++, y) anyway. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
parent
e6027420b7
commit
ff4952896e
1 changed files with 7 additions and 4 deletions
|
@ -154,10 +154,13 @@
|
||||||
(c)[1]=(unsigned char)(((l)>> 8)&0xff), \
|
(c)[1]=(unsigned char)(((l)>> 8)&0xff), \
|
||||||
(c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3)
|
(c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3)
|
||||||
|
|
||||||
#define DTLS_VERSION_GT(v1, v2) ((v1) < (v2))
|
/* DTLS version numbers are strange because they're inverted. Except
|
||||||
#define DTLS_VERSION_GE(v1, v2) ((v1) <= (v2))
|
* for DTLS1_BAD_VER, which should be considered "lower" than the rest. */
|
||||||
#define DTLS_VERSION_LT(v1, v2) ((v1) > (v2))
|
#define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1))
|
||||||
#define DTLS_VERSION_LE(v1, v2) ((v1) >= (v2))
|
#define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2))
|
||||||
|
#define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2))
|
||||||
|
#define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2))
|
||||||
|
#define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2))
|
||||||
|
|
||||||
/* LOCAL STUFF */
|
/* LOCAL STUFF */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue