diff options
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r-- | ssl/packet_locl.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index 0ec5a389ce..c51d8922a8 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -701,9 +701,23 @@ int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, * Write the value stored in |val| into the WPACKET. The value will consume * |bytes| amount of storage. An error will occur if |val| cannot be * accommodated in |bytes| storage, e.g. attempting to write the value 256 into - * 1 byte will fail. + * 1 byte will fail. Don't call this directly. Use the convenience macros below + * instead. */ -int WPACKET_put_bytes(WPACKET *pkt, unsigned int val, size_t bytes); +int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t bytes); + +/* + * Convenience macros for calling WPACKET_put_bytes with different + * lengths + */ +#define WPACKET_put_bytes_u8(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 1) +#define WPACKET_put_bytes_u16(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 2) +#define WPACKET_put_bytes_u24(pkt, val) \ + WPACKET_put_bytes__((pkt), (val)), 3) +#define WPACKET_put_bytes_u32(pkt, val) \ + WPACKET_sub_allocate_bytes__((pkt), (val), 4) /* Set a maximum size that we will not allow the WPACKET to grow beyond */ int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); |