blob: 22ad599e2e22ecb3f784794a02e91f8500261caa [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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 Nobleb7ebd3b2014-11-26 16:33:03 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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 Nobleb7ebd3b2014-11-26 16:33:03 -080016 *
17 */
18
Craig Tiller9a4dddd2016-03-25 17:08:13 -070019#ifndef GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H
20#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080021
Craig Tiller9533d042016-03-25 17:11:06 -070022#include "src/core/lib/transport/transport.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080023
Yash Tibrewala7e6d652017-09-20 18:56:37 -070024#ifdef __cplusplus
25extern "C" {
26#endif
27
Craig Tillera82950e2015-09-22 12:33:20 -070028typedef struct grpc_transport_vtable {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080029 /* Memory required for a single stream element - this is allocated by upper
30 layers and initialized by the transport */
Craig Tillera82950e2015-09-22 12:33:20 -070031 size_t sizeof_stream; /* = sizeof(transport stream) */
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080032
Craig Tiller178edfa2016-02-17 20:54:46 -080033 /* name of this transport implementation */
Craig Tillerbaa14a92017-11-03 09:09:36 -070034 const char* name;
Craig Tiller178edfa2016-02-17 20:54:46 -080035
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080036 /* implementation of grpc_transport_init_stream */
Craig Tillerbaa14a92017-11-03 09:09:36 -070037 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 Tiller9d35a1f2015-11-02 14:16:12 -080040
41 /* implementation of grpc_transport_set_pollset */
Craig Tillerbaa14a92017-11-03 09:09:36 -070042 void (*set_pollset)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
43 grpc_stream* stream, grpc_pollset* pollset);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080044
David Garcia Quintas4afce7e2016-04-18 16:25:17 -070045 /* implementation of grpc_transport_set_pollset */
Craig Tillerbaa14a92017-11-03 09:09:36 -070046 void (*set_pollset_set)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
47 grpc_stream* stream, grpc_pollset_set* pollset_set);
David Garcia Quintas4afce7e2016-04-18 16:25:17 -070048
Craig Tiller3f475422015-06-25 10:43:05 -070049 /* implementation of grpc_transport_perform_stream_op */
Craig Tillerbaa14a92017-11-03 09:09:36 -070050 void (*perform_stream_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
51 grpc_stream* stream,
52 grpc_transport_stream_op_batch* op);
Craig Tiller3f475422015-06-25 10:43:05 -070053
54 /* implementation of grpc_transport_perform_op */
Craig Tillerbaa14a92017-11-03 09:09:36 -070055 void (*perform_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
56 grpc_transport_op* op);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080057
58 /* implementation of grpc_transport_destroy_stream */
Craig Tillerbaa14a92017-11-03 09:09:36 -070059 void (*destroy_stream)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
60 grpc_stream* stream,
61 grpc_closure* then_schedule_closure);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080062
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080063 /* implementation of grpc_transport_destroy */
Craig Tillerbaa14a92017-11-03 09:09:36 -070064 void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_transport* self);
Craig Tiller1b22b9d2015-07-20 13:42:22 -070065
Yuchen Zeng5ab4ca52016-10-24 10:49:55 -070066 /* implementation of grpc_transport_get_endpoint */
Craig Tillerbaa14a92017-11-03 09:09:36 -070067 grpc_endpoint* (*get_endpoint)(grpc_exec_ctx* exec_ctx, grpc_transport* self);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080068} grpc_transport_vtable;
69
70/* an instance of a grpc transport */
Craig Tillera82950e2015-09-22 12:33:20 -070071struct grpc_transport {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080072 /* pointer to a vtable defining operations on this transport */
Craig Tillerbaa14a92017-11-03 09:09:36 -070073 const grpc_transport_vtable* vtable;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080074};
75
Yash Tibrewala7e6d652017-09-20 18:56:37 -070076#ifdef __cplusplus
77}
78#endif
79
Yash Tibrewal12fc6d42017-10-09 16:43:34 -070080#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */