GRPC Core 0.10.0.0

- Main Page
- Data Structures
- Files

- File List
- Globals

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
37 #include "src/core/transport/chttp2/frame.h"
38 #include "src/core/transport/metadata.h"
39 #include "src/core/transport/stream_op.h"
40 #include <grpc/support/port_platform.h>
41 #include <grpc/support/slice.h>
42 #include <grpc/support/slice_buffer.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 {
49 gpr_uint32 filter_elems_sum;
50 /* one before the lowest usable table index */
51 gpr_uint32 tail_remote_index;
52 gpr_uint16 table_size;
53 gpr_uint16 table_elems;
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. */
60 gpr_uint8 filter_elems[GRPC_CHTTP2_HPACKC_NUM_FILTERS];
61
62 /* metadata context */
63 grpc_mdctx *mdctx;
64 /* the string 'grpc-timeout' */
65 grpc_mdstr *timeout_key_str;
66
67 /* entry tables for keys & elems: these tables track values that have been
68 seen and *may* be in the decompressor table */
69 grpc_mdstr *entries_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
70 grpc_mdelem *entries_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
71 gpr_uint32 indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
72 gpr_uint32 indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
73
74 gpr_uint16 table_elem_size[GRPC_CHTTP2_HPACKC_MAX_TABLE_ELEMS];
75 } grpc_chttp2_hpack_compressor;
76
77 void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c,
78 grpc_mdctx *mdctx);
79 void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c);
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_chttp2_hpack_compressor::mdctx
grpc_mdctx * mdctx
Definition: stream_encoder.h:63
GRPC_CHTTP2_HPACKC_NUM_FILTERS
#define GRPC_CHTTP2_HPACKC_NUM_FILTERS
Definition: stream_encoder.h:44
port_platform.h
gpr_uint8
uint8_t gpr_uint8
Definition: port_platform.h:307
grpc_chttp2_hpack_compressor::table_size
gpr_uint16 table_size
Definition: stream_encoder.h:52
grpc_chttp2_hpack_compressor
Definition: stream_encoder.h:48
metadata.h
GRPC_CHTTP2_HPACKC_MAX_TABLE_ELEMS
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_ELEMS
Definition: stream_encoder.h:46
grpc_mdstr
Definition: metadata.h:70
grpc_chttp2_encode
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
gpr_uint32
uint32_t gpr_uint32
Definition: port_platform.h:309
gpr_slice_buffer
Definition: slice_buffer.h:48
GRPC_CHTTP2_HPACKC_NUM_VALUES
#define GRPC_CHTTP2_HPACKC_NUM_VALUES
Definition: stream_encoder.h:45
frame.h
grpc_chttp2_hpack_compressor::timeout_key_str
grpc_mdstr * timeout_key_str
Definition: stream_encoder.h:65
grpc_mdctx
Definition: metadata.c:98
grpc_mdelem
Definition: metadata.h:78
gpr_uint16
uint16_t gpr_uint16
Definition: port_platform.h:308
slice_buffer.h
grpc_chttp2_hpack_compressor::table_elems
gpr_uint16 table_elems
Definition: stream_encoder.h:53
grpc_chttp2_hpack_compressor_destroy
void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c)
Definition: stream_encoder.c:462
grpc_chttp2_hpack_compressor::filter_elems_sum
gpr_uint32 filter_elems_sum
Definition: stream_encoder.h:49
slice.h
grpc_chttp2_hpack_compressor::tail_remote_index
gpr_uint32 tail_remote_index
Definition: stream_encoder.h:51
stream_op.h
grpc_chttp2_hpack_compressor_init
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c, grpc_mdctx *mdctx)
Definition: stream_encoder.c:455
grpc_stream_op
Definition: stream_op.h:162
grpc_stream_op_buffer
A stream op buffer is a wrapper around stream operations that is dynamically extendable.
Definition: stream_op.h:176
grpc_chttp2_preencode
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