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

Side by Side Diff: webrtc/base/physicalsocketserver.cc

Issue 2866183004: Deleted unused method EstimateMTU, and the WinPing class. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « webrtc/base/physicalsocketserver.h ('k') | webrtc/base/socket.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 /* 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 #include "webrtc/base/physicalsocketserver.h" 10 #include "webrtc/base/physicalsocketserver.h"
(...skipping 29 matching lines...) Expand all
40 #include <map> 40 #include <map>
41 41
42 #include "webrtc/base/arraysize.h" 42 #include "webrtc/base/arraysize.h"
43 #include "webrtc/base/basictypes.h" 43 #include "webrtc/base/basictypes.h"
44 #include "webrtc/base/byteorder.h" 44 #include "webrtc/base/byteorder.h"
45 #include "webrtc/base/checks.h" 45 #include "webrtc/base/checks.h"
46 #include "webrtc/base/logging.h" 46 #include "webrtc/base/logging.h"
47 #include "webrtc/base/networkmonitor.h" 47 #include "webrtc/base/networkmonitor.h"
48 #include "webrtc/base/nullsocketserver.h" 48 #include "webrtc/base/nullsocketserver.h"
49 #include "webrtc/base/timeutils.h" 49 #include "webrtc/base/timeutils.h"
50 #include "webrtc/base/winping.h"
51 #include "webrtc/base/win32socketinit.h" 50 #include "webrtc/base/win32socketinit.h"
52 51
53 #if defined(WEBRTC_POSIX) 52 #if defined(WEBRTC_POSIX)
54 #include <netinet/tcp.h> // for TCP_NODELAY 53 #include <netinet/tcp.h> // for TCP_NODELAY
55 #define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h 54 #define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h
56 typedef void* SockOptArg; 55 typedef void* SockOptArg;
57 56
58 #endif // WEBRTC_POSIX 57 #endif // WEBRTC_POSIX
59 58
60 #if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__) 59 #if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__)
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 s_ = INVALID_SOCKET; 464 s_ = INVALID_SOCKET;
466 state_ = CS_CLOSED; 465 state_ = CS_CLOSED;
467 enabled_events_ = 0; 466 enabled_events_ = 0;
468 if (resolver_) { 467 if (resolver_) {
469 resolver_->Destroy(false); 468 resolver_->Destroy(false);
470 resolver_ = nullptr; 469 resolver_ = nullptr;
471 } 470 }
472 return err; 471 return err;
473 } 472 }
474 473
475 int PhysicalSocket::EstimateMTU(uint16_t* mtu) {
476 SocketAddress addr = GetRemoteAddress();
477 if (addr.IsAnyIP()) {
478 SetError(ENOTCONN);
479 return -1;
480 }
481
482 #if defined(WEBRTC_WIN)
483 // Gets the interface MTU (TTL=1) for the interface used to reach |addr|.
484 WinPing ping;
485 if (!ping.IsValid()) {
486 SetError(EINVAL); // can't think of a better error ID
487 return -1;
488 }
489 int header_size = ICMP_HEADER_SIZE;
490 if (addr.family() == AF_INET6) {
491 header_size += IPV6_HEADER_SIZE;
492 } else if (addr.family() == AF_INET) {
493 header_size += IP_HEADER_SIZE;
494 }
495
496 for (int level = 0; PACKET_MAXIMUMS[level + 1] > 0; ++level) {
497 int32_t size = PACKET_MAXIMUMS[level] - header_size;
498 WinPing::PingResult result = ping.Ping(addr.ipaddr(), size,
499 ICMP_PING_TIMEOUT_MILLIS,
500 1, false);
501 if (result == WinPing::PING_FAIL) {
502 SetError(EINVAL); // can't think of a better error ID
503 return -1;
504 } else if (result != WinPing::PING_TOO_LARGE) {
505 *mtu = PACKET_MAXIMUMS[level];
506 return 0;
507 }
508 }
509
510 RTC_NOTREACHED();
511 return -1;
512 #elif defined(WEBRTC_MAC)
513 // No simple way to do this on Mac OS X.
514 // SIOCGIFMTU would work if we knew which interface would be used, but
515 // figuring that out is pretty complicated. For now we'll return an error
516 // and let the caller pick a default MTU.
517 SetError(EINVAL);
518 return -1;
519 #elif defined(WEBRTC_LINUX)
520 // Gets the path MTU.
521 int value;
522 socklen_t vlen = sizeof(value);
523 int err = getsockopt(s_, IPPROTO_IP, IP_MTU, &value, &vlen);
524 if (err < 0) {
525 UpdateLastError();
526 return err;
527 }
528
529 RTC_DCHECK((0 <= value) && (value <= 65536));
530 *mtu = value;
531 return 0;
532 #elif defined(__native_client__)
533 // Most socket operations, including this, will fail in NaCl's sandbox.
534 error_ = EACCES;
535 return -1;
536 #endif
537 }
538
539 SOCKET PhysicalSocket::DoAccept(SOCKET socket, 474 SOCKET PhysicalSocket::DoAccept(SOCKET socket,
540 sockaddr* addr, 475 sockaddr* addr,
541 socklen_t* addrlen) { 476 socklen_t* addrlen) {
542 return ::accept(socket, addr, addrlen); 477 return ::accept(socket, addr, addrlen);
543 } 478 }
544 479
545 int PhysicalSocket::DoSend(SOCKET socket, const char* buf, int len, int flags) { 480 int PhysicalSocket::DoSend(SOCKET socket, const char* buf, int len, int flags) {
546 return ::send(socket, buf, len, flags); 481 return ::send(socket, buf, len, flags);
547 } 482 }
548 483
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 break; 1572 break;
1638 } 1573 }
1639 } 1574 }
1640 1575
1641 // Done 1576 // Done
1642 return true; 1577 return true;
1643 } 1578 }
1644 #endif // WEBRTC_WIN 1579 #endif // WEBRTC_WIN
1645 1580
1646 } // namespace rtc 1581 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/physicalsocketserver.h ('k') | webrtc/base/socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698