OLD | NEW |
1 /* Copyright 2013 The Chromium Authors. All rights reserved. | 1 /* Copyright 2013 The Chromium Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 /* From ppb_udp_socket.idl modified Wed Jan 14 13:13:19 2015. */ | 6 /* From ppb_udp_socket.idl modified Mon Mar 2 16:50:15 2015. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ | 8 #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ |
9 #define PPAPI_C_PPB_UDP_SOCKET_H_ | 9 #define PPAPI_C_PPB_UDP_SOCKET_H_ |
10 | 10 |
11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/c/pp_macros.h" | 14 #include "ppapi/c/pp_macros.h" |
15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/c/pp_stdint.h" | 16 #include "ppapi/c/pp_stdint.h" |
17 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
18 | 18 |
19 #define PPB_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" | 19 #define PPB_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" |
20 #define PPB_UDPSOCKET_INTERFACE_1_1 "PPB_UDPSocket;1.1" | 20 #define PPB_UDPSOCKET_INTERFACE_1_1 "PPB_UDPSocket;1.1" |
| 21 #define PPB_UDPSOCKET_INTERFACE_1_2 "PPB_UDPSocket;1.2" /* dev */ |
21 #define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_1 | 22 #define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_1 |
22 | 23 |
23 /** | 24 /** |
24 * @file | 25 * @file |
25 * This file defines the <code>PPB_UDPSocket</code> interface. | 26 * This file defines the <code>PPB_UDPSocket</code> interface. |
26 */ | 27 */ |
27 | 28 |
28 | 29 |
29 /** | 30 /** |
30 * @addtogroup Enums | 31 * @addtogroup Enums |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 * Specifies the total per-socket buffer space reserved for receives. Value's | 64 * Specifies the total per-socket buffer space reserved for receives. Value's |
64 * type should be <code>PP_VARTYPE_INT32</code>. | 65 * type should be <code>PP_VARTYPE_INT32</code>. |
65 * On version 1.0, this option can only be set after a successful | 66 * On version 1.0, this option can only be set after a successful |
66 * <code>Bind()</code> call. On version 1.1 or later, there is no such | 67 * <code>Bind()</code> call. On version 1.1 or later, there is no such |
67 * limitation. | 68 * limitation. |
68 * | 69 * |
69 * Note: This is only treated as a hint for the browser to set the buffer | 70 * Note: This is only treated as a hint for the browser to set the buffer |
70 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't | 71 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't |
71 * guarantee it will conform to the size. | 72 * guarantee it will conform to the size. |
72 */ | 73 */ |
73 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 | 74 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, |
| 75 /** |
| 76 * Specifies whether the packets sent from the host to the multicast group |
| 77 * should be looped back to the host or not. Value's type should be |
| 78 * <code>PP_VARTYPE_BOOL</code>. |
| 79 * This option can only be set before calling <code>Bind()</code>. |
| 80 * |
| 81 * This is only supported in version 1.2 of the API (Chrome 43) and later. |
| 82 */ |
| 83 PP_UDPSOCKET_OPTION_MULTICAST_LOOP = 4, |
| 84 /** |
| 85 * Specifies the time-to-live for packets sent to the multicast group. The |
| 86 * value should be within 0 to 255 range. The default value is 1 and means |
| 87 * that packets will not be routed beyond the local network. Value's type |
| 88 * should be <code>PP_VARTYPE_INT32</code>. |
| 89 * This option can only be set before calling <code>Bind()</code>. |
| 90 * |
| 91 * This is only supported in version 1.2 of the API (Chrome 43) and later. |
| 92 */ |
| 93 PP_UDPSOCKET_OPTION_MULTICAST_TTL = 5 |
74 } PP_UDPSocket_Option; | 94 } PP_UDPSocket_Option; |
75 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); | 95 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); |
76 /** | 96 /** |
77 * @} | 97 * @} |
78 */ | 98 */ |
79 | 99 |
80 /** | 100 /** |
81 * @addtogroup Interfaces | 101 * @addtogroup Interfaces |
82 * @{ | 102 * @{ |
83 */ | 103 */ |
84 /** | 104 /** |
85 * The <code>PPB_UDPSocket</code> interface provides UDP socket operations. | 105 * The <code>PPB_UDPSocket</code> interface provides UDP socket operations. |
86 * | 106 * |
87 * Permissions: Apps permission <code>socket</code> with subrule | 107 * Permissions: Apps permission <code>socket</code> with subrule |
88 * <code>udp-bind</code> is required for <code>Bind()</code>; subrule | 108 * <code>udp-bind</code> is required for <code>Bind()</code>; subrule |
89 * <code>udp-send-to</code> is required for <code>SendTo()</code>. | 109 * <code>udp-send-to</code> is required for <code>SendTo()</code>. |
90 * For more details about network communication permissions, please see: | 110 * For more details about network communication permissions, please see: |
91 * http://developer.chrome.com/apps/app_network.html | 111 * http://developer.chrome.com/apps/app_network.html |
92 */ | 112 */ |
93 struct PPB_UDPSocket_1_1 { | 113 struct PPB_UDPSocket_1_2 { /* dev */ |
94 /** | 114 /** |
95 * Creates a UDP socket resource. | 115 * Creates a UDP socket resource. |
96 * | 116 * |
97 * @param[in] instance A <code>PP_Instance</code> identifying one instance of | 117 * @param[in] instance A <code>PP_Instance</code> identifying one instance of |
98 * a module. | 118 * a module. |
99 * | 119 * |
100 * @return A <code>PP_Resource</code> corresponding to a UDP socket or 0 | 120 * @return A <code>PP_Resource</code> corresponding to a UDP socket or 0 |
101 * on failure. | 121 * on failure. |
102 */ | 122 */ |
103 PP_Resource (*Create)(PP_Instance instance); | 123 PP_Resource (*Create)(PP_Instance instance); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 * @param[in] value The option value to set. | 228 * @param[in] value The option value to set. |
209 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 229 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
210 * completion. | 230 * completion. |
211 * | 231 * |
212 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 232 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
213 */ | 233 */ |
214 int32_t (*SetOption)(PP_Resource udp_socket, | 234 int32_t (*SetOption)(PP_Resource udp_socket, |
215 PP_UDPSocket_Option name, | 235 PP_UDPSocket_Option name, |
216 struct PP_Var value, | 236 struct PP_Var value, |
217 struct PP_CompletionCallback callback); | 237 struct PP_CompletionCallback callback); |
| 238 /** |
| 239 * Joins the multicast group with address specified by <code>group</code> |
| 240 * parameter, which is expected to be a <code>PPB_NetAddress</code> object. |
| 241 * |
| 242 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP |
| 243 * socket. |
| 244 * @param[in] group A <code>PP_Resource</code> corresponding to the network |
| 245 * address of the multicast group. |
| 246 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 247 * completion. |
| 248 * |
| 249 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 250 */ |
| 251 int32_t (*JoinGroup)(PP_Resource udp_socket, |
| 252 PP_Resource group, |
| 253 struct PP_CompletionCallback callback); |
| 254 /** |
| 255 * Leaves the multicast group with address specified by <code>group</code> |
| 256 * parameter, which is expected to be a <code>PPB_NetAddress</code> object. |
| 257 * |
| 258 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP |
| 259 * socket. |
| 260 * @param[in] group A <code>PP_Resource</code> corresponding to the network |
| 261 * address of the multicast group. |
| 262 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 263 * completion. |
| 264 * |
| 265 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 266 */ |
| 267 int32_t (*LeaveGroup)(PP_Resource udp_socket, |
| 268 PP_Resource group, |
| 269 struct PP_CompletionCallback callback); |
218 }; | 270 }; |
219 | 271 |
220 typedef struct PPB_UDPSocket_1_1 PPB_UDPSocket; | |
221 | |
222 struct PPB_UDPSocket_1_0 { | 272 struct PPB_UDPSocket_1_0 { |
223 PP_Resource (*Create)(PP_Instance instance); | 273 PP_Resource (*Create)(PP_Instance instance); |
224 PP_Bool (*IsUDPSocket)(PP_Resource resource); | 274 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
225 int32_t (*Bind)(PP_Resource udp_socket, | 275 int32_t (*Bind)(PP_Resource udp_socket, |
226 PP_Resource addr, | 276 PP_Resource addr, |
227 struct PP_CompletionCallback callback); | 277 struct PP_CompletionCallback callback); |
228 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); | 278 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
229 int32_t (*RecvFrom)(PP_Resource udp_socket, | 279 int32_t (*RecvFrom)(PP_Resource udp_socket, |
230 char* buffer, | 280 char* buffer, |
231 int32_t num_bytes, | 281 int32_t num_bytes, |
232 PP_Resource* addr, | 282 PP_Resource* addr, |
233 struct PP_CompletionCallback callback); | 283 struct PP_CompletionCallback callback); |
234 int32_t (*SendTo)(PP_Resource udp_socket, | 284 int32_t (*SendTo)(PP_Resource udp_socket, |
235 const char* buffer, | 285 const char* buffer, |
236 int32_t num_bytes, | 286 int32_t num_bytes, |
237 PP_Resource addr, | 287 PP_Resource addr, |
238 struct PP_CompletionCallback callback); | 288 struct PP_CompletionCallback callback); |
239 void (*Close)(PP_Resource udp_socket); | 289 void (*Close)(PP_Resource udp_socket); |
240 int32_t (*SetOption)(PP_Resource udp_socket, | 290 int32_t (*SetOption)(PP_Resource udp_socket, |
241 PP_UDPSocket_Option name, | 291 PP_UDPSocket_Option name, |
242 struct PP_Var value, | 292 struct PP_Var value, |
243 struct PP_CompletionCallback callback); | 293 struct PP_CompletionCallback callback); |
244 }; | 294 }; |
| 295 |
| 296 struct PPB_UDPSocket_1_1 { |
| 297 PP_Resource (*Create)(PP_Instance instance); |
| 298 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
| 299 int32_t (*Bind)(PP_Resource udp_socket, |
| 300 PP_Resource addr, |
| 301 struct PP_CompletionCallback callback); |
| 302 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
| 303 int32_t (*RecvFrom)(PP_Resource udp_socket, |
| 304 char* buffer, |
| 305 int32_t num_bytes, |
| 306 PP_Resource* addr, |
| 307 struct PP_CompletionCallback callback); |
| 308 int32_t (*SendTo)(PP_Resource udp_socket, |
| 309 const char* buffer, |
| 310 int32_t num_bytes, |
| 311 PP_Resource addr, |
| 312 struct PP_CompletionCallback callback); |
| 313 void (*Close)(PP_Resource udp_socket); |
| 314 int32_t (*SetOption)(PP_Resource udp_socket, |
| 315 PP_UDPSocket_Option name, |
| 316 struct PP_Var value, |
| 317 struct PP_CompletionCallback callback); |
| 318 }; |
| 319 |
| 320 typedef struct PPB_UDPSocket_1_1 PPB_UDPSocket; |
245 /** | 321 /** |
246 * @} | 322 * @} |
247 */ | 323 */ |
248 | 324 |
249 #endif /* PPAPI_C_PPB_UDP_SOCKET_H_ */ | 325 #endif /* PPAPI_C_PPB_UDP_SOCKET_H_ */ |
250 | 326 |
OLD | NEW |