OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/base/nethelpers.h" | 11 #include "webrtc/base/nethelpers.h" |
12 | 12 |
| 13 #include <memory> |
| 14 |
13 #if defined(WEBRTC_WIN) | 15 #if defined(WEBRTC_WIN) |
14 #include <ws2spi.h> | 16 #include <ws2spi.h> |
15 #include <ws2tcpip.h> | 17 #include <ws2tcpip.h> |
16 #include "webrtc/base/win32.h" | 18 #include "webrtc/base/win32.h" |
17 #endif | 19 #endif |
18 | 20 |
19 #include "webrtc/base/byteorder.h" | 21 #include "webrtc/base/byteorder.h" |
20 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
21 #include "webrtc/base/signalthread.h" | 23 #include "webrtc/base/signalthread.h" |
22 | 24 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // We only need to check this for Windows XP (so far). | 122 // We only need to check this for Windows XP (so far). |
121 return true; | 123 return true; |
122 #else | 124 #else |
123 if (IsWindowsVistaOrLater()) { | 125 if (IsWindowsVistaOrLater()) { |
124 return true; | 126 return true; |
125 } | 127 } |
126 if (!IsWindowsXpOrLater()) { | 128 if (!IsWindowsXpOrLater()) { |
127 return false; | 129 return false; |
128 } | 130 } |
129 DWORD protbuff_size = 4096; | 131 DWORD protbuff_size = 4096; |
130 scoped_ptr<char[]> protocols; | 132 std::unique_ptr<char[]> protocols; |
131 LPWSAPROTOCOL_INFOW protocol_infos = NULL; | 133 LPWSAPROTOCOL_INFOW protocol_infos = NULL; |
132 int requested_protocols[2] = {AF_INET6, 0}; | 134 int requested_protocols[2] = {AF_INET6, 0}; |
133 | 135 |
134 int err = 0; | 136 int err = 0; |
135 int ret = 0; | 137 int ret = 0; |
136 // Check for protocols in a do-while loop until we provide a buffer large | 138 // Check for protocols in a do-while loop until we provide a buffer large |
137 // enough. (WSCEnumProtocols sets protbuff_size to its desired value). | 139 // enough. (WSCEnumProtocols sets protbuff_size to its desired value). |
138 // It is extremely unlikely that this will loop more than once. | 140 // It is extremely unlikely that this will loop more than once. |
139 do { | 141 do { |
140 protocols.reset(new char[protbuff_size]); | 142 protocols.reset(new char[protbuff_size]); |
(...skipping 10 matching lines...) Expand all Loading... |
151 // Non-IPv6 enabled WinXP will still return a RAW protocol. | 153 // Non-IPv6 enabled WinXP will still return a RAW protocol. |
152 for (int i = 0; i < ret; ++i) { | 154 for (int i = 0; i < ret; ++i) { |
153 if (protocol_infos[i].iAddressFamily == AF_INET6) { | 155 if (protocol_infos[i].iAddressFamily == AF_INET6) { |
154 return true; | 156 return true; |
155 } | 157 } |
156 } | 158 } |
157 return false; | 159 return false; |
158 #endif | 160 #endif |
159 } | 161 } |
160 } // namespace rtc | 162 } // namespace rtc |
OLD | NEW |