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_net_address_private.idl, 7 * modified Mon Jun 24 09:52:39 2013. 8 */ 9 10 #ifndef PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ 11 #define PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ 12 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" 18 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 23 24 /** 25 * @file 26 * This file defines the <code>PPB_NetAddress_Private</code> interface. 27 */ 28 29 30 /** 31 * @addtogroup Enums 32 * @{ 33 */ 34 typedef enum { 35 /** 36 * The address family is unspecified. 37 */ 38 PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED = 0, 39 /** 40 * The Internet Protocol version 4 (IPv4) address family. 41 */ 42 PP_NETADDRESSFAMILY_PRIVATE_IPV4 = 1, 43 /** 44 * The Internet Protocol version 6 (IPv6) address family. 45 */ 46 PP_NETADDRESSFAMILY_PRIVATE_IPV6 = 2 47 } PP_NetAddressFamily_Private; 48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddressFamily_Private, 4); 49 /** 50 * @} 51 */ 52 53 /** 54 * @addtogroup Structs 55 * @{ 56 */ 57 /** 58 * This is an opaque type holding a network address. Plugins must 59 * never access members of this struct directly. 60 */ 61 struct PP_NetAddress_Private { 62 uint32_t size; 63 char data[128]; 64 }; 65 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_Private, 132); 66 /** 67 * @} 68 */ 69 70 /** 71 * @addtogroup Interfaces 72 * @{ 73 */ 74 /** 75 * The <code>PPB_NetAddress_Private</code> interface provides operations on 76 * network addresses. 77 */ 78 struct PPB_NetAddress_Private_1_1 { 79 /** 80 * Returns PP_TRUE if the two addresses are equal (host and port). 81 */ 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. 86 */ 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. 93 */ 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. 99 */ 100 PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr, 101 uint16_t port, 102 struct PP_NetAddress_Private* addr_out); 103 /** 104 * Gets the "any" address (for IPv4 or IPv6); for use with UDP Bind. 105 */ 106 void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr); 107 /** 108 * Gets the address family. 109 */ 110 PP_NetAddressFamily_Private (*GetFamily)( 111 const struct PP_NetAddress_Private* addr); 112 /** 113 * Gets the port. The port is returned in host byte order. 114 */ 115 uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr); 116 /** 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. 122 */ 123 PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr, 124 void* address, 125 uint16_t address_size); 126 /** 127 * Returns ScopeID for IPv6 addresses or 0 for IPv4. 128 */ 129 uint32_t (*GetScopeID)(const struct PP_NetAddress_Private* addr); 130 /** 131 * Creates NetAddress with the specified IPv4 address and port 132 * number. 133 */ 134 void (*CreateFromIPv4Address)(const uint8_t ip[4], 135 uint16_t port, 136 struct PP_NetAddress_Private* addr_out); 137 /** 138 * Creates NetAddress with the specified IPv6 address, scope_id and 139 * port number. 140 */ 141 void (*CreateFromIPv6Address)(const uint8_t ip[16], 142 uint32_t scope_id, 143 uint16_t port, 144 struct PP_NetAddress_Private* addr_out); 145 }; 146 147 typedef struct PPB_NetAddress_Private_1_1 PPB_NetAddress_Private; 148 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); 161 }; 162 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); 181 }; 182 /** 183 * @} 184 */ 185 186 #endif /* PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ */ 187 188