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

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

Issue 10384171: Fix PepperPortAllocator to resolve STUN addresses using HostResolverPrivate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « no previous file | remoting/client/plugin/pepper_port_allocator.h » ('j') | 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_packet_socket_factory.h" 5 #include "remoting/client/plugin/pepper_packet_socket_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "ppapi/cpp/private/net_address_private.h" 10 #include "ppapi/cpp/private/net_address_private.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 min_port_(0), 106 min_port_(0),
107 max_port_(0), 107 max_port_(0),
108 send_pending_(false), 108 send_pending_(false),
109 send_queue_size_(0) { 109 send_queue_size_(0) {
110 } 110 }
111 111
112 UdpPacketSocket::~UdpPacketSocket() { 112 UdpPacketSocket::~UdpPacketSocket() {
113 Close(); 113 Close();
114 } 114 }
115 115
116 bool SocketAddressToPpAddressWithPort(const talk_base::SocketAddress& address,
117 PP_NetAddress_Private* pp_address,
118 uint16_t port) {
119 bool result = false;
120 switch (address.ipaddr().family()) {
121 case AF_INET: {
122 in_addr addr = address.ipaddr().ipv4_address();
123 result = pp::NetAddressPrivate::CreateFromIPv4Address(
124 reinterpret_cast<uint8_t*>(&addr), port, pp_address);
125 break;
126 }
127 case AF_INET6: {
128 in6_addr addr = address.ipaddr().ipv6_address();
129 result = pp::NetAddressPrivate::CreateFromIPv6Address(
130 addr.s6_addr, 0, port, pp_address);
131 break;
132 }
133 default: {
134 LOG(WARNING) << "Unknown address family: " << address.ipaddr().family();
135 }
136 }
137 if (!result) {
138 LOG(WARNING) << "Failed to convert address: " << address.ToString();
139 }
140 return result;
141 }
142
143 bool SocketAddressToPpAddress(const talk_base::SocketAddress& address,
144 PP_NetAddress_Private* pp_address) {
145 return SocketAddressToPpAddressWithPort(address, pp_address, address.port());
146 }
147
148 bool PpAddressToSocketAddress(const PP_NetAddress_Private& pp_address,
149 talk_base::SocketAddress* address) {
150 uint8_t addr_storage[16];
151 bool result = pp::NetAddressPrivate::GetAddress(
152 pp_address, &addr_storage, sizeof(addr_storage));
153
154 if (result) {
155 switch (pp::NetAddressPrivate::GetFamily(pp_address)) {
156 case PP_NETADDRESSFAMILY_IPV4:
157 address->SetIP(talk_base::IPAddress(
158 *reinterpret_cast<in_addr*>(addr_storage)));
159 break;
160 case PP_NETADDRESSFAMILY_IPV6:
161 address->SetIP(talk_base::IPAddress(
162 *reinterpret_cast<in6_addr*>(addr_storage)));
163 break;
164 default:
165 result = false;
166 }
167 }
168
169 if (!result) {
170 LOG(WARNING) << "Failed to convert address: "
171 << pp::NetAddressPrivate::Describe(pp_address, true);
172 } else {
173 address->SetPort(pp::NetAddressPrivate::GetPort(pp_address));
174 }
175 return result;
176 }
177
178 bool UdpPacketSocket::Init(const talk_base::SocketAddress& local_address, 116 bool UdpPacketSocket::Init(const talk_base::SocketAddress& local_address,
179 int min_port, 117 int min_port,
180 int max_port) { 118 int max_port) {
181 if (socket_.is_null()) { 119 if (socket_.is_null()) {
182 return false; 120 return false;
183 } 121 }
184 122
185 local_address_ = local_address; 123 local_address_ = local_address;
186 max_port_ = max_port; 124 max_port_ = max_port;
187 min_port_ = min_port; 125 min_port_ = min_port;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 const talk_base::SocketAddress& remote_address, 344 const talk_base::SocketAddress& remote_address,
407 const talk_base::ProxyInfo& proxy_info, 345 const talk_base::ProxyInfo& proxy_info,
408 const std::string& user_agent, 346 const std::string& user_agent,
409 bool ssl) { 347 bool ssl) {
410 // We don't use TCP sockets for remoting connections. 348 // We don't use TCP sockets for remoting connections.
411 NOTREACHED(); 349 NOTREACHED();
412 return NULL; 350 return NULL;
413 } 351 }
414 352
415 } // namespace remoting 353 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/client/plugin/pepper_port_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698