Pepper_47_C_interfaces
ppb_udp_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_udp_socket_private.idl modified Thu Oct 20 13:57:04 2016. */
7 
8 #ifndef PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_
9 #define PPAPI_C_PRIVATE_PPB_UDP_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_UDPSOCKET_PRIVATE_INTERFACE_0_2 "PPB_UDPSocket_Private;0.2"
21 #define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_UDPSocket_Private;0.3"
22 #define PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4 "PPB_UDPSocket_Private;0.4"
23 #define PPB_UDPSOCKET_PRIVATE_INTERFACE PPB_UDPSOCKET_PRIVATE_INTERFACE_0_4
24 
25 /**
26  * @file
27  * This file defines the <code>PPB_UDPSocket_Private</code> interface.
28  */
29 
30 
31 /**
32  * @addtogroup Enums
33  * @{
34  */
35 typedef enum {
36  /* Allow the socket to share the local address to which socket will
37  * be bound with other processes. Value's type should be
38  * PP_VARTYPE_BOOL. */
40  /* Allow sending and receiving packets sent to and from broadcast
41  * addresses. Value's type should be PP_VARTYPE_BOOL. */
43  /* Special value for counting the number of available
44  * features. Should not be passed to SetSocketFeature(). */
48 /**
49  * @}
50  */
51 
52 /**
53  * @addtogroup Interfaces
54  * @{
55  */
57  /**
58  * Creates a UDP socket resource.
59  */
60  PP_Resource (*Create)(PP_Instance instance_id);
61  /**
62  * Determines if a given resource is a UDP socket.
63  */
64  PP_Bool (*IsUDPSocket)(PP_Resource resource_id);
65  /**
66  * Sets a socket feature to |udp_socket|. Should be called before
67  * Bind(). Possible values for |name|, |value| and |value|'s type
68  * are described in PP_UDPSocketFeature_Private description. If no
69  * error occurs, returns PP_OK. Otherwise, returns
70  * PP_ERROR_BADRESOURCE (if bad |udp_socket| provided),
71  * PP_ERROR_BADARGUMENT (if bad name/value/value's type provided)
72  * or PP_ERROR_FAILED in the case of internal errors.
73  */
74  int32_t (*SetSocketFeature)(PP_Resource udp_socket,
76  struct PP_Var value);
77  /* Creates a socket and binds to the address given by |addr|. */
78  int32_t (*Bind)(PP_Resource udp_socket,
79  const struct PP_NetAddress_Private* addr,
80  struct PP_CompletionCallback callback);
81  /* Returns the address that the socket has bound to. A successful
82  * call to Bind must be called first. Returns PP_FALSE if Bind
83  * fails, or if Close has been called.
84  */
86  struct PP_NetAddress_Private* addr);
87  /* Performs a non-blocking recvfrom call on socket.
88  * Bind must be called first. |callback| is invoked when recvfrom
89  * reads data. You must call GetRecvFromAddress to recover the
90  * address the data was retrieved from.
91  */
92  int32_t (*RecvFrom)(PP_Resource udp_socket,
93  char* buffer,
94  int32_t num_bytes,
95  struct PP_CompletionCallback callback);
96  /* Upon successful completion of RecvFrom, the address that the data
97  * was received from is stored in |addr|.
98  */
100  struct PP_NetAddress_Private* addr);
101  /* Performs a non-blocking sendto call on the socket created and
102  * bound(has already called Bind). The callback |callback| is
103  * invoked when sendto completes.
104  */
105  int32_t (*SendTo)(PP_Resource udp_socket,
106  const char* buffer,
107  int32_t num_bytes,
108  const struct PP_NetAddress_Private* addr,
109  struct PP_CompletionCallback callback);
110  /* Cancels all pending reads and writes, and closes the socket. */
111  void (*Close)(PP_Resource udp_socket);
112 };
113 
115 
117  PP_Resource (*Create)(PP_Instance instance_id);
118  PP_Bool (*IsUDPSocket)(PP_Resource resource_id);
119  int32_t (*Bind)(PP_Resource udp_socket,
120  const struct PP_NetAddress_Private* addr,
121  struct PP_CompletionCallback callback);
122  int32_t (*RecvFrom)(PP_Resource udp_socket,
123  char* buffer,
124  int32_t num_bytes,
125  struct PP_CompletionCallback callback);
127  struct PP_NetAddress_Private* addr);
128  int32_t (*SendTo)(PP_Resource udp_socket,
129  const char* buffer,
130  int32_t num_bytes,
131  const struct PP_NetAddress_Private* addr,
132  struct PP_CompletionCallback callback);
133  void (*Close)(PP_Resource udp_socket);
134 };
135 
137  PP_Resource (*Create)(PP_Instance instance_id);
138  PP_Bool (*IsUDPSocket)(PP_Resource resource_id);
139  int32_t (*Bind)(PP_Resource udp_socket,
140  const struct PP_NetAddress_Private* addr,
141  struct PP_CompletionCallback callback);
143  struct PP_NetAddress_Private* addr);
144  int32_t (*RecvFrom)(PP_Resource udp_socket,
145  char* buffer,
146  int32_t num_bytes,
147  struct PP_CompletionCallback callback);
149  struct PP_NetAddress_Private* addr);
150  int32_t (*SendTo)(PP_Resource udp_socket,
151  const char* buffer,
152  int32_t num_bytes,
153  const struct PP_NetAddress_Private* addr,
154  struct PP_CompletionCallback callback);
155  void (*Close)(PP_Resource udp_socket);
156 };
157 /**
158  * @}
159  */
160 
161 #endif /* PPAPI_C_PRIVATE_PPB_UDP_SOCKET_PRIVATE_H_ */
162 
int32_t(* SendTo)(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
void(* Close)(PP_Resource udp_socket)
PP_Resource(* Create)(PP_Instance instance_id)
void(* Close)(PP_Resource udp_socket)
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocketFeature_Private, 4)
PP_Bool(* GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private *addr)
int32_t(* SendTo)(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
void(* Close)(PP_Resource udp_socket)
int32_t PP_Resource
Definition: pp_resource.h:40
PP_Bool(* IsUDPSocket)(PP_Resource resource_id)
int32_t(* RecvFrom)(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback)
int32_t(* Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
PP_Resource(* Create)(PP_Instance instance_id)
union PP_VarValue value
Definition: pp_var.h:180
int32_t(* RecvFrom)(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback)
int32_t(* RecvFrom)(PP_Resource udp_socket, char *buffer, int32_t num_bytes, struct PP_CompletionCallback callback)
Definition: pp_var.h:166
PP_Bool(* IsUDPSocket)(PP_Resource resource_id)
PP_Resource(* Create)(PP_Instance instance_id)
int32_t PP_Instance
Definition: pp_instance.h:34
int32_t(* SetSocketFeature)(PP_Resource udp_socket, PP_UDPSocketFeature_Private name, struct PP_Var value)
PP_Bool(* GetBoundAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private *addr)
PP_Bool(* IsUDPSocket)(PP_Resource resource_id)
PP_Bool
Definition: pp_bool.h:30
PP_UDPSocketFeature_Private
PP_Bool(* GetBoundAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private *addr)
PP_Bool(* GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private *addr)
int32_t(* Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
int32_t(* SendTo)(PP_Resource udp_socket, const char *buffer, int32_t num_bytes, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
int32_t(* Bind)(PP_Resource udp_socket, const struct PP_NetAddress_Private *addr, struct PP_CompletionCallback callback)
PP_Bool(* GetRecvFromAddress)(PP_Resource udp_socket, struct PP_NetAddress_Private *addr)