GRPC Core  18.0.0
tcp_custom.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
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
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H
20 #define GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H
21 
23 
26 
27 // Same number as the micro of SO_REUSEPORT in kernel
28 #define GRPC_CUSTOM_SOCKET_OPT_SO_REUSEPORT (0x00000200u)
29 
32 
33 typedef struct grpc_custom_socket {
34  // Implementation defined
35  void* impl;
39  int refs;
41 
47  size_t nread,
53 
54 typedef struct grpc_socket_vtable {
55  grpc_error_handle (*init)(grpc_custom_socket* socket, int domain);
56  void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr,
57  size_t len, grpc_custom_connect_callback cb);
58  void (*destroy)(grpc_custom_socket* socket);
59  void (*shutdown)(grpc_custom_socket* socket);
61  void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices,
63  void (*read)(grpc_custom_socket* socket, char* buffer, size_t length,
66  const grpc_sockaddr* addr, int* len);
68  const grpc_sockaddr* addr, int* len);
70  const grpc_sockaddr* addr, size_t len, int flags);
75 
76 /* Internal APIs */
78 
80 
82  grpc_resource_quota* resource_quota,
83  const char* peer_string);
84 
85 #endif /* GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H */
grpc_error * grpc_error_handle
Definition: error.h:48
grpc_error_handle error
Definition: lame_client.cc:54
Definition: tcp_custom.h:33
grpc_custom_tcp_connect * connector
Definition: tcp_custom.h:38
void * impl
Definition: tcp_custom.h:35
grpc_tcp_listener * listener
Definition: tcp_custom.h:37
int refs
Definition: tcp_custom.h:39
grpc_endpoint * endpoint
Definition: tcp_custom.h:36
Definition: tcp_client_custom.cc:38
Definition: endpoint.h:106
Definition: error_internal.h:41
Definition: resource_quota.cc:127
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
Definition: tcp_custom.h:54
grpc_error_handle(* init)(grpc_custom_socket *socket, int domain)
Definition: tcp_custom.h:55
void(* destroy)(grpc_custom_socket *socket)
Definition: tcp_custom.h:58
void(* close)(grpc_custom_socket *socket, grpc_custom_close_callback cb)
Definition: tcp_custom.h:60
grpc_error_handle(* bind)(grpc_custom_socket *socket, const grpc_sockaddr *addr, size_t len, int flags)
Definition: tcp_custom.h:69
void(* write)(grpc_custom_socket *socket, grpc_slice_buffer *slices, grpc_custom_write_callback cb)
Definition: tcp_custom.h:61
void(* accept)(grpc_custom_socket *socket, grpc_custom_socket *client, grpc_custom_accept_callback cb)
Definition: tcp_custom.h:72
grpc_error_handle(* getsockname)(grpc_custom_socket *socket, const grpc_sockaddr *addr, int *len)
Definition: tcp_custom.h:67
void(* read)(grpc_custom_socket *socket, char *buffer, size_t length, grpc_custom_read_callback cb)
Definition: tcp_custom.h:63
void(* shutdown)(grpc_custom_socket *socket)
Definition: tcp_custom.h:59
grpc_error_handle(* getpeername)(grpc_custom_socket *socket, const grpc_sockaddr *addr, int *len)
Definition: tcp_custom.h:65
grpc_error_handle(* listen)(grpc_custom_socket *socket)
Definition: tcp_custom.h:71
void(* connect)(grpc_custom_socket *socket, const grpc_sockaddr *addr, size_t len, grpc_custom_connect_callback cb)
Definition: tcp_custom.h:56
Definition: tcp_server_custom.cc:45
void(* grpc_custom_connect_callback)(grpc_custom_socket *socket, grpc_error_handle error)
Definition: tcp_custom.h:42
grpc_endpoint * custom_tcp_endpoint_create(grpc_custom_socket *socket, grpc_resource_quota *resource_quota, const char *peer_string)
Definition: tcp_custom.cc:357
void(* grpc_custom_accept_callback)(grpc_custom_socket *socket, grpc_custom_socket *client, grpc_error_handle error)
Definition: tcp_custom.h:49
void(* grpc_custom_close_callback)(grpc_custom_socket *socket)
Definition: tcp_custom.h:52
void grpc_custom_endpoint_init(grpc_socket_vtable *impl)
Definition: tcp_custom.cc:50
void(* grpc_custom_read_callback)(grpc_custom_socket *socket, size_t nread, grpc_error_handle error)
Definition: tcp_custom.h:46
void grpc_custom_close_server_callback(grpc_tcp_listener *listener)
Definition: tcp_server_custom.cc:167
void(* grpc_custom_write_callback)(grpc_custom_socket *socket, grpc_error_handle error)
Definition: tcp_custom.h:44
struct grpc_socket_vtable grpc_socket_vtable
struct grpc_custom_socket grpc_custom_socket
XdsClient * client
Definition: xds_api.cc:906