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/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> |
11 #include <sys/uio.h> | 11 #include <sys/uio.h> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 | 15 |
16 #ifndef SO_RXQ_OVFL | 16 #ifndef SO_RXQ_OVFL |
17 #define SO_RXQ_OVFL 40 | 17 #define SO_RXQ_OVFL 40 |
18 #endif | 18 #endif |
19 | 19 |
20 namespace net { | 20 namespace net { |
| 21 namespace tools { |
21 | 22 |
22 // static | 23 // static |
23 IPAddressNumber QuicSocketUtils::GetAddressFromMsghdr(struct msghdr *hdr) { | 24 IPAddressNumber QuicSocketUtils::GetAddressFromMsghdr(struct msghdr *hdr) { |
24 IPAddressNumber ret; | 25 IPAddressNumber ret; |
25 if (hdr->msg_controllen > 0) { | 26 if (hdr->msg_controllen > 0) { |
26 for (cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); | 27 for (cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); |
27 cmsg != NULL; | 28 cmsg != NULL; |
28 cmsg = CMSG_NXTHDR(hdr, cmsg)) { | 29 cmsg = CMSG_NXTHDR(hdr, cmsg)) { |
29 const uint8* addr_data = reinterpret_cast<const uint8*>CMSG_DATA(cmsg); | 30 const uint8* addr_data = reinterpret_cast<const uint8*>CMSG_DATA(cmsg); |
30 int len = 0; | 31 int len = 0; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 in6_pktinfo* pktinfo = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg)); | 172 in6_pktinfo* pktinfo = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg)); |
172 memset(pktinfo, 0, sizeof(in6_pktinfo)); | 173 memset(pktinfo, 0, sizeof(in6_pktinfo)); |
173 memcpy(&pktinfo->ipi6_addr, &self_address[0], self_address.size()); | 174 memcpy(&pktinfo->ipi6_addr, &self_address[0], self_address.size()); |
174 } | 175 } |
175 | 176 |
176 int rc = sendmsg(fd, &hdr, 0); | 177 int rc = sendmsg(fd, &hdr, 0); |
177 *error = (rc >= 0) ? 0 : errno; | 178 *error = (rc >= 0) ? 0 : errno; |
178 return rc; | 179 return rc; |
179 } | 180 } |
180 | 181 |
| 182 } // namespace tools |
181 } // namespace net | 183 } // namespace net |
OLD | NEW |