Lines Matching defs:buf
37 void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd) {
38 nghttp2_put_uint32be(&buf[0], (uint32_t)(hd->length << 8));
39 buf[3] = hd->type;
40 buf[4] = hd->flags;
41 nghttp2_put_uint32be(&buf[5], (uint32_t)hd->stream_id);
45 void nghttp2_frame_unpack_frame_hd(nghttp2_frame_hd *hd, const uint8_t *buf) {
46 hd->length = nghttp2_get_uint32(&buf[0]) >> 8;
47 hd->type = buf[3];
48 hd->flags = buf[4];
49 hd->stream_id = nghttp2_get_uint32(&buf[5]) & NGHTTP2_STREAM_ID_MASK;
295 * changing buf->pos and serializing frame header.
297 * This function assumes bufs->cur points to the last buf chain of the
307 nghttp2_buf *buf;
311 buf = &bufs->head->buf;
314 hd.length = nghttp2_buf_len(buf);
325 buf->pos -= NGHTTP2_FRAME_HDLEN;
326 nghttp2_frame_pack_frame_hd(buf->pos, &hd);
337 buf = &ci->buf;
339 hd.length = nghttp2_buf_len(buf);
343 buf->pos -= NGHTTP2_FRAME_HDLEN;
344 nghttp2_frame_pack_frame_hd(buf->pos, &hd);
347 buf = &ci->buf;
348 hd.length = nghttp2_buf_len(buf);
354 buf->pos -= NGHTTP2_FRAME_HDLEN;
355 nghttp2_frame_pack_frame_hd(buf->pos, &hd);
365 nghttp2_buf *buf;
371 buf = &bufs->cur->buf;
373 buf->pos += nv_offset;
374 buf->last = buf->pos;
376 /* This call will adjust buf->last to the correct position */
383 buf->pos -= nv_offset;
390 nghttp2_frame_pack_priority_spec(buf->pos, &frame->pri_spec);
399 void nghttp2_frame_pack_priority_spec(uint8_t *buf,
401 nghttp2_put_uint32be(buf, (uint32_t)pri_spec->stream_id);
403 buf[0] |= 0x80;
405 buf[4] = (uint8_t)(pri_spec->weight - 1);
434 nghttp2_buf *buf;
438 buf = &bufs->head->buf;
440 assert(nghttp2_buf_avail(buf) >= NGHTTP2_PRIORITY_SPECLEN);
442 buf->pos -= NGHTTP2_FRAME_HDLEN;
444 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
446 nghttp2_frame_pack_priority_spec(buf->last, &frame->pri_spec);
448 buf->last += NGHTTP2_PRIORITY_SPECLEN;
458 nghttp2_buf *buf;
462 buf = &bufs->head->buf;
464 assert(nghttp2_buf_avail(buf) >= 4);
466 buf->pos -= NGHTTP2_FRAME_HDLEN;
468 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
470 nghttp2_put_uint32be(buf->last, frame->error_code);
471 buf->last += 4;
480 nghttp2_buf *buf;
484 buf = &bufs->head->buf;
486 if (nghttp2_buf_avail(buf) < frame->hd.length) {
490 buf->pos -= NGHTTP2_FRAME_HDLEN;
492 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
494 buf->last +=
495 nghttp2_frame_pack_settings_payload(buf->last, frame->iv, frame->niv);
500 size_t nghttp2_frame_pack_settings_payload(uint8_t *buf,
504 for (i = 0; i < niv; ++i, buf += NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH) {
505 nghttp2_put_uint16be(buf, (uint16_t)iv[i].settings_id);
506 nghttp2_put_uint32be(buf + 2, iv[i].value);
559 nghttp2_buf *buf;
563 buf = &bufs->cur->buf;
565 buf->pos += nv_offset;
566 buf->last = buf->pos;
568 /* This call will adjust buf->last to the correct position */
575 buf->pos -= nv_offset;
581 nghttp2_put_uint32be(buf->pos, (uint32_t)frame->promised_stream_id);
598 nghttp2_buf *buf;
602 buf = &bufs->head->buf;
604 assert(nghttp2_buf_avail(buf) >= 8);
606 buf->pos -= NGHTTP2_FRAME_HDLEN;
608 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
610 buf->last =
611 nghttp2_cpymem(buf->last, frame->opaque_data, sizeof(frame->opaque_data));
621 nghttp2_buf *buf;
625 buf = &bufs->head->buf;
627 buf->pos -= NGHTTP2_FRAME_HDLEN;
629 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
631 nghttp2_put_uint32be(buf->last, (uint32_t)frame->last_stream_id);
632 buf->last += 4;
634 nghttp2_put_uint32be(buf->last, frame->error_code);
635 buf->last += 4;
693 nghttp2_buf *buf;
697 buf = &bufs->head->buf;
699 assert(nghttp2_buf_avail(buf) >= 4);
701 buf->pos -= NGHTTP2_FRAME_HDLEN;
703 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
705 nghttp2_put_uint32be(buf->last, (uint32_t)frame->window_size_increment);
706 buf->last += 4;
717 nghttp2_buf *buf;
725 buf = &bufs->head->buf;
727 assert(nghttp2_buf_avail(buf) >=
730 buf->pos -= NGHTTP2_FRAME_HDLEN;
732 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
734 nghttp2_put_uint16be(buf->last, (uint16_t)altsvc->origin_len);
735 buf->last += 2;
768 uint8_t *buf;
777 buf = nghttp2_mem_malloc(mem, payloadlen - 2);
778 if (!buf) {
782 nghttp2_cpymem(buf, payload + 2, payloadlen - 2);
784 nghttp2_frame_unpack_altsvc_payload(frame, origin_len, buf, payloadlen - 2);
790 nghttp2_buf *buf;
797 buf = &bufs->head->buf;
799 if (nghttp2_buf_avail(buf) < frame->hd.length) {
803 buf->pos -= NGHTTP2_FRAME_HDLEN;
805 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
809 nghttp2_put_uint16be(buf->last, (uint16_t)orig->origin_len);
810 buf->last += 2;
811 buf->last = nghttp2_cpymem(buf->last, orig->origin, orig->origin_len);
814 assert(nghttp2_buf_len(buf) == NGHTTP2_FRAME_HDLEN + frame->hd.length);
894 nghttp2_buf *buf;
902 buf = &bufs->head->buf;
904 assert(nghttp2_buf_avail(buf) >= 4 + priority_update->field_value_len);
906 buf->pos -= NGHTTP2_FRAME_HDLEN;
908 nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
910 nghttp2_put_uint32be(buf->last, (uint32_t)priority_update->stream_id);
911 buf->last += 4;
1145 static void frame_set_pad(nghttp2_buf *buf, size_t padlen, int framehd_only) {
1151 memmove(buf->pos - 1, buf->pos, NGHTTP2_FRAME_HDLEN);
1153 --buf->pos;
1155 buf->pos[4] |= NGHTTP2_FLAG_PADDED;
1157 newlen = (nghttp2_get_uint32(buf->pos) >> 8) + padlen;
1158 nghttp2_put_uint32be(buf->pos, (uint32_t)((newlen << 8) + buf->pos[3]));
1165 buf->pos[NGHTTP2_FRAME_HDLEN] = (uint8_t)trail_padlen;
1168 memset(buf->last, 0, trail_padlen);
1171 buf->last += trail_padlen;
1176 nghttp2_buf *buf;
1198 * completely. For padded frame, we are going to adjust buf->pos of
1200 * in the correct position. Also extends buf->last to include
1204 buf = &bufs->head->buf;
1206 assert(nghttp2_buf_avail(buf) >= padlen - 1);
1208 frame_set_pad(buf, padlen, framehd_only);