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

Unified 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 side-by-side diff with in-line comments
Download patch
« net/base/net_util.h ('K') | « net/udp/udp_socket_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_win.cc
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index 1f0c337fd4a609fcb783bb0382345a88ab4ecd34..430346cc90e380eb2ab1dc22267b3e9c8fdac27e 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -752,4 +752,83 @@ int UDPSocketWin::SetMulticastLoopbackMode(bool loopback) {
return OK;
}
+// setsockopt IP_TOS doesn't work on XP and newer. This code
+// attempts to map DSCP to the GQoS api, which will then
+// of course map it back to DSCP. Unfortunately, this does not
+// give as fine-grained control of the DSCP value as
+// setsockopt does.
+int UDPSocketWin::SetDiffServCodePoint(DiffServCodePoint dscp) {
+ QOS qos;
+ switch (dscp) {
+ case DSCP_NO_CHANGE:
+ return OK;
+
+ default:
+ case DSCP_CS0:
+ case DSCP_CS1:
+ case DSCP_AF11:
+ case DSCP_AF12:
+ case DSCP_AF13:
+ qos.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ qos.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT;
+ break;
+
+ case DSCP_CS2:
+ case DSCP_AF21:
+ case DSCP_AF22:
+ case DSCP_AF23:
+ qos.SendingFlowspec.ServiceType = SERVICETYPE_CONTROLLEDLOAD;
+ qos.ReceivingFlowspec.ServiceType = SERVICETYPE_CONTROLLEDLOAD;
+ break;
+
+ case DSCP_CS3:
+ case DSCP_AF31:
+ case DSCP_AF32:
+ case DSCP_AF33:
+ case DSCP_CS4:
+ case DSCP_AF41:
+ case DSCP_AF42:
+ case DSCP_AF43:
+ case DSCP_CS5:
+ case DSCP_EF:
+ case DSCP_CS6:
+ qos.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
+ qos.ReceivingFlowspec.ServiceType = SERVICETYPE_GUARANTEED;
+ break;
+
+ case DSCP_CS7:
+ qos.SendingFlowspec.ServiceType = SERVICETYPE_NETWORK_CONTROL;
+ qos.ReceivingFlowspec.ServiceType = SERVICETYPE_NETWORK_CONTROL;
+ break;
+ }
+
+ qos.ReceivingFlowspec.TokenRate = 100000000;
+ qos.ReceivingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;
+ qos.ReceivingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;
+ qos.ReceivingFlowspec.Latency = QOS_NOT_SPECIFIED;
+ qos.ReceivingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
+ qos.ReceivingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
+ qos.ReceivingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
+
+ // We don't actually know what bandwidth we will be
+ // using, try something really high.
+ qos.SendingFlowspec.TokenRate = 100000000;
+ qos.SendingFlowspec.TokenBucketSize = 100000000;
+ qos.SendingFlowspec.PeakBandwidth = 100000000;
+ qos.SendingFlowspec.Latency = QOS_NOT_SPECIFIED;
+ qos.SendingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
+ qos.SendingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
+ qos.SendingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
+
+ qos.ProviderSpecific.len = 0;
+ qos.ProviderSpecific.buf = NULL;
+ DWORD bytes_returned;
+ if (WSAIoctl(socket_, SIO_SET_QOS,
+ &qos, sizeof(QOS), NULL, 0,
+ &bytes_returned, NULL, NULL)) {
+ return MapSystemError(WSAGetLastError());
+ }
+ return OK;
+}
+
} // namespace net
« 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