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

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

Issue 22381012: Allow p2p UDP packages to set DSCP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed tests 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
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_win.h" 5 #include "net/udp/udp_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 //----------------------------------------------------------------------------- 159 //-----------------------------------------------------------------------------
160 160
161 UDPSocketWin::UDPSocketWin(DatagramSocket::BindType bind_type, 161 UDPSocketWin::UDPSocketWin(DatagramSocket::BindType bind_type,
162 const RandIntCallback& rand_int_cb, 162 const RandIntCallback& rand_int_cb,
163 net::NetLog* net_log, 163 net::NetLog* net_log,
164 const net::NetLog::Source& source) 164 const net::NetLog::Source& source)
165 : socket_(INVALID_SOCKET), 165 : socket_(INVALID_SOCKET),
166 addr_family_(0), 166 addr_family_(0),
167 socket_options_(SOCKET_OPTION_MULTICAST_LOOP), 167 socket_options_(SOCKET_OPTION_MULTICAST_LOOP),
168 multicast_time_to_live_(1), 168 multicast_time_to_live_(1),
169 dscp_(DSCP_CS0),
169 bind_type_(bind_type), 170 bind_type_(bind_type),
170 rand_int_cb_(rand_int_cb), 171 rand_int_cb_(rand_int_cb),
171 recv_from_address_(NULL), 172 recv_from_address_(NULL),
172 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_UDP_SOCKET)) { 173 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_UDP_SOCKET)) {
173 EnsureWinsockInit(); 174 EnsureWinsockInit();
174 net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE, 175 net_log_.BeginEvent(NetLog::TYPE_SOCKET_ALIVE,
175 source.ToEventParametersCallback()); 176 source.ToEventParametersCallback());
176 if (bind_type == DatagramSocket::RANDOM_BIND) 177 if (bind_type == DatagramSocket::RANDOM_BIND)
177 DCHECK(!rand_int_cb.is_null()); 178 DCHECK(!rand_int_cb.is_null());
178 } 179 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 DWORD hops = multicast_time_to_live_; 615 DWORD hops = multicast_time_to_live_;
615 int protocol_level = 616 int protocol_level =
616 addr_family_ == AF_INET ? IPPROTO_IP : IPPROTO_IPV6; 617 addr_family_ == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
617 int option = 618 int option =
618 addr_family_ == AF_INET ? IP_MULTICAST_TTL: IPV6_MULTICAST_HOPS; 619 addr_family_ == AF_INET ? IP_MULTICAST_TTL: IPV6_MULTICAST_HOPS;
619 int rv = setsockopt(socket_, protocol_level, option, 620 int rv = setsockopt(socket_, protocol_level, option,
620 reinterpret_cast<const char*>(&hops), sizeof(hops)); 621 reinterpret_cast<const char*>(&hops), sizeof(hops));
621 if (rv < 0) 622 if (rv < 0)
622 return MapSystemError(WSAGetLastError()); 623 return MapSystemError(WSAGetLastError());
623 } 624 }
625 if (dscp_) {
626 int rw;
627 DWORD dscp_and_ecn = dscp_ << 2;
628 if (addr_family_ == AF_INET) {
629 rv = setsockopt(socket_, IPPROTO_IP, IP_TOS,
630 reinterpret_cast<const char*>(&dscp_and_ecn),
631 sizeof(dscp_and_ecn));
632 } else {
633 rv = setsockopt(socket_, IPPROTO_IPV6, IPV6_TCLASS,
634 reinterpret_cast<const char*>(&dscp_and_ecn),
635 sizeof(dscp_and_ecn));
636 }
637 if (rv < 0) {
638 LOG(INFO) << "Failed to set dscp, errno=" << errno;
639 }
640 }
624 return OK; 641 return OK;
625 } 642 }
626 643
627 int UDPSocketWin::DoBind(const IPEndPoint& address) { 644 int UDPSocketWin::DoBind(const IPEndPoint& address) {
628 SockaddrStorage storage; 645 SockaddrStorage storage;
629 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 646 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
630 return ERR_ADDRESS_INVALID; 647 return ERR_ADDRESS_INVALID;
631 int rv = bind(socket_, storage.addr, storage.addr_len); 648 int rv = bind(socket_, storage.addr, storage.addr_len);
632 return rv < 0 ? MapSystemError(WSAGetLastError()) : rv; 649 return rv < 0 ? MapSystemError(WSAGetLastError()) : rv;
633 } 650 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 return ERR_SOCKET_IS_CONNECTED; 763 return ERR_SOCKET_IS_CONNECTED;
747 764
748 if (loopback) 765 if (loopback)
749 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; 766 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP;
750 else 767 else
751 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; 768 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP;
752 return OK; 769 return OK;
753 } 770 }
754 771
755 } // namespace net 772 } // namespace net
OLDNEW
« content/browser/renderer_host/p2p/socket_host_udp.cc ('K') | « net/udp/udp_socket_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698