Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: remoting/client/plugin/pepper_util.cc

Issue 12091004: POSIX: re-enable strict aliasing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_socket_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/client/plugin/pepper_util.h" 5 #include "remoting/client/plugin/pepper_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/cpp/module.h" 10 #include "ppapi/cpp/module.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return result; 52 return result;
53 } 53 }
54 54
55 bool SocketAddressToPpAddress(const talk_base::SocketAddress& address, 55 bool SocketAddressToPpAddress(const talk_base::SocketAddress& address,
56 PP_NetAddress_Private* pp_address) { 56 PP_NetAddress_Private* pp_address) {
57 return SocketAddressToPpAddressWithPort(address, pp_address, address.port()); 57 return SocketAddressToPpAddressWithPort(address, pp_address, address.port());
58 } 58 }
59 59
60 bool PpAddressToSocketAddress(const PP_NetAddress_Private& pp_address, 60 bool PpAddressToSocketAddress(const PP_NetAddress_Private& pp_address,
61 talk_base::SocketAddress* address) { 61 talk_base::SocketAddress* address) {
62 uint8_t addr_storage[16]; 62 union {
63 in_addr ip4;
64 in6_addr ip6;
65 uint8_t raw[16];
66 } addr_storage;
63 bool result = pp::NetAddressPrivate::GetAddress( 67 bool result = pp::NetAddressPrivate::GetAddress(
64 pp_address, &addr_storage, sizeof(addr_storage)); 68 pp_address, &addr_storage.raw, sizeof(addr_storage.raw));
65 69
66 if (result) { 70 if (result) {
67 switch (pp::NetAddressPrivate::GetFamily(pp_address)) { 71 switch (pp::NetAddressPrivate::GetFamily(pp_address)) {
68 case PP_NETADDRESSFAMILY_PRIVATE_IPV4: 72 case PP_NETADDRESSFAMILY_PRIVATE_IPV4:
69 address->SetIP(talk_base::IPAddress( 73 address->SetIP(talk_base::IPAddress(addr_storage.ip4));
70 *reinterpret_cast<in_addr*>(addr_storage)));
71 break; 74 break;
72 case PP_NETADDRESSFAMILY_PRIVATE_IPV6: 75 case PP_NETADDRESSFAMILY_PRIVATE_IPV6:
73 address->SetIP(talk_base::IPAddress( 76 address->SetIP(talk_base::IPAddress(addr_storage.ip6));
74 *reinterpret_cast<in6_addr*>(addr_storage)));
75 break; 77 break;
76 default: 78 default:
77 result = false; 79 result = false;
78 } 80 }
79 } 81 }
80 82
81 if (!result) { 83 if (!result) {
82 LOG(WARNING) << "Failed to convert address: " 84 LOG(WARNING) << "Failed to convert address: "
83 << pp::NetAddressPrivate::Describe(pp_address, true); 85 << pp::NetAddressPrivate::Describe(pp_address, true);
84 } else { 86 } else {
85 address->SetPort(pp::NetAddressPrivate::GetPort(pp_address)); 87 address->SetPort(pp::NetAddressPrivate::GetPort(pp_address));
86 } 88 }
87 return result; 89 return result;
88 } 90 }
89 91
90 } // namespace remoting 92 } // namespace remoting
OLDNEW
« no previous file with comments | « net/tools/quic/quic_socket_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698