1 // Copyright (c) 2011 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.
5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_
11 #include "base/basictypes.h"
12 #include "ppapi/c/pp_stdint.h"
13 #include "ppapi/c/ppb_net_address.h"
14 #include "ppapi/shared_impl/ppapi_shared_export.h"
16 struct PP_NetAddress_Private
;
21 class PPAPI_SHARED_EXPORT NetAddressPrivateImpl
{
23 static bool ValidateNetAddress(const PP_NetAddress_Private
& addr
);
25 static bool SockaddrToNetAddress(const sockaddr
* sa
,
27 PP_NetAddress_Private
* net_addr
);
29 static bool IPEndPointToNetAddress(const std::vector
<unsigned char>& address
,
31 PP_NetAddress_Private
* net_addr
);
33 static bool NetAddressToIPEndPoint(const PP_NetAddress_Private
& net_addr
,
34 std::vector
<unsigned char>* address
,
37 static std::string
DescribeNetAddress(const PP_NetAddress_Private
& addr
,
40 static void GetAnyAddress(PP_Bool is_ipv6
, PP_NetAddress_Private
* addr
);
42 // Conversion methods to make PPB_NetAddress resource work with
43 // PP_NetAddress_Private.
44 // TODO(yzshen): Remove them once PPB_NetAddress resource doesn't use
45 // PP_NetAddress_Private as storage type.
46 static void CreateNetAddressPrivateFromIPv4Address(
47 const PP_NetAddress_IPv4
& ipv4_addr
,
48 PP_NetAddress_Private
* addr
);
49 static void CreateNetAddressPrivateFromIPv6Address(
50 const PP_NetAddress_IPv6
& ipv6_addr
,
51 PP_NetAddress_Private
* addr
);
52 static PP_NetAddress_Family
GetFamilyFromNetAddressPrivate(
53 const PP_NetAddress_Private
& addr
);
54 static bool DescribeNetAddressPrivateAsIPv4Address(
55 const PP_NetAddress_Private
& addr
,
56 PP_NetAddress_IPv4
* ipv4_addr
);
57 static bool DescribeNetAddressPrivateAsIPv6Address(
58 const PP_NetAddress_Private
& addr
,
59 PP_NetAddress_IPv6
* ipv6_addr
);
61 static const PP_NetAddress_Private kInvalidNetAddress
;
64 DISALLOW_IMPLICIT_CONSTRUCTORS(NetAddressPrivateImpl
);
69 #endif // PPAPI_SHARED_IMPL_PRIVATE_NET_ADDRESS_PRIVATE_IMPL_H_