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

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: use GQoS on windows 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
« net/base/net_util.h ('K') | « net/udp/udp_socket_win.h ('k') | no next file » | 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_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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if (is_connected()) 745 if (is_connected())
746 return ERR_SOCKET_IS_CONNECTED; 746 return ERR_SOCKET_IS_CONNECTED;
747 747
748 if (loopback) 748 if (loopback)
749 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; 749 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP;
750 else 750 else
751 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; 751 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP;
752 return OK; 752 return OK;
753 } 753 }
754 754
755 // setsockopt IP_TOS doesn't work on XP and newer. This code
756 // attempts to map DSCP to the GQoS api, which will then
757 // of course map it back to DSCP. Unfortunately, this does not
758 // give as fine-grained control of the DSCP value as
759 // setsockopt does.
760 int UDPSocketWin::SetDiffServCodePoint(DiffServCodePoint dscp) {
761 QOS qos;
762 switch (dscp) {
763 case DSCP_NO_CHANGE:
764 return OK;
765
766 default:
767 case DSCP_CS0:
768 case DSCP_CS1:
769 case DSCP_AF11:
770 case DSCP_AF12:
771 case DSCP_AF13:
772 qos.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
773 qos.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
774 break;
775
776 case DSCP_CS2:
777 case DSCP_AF21:
778 case DSCP_AF22:
779 case DSCP_AF23:
780 qos.SendingFlowspec.ServiceType = SERVICETYPE_CONTROLLEDLOAD;
781 qos.ReceivingFlowspec.ServiceType = SERVICETYPE_CONTROLLEDLOAD;
782 break;
783
784 case DSCP_CS3:
785 case DSCP_AF31:
786 case DSCP_AF32:
787 case DSCP_AF33:
788 case DSCP_CS4:
789 case DSCP_AF41:
790 case DSCP_AF42:
791 case DSCP_AF43:
792 case DSCP_CS5:
793 case DSCP_EF:
794 case DSCP_CS6:
795 qos.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
796 qos.ReceivingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
797 break;
798
799 case DSCP_CS7:
800 qos.SendingFlowspec.ServiceType = SERVICETYPE_NETWORK_CONTROL;
801 qos.ReceivingFlowspec.ServiceType = SERVICETYPE_NETWORK_CONTROL;
802 break;
803 }
804
805 qos.ReceivingFlowspec.TokenRate = 100000000;
806 qos.ReceivingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;
807 qos.ReceivingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;
808 qos.ReceivingFlowspec.Latency = QOS_NOT_SPECIFIED;
809 qos.ReceivingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
810 qos.ReceivingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
811 qos.ReceivingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
812
813 // We don't actually know what bandwidth we will be
814 // using, try something really high.
815 qos.SendingFlowspec.TokenRate = 100000000;
816 qos.SendingFlowspec.TokenBucketSize = 100000000;
817 qos.SendingFlowspec.PeakBandwidth = 100000000;
818 qos.SendingFlowspec.Latency = QOS_NOT_SPECIFIED;
819 qos.SendingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
820 qos.SendingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
821 qos.SendingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
822
823 qos.ProviderSpecific.len = 0;
824 qos.ProviderSpecific.buf = NULL;
825 DWORD bytes_returned;
826 if (WSAIoctl(socket_, SIO_SET_QOS,
827 &qos, sizeof(QOS), NULL, 0,
828 &bytes_returned, NULL, NULL)) {
829 return MapSystemError(WSAGetLastError());
830 }
831 return OK;
832 }
833
755 } // namespace net 834 } // namespace net
OLDNEW
« net/base/net_util.h ('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