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/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 | 1599 |
1600 std::string IPAddressToString(const IPAddressNumber& addr) { | 1600 std::string IPAddressToString(const IPAddressNumber& addr) { |
1601 return IPAddressToString(&addr.front(), addr.size()); | 1601 return IPAddressToString(&addr.front(), addr.size()); |
1602 } | 1602 } |
1603 | 1603 |
1604 std::string IPAddressToStringWithPort(const IPAddressNumber& addr, | 1604 std::string IPAddressToStringWithPort(const IPAddressNumber& addr, |
1605 uint16 port) { | 1605 uint16 port) { |
1606 return IPAddressToStringWithPort(&addr.front(), addr.size(), port); | 1606 return IPAddressToStringWithPort(&addr.front(), addr.size(), port); |
1607 } | 1607 } |
1608 | 1608 |
| 1609 std::string IPAddressToPackedString(const IPAddressNumber& addr) { |
| 1610 return std::string(reinterpret_cast<const char *>(&addr.front()), |
| 1611 addr.size()); |
| 1612 } |
| 1613 |
1609 std::string GetHostName() { | 1614 std::string GetHostName() { |
1610 #if defined(OS_WIN) | 1615 #if defined(OS_WIN) |
1611 EnsureWinsockInit(); | 1616 EnsureWinsockInit(); |
1612 #endif | 1617 #endif |
1613 | 1618 |
1614 // Host names are limited to 255 bytes. | 1619 // Host names are limited to 255 bytes. |
1615 char buffer[256]; | 1620 char buffer[256]; |
1616 int result = gethostname(buffer, sizeof(buffer)); | 1621 int result = gethostname(buffer, sizeof(buffer)); |
1617 if (result != 0) { | 1622 if (result != 0) { |
1618 DVLOG(1) << "gethostname() failed with " << result; | 1623 DVLOG(1) << "gethostname() failed with " << result; |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 | 2166 |
2162 NetworkInterface::NetworkInterface(const std::string& name, | 2167 NetworkInterface::NetworkInterface(const std::string& name, |
2163 const IPAddressNumber& address) | 2168 const IPAddressNumber& address) |
2164 : name(name), address(address) { | 2169 : name(name), address(address) { |
2165 } | 2170 } |
2166 | 2171 |
2167 NetworkInterface::~NetworkInterface() { | 2172 NetworkInterface::~NetworkInterface() { |
2168 } | 2173 } |
2169 | 2174 |
2170 } // namespace net | 2175 } // namespace net |
OLD | NEW |