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
3 * found in the LICENSE file.
6 /* From ppb_net_address.idl modified Sat Jun 22 10:14:31 2013. */
8 #ifndef PPAPI_C_PPB_NET_ADDRESS_H_
9 #define PPAPI_C_PPB_NET_ADDRESS_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_var.h"
18 #define PPB_NETADDRESS_INTERFACE_1_0 "PPB_NetAddress;1.0"
19 #define PPB_NETADDRESS_INTERFACE PPB_NETADDRESS_INTERFACE_1_0
23 * This file defines the <code>PPB_NetAddress</code> interface.
32 * Network address family types.
36 * The address family is unspecified.
38 PP_NETADDRESS_FAMILY_UNSPECIFIED
= 0,
40 * The Internet Protocol version 4 (IPv4) address family.
42 PP_NETADDRESS_FAMILY_IPV4
= 1,
44 * The Internet Protocol version 6 (IPv6) address family.
46 PP_NETADDRESS_FAMILY_IPV6
= 2
47 } PP_NetAddress_Family
;
48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddress_Family
, 4);
58 * All members are expressed in network byte order.
60 struct PP_NetAddress_IPv4
{
70 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_IPv4
, 6);
73 * All members are expressed in network byte order.
75 struct PP_NetAddress_IPv6
{
85 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_IPv6
, 18);
91 * @addtogroup Interfaces
95 * The <code>PPB_NetAddress</code> interface provides operations on network
98 struct PPB_NetAddress_1_0
{
100 * Creates a <code>PPB_NetAddress</code> resource with the specified IPv4
103 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
105 * @param[in] ipv4_addr An IPv4 address.
107 * @return A <code>PP_Resource</code> representing the same address as
108 * <code>ipv4_addr</code> or 0 on failure.
110 PP_Resource (*CreateFromIPv4Address
)(
111 PP_Instance instance
,
112 const struct PP_NetAddress_IPv4
* ipv4_addr
);
114 * Creates a <code>PPB_NetAddress</code> resource with the specified IPv6
117 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
119 * @param[in] ipv6_addr An IPv6 address.
121 * @return A <code>PP_Resource</code> representing the same address as
122 * <code>ipv6_addr</code> or 0 on failure.
124 PP_Resource (*CreateFromIPv6Address
)(
125 PP_Instance instance
,
126 const struct PP_NetAddress_IPv6
* ipv6_addr
);
128 * Determines if a given resource is a network address.
130 * @param[in] resource A <code>PP_Resource</code> to check.
132 * @return <code>PP_TRUE</code> if the input is a <code>PPB_NetAddress</code>
133 * resource; <code>PP_FALSE</code> otherwise.
135 PP_Bool (*IsNetAddress
)(PP_Resource resource
);
137 * Gets the address family.
139 * @param[in] addr A <code>PP_Resource</code> corresponding to a network
142 * @return The address family on success;
143 * <code>PP_NETADDRESS_FAMILY_UNSPECIFIED</code> on failure.
145 PP_NetAddress_Family (*GetFamily
)(PP_Resource addr
);
147 * Returns a human-readable description of the network address. The
148 * description is in the form of host [ ":" port ] and conforms to
149 * http://tools.ietf.org/html/rfc3986#section-3.2 for IPv4 and IPv6 addresses
150 * (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80").
152 * @param[in] addr A <code>PP_Resource</code> corresponding to a network
154 * @param[in] include_port Whether to include the port number in the
157 * @return A string <code>PP_Var</code> on success; an undefined
158 * <code>PP_Var</code> on failure.
160 struct PP_Var (*DescribeAsString
)(PP_Resource addr
, PP_Bool include_port
);
162 * Fills a <code>PP_NetAddress_IPv4</code> structure if the network address is
163 * of <code>PP_NETADDRESS_FAMILY_IPV4</code> address family.
164 * Note that passing a network address of
165 * <code>PP_NETADDRESS_FAMILY_IPV6</code> address family will fail even if the
166 * address is an IPv4-mapped IPv6 address.
168 * @param[in] addr A <code>PP_Resource</code> corresponding to a network
170 * @param[out] ipv4_addr A <code>PP_NetAddress_IPv4</code> structure to store
173 * @return A <code>PP_Bool</code> value indicating whether the operation
176 PP_Bool (*DescribeAsIPv4Address
)(PP_Resource addr
,
177 struct PP_NetAddress_IPv4
* ipv4_addr
);
179 * Fills a <code>PP_NetAddress_IPv6</code> structure if the network address is
180 * of <code>PP_NETADDRESS_FAMILY_IPV6</code> address family.
181 * Note that passing a network address of
182 * <code>PP_NETADDRESS_FAMILY_IPV4</code> address family will fail - this
183 * method doesn't map it to an IPv6 address.
185 * @param[in] addr A <code>PP_Resource</code> corresponding to a network
187 * @param[out] ipv6_addr A <code>PP_NetAddress_IPv6</code> structure to store
190 * @return A <code>PP_Bool</code> value indicating whether the operation
193 PP_Bool (*DescribeAsIPv6Address
)(PP_Resource addr
,
194 struct PP_NetAddress_IPv6
* ipv6_addr
);
197 typedef struct PPB_NetAddress_1_0 PPB_NetAddress
;
202 #endif /* PPAPI_C_PPB_NET_ADDRESS_H_ */