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

Side by Side Diff: net/base/address_tracker_linux.cc

Issue 2890773002: When creating sockets for ioctl() use AF_INET6 or AF_INET (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | net/base/network_interfaces_linux.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/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
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
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
OLDNEW
« no previous file with comments | « no previous file | net/base/network_interfaces_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698