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

Side by Side Diff: webrtc/p2p/base/stunport.cc

Issue 2685053004: Add the URL attribute to cricket::Candiate. (Closed)
Patch Set: Merge Created 3 years, 10 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
« no previous file with comments | « webrtc/p2p/base/relayport.cc ('k') | webrtc/p2p/base/stunport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // default local address will be issued as a candidate instead if 308 // default local address will be issued as a candidate instead if
309 // |emit_local_for_anyaddress| is true. This is to allow connectivity for 309 // |emit_local_for_anyaddress| is true. This is to allow connectivity for
310 // applications which absolutely requires a HOST candidate. 310 // applications which absolutely requires a HOST candidate.
311 rtc::SocketAddress addr = address; 311 rtc::SocketAddress addr = address;
312 312
313 // If MaybeSetDefaultLocalAddress fails, we keep the "any" IP so that at 313 // If MaybeSetDefaultLocalAddress fails, we keep the "any" IP so that at
314 // least the port is listening. 314 // least the port is listening.
315 MaybeSetDefaultLocalAddress(&addr); 315 MaybeSetDefaultLocalAddress(&addr);
316 316
317 AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "", "", 317 AddAddress(addr, addr, rtc::SocketAddress(), UDP_PROTOCOL_NAME, "", "",
318 LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, false); 318 LOCAL_PORT_TYPE, ICE_TYPE_PREFERENCE_HOST, 0, "", false);
319 MaybePrepareStunCandidate(); 319 MaybePrepareStunCandidate();
320 } 320 }
321 321
322 void UDPPort::OnReadPacket(rtc::AsyncPacketSocket* socket, 322 void UDPPort::OnReadPacket(rtc::AsyncPacketSocket* socket,
323 const char* data, 323 const char* data,
324 size_t size, 324 size_t size,
325 const rtc::SocketAddress& remote_addr, 325 const rtc::SocketAddress& remote_addr,
326 const rtc::PacketTime& packet_time) { 326 const rtc::PacketTime& packet_time) {
327 RTC_DCHECK(socket == socket_); 327 RTC_DCHECK(socket == socket_);
328 RTC_DCHECK(!remote_addr.IsUnresolvedIP()); 328 RTC_DCHECK(!remote_addr.IsUnresolvedIP());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 if ((!SharedSocket() || stun_reflected_addr != socket_->GetLocalAddress()) && 446 if ((!SharedSocket() || stun_reflected_addr != socket_->GetLocalAddress()) &&
447 !HasCandidateWithAddress(stun_reflected_addr)) { 447 !HasCandidateWithAddress(stun_reflected_addr)) {
448 448
449 rtc::SocketAddress related_address = socket_->GetLocalAddress(); 449 rtc::SocketAddress related_address = socket_->GetLocalAddress();
450 // If we can't stamp the related address correctly, empty it to avoid leak. 450 // If we can't stamp the related address correctly, empty it to avoid leak.
451 if (!MaybeSetDefaultLocalAddress(&related_address)) { 451 if (!MaybeSetDefaultLocalAddress(&related_address)) {
452 related_address = rtc::EmptySocketAddressWithFamily( 452 related_address = rtc::EmptySocketAddressWithFamily(
453 related_address.family()); 453 related_address.family());
454 } 454 }
455 455
456 std::ostringstream url;
457 url << "stun:" << stun_server_addr.ipaddr().ToString() << ":"
458 << stun_server_addr.port();
456 AddAddress(stun_reflected_addr, socket_->GetLocalAddress(), related_address, 459 AddAddress(stun_reflected_addr, socket_->GetLocalAddress(), related_address,
457 UDP_PROTOCOL_NAME, "", "", STUN_PORT_TYPE, 460 UDP_PROTOCOL_NAME, "", "", STUN_PORT_TYPE,
458 ICE_TYPE_PREFERENCE_SRFLX, 0, false); 461 ICE_TYPE_PREFERENCE_SRFLX, 0, url.str(), false);
459 } 462 }
460 MaybeSetPortCompleteOrError(); 463 MaybeSetPortCompleteOrError();
461 } 464 }
462 465
463 void UDPPort::OnStunBindingOrResolveRequestFailed( 466 void UDPPort::OnStunBindingOrResolveRequestFailed(
464 const rtc::SocketAddress& stun_server_addr) { 467 const rtc::SocketAddress& stun_server_addr) {
465 if (bind_request_failed_servers_.find(stun_server_addr) != 468 if (bind_request_failed_servers_.find(stun_server_addr) !=
466 bind_request_failed_servers_.end()) { 469 bind_request_failed_servers_.end()) {
467 return; 470 return;
468 } 471 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 const std::vector<Candidate>& existing_candidates = Candidates(); 510 const std::vector<Candidate>& existing_candidates = Candidates();
508 std::vector<Candidate>::const_iterator it = existing_candidates.begin(); 511 std::vector<Candidate>::const_iterator it = existing_candidates.begin();
509 for (; it != existing_candidates.end(); ++it) { 512 for (; it != existing_candidates.end(); ++it) {
510 if (it->address() == addr) 513 if (it->address() == addr)
511 return true; 514 return true;
512 } 515 }
513 return false; 516 return false;
514 } 517 }
515 518
516 } // namespace cricket 519 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/relayport.cc ('k') | webrtc/p2p/base/stunport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698