Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 19 | #ifndef GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H |
| 20 | #define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 21 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 22 | #include "src/core/lib/transport/transport.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 23 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 28 | typedef struct grpc_transport_vtable { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 29 | /* Memory required for a single stream element - this is allocated by upper |
| 30 | layers and initialized by the transport */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 31 | size_t sizeof_stream; /* = sizeof(transport stream) */ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 32 | |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 33 | /* name of this transport implementation */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 34 | const char* name; |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 35 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 36 | /* implementation of grpc_transport_init_stream */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 37 | int (*init_stream)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 38 | grpc_stream* stream, grpc_stream_refcount* refcount, |
| 39 | const void* server_data, gpr_arena* arena); |
Craig Tiller | 9d35a1f | 2015-11-02 14:16:12 -0800 | [diff] [blame] | 40 | |
| 41 | /* implementation of grpc_transport_set_pollset */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 42 | void (*set_pollset)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 43 | grpc_stream* stream, grpc_pollset* pollset); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 44 | |
David Garcia Quintas | 4afce7e | 2016-04-18 16:25:17 -0700 | [diff] [blame] | 45 | /* implementation of grpc_transport_set_pollset */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 46 | void (*set_pollset_set)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 47 | grpc_stream* stream, grpc_pollset_set* pollset_set); |
David Garcia Quintas | 4afce7e | 2016-04-18 16:25:17 -0700 | [diff] [blame] | 48 | |
Craig Tiller | 3f47542 | 2015-06-25 10:43:05 -0700 | [diff] [blame] | 49 | /* implementation of grpc_transport_perform_stream_op */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 50 | void (*perform_stream_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 51 | grpc_stream* stream, |
| 52 | grpc_transport_stream_op_batch* op); |
Craig Tiller | 3f47542 | 2015-06-25 10:43:05 -0700 | [diff] [blame] | 53 | |
| 54 | /* implementation of grpc_transport_perform_op */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 55 | void (*perform_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 56 | grpc_transport_op* op); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 57 | |
| 58 | /* implementation of grpc_transport_destroy_stream */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 59 | void (*destroy_stream)(grpc_exec_ctx* exec_ctx, grpc_transport* self, |
| 60 | grpc_stream* stream, |
| 61 | grpc_closure* then_schedule_closure); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 62 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 63 | /* implementation of grpc_transport_destroy */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 64 | void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_transport* self); |
Craig Tiller | 1b22b9d | 2015-07-20 13:42:22 -0700 | [diff] [blame] | 65 | |
Yuchen Zeng | 5ab4ca5 | 2016-10-24 10:49:55 -0700 | [diff] [blame] | 66 | /* implementation of grpc_transport_get_endpoint */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 67 | grpc_endpoint* (*get_endpoint)(grpc_exec_ctx* exec_ctx, grpc_transport* self); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 68 | } grpc_transport_vtable; |
| 69 | |
| 70 | /* an instance of a grpc transport */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 71 | struct grpc_transport { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 72 | /* pointer to a vtable defining operations on this transport */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 73 | const grpc_transport_vtable* vtable; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 76 | #ifdef __cplusplus |
| 77 | } |
| 78 | #endif |
| 79 | |
Yash Tibrewal | 12fc6d4 | 2017-10-09 16:43:34 -0700 | [diff] [blame] | 80 | #endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ |