15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* From private/ppb_net_address_private.idl,
7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch *   modified Mon Jun 24 09:52:39 2013.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_bool.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_macros.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_module.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_stdint.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_var.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPB_NETADDRESS_PRIVATE_INTERFACE_0_1 "PPB_NetAddress_Private;0.1"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPB_NETADDRESS_PRIVATE_INTERFACE_1_0 "PPB_NetAddress_Private;1.0"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPB_NETADDRESS_PRIVATE_INTERFACE_1_1 "PPB_NetAddress_Private;1.1"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PPB_NETADDRESS_PRIVATE_INTERFACE PPB_NETADDRESS_PRIVATE_INTERFACE_1_1
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @file
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This file defines the <code>PPB_NetAddress_Private</code> interface.
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @addtogroup Enums
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @{
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum {
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * The address family is unspecified.
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
38eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED = 0,
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * The Internet Protocol version 4 (IPv4) address family.
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
42eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  PP_NETADDRESSFAMILY_PRIVATE_IPV4 = 1,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * The Internet Protocol version 6 (IPv6) address family.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
46eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  PP_NETADDRESSFAMILY_PRIVATE_IPV6 = 2
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PP_NetAddressFamily_Private;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetAddressFamily_Private, 4);
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @}
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @addtogroup Structs
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @{
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This is an opaque type holding a network address. Plugins must
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * never access members of this struct directly.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PP_NetAddress_Private {
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint32_t size;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  char data[128];
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_NetAddress_Private, 132);
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @}
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @addtogroup Interfaces
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @{
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The <code>PPB_NetAddress_Private</code> interface provides operations on
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * network addresses.
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PPB_NetAddress_Private_1_1 {
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Returns PP_TRUE if the two addresses are equal (host and port).
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                      const struct PP_NetAddress_Private* addr2);
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Returns PP_TRUE if the two addresses refer to the same host.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const struct PP_NetAddress_Private* addr2);
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Returns a human-readable description of the network address, optionally
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * including the port (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80"),
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * or an undefined var on failure.
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct PP_Var (*Describe)(PP_Module module,
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            const struct PP_NetAddress_Private* addr,
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            PP_Bool include_port);
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Replaces the port in the given source address. Returns PP_TRUE on success.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         uint16_t port,
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         struct PP_NetAddress_Private* addr_out);
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Gets the "any" address (for IPv4 or IPv6); for use with UDP Bind.
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Gets the address family.
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_NetAddressFamily_Private (*GetFamily)(
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const struct PP_NetAddress_Private* addr);
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Gets the port. The port is returned in host byte order.
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr);
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Gets the address. The output, address, must be large enough for the
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * current socket family. The output will be the binary representation of an
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * address for the current socket family. For IPv4 and IPv6 the address is in
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * network byte order. PP_TRUE is returned if the address was successfully
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * retrieved.
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr,
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        void* address,
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        uint16_t address_size);
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Returns ScopeID for IPv6 addresses or 0 for IPv4.
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint32_t (*GetScopeID)(const struct PP_NetAddress_Private* addr);
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Creates NetAddress with the specified IPv4 address and port
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * number.
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void (*CreateFromIPv4Address)(const uint8_t ip[4],
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                uint16_t port,
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                struct PP_NetAddress_Private* addr_out);
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  /**
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * Creates NetAddress with the specified IPv6 address, scope_id and
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   * port number.
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   */
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void (*CreateFromIPv6Address)(const uint8_t ip[16],
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                uint32_t scope_id,
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                uint16_t port,
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                struct PP_NetAddress_Private* addr_out);
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PPB_NetAddress_Private_1_1 PPB_NetAddress_Private;
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PPB_NetAddress_Private_0_1 {
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                      const struct PP_NetAddress_Private* addr2);
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const struct PP_NetAddress_Private* addr2);
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct PP_Var (*Describe)(PP_Module module,
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            const struct PP_NetAddress_Private* addr,
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            PP_Bool include_port);
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         uint16_t port,
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         struct PP_NetAddress_Private* addr_out);
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PPB_NetAddress_Private_1_0 {
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreEqual)(const struct PP_NetAddress_Private* addr1,
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                      const struct PP_NetAddress_Private* addr2);
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*AreHostsEqual)(const struct PP_NetAddress_Private* addr1,
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           const struct PP_NetAddress_Private* addr2);
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct PP_Var (*Describe)(PP_Module module,
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            const struct PP_NetAddress_Private* addr,
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            PP_Bool include_port);
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*ReplacePort)(const struct PP_NetAddress_Private* src_addr,
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         uint16_t port,
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         struct PP_NetAddress_Private* addr_out);
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void (*GetAnyAddress)(PP_Bool is_ipv6, struct PP_NetAddress_Private* addr);
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_NetAddressFamily_Private (*GetFamily)(
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const struct PP_NetAddress_Private* addr);
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  uint16_t (*GetPort)(const struct PP_NetAddress_Private* addr);
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Bool (*GetAddress)(const struct PP_NetAddress_Private* addr,
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        void* address,
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        uint16_t address_size);
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @}
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  /* PPAPI_C_PRIVATE_PPB_NET_ADDRESS_PRIVATE_H_ */
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
188