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/base/address_tracker_linux.h" | 5 #include "net/base/address_tracker_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/if.h> | 8 #include <linux/if.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 // Request dump of addresses. | 110 // Request dump of addresses. |
111 struct sockaddr_nl peer = {}; | 111 struct sockaddr_nl peer = {}; |
112 peer.nl_family = AF_NETLINK; | 112 peer.nl_family = AF_NETLINK; |
113 | 113 |
114 struct { | 114 struct { |
115 struct nlmsghdr header; | 115 struct nlmsghdr header; |
116 struct rtgenmsg msg; | 116 struct rtgenmsg msg; |
117 } request = {}; | 117 } request = {}; |
118 | 118 |
119 request.header.nlmsg_len = NLMSG_LENGTH(sizeof(request)); | 119 request.header.nlmsg_len = NLMSG_LENGTH(sizeof(request.msg)); |
120 request.header.nlmsg_type = RTM_GETADDR; | 120 request.header.nlmsg_type = RTM_GETADDR; |
121 request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; | 121 request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; |
122 request.header.nlmsg_pid = getpid(); | 122 request.header.nlmsg_pid = getpid(); |
123 request.msg.rtgen_family = AF_UNSPEC; | 123 request.msg.rtgen_family = AF_UNSPEC; |
124 | 124 |
125 rv = HANDLE_EINTR(sendto(netlink_fd_, &request, request.header.nlmsg_len, | 125 rv = HANDLE_EINTR(sendto(netlink_fd_, &request, request.header.nlmsg_len, |
126 0, reinterpret_cast<struct sockaddr*>(&peer), | 126 0, reinterpret_cast<struct sockaddr*>(&peer), |
127 sizeof(peer))); | 127 sizeof(peer))); |
128 if (rv < 0) { | 128 if (rv < 0) { |
129 PLOG(ERROR) << "Could not send NETLINK request"; | 129 PLOG(ERROR) << "Could not send NETLINK request"; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {} | 306 void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {} |
307 | 307 |
308 void AddressTrackerLinux::CloseSocket() { | 308 void AddressTrackerLinux::CloseSocket() { |
309 if (netlink_fd_ >= 0 && HANDLE_EINTR(close(netlink_fd_)) < 0) | 309 if (netlink_fd_ >= 0 && HANDLE_EINTR(close(netlink_fd_)) < 0) |
310 PLOG(ERROR) << "Could not close NETLINK socket."; | 310 PLOG(ERROR) << "Could not close NETLINK socket."; |
311 netlink_fd_ = -1; | 311 netlink_fd_ = -1; |
312 } | 312 } |
313 | 313 |
314 } // namespace internal | 314 } // namespace internal |
315 } // namespace net | 315 } // namespace net |
OLD | NEW |