• Home
  • Raw
  • Download

Lines Matching refs:inflater

720 int nghttp2_hd_inflate_init(nghttp2_hd_inflater *inflater, nghttp2_mem *mem) {  in nghttp2_hd_inflate_init()  argument
723 rv = hd_context_init(&inflater->ctx, mem); in nghttp2_hd_inflate_init()
728 inflater->settings_hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE; in nghttp2_hd_inflate_init()
729 inflater->min_hd_table_bufsize_max = UINT32_MAX; in nghttp2_hd_inflate_init()
731 inflater->nv_name_keep = NULL; in nghttp2_hd_inflate_init()
732 inflater->nv_value_keep = NULL; in nghttp2_hd_inflate_init()
734 inflater->opcode = NGHTTP2_HD_OPCODE_NONE; in nghttp2_hd_inflate_init()
735 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_init()
737 nghttp2_buf_init(&inflater->namebuf); in nghttp2_hd_inflate_init()
738 nghttp2_buf_init(&inflater->valuebuf); in nghttp2_hd_inflate_init()
740 inflater->namercbuf = NULL; in nghttp2_hd_inflate_init()
741 inflater->valuercbuf = NULL; in nghttp2_hd_inflate_init()
743 inflater->huffman_encoded = 0; in nghttp2_hd_inflate_init()
744 inflater->index = 0; in nghttp2_hd_inflate_init()
745 inflater->left = 0; in nghttp2_hd_inflate_init()
746 inflater->shift = 0; in nghttp2_hd_inflate_init()
747 inflater->index_required = 0; in nghttp2_hd_inflate_init()
748 inflater->no_index = 0; in nghttp2_hd_inflate_init()
756 static void hd_inflate_keep_free(nghttp2_hd_inflater *inflater) { in hd_inflate_keep_free() argument
757 nghttp2_rcbuf_decref(inflater->nv_value_keep); in hd_inflate_keep_free()
758 nghttp2_rcbuf_decref(inflater->nv_name_keep); in hd_inflate_keep_free()
760 inflater->nv_value_keep = NULL; in hd_inflate_keep_free()
761 inflater->nv_name_keep = NULL; in hd_inflate_keep_free()
768 void nghttp2_hd_inflate_free(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_free() argument
769 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_free()
771 nghttp2_rcbuf_decref(inflater->valuercbuf); in nghttp2_hd_inflate_free()
772 nghttp2_rcbuf_decref(inflater->namercbuf); in nghttp2_hd_inflate_free()
774 hd_context_free(&inflater->ctx); in nghttp2_hd_inflate_free()
1257 nghttp2_hd_inflater *inflater, size_t settings_max_dynamic_table_size) { in nghttp2_hd_inflate_change_table_size() argument
1258 switch (inflater->state) { in nghttp2_hd_inflate_change_table_size()
1273 if (inflater->ctx.hd_table_bufsize_max > settings_max_dynamic_table_size) { in nghttp2_hd_inflate_change_table_size()
1274 inflater->state = NGHTTP2_HD_STATE_EXPECT_TABLE_SIZE; in nghttp2_hd_inflate_change_table_size()
1277 inflater->min_hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1280 inflater->settings_hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1282 inflater->ctx.hd_table_bufsize_max = settings_max_dynamic_table_size; in nghttp2_hd_inflate_change_table_size()
1284 hd_context_shrink_table_size(&inflater->ctx, NULL); in nghttp2_hd_inflate_change_table_size()
1622 static void hd_inflate_set_huffman_encoded(nghttp2_hd_inflater *inflater, in hd_inflate_set_huffman_encoded() argument
1624 inflater->huffman_encoded = (*in & (1 << 7)) != 0; in hd_inflate_set_huffman_encoded()
1640 static ssize_t hd_inflate_read_len(nghttp2_hd_inflater *inflater, int *rfin, in hd_inflate_read_len() argument
1648 rv = decode_length(&out, &inflater->shift, rfin, (uint32_t)inflater->left, in hd_inflate_read_len()
1649 inflater->shift, in, last, prefix); in hd_inflate_read_len()
1661 inflater->left = out; in hd_inflate_read_len()
1681 static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater, in hd_inflate_read_huff() argument
1686 if ((size_t)(last - in) >= inflater->left) { in hd_inflate_read_huff()
1687 last = in + inflater->left; in hd_inflate_read_huff()
1690 readlen = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, buf, in, in hd_inflate_read_huff()
1697 if (nghttp2_hd_huff_decode_failure_state(&inflater->huff_decode_ctx)) { in hd_inflate_read_huff()
1702 inflater->left -= (size_t)readlen; in hd_inflate_read_huff()
1718 static ssize_t hd_inflate_read(nghttp2_hd_inflater *inflater, nghttp2_buf *buf, in hd_inflate_read() argument
1720 size_t len = nghttp2_min((size_t)(last - in), inflater->left); in hd_inflate_read()
1724 inflater->left -= len; in hd_inflate_read()
1732 static void hd_inflate_commit_indexed(nghttp2_hd_inflater *inflater, in hd_inflate_commit_indexed() argument
1734 nghttp2_hd_nv nv = nghttp2_hd_table_get(&inflater->ctx, inflater->index); in hd_inflate_commit_indexed()
1750 static int hd_inflate_commit_newname(nghttp2_hd_inflater *inflater, in hd_inflate_commit_newname() argument
1755 if (inflater->no_index) { in hd_inflate_commit_newname()
1761 nv.name = inflater->namercbuf; in hd_inflate_commit_newname()
1762 nv.value = inflater->valuercbuf; in hd_inflate_commit_newname()
1763 nv.token = lookup_token(inflater->namercbuf->base, inflater->namercbuf->len); in hd_inflate_commit_newname()
1765 if (inflater->index_required) { in hd_inflate_commit_newname()
1766 rv = add_hd_table_incremental(&inflater->ctx, &nv, NULL, 0); in hd_inflate_commit_newname()
1775 inflater->nv_name_keep = nv.name; in hd_inflate_commit_newname()
1776 inflater->nv_value_keep = nv.value; in hd_inflate_commit_newname()
1778 inflater->namercbuf = NULL; in hd_inflate_commit_newname()
1779 inflater->valuercbuf = NULL; in hd_inflate_commit_newname()
1795 static int hd_inflate_commit_indname(nghttp2_hd_inflater *inflater, in hd_inflate_commit_indname() argument
1800 nv = nghttp2_hd_table_get(&inflater->ctx, inflater->index); in hd_inflate_commit_indname()
1802 if (inflater->no_index) { in hd_inflate_commit_indname()
1810 nv.value = inflater->valuercbuf; in hd_inflate_commit_indname()
1812 if (inflater->index_required) { in hd_inflate_commit_indname()
1813 rv = add_hd_table_incremental(&inflater->ctx, &nv, NULL, 0); in hd_inflate_commit_indname()
1822 inflater->nv_name_keep = nv.name; in hd_inflate_commit_indname()
1823 inflater->nv_value_keep = nv.value; in hd_inflate_commit_indname()
1825 inflater->valuercbuf = NULL; in hd_inflate_commit_indname()
1830 ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater, nghttp2_nv *nv_out, in nghttp2_hd_inflate_hd() argument
1833 return nghttp2_hd_inflate_hd2(inflater, nv_out, inflate_flags, in, inlen, in nghttp2_hd_inflate_hd()
1837 ssize_t nghttp2_hd_inflate_hd2(nghttp2_hd_inflater *inflater, in nghttp2_hd_inflate_hd2() argument
1843 rv = nghttp2_hd_inflate_hd_nv(inflater, &hd_nv, inflate_flags, in, inlen, in nghttp2_hd_inflate_hd2()
1863 ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater, in nghttp2_hd_inflate_hd_nv() argument
1874 mem = inflater->ctx.mem; in nghttp2_hd_inflate_hd_nv()
1876 if (inflater->ctx.bad) { in nghttp2_hd_inflate_hd_nv()
1880 DEBUGF("inflatehd: start state=%d\n", inflater->state); in nghttp2_hd_inflate_hd_nv()
1881 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_hd_nv()
1885 switch (inflater->state) { in nghttp2_hd_inflate_hd_nv()
1899 if (inflater->state == NGHTTP2_HD_STATE_OPCODE) { in nghttp2_hd_inflate_hd_nv()
1905 inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED; in nghttp2_hd_inflate_hd_nv()
1906 inflater->state = NGHTTP2_HD_STATE_READ_TABLE_SIZE; in nghttp2_hd_inflate_hd_nv()
1909 inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED; in nghttp2_hd_inflate_hd_nv()
1910 inflater->state = NGHTTP2_HD_STATE_READ_INDEX; in nghttp2_hd_inflate_hd_nv()
1914 inflater->opcode = NGHTTP2_HD_OPCODE_NEWNAME; in nghttp2_hd_inflate_hd_nv()
1915 inflater->state = NGHTTP2_HD_STATE_NEWNAME_CHECK_NAMELEN; in nghttp2_hd_inflate_hd_nv()
1918 inflater->opcode = NGHTTP2_HD_OPCODE_INDNAME; in nghttp2_hd_inflate_hd_nv()
1919 inflater->state = NGHTTP2_HD_STATE_READ_INDEX; in nghttp2_hd_inflate_hd_nv()
1921 inflater->index_required = (*in & 0x40) != 0; in nghttp2_hd_inflate_hd_nv()
1922 inflater->no_index = (*in & 0xf0u) == 0x10u; in nghttp2_hd_inflate_hd_nv()
1924 inflater->index_required, inflater->no_index); in nghttp2_hd_inflate_hd_nv()
1925 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
1929 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
1930 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
1935 inflater, &rfin, in, last, 5, in nghttp2_hd_inflate_hd_nv()
1936 nghttp2_min(inflater->min_hd_table_bufsize_max, in nghttp2_hd_inflate_hd_nv()
1937 inflater->settings_hd_table_bufsize_max)); in nghttp2_hd_inflate_hd_nv()
1945 DEBUGF("inflatehd: table_size=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
1946 inflater->min_hd_table_bufsize_max = UINT32_MAX; in nghttp2_hd_inflate_hd_nv()
1947 inflater->ctx.hd_table_bufsize_max = inflater->left; in nghttp2_hd_inflate_hd_nv()
1948 hd_context_shrink_table_size(&inflater->ctx, NULL); in nghttp2_hd_inflate_hd_nv()
1949 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_hd_nv()
1954 if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) { in nghttp2_hd_inflate_hd_nv()
1956 } else if (inflater->index_required) { in nghttp2_hd_inflate_hd_nv()
1963 rv = hd_inflate_read_len(inflater, &rfin, in, last, prefixlen, in nghttp2_hd_inflate_hd_nv()
1964 get_max_index(&inflater->ctx)); in nghttp2_hd_inflate_hd_nv()
1975 if (inflater->left == 0) { in nghttp2_hd_inflate_hd_nv()
1980 DEBUGF("inflatehd: index=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
1981 if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) { in nghttp2_hd_inflate_hd_nv()
1982 inflater->index = inflater->left; in nghttp2_hd_inflate_hd_nv()
1983 --inflater->index; in nghttp2_hd_inflate_hd_nv()
1985 hd_inflate_commit_indexed(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
1987 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
1991 inflater->index = inflater->left; in nghttp2_hd_inflate_hd_nv()
1992 --inflater->index; in nghttp2_hd_inflate_hd_nv()
1994 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
1999 hd_inflate_set_huffman_encoded(inflater, in); in nghttp2_hd_inflate_hd_nv()
2000 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN; in nghttp2_hd_inflate_hd_nv()
2001 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
2002 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
2003 DEBUGF("inflatehd: huffman encoded=%d\n", inflater->huffman_encoded != 0); in nghttp2_hd_inflate_hd_nv()
2007 rv = hd_inflate_read_len(inflater, &rfin, in, last, 7, NGHTTP2_HD_MAX_NV); in nghttp2_hd_inflate_hd_nv()
2014 inflater->left); in nghttp2_hd_inflate_hd_nv()
2019 if (inflater->huffman_encoded) { in nghttp2_hd_inflate_hd_nv()
2020 nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx); in nghttp2_hd_inflate_hd_nv()
2022 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMEHUFF; in nghttp2_hd_inflate_hd_nv()
2024 rv = nghttp2_rcbuf_new(&inflater->namercbuf, inflater->left * 2 + 1, in nghttp2_hd_inflate_hd_nv()
2027 inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAME; in nghttp2_hd_inflate_hd_nv()
2028 rv = nghttp2_rcbuf_new(&inflater->namercbuf, inflater->left + 1, mem); in nghttp2_hd_inflate_hd_nv()
2035 nghttp2_buf_wrap_init(&inflater->namebuf, inflater->namercbuf->base, in nghttp2_hd_inflate_hd_nv()
2036 inflater->namercbuf->len); in nghttp2_hd_inflate_hd_nv()
2040 rv = hd_inflate_read_huff(inflater, &inflater->namebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2049 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2050 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2055 *inflater->namebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2056 inflater->namercbuf->len = nghttp2_buf_len(&inflater->namebuf); in nghttp2_hd_inflate_hd_nv()
2058 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2062 rv = hd_inflate_read(inflater, &inflater->namebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2070 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2071 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2076 *inflater->namebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2077 inflater->namercbuf->len = nghttp2_buf_len(&inflater->namebuf); in nghttp2_hd_inflate_hd_nv()
2079 inflater->state = NGHTTP2_HD_STATE_CHECK_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2083 hd_inflate_set_huffman_encoded(inflater, in); in nghttp2_hd_inflate_hd_nv()
2084 inflater->state = NGHTTP2_HD_STATE_READ_VALUELEN; in nghttp2_hd_inflate_hd_nv()
2085 inflater->left = 0; in nghttp2_hd_inflate_hd_nv()
2086 inflater->shift = 0; in nghttp2_hd_inflate_hd_nv()
2087 DEBUGF("inflatehd: huffman encoded=%d\n", inflater->huffman_encoded != 0); in nghttp2_hd_inflate_hd_nv()
2091 rv = hd_inflate_read_len(inflater, &rfin, in, last, 7, NGHTTP2_HD_MAX_NV); in nghttp2_hd_inflate_hd_nv()
2102 DEBUGF("inflatehd: valuelen=%zu\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2104 if (inflater->huffman_encoded) { in nghttp2_hd_inflate_hd_nv()
2105 nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx); in nghttp2_hd_inflate_hd_nv()
2107 inflater->state = NGHTTP2_HD_STATE_READ_VALUEHUFF; in nghttp2_hd_inflate_hd_nv()
2109 rv = nghttp2_rcbuf_new(&inflater->valuercbuf, inflater->left * 2 + 1, in nghttp2_hd_inflate_hd_nv()
2112 inflater->state = NGHTTP2_HD_STATE_READ_VALUE; in nghttp2_hd_inflate_hd_nv()
2114 rv = nghttp2_rcbuf_new(&inflater->valuercbuf, inflater->left + 1, mem); in nghttp2_hd_inflate_hd_nv()
2121 nghttp2_buf_wrap_init(&inflater->valuebuf, inflater->valuercbuf->base, in nghttp2_hd_inflate_hd_nv()
2122 inflater->valuercbuf->len); in nghttp2_hd_inflate_hd_nv()
2128 rv = hd_inflate_read_huff(inflater, &inflater->valuebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2137 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2138 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2143 *inflater->valuebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2144 inflater->valuercbuf->len = nghttp2_buf_len(&inflater->valuebuf); in nghttp2_hd_inflate_hd_nv()
2146 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
2147 rv = hd_inflate_commit_newname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2149 rv = hd_inflate_commit_indname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2156 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
2161 rv = hd_inflate_read(inflater, &inflater->valuebuf, in, last); in nghttp2_hd_inflate_hd_nv()
2172 if (inflater->left) { in nghttp2_hd_inflate_hd_nv()
2173 DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left); in nghttp2_hd_inflate_hd_nv()
2177 *inflater->valuebuf.last = '\0'; in nghttp2_hd_inflate_hd_nv()
2178 inflater->valuercbuf->len = nghttp2_buf_len(&inflater->valuebuf); in nghttp2_hd_inflate_hd_nv()
2180 if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) { in nghttp2_hd_inflate_hd_nv()
2181 rv = hd_inflate_commit_newname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2183 rv = hd_inflate_commit_indname(inflater, nv_out); in nghttp2_hd_inflate_hd_nv()
2190 inflater->state = NGHTTP2_HD_STATE_OPCODE; in nghttp2_hd_inflate_hd_nv()
2204 if (inflater->state != NGHTTP2_HD_STATE_OPCODE && in nghttp2_hd_inflate_hd_nv()
2205 inflater->state != NGHTTP2_HD_STATE_INFLATE_START) { in nghttp2_hd_inflate_hd_nv()
2206 DEBUGF("inflatehd: unacceptable state=%d\n", inflater->state); in nghttp2_hd_inflate_hd_nv()
2228 inflater->ctx.bad = 1; in nghttp2_hd_inflate_hd_nv()
2232 int nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_end_headers() argument
2233 hd_inflate_keep_free(inflater); in nghttp2_hd_inflate_end_headers()
2234 inflater->state = NGHTTP2_HD_STATE_INFLATE_START; in nghttp2_hd_inflate_end_headers()
2245 nghttp2_hd_inflater *inflater; in nghttp2_hd_inflate_new2() local
2251 inflater = nghttp2_mem_malloc(mem, sizeof(nghttp2_hd_inflater)); in nghttp2_hd_inflate_new2()
2253 if (inflater == NULL) { in nghttp2_hd_inflate_new2()
2257 rv = nghttp2_hd_inflate_init(inflater, mem); in nghttp2_hd_inflate_new2()
2260 nghttp2_mem_free(mem, inflater); in nghttp2_hd_inflate_new2()
2265 *inflater_ptr = inflater; in nghttp2_hd_inflate_new2()
2270 void nghttp2_hd_inflate_del(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_del() argument
2273 mem = inflater->ctx.mem; in nghttp2_hd_inflate_del()
2274 nghttp2_hd_inflate_free(inflater); in nghttp2_hd_inflate_del()
2276 nghttp2_mem_free(mem, inflater); in nghttp2_hd_inflate_del()
2334 size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_num_table_entries() argument
2335 return get_max_index(&inflater->ctx); in nghttp2_hd_inflate_get_num_table_entries()
2339 nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx) { in nghttp2_hd_inflate_get_table_entry() argument
2340 return hd_get_table_entry(&inflater->ctx, idx); in nghttp2_hd_inflate_get_table_entry()
2344 nghttp2_hd_inflate_get_dynamic_table_size(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_dynamic_table_size() argument
2345 return inflater->ctx.hd_table_bufsize; in nghttp2_hd_inflate_get_dynamic_table_size()
2349 nghttp2_hd_inflate_get_max_dynamic_table_size(nghttp2_hd_inflater *inflater) { in nghttp2_hd_inflate_get_max_dynamic_table_size() argument
2350 return inflater->ctx.hd_table_bufsize_max; in nghttp2_hd_inflate_get_max_dynamic_table_size()