Pepper_47_C_interfaces
ppb_tcp_socket_private.h
Go to the documentation of this file.
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 /* From private/ppb_tcp_socket_private.idl modified Thu Oct 20 13:57:04 2016. */
7 
8 #ifndef PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_
9 #define PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_
10 
11 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_var.h"
19 
20 #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_TCPSocket_Private;0.3"
21 #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4 "PPB_TCPSocket_Private;0.4"
22 #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5 "PPB_TCPSocket_Private;0.5"
23 #define PPB_TCPSOCKET_PRIVATE_INTERFACE PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5
24 
25 /**
26  * @file
27  * This file defines the <code>PPB_TCPSocket_Private</code> interface.
28  */
29 
30 
31 /**
32  * @addtogroup Enums
33  * @{
34  */
35 typedef enum {
36  /* Special value used for testing. Guaranteed to fail SetOption(). */
38  /* Disable coalescing of small writes to make TCP segments, and instead
39  * deliver data immediately. For SSL sockets, this option must be set before
40  * SSLHandshake() is called. Value type is PP_VARTYPE_BOOL. */
44 /**
45  * @}
46  */
47 
48 /**
49  * @addtogroup Interfaces
50  * @{
51  */
52 /**
53  * The <code>PPB_TCPSocket_Private</code> interface provides TCP socket
54  * operations.
55  */
57  /**
58  * Allocates a TCP socket resource.
59  */
61  /**
62  * Determines if a given resource is TCP socket.
63  */
65  /**
66  * Connects to a TCP port given as a host-port pair.
67  * When a proxy server is used, |host| and |port| refer to the proxy server
68  * instead of the destination server.
69  */
70  int32_t (*Connect)(PP_Resource tcp_socket,
71  const char* host,
72  uint16_t port,
73  struct PP_CompletionCallback callback);
74  /**
75  * Same as Connect(), but connecting to the address given by |addr|. A typical
76  * use-case would be for reconnections.
77  */
78  int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket,
79  const struct PP_NetAddress_Private* addr,
80  struct PP_CompletionCallback callback);
81  /**
82  * Gets the local address of the socket, if it has been connected.
83  * Returns PP_TRUE on success.
84  */
86  struct PP_NetAddress_Private* local_addr);
87  /**
88  * Gets the remote address of the socket, if it has been connected.
89  * Returns PP_TRUE on success.
90  */
92  struct PP_NetAddress_Private* remote_addr);
93  /**
94  * Does SSL handshake and moves to sending and receiving encrypted data. The
95  * socket must have been successfully connected. |server_name| will be
96  * compared with the name(s) in the server's certificate during the SSL
97  * handshake. |server_port| is only used to identify an SSL server in the SSL
98  * session cache.
99  * When a proxy server is used, |server_name| and |server_port| refer to the
100  * destination server.
101  * If the socket is not connected, or there are pending read/write requests,
102  * SSLHandshake() will fail without starting a handshake. Otherwise, any
103  * failure during the handshake process will cause the socket to be
104  * disconnected.
105  */
106  int32_t (*SSLHandshake)(PP_Resource tcp_socket,
107  const char* server_name,
108  uint16_t server_port,
109  struct PP_CompletionCallback callback);
110  /**
111  * Returns the server's <code>PPB_X509Certificate_Private</code> for a socket
112  * connection if an SSL connection has been established using
113  * <code>SSLHandshake</code>. If no SSL connection has been established, a
114  * null resource is returned.
115  */
117  /**
118  * NOTE: This function is not implemented and will return
119  * <code>PP_FALSE</code>.
120  * Adds a trusted/untrusted chain building certificate to be used for this
121  * connection. The <code>certificate</code> must be a
122  * <code>PPB_X509Certificate_Private<code>. <code>PP_TRUE</code> is returned
123  * upon success.
124  */
126  PP_Resource certificate,
127  PP_Bool is_trusted);
128  /**
129  * Reads data from the socket. The size of |buffer| must be at least as large
130  * as |bytes_to_read|. May perform a partial read. Returns the number of bytes
131  * read or an error code. If the return value is 0, then it indicates that
132  * end-of-file was reached.
133  * This method won't return more than 1 megabyte, so if |bytes_to_read|
134  * exceeds 1 megabyte, it will always perform a partial read.
135  * Multiple outstanding read requests are not supported.
136  */
137  int32_t (*Read)(PP_Resource tcp_socket,
138  char* buffer,
139  int32_t bytes_to_read,
140  struct PP_CompletionCallback callback);
141  /**
142  * Writes data to the socket. May perform a partial write. Returns the number
143  * of bytes written or an error code.
144  * This method won't write more than 1 megabyte, so if |bytes_to_write|
145  * exceeds 1 megabyte, it will always perform a partial write.
146  * Multiple outstanding write requests are not supported.
147  */
148  int32_t (*Write)(PP_Resource tcp_socket,
149  const char* buffer,
150  int32_t bytes_to_write,
151  struct PP_CompletionCallback callback);
152  /**
153  * Cancels any IO that may be pending, and disconnects the socket. Any pending
154  * callbacks will still run, reporting PP_Error_Aborted if pending IO was
155  * interrupted. It is NOT valid to call Connect() again after a call to this
156  * method. Note: If the socket is destroyed when it is still connected, then
157  * it will be implicitly disconnected, so you are not required to call this
158  * method.
159  */
160  void (*Disconnect)(PP_Resource tcp_socket);
161  /**
162  * Sets an option on |tcp_socket|. Supported |name| and |value| parameters
163  * are as described for PP_TCPSocketOption_Private. |callback| will be
164  * invoked with PP_OK if setting the option succeeds, or an error code
165  * otherwise. The socket must be connection before SetOption is called.
166  */
167  int32_t (*SetOption)(PP_Resource tcp_socket,
169  struct PP_Var value,
170  struct PP_CompletionCallback callback);
171 };
172 
174 
178  int32_t (*Connect)(PP_Resource tcp_socket,
179  const char* host,
180  uint16_t port,
181  struct PP_CompletionCallback callback);
182  int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket,
183  const struct PP_NetAddress_Private* addr,
184  struct PP_CompletionCallback callback);
186  struct PP_NetAddress_Private* local_addr);
188  struct PP_NetAddress_Private* remote_addr);
189  int32_t (*SSLHandshake)(PP_Resource tcp_socket,
190  const char* server_name,
191  uint16_t server_port,
192  struct PP_CompletionCallback callback);
193  int32_t (*Read)(PP_Resource tcp_socket,
194  char* buffer,
195  int32_t bytes_to_read,
196  struct PP_CompletionCallback callback);
197  int32_t (*Write)(PP_Resource tcp_socket,
198  const char* buffer,
199  int32_t bytes_to_write,
200  struct PP_CompletionCallback callback);
201  void (*Disconnect)(PP_Resource tcp_socket);
202 };
203 
207  int32_t (*Connect)(PP_Resource tcp_socket,
208  const char* host,
209  uint16_t port,
210  struct PP_CompletionCallback callback);
211  int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket,
212  const struct PP_NetAddress_Private* addr,
213  struct PP_CompletionCallback callback);
215  struct PP_NetAddress_Private* local_addr);
217  struct PP_NetAddress_Private* remote_addr);
218  int32_t (*SSLHandshake)(PP_Resource tcp_socket,
219  const char* server_name,
220  uint16_t server_port,
221  struct PP_CompletionCallback callback);
224  PP_Resource certificate,
225  PP_Bool is_trusted);
226  int32_t (*Read)(PP_Resource tcp_socket,
227  char* buffer,
228  int32_t bytes_to_read,
229  struct PP_CompletionCallback callback);
230  int32_t (*Write)(PP_Resource tcp_socket,
231  const char* buffer,
232  int32_t bytes_to_write,
233  struct PP_CompletionCallback callback);
234  void (*Disconnect)(PP_Resource tcp_socket);
235 };
236 /**
237  * @}
238  */
239 
240 #endif /* PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ */
241 
int32_t(* Write)(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback)
int32_t(* Connect)(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback)
PP_Resource(* Create)(PP_Instance instance)
PP_Resource(* Create)(PP_Instance instance)
int32_t(* Read)(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback)
PP_Bool(* IsTCPSocket)(PP_Resource resource)
int32_t(* Connect)(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback)
PP_Bool(* AddChainBuildingCertificate)(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted)
PP_Resource(* GetServerCertificate)(PP_Resource tcp_socket)
PP_Resource(* GetServerCertificate)(PP_Resource tcp_socket)
PP_Bool(* GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr)
PP_Bool(* GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr)
PP_Bool(* GetLocalAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *local_addr)
int32_t(* SSLHandshake)(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback)
int32_t PP_Resource
Definition: pp_resource.h:40
PP_Bool(* AddChainBuildingCertificate)(PP_Resource tcp_socket, PP_Resource certificate, PP_Bool is_trusted)
PP_Bool(* IsTCPSocket)(PP_Resource resource)
int32_t(* Write)(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback)
PP_Bool(* GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr)
int32_t(* SSLHandshake)(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback)
void(* Disconnect)(PP_Resource tcp_socket)
int32_t(* ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
int32_t(* SSLHandshake)(PP_Resource tcp_socket, const char *server_name, uint16_t server_port, struct PP_CompletionCallback callback)
union PP_VarValue value
Definition: pp_var.h:180
PP_Bool(* IsTCPSocket)(PP_Resource resource)
int32_t(* Connect)(PP_Resource tcp_socket, const char *host, uint16_t port, struct PP_CompletionCallback callback)
PP_Bool(* GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr)
int32_t(* Write)(PP_Resource tcp_socket, const char *buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback)
Definition: pp_var.h:166
int32_t PP_Instance
Definition: pp_instance.h:34
void(* Disconnect)(PP_Resource tcp_socket)
int32_t(* Read)(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback)
int32_t(* ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
int32_t(* ConnectWithNetAddress)(PP_Resource tcp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
PP_Bool
Definition: pp_bool.h:30
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TCPSocketOption_Private, 4)
PP_TCPSocketOption_Private
void(* Disconnect)(PP_Resource tcp_socket)
PP_Resource(* Create)(PP_Instance instance)
int32_t(* SetOption)(PP_Resource tcp_socket, PP_TCPSocketOption_Private name, struct PP_Var value, struct PP_CompletionCallback callback)
int32_t(* Read)(PP_Resource tcp_socket, char *buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback)
PP_Bool(* GetRemoteAddress)(PP_Resource tcp_socket, struct PP_NetAddress_Private *remote_addr)