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).
This commit is contained in:
Willy Tarreau
2017-07-27 13:37:23 +02:00
parent 2e43f08c60
commit e482074c96

View File

@@ -14,6 +14,7 @@
#include <common/config.h>
#include <common/h2.h>
#include <common/hpack-tbl.h>
#include <common/net_helper.h>
#include <proto/applet.h>
#include <proto/connection.h>
#include <proto/stream.h>
@@ -391,6 +392,15 @@ static inline void h2s_error(struct h2s *h2s, enum h2_err err)
}
}
/* writes the 24-bit frame size <len> at address <frame> */
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 */