Lines Matching defs:rstate

930   nghttp3_qpack_read_state_reset(&encoder->rstate);
2404 * qpack_read_varint reads |rstate->prefix| prefixed integer stored
2409 * If the |rstate->left| is nonzero, it is used as an initial value,
2411 * data. |rstate->shift| is used as initial integer shift.
2416 * This function stores the decoded integer in |rstate->left| if it
2418 * to make in the next call will be stored in |rstate->shift|) and
2423 nghttp3_qpack_read_state *rstate,
2426 uint64_t k = (uint8_t)((1 << rstate->prefix) - 1);
2427 uint64_t n = rstate->left;
2430 size_t shift = rstate->shift;
2432 rstate->shift = 0;
2437 rstate->left = (*p) & k;
2445 rstate->left = n;
2474 rstate->shift = shift;
2477 rstate->left = n;
2481 rstate->left = n;
2510 encoder->rstate.prefix = 7;
2514 encoder->rstate.prefix = 6;
2518 encoder->rstate.prefix = 6;
2523 nread = qpack_read_varint(&rfin, &encoder->rstate, p, end);
2538 rv = nghttp3_qpack_encoder_add_icnt(encoder, encoder->rstate.left);
2545 (int64_t)encoder->rstate.left);
2552 (int64_t)encoder->rstate.left);
2561 nghttp3_qpack_read_state_reset(&encoder->rstate);
2618 void nghttp3_qpack_read_state_free(nghttp3_qpack_read_state *rstate) {
2619 nghttp3_rcbuf_decref(rstate->value);
2620 nghttp3_rcbuf_decref(rstate->name);
2623 void nghttp3_qpack_read_state_reset(nghttp3_qpack_read_state *rstate) {
2624 rstate->name = NULL;
2625 rstate->value = NULL;
2626 nghttp3_buf_init(&rstate->namebuf);
2627 nghttp3_buf_init(&rstate->valuebuf);
2628 rstate->left = 0;
2629 rstate->prefix = 0;
2630 rstate->shift = 0;
2631 rstate->absidx = 0;
2632 rstate->never = 0;
2633 rstate->dynamic = 0;
2634 rstate->huffman_encoded = 0;
2654 nghttp3_qpack_read_state_reset(&decoder->rstate);
2662 nghttp3_qpack_read_state_free(&decoder->rstate);
2677 static nghttp3_ssize qpack_read_huffman_string(nghttp3_qpack_read_state *rstate,
2685 if (len >= rstate->left) {
2686 len = (size_t)rstate->left;
2690 nwrite = nghttp3_qpack_huffman_decode(&rstate->huffman_ctx, dest->last, begin,
2696 if (nghttp3_qpack_huffman_decode_failure_state(&rstate->huffman_ctx)) {
2701 rstate->left -= len;
2705 static nghttp3_ssize qpack_read_string(nghttp3_qpack_read_state *rstate,
2709 size_t n = (size_t)nghttp3_min((uint64_t)len, rstate->left);
2713 rstate->left -= n;
2718 * qpack_decoder_validate_index checks rstate->absidx is acceptable.
2724 * rstate->absidx is invalid.
2727 nghttp3_qpack_read_state *rstate) {
2728 if (rstate->dynamic) {
2729 return rstate->absidx < decoder->ctx.next_absidx &&
2730 decoder->ctx.next_absidx - rstate->absidx - 1 <
2735 return rstate->absidx < nghttp3_arraylen(stable) ? 0
2739 static void qpack_read_state_check_huffman(nghttp3_qpack_read_state *rstate,
2741 rstate->huffman_encoded = (b & (1 << rstate->prefix)) != 0;
2744 static void qpack_read_state_terminate_name(nghttp3_qpack_read_state *rstate) {
2745 *rstate->namebuf.last = '\0';
2746 rstate->name->len = nghttp3_buf_len(&rstate->namebuf);
2749 static void qpack_read_state_terminate_value(nghttp3_qpack_read_state *rstate) {
2750 *rstate->valuebuf.last = '\0';
2751 rstate->value->len = nghttp3_buf_len(&rstate->valuebuf);
2781 decoder->rstate.dynamic = !((*p) & 0x40);
2782 decoder->rstate.prefix = 6;
2787 decoder->rstate.dynamic = 0;
2788 decoder->rstate.prefix = 5;
2793 decoder->rstate.prefix = 5;
2798 decoder->rstate.dynamic = 1;
2799 decoder->rstate.prefix = 5;
2808 nread = qpack_read_varint(&rfin, &decoder->rstate, p, end);
2823 decoder->rstate.left);
2825 decoder, (size_t)decoder->rstate.left);
2832 nghttp3_qpack_read_state_reset(&decoder->rstate);
2836 rv = nghttp3_qpack_decoder_rel2abs(decoder, &decoder->rstate);
2847 nghttp3_qpack_read_state_reset(&decoder->rstate);
2852 decoder->rstate.prefix = 7;
2861 qpack_read_state_check_huffman(&decoder->rstate, *p);
2863 decoder->rstate.left = 0;
2864 decoder->rstate.shift = 0;
2867 nread = qpack_read_varint(&rfin, &decoder->rstate, p, end);
2880 if (decoder->rstate.left > NGHTTP3_QPACK_MAX_NAMELEN) {
2885 if (decoder->rstate.huffman_encoded) {
2887 nghttp3_qpack_huffman_decode_context_init(&decoder->rstate.huffman_ctx);
2888 rv = nghttp3_rcbuf_new(&decoder->rstate.name,
2889 (size_t)decoder->rstate.left * 2 + 1, mem);
2892 rv = nghttp3_rcbuf_new(&decoder->rstate.name,
2893 (size_t)decoder->rstate.left + 1, mem);
2899 nghttp3_buf_wrap_init(&decoder->rstate.namebuf,
2900 decoder->rstate.name->base,
2901 decoder->rstate.name->len);
2904 nread = qpack_read_huffman_string(&decoder->rstate,
2905 &decoder->rstate.namebuf, p, end);
2914 if (decoder->rstate.left) {
2918 qpack_read_state_terminate_name(&decoder->rstate);
2921 decoder->rstate.prefix = 7;
2925 qpack_read_string(&decoder->rstate, &decoder->rstate.namebuf, p, end);
2933 if (decoder->rstate.left) {
2937 qpack_read_state_terminate_name(&decoder->rstate);
2940 decoder->rstate.prefix = 7;
2943 qpack_read_state_check_huffman(&decoder->rstate, *p);
2945 decoder->rstate.left = 0;
2946 decoder->rstate.shift = 0;
2949 nread = qpack_read_varint(&rfin, &decoder->rstate, p, end);
2962 if (decoder->rstate.left > NGHTTP3_QPACK_MAX_VALUELEN) {
2967 if (decoder->rstate.huffman_encoded) {
2969 nghttp3_qpack_huffman_decode_context_init(&decoder->rstate.huffman_ctx);
2970 rv = nghttp3_rcbuf_new(&decoder->rstate.value,
2971 (size_t)decoder->rstate.left * 2 + 1, mem);
2974 rv = nghttp3_rcbuf_new(&decoder->rstate.value,
2975 (size_t)decoder->rstate.left + 1, mem);
2981 nghttp3_buf_wrap_init(&decoder->rstate.valuebuf,
2982 decoder->rstate.value->base,
2983 decoder->rstate.value->len);
2989 nread = qpack_read_huffman_string(&decoder->rstate,
2990 &decoder->rstate.valuebuf, p, end);
2999 if (decoder->rstate.left) {
3003 qpack_read_state_terminate_value(&decoder->rstate);
3022 nghttp3_qpack_read_state_reset(&decoder->rstate);
3025 nread = qpack_read_string(&decoder->rstate, &decoder->rstate.valuebuf, p,
3034 if (decoder->rstate.left) {
3038 qpack_read_state_terminate_value(&decoder->rstate);
3057 nghttp3_qpack_read_state_reset(&decoder->rstate);
3100 decoder->rstate.dynamic ? "dynamic" : "static", decoder->rstate.absidx,
3101 (int)decoder->rstate.value->len, decoder->rstate.value->base);
3103 if (decoder->rstate.dynamic) {
3115 shd = &stable[decoder->rstate.absidx];
3117 if (table_space(shd->name.len, decoder->rstate.value->len) >
3123 qnv.value = decoder->rstate.value;
3139 ent = nghttp3_qpack_context_dtable_get(&decoder->ctx, decoder->rstate.absidx);
3141 if (table_space(ent->nv.name->len, decoder->rstate.value->len) >
3147 qnv.value = decoder->rstate.value;
3167 decoder->rstate.absidx);
3169 ent = nghttp3_qpack_context_dtable_get(&decoder->ctx, decoder->rstate.absidx);
3193 (int)decoder->rstate.name->len, decoder->rstate.name->base,
3194 (int)decoder->rstate.value->len, decoder->rstate.value->base);
3196 if (table_space(decoder->rstate.name->len, decoder->rstate.value->len) >
3201 qnv.name = decoder->rstate.name;
3202 qnv.value = decoder->rstate.value;
3223 nghttp3_qpack_read_state_reset(&sctx->rstate);
3226 sctx->rstate.prefix = 8;
3236 nghttp3_qpack_read_state_free(&sctx->rstate);
3270 nread = qpack_read_varint(&rfin, &sctx->rstate, p, end);
3284 sctx->rstate.left);
3296 sctx->rstate.left = 0;
3297 sctx->rstate.prefix = 7;
3298 sctx->rstate.shift = 0;
3301 nread = qpack_read_varint(&rfin, &sctx->rstate, p, end);
3315 if (sctx->ricnt <= sctx->rstate.left) {
3319 sctx->base = sctx->ricnt - sctx->rstate.left - 1;
3321 sctx->base = sctx->ricnt + sctx->rstate.left;
3336 sctx->rstate.left = 0;
3337 sctx->rstate.shift = 0;
3340 assert(sctx->rstate.left == 0);
3341 assert(sctx->rstate.shift == 0);
3345 sctx->rstate.dynamic = !((*p) & 0x40);
3346 sctx->rstate.prefix = 6;
3351 sctx->rstate.never = (*p) & 0x20;
3352 sctx->rstate.dynamic = !((*p) & 0x10);
3353 sctx->rstate.prefix = 4;
3358 sctx->rstate.never = (*p) & 0x10;
3359 sctx->rstate.dynamic = 0;
3360 sctx->rstate.prefix = 3;
3365 sctx->rstate.dynamic = 1;
3366 sctx->rstate.prefix = 4;
3371 sctx->rstate.never = (*p) & 0x08;
3372 sctx->rstate.dynamic = 1;
3373 sctx->rstate.prefix = 3;
3378 nread = qpack_read_varint(&rfin, &sctx->rstate, p, end);
3401 nghttp3_qpack_read_state_reset(&sctx->rstate);
3413 nghttp3_qpack_read_state_reset(&sctx->rstate);
3421 sctx->rstate.prefix = 7;
3429 sctx->rstate.prefix = 7;
3438 qpack_read_state_check_huffman(&sctx->rstate, *p);
3440 sctx->rstate.left = 0;
3441 sctx->rstate.shift = 0;
3444 nread = qpack_read_varint(&rfin, &sctx->rstate, p, end);
3457 if (sctx->rstate.left > NGHTTP3_QPACK_MAX_NAMELEN) {
3462 if (sctx->rstate.huffman_encoded) {
3464 nghttp3_qpack_huffman_decode_context_init(&sctx->rstate.huffman_ctx);
3465 rv = nghttp3_rcbuf_new(&sctx->rstate.name,
3466 (size_t)sctx->rstate.left * 2 + 1, mem);
3469 rv = nghttp3_rcbuf_new(&sctx->rstate.name,
3470 (size_t)sctx->rstate.left + 1, mem);
3476 nghttp3_buf_wrap_init(&sctx->rstate.namebuf, sctx->rstate.name->base,
3477 sctx->rstate.name->len);
3480 nread = qpack_read_huffman_string(&sctx->rstate, &sctx->rstate.namebuf, p,
3490 if (sctx->rstate.left) {
3494 qpack_read_state_terminate_name(&sctx->rstate);
3497 sctx->rstate.prefix = 7;
3500 nread = qpack_read_string(&sctx->rstate, &sctx->rstate.namebuf, p, end);
3508 if (sctx->rstate.left) {
3512 qpack_read_state_terminate_name(&sctx->rstate);
3515 sctx->rstate.prefix = 7;
3518 qpack_read_state_check_huffman(&sctx->rstate, *p);
3520 sctx->rstate.left = 0;
3521 sctx->rstate.shift = 0;
3524 nread = qpack_read_varint(&rfin, &sctx->rstate, p, end);
3537 if (sctx->rstate.left > NGHTTP3_QPACK_MAX_VALUELEN) {
3542 if (sctx->rstate.huffman_encoded) {
3544 nghttp3_qpack_huffman_decode_context_init(&sctx->rstate.huffman_ctx);
3545 rv = nghttp3_rcbuf_new(&sctx->rstate.value,
3546 (size_t)sctx->rstate.left * 2 + 1, mem);
3549 rv = nghttp3_rcbuf_new(&sctx->rstate.value,
3550 (size_t)sctx->rstate.left + 1, mem);
3556 nghttp3_buf_wrap_init(&sctx->rstate.valuebuf, sctx->rstate.value->base,
3557 sctx->rstate.value->len);
3563 nread = qpack_read_huffman_string(&sctx->rstate, &sctx->rstate.valuebuf,
3573 if (sctx->rstate.left) {
3577 qpack_read_state_terminate_value(&sctx->rstate);
3599 nghttp3_qpack_read_state_reset(&sctx->rstate);
3603 nread = qpack_read_string(&sctx->rstate, &sctx->rstate.valuebuf, p, end);
3611 if (sctx->rstate.left) {
3615 qpack_read_state_terminate_value(&sctx->rstate);
3637 nghttp3_qpack_read_state_reset(&sctx->rstate);
3647 nghttp3_qpack_read_state_reset(&sctx->rstate);
3814 nghttp3_qpack_read_state *rstate) {
3816 rstate->dynamic, rstate->left, decoder->ctx.next_absidx);
3818 if (rstate->dynamic) {
3819 if (decoder->ctx.next_absidx < rstate->left + 1) {
3822 rstate->absidx = decoder->ctx.next_absidx - rstate->left - 1;
3824 rstate->absidx = rstate->left;
3826 if (qpack_decoder_validate_index(decoder, rstate) != 0) {
3834 nghttp3_qpack_read_state *rstate = &sctx->rstate;
3838 rstate->dynamic, rstate->left, sctx->base, decoder->ctx.next_absidx);
3840 if (rstate->dynamic) {
3841 if (sctx->base < rstate->left + 1) {
3844 rstate->absidx = sctx->base - rstate->left - 1;
3846 if (rstate->absidx >= sctx->ricnt) {
3850 rstate->absidx = rstate->left;
3853 if (qpack_decoder_validate_index(decoder, rstate) != 0) {
3861 nghttp3_qpack_read_state *rstate = &sctx->rstate;
3864 rstate->left, sctx->base, decoder->ctx.next_absidx);
3866 assert(rstate->dynamic);
3868 rstate->absidx = rstate->left + sctx->base;
3870 if (rstate->absidx >= sctx->ricnt) {
3874 if (qpack_decoder_validate_index(decoder, rstate) != 0) {
3884 const nghttp3_qpack_static_header *shd = &stable[sctx->rstate.absidx];
3898 nghttp3_qpack_context_dtable_get(&decoder->ctx, sctx->rstate.absidx);
3910 sctx->rstate.dynamic ? "dynamic" : "static", sctx->rstate.absidx);
3912 if (sctx->rstate.dynamic) {
3923 const nghttp3_qpack_static_header *shd = &stable[sctx->rstate.absidx];
3927 nv->value = sctx->rstate.value;
3930 sctx->rstate.never ? NGHTTP3_NV_FLAG_NEVER_INDEX : NGHTTP3_NV_FLAG_NONE;
3932 sctx->rstate.value = NULL;
3943 if (qpack_decoder_validate_index(decoder, &sctx->rstate) != 0) {
3947 ent = nghttp3_qpack_context_dtable_get(&decoder->ctx, sctx->rstate.absidx);
3950 nv->value = sctx->rstate.value;
3953 sctx->rstate.never ? NGHTTP3_NV_FLAG_NEVER_INDEX : NGHTTP3_NV_FLAG_NONE;
3957 sctx->rstate.value = NULL;
3968 sctx->rstate.dynamic ? "dynamic" : "static", sctx->rstate.absidx,
3969 (int)sctx->rstate.value->len, sctx->rstate.value->base);
3971 if (sctx->rstate.dynamic) {
3986 (int)sctx->rstate.name->len, sctx->rstate.name->base,
3987 (int)sctx->rstate.value->len, sctx->rstate.value->base);
3989 nv->name = sctx->rstate.name;
3990 nv->value = sctx->rstate.value;
3993 sctx->rstate.never ? NGHTTP3_NV_FLAG_NEVER_INDEX : NGHTTP3_NV_FLAG_NONE;
3995 sctx->rstate.name = NULL;
3996 sctx->rstate.value = NULL;