aboutsummaryrefslogtreecommitdiff
path: root/ssl/packet_locl.h
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-09-20 14:47:44 +0100
committerMatt Caswell <matt@openssl.org>2016-09-20 14:47:44 +0100
commit08029dfa03c0ee3a50f373017143aaae5f87d17f (patch)
tree536a5df572e89053310d4b8a4fe6dee4ce56485b /ssl/packet_locl.h
parent85a7a5e6ef633d2b01ef9792463a36b507a35a6a (diff)
downloadopenssl-08029dfa03c0ee3a50f373017143aaae5f87d17f.zip
openssl-08029dfa03c0ee3a50f373017143aaae5f87d17f.tar.gz
openssl-08029dfa03c0ee3a50f373017143aaae5f87d17f.tar.bz2
Convert WPACKET_put_bytes to use convenience macros
All the other functions that take an argument for the number of bytes use convenience macros for this purpose. We should do the same with WPACKET_put_bytes(). Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r--ssl/packet_locl.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index 0ec5a38..c51d892 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);