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

Side by Side Diff: net/udp/udp_socket_posix.cc

Issue 2235973002: Add a SetDoNotFragment() method to DatagramSocket, and call this for (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 | « net/udp/udp_socket_posix.h ('k') | net/udp/udp_socket_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 // 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 "net/udp/udp_socket_posix.h" 5 #include "net/udp/udp_socket_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <net/if.h> 9 #include <net/if.h>
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 419
420 int UDPSocketPosix::SetSendBufferSize(int32_t size) { 420 int UDPSocketPosix::SetSendBufferSize(int32_t size) {
421 DCHECK_NE(socket_, kInvalidSocket); 421 DCHECK_NE(socket_, kInvalidSocket);
422 DCHECK(CalledOnValidThread()); 422 DCHECK(CalledOnValidThread());
423 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, 423 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
424 reinterpret_cast<const char*>(&size), sizeof(size)); 424 reinterpret_cast<const char*>(&size), sizeof(size));
425 return rv == 0 ? OK : MapSystemError(errno); 425 return rv == 0 ? OK : MapSystemError(errno);
426 } 426 }
427 427
428 int UDPSocketPosix::SetDoNotFragment() {
429 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread());
431
432 #if !defined(IP_PMTUDISC_DO)
433 return ERR_NOT_IMPLEMENTED;
434 #else
435 if (addr_family_ == AF_INET6) {
436 int val = IPV6_PMTUDISC_DO;
437 if (setsockopt(socket_, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val,
438 sizeof(val)) != 0) {
439 return MapSystemError(errno);
440 }
441
442 int v6_only = false;
443 socklen_t v6_only_len = sizeof(v6_only);
444 if (getsockopt(socket_, IPPROTO_IPV6, IPV6_V6ONLY, &v6_only,
445 &v6_only_len) != 0) {
446 return MapSystemError(errno);
447 }
448
449 if (v6_only)
450 return OK;
451 }
452
453 int val = IP_PMTUDISC_DO;
454 int rv = setsockopt(socket_, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
455 return rv == 0 ? OK : MapSystemError(errno);
456 #endif
457 }
458
428 int UDPSocketPosix::AllowAddressReuse() { 459 int UDPSocketPosix::AllowAddressReuse() {
429 DCHECK_NE(socket_, kInvalidSocket); 460 DCHECK_NE(socket_, kInvalidSocket);
430 DCHECK(CalledOnValidThread()); 461 DCHECK(CalledOnValidThread());
431 DCHECK(!is_connected()); 462 DCHECK(!is_connected());
432 int true_value = 1; 463 int true_value = 1;
433 int rv = setsockopt( 464 int rv = setsockopt(
434 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value)); 465 socket_, SOL_SOCKET, SO_REUSEADDR, &true_value, sizeof(true_value));
435 return rv == 0 ? OK : MapSystemError(errno); 466 return rv == 0 ? OK : MapSystemError(errno);
436 } 467 }
437 468
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 return MapSystemError(errno); 872 return MapSystemError(errno);
842 873
843 return OK; 874 return OK;
844 } 875 }
845 876
846 void UDPSocketPosix::DetachFromThread() { 877 void UDPSocketPosix::DetachFromThread() {
847 base::NonThreadSafe::DetachFromThread(); 878 base::NonThreadSafe::DetachFromThread();
848 } 879 }
849 880
850 } // namespace net 881 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_posix.h ('k') | net/udp/udp_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698