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

Side by Side Diff: net/tools/quic/quic_socket_utils.cc

Issue 397793004: Replace setsockopt(IP_PKTINFO) and setsockopt(IPV6_RECVPKTINFO) calls by (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/tools/quic/quic_server.cc ('K') | « net/tools/quic/quic_server.cc ('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/tools/quic/quic_socket_utils.h" 5 #include "net/tools/quic/quic_socket_utils.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/in.h> 8 #include <netinet/in.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return true; 63 return true;
64 } 64 }
65 } 65 }
66 } 66 }
67 return false; 67 return false;
68 } 68 }
69 69
70 // static 70 // static
71 int QuicSocketUtils::SetGetAddressInfo(int fd, int address_family) { 71 int QuicSocketUtils::SetGetAddressInfo(int fd, int address_family) {
72 int get_local_ip = 1; 72 int get_local_ip = 1;
73 if (address_family == AF_INET) { 73 int rc = setsockopt(fd, IPPROTO_IP, IP_PKTINFO,
74 return setsockopt(fd, IPPROTO_IP, IP_PKTINFO,
75 &get_local_ip, sizeof(get_local_ip)); 74 &get_local_ip, sizeof(get_local_ip));
76 } else { 75 if (rc == 0 && address_family == AF_INET6) {
77 return setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, 76 rc = setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
78 &get_local_ip, sizeof(get_local_ip)); 77 &get_local_ip, sizeof(get_local_ip));
79 } 78 }
79 return rc;
80 } 80 }
81 81
82 // static 82 // static
83 bool QuicSocketUtils::SetSendBufferSize(int fd, size_t size) { 83 bool QuicSocketUtils::SetSendBufferSize(int fd, size_t size) {
84 if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) { 84 if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) {
85 LOG(ERROR) << "Failed to set socket send size"; 85 LOG(ERROR) << "Failed to set socket send size";
86 return false; 86 return false;
87 } 87 }
88 return true; 88 return true;
89 } 89 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 int rc = sendmsg(fd, &hdr, 0); 216 int rc = sendmsg(fd, &hdr, 0);
217 if (rc >= 0) { 217 if (rc >= 0) {
218 return WriteResult(WRITE_STATUS_OK, rc); 218 return WriteResult(WRITE_STATUS_OK, rc);
219 } 219 }
220 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) ? 220 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) ?
221 WRITE_STATUS_BLOCKED : WRITE_STATUS_ERROR, errno); 221 WRITE_STATUS_BLOCKED : WRITE_STATUS_ERROR, errno);
222 } 222 }
223 223
224 } // namespace tools 224 } // namespace tools
225 } // namespace net 225 } // namespace net
OLDNEW
« net/tools/quic/quic_server.cc ('K') | « net/tools/quic/quic_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698