diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index af83419f..b6327bf1 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -262,7 +262,7 @@ ssize_t nghttp2_frame_pack_headers(nghttp2_buf *buf, /* Don't use buf->last, since it already points to the end of the frame */ - memset(buf->pos, 0, NGHTTP2_FRAME_HEAD_LENGTH); + memset(buf->pos, 0, NGHTTP2_FRAME_HDLEN); /* pack ctrl header after length is determined */ if(NGHTTP2_MAX_FRAME_LENGTH < frame->hd.length) { @@ -301,7 +301,7 @@ int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, ssize_t nghttp2_frame_pack_priority(nghttp2_buf *buf, nghttp2_priority *frame) { - ssize_t framelen= NGHTTP2_FRAME_HEAD_LENGTH + 4; + ssize_t framelen= NGHTTP2_FRAME_HDLEN + 4; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -332,7 +332,7 @@ void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, ssize_t nghttp2_frame_pack_rst_stream(nghttp2_buf *buf, nghttp2_rst_stream *frame) { - ssize_t framelen = NGHTTP2_FRAME_HEAD_LENGTH + 4; + ssize_t framelen = NGHTTP2_FRAME_HDLEN + 4; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -363,7 +363,7 @@ void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame, ssize_t nghttp2_frame_pack_settings(nghttp2_buf *buf, nghttp2_settings *frame) { - ssize_t framelen = NGHTTP2_FRAME_HEAD_LENGTH + frame->hd.length; + ssize_t framelen = NGHTTP2_FRAME_HDLEN + frame->hd.length; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -471,7 +471,7 @@ ssize_t nghttp2_frame_pack_push_promise(nghttp2_buf *buf, /* Don't use buf->last, since it already points to the end of the frame */ - memset(buf->pos, 0, NGHTTP2_FRAME_HEAD_LENGTH); + memset(buf->pos, 0, NGHTTP2_FRAME_HDLEN); /* pack ctrl header after length is determined */ if(NGHTTP2_MAX_FRAME_LENGTH < frame->hd.length) { @@ -505,7 +505,7 @@ int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, ssize_t nghttp2_frame_pack_ping(nghttp2_buf *buf, nghttp2_ping *frame) { - ssize_t framelen = NGHTTP2_FRAME_HEAD_LENGTH + 8; + ssize_t framelen = NGHTTP2_FRAME_HDLEN + 8; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -535,7 +535,7 @@ void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame, ssize_t nghttp2_frame_pack_goaway(nghttp2_buf *buf, nghttp2_goaway *frame) { - ssize_t framelen = NGHTTP2_FRAME_HEAD_LENGTH + frame->hd.length; + ssize_t framelen = NGHTTP2_FRAME_HDLEN + frame->hd.length; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -576,7 +576,7 @@ void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame, ssize_t nghttp2_frame_pack_window_update(nghttp2_buf *buf, nghttp2_window_update *frame) { - ssize_t framelen = NGHTTP2_FRAME_HEAD_LENGTH + 4; + ssize_t framelen = NGHTTP2_FRAME_HDLEN + 4; int rv; assert(nghttp2_buf_len(buf) == 0); @@ -752,7 +752,7 @@ void nghttp2_frame_set_pad(nghttp2_buf *buf, uint8_t *flags_ptr, size_t padlen) /* Consume previous 2 bytes, shifting 2 bytes to the left */ nghttp2_buf_shift_left(buf, 2); - p = buf->pos + NGHTTP2_FRAME_HEAD_LENGTH; + p = buf->pos + NGHTTP2_FRAME_HDLEN; *p++ = trail_padlen >> 8; *p = trail_padlen & 0xff; @@ -765,6 +765,6 @@ void nghttp2_frame_set_pad(nghttp2_buf *buf, uint8_t *flags_ptr, size_t padlen) trail_padlen = padlen - 1; *flags_ptr |= NGHTTP2_FLAG_PAD_LOW; - *(buf->pos + NGHTTP2_FRAME_HEAD_LENGTH) = trail_padlen; + *(buf->pos + NGHTTP2_FRAME_HDLEN) = trail_padlen; } } diff --git a/lib/nghttp2_frame.h b/lib/nghttp2_frame.h index e0ef24c6..d74ea0bc 100644 --- a/lib/nghttp2_frame.h +++ b/lib/nghttp2_frame.h @@ -51,7 +51,6 @@ /* The number of bytes of frame header. */ #define NGHTTP2_FRAME_HDLEN 8 -#define NGHTTP2_FRAME_HEAD_LENGTH NGHTTP2_FRAME_HDLEN /* The number of bytes for each SETTINGS entry */ #define NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH 5 diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 13d4b619..444200b4 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -185,7 +185,7 @@ static void nghttp2_inbound_frame_reset(nghttp2_session *session) } memset(&iframe->frame, 0, sizeof(nghttp2_frame)); iframe->state = NGHTTP2_IB_READ_HEAD; - iframe->left = NGHTTP2_FRAME_HEAD_LENGTH; + iframe->left = NGHTTP2_FRAME_HDLEN; iframe->niv = 0; iframe->payloadleft = 0; iframe->padlen = 0; @@ -1614,7 +1614,7 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session) cont_hd.flags = NGHTTP2_FLAG_NONE; /* Reuse previous buffers for frame header */ - framebuf->pos -= NGHTTP2_FRAME_HEAD_LENGTH; + framebuf->pos -= NGHTTP2_FRAME_HDLEN; if(cont_hd.length + framebuf->mark == framebuf->last) { size_t padlen; @@ -1973,7 +1973,7 @@ ssize_t nghttp2_session_mem_send(nghttp2_session *session, NGHTTP2_MAX_FRAME_LENGTH */ frame = nghttp2_outbound_item_get_ctrl_frame(item); - framebuf->mark = framebuf->pos + NGHTTP2_FRAME_HEAD_LENGTH + + framebuf->mark = framebuf->pos + NGHTTP2_FRAME_HDLEN + nghttp2_get_uint16(framebuf->pos); rv = session_call_before_frame_send(session, frame); @@ -4072,7 +4072,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, iframe->frame.hd.flags &= ~(NGHTTP2_FLAG_PAD_HIGH | NGHTTP2_FLAG_PAD_LOW); if((iframe->frame.hd.flags & NGHTTP2_FLAG_END_HEADERS) == 0) { - inbound_frame_reset_left(iframe, NGHTTP2_FRAME_HEAD_LENGTH); + inbound_frame_reset_left(iframe, NGHTTP2_FRAME_HDLEN); iframe->padlen = 0; if(iframe->state == NGHTTP2_IB_READ_HEADER_BLOCK) { iframe->state = NGHTTP2_IB_EXPECT_CONTINUATION; @@ -4654,7 +4654,7 @@ ssize_t nghttp2_session_pack_data(nghttp2_session *session, the correct flags */ frame->hd.flags |= flags; - memset(buf->pos, 0, NGHTTP2_FRAME_HEAD_LENGTH); + memset(buf->pos, 0, NGHTTP2_FRAME_HDLEN); hd = frame->hd; hd.flags = flags; diff --git a/tests/failmalloc_test.c b/tests/failmalloc_test.c index 9fd5a19a..415b53f5 100644 --- a/tests/failmalloc_test.c +++ b/tests/failmalloc_test.c @@ -436,9 +436,9 @@ static void run_nghttp2_frame_pack_settings(void) goto fail; } rv = nghttp2_frame_unpack_settings(&oframe.settings, - &buf[0], NGHTTP2_FRAME_HEAD_LENGTH, - &buf[NGHTTP2_FRAME_HEAD_LENGTH], - framelen-NGHTTP2_FRAME_HEAD_LENGTH); + &buf[0], NGHTTP2_FRAME_HDLEN, + &buf[NGHTTP2_FRAME_HDLEN], + framelen-NGHTTP2_FRAME_HDLEN); if(rv != 0) { goto fail; } diff --git a/tests/nghttp2_frame_test.c b/tests/nghttp2_frame_test.c index 6a8817f0..c36933a6 100644 --- a/tests/nghttp2_frame_test.c +++ b/tests/nghttp2_frame_test.c @@ -257,7 +257,7 @@ void test_nghttp2_frame_pack_settings() nghttp2_frame_iv_copy(iv, 3), 3); framelen = nghttp2_frame_pack_settings(&buf, &frame); - CU_ASSERT(NGHTTP2_FRAME_HEAD_LENGTH + + CU_ASSERT(NGHTTP2_FRAME_HDLEN + 3 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH == framelen); CU_ASSERT(framelen == nghttp2_buf_len(&buf)); diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index d7a68352..54f756f2 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -734,7 +734,7 @@ void test_nghttp2_session_recv_continuation(void) cont_hd.stream_id = 1; nghttp2_frame_pack_frame_hd(data + datalen, &cont_hd); - datalen += NGHTTP2_FRAME_HEAD_LENGTH; + datalen += NGHTTP2_FRAME_HDLEN; memcpy(data + datalen, buf.pos, cont_hd.length); datalen += cont_hd.length; @@ -918,7 +918,7 @@ void test_nghttp2_session_continue(void) recv_frame = user_data.frame; CU_ASSERT(NGHTTP2_HEADERS == recv_frame->hd.type); - CU_ASSERT(framelen1 - NGHTTP2_FRAME_HEAD_LENGTH == recv_frame->hd.length); + CU_ASSERT(framelen1 - NGHTTP2_FRAME_HDLEN == recv_frame->hd.length); CU_ASSERT(1 == user_data.begin_headers_cb_called); CU_ASSERT(1 == user_data.header_cb_called); @@ -950,7 +950,7 @@ void test_nghttp2_session_continue(void) recv_frame = user_data.frame; CU_ASSERT(NGHTTP2_HEADERS == recv_frame->hd.type); - CU_ASSERT(framelen2 - NGHTTP2_FRAME_HEAD_LENGTH == recv_frame->hd.length); + CU_ASSERT(framelen2 - NGHTTP2_FRAME_HDLEN == recv_frame->hd.length); CU_ASSERT(1 == user_data.begin_headers_cb_called); CU_ASSERT(1 == user_data.header_cb_called); @@ -1002,7 +1002,7 @@ void test_nghttp2_session_continue(void) rv = nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); - CU_ASSERT(16 + NGHTTP2_FRAME_HEAD_LENGTH == rv); + CU_ASSERT(16 + NGHTTP2_FRAME_HDLEN == rv); CU_ASSERT(0 == user_data.frame_recv_cb_called); /* Next nghttp2_session_mem_recv invokes on_frame_recv_callback and @@ -1011,7 +1011,7 @@ void test_nghttp2_session_continue(void) user_data.frame_recv_cb_called = 0; rv = nghttp2_session_mem_recv(session, databuf.pos, nghttp2_buf_len(&databuf)); - CU_ASSERT(16 + NGHTTP2_FRAME_HEAD_LENGTH == rv); + CU_ASSERT(16 + NGHTTP2_FRAME_HDLEN == rv); CU_ASSERT(1 == user_data.frame_recv_cb_called); /* And finally call on_frame_recv_callback with 0 size input */ @@ -3638,10 +3638,10 @@ void test_nghttp2_session_flow_control_data_recv(void) hd.flags = NGHTTP2_FLAG_END_STREAM; hd.stream_id = 1; nghttp2_frame_pack_frame_hd(data, &hd); - CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HEAD_LENGTH == + CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HDLEN == nghttp2_session_mem_recv(session, data, NGHTTP2_MAX_FRAME_LENGTH + - NGHTTP2_FRAME_HEAD_LENGTH)); + NGHTTP2_FRAME_HDLEN)); item = nghttp2_session_get_next_ob_item(session); /* Since this is the last frame, stream-level WINDOW_UPDATE is not @@ -3658,10 +3658,10 @@ void test_nghttp2_session_flow_control_data_recv(void) RST_STREAM is issued by the remote, but the local side keeps sending DATA frames. Without calculating connection-level window, the subsequent flow control gets confused. */ - CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HEAD_LENGTH == + CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HDLEN == nghttp2_session_mem_recv(session, data, NGHTTP2_MAX_FRAME_LENGTH + - NGHTTP2_FRAME_HEAD_LENGTH)); + NGHTTP2_FRAME_HDLEN)); item = nghttp2_session_get_next_ob_item(session); CU_ASSERT(NGHTTP2_WINDOW_UPDATE == OB_CTRL_TYPE(item)); @@ -3699,12 +3699,12 @@ void test_nghttp2_session_flow_control_data_with_padding_recv(void) hd.stream_id = 1; nghttp2_frame_pack_frame_hd(data, &hd); /* Add 2 byte padding (PAD_LOW itself is padding) */ - data[NGHTTP2_FRAME_HEAD_LENGTH] = 1; - data[NGHTTP2_FRAME_HEAD_LENGTH + 1] = 1; + data[NGHTTP2_FRAME_HDLEN] = 1; + data[NGHTTP2_FRAME_HDLEN + 1] = 1; - CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HEAD_LENGTH + hd.length) == + CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + hd.length) == nghttp2_session_mem_recv(session, data, - NGHTTP2_FRAME_HEAD_LENGTH + hd.length)); + NGHTTP2_FRAME_HDLEN + hd.length)); CU_ASSERT((int32_t)hd.length == session->recv_window_size); CU_ASSERT((int32_t)hd.length == stream->recv_window_size); diff --git a/tests/nghttp2_test_helper.c b/tests/nghttp2_test_helper.c index ec2f18a7..a2a7c56a 100644 --- a/tests/nghttp2_test_helper.c +++ b/tests/nghttp2_test_helper.c @@ -36,8 +36,8 @@ int unpack_framebuf(nghttp2_frame *frame, nghttp2_buf *buf) int unpack_frame(nghttp2_frame *frame, const uint8_t *in, size_t len) { ssize_t rv = 0; - const uint8_t *payload = in + NGHTTP2_FRAME_HEAD_LENGTH; - size_t payloadlen = len - NGHTTP2_FRAME_HEAD_LENGTH; + const uint8_t *payload = in + NGHTTP2_FRAME_HDLEN; + size_t payloadlen = len - NGHTTP2_FRAME_HDLEN; size_t payloadoff; nghttp2_frame_unpack_frame_hd(&frame->hd, in);