| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 5 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 a->sin6_family = AF_INET6; | 323 a->sin6_family = AF_INET6; |
| 324 a->sin6_addr = in6addr_any; | 324 a->sin6_addr = in6addr_any; |
| 325 } else { | 325 } else { |
| 326 sockaddr_in* a = reinterpret_cast<sockaddr_in*>(addr->data); | 326 sockaddr_in* a = reinterpret_cast<sockaddr_in*>(addr->data); |
| 327 addr->size = sizeof(*a); | 327 addr->size = sizeof(*a); |
| 328 a->sin_family = AF_INET; | 328 a->sin_family = AF_INET; |
| 329 a->sin_addr.s_addr = INADDR_ANY; | 329 a->sin_addr.s_addr = INADDR_ANY; |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 void CreateFromIPv4Address(const uint8_t ip[4], |
| 334 uint16_t port, |
| 335 struct PP_NetAddress_Private* addr_out) { |
| 336 sockaddr_in* a = reinterpret_cast<sockaddr_in*>(addr_out->data); |
| 337 addr_out->size = sizeof(*a); |
| 338 memset(a, 0, sizeof(*a)); |
| 339 a->sin_family = AF_INET; |
| 340 memcpy(&(a->sin_addr), ip, sizeof(a->sin_addr)); |
| 341 a->sin_port = htons(port); |
| 342 } |
| 343 |
| 344 void CreateFromIPv6Address(const uint8_t ip[16], |
| 345 uint32_t scope_id, |
| 346 uint16_t port, |
| 347 struct PP_NetAddress_Private* addr_out) { |
| 348 sockaddr_in6* a = reinterpret_cast<sockaddr_in6*>(addr_out->data); |
| 349 addr_out->size = sizeof(*a); |
| 350 memset(a, 0, sizeof(*a)); |
| 351 a->sin6_family = AF_INET6; |
| 352 memcpy(&(a->sin6_addr), ip, sizeof(a->sin6_addr)); |
| 353 a->sin6_port = htons(port); |
| 354 a->sin6_scope_id = scope_id; |
| 355 } |
| 356 |
| 333 const PPB_NetAddress_Private_0_1 net_address_private_interface_0_1 = { | 357 const PPB_NetAddress_Private_0_1 net_address_private_interface_0_1 = { |
| 334 &AreEqual, | 358 &AreEqual, |
| 335 &AreHostsEqual, | 359 &AreHostsEqual, |
| 336 &Describe, | 360 &Describe, |
| 337 &ReplacePort, | 361 &ReplacePort, |
| 338 &GetAnyAddress | 362 &GetAnyAddress |
| 339 }; | 363 }; |
| 340 | 364 |
| 341 const PPB_NetAddress_Private_1_0 net_address_private_interface_1_0 = { | 365 const PPB_NetAddress_Private_1_0 net_address_private_interface_1_0 = { |
| 342 &AreEqual, | 366 &AreEqual, |
| 343 &AreHostsEqual, | 367 &AreHostsEqual, |
| 344 &Describe, | 368 &Describe, |
| 345 &ReplacePort, | 369 &ReplacePort, |
| 346 &GetAnyAddress, | 370 &GetAnyAddress, |
| 347 &GetFamily, | 371 &GetFamily, |
| 348 &GetPort, | 372 &GetPort, |
| 349 &GetAddress | 373 &GetAddress, |
| 374 &CreateFromIPv4Address, |
| 375 &CreateFromIPv6Address |
| 350 }; | 376 }; |
| 351 | 377 |
| 352 } // namespace | 378 } // namespace |
| 353 | 379 |
| 354 namespace thunk { | 380 namespace thunk { |
| 355 | 381 |
| 356 PPAPI_THUNK_EXPORT const PPB_NetAddress_Private_0_1* | 382 PPAPI_THUNK_EXPORT const PPB_NetAddress_Private_0_1* |
| 357 GetPPB_NetAddress_Private_0_1_Thunk() { | 383 GetPPB_NetAddress_Private_0_1_Thunk() { |
| 358 return &net_address_private_interface_0_1; | 384 return &net_address_private_interface_0_1; |
| 359 } | 385 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 net::IPEndPoint ip_end_point; | 479 net::IPEndPoint ip_end_point; |
| 454 if (!NetAddressToIPEndPoint(net_addr, &ip_end_point)) | 480 if (!NetAddressToIPEndPoint(net_addr, &ip_end_point)) |
| 455 return false; | 481 return false; |
| 456 | 482 |
| 457 *address_list = net::AddressList::CreateFromIPAddress(ip_end_point.address(), | 483 *address_list = net::AddressList::CreateFromIPAddress(ip_end_point.address(), |
| 458 ip_end_point.port()); | 484 ip_end_point.port()); |
| 459 return true; | 485 return true; |
| 460 } | 486 } |
| 461 | 487 |
| 462 } // namespace ppapi | 488 } // namespace ppapi |
| OLD | NEW |