GRPC Core  0.10.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stream_encoder.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H
35 #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H
36 
41 #include <grpc/support/slice.h>
43 
44 #define GRPC_CHTTP2_HPACKC_NUM_FILTERS 256
45 #define GRPC_CHTTP2_HPACKC_NUM_VALUES 256
46 #define GRPC_CHTTP2_HPACKC_MAX_TABLE_ELEMS (4096 / 32)
47 
48 typedef struct {
50  /* one before the lowest usable table index */
54 
55  /* filter tables for elems: this tables provides an approximate
56  popularity count for particular hashes, and are used to determine whether
57  a new literal should be added to the compression table or not.
58  They track a single integer that counts how often a particular value has
59  been seen. When that count reaches max (255), all values are halved. */
61 
62  /* metadata context */
64  /* the string 'grpc-timeout' */
66 
67  /* entry tables for keys & elems: these tables track values that have been
68  seen and *may* be in the decompressor table */
73 
76 
78  grpc_mdctx *mdctx);
80 
81 /* select stream ops to be encoded, moving them from inops to outops, and
82  moving subsequent ops in inops forward in the queue */
83 gpr_uint32 grpc_chttp2_preencode(grpc_stream_op *inops, size_t *inops_count,
84  gpr_uint32 max_flow_controlled_bytes,
85  grpc_stream_op_buffer *outops);
86 
87 /* encode stream ops to output */
88 void grpc_chttp2_encode(grpc_stream_op *ops, size_t ops_count, int eof,
89  gpr_uint32 stream_id,
90  grpc_chttp2_hpack_compressor *compressor,
91  gpr_slice_buffer *output);
92 
93 #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H */
grpc_mdctx * mdctx
Definition: stream_encoder.h:63
#define GRPC_CHTTP2_HPACKC_NUM_FILTERS
Definition: stream_encoder.h:44
uint8_t gpr_uint8
Definition: port_platform.h:307
gpr_uint16 table_size
Definition: stream_encoder.h:52
Definition: stream_encoder.h:48
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_ELEMS
Definition: stream_encoder.h:46
Definition: metadata.h:70
void grpc_chttp2_encode(grpc_stream_op *ops, size_t ops_count, int eof, gpr_uint32 stream_id, grpc_chttp2_hpack_compressor *compressor, gpr_slice_buffer *output)
Definition: stream_encoder.c:550
uint32_t gpr_uint32
Definition: port_platform.h:309
Definition: slice_buffer.h:48
#define GRPC_CHTTP2_HPACKC_NUM_VALUES
Definition: stream_encoder.h:45
grpc_mdstr * timeout_key_str
Definition: stream_encoder.h:65
Definition: metadata.c:98
Definition: metadata.h:78
uint16_t gpr_uint16
Definition: port_platform.h:308
gpr_uint16 table_elems
Definition: stream_encoder.h:53
void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c)
Definition: stream_encoder.c:462
gpr_uint32 filter_elems_sum
Definition: stream_encoder.h:49
gpr_uint32 tail_remote_index
Definition: stream_encoder.h:51
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c, grpc_mdctx *mdctx)
Definition: stream_encoder.c:455
Definition: stream_op.h:162
A stream op buffer is a wrapper around stream operations that is dynamically extendable.
Definition: stream_op.h:176
gpr_uint32 grpc_chttp2_preencode(grpc_stream_op *inops, size_t *inops_count, gpr_uint32 max_flow_controlled_bytes, grpc_stream_op_buffer *outops)
Definition: stream_encoder.c:471