Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / ppapi / c / private / ppb_net_address_private.h
blob2ae1366697184409a99578776240e71d8f6eb032
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 */
6 /* From private/ppb_net_address_private.idl,
7 * modified Sat Oct 20 12:39:54 2012.
8 */
10 #ifndef PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_
11 #define PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_module.h"
16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_var.h"
19 #define PPB_NETADDRESS_PRIVATE_INTERFACE_0_1 "PPB_NetAddress_Private;0.1"
20 #define PPB_NETADDRESS_PRIVATE_INTERFACE_1_0 "PPB_NetAddress_Private;1.0"
21 #define PPB_NETADDRESS_PRIVATE_INTERFACE_1_1 "PPB_NetAddress_Private;1.1"
22 #define PPB_NETADDRESS_PRIVATE_INTERFACE PPB_NETADDRESS_PRIVATE_INTERFACE_1_1
24 /**
25 * @file
26 * This file defines the <code>PPB_NetAddress_Private</code> interface.
30 /**
31 * @addtogroup Enums
32 * @{
34 typedef enum {
35 /**
36 * The address family is unspecified.
38 PP_NETADDRESSFAMILY_UNSPECIFIED = 0,
39 /**
40 * The Internet Protocol version 4 (IPv4) address family.
42 PP_NETADDRESSFAMILY_IPV4 = 1,
43 /**
44 * The Internet Protocol version 6 (IPv6) address family.
46 PP_NETADDRESSFAMILY_IPV6 = 2
47 } PP_NetAddressFamily_Private;
48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddressFamily_Private, 4);
49 /**
50 * @}
53 /**
54 * @addtogroup Structs
55 * @{
57 /**
58 * This is an opaque type holding a network address. Plugins must
59 * never access members of this struct directly.
61 struct PP_NetAddress_Private {
62 uint32_t size;
63 char data[128];
65 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_Private, 132);
66 /**
67 * @}
70 /**
71 * @addtogroup Interfaces
72 * @{
74 /**
75 * The <code>PPB_NetAddress_Private</code> interface provides operations on
76 * network addresses.
78 struct PPB_NetAddress_Private_1_1 {
79 /**
80 * Returns PP_TRUE if the two addresses are equal (host and port).
82 PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
83 const struct PP_NetAddress_Private* addr2);
84 /**
85 * Returns PP_TRUE if the two addresses refer to the same host.
87 PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
88 const struct PP_NetAddress_Private* addr2);
89 /**
90 * Returns a human-readable description of the network address, optionally
91 * including the port (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"),
92 * or an undefined var on failure.
94 struct PP_Var (*Describe)(PP_Module module,
95 const struct PP_NetAddress_Private* addr,
96 PP_Bool include_port);
97 /**
98 * Replaces the port in the given source address. Returns PP_TRUE on success.
100 PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
101 uint16_t port,
102 struct PP_NetAddress_Private* addr_out);
104 * Gets the "any" address (for IPv4 or IPv6); for use with UDP Bind.
106 void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
108 * Gets the address family.
110 PP_NetAddressFamily_Private (*GetFamily)(
111 const struct PP_NetAddress_Private* addr);
113 * Gets the port. The port is returned in host byte order.
115 uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr);
117 * Gets the address. The output, address, must be large enough for the
118 * current socket family. The output will be the binary representation of an
119 * address for the current socket family. For IPv4 and IPv6 the address is in
120 * network byte order. PP_TRUE is returned if the address was successfully
121 * retrieved.
123 PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr,
124 void* address,
125 uint16_t address_size);
127 * Returns ScopeID for IPv6 addresses or 0 for IPv4.
129 uint32_t (*GetScopeID)(const struct PP_NetAddress_Private* addr);
131 * Creates NetAddress with the specified IPv4 address and port
132 * number.
134 void (*CreateFromIPv4Address)(const uint8_t ip[4],
135 uint16_t port,
136 struct PP_NetAddress_Private* addr_out);
138 * Creates NetAddress with the specified IPv6 address, scope_id and
139 * port number.
141 void (*CreateFromIPv6Address)(const uint8_t ip[16],
142 uint32_t scope_id,
143 uint16_t port,
144 struct PP_NetAddress_Private* addr_out);
147 typedef struct PPB_NetAddress_Private_1_1 PPB_NetAddress_Private;
149 struct PPB_NetAddress_Private_0_1 {
150 PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
151 const struct PP_NetAddress_Private* addr2);
152 PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
153 const struct PP_NetAddress_Private* addr2);
154 struct PP_Var (*Describe)(PP_Module module,
155 const struct PP_NetAddress_Private* addr,
156 PP_Bool include_port);
157 PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
158 uint16_t port,
159 struct PP_NetAddress_Private* addr_out);
160 void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
163 struct PPB_NetAddress_Private_1_0 {
164 PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
165 const struct PP_NetAddress_Private* addr2);
166 PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
167 const struct PP_NetAddress_Private* addr2);
168 struct PP_Var (*Describe)(PP_Module module,
169 const struct PP_NetAddress_Private* addr,
170 PP_Bool include_port);
171 PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
172 uint16_t port,
173 struct PP_NetAddress_Private* addr_out);
174 void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
175 PP_NetAddressFamily_Private (*GetFamily)(
176 const struct PP_NetAddress_Private* addr);
177 uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr);
178 PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr,
179 void* address,
180 uint16_t address_size);
183 * @}
186 #endif /* PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ */