From e482074c96b6d6c19bacec13488ff77977670751 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 27 Jul 2017 13:37:23 +0200 Subject: [PATCH] MINOR: h2: add h2_set_frame_size() to update the size in a binary frame This function is called after preparing a frame, in order to update the frame's size in the frame header. It takes the frame payload length in argument. It simply writes a 24-bit frame size into a buffer, making use of the net_helper functions which try to optimize per platform (this is a frequently used operation). --- src/mux_h2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mux_h2.c b/src/mux_h2.c index 6268465d8..7cdf31c32 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -391,6 +392,15 @@ static inline void h2s_error(struct h2s *h2s, enum h2_err err) } } +/* writes the 24-bit frame size at address */ +static inline void h2_set_frame_size(void *frame, uint32_t len) +{ + uint8_t *out = frame; + + *out = len >> 16; + write_n16(out + 1, len); +} + /*********************************************************/ /* functions below are I/O callbacks from the connection */