From: Willy Tarreau Date: Thu, 27 Jul 2017 11:37:23 +0000 (+0200) Subject: MINOR: h2: add h2_set_frame_size() to update the size in a binary frame X-Git-Tag: v1.8-rc1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e482074c96b6d6c19bacec13488ff77977670751;p=thirdparty%2Fhaproxy.git 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). --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 6268465d8f..7cdf31c325 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 */