• Home
  • Raw
  • Download

Lines Matching refs:inflater

725 int nghttp2_hd_inflate_init(nghttp2_hd_inflater *inflater, nghttp2_mem *mem) {  in nghttp2_hd_inflate_init()  argument
728 rv = hd_context_init(&inflater->ctx, mem); in nghttp2_hd_inflate_init()
733 inflater->settings_hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE; in nghttp2_hd_inflate_init()
734 inflater->min_hd_table_bufsize_max = UINT32_MAX; in nghttp2_hd_inflate_init()
736 inflater->nv_name_keep = NULL; in nghttp2_hd_inflate_init()
737 inflater->nv_value_keep = NULL; in nghttp2_hd_inflate_init()
739 inflater->opcode = NGHTTP2_HD_OPCODE_NONE; in nghttp2_hd_inflate_init()
740 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_init()
742 nghttp2_buf_init(&inflater->namebuf); in nghttp2_hd_inflate_init()
743 nghttp2_buf_init(&inflater->valuebuf); in nghttp2_hd_inflate_init()
745 inflater->namercbuf = NULL; in nghttp2_hd_inflate_init()
746 inflater->valuercbuf = NULL; in nghttp2_hd_inflate_init()
748 inflater->huffman_encoded = 0; in nghttp2_hd_inflate_init()
749 inflater->index = 0; in nghttp2_hd_inflate_init()
750 inflater->left = 0; in nghttp2_hd_inflate_init()
751 inflater->shift = 0; in nghttp2_hd_inflate_init()
752 inflater->index_required = 0; in nghttp2_hd_inflate_init()
753 inflater->no_index = 0; in nghttp2_hd_inflate_init()
761 static void hd_inflate_keep_free(nghttp2_hd_inflater *inflater) { in hd_inflate_keep_free() argument
762 nghttp2_rcbuf_decref(inflater->nv_value_keep); in hd_inflate_keep_free()
763 nghttp2_rcbuf_decref(inflater->nv_name_keep); in hd_inflate_keep_free()
765 inflater->nv_value_keep = NULL; in hd_inflate_keep_free()
766 inflater->nv_name_keep = NULL; in hd_inflate_keep_free()
773 void nghttp2_hd_inflate_free(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_free() argument
774 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_free()
776 nghttp2_rcbuf_decref(inflater->valuercbuf); in nghttp2_hd_inflate_free()
777 nghttp2_rcbuf_decref(inflater->namercbuf); in nghttp2_hd_inflate_free()
779 hd_context_free(&inflater->ctx); in nghttp2_hd_inflate_free()
1262 nghttp2_hd_inflater *inflater, size_t settings_max_dynamic_table_size) { in nghttp2_hd_inflate_change_table_size() argument
1263 switch (inflater->state) { in nghttp2_hd_inflate_change_table_size()
1271 inflater->settings_hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1280 if (inflater->ctx.hd_table_bufsize_max > settings_max_dynamic_table_size) { in nghttp2_hd_inflate_change_table_size()
1281 inflater->state = NGHTTP2_HD_STATE_EXPECT_TABLE_SIZE; in nghttp2_hd_inflate_change_table_size()
1284 inflater->min_hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1286 inflater->ctx.hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1288 hd_context_shrink_table_size(&inflater->ctx, NULL); in nghttp2_hd_inflate_change_table_size()
1628 static void hd_inflate_set_huffman_encoded(nghttp2_hd_inflater *inflater, in hd_inflate_set_huffman_encoded() argument
1630 inflater->huffman_encoded = (*in & (1 << 7)) != 0; in hd_inflate_set_huffman_encoded()
1646 static ssize_t hd_inflate_read_len(nghttp2_hd_inflater *inflater, int *rfin, in hd_inflate_read_len() argument
1654 rv = decode_length(&out, &inflater->shift, rfin, (uint32_t)inflater->left, in hd_inflate_read_len()
1655 inflater->shift, in, last, prefix); in hd_inflate_read_len()
1667 inflater->left = out; in hd_inflate_read_len()
1687 static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater, in hd_inflate_read_huff() argument
1692 if ((size_t)(last - in) >= inflater->left) { in hd_inflate_read_huff()
1693 last = in + inflater->left; in hd_inflate_read_huff()
1696 readlen = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, buf, in, in hd_inflate_read_huff()
1703 if (nghttp2_hd_huff_decode_failure_state(&inflater->huff_decode_ctx)) { in hd_inflate_read_huff()
1708 inflater->left -= (size_t)readlen; in hd_inflate_read_huff()
1724 static ssize_t hd_inflate_read(nghttp2_hd_inflater *inflater, nghttp2_buf *buf, in hd_inflate_read() argument
1726 size_t len = nghttp2_min((size_t)(last - in), inflater->left); in hd_inflate_read()
1730 inflater->left -= len; in hd_inflate_read()
1738 static void hd_inflate_commit_indexed(nghttp2_hd_inflater *inflater, in hd_inflate_commit_indexed() argument
1740 nghttp2_hd_nv nv = nghttp2_hd_table_get(&inflater->ctx, inflater->index); in hd_inflate_commit_indexed()
1756 static int hd_inflate_commit_newname(nghttp2_hd_inflater *inflater, in hd_inflate_commit_newname() argument
1761 if (inflater->no_index) { in hd_inflate_commit_newname()
1767 nv.name = inflater->namercbuf; in hd_inflate_commit_newname()
1768 nv.value = inflater->valuercbuf; in hd_inflate_commit_newname()
1769 nv.token = lookup_token(inflater->namercbuf->base, inflater->namercbuf->len); in hd_inflate_commit_newname()
1771 if (inflater->index_required) { in hd_inflate_commit_newname()
1772 rv = add_hd_table_incremental(&inflater->ctx, &nv, NULL, 0); in hd_inflate_commit_newname()
1781 inflater->nv_name_keep = nv.name; in hd_inflate_commit_newname()
1782 inflater->nv_value_keep = nv.value; in hd_inflate_commit_newname()
1784 inflater->namercbuf = NULL; in hd_inflate_commit_newname()
1785 inflater->valuercbuf = NULL; in hd_inflate_commit_newname()
1801 static int hd_inflate_commit_indname(nghttp2_hd_inflater *inflater, in hd_inflate_commit_indname() argument
1806 nv = nghttp2_hd_table_get(&inflater->ctx, inflater->index); in hd_inflate_commit_indname()
1808 if (inflater->no_index) { in hd_inflate_commit_indname()
1816 nv.value = inflater->valuercbuf; in hd_inflate_commit_indname()
1818 if (inflater->index_required) { in hd_inflate_commit_indname()
1819 rv = add_hd_table_incremental(&inflater->ctx, &nv, NULL, 0); in hd_inflate_commit_indname()
1828 inflater->nv_name_keep = nv.name; in hd_inflate_commit_indname()
1829 inflater->nv_value_keep = nv.value; in hd_inflate_commit_indname()
1831 inflater->valuercbuf = NULL; in hd_inflate_commit_indname()
1836 ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, nghttp2_nv *nv_out, in nghttp2_hd_inflate_hd() argument
1839 return nghttp2_hd_inflate_hd2(inflater, nv_out, inflate_flags, in, inlen, in nghttp2_hd_inflate_hd()
1843 ssize_t nghttp2_hd_inflate_hd2(nghttp2_hd_inflater *inflater, in nghttp2_hd_inflate_hd2() argument
1849 rv = nghttp2_hd_inflate_hd_nv(inflater, &hd_nv, inflate_flags, in, inlen, in nghttp2_hd_inflate_hd2()
1869 ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater, in nghttp2_hd_inflate_hd_nv() argument
1880 mem = inflater->ctx.mem; in nghttp2_hd_inflate_hd_nv()
1882 if (inflater->ctx.bad) { in nghttp2_hd_inflate_hd_nv()
1886 DEBUGF("inflatehd: start state=%d\n", inflater->state); in nghttp2_hd_inflate_hd_nv()
1887 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_hd_nv()
1891 switch (inflater->state) { in nghttp2_hd_inflate_hd_nv()
1905 if (inflater->state == NGHTTP2_HD_STATE_OPCODE) { in nghttp2_hd_inflate_hd_nv()
1911 inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED; in nghttp2_hd_inflate_hd_nv()
1912 inflater->state = NGHTTP2_HD_STATE_READ_TABLE_SIZE; in nghttp2_hd_inflate_hd_nv()
1915 inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED; in nghttp2_hd_inflate_hd_nv()
1916 inflater->state = NGHTTP2_HD_STATE_READ_INDEX; in nghttp2_hd_inflate_hd_nv()
1920 inflater->opcode = NGHTTP2_HD_OPCODE_NEWNAME; in nghttp2_hd_inflate_hd_nv()
1921 inflater->state = NGHTTP2_HD_STATE_NEWNAME_CHECK_NAMELEN; in nghttp2_hd_inflate_hd_nv()
1924 inflater->opcode = NGHTTP2_HD_OPCODE_INDNAME; in nghttp2_hd_inflate_hd_nv()
1925 inflater->state = NGHTTP2_HD_STATE_READ_INDEX; in nghttp2_hd_inflate_hd_nv()
1927 inflater->index_required = (*in & 0x40) != 0; in nghttp2_hd_inflate_hd_nv()
1928 inflater->no_index = (*in & 0xf0u) == 0x10u; in nghttp2_hd_inflate_hd_nv()
1930 inflater->index_required, inflater->no_index); in nghttp2_hd_inflate_hd_nv()
1931 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
1935 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
1936 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
1941 inflater, &rfin, in, last, 5, in nghttp2_hd_inflate_hd_nv()
1942 nghttp2_min(inflater->min_hd_table_bufsize_max, in nghttp2_hd_inflate_hd_nv()
1943 inflater->settings_hd_table_bufsize_max)); in nghttp2_hd_inflate_hd_nv()
1951 DEBUGF("inflatehd: table_size=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
1952 inflater->min_hd_table_bufsize_max = UINT32_MAX; in nghttp2_hd_inflate_hd_nv()
1953 inflater->ctx.hd_table_bufsize_max = inflater->left; in nghttp2_hd_inflate_hd_nv()
1954 hd_context_shrink_table_size(&inflater->ctx, NULL); in nghttp2_hd_inflate_hd_nv()
1955 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_hd_nv()
1960 if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) { in nghttp2_hd_inflate_hd_nv()
1962 } else if (inflater->index_required) { in nghttp2_hd_inflate_hd_nv()
1969 rv = hd_inflate_read_len(inflater, &rfin, in, last, prefixlen, in nghttp2_hd_inflate_hd_nv()
1970 get_max_index(&inflater->ctx)); in nghttp2_hd_inflate_hd_nv()
1981 if (inflater->left == 0) { in nghttp2_hd_inflate_hd_nv()
1986 DEBUGF("inflatehd: index=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
1987 if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) { in nghttp2_hd_inflate_hd_nv()
1988 inflater->index = inflater->left; in nghttp2_hd_inflate_hd_nv()
1989 --inflater->index; in nghttp2_hd_inflate_hd_nv()
1991 hd_inflate_commit_indexed(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
1993 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
1997 inflater->index = inflater->left; in nghttp2_hd_inflate_hd_nv()
1998 --inflater->index; in nghttp2_hd_inflate_hd_nv()
2000 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2005 hd_inflate_set_huffman_encoded(inflater, in); in nghttp2_hd_inflate_hd_nv()
2006 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN; in nghttp2_hd_inflate_hd_nv()
2007 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
2008 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
2009 DEBUGF("inflatehd: huffman encoded=%d\n", inflater->huffman_encoded != 0); in nghttp2_hd_inflate_hd_nv()
2013 rv = hd_inflate_read_len(inflater, &rfin, in, last, 7, NGHTTP2_HD_MAX_NV); in nghttp2_hd_inflate_hd_nv()
2020 inflater->left); in nghttp2_hd_inflate_hd_nv()
2025 if (inflater->huffman_encoded) { in nghttp2_hd_inflate_hd_nv()
2026 nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx); in nghttp2_hd_inflate_hd_nv()
2028 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMEHUFF; in nghttp2_hd_inflate_hd_nv()
2030 rv = nghttp2_rcbuf_new(&inflater->namercbuf, inflater->left * 2 + 1, in nghttp2_hd_inflate_hd_nv()
2033 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAME; in nghttp2_hd_inflate_hd_nv()
2034 rv = nghttp2_rcbuf_new(&inflater->namercbuf, inflater->left + 1, mem); in nghttp2_hd_inflate_hd_nv()
2041 nghttp2_buf_wrap_init(&inflater->namebuf, inflater->namercbuf->base, in nghttp2_hd_inflate_hd_nv()
2042 inflater->namercbuf->len); in nghttp2_hd_inflate_hd_nv()
2046 rv = hd_inflate_read_huff(inflater, &inflater->namebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2055 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2056 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2061 *inflater->namebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2062 inflater->namercbuf->len = nghttp2_buf_len(&inflater->namebuf); in nghttp2_hd_inflate_hd_nv()
2064 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2068 rv = hd_inflate_read(inflater, &inflater->namebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2076 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2077 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2082 *inflater->namebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2083 inflater->namercbuf->len = nghttp2_buf_len(&inflater->namebuf); in nghttp2_hd_inflate_hd_nv()
2085 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2089 hd_inflate_set_huffman_encoded(inflater, in); in nghttp2_hd_inflate_hd_nv()
2090 inflater->state = NGHTTP2_HD_STATE_READ_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2091 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
2092 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
2093 DEBUGF("inflatehd: huffman encoded=%d\n", inflater->huffman_encoded != 0); in nghttp2_hd_inflate_hd_nv()
2097 rv = hd_inflate_read_len(inflater, &rfin, in, last, 7, NGHTTP2_HD_MAX_NV); in nghttp2_hd_inflate_hd_nv()
2108 DEBUGF("inflatehd: valuelen=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2110 if (inflater->huffman_encoded) { in nghttp2_hd_inflate_hd_nv()
2111 nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx); in nghttp2_hd_inflate_hd_nv()
2113 inflater->state = NGHTTP2_HD_STATE_READ_VALUEHUFF; in nghttp2_hd_inflate_hd_nv()
2115 rv = nghttp2_rcbuf_new(&inflater->valuercbuf, inflater->left * 2 + 1, in nghttp2_hd_inflate_hd_nv()
2118 inflater->state = NGHTTP2_HD_STATE_READ_VALUE; in nghttp2_hd_inflate_hd_nv()
2120 rv = nghttp2_rcbuf_new(&inflater->valuercbuf, inflater->left + 1, mem); in nghttp2_hd_inflate_hd_nv()
2127 nghttp2_buf_wrap_init(&inflater->valuebuf, inflater->valuercbuf->base, in nghttp2_hd_inflate_hd_nv()
2128 inflater->valuercbuf->len); in nghttp2_hd_inflate_hd_nv()
2134 rv = hd_inflate_read_huff(inflater, &inflater->valuebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2143 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2144 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2149 *inflater->valuebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2150 inflater->valuercbuf->len = nghttp2_buf_len(&inflater->valuebuf); in nghttp2_hd_inflate_hd_nv()
2152 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
2153 rv = hd_inflate_commit_newname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2155 rv = hd_inflate_commit_indname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2162 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
2167 rv = hd_inflate_read(inflater, &inflater->valuebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2178 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2179 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2183 *inflater->valuebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2184 inflater->valuercbuf->len = nghttp2_buf_len(&inflater->valuebuf); in nghttp2_hd_inflate_hd_nv()
2186 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
2187 rv = hd_inflate_commit_newname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2189 rv = hd_inflate_commit_indname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2196 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
2210 if (inflater->state != NGHTTP2_HD_STATE_OPCODE && in nghttp2_hd_inflate_hd_nv()
2211 inflater->state != NGHTTP2_HD_STATE_INFLATE_START) { in nghttp2_hd_inflate_hd_nv()
2212 DEBUGF("inflatehd: unacceptable state=%d\n", inflater->state); in nghttp2_hd_inflate_hd_nv()
2234 inflater->ctx.bad = 1; in nghttp2_hd_inflate_hd_nv()
2238 int nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_end_headers() argument
2239 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_end_headers()
2240 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_end_headers()
2251 nghttp2_hd_inflater *inflater; in nghttp2_hd_inflate_new2() local
2257 inflater = nghttp2_mem_malloc(mem, sizeof(nghttp2_hd_inflater)); in nghttp2_hd_inflate_new2()
2259 if (inflater == NULL) { in nghttp2_hd_inflate_new2()
2263 rv = nghttp2_hd_inflate_init(inflater, mem); in nghttp2_hd_inflate_new2()
2266 nghttp2_mem_free(mem, inflater); in nghttp2_hd_inflate_new2()
2271 *inflater_ptr = inflater; in nghttp2_hd_inflate_new2()
2276 void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_del() argument
2279 mem = inflater->ctx.mem; in nghttp2_hd_inflate_del()
2280 nghttp2_hd_inflate_free(inflater); in nghttp2_hd_inflate_del()
2282 nghttp2_mem_free(mem, inflater); in nghttp2_hd_inflate_del()
2340 size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_num_table_entries() argument
2341 return get_max_index(&inflater->ctx); in nghttp2_hd_inflate_get_num_table_entries()
2345 nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx) { in nghttp2_hd_inflate_get_table_entry() argument
2346 return hd_get_table_entry(&inflater->ctx, idx); in nghttp2_hd_inflate_get_table_entry()
2350 nghttp2_hd_inflate_get_dynamic_table_size(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_dynamic_table_size() argument
2351 return inflater->ctx.hd_table_bufsize; in nghttp2_hd_inflate_get_dynamic_table_size()
2355 nghttp2_hd_inflate_get_max_dynamic_table_size(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_max_dynamic_table_size() argument
2356 return inflater->ctx.hd_table_bufsize_max; in nghttp2_hd_inflate_get_max_dynamic_table_size()