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

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

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 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
« no previous file with comments | « net/tools/quic/quic_server_session.cc ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 hdr.msg_name = &raw_address; 142 hdr.msg_name = &raw_address;
143 hdr.msg_namelen = sizeof(raw_address); 143 hdr.msg_namelen = sizeof(raw_address);
144 hdr.msg_iov = &iov; 144 hdr.msg_iov = &iov;
145 hdr.msg_iovlen = 1; 145 hdr.msg_iovlen = 1;
146 146
147 const int kSpaceForIp = CMSG_SPACE(sizeof(in6_pktinfo)); 147 const int kSpaceForIp = CMSG_SPACE(sizeof(in6_pktinfo));
148 char cbuf[kSpaceForIp]; 148 char cbuf[kSpaceForIp];
149 if (self_address.empty()) { 149 if (self_address.empty()) {
150 hdr.msg_control = 0; 150 hdr.msg_control = 0;
151 hdr.msg_controllen = 0; 151 hdr.msg_controllen = 0;
152 } else if (self_address.size() == sizeof(sockaddr_in)) { 152 } else if (GetAddressFamily(self_address) == ADDRESS_FAMILY_IPV4) {
153 cmsghdr *cmsg = reinterpret_cast<cmsghdr*>(cbuf); 153 cmsghdr *cmsg = reinterpret_cast<cmsghdr*>(cbuf);
154 hdr.msg_control = cmsg; 154 hdr.msg_control = cmsg;
155 hdr.msg_controllen = CMSG_SPACE(sizeof(in_pktinfo)); 155 hdr.msg_controllen = CMSG_SPACE(sizeof(in_pktinfo));
156 156
157 cmsg->cmsg_len = CMSG_LEN(sizeof(in_pktinfo)); 157 cmsg->cmsg_len = CMSG_LEN(sizeof(in_pktinfo));
158 cmsg->cmsg_level = IPPROTO_IP; 158 cmsg->cmsg_level = IPPROTO_IP;
159 cmsg->cmsg_type = IP_PKTINFO; 159 cmsg->cmsg_type = IP_PKTINFO;
160 in_pktinfo* pktinfo = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg)); 160 in_pktinfo* pktinfo = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg));
161 memset(pktinfo, 0, sizeof(in_pktinfo)); 161 memset(pktinfo, 0, sizeof(in_pktinfo));
162 pktinfo->ipi_ifindex = 0; 162 pktinfo->ipi_ifindex = 0;
(...skipping 11 matching lines...) Expand all
174 memcpy(&pktinfo->ipi6_addr, &self_address[0], self_address.size()); 174 memcpy(&pktinfo->ipi6_addr, &self_address[0], self_address.size());
175 } 175 }
176 176
177 int rc = sendmsg(fd, &hdr, 0); 177 int rc = sendmsg(fd, &hdr, 0);
178 *error = (rc >= 0) ? 0 : errno; 178 *error = (rc >= 0) ? 0 : errno;
179 return rc; 179 return rc;
180 } 180 }
181 181
182 } // namespace tools 182 } // namespace tools
183 } // namespace net 183 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server_session.cc ('k') | net/tools/quic/test_tools/quic_client_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698