GRPC Core  0.11.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hpack_parser.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_HPACK_PARSER_H
35 #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H
36 
37 #include <stddef.h>
38 
43 
45 
47  const gpr_uint8 *beg,
48  const gpr_uint8 *end);
49 
50 typedef struct {
51  char *str;
55 
57  /* user specified callback for each header output */
58  void (*on_header)(void *user_data, grpc_mdelem *md);
60 
61  /* current parse state - or a function that implements it */
63  /* future states dependent on the opening op code */
65  /* what to do after skipping prioritization data */
67  /* the value we're currently parsing */
68  union {
71  } parsing;
72  /* string parameters for each chunk */
75  /* parsed index */
77  /* length of source bytes for the currently parsing string */
79  /* number of source bytes read for the currently parsing string */
81  /* huffman decoding state */
83  /* is the string being decoded binary? */
85  /* is the current string huffman encoded? */
87  /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal
88  it should append a metadata boundary at the end of frame */
92 
93  /* hpack table */
95 };
96 
98  grpc_mdctx *mdctx);
100 
102 
103 /* returns 1 on success, 0 on error */
105  const gpr_uint8 *beg, const gpr_uint8 *end);
106 
107 /* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
108  the transport */
110  void *hpack_parser, grpc_chttp2_transport_parsing *transport_parsing,
111  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
112 
113 #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */
void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser *p, grpc_mdctx *mdctx)
Definition: hpack_parser.c:1343
uint8_t gpr_uint8
Definition: port_platform.h:310
int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p, const gpr_uint8 *beg, const gpr_uint8 *end)
Definition: hpack_parser.c:1368
Definition: hpack_table.h:59
grpc_chttp2_parse_error
Definition: frame.h:42
Definition: hpack_parser.h:56
uint32_t gpr_uint32
Definition: port_platform.h:312
gpr_uint32 capacity
Definition: hpack_parser.h:53
grpc_chttp2_hpack_parser_state state
Definition: hpack_parser.h:62
gpr_uint8 huff
Definition: hpack_parser.h:86
grpc_chttp2_hpack_parser_state after_prioritization
Definition: hpack_parser.h:66
gpr_uint16 huff_state
Definition: hpack_parser.h:82
gpr_uint32 strlen
Definition: hpack_parser.h:78
gpr_uint32 length
Definition: hpack_parser.h:52
void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser *p)
Definition: hpack_parser.c:1362
gpr_uint8 is_boundary
Definition: hpack_parser.h:89
gpr_uint32 base64_buffer
Definition: hpack_parser.h:91
Definition: metadata.c:98
gpr_uint8 binary
Definition: hpack_parser.h:84
Definition: metadata.h:78
Definition: internal.h:221
grpc_chttp2_hptbl table
Definition: hpack_parser.h:94
uint16_t gpr_uint16
Definition: port_platform.h:311
gpr_uint32 strgot
Definition: hpack_parser.h:80
Definition: hpack_parser.h:50
void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p)
Definition: hpack_parser.c:1357
const grpc_chttp2_hpack_parser_state * next_state
Definition: hpack_parser.h:64
Definition: internal.h:426
void(* on_header)(void *user_data, grpc_mdelem *md)
Definition: hpack_parser.h:58
union grpc_chttp2_hpack_parser::@21 parsing
char * str
Definition: hpack_parser.h:51
grpc_chttp2_hpack_parser_string value
Definition: hpack_parser.h:74
int(* grpc_chttp2_hpack_parser_state)(grpc_chttp2_hpack_parser *p, const gpr_uint8 *beg, const gpr_uint8 *end)
Definition: hpack_parser.h:46
gpr_uint8 is_eof
Definition: hpack_parser.h:90
grpc_chttp2_hpack_parser_string key
Definition: hpack_parser.h:73
gpr_uint32 index
Definition: hpack_parser.h:76
grpc_chttp2_hpack_parser_string * str
Definition: hpack_parser.h:70
grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(void *hpack_parser, grpc_chttp2_transport_parsing *transport_parsing, grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last)
Definition: hpack_parser.c:1377
Definition: slice.h:79
void * on_header_user_data
Definition: hpack_parser.h:59
gpr_uint32 * value
Definition: hpack_parser.h:69