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

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

Issue 22381012: Allow p2p UDP packages to set DSCP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: plumb DSCP up through IPC layer 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_libevent.h" 5 #include "net/udp/udp_socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 &ttl, sizeof(ttl)); 524 &ttl, sizeof(ttl));
525 } else { 525 } else {
526 // Signed interger. -1 to use route default. 526 // Signed interger. -1 to use route default.
527 int ttl = multicast_time_to_live_; 527 int ttl = multicast_time_to_live_;
528 rv = setsockopt(socket_, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, 528 rv = setsockopt(socket_, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
529 &ttl, sizeof(ttl)); 529 &ttl, sizeof(ttl));
530 } 530 }
531 if (rv < 0) 531 if (rv < 0)
532 return MapSystemError(errno); 532 return MapSystemError(errno);
533 } 533 }
534
Alpha Left Google 2013/08/08 23:28:26 nit: Don't add empty lines.
hubbe 2013/08/15 23:31:11 Done.
534 return OK; 535 return OK;
535 } 536 }
536 537
537 int UDPSocketLibevent::DoBind(const IPEndPoint& address) { 538 int UDPSocketLibevent::DoBind(const IPEndPoint& address) {
538 SockaddrStorage storage; 539 SockaddrStorage storage;
539 if (!address.ToSockAddr(storage.addr, &storage.addr_len)) 540 if (!address.ToSockAddr(storage.addr, &storage.addr_len))
540 return ERR_ADDRESS_INVALID; 541 return ERR_ADDRESS_INVALID;
541 int rv = bind(socket_, storage.addr, storage.addr_len); 542 int rv = bind(socket_, storage.addr, storage.addr_len);
542 return rv < 0 ? MapSystemError(errno) : rv; 543 return rv < 0 ? MapSystemError(errno) : rv;
543 } 544 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 DCHECK(CalledOnValidThread()); 645 DCHECK(CalledOnValidThread());
645 if (is_connected()) 646 if (is_connected())
646 return ERR_SOCKET_IS_CONNECTED; 647 return ERR_SOCKET_IS_CONNECTED;
647 648
648 if (loopback) 649 if (loopback)
649 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; 650 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP;
650 else 651 else
651 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; 652 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP;
652 return OK; 653 return OK;
653 } 654 }
655
656 int UDPSocketLibevent::SetToS(DiffServCodePoint dscp) {
657 if (dscp == DSCP_NO_CHANGE) {
658 return OK;
659 }
660 int rv;
661 int dscp_and_ecn = dscp << 2;
662 if (addr_family_ == AF_INET) {
663 rv = setsockopt(socket_, IPPROTO_IP, IP_TOS,
664 &dscp_and_ecn, sizeof(dscp_and_ecn));
665 } else {
666 rv = setsockopt(socket_, IPPROTO_IPV6, IPV6_TCLASS,
667 &dscp_and_ecn, sizeof(dscp_and_ecn));
668 }
669 if (rv < 0)
670 return MapSystemError(errno);
671
672 return OK;
673 }
674
654 } // namespace net 675 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698