Chromium Code Reviews| Index: ppapi/shared_impl/private/net_address_private_impl.cc |
| diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc |
| index 74f9f3da6f3061e13032d2967d90cd9363ca85f4..3db8127e689a6470ed60d209501798d6607b69fd 100644 |
| --- a/ppapi/shared_impl/private/net_address_private_impl.cc |
| +++ b/ppapi/shared_impl/private/net_address_private_impl.cc |
| @@ -330,6 +330,30 @@ void GetAnyAddress(PP_Bool is_ipv6, PP_NetAddress_Private* addr) { |
| } |
| } |
| +void CreateFromIPv4Address(const uint8_t ip[4], |
| + uint16_t port, |
| + struct PP_NetAddress_Private* addr_out) { |
| + sockaddr_in* a = reinterpret_cast<sockaddr_in*>(addr_out->data); |
| + addr_out->size = sizeof(*a); |
| + memset(a, 0, sizeof(*a)); |
|
viettrungluu
2012/03/21 17:42:55
Might as well zero all of |data| (as in |GetAnyAdd
Sergey Ulanov
2012/03/21 18:14:51
Done.
|
| + a->sin_family = AF_INET; |
| + memcpy(&(a->sin_addr), ip, sizeof(a->sin_addr)); |
| + a->sin_port = htons(port); |
| +} |
| + |
| +void CreateFromIPv6Address(const uint8_t ip[16], |
| + uint32_t scope_id, |
| + uint16_t port, |
| + struct PP_NetAddress_Private* addr_out) { |
| + sockaddr_in6* a = reinterpret_cast<sockaddr_in6*>(addr_out->data); |
| + addr_out->size = sizeof(*a); |
| + memset(a, 0, sizeof(*a)); |
|
viettrungluu
2012/03/21 17:42:55
"
Sergey Ulanov
2012/03/21 18:14:51
Done.
|
| + a->sin6_family = AF_INET6; |
| + memcpy(&(a->sin6_addr), ip, sizeof(a->sin6_addr)); |
| + a->sin6_port = htons(port); |
| + a->sin6_scope_id = scope_id; |
|
viettrungluu
2012/03/21 17:42:55
Maybe we should include a GetScopeID() in the 1.1
Sergey Ulanov
2012/03/21 18:14:51
Done.
|
| +} |
| + |
| const PPB_NetAddress_Private_0_1 net_address_private_interface_0_1 = { |
| &AreEqual, |
| &AreHostsEqual, |
| @@ -349,6 +373,19 @@ const PPB_NetAddress_Private_1_0 net_address_private_interface_1_0 = { |
| &GetAddress |
| }; |
| +const PPB_NetAddress_Private_1_1 net_address_private_interface_1_1 = { |
| + &AreEqual, |
| + &AreHostsEqual, |
| + &Describe, |
| + &ReplacePort, |
| + &GetAnyAddress, |
| + &GetFamily, |
| + &GetPort, |
| + &GetAddress, |
| + &CreateFromIPv4Address, |
| + &CreateFromIPv6Address |
| +}; |
| + |
| } // namespace |
| namespace thunk { |
| @@ -363,6 +400,11 @@ GetPPB_NetAddress_Private_1_0_Thunk() { |
| return &net_address_private_interface_1_0; |
| } |
| +PPAPI_THUNK_EXPORT const PPB_NetAddress_Private_1_1* |
| +GetPPB_NetAddress_Private_1_1_Thunk() { |
| + return &net_address_private_interface_1_1; |
| +} |
| + |
| } // namespace thunk |
| // static |