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.
6 /* From private/ppb_net_address_private.idl,
7 * modified Sat Oct 20 12:39:54 2012.
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
26 * This file defines the <code>PPB_NetAddress_Private</code> interface.
36 * The address family is unspecified.
38 PP_NETADDRESSFAMILY_UNSPECIFIED
= 0,
40 * The Internet Protocol version 4 (IPv4) address family.
42 PP_NETADDRESSFAMILY_IPV4
= 1,
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);
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
{
65 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_Private
, 132);
71 * @addtogroup Interfaces
75 * The <code>PPB_NetAddress_Private</code> interface provides operations on
78 struct PPB_NetAddress_Private_1_1
{
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
);
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
);
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
);
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
,
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
123 PP_Bool (*GetAddress
)(const struct PP_NetAddress_Private
* addr
,
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
134 void (*CreateFromIPv4Address
)(const uint8_t ip
[4],
136 struct PP_NetAddress_Private
* addr_out
);
138 * Creates NetAddress with the specified IPv6 address, scope_id and
141 void (*CreateFromIPv6Address
)(const uint8_t ip
[16],
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
,
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
,
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
,
180 uint16_t address_size
);
186 #endif /* PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ */