| 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 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return false; | 91 return false; |
| 92 *out = IPAddress(address, address_length); | 92 *out = IPAddress(address, address_length); |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace | 96 } // namespace |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 char* AddressTrackerLinux::GetInterfaceName(int interface_index, char* buf) { | 99 char* AddressTrackerLinux::GetInterfaceName(int interface_index, char* buf) { |
| 100 memset(buf, 0, IFNAMSIZ); | 100 memset(buf, 0, IFNAMSIZ); |
| 101 base::ScopedFD ioctl_socket(socket(AF_INET, SOCK_DGRAM, 0)); | 101 base::ScopedFD ioctl_socket = GetSocketForIoctl(); |
| 102 if (!ioctl_socket.is_valid()) | 102 if (!ioctl_socket.is_valid()) |
| 103 return buf; | 103 return buf; |
| 104 | 104 |
| 105 struct ifreq ifr = {}; | 105 struct ifreq ifr = {}; |
| 106 ifr.ifr_ifindex = interface_index; | 106 ifr.ifr_ifindex = interface_index; |
| 107 | 107 |
| 108 if (ioctl(ioctl_socket.get(), SIOCGIFNAME, &ifr) == 0) | 108 if (ioctl(ioctl_socket.get(), SIOCGIFNAME, &ifr) == 0) |
| 109 strncpy(buf, ifr.ifr_name, IFNAMSIZ - 1); | 109 strncpy(buf, ifr.ifr_name, IFNAMSIZ - 1); |
| 110 return buf; | 110 return buf; |
| 111 } | 111 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 492 |
| 493 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { | 493 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { |
| 494 if (tracker_.tracking_) { | 494 if (tracker_.tracking_) { |
| 495 lock_.AssertAcquired(); | 495 lock_.AssertAcquired(); |
| 496 lock_.Release(); | 496 lock_.Release(); |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 | 499 |
| 500 } // namespace internal | 500 } // namespace internal |
| 501 } // namespace net | 501 } // namespace net |
| OLD | NEW |