3 * Copyright 2015 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H
20 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H
22 /* Parser for GRPC streams embedded in DATA frames */
24 #include <grpc/support/port_platform.h>
26 #include <grpc/slice.h>
27 #include <grpc/slice_buffer.h>
28 #include "src/core/ext/transport/chttp2/transport/frame.h"
29 #include "src/core/lib/transport/byte_stream.h"
30 #include "src/core/lib/transport/transport.h"
33 GRPC_CHTTP2_DATA_FH_0,
34 GRPC_CHTTP2_DATA_FH_1,
35 GRPC_CHTTP2_DATA_FH_2,
36 GRPC_CHTTP2_DATA_FH_3,
37 GRPC_CHTTP2_DATA_FH_4,
38 GRPC_CHTTP2_DATA_FRAME,
39 GRPC_CHTTP2_DATA_ERROR
40 } grpc_chttp2_stream_state;
43 class Chttp2IncomingByteStream;
44 } // namespace grpc_core
46 struct grpc_chttp2_data_parser {
47 grpc_chttp2_data_parser() = default;
48 ~grpc_chttp2_data_parser();
50 grpc_chttp2_stream_state state = GRPC_CHTTP2_DATA_FH_0;
51 uint8_t frame_type = 0;
52 uint32_t frame_size = 0;
53 grpc_error* error = GRPC_ERROR_NONE;
55 bool is_frame_compressed = false;
56 grpc_core::Chttp2IncomingByteStream* parsing_frame = nullptr;
59 /* start processing a new data frame */
60 grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
63 grpc_chttp2_stream* s);
65 /* handle a slice of a data frame - is_last indicates the last slice of a
67 grpc_error* grpc_chttp2_data_parser_parse(void* parser,
68 grpc_chttp2_transport* t,
69 grpc_chttp2_stream* s,
70 const grpc_slice& slice, int is_last);
72 void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
73 uint32_t write_bytes, int is_eof,
74 grpc_transport_one_way_stats* stats,
75 grpc_slice_buffer* outbuf);
77 grpc_error* grpc_deframe_unprocessed_incoming_frames(
78 grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
79 grpc_slice_buffer* slices, grpc_slice* slice_out,
80 grpc_core::OrphanablePtr<grpc_core::ByteStream>* stream_out);
82 #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */