Lines Matching refs:frame

62 void nghttp2_frame_headers_init(nghttp2_headers *frame, uint8_t flags,
66 nghttp2_frame_hd_init(&frame->hd, 0, NGHTTP2_HEADERS, flags, stream_id);
67 frame->padlen = 0;
68 frame->nva = nva;
69 frame->nvlen = nvlen;
70 frame->cat = cat;
73 frame->pri_spec = *pri_spec;
75 nghttp2_priority_spec_default_init(&frame->pri_spec);
79 void nghttp2_frame_headers_free(nghttp2_headers *frame, nghttp2_mem *mem) {
80 nghttp2_nv_array_del(frame->nva, mem);
83 void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id,
85 nghttp2_frame_hd_init(&frame->hd, NGHTTP2_PRIORITY_SPECLEN, NGHTTP2_PRIORITY,
87 frame->pri_spec = *pri_spec;
90 void nghttp2_frame_priority_free(nghttp2_priority *frame) { (void)frame; }
92 void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame, int32_t stream_id,
94 nghttp2_frame_hd_init(&frame->hd, 4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE,
96 frame->error_code = error_code;
99 void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame) { (void)frame; }
101 void nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags,
103 nghttp2_frame_hd_init(&frame->hd, niv * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH,
105 frame->niv = niv;
106 frame->iv = iv;
109 void nghttp2_frame_settings_free(nghttp2_settings *frame, nghttp2_mem *mem) {
110 nghttp2_mem_free(mem, frame->iv);
113 void nghttp2_frame_push_promise_init(nghttp2_push_promise *frame, uint8_t flags,
117 nghttp2_frame_hd_init(&frame->hd, 0, NGHTTP2_PUSH_PROMISE, flags, stream_id);
118 frame->padlen = 0;
119 frame->nva = nva;
120 frame->nvlen = nvlen;
121 frame->promised_stream_id = promised_stream_id;
122 frame->reserved = 0;
125 void nghttp2_frame_push_promise_free(nghttp2_push_promise *frame,
127 nghttp2_nv_array_del(frame->nva, mem);
130 void nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags,
132 nghttp2_frame_hd_init(&frame->hd, 8, NGHTTP2_PING, flags, 0);
134 memcpy(frame->opaque_data, opaque_data, sizeof(frame->opaque_data));
136 memset(frame->opaque_data, 0, sizeof(frame->opaque_data));
140 void nghttp2_frame_ping_free(nghttp2_ping *frame) { (void)frame; }
142 void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
145 nghttp2_frame_hd_init(&frame->hd, 8 + opaque_data_len, NGHTTP2_GOAWAY,
147 frame->last_stream_id = last_stream_id;
148 frame->error_code = error_code;
149 frame->opaque_data = opaque_data;
150 frame->opaque_data_len = opaque_data_len;
151 frame->reserved = 0;
154 void nghttp2_frame_goaway_free(nghttp2_goaway *frame, nghttp2_mem *mem) {
155 nghttp2_mem_free(mem, frame->opaque_data);
158 void nghttp2_frame_window_update_init(nghttp2_window_update *frame,
161 nghttp2_frame_hd_init(&frame->hd, 4, NGHTTP2_WINDOW_UPDATE, flags, stream_id);
162 frame->window_size_increment = window_size_increment;
163 frame->reserved = 0;
166 void nghttp2_frame_window_update_free(nghttp2_window_update *frame) {
167 (void)frame;
170 size_t nghttp2_frame_trail_padlen(nghttp2_frame *frame, size_t padlen) {
171 /* We have iframe->padlen == 0, but iframe->frame.hd.flags may have
173 CONTINUATION frame, since we don't reset flags after HEADERS was
178 return padlen - ((frame->hd.flags & NGHTTP2_FLAG_PADDED) > 0);
181 void nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags,
183 /* At this moment, the length of DATA frame is unknown */
184 nghttp2_frame_hd_init(&frame->hd, 0, NGHTTP2_DATA, flags, stream_id);
185 frame->padlen = 0;
188 void nghttp2_frame_data_free(nghttp2_data *frame) { (void)frame; }
190 void nghttp2_frame_extension_init(nghttp2_extension *frame, uint8_t type,
193 nghttp2_frame_hd_init(&frame->hd, 0, type, flags, stream_id);
194 frame->payload = payload;
197 void nghttp2_frame_extension_free(nghttp2_extension *frame) { (void)frame; }
199 void nghttp2_frame_altsvc_init(nghttp2_extension *frame, int32_t stream_id,
204 nghttp2_frame_hd_init(&frame->hd, 2 + origin_len + field_value_len,
207 altsvc = frame->payload;
214 void nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem) {
217 altsvc = frame->payload;
226 void nghttp2_frame_origin_init(nghttp2_extension *frame,
236 nghttp2_frame_hd_init(&frame->hd, payloadlen, NGHTTP2_ORIGIN,
239 origin = frame->payload;
244 void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem) {
247 origin = frame->payload;
256 void nghttp2_frame_priority_update_init(nghttp2_extension *frame,
261 nghttp2_frame_hd_init(&frame->hd, 4 + field_value_len,
264 priority_update = frame->payload;
270 void nghttp2_frame_priority_update_free(nghttp2_extension *frame,
274 priority_update = frame->payload;
289 size_t nghttp2_frame_headers_payload_nv_offset(nghttp2_headers *frame) {
290 return nghttp2_frame_priority_len(frame->hd.flags);
295 * changing buf->pos and serializing frame header.
298 * frame(s).
300 * This function serializes frame header for HEADERS/PUSH_PROMISE and
318 /* We have multiple frame buffers, which means one or more
319 CONTINUATION frame is involved. Remove END_HEADERS flag from the
320 first frame. */
361 int nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame,
369 nv_offset = nghttp2_frame_headers_payload_nv_offset(frame);
377 rv = nghttp2_hd_deflate_hd_bufs(deflater, bufs, frame->nva, frame->nvlen);
389 if (frame->hd.flags & NGHTTP2_FLAG_PRIORITY) {
390 nghttp2_frame_pack_priority_spec(buf->pos, &frame->pri_spec);
393 frame->padlen = 0;
394 frame->hd.length = nghttp2_bufs_len(bufs);
396 return frame_pack_headers_shared(bufs, &frame->hd);
421 void nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame,
423 if (frame->hd.flags & NGHTTP2_FLAG_PRIORITY) {
424 nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload);
426 nghttp2_priority_spec_default_init(&frame->pri_spec);
429 frame->nva = NULL;
430 frame->nvlen = 0;
433 void nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) {
444 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
446 nghttp2_frame_pack_priority_spec(buf->last, &frame->pri_spec);
451 void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame,
453 nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload);
457 nghttp2_rst_stream *frame) {
468 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
470 nghttp2_put_uint32be(buf->last, frame->error_code);
474 void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame,
476 frame->error_code = nghttp2_get_uint32(payload);
479 int nghttp2_frame_pack_settings(nghttp2_bufs *bufs, nghttp2_settings *frame) {
486 if (nghttp2_buf_avail(buf) < frame->hd.length) {
492 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
495 nghttp2_frame_pack_settings_payload(buf->last, frame->iv, frame->niv);
511 void nghttp2_frame_unpack_settings_payload(nghttp2_settings *frame,
514 frame->iv = iv;
515 frame->niv = niv;
555 nghttp2_push_promise *frame,
569 rv = nghttp2_hd_deflate_hd_bufs(deflater, bufs, frame->nva, frame->nvlen);
581 nghttp2_put_uint32be(buf->pos, (uint32_t)frame->promised_stream_id);
583 frame->padlen = 0;
584 frame->hd.length = nghttp2_bufs_len(bufs);
586 return frame_pack_headers_shared(bufs, &frame->hd);
589 void nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame,
591 frame->promised_stream_id =
593 frame->nva = NULL;
594 frame->nvlen = 0;
597 void nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame) {
608 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
611 nghttp2_cpymem(buf->last, frame->opaque_data, sizeof(frame->opaque_data));
614 void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame,
616 memcpy(frame->opaque_data, payload, sizeof(frame->opaque_data));
619 int nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame) {
629 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
631 nghttp2_put_uint32be(buf->last, (uint32_t)frame->last_stream_id);
634 nghttp2_put_uint32be(buf->last, frame->error_code);
637 rv = nghttp2_bufs_add(bufs, frame->opaque_data, frame->opaque_data_len);
650 void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame,
654 frame->last_stream_id = nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK;
655 frame->error_code = nghttp2_get_uint32(payload + 4);
657 frame->opaque_data = var_gift_payload;
658 frame->opaque_data_len = var_gift_payloadlen;
661 int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame,
685 nghttp2_frame_unpack_goaway_payload(frame, payload, var_gift_payload,
692 nghttp2_window_update *frame) {
703 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
705 nghttp2_put_uint32be(buf->last, (uint32_t)frame->window_size_increment);
709 void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame,
711 frame->window_size_increment =
715 void nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) {
723 altsvc = frame->payload;
732 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
746 void nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame,
752 altsvc = frame->payload;
765 int nghttp2_frame_unpack_altsvc_payload2(nghttp2_extension *frame,
784 nghttp2_frame_unpack_altsvc_payload(frame, origin_len, buf, payloadlen - 2);
789 int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *frame) {
795 origin = frame->payload;
799 if (nghttp2_buf_avail(buf) < frame->hd.length) {
805 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
814 assert(nghttp2_buf_len(buf) == NGHTTP2_FRAME_HDLEN + frame->hd.length);
819 int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
830 origin = frame->payload;
892 nghttp2_extension *frame) {
900 priority_update = frame->payload;
908 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
919 void nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame,
926 priority_update = frame->payload;
1197 * We arranged padding so that it is included in the first frame
1198 * completely. For padded frame, we are going to adjust buf->pos of
1199 * frame which includes padding and serialize (memmove) frame header