From: Pauli Date: Wed, 25 Jun 2025 23:03:38 +0000 (+1000) Subject: packet: add new utility function PACKET_get_4_len() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19126fcf230dc0b7b2d2785ec5e851c97fb15f93;p=thirdparty%2Fopenssl.git packet: add new utility function PACKET_get_4_len() Get 4 bytes in network order from |pkt| and store the value in |*data| Similar to PACKET_get_net_4() except the data is uint32_t Reviewed-by: Viktor Dukhovni Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/27885) --- diff --git a/include/internal/packet.h b/include/internal/packet.h index 6fcd345ce28..7720167fca8 100644 --- a/include/internal/packet.h +++ b/include/internal/packet.h @@ -274,6 +274,25 @@ __owur static ossl_inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data) return ret; } +/** + * @brief Get 4 bytes in network order from |pkt| and store the value in |*data| + * Similar to PACKET_get_net_4() except the data is uint32_t + * + * @param pkt Contains a buffer to read from + * @param data The object to write the data to. + * @returns 1 on success, or 0 otherwise. + */ +static ossl_unused ossl_inline +int PACKET_get_net_4_len_u32(PACKET *pkt, uint32_t *data) +{ + size_t i = 0; + int ret = PACKET_get_net_4_len(pkt, &i); + + if (ret) + *data = (uint32_t)i; + return ret; +} + /* Get 8 bytes in network order from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_net_8(PACKET *pkt, uint64_t *data) {