blob: f64c44f3d9a057ac39826678cb5621a47eac1ef1 [file] [log] [blame]
nnoble0c475f02014-12-05 15:37:39 -08001/*
2 *
David Garcia Quintas3598d442016-03-15 14:53:05 -07003 * Copyright 2015-2016, Google Inc.
nnoble0c475f02014-12-05 15:37:39 -08004 * 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
Craig Tiller9a4dddd2016-03-25 17:08:13 -070034#ifndef GRPC_CORE_LIB_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
35#define GRPC_CORE_LIB_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
nnoble0c475f02014-12-05 15:37:39 -080036
nnoble0c475f02014-12-05 15:37:39 -080037#include <grpc/support/port_platform.h>
38#include <grpc/support/slice.h>
39#include <grpc/support/slice_buffer.h>
Craig Tiller9533d042016-03-25 17:11:06 -070040#include "src/core/lib/iomgr/exec_ctx.h"
41#include "src/core/lib/transport/chttp2/frame.h"
nnoble0c475f02014-12-05 15:37:39 -080042
Craig Tillera82950e2015-09-22 12:33:20 -070043typedef enum {
nnoble0c475f02014-12-05 15:37:39 -080044 GRPC_CHTTP2_GOAWAY_LSI0,
45 GRPC_CHTTP2_GOAWAY_LSI1,
46 GRPC_CHTTP2_GOAWAY_LSI2,
47 GRPC_CHTTP2_GOAWAY_LSI3,
48 GRPC_CHTTP2_GOAWAY_ERR0,
49 GRPC_CHTTP2_GOAWAY_ERR1,
50 GRPC_CHTTP2_GOAWAY_ERR2,
51 GRPC_CHTTP2_GOAWAY_ERR3,
52 GRPC_CHTTP2_GOAWAY_DEBUG
53} grpc_chttp2_goaway_parse_state;
54
Craig Tillera82950e2015-09-22 12:33:20 -070055typedef struct {
nnoble0c475f02014-12-05 15:37:39 -080056 grpc_chttp2_goaway_parse_state state;
Craig Tiller7536af02015-12-22 13:49:30 -080057 uint32_t last_stream_id;
58 uint32_t error_code;
nnoble0c475f02014-12-05 15:37:39 -080059 char *debug_data;
Craig Tiller7536af02015-12-22 13:49:30 -080060 uint32_t debug_length;
61 uint32_t debug_pos;
nnoble0c475f02014-12-05 15:37:39 -080062} grpc_chttp2_goaway_parser;
63
Craig Tillera82950e2015-09-22 12:33:20 -070064void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p);
65void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
66grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
Craig Tiller7536af02015-12-22 13:49:30 -080067 grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
Craig Tillera82950e2015-09-22 12:33:20 -070068grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
69 grpc_exec_ctx *exec_ctx, void *parser,
70 grpc_chttp2_transport_parsing *transport_parsing,
71 grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
nnoble0c475f02014-12-05 15:37:39 -080072
Craig Tiller7536af02015-12-22 13:49:30 -080073void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
Craig Tillera82950e2015-09-22 12:33:20 -070074 gpr_slice debug_data,
75 gpr_slice_buffer *slice_buffer);
nnoble0c475f02014-12-05 15:37:39 -080076
Craig Tiller9a4dddd2016-03-25 17:08:13 -070077#endif /* GRPC_CORE_LIB_TRANSPORT_CHTTP2_FRAME_GOAWAY_H */