Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 | 8 |
| 9 #include "base/eintr_wrapper.h" | 9 #include "base/eintr_wrapper.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 base::ThreadRestrictions::AssertIOAllowed(); | 69 base::ThreadRestrictions::AssertIOAllowed(); |
| 70 | 70 |
| 71 ifaddrs *ifaddr; | 71 ifaddrs *ifaddr; |
| 72 if (getifaddrs(&ifaddr) < 0) { | 72 if (getifaddrs(&ifaddr) < 0) { |
| 73 PLOG(ERROR) << "getifaddrs"; | 73 PLOG(ERROR) << "getifaddrs"; |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 | 76 |
| 77 for (ifaddrs *ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { | 77 for (ifaddrs *ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { |
| 78 int family = ifa->ifa_addr->sa_family; | 78 int family = ifa->ifa_addr->sa_family; |
| 79 if (!ifa->ifa_addr) | |
| 80 continue; | |
|
wtc
2011/08/10 19:29:02
Did you test this patch? On line 78 you have alre
wtc
2011/08/10 19:32:22
I checked the other two getifaddrs calls in net/ba
| |
| 79 if (family == AF_INET || family == AF_INET6) { | 81 if (family == AF_INET || family == AF_INET6) { |
| 80 IPEndPoint address; | 82 IPEndPoint address; |
| 81 std::string name = ifa->ifa_name; | 83 std::string name = ifa->ifa_name; |
| 82 if (address.FromSockAddr(ifa->ifa_addr, | 84 if (address.FromSockAddr(ifa->ifa_addr, |
| 83 sizeof(ifa->ifa_addr)) && | 85 sizeof(ifa->ifa_addr)) && |
| 84 name.substr(0, 2) != "lo") { | 86 name.substr(0, 2) != "lo") { |
| 85 networks->push_back(NetworkInterface(name, address.address())); | 87 networks->push_back(NetworkInterface(name, address.address())); |
| 86 } | 88 } |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 | 91 |
| 90 freeifaddrs(ifaddr); | 92 freeifaddrs(ifaddr); |
| 91 | 93 |
| 92 return true; | 94 return true; |
| 93 #endif | 95 #endif |
| 94 } | 96 } |
| 95 | 97 |
| 96 } // namespace net | 98 } // namespace net |
| OLD | NEW |