diff options
author | akastornov <akastornov@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
commit | 3a2de774d91ca8d7325aaf81c200b1d2047725e6 (patch) | |
tree | 5674a780ce03a8bbd794733a19c7a70d587e4a14 /contrib/libs/grpc/src/core/ext | |
parent | 7bd11ff35e97544d119e43447e3e865f2588ee7f (diff) | |
download | ydb-3a2de774d91ca8d7325aaf81c200b1d2047725e6.tar.gz |
Restoring authorship annotation for <akastornov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/core/ext')
30 files changed, 1041 insertions, 1041 deletions
diff --git a/contrib/libs/grpc/src/core/ext/README.md b/contrib/libs/grpc/src/core/ext/README.md index 0812b20823..81d492b43c 100644 --- a/contrib/libs/grpc/src/core/ext/README.md +++ b/contrib/libs/grpc/src/core/ext/README.md @@ -1,5 +1,5 @@ -Optional plugins for gRPC Core: Modules in this directory extend gRPC Core in -useful ways. All optional code belongs here. - -NOTE: The movement of code between lib and ext is an ongoing effort, so this -directory currently contains too much of the core library. +Optional plugins for gRPC Core: Modules in this directory extend gRPC Core in +useful ways. All optional code belongs here. + +NOTE: The movement of code between lib and ext is an ongoing effort, so this +directory currently contains too much of the core library. diff --git a/contrib/libs/grpc/src/core/ext/transport/README.md b/contrib/libs/grpc/src/core/ext/transport/README.md index 2290568784..70273b169e 100644 --- a/contrib/libs/grpc/src/core/ext/transport/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/README.md @@ -1 +1 @@ -Transports for gRPC +Transports for gRPC diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md index 8880a47460..1d63c5f064 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md @@ -1 +1 @@ -CHTTP2 - gRPC's implementation of a HTTP2 based transport +CHTTP2 - gRPC's implementation of a HTTP2 based transport diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h index e2ffe4e405..1d0af6d7d7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h @@ -1,36 +1,36 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H + #include <grpc/support/port_platform.h> -#include <string.h> - +#include <string.h> + /* Returns 1 if the version is supported, 0 otherwise. */ int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size); - -/* Returns the number of protocol versions to advertise */ -size_t grpc_chttp2_num_alpn_versions(void); - -/* Returns the protocol version at index i (0 <= i < - * grpc_chttp2_num_alpn_versions()) */ + +/* Returns the number of protocol versions to advertise */ +size_t grpc_chttp2_num_alpn_versions(void); + +/* Returns the protocol version at index i (0 <= i < + * grpc_chttp2_num_alpn_versions()) */ const char* grpc_chttp2_get_alpn_version_index(size_t i); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h index 322cbc2eba..4e2becaafe 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H + #include <grpc/support/port_platform.h> - + #include "src/core/ext/filters/client_channel/connector.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" namespace grpc_core { - + class Chttp2Connector : public SubchannelConnector { public: Chttp2Connector(); @@ -72,4 +72,4 @@ class Chttp2Connector : public SubchannelConnector { } // namespace grpc_core -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md index fa11463388..df33b76a4a 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md @@ -1 +1 @@ -Plugin for creating insecure channels using chttp2 +Plugin for creating insecure channels using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md index 405a86e5db..6736a4911a 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md @@ -1 +1 @@ -Plugin for creating secure channels using chttp2 +Plugin for creating secure channels using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h index 095cc5e4c0..d94880b996 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -1,38 +1,38 @@ -/* - * +/* + * * Copyright 2016 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> - +#include <grpc/impl/codegen/grpc_types.h> + #include "src/core/lib/iomgr/error.h" #include "src/core/lib/surface/server.h" - + namespace grpc_core { -/// Adds a port to \a server. Sets \a port_num to the port number. -/// Takes ownership of \a args. +/// Adds a port to \a server. Sets \a port_num to the port number. +/// Takes ownership of \a args. grpc_error* Chttp2ServerAddPort(Server* server, const char* addr, grpc_channel_args* args, int* port_num); - + } // namespace grpc_core -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md index fc0bc14ed7..74dc9e94a0 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md @@ -1 +1 @@ -Plugin for creating insecure servers using chttp2 +Plugin for creating insecure servers using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md index 6bda696a9a..372c6dc24c 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md @@ -1 +1 @@ -Plugin for creating secure servers using chttp2 +Plugin for creating secure servers using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md index 4684e58759..7471b0243b 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md @@ -1,4 +1,4 @@ -chttp2 transport plugin - implements grpc over http2 - -Used by chttp2/{client,server}/{insecure,secure} plugins to implement most of -their functionality +chttp2 transport plugin - implements grpc over http2 + +Used by chttp2/{client,server}/{insecure,secure} plugins to implement most of +their functionality diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h index 1cbca033a1..c3bc8fa701 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -1,56 +1,56 @@ -/* - * +/* + * * Copyright 2016 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <stdbool.h> - -struct grpc_base64_decode_context { - /* input/output: */ +#include <grpc/slice.h> +#include <stdbool.h> + +struct grpc_base64_decode_context { + /* input/output: */ const uint8_t* input_cur; const uint8_t* input_end; uint8_t* output_cur; uint8_t* output_end; - /* Indicate if the decoder should handle the tail of input data*/ - bool contains_tail; -}; - -/* base64 decode a grpc_base64_decode_context util either input_end is reached - or output_end is reached. When input_end is reached, (input_end - input_cur) - is less than 4. When output_end is reached, (output_end - output_cur) is less - than 3. Returns false if decoding is failed. */ + /* Indicate if the decoder should handle the tail of input data*/ + bool contains_tail; +}; + +/* base64 decode a grpc_base64_decode_context util either input_end is reached + or output_end is reached. When input_end is reached, (input_end - input_cur) + is less than 4. When output_end is reached, (output_end - output_cur) is less + than 3. Returns false if decoding is failed. */ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx); - -/* base64 decode a slice with pad chars. Returns a new slice, does not take - ownership of the input. Returns an empty slice if decoding is failed. */ + +/* base64 decode a slice with pad chars. Returns a new slice, does not take + ownership of the input. Returns an empty slice if decoding is failed. */ grpc_slice grpc_chttp2_base64_decode(const grpc_slice& input); - -/* base64 decode a slice without pad chars, data length is needed. Returns a new - slice, does not take ownership of the input. Returns an empty slice if - decoding is failed. */ + +/* base64 decode a slice without pad chars, data length is needed. Returns a new + slice, does not take ownership of the input. Returns an empty slice if + decoding is failed. */ grpc_slice grpc_chttp2_base64_decode_with_length(const grpc_slice& input, - size_t output_length); - + size_t output_length); + /* Infer the length of decoded data from encoded data. */ size_t grpc_chttp2_base64_infer_length_after_decode(const grpc_slice& slice); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h index 4f7ee67bd3..10c3523877 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -1,42 +1,42 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> - -/* base64 encode a slice. Returns a new slice, does not take ownership of the - input */ +#include <grpc/slice.h> + +/* base64 encode a slice. Returns a new slice, does not take ownership of the + input */ grpc_slice grpc_chttp2_base64_encode(const grpc_slice& input); - -/* Compress a slice with the static huffman encoder detailed in the hpack - standard. Returns a new slice, does not take ownership of the input */ + +/* Compress a slice with the static huffman encoder detailed in the hpack + standard. Returns a new slice, does not take ownership of the input */ grpc_slice grpc_chttp2_huffman_compress(const grpc_slice& input); - -/* equivalent to: - grpc_slice x = grpc_chttp2_base64_encode(input); - grpc_slice y = grpc_chttp2_huffman_compress(x); + +/* equivalent to: + grpc_slice x = grpc_chttp2_base64_encode(input); + grpc_slice y = grpc_chttp2_huffman_compress(x); grpc_slice_unref_internal( x); - return y; */ + return y; */ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress( const grpc_slice& input); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h index b04630bbe2..b2a7932eee 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -1,39 +1,39 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H + #include <grpc/support/port_platform.h> #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/transport/transport.h" - +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/transport/transport.h" + extern grpc_core::TraceFlag grpc_http_trace; extern grpc_core::TraceFlag grpc_keepalive_trace; extern grpc_core::TraceFlag grpc_trace_http2_stream_state; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser; - + extern bool g_flow_control_enabled; - + grpc_transport* grpc_create_chttp2_transport( const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client, grpc_resource_user* resource_user = nullptr); @@ -41,12 +41,12 @@ grpc_transport* grpc_create_chttp2_transport( grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode> grpc_chttp2_transport_get_socket_node(grpc_transport* transport); -/// Takes ownership of \a read_buffer, which (if non-NULL) contains -/// leftover bytes previously read from the endpoint (e.g., by handshakers). +/// Takes ownership of \a read_buffer, which (if non-NULL) contains +/// leftover bytes previously read from the endpoint (e.g., by handshakers). /// If non-null, \a notify_on_receive_settings will be scheduled when /// HTTP/2 settings are received from the peer. void grpc_chttp2_transport_start_reading( grpc_transport* transport, grpc_slice_buffer* read_buffer, grpc_closure* notify_on_receive_settings); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h index 083c0076e7..1f5a7b2c0f 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h @@ -1,47 +1,47 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H - -#include <grpc/support/port_platform.h> - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H + +#include <grpc/support/port_platform.h> + #include <grpc/slice.h> -#include "src/core/lib/iomgr/error.h" - -/* defined in internal.h */ -typedef struct grpc_chttp2_stream grpc_chttp2_stream; -typedef struct grpc_chttp2_transport grpc_chttp2_transport; - -#define GRPC_CHTTP2_FRAME_DATA 0 -#define GRPC_CHTTP2_FRAME_HEADER 1 -#define GRPC_CHTTP2_FRAME_CONTINUATION 9 -#define GRPC_CHTTP2_FRAME_RST_STREAM 3 -#define GRPC_CHTTP2_FRAME_SETTINGS 4 -#define GRPC_CHTTP2_FRAME_PING 6 -#define GRPC_CHTTP2_FRAME_GOAWAY 7 -#define GRPC_CHTTP2_FRAME_WINDOW_UPDATE 8 - -#define GRPC_CHTTP2_DATA_FLAG_END_STREAM 1 -#define GRPC_CHTTP2_FLAG_ACK 1 -#define GRPC_CHTTP2_DATA_FLAG_END_HEADERS 4 -#define GRPC_CHTTP2_DATA_FLAG_PADDED 8 -#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20 - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H */ +#include "src/core/lib/iomgr/error.h" + +/* defined in internal.h */ +typedef struct grpc_chttp2_stream grpc_chttp2_stream; +typedef struct grpc_chttp2_transport grpc_chttp2_transport; + +#define GRPC_CHTTP2_FRAME_DATA 0 +#define GRPC_CHTTP2_FRAME_HEADER 1 +#define GRPC_CHTTP2_FRAME_CONTINUATION 9 +#define GRPC_CHTTP2_FRAME_RST_STREAM 3 +#define GRPC_CHTTP2_FRAME_SETTINGS 4 +#define GRPC_CHTTP2_FRAME_PING 6 +#define GRPC_CHTTP2_FRAME_GOAWAY 7 +#define GRPC_CHTTP2_FRAME_WINDOW_UPDATE 8 + +#define GRPC_CHTTP2_DATA_FLAG_END_STREAM 1 +#define GRPC_CHTTP2_FLAG_ACK 1 +#define GRPC_CHTTP2_DATA_FLAG_END_HEADERS 4 +#define GRPC_CHTTP2_DATA_FLAG_PADDED 8 +#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20 + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h index ec3890098e..ee08a4d758 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h @@ -1,82 +1,82 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H - -/* Parser for GRPC streams embedded in DATA frames */ - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H + +/* Parser for GRPC streams embedded in DATA frames */ + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/byte_stream.h" -#include "src/core/lib/transport/transport.h" - -typedef enum { - GRPC_CHTTP2_DATA_FH_0, - GRPC_CHTTP2_DATA_FH_1, - GRPC_CHTTP2_DATA_FH_2, - GRPC_CHTTP2_DATA_FH_3, - GRPC_CHTTP2_DATA_FH_4, - GRPC_CHTTP2_DATA_FRAME, - GRPC_CHTTP2_DATA_ERROR -} grpc_chttp2_stream_state; - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/byte_stream.h" +#include "src/core/lib/transport/transport.h" + +typedef enum { + GRPC_CHTTP2_DATA_FH_0, + GRPC_CHTTP2_DATA_FH_1, + GRPC_CHTTP2_DATA_FH_2, + GRPC_CHTTP2_DATA_FH_3, + GRPC_CHTTP2_DATA_FH_4, + GRPC_CHTTP2_DATA_FRAME, + GRPC_CHTTP2_DATA_ERROR +} grpc_chttp2_stream_state; + namespace grpc_core { class Chttp2IncomingByteStream; } // namespace grpc_core - + struct grpc_chttp2_data_parser { grpc_chttp2_data_parser() = default; ~grpc_chttp2_data_parser(); - + grpc_chttp2_stream_state state = GRPC_CHTTP2_DATA_FH_0; uint8_t frame_type = 0; uint32_t frame_size = 0; grpc_error* error = GRPC_ERROR_NONE; - + bool is_frame_compressed = false; grpc_core::Chttp2IncomingByteStream* parsing_frame = nullptr; }; - -/* start processing a new data frame */ + +/* start processing a new data frame */ grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser, - uint8_t flags, + uint8_t flags, uint32_t stream_id, grpc_chttp2_stream* s); - -/* handle a slice of a data frame - is_last indicates the last slice of a - frame */ + +/* handle a slice of a data frame - is_last indicates the last slice of a + frame */ grpc_error* grpc_chttp2_data_parser_parse(void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf, - uint32_t write_bytes, int is_eof, + uint32_t write_bytes, int is_eof, grpc_transport_one_way_stats* stats, grpc_slice_buffer* outbuf); - + grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_chttp2_data_parser* p, grpc_chttp2_stream* s, grpc_slice_buffer* slices, grpc_slice* slice_out, grpc_core::OrphanablePtr<grpc_core::ByteStream>* stream_out); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h index df6274d628..e3f0a15f82 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -1,49 +1,49 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" - -typedef enum { - GRPC_CHTTP2_GOAWAY_LSI0, - GRPC_CHTTP2_GOAWAY_LSI1, - GRPC_CHTTP2_GOAWAY_LSI2, - GRPC_CHTTP2_GOAWAY_LSI3, - GRPC_CHTTP2_GOAWAY_ERR0, - GRPC_CHTTP2_GOAWAY_ERR1, - GRPC_CHTTP2_GOAWAY_ERR2, - GRPC_CHTTP2_GOAWAY_ERR3, - GRPC_CHTTP2_GOAWAY_DEBUG -} grpc_chttp2_goaway_parse_state; - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" + +typedef enum { + GRPC_CHTTP2_GOAWAY_LSI0, + GRPC_CHTTP2_GOAWAY_LSI1, + GRPC_CHTTP2_GOAWAY_LSI2, + GRPC_CHTTP2_GOAWAY_LSI3, + GRPC_CHTTP2_GOAWAY_ERR0, + GRPC_CHTTP2_GOAWAY_ERR1, + GRPC_CHTTP2_GOAWAY_ERR2, + GRPC_CHTTP2_GOAWAY_ERR3, + GRPC_CHTTP2_GOAWAY_DEBUG +} grpc_chttp2_goaway_parse_state; + struct grpc_chttp2_goaway_parser { - grpc_chttp2_goaway_parse_state state; - uint32_t last_stream_id; - uint32_t error_code; + grpc_chttp2_goaway_parse_state state; + uint32_t last_stream_id; + uint32_t error_code; char* debug_data; - uint32_t debug_length; - uint32_t debug_pos; + uint32_t debug_length; + uint32_t debug_pos; }; void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p); void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p); @@ -54,9 +54,9 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, + +void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, const grpc_slice& debug_data, grpc_slice_buffer* slice_buffer); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h index e356bf43f0..5529c2c893 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -1,44 +1,44 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" + struct grpc_chttp2_ping_parser { - uint8_t byte; - uint8_t is_ack; + uint8_t byte; + uint8_t is_ack; uint64_t opaque_8bytes; }; grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes); - + grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser, - uint32_t length, uint8_t flags); + uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_ping_parser_parse(void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + /* Test-only function for disabling ping ack */ void grpc_set_disable_ping_ack(bool disable_ping_ack); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index e324ee2cfc..93592da6aa 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -1,37 +1,37 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_rst_stream_parser { - uint8_t byte; - uint8_t reason_bytes[4]; + uint8_t byte; + uint8_t reason_bytes[4]; }; -grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, +grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats* stats); - + // Adds RST_STREAM frame to t->qbuf (buffer for the next write). Should be // called when we want to add RST_STREAM and we are not in // write_action_begin_locked. @@ -46,5 +46,5 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h index 181471401c..144d6b9de9 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -1,53 +1,53 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" - -typedef enum { - GRPC_CHTTP2_SPS_ID0, - GRPC_CHTTP2_SPS_ID1, - GRPC_CHTTP2_SPS_VAL0, - GRPC_CHTTP2_SPS_VAL1, - GRPC_CHTTP2_SPS_VAL2, - GRPC_CHTTP2_SPS_VAL3 -} grpc_chttp2_settings_parse_state; - + +typedef enum { + GRPC_CHTTP2_SPS_ID0, + GRPC_CHTTP2_SPS_ID1, + GRPC_CHTTP2_SPS_VAL0, + GRPC_CHTTP2_SPS_VAL1, + GRPC_CHTTP2_SPS_VAL2, + GRPC_CHTTP2_SPS_VAL3 +} grpc_chttp2_settings_parse_state; + struct grpc_chttp2_settings_parser { - grpc_chttp2_settings_parse_state state; + grpc_chttp2_settings_parse_state state; uint32_t* target_settings; - uint8_t is_ack; - uint16_t id; - uint32_t value; - uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS]; + uint8_t is_ack; + uint16_t id; + uint32_t value; + uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS]; }; -/* Create a settings frame by diffing old & new, and updating old to be new */ +/* Create a settings frame by diffing old & new, and updating old to be new */ grpc_slice grpc_chttp2_settings_create(uint32_t* old, const uint32_t* newval, - uint32_t force_mask, size_t count); -/* Create an ack settings frame */ -grpc_slice grpc_chttp2_settings_ack_create(void); - + uint32_t force_mask, size_t count); +/* Create an ack settings frame */ +grpc_slice grpc_chttp2_settings_ack_create(void); + grpc_error* grpc_chttp2_settings_parser_begin_frame( grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags, uint32_t* settings); @@ -56,5 +56,5 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h index 340445d87a..e21b0e0ed0 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -1,38 +1,38 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_window_update_parser { - uint8_t byte; - uint8_t is_connection_update; - uint32_t amount; + uint8_t byte; + uint8_t is_connection_update; + uint32_t amount; }; -grpc_slice grpc_chttp2_window_update_create( +grpc_slice grpc_chttp2_window_update_create( uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats* stats); - + grpc_error* grpc_chttp2_window_update_parser_begin_frame( grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_window_update_parser_parse(void* parser, @@ -40,5 +40,5 @@ grpc_error* grpc_chttp2_window_update_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 5093f80ae2..f8d1c893b7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -1,69 +1,69 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/metadata.h" -#include "src/core/lib/transport/metadata_batch.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/metadata_batch.h" +#include "src/core/lib/transport/transport.h" + // This should be <= 8. We use 6 to save space. #define GRPC_CHTTP2_HPACKC_NUM_VALUES_BITS 6 #define GRPC_CHTTP2_HPACKC_NUM_VALUES (1 << GRPC_CHTTP2_HPACKC_NUM_VALUES_BITS) -/* initial table size, per spec */ -#define GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE 4096 -/* maximum table size we'll actually use */ -#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024) - +/* initial table size, per spec */ +#define GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE 4096 +/* maximum table size we'll actually use */ +#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024) + extern grpc_core::TraceFlag grpc_http_trace; struct grpc_chttp2_hpack_compressor { - uint32_t max_table_size; - uint32_t max_table_elems; - uint32_t cap_table_elems; - /** maximum number of bytes we'll use for the decode table (to guard against - peers ooming us by setting decode table size high) */ - uint32_t max_usable_size; - /* one before the lowest usable table index */ - uint32_t tail_remote_index; - uint32_t table_size; - uint32_t table_elems; + uint32_t max_table_size; + uint32_t max_table_elems; + uint32_t cap_table_elems; + /** maximum number of bytes we'll use for the decode table (to guard against + peers ooming us by setting decode table size high) */ + uint32_t max_usable_size; + /* one before the lowest usable table index */ + uint32_t tail_remote_index; + uint32_t table_size; + uint32_t table_elems; uint16_t* table_elem_size; /** if non-zero, advertise to the decoder that we'll start using a table of this size */ uint8_t advertise_table_size_change; - - /* filter tables for elems: this tables provides an approximate - popularity count for particular hashes, and are used to determine whether - a new literal should be added to the compression table or not. - They track a single integer that counts how often a particular value has - been seen. When that count reaches max (255), all values are halved. */ + + /* filter tables for elems: this tables provides an approximate + popularity count for particular hashes, and are used to determine whether + a new literal should be added to the compression table or not. + They track a single integer that counts how often a particular value has + been seen. When that count reaches max (255), all values are halved. */ uint32_t filter_elems_sum; uint8_t filter_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES]; - - /* entry tables for keys & elems: these tables track values that have been - seen and *may* be in the decompressor table */ + + /* entry tables for keys & elems: these tables track values that have been + seen and *may* be in the decompressor table */ struct { struct { grpc_mdelem value; @@ -82,14 +82,14 @@ struct grpc_chttp2_hpack_compressor { } entries[GRPC_CHTTP2_HPACKC_NUM_VALUES]; } key_table; /* Key table management */ }; - + void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c); void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c); -void grpc_chttp2_hpack_compressor_set_max_table_size( +void grpc_chttp2_hpack_compressor_set_max_table_size( grpc_chttp2_hpack_compressor* c, uint32_t max_table_size); -void grpc_chttp2_hpack_compressor_set_max_usable_size( +void grpc_chttp2_hpack_compressor_set_max_usable_size( grpc_chttp2_hpack_compressor* c, uint32_t max_table_size); - + struct grpc_encode_header_options { uint32_t stream_id; bool is_eof; @@ -104,4 +104,4 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, const grpc_encode_header_options* options, grpc_slice_buffer* outbuf); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h index 1b859c4d7c..dc45940986 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -1,37 +1,37 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/ext/transport/chttp2/transport/hpack_table.h" -#include "src/core/lib/transport/metadata.h" - -typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; - +#include <stddef.h> + +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/hpack_table.h" +#include "src/core/lib/transport/metadata.h" + +typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; + typedef grpc_error* (*grpc_chttp2_hpack_parser_state)( grpc_chttp2_hpack_parser* p, const uint8_t* beg, const uint8_t* end); - + struct grpc_chttp2_hpack_parser_string { bool copied; struct { @@ -43,31 +43,31 @@ struct grpc_chttp2_hpack_parser_string { } copied; } data; }; -struct grpc_chttp2_hpack_parser { - /* user specified callback for each header output */ +struct grpc_chttp2_hpack_parser { + /* user specified callback for each header output */ grpc_error* (*on_header)(void* user_data, grpc_mdelem md); void* on_header_user_data; - + grpc_error* last_error; - - /* current parse state - or a function that implements it */ - grpc_chttp2_hpack_parser_state state; - /* future states dependent on the opening op code */ + + /* current parse state - or a function that implements it */ + grpc_chttp2_hpack_parser_state state; + /* future states dependent on the opening op code */ const grpc_chttp2_hpack_parser_state* next_state; - /* what to do after skipping prioritization data */ - grpc_chttp2_hpack_parser_state after_prioritization; + /* what to do after skipping prioritization data */ + grpc_chttp2_hpack_parser_state after_prioritization; /* the refcount of the slice that we're currently parsing */ grpc_slice_refcount* current_slice_refcount; - /* the value we're currently parsing */ - union { + /* the value we're currently parsing */ + union { uint32_t* value; grpc_chttp2_hpack_parser_string* str; - } parsing; - /* string parameters for each chunk */ - grpc_chttp2_hpack_parser_string key; - grpc_chttp2_hpack_parser_string value; - /* parsed index */ - uint32_t index; + } parsing; + /* string parameters for each chunk */ + grpc_chttp2_hpack_parser_string key; + grpc_chttp2_hpack_parser_string value; + /* parsed index */ + uint32_t index; /* When we parse a value string, we determine the metadata element for a specific index, which we need again when we're finishing up with that header. To avoid calculating the metadata element for that index a second @@ -76,42 +76,42 @@ struct grpc_chttp2_hpack_parser { #ifndef NDEBUG int64_t precomputed_md_index; #endif - /* length of source bytes for the currently parsing string */ - uint32_t strlen; - /* number of source bytes read for the currently parsing string */ - uint32_t strgot; - /* huffman decoding state */ - int16_t huff_state; - /* is the string being decoded binary? */ - uint8_t binary; - /* is the current string huffman encoded? */ - uint8_t huff; - /* is a dynamic table update allowed? */ - uint8_t dynamic_table_update_allowed; - /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal - it should append a metadata boundary at the end of frame */ - uint8_t is_boundary; - uint8_t is_eof; - uint32_t base64_buffer; - - /* hpack table */ - grpc_chttp2_hptbl table; -}; - + /* length of source bytes for the currently parsing string */ + uint32_t strlen; + /* number of source bytes read for the currently parsing string */ + uint32_t strgot; + /* huffman decoding state */ + int16_t huff_state; + /* is the string being decoded binary? */ + uint8_t binary; + /* is the current string huffman encoded? */ + uint8_t huff; + /* is a dynamic table update allowed? */ + uint8_t dynamic_table_update_allowed; + /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal + it should append a metadata boundary at the end of frame */ + uint8_t is_boundary; + uint8_t is_eof; + uint32_t base64_buffer; + + /* hpack table */ + grpc_chttp2_hptbl table; +}; + void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p); void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p); - + void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p); - + grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p, const grpc_slice& slice); - -/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for - the transport */ + +/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for + the transport */ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h index 34c3dceda7..9ba29d8525 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -1,52 +1,52 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> +#include <grpc/slice.h> #include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" - -/* HPACK header table */ - -/* last index in the static table */ -#define GRPC_CHTTP2_LAST_STATIC_ENTRY 61 - -/* Initial table size as per the spec */ -#define GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE 4096 -/* Maximum table size that we'll use */ -#define GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE -/* Per entry overhead bytes as per the spec */ -#define GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD 32 -#if 0 -/* Maximum number of entries we could possibly fit in the table, given defined - overheads */ -#define GRPC_CHTTP2_MAX_TABLE_COUNT \ - ((GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / \ - GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD) -#endif - -/* hpack decoder table */ + +/* HPACK header table */ + +/* last index in the static table */ +#define GRPC_CHTTP2_LAST_STATIC_ENTRY 61 + +/* Initial table size as per the spec */ +#define GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE 4096 +/* Maximum table size that we'll use */ +#define GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE +/* Per entry overhead bytes as per the spec */ +#define GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD 32 +#if 0 +/* Maximum number of entries we could possibly fit in the table, given defined + overheads */ +#define GRPC_CHTTP2_MAX_TABLE_COUNT \ + ((GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / \ + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD) +#endif + +/* hpack decoder table */ struct grpc_chttp2_hptbl { static uint32_t entries_for_bytes(uint32_t bytes) { return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / @@ -64,35 +64,35 @@ struct grpc_chttp2_hptbl { memset(ents, 0, AllocSize); } - /* the first used entry in ents */ + /* the first used entry in ents */ uint32_t first_ent = 0; - /* how many entries are in the table */ + /* how many entries are in the table */ uint32_t num_ents = 0; - /* the amount of memory used by the table, according to the hpack algorithm */ + /* the amount of memory used by the table, according to the hpack algorithm */ uint32_t mem_used = 0; - /* the max memory allowed to be used by the table, according to the hpack - algorithm */ + /* the max memory allowed to be used by the table, according to the hpack + algorithm */ uint32_t max_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; - /* the currently agreed size of the table, according to the hpack algorithm */ + /* the currently agreed size of the table, according to the hpack algorithm */ uint32_t current_table_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; - /* Maximum number of entries we could possibly fit in the table, given defined - overheads */ + /* Maximum number of entries we could possibly fit in the table, given defined + overheads */ uint32_t max_entries = kInitialCapacity; - /* Number of entries allocated in ents */ + /* Number of entries allocated in ents */ uint32_t cap_entries = kInitialCapacity; - /* a circular buffer of headers - this is stored in the opposite order to - what hpack specifies, in order to simplify table management a little... - meaning lookups need to SUBTRACT from the end position */ + /* a circular buffer of headers - this is stored in the opposite order to + what hpack specifies, in order to simplify table management a little... + meaning lookups need to SUBTRACT from the end position */ grpc_mdelem* ents = nullptr; }; - + void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl); void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl, - uint32_t max_bytes); + uint32_t max_bytes); grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, - uint32_t bytes); - -/* lookup a table entry based on its hpack index */ + uint32_t bytes); + +/* lookup a table entry based on its hpack index */ grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( @@ -116,7 +116,7 @@ inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, } } } -/* add a table entry to the index */ +/* add a table entry to the index */ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) GRPC_MUST_USE_RESULT; @@ -136,13 +136,13 @@ inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { return 0; } -/* Find a key/value pair in the table... returns the index in the table of the - most similar entry, or 0 if the value was not found */ +/* Find a key/value pair in the table... returns the index in the table of the + most similar entry, or 0 if the value was not found */ struct grpc_chttp2_hptbl_find_result { - uint32_t index; - int has_value; + uint32_t index; + int has_value; }; -grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( +grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( const grpc_chttp2_hptbl* tbl, grpc_mdelem md); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt index 08842a0267..441fb95707 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt @@ -1,66 +1,66 @@ -Static table, from the spec: - +-------+-----------------------------+---------------+ - | Index | Header Name | Header Value | - +-------+-----------------------------+---------------+ - | 1 | :authority | | - | 2 | :method | GET | - | 3 | :method | POST | - | 4 | :path | / | - | 5 | :path | /index.html | - | 6 | :scheme | http | - | 7 | :scheme | https | - | 8 | :status | 200 | - | 9 | :status | 204 | - | 10 | :status | 206 | - | 11 | :status | 304 | - | 12 | :status | 400 | - | 13 | :status | 404 | - | 14 | :status | 500 | - | 15 | accept-charset | | - | 16 | accept-encoding | gzip, deflate | - | 17 | accept-language | | - | 18 | accept-ranges | | - | 19 | accept | | - | 20 | access-control-allow-origin | | - | 21 | age | | - | 22 | allow | | - | 23 | authorization | | - | 24 | cache-control | | - | 25 | content-disposition | | - | 26 | content-encoding | | - | 27 | content-language | | - | 28 | content-length | | - | 29 | content-location | | - | 30 | content-range | | - | 31 | content-type | | - | 32 | cookie | | - | 33 | date | | - | 34 | etag | | - | 35 | expect | | - | 36 | expires | | - | 37 | from | | - | 38 | host | | - | 39 | if-match | | - | 40 | if-modified-since | | - | 41 | if-none-match | | - | 42 | if-range | | - | 43 | if-unmodified-since | | - | 44 | last-modified | | - | 45 | link | | - | 46 | location | | - | 47 | max-forwards | | - | 48 | proxy-authenticate | | - | 49 | proxy-authorization | | - | 50 | range | | - | 51 | referer | | - | 52 | refresh | | - | 53 | retry-after | | - | 54 | server | | - | 55 | set-cookie | | - | 56 | strict-transport-security | | - | 57 | transfer-encoding | | - | 58 | user-agent | | - | 59 | vary | | - | 60 | via | | - | 61 | www-authenticate | | - +-------+-----------------------------+---------------+ +Static table, from the spec: + +-------+-----------------------------+---------------+ + | Index | Header Name | Header Value | + +-------+-----------------------------+---------------+ + | 1 | :authority | | + | 2 | :method | GET | + | 3 | :method | POST | + | 4 | :path | / | + | 5 | :path | /index.html | + | 6 | :scheme | http | + | 7 | :scheme | https | + | 8 | :status | 200 | + | 9 | :status | 204 | + | 10 | :status | 206 | + | 11 | :status | 304 | + | 12 | :status | 400 | + | 13 | :status | 404 | + | 14 | :status | 500 | + | 15 | accept-charset | | + | 16 | accept-encoding | gzip, deflate | + | 17 | accept-language | | + | 18 | accept-ranges | | + | 19 | accept | | + | 20 | access-control-allow-origin | | + | 21 | age | | + | 22 | allow | | + | 23 | authorization | | + | 24 | cache-control | | + | 25 | content-disposition | | + | 26 | content-encoding | | + | 27 | content-language | | + | 28 | content-length | | + | 29 | content-location | | + | 30 | content-range | | + | 31 | content-type | | + | 32 | cookie | | + | 33 | date | | + | 34 | etag | | + | 35 | expect | | + | 36 | expires | | + | 37 | from | | + | 38 | host | | + | 39 | if-match | | + | 40 | if-modified-since | | + | 41 | if-none-match | | + | 42 | if-range | | + | 43 | if-unmodified-since | | + | 44 | last-modified | | + | 45 | link | | + | 46 | location | | + | 47 | max-forwards | | + | 48 | proxy-authenticate | | + | 49 | proxy-authorization | | + | 50 | range | | + | 51 | referer | | + | 52 | refresh | | + | 53 | retry-after | | + | 54 | server | | + | 55 | set-cookie | | + | 56 | strict-transport-security | | + | 57 | transfer-encoding | | + | 58 | user-agent | | + | 59 | vary | | + | 60 | via | | + | 61 | www-authenticate | | + +-------+-----------------------------+---------------+ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h index 49feb238f1..1ceb6efd16 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H - -/* HPACK static huffman table */ - -#define GRPC_CHTTP2_NUM_HUFFSYMS 257 - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H + +/* HPACK static huffman table */ + +#define GRPC_CHTTP2_NUM_HUFFSYMS 257 + struct grpc_chttp2_huffsym { - unsigned bits; - unsigned length; + unsigned bits; + unsigned length; }; -extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS]; - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H */ +extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS]; + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h index b63caa1ae2..da7b522e91 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -1,28 +1,28 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/transport/transport.h" - +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_incoming_metadata_buffer { explicit grpc_chttp2_incoming_metadata_buffer(grpc_core::Arena* arena) : arena(arena) { @@ -42,17 +42,17 @@ struct grpc_chttp2_incoming_metadata_buffer { grpc_linked_mdelem preallocated_mdelems[kPreallocatedMDElem]; grpc_metadata_batch batch; }; - -void grpc_chttp2_incoming_metadata_buffer_publish( + +void grpc_chttp2_incoming_metadata_buffer_publish( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch); - + grpc_error* grpc_chttp2_incoming_metadata_buffer_add( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; -void grpc_chttp2_incoming_metadata_buffer_set_deadline( +void grpc_chttp2_incoming_metadata_buffer_set_deadline( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h index 2f028c08f3..253dba1fbd 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h @@ -1,77 +1,77 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H + #include <grpc/support/port_platform.h> -#include <assert.h> -#include <stdbool.h> - +#include <assert.h> +#include <stdbool.h> + #include "src/core/ext/transport/chttp2/transport/flow_control.h" -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/ext/transport/chttp2/transport/frame_data.h" -#include "src/core/ext/transport/chttp2/transport/frame_goaway.h" -#include "src/core/ext/transport/chttp2/transport/frame_ping.h" -#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h" -#include "src/core/ext/transport/chttp2/transport/frame_settings.h" -#include "src/core/ext/transport/chttp2/transport/frame_window_update.h" -#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" -#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" -#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" -#include "src/core/ext/transport/chttp2/transport/stream_map.h" +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/frame_data.h" +#include "src/core/ext/transport/chttp2/transport/frame_goaway.h" +#include "src/core/ext/transport/chttp2/transport/frame_ping.h" +#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h" +#include "src/core/ext/transport/chttp2/transport/frame_settings.h" +#include "src/core/ext/transport/chttp2/transport/frame_window_update.h" +#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" +#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" +#include "src/core/ext/transport/chttp2/transport/stream_map.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/compression/stream_compression.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/iomgr/combiner.h" -#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/transport_impl.h" - +#include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/transport_impl.h" + namespace grpc_core { class ContextList; } -/* streams are kept in various linked lists depending on what things need to - happen to them... this enum labels each list */ -typedef enum { +/* streams are kept in various linked lists depending on what things need to + happen to them... this enum labels each list */ +typedef enum { /* If a stream is in the following two lists, an explicit ref is associated with the stream */ - GRPC_CHTTP2_LIST_WRITABLE, - GRPC_CHTTP2_LIST_WRITING, + GRPC_CHTTP2_LIST_WRITABLE, + GRPC_CHTTP2_LIST_WRITING, /* No additional ref is taken for the following refs. Make sure to remove the stream from these lists when the stream is removed. */ - GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, + GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, GRPC_CHTTP2_LIST_STALLED_BY_STREAM, - /** streams that are waiting to start because there are too many concurrent - streams on the connection */ - GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, - STREAM_LIST_COUNT /* must be last */ -} grpc_chttp2_stream_list_id; - -typedef enum { - GRPC_CHTTP2_WRITE_STATE_IDLE, - GRPC_CHTTP2_WRITE_STATE_WRITING, - GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE, -} grpc_chttp2_write_state; - + /** streams that are waiting to start because there are too many concurrent + streams on the connection */ + GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, + STREAM_LIST_COUNT /* must be last */ +} grpc_chttp2_stream_list_id; + +typedef enum { + GRPC_CHTTP2_WRITE_STATE_IDLE, + GRPC_CHTTP2_WRITE_STATE_WRITING, + GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE, +} grpc_chttp2_write_state; + typedef enum { GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY, GRPC_CHTTP2_OPTIMIZE_FOR_THROUGHPUT, @@ -131,49 +131,49 @@ struct grpc_chttp2_server_ping_recv_state { grpc_millis last_ping_recv_time; int ping_strikes; }; -/* deframer state for the overall http2 stream of bytes */ -typedef enum { - /* prefix: one entry per http2 connection prefix byte */ - GRPC_DTS_CLIENT_PREFIX_0 = 0, - GRPC_DTS_CLIENT_PREFIX_1, - GRPC_DTS_CLIENT_PREFIX_2, - GRPC_DTS_CLIENT_PREFIX_3, - GRPC_DTS_CLIENT_PREFIX_4, - GRPC_DTS_CLIENT_PREFIX_5, - GRPC_DTS_CLIENT_PREFIX_6, - GRPC_DTS_CLIENT_PREFIX_7, - GRPC_DTS_CLIENT_PREFIX_8, - GRPC_DTS_CLIENT_PREFIX_9, - GRPC_DTS_CLIENT_PREFIX_10, - GRPC_DTS_CLIENT_PREFIX_11, - GRPC_DTS_CLIENT_PREFIX_12, - GRPC_DTS_CLIENT_PREFIX_13, - GRPC_DTS_CLIENT_PREFIX_14, - GRPC_DTS_CLIENT_PREFIX_15, - GRPC_DTS_CLIENT_PREFIX_16, - GRPC_DTS_CLIENT_PREFIX_17, - GRPC_DTS_CLIENT_PREFIX_18, - GRPC_DTS_CLIENT_PREFIX_19, - GRPC_DTS_CLIENT_PREFIX_20, - GRPC_DTS_CLIENT_PREFIX_21, - GRPC_DTS_CLIENT_PREFIX_22, - GRPC_DTS_CLIENT_PREFIX_23, - /* frame header byte 0... */ - /* must follow from the prefix states */ - GRPC_DTS_FH_0, - GRPC_DTS_FH_1, - GRPC_DTS_FH_2, - GRPC_DTS_FH_3, - GRPC_DTS_FH_4, - GRPC_DTS_FH_5, - GRPC_DTS_FH_6, - GRPC_DTS_FH_7, - /* ... frame header byte 8 */ - GRPC_DTS_FH_8, - /* inside a http2 frame */ - GRPC_DTS_FRAME -} grpc_chttp2_deframe_transport_state; - +/* deframer state for the overall http2 stream of bytes */ +typedef enum { + /* prefix: one entry per http2 connection prefix byte */ + GRPC_DTS_CLIENT_PREFIX_0 = 0, + GRPC_DTS_CLIENT_PREFIX_1, + GRPC_DTS_CLIENT_PREFIX_2, + GRPC_DTS_CLIENT_PREFIX_3, + GRPC_DTS_CLIENT_PREFIX_4, + GRPC_DTS_CLIENT_PREFIX_5, + GRPC_DTS_CLIENT_PREFIX_6, + GRPC_DTS_CLIENT_PREFIX_7, + GRPC_DTS_CLIENT_PREFIX_8, + GRPC_DTS_CLIENT_PREFIX_9, + GRPC_DTS_CLIENT_PREFIX_10, + GRPC_DTS_CLIENT_PREFIX_11, + GRPC_DTS_CLIENT_PREFIX_12, + GRPC_DTS_CLIENT_PREFIX_13, + GRPC_DTS_CLIENT_PREFIX_14, + GRPC_DTS_CLIENT_PREFIX_15, + GRPC_DTS_CLIENT_PREFIX_16, + GRPC_DTS_CLIENT_PREFIX_17, + GRPC_DTS_CLIENT_PREFIX_18, + GRPC_DTS_CLIENT_PREFIX_19, + GRPC_DTS_CLIENT_PREFIX_20, + GRPC_DTS_CLIENT_PREFIX_21, + GRPC_DTS_CLIENT_PREFIX_22, + GRPC_DTS_CLIENT_PREFIX_23, + /* frame header byte 0... */ + /* must follow from the prefix states */ + GRPC_DTS_FH_0, + GRPC_DTS_FH_1, + GRPC_DTS_FH_2, + GRPC_DTS_FH_3, + GRPC_DTS_FH_4, + GRPC_DTS_FH_5, + GRPC_DTS_FH_6, + GRPC_DTS_FH_7, + /* ... frame header byte 8 */ + GRPC_DTS_FH_8, + /* inside a http2 frame */ + GRPC_DTS_FRAME +} grpc_chttp2_deframe_transport_state; + struct grpc_chttp2_stream_list { grpc_chttp2_stream* head; grpc_chttp2_stream* tail; @@ -182,41 +182,41 @@ struct grpc_chttp2_stream_link { grpc_chttp2_stream* next; grpc_chttp2_stream* prev; }; -/* We keep several sets of connection wide parameters */ -typedef enum { - /* The settings our peer has asked for (and we have acked) */ - GRPC_PEER_SETTINGS = 0, - /* The settings we'd like to have */ - GRPC_LOCAL_SETTINGS, - /* The settings we've published to our peer */ - GRPC_SENT_SETTINGS, - /* The settings the peer has acked */ - GRPC_ACKED_SETTINGS, - GRPC_NUM_SETTING_SETS -} grpc_chttp2_setting_set; - -typedef enum { - GRPC_CHTTP2_NO_GOAWAY_SEND, - GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED, - GRPC_CHTTP2_GOAWAY_SENT, -} grpc_chttp2_sent_goaway_state; - -typedef struct grpc_chttp2_write_cb { - int64_t call_at_byte; +/* We keep several sets of connection wide parameters */ +typedef enum { + /* The settings our peer has asked for (and we have acked) */ + GRPC_PEER_SETTINGS = 0, + /* The settings we'd like to have */ + GRPC_LOCAL_SETTINGS, + /* The settings we've published to our peer */ + GRPC_SENT_SETTINGS, + /* The settings the peer has acked */ + GRPC_ACKED_SETTINGS, + GRPC_NUM_SETTING_SETS +} grpc_chttp2_setting_set; + +typedef enum { + GRPC_CHTTP2_NO_GOAWAY_SEND, + GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED, + GRPC_CHTTP2_GOAWAY_SENT, +} grpc_chttp2_sent_goaway_state; + +typedef struct grpc_chttp2_write_cb { + int64_t call_at_byte; grpc_closure* closure; struct grpc_chttp2_write_cb* next; -} grpc_chttp2_write_cb; - +} grpc_chttp2_write_cb; + namespace grpc_core { - + class Chttp2IncomingByteStream : public ByteStream { public: Chttp2IncomingByteStream(grpc_chttp2_transport* transport, grpc_chttp2_stream* stream, uint32_t frame_size, uint32_t flags); - + void Orphan() override; - + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; grpc_error* Pull(grpc_slice* slice) override; void Shutdown(grpc_error* error) override; @@ -269,14 +269,14 @@ class Chttp2IncomingByteStream : public ByteStream { /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == * true */ - struct { - grpc_closure closure; - size_t max_size_hint; + struct { + grpc_closure closure; + size_t max_size_hint; grpc_closure* on_complete; } next_action_; grpc_closure destroy_action_; -}; - +}; + } // namespace grpc_core typedef enum { @@ -286,125 +286,125 @@ typedef enum { GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED, } grpc_chttp2_keepalive_state; -struct grpc_chttp2_transport { +struct grpc_chttp2_transport { grpc_chttp2_transport(const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client, grpc_resource_user* resource_user); ~grpc_chttp2_transport(); - grpc_transport base; /* must be first */ + grpc_transport base; /* must be first */ grpc_core::RefCount refs; grpc_endpoint* ep; TString peer_string; - + grpc_resource_user* resource_user; grpc_core::Combiner* combiner; - + grpc_closure* notify_on_receive_settings = nullptr; - /** write execution state of the transport */ + /** write execution state of the transport */ grpc_chttp2_write_state write_state = GRPC_CHTTP2_WRITE_STATE_IDLE; - - /** is the transport destroying itself? */ + + /** is the transport destroying itself? */ uint8_t destroying = false; - /** has the upper layer closed the transport? */ + /** has the upper layer closed the transport? */ grpc_error* closed_with_error = GRPC_ERROR_NONE; - - /** is there a read request to the endpoint outstanding? */ + + /** is there a read request to the endpoint outstanding? */ uint8_t endpoint_reading = 1; - - /** various lists of streams */ + + /** various lists of streams */ grpc_chttp2_stream_list lists[STREAM_LIST_COUNT] = {}; - - /** maps stream id to grpc_chttp2_stream objects */ - grpc_chttp2_stream_map stream_map; - - grpc_closure write_action_begin_locked; - grpc_closure write_action; - grpc_closure write_action_end_locked; - - grpc_closure read_action_locked; - - /** incoming read bytes */ - grpc_slice_buffer read_buffer; - - /** address to place a newly accepted stream - set and unset by - grpc_chttp2_parsing_accept_stream; used by init_stream to - publish the accepted server stream */ + + /** maps stream id to grpc_chttp2_stream objects */ + grpc_chttp2_stream_map stream_map; + + grpc_closure write_action_begin_locked; + grpc_closure write_action; + grpc_closure write_action_end_locked; + + grpc_closure read_action_locked; + + /** incoming read bytes */ + grpc_slice_buffer read_buffer; + + /** address to place a newly accepted stream - set and unset by + grpc_chttp2_parsing_accept_stream; used by init_stream to + publish the accepted server stream */ grpc_chttp2_stream** accepting_stream = nullptr; - + /* accept stream callback */ void (*accept_stream_cb)(void* user_data, grpc_transport* transport, const void* server_data); void* accept_stream_cb_user_data; - + /** connectivity tracking */ grpc_core::ConnectivityStateTracker state_tracker; - - /** data to write now */ - grpc_slice_buffer outbuf; - /** hpack encoding */ - grpc_chttp2_hpack_compressor hpack_compressor; - /** is this a client? */ + + /** data to write now */ + grpc_slice_buffer outbuf; + /** hpack encoding */ + grpc_chttp2_hpack_compressor hpack_compressor; + /** is this a client? */ bool is_client; - - /** data to write next write */ - grpc_slice_buffer qbuf; - - /** how much data are we willing to buffer when the WRITE_BUFFER_HINT is set? - */ + + /** data to write next write */ + grpc_slice_buffer qbuf; + + /** how much data are we willing to buffer when the WRITE_BUFFER_HINT is set? + */ uint32_t write_buffer_size = grpc_core::chttp2::kDefaultWindow; - + /** Set to a grpc_error object if a goaway frame is received. By default, set * to GRPC_ERROR_NONE */ grpc_error* goaway_error = GRPC_ERROR_NONE; grpc_chttp2_sent_goaway_state sent_goaway_state = GRPC_CHTTP2_NO_GOAWAY_SEND; - - /** are the local settings dirty and need to be sent? */ + + /** are the local settings dirty and need to be sent? */ bool dirtied_local_settings = true; - /** have local settings been sent? */ + /** have local settings been sent? */ bool sent_local_settings = false; /** bitmask of setting indexes to send out Hack: it's common for implementations to assume 65536 bytes initial send window -- this should by rights be 0 */ uint32_t force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - /** settings values */ - uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; - - /** what is the next stream id to be allocated by this peer? - copied to next_stream_id in parsing when parsing commences */ + /** settings values */ + uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; + + /** what is the next stream id to be allocated by this peer? + copied to next_stream_id in parsing when parsing commences */ uint32_t next_stream_id = 0; - - /** last new stream id */ + + /** last new stream id */ uint32_t last_new_stream_id = 0; - + /** ping queues for various ping insertion points */ grpc_chttp2_ping_queue ping_queue = grpc_chttp2_ping_queue(); grpc_chttp2_repeated_ping_policy ping_policy; grpc_chttp2_repeated_ping_state ping_state; uint64_t ping_ctr = 0; /* unique id for pings */ grpc_closure retry_initiate_ping_locked; - + /** ping acks */ size_t ping_ack_count = 0; size_t ping_ack_capacity = 0; uint64_t* ping_acks = nullptr; grpc_chttp2_server_ping_recv_state ping_recv_state; - /** parser for headers */ - grpc_chttp2_hpack_parser hpack_parser; - /** simple one shot parsers */ - union { - grpc_chttp2_window_update_parser window_update; - grpc_chttp2_settings_parser settings; - grpc_chttp2_ping_parser ping; - grpc_chttp2_rst_stream_parser rst_stream; - } simple; - /** parser for goaway frames */ - grpc_chttp2_goaway_parser goaway_parser; - + /** parser for headers */ + grpc_chttp2_hpack_parser hpack_parser; + /** simple one shot parsers */ + union { + grpc_chttp2_window_update_parser window_update; + grpc_chttp2_settings_parser settings; + grpc_chttp2_ping_parser ping; + grpc_chttp2_rst_stream_parser rst_stream; + } simple; + /** parser for goaway frames */ + grpc_chttp2_goaway_parser goaway_parser; + grpc_core::PolymorphicManualConstructor< grpc_core::chttp2::TransportFlowControlBase, grpc_core::chttp2::TransportFlowControl, @@ -414,8 +414,8 @@ struct grpc_chttp2_transport { * the remote peer. If there is a positive delta, then we will make all * streams readable since they may have become unstalled */ int64_t initial_window_update = 0; - - /* deframing */ + + /* deframing */ grpc_chttp2_deframe_transport_state deframe_state = GRPC_DTS_CLIENT_PREFIX_0; uint8_t incoming_frame_type = 0; uint8_t incoming_frame_flags = 0; @@ -424,39 +424,39 @@ struct grpc_chttp2_transport { uint32_t expect_continuation_stream_id = 0; uint32_t incoming_frame_size = 0; uint32_t incoming_stream_id = 0; - - /* active parser */ + + /* active parser */ void* parser_data = nullptr; grpc_chttp2_stream* incoming_stream = nullptr; grpc_error* (*parser)(void* parser_user_data, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + grpc_chttp2_write_cb* write_cb_pool = nullptr; - + /* bdp estimator */ bool bdp_ping_blocked = false; /* Is the BDP blocked due to not receiving any data? */ grpc_closure next_bdp_ping_timer_expired_locked; grpc_closure start_bdp_ping_locked; grpc_closure finish_bdp_ping_locked; - - /* if non-NULL, close the transport with this error when writes are finished - */ + + /* if non-NULL, close the transport with this error when writes are finished + */ grpc_error* close_transport_on_writes_finished = GRPC_ERROR_NONE; - - /* a list of closures to run after writes are finished */ + + /* a list of closures to run after writes are finished */ grpc_closure_list run_after_write = GRPC_CLOSURE_LIST_INIT; - - /* buffer pool state */ - /** have we scheduled a benign cleanup? */ + + /* buffer pool state */ + /** have we scheduled a benign cleanup? */ bool benign_reclaimer_registered = false; - /** have we scheduled a destructive cleanup? */ + /** have we scheduled a destructive cleanup? */ bool destructive_reclaimer_registered = false; - /** benign cleanup closure */ - grpc_closure benign_reclaimer_locked; - /** destructive cleanup closure */ - grpc_closure destructive_reclaimer_locked; + /** benign cleanup closure */ + grpc_closure benign_reclaimer_locked; + /** destructive cleanup closure */ + grpc_closure destructive_reclaimer_locked; /* next bdp ping timer */ bool have_next_bdp_ping_timer = false; @@ -497,16 +497,16 @@ struct grpc_chttp2_transport { * thereby reducing the number of induced frames. */ uint32_t num_pending_induced_frames = 0; bool reading_paused_on_pending_induced_frames = false; -}; - -typedef enum { - GRPC_METADATA_NOT_PUBLISHED, - GRPC_METADATA_SYNTHESIZED_FROM_FAKE, - GRPC_METADATA_PUBLISHED_FROM_WIRE, +}; + +typedef enum { + GRPC_METADATA_NOT_PUBLISHED, + GRPC_METADATA_SYNTHESIZED_FROM_FAKE, + GRPC_METADATA_PUBLISHED_FROM_WIRE, GRPC_METADATA_PUBLISHED_AT_CLOSE -} grpc_published_metadata_method; - -struct grpc_chttp2_stream { +} grpc_published_metadata_method; + +struct grpc_chttp2_stream { grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_stream_refcount* refcount, const void* server_data, grpc_core::Arena* arena); ~grpc_chttp2_stream(); @@ -520,17 +520,17 @@ struct grpc_chttp2_stream { struct Reffer { explicit Reffer(grpc_chttp2_stream* s); } reffer; - - grpc_closure destroy_stream; + + grpc_closure destroy_stream; grpc_closure* destroy_stream_arg; - - grpc_chttp2_stream_link links[STREAM_LIST_COUNT]; + + grpc_chttp2_stream_link links[STREAM_LIST_COUNT]; uint8_t included[STREAM_LIST_COUNT] = {}; - - /** HTTP2 stream id for this stream, or zero if one has not been assigned */ + + /** HTTP2 stream id for this stream, or zero if one has not been assigned */ uint32_t id = 0; - - /** things the upper layers would like to send */ + + /** things the upper layers would like to send */ grpc_metadata_batch* send_initial_metadata = nullptr; grpc_closure* send_initial_metadata_finished = nullptr; grpc_metadata_batch* send_trailing_metadata = nullptr; @@ -542,16 +542,16 @@ struct grpc_chttp2_stream { // detecting cancellation on the server-side).. bool* sent_trailing_metadata_op = nullptr; grpc_closure* send_trailing_metadata_finished = nullptr; - + grpc_core::OrphanablePtr<grpc_core::ByteStream> fetching_send_message; uint32_t fetched_send_message_length = 0; grpc_slice fetching_slice = grpc_empty_slice(); - int64_t next_message_end_offset; + int64_t next_message_end_offset; int64_t flow_controlled_bytes_written = 0; int64_t flow_controlled_bytes_flowed = 0; - grpc_closure complete_fetch_locked; + grpc_closure complete_fetch_locked; grpc_closure* fetching_send_message_finished = nullptr; - + grpc_metadata_batch* recv_initial_metadata; grpc_closure* recv_initial_metadata_ready = nullptr; bool* trailing_metadata_available = nullptr; @@ -559,39 +559,39 @@ struct grpc_chttp2_stream { grpc_closure* recv_message_ready = nullptr; grpc_metadata_batch* recv_trailing_metadata; grpc_closure* recv_trailing_metadata_finished = nullptr; - + grpc_transport_stream_stats* collecting_stats = nullptr; grpc_transport_stream_stats stats = grpc_transport_stream_stats(); - - /** Is this stream closed for writing. */ + + /** Is this stream closed for writing. */ bool write_closed = false; - /** Is this stream reading half-closed. */ + /** Is this stream reading half-closed. */ bool read_closed = false; - /** Are all published incoming byte streams closed. */ + /** Are all published incoming byte streams closed. */ bool all_incoming_byte_streams_finished = false; - /** Has this stream seen an error. - If true, then pending incoming frames can be thrown away. */ + /** Has this stream seen an error. + If true, then pending incoming frames can be thrown away. */ bool seen_error = false; - /** Are we buffering writes on this stream? If yes, we won't become writable - until there's enough queued up in the flow_controlled_buffer */ + /** Are we buffering writes on this stream? If yes, we won't become writable + until there's enough queued up in the flow_controlled_buffer */ bool write_buffering = false; - + /* have we sent or received the EOS bit? */ bool eos_received = false; bool eos_sent = false; - /** the error that resulted in this stream being read-closed */ + /** the error that resulted in this stream being read-closed */ grpc_error* read_closed_error = GRPC_ERROR_NONE; - /** the error that resulted in this stream being write-closed */ + /** the error that resulted in this stream being write-closed */ grpc_error* write_closed_error = GRPC_ERROR_NONE; - + grpc_published_metadata_method published_metadata[2] = {}; bool final_metadata_requested = false; - - grpc_chttp2_incoming_metadata_buffer metadata_buffer[2]; - + + grpc_chttp2_incoming_metadata_buffer metadata_buffer[2]; + grpc_slice_buffer frame_storage; /* protected by t combiner */ - + grpc_closure* on_next = nullptr; /* protected by t combiner */ bool pending_byte_stream = false; /* protected by t combiner */ // cached length of buffer to be used by the transport thread in cases where @@ -606,21 +606,21 @@ struct grpc_chttp2_stream { grpc_closure reset_byte_stream; grpc_error* byte_stream_error = GRPC_ERROR_NONE; /* protected by t combiner */ bool received_last_frame = false; /* protected by t combiner */ - + grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; - /** saw some stream level error */ + /** saw some stream level error */ grpc_error* forced_close_error = GRPC_ERROR_NONE; - /** how many header frames have we received? */ + /** how many header frames have we received? */ uint8_t header_frames_received = 0; - /** parsing state for data frames */ + /** parsing state for data frames */ /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == * true */ - grpc_chttp2_data_parser data_parser; - /** number of bytes received - reset at end of parse thread execution */ + grpc_chttp2_data_parser data_parser; + /** number of bytes received - reset at end of parse thread execution */ int64_t received_bytes = 0; - + bool sent_initial_metadata = false; bool sent_trailing_metadata = false; @@ -630,8 +630,8 @@ struct grpc_chttp2_stream { grpc_core::chttp2::StreamFlowControlDisabled> flow_control; - grpc_slice_buffer flow_controlled_buffer; - + grpc_slice_buffer flow_controlled_buffer; + grpc_chttp2_write_cb* on_flow_controlled_cbs = nullptr; grpc_chttp2_write_cb* on_write_finished_cbs = nullptr; grpc_chttp2_write_cb* finish_after_write = nullptr; @@ -669,23 +669,23 @@ struct grpc_chttp2_stream { * compression. */ grpc_slice_buffer decompressed_data_buffer; -}; - -/** Transport writing call flow: - grpc_chttp2_initiate_write() is called anywhere that we know bytes need to - go out on the wire. - If no other write has been started, a task is enqueued onto our workqueue. - When that task executes, it obtains the global lock, and gathers the data - to write. - The global lock is dropped and we do the syscall to write. - After writing, a follow-up check is made to see if another round of writing - should be performed. - - The actual call chain is documented in the implementation of this function. - */ +}; + +/** Transport writing call flow: + grpc_chttp2_initiate_write() is called anywhere that we know bytes need to + go out on the wire. + If no other write has been started, a task is enqueued onto our workqueue. + When that task executes, it obtains the global lock, and gathers the data + to write. + The global lock is dropped and we do the syscall to write. + After writing, a follow-up check is made to see if another round of writing + should be performed. + + The actual call chain is documented in the implementation of this function. + */ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t, grpc_chttp2_initiate_write_reason reason); - + struct grpc_chttp2_begin_write_result { /** are we writing? */ bool writing; @@ -698,45 +698,45 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( grpc_chttp2_transport* t); void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error); -/** Process one slice of incoming data; return 1 if the connection is still - viable after reading, or 0 if the connection should be torn down */ +/** Process one slice of incoming data; return 1 if the connection is still + viable after reading, or 0 if the connection should be torn down */ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, const grpc_slice& slice); - + bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); -/** Get a writable stream - returns non-zero if there was a stream available */ +/** Get a writable stream + returns non-zero if there was a stream available */ bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t); bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); - + void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); - + void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream** s); void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream** s); void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t, @@ -759,62 +759,62 @@ inline grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream( grpc_chttp2_stream_map_find(&t->stream_map, id)); } grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, - uint32_t id); - + uint32_t id); + void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, - uint32_t goaway_error, + uint32_t goaway_error, uint32_t last_stream_id, const grpc_slice& goaway_text); - + void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t); - + void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_closure** pclosure, grpc_error* error, const char* desc); - + #define GRPC_HEADER_SIZE_IN_BYTES 5 #define MAX_SIZE_T (~(size_t)0) -#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" -#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ - (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) - +#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" +#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ + (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) + // extern grpc_core::TraceFlag grpc_http_trace; // extern grpc_core::TraceFlag grpc_flowctl_trace; - + #define GRPC_CHTTP2_IF_TRACING(stmt) \ do { \ if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { \ (stmt); \ } \ } while (0) - + void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* stream, grpc_error* error); void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t, grpc_chttp2_stream* s, int close_reads, int close_writes, grpc_error* error); void grpc_chttp2_start_writing(grpc_chttp2_transport* t); - + #ifndef NDEBUG -#define GRPC_CHTTP2_STREAM_REF(stream, reason) \ - grpc_chttp2_stream_ref(stream, reason) +#define GRPC_CHTTP2_STREAM_REF(stream, reason) \ + grpc_chttp2_stream_ref(stream, reason) #define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \ grpc_chttp2_stream_unref(stream, reason) void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason); void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason); -#else -#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream) +#else +#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream) #define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \ grpc_chttp2_stream_unref(stream) void grpc_chttp2_stream_ref(grpc_chttp2_stream* s); void grpc_chttp2_stream_unref(grpc_chttp2_stream* s); -#endif - +#endif + #ifndef NDEBUG -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ - grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) +#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ + grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) #define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \ grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__) inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, @@ -829,8 +829,8 @@ inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, int line) { t->refs.Ref(grpc_core::DebugLocation(file, line), reason); } -#else -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t) +#else +#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t) #define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t) inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { if (t->refs.Unref()) { @@ -840,40 +840,40 @@ inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { t->refs.Ref(); } -#endif - +#endif + void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id); - + /** Add a new ping strike to ping_recv_state.ping_strikes. If ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY with error code ENHANCE_YOUR_CALM and additional debug data resembling "too_many_pings" followed by immediately closing the connection. */ void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t); - + /** Resets ping clock. Should be called when flushing window updates, * initial/trailing metadata or data frames. For a server, it resets the number * of ping strikes and the last_ping_recv_time. For a ping sender, it resets * pings_before_data_required. */ void grpc_chttp2_reset_ping_clock(grpc_chttp2_transport* t); -/** add a ref to the stream and add it to the writable list; - ref will be dropped in writing.c */ +/** add a ref to the stream and add it to the writable list; + ref will be dropped in writing.c */ void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_error* due_to_error); - + void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t, grpc_chttp2_stream* s); void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t, grpc_chttp2_stream* s); void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_error* error); - + /** Set the default keepalive configurations, must only be called at initialization */ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args, @@ -883,4 +883,4 @@ void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error* error); void schedule_bdp_ping_locked(grpc_chttp2_transport* t); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h index 485abd2d13..d79e502f70 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h @@ -1,67 +1,67 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H - -#include <grpc/support/port_platform.h> - -#include <stddef.h> - -/* Data structure to map a uint32_t to a data object (represented by a void*) - - Represented as a sorted array of keys, and a corresponding array of values. - Lookups are performed with binary search. - Adds are restricted to strictly higher keys than previously seen (this is - guaranteed by http2). */ + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H + +#include <grpc/support/port_platform.h> + +#include <stddef.h> + +/* Data structure to map a uint32_t to a data object (represented by a void*) + + Represented as a sorted array of keys, and a corresponding array of values. + Lookups are performed with binary search. + Adds are restricted to strictly higher keys than previously seen (this is + guaranteed by http2). */ struct grpc_chttp2_stream_map { uint32_t* keys; void** values; - size_t count; - size_t free; - size_t capacity; + size_t count; + size_t free; + size_t capacity; }; void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map, - size_t initial_capacity); + size_t initial_capacity); void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map* map); - -/* Add a new key: given http2 semantics, new keys must always be greater than - existing keys - this is asserted */ + +/* Add a new key: given http2 semantics, new keys must always be greater than + existing keys - this is asserted */ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key, void* value); - -/* Delete an existing key - returns the previous value of the key if it existed, - or NULL otherwise */ + +/* Delete an existing key - returns the previous value of the key if it existed, + or NULL otherwise */ void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key); - -/* Return an existing key, or NULL if it does not exist */ + +/* Return an existing key, or NULL if it does not exist */ void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key); - -/* Return a random entry */ + +/* Return a random entry */ void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map); - -/* How many (populated) entries are in the stream map? */ + +/* How many (populated) entries are in the stream map? */ size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map); - -/* Callback on each stream */ + +/* Callback on each stream */ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map, void (*f)(void* user_data, uint32_t key, void* value), void* user_data); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h index 5a2b670f06..cdaeaef0a7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h @@ -1,60 +1,60 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H - -#include <grpc/support/port_platform.h> - -/* Helpers for hpack varint encoding */ - -/* length of a value that needs varint tail encoding (it's bigger than can be - bitpacked into the opcode byte) - returned value includes the length of the - opcode byte */ -uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value); - -void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target, - uint32_t tail_length); - -/* maximum value that can be bitpacked with the opcode if the opcode has a - prefix - of length prefix_bits */ -#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ - ((uint32_t)((1 << (8 - (prefix_bits))) - 1)) - -/* length required to bitpack a value */ -#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \ - ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ - ? 1u \ - : grpc_chttp2_hpack_varint_length( \ - (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) - -#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ - do { \ - uint8_t* tgt = target; \ - if ((length) == 1u) { \ - (tgt)[0] = (uint8_t)((prefix_or) | (n)); \ - } else { \ - (tgt)[0] = \ - (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ - grpc_chttp2_hpack_write_varint_tail( \ - (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ - } \ - } while (0) - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */ + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H + +#include <grpc/support/port_platform.h> + +/* Helpers for hpack varint encoding */ + +/* length of a value that needs varint tail encoding (it's bigger than can be + bitpacked into the opcode byte) - returned value includes the length of the + opcode byte */ +uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value); + +void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target, + uint32_t tail_length); + +/* maximum value that can be bitpacked with the opcode if the opcode has a + prefix + of length prefix_bits */ +#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ + ((uint32_t)((1 << (8 - (prefix_bits))) - 1)) + +/* length required to bitpack a value */ +#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \ + ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ + ? 1u \ + : grpc_chttp2_hpack_varint_length( \ + (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) + +#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ + do { \ + uint8_t* tgt = target; \ + if ((length) == 1u) { \ + (tgt)[0] = (uint8_t)((prefix_or) | (n)); \ + } else { \ + (tgt)[0] = \ + (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ + grpc_chttp2_hpack_write_varint_tail( \ + (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ + } \ + } while (0) + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */ |