| OLD | NEW |
| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 DCHECK(CalledOnValidThread()); | 645 DCHECK(CalledOnValidThread()); |
| 646 if (is_connected()) | 646 if (is_connected()) |
| 647 return ERR_SOCKET_IS_CONNECTED; | 647 return ERR_SOCKET_IS_CONNECTED; |
| 648 | 648 |
| 649 if (loopback) | 649 if (loopback) |
| 650 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; | 650 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; |
| 651 else | 651 else |
| 652 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; | 652 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; |
| 653 return OK; | 653 return OK; |
| 654 } | 654 } |
| 655 |
| 656 int UDPSocketLibevent::SetDiffServCodePoint(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 |
| 655 } // namespace net | 675 } // namespace net |
| OLD | NEW |