Rename padding related names

This commit is contained in:
Tatsuhiro Tsujikawa
2014-02-09 21:46:15 +09:00
parent ce53d7bd9e
commit 68b5ffc1dc
10 changed files with 47 additions and 46 deletions

View File

@@ -151,9 +151,9 @@ typedef struct {
* @macro
*
* The default value of DATA padding alignment. See
* :member:`NGHTTP2_OPT_PAD_ALIGNMENT`.
* :member:`NGHTTP2_OPT_PADDING_BOUNDARY`.
*/
#define NGHTTP2_PAD_ALIGNMENT 16
#define NGHTTP2_PADDING_BOUNDARY 64
/**
* @enum
@@ -1341,7 +1341,7 @@ typedef enum {
* to this alignment. The option value must be greater than or equal
* to 8.
*/
NGHTTP2_OPT_PAD_ALIGNMENT = 1 << 3
NGHTTP2_OPT_PADDING_BOUNDARY = 1 << 3
} nghttp2_opt;
/**
@@ -1363,9 +1363,9 @@ typedef struct {
*/
uint8_t no_auto_connection_window_update;
/**
* :enum:`NGHTTP2_OPT_PAD_ALIGNMENT`
* :enum:`NGHTTP2_OPT_PADDING_BOUNDARY`
*/
uint16_t pad_alignment;
uint16_t padding_boundary;
} nghttp2_opt_set;
/**

View File

@@ -228,7 +228,7 @@ ssize_t nghttp2_frame_pack_headers(uint8_t **buf_ptr,
size_t *bufoff_ptr,
nghttp2_headers *frame,
nghttp2_hd_deflater *deflater,
size_t align)
size_t boundary)
{
size_t payloadoff = NGHTTP2_FRAME_HEAD_LENGTH + 2;
size_t nv_offset =
@@ -244,13 +244,13 @@ ssize_t nghttp2_frame_pack_headers(uint8_t **buf_ptr,
payloadlen = nghttp2_frame_headers_payload_nv_offset(frame) + rv;
if(align > 0) {
if(boundary > 0) {
ssize_t padlen;
padlen = nghttp2_frame_add_pad(buf_ptr, buflen_ptr, bufoff_ptr,
&frame->hd.flags,
payloadlen,
payloadlen + align,
align);
payloadlen + boundary,
boundary);
if(padlen < 0) {
return padlen;
}
@@ -665,11 +665,12 @@ ssize_t nghttp2_frame_add_pad(uint8_t **buf_ptr, size_t *buflen_ptr,
uint8_t *flags_ptr,
size_t payloadlen,
size_t payloadmax,
size_t align)
size_t boundary)
{
int rv;
size_t nextlen = nghttp2_min((payloadlen + align - 1) / align * align,
payloadmax);
size_t nextlen =
nghttp2_min((payloadlen + boundary - 1) / boundary * boundary,
payloadmax);
size_t padlen = nextlen - payloadlen;
size_t trail_padlen = 0;
/* extra 2 bytes for PAD_HIGH and PAD_LOW. */

View File

@@ -107,8 +107,8 @@ size_t nghttp2_frame_headers_payload_nv_offset(nghttp2_headers *frame);
* The first byte the frame is serialized is returned in the
* |*bufoff_ptr|.
*
* The |align| is used as padding alignment. If the |align| is zero,
* no padding is added.
* The |boundary| is used as padding boundary. If the |boundary| is
* zero, no padding is added.
*
* frame->hd.length is assigned after length is determined during
* packing process. If payload length is strictly larger than
@@ -132,7 +132,7 @@ ssize_t nghttp2_frame_pack_headers(uint8_t **buf_ptr,
size_t *bufoff_ptr,
nghttp2_headers *frame,
nghttp2_hd_deflater *deflater,
size_t align);
size_t boundary);
/*
* Unpacks HEADERS frame byte sequence into |frame|. This function
@@ -508,8 +508,8 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv);
* payload must start at offset NGHTTP2_FRAME_HEAD_LENGTH + 2 from
* |*buf_ptr| to account for PAD_HIGH and PAD_LOW. The maximum payload
* allowed is given in the |payloadmax|. The padding will not be made
* more than |payloadmax|. The padding alignment is given in the
* |align|.
* more than |payloadmax|. The padding boundary is given in the
* |boundary|.
*
* The |*flags_ptr| is updated to include NGHTTP2_FLAG_PAD_LOW and
* NGHTTP2_FLAG_PAD_HIGH based on the padding length. The
@@ -582,6 +582,6 @@ ssize_t nghttp2_frame_add_pad(uint8_t **buf_ptr, size_t *buflen_ptr,
uint8_t *flags_ptr,
size_t payloadlen,
size_t payloadmax,
size_t align);
size_t boundary);
#endif /* NGHTTP2_FRAME_H */

View File

@@ -224,11 +224,11 @@ static int nghttp2_session_new(nghttp2_session **session_ptr,
(*session_ptr)->opt_flags |=
NGHTTP2_OPTMASK_NO_AUTO_CONNECTION_WINDOW_UPDATE;
}
if((opt_set_mask & NGHTTP2_OPT_PAD_ALIGNMENT) &&
opt_set->pad_alignment >= 8) {
(*session_ptr)->pad_alignment = opt_set->pad_alignment;
if((opt_set_mask & NGHTTP2_OPT_PADDING_BOUNDARY) &&
opt_set->padding_boundary >= 8) {
(*session_ptr)->padding_boundary = opt_set->padding_boundary;
} else {
(*session_ptr)->pad_alignment = NGHTTP2_PAD_ALIGNMENT;
(*session_ptr)->padding_boundary = NGHTTP2_PADDING_BOUNDARY;
}
(*session_ptr)->remote_window_size = NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE;
@@ -1123,7 +1123,7 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
&session->aob.framebufoff,
&frame->headers,
&session->hd_deflater,
session->pad_alignment);
session->padding_boundary);
if(framebuflen < 0) {
return framebuflen;
}
@@ -4227,11 +4227,11 @@ ssize_t nghttp2_session_pack_data(nghttp2_session *session,
frame->hd.flags &= ~(NGHTTP2_FLAG_PAD_HIGH | NGHTTP2_FLAG_PAD_LOW);
flags = 0;
if(session->pad_alignment &&
if(session->padding_boundary &&
payloadlen > 0 && (size_t)payloadlen < datamax) {
rv = nghttp2_frame_add_pad(buf_ptr, buflen_ptr, bufoff_ptr,
&flags, payloadlen, datamax,
session->pad_alignment);
session->padding_boundary);
if(rv < 0) {
return rv;
}

View File

@@ -153,8 +153,8 @@ struct nghttp2_session {
size_t num_incoming_streams;
/* The number of bytes allocated for nvbuf */
size_t nvbuflen;
/* padding alignemnt. See NGHTTP2_OPT_PAD_ALIGNMENT. */
size_t pad_alignment;
/* padding alignemnt. See NGHTTP2_OPT_PADDING_BOUNDARY. */
size_t padding_boundary;
/* Next Stream ID. Made unsigned int to detect >= (1 << 31). */
uint32_t next_stream_id;
/* The largest stream ID received so far */