Commit 68b5ffc1 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Rename padding related names

parent ce53d7bd
......@@ -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;
/**
......
......@@ -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. */
......
......@@ -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 */
......@@ -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;
}
......
......@@ -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 */
......
......@@ -66,7 +66,7 @@ const std::string NGHTTPD_SERVER = "nghttpd nghttp2/" NGHTTP2_VERSION;
Config::Config()
: data_ptr(nullptr),
output_upper_thres(1024*1024),
pad_alignment(NGHTTP2_PAD_ALIGNMENT),
padding_boundary(NGHTTP2_PADDING_BOUNDARY),
header_table_size(-1),
port(0),
verbose(false),
......@@ -365,11 +365,11 @@ int Http2Handler::on_connect()
nghttp2_opt_set opt_set;
memset(&opt_set, 0, sizeof(opt_set));
opt_set.pad_alignment = sessions_->get_config()->pad_alignment;
opt_set.padding_boundary = sessions_->get_config()->padding_boundary;
fill_callback(callbacks, sessions_->get_config());
r = nghttp2_session_server_new2(&session_, &callbacks, this,
NGHTTP2_OPT_PAD_ALIGNMENT, &opt_set);
NGHTTP2_OPT_PADDING_BOUNDARY, &opt_set);
if(r != 0) {
return r;
}
......
......@@ -56,7 +56,7 @@ struct Config {
std::string cert_file;
void *data_ptr;
size_t output_upper_thres;
size_t pad_alignment;
size_t padding_boundary;
ssize_t header_table_size;
uint16_t port;
bool verbose;
......
......@@ -82,7 +82,7 @@ struct Config {
std::string keyfile;
std::string datafile;
size_t output_upper_thres;
size_t pad_alignment;
size_t padding_boundary;
ssize_t peer_max_concurrent_streams;
ssize_t header_table_size;
int32_t pri;
......@@ -100,7 +100,7 @@ struct Config {
bool continuation;
Config()
: output_upper_thres(1024*1024),
pad_alignment(NGHTTP2_PAD_ALIGNMENT),
padding_boundary(NGHTTP2_PADDING_BOUNDARY),
peer_max_concurrent_streams(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS),
header_table_size(-1),
pri(NGHTTP2_PRI_DEFAULT),
......@@ -716,10 +716,10 @@ struct HttpClient {
}
nghttp2_opt_set opt_set;
opt_set.peer_max_concurrent_streams = config.peer_max_concurrent_streams;
opt_set.pad_alignment = config.pad_alignment;
opt_set.padding_boundary = config.padding_boundary;
rv = nghttp2_session_client_new2(&session, callbacks, this,
NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS |
NGHTTP2_OPT_PAD_ALIGNMENT,
NGHTTP2_OPT_PADDING_BOUNDARY,
&opt_set);
if(rv != 0) {
return -1;
......@@ -1710,8 +1710,8 @@ void print_help(std::ostream& out)
<< " is large enough as it is seen as unlimited.\n"
<< " -c, --header-table-size=<N>\n"
<< " Specify decoder header table size.\n"
<< " -b, --pad=<ALIGNMENT>\n"
<< " Alignment of frame payload padding.\n"
<< " -b, --padding=<BOUNDARY>\n"
<< " Padding boundary for frame payload.\n"
<< " --color Force colored log output.\n"
<< " --continuation Send large header to test CONTINUATION.\n"
<< std::endl;
......@@ -1740,7 +1740,7 @@ int main(int argc, char **argv)
{"pri", required_argument, nullptr, 'p'},
{"peer-max-concurrent-streams", required_argument, nullptr, 'M'},
{"header-table-size", required_argument, nullptr, 'c'},
{"data-pad", required_argument, nullptr, 'b'},
{"padding", required_argument, nullptr, 'b'},
{"cert", required_argument, &flag, 1},
{"key", required_argument, &flag, 2},
{"color", no_argument, &flag, 3},
......@@ -1766,7 +1766,7 @@ int main(int argc, char **argv)
print_help(std::cout);
exit(EXIT_SUCCESS);
case 'b':
config.pad_alignment = strtol(optarg, nullptr, 10);
config.padding_boundary = strtol(optarg, nullptr, 10);
break;
case 'n':
config.null_out = true;
......
......@@ -115,8 +115,8 @@ void print_help(std::ostream& out)
<< " -p/=/foo.png -p/doc=/bar.css\n"
<< " PATH and PUSH_PATHs are relative to document\n"
<< " root. See --htdocs option.\n"
<< " -b, --pad=<ALIGNMENT>\n"
<< " Alignment of frame payload padding.\n"
<< " -b, --padding=<BOUNDARY>\n"
<< " Padding boundary for frame payload.\n"
<< " -h, --help Print this help.\n"
<< std::endl;
}
......@@ -136,7 +136,7 @@ int main(int argc, char **argv)
{"verify-client", no_argument, nullptr, 'V'},
{"header-table-size", required_argument, nullptr, 'c'},
{"push", required_argument, nullptr, 'p'},
{"data-pad", required_argument, nullptr, 'b'},
{"padding", required_argument, nullptr, 'b'},
{"no-tls", no_argument, &flag, 1},
{"color", no_argument, &flag, 2},
{nullptr, 0, nullptr, 0}
......@@ -155,7 +155,7 @@ int main(int argc, char **argv)
config.verify_client = true;
break;
case 'b':
config.pad_alignment = strtol(optarg, nullptr, 10);
config.padding_boundary = strtol(optarg, nullptr, 10);
break;
case 'd':
config.htdocs = optarg;
......
......@@ -3870,7 +3870,7 @@ void test_nghttp2_session_pack_data_with_padding(void)
data_prd.read_callback = fixed_length_data_source_read_callback;
nghttp2_session_client_new(&session, &callbacks, &ud);
session->pad_alignment = 512;
session->padding_boundary = 512;
nghttp2_submit_request(session, NGHTTP2_PRI_DEFAULT, NULL, 0, &data_prd,
NULL);
......@@ -3881,7 +3881,7 @@ void test_nghttp2_session_pack_data_with_padding(void)
CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type);
frame = OB_DATA(session->aob.item);
CU_ASSERT(session->pad_alignment - datalen == frame->padlen);
CU_ASSERT(session->padding_boundary - datalen == frame->padlen);
CU_ASSERT(frame->hd.flags & NGHTTP2_FLAG_PAD_LOW);
CU_ASSERT(frame->hd.flags & NGHTTP2_FLAG_PAD_HIGH);
......@@ -3905,7 +3905,7 @@ void test_nghttp2_session_pack_data_with_padding(void)
CU_ASSERT(NGHTTP2_HEADERS == ud.sent_frame_type);
frame = OB_DATA(session->aob.item);
CU_ASSERT((frame->padlen + datalen) % session->pad_alignment == 0);
CU_ASSERT((frame->padlen + datalen) % session->padding_boundary == 0);
CU_ASSERT(frame->hd.flags & NGHTTP2_FLAG_PAD_LOW);
CU_ASSERT(0 == (frame->hd.flags & NGHTTP2_FLAG_PAD_HIGH));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment