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

Side by Side Diff: net/socket/socket_descriptor.cc

Issue 25727003: Enable IPv4 address mapped to IPv6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/socket/socket_descriptor.h" 5 #include "net/socket/socket_descriptor.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #endif 10 #endif
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 13
14 #if defined(OS_WIN) 14 #if defined(OS_WIN)
15 #include <ws2tcpip.h>
16 #include "base/win/windows_version.h"
15 #include "net/base/winsock_init.h" 17 #include "net/base/winsock_init.h"
16 #endif 18 #endif
17 19
18 namespace net { 20 namespace net {
19 21
20 PlatformSocketFactory* g_socket_factory = NULL; 22 PlatformSocketFactory* g_socket_factory = NULL;
21 23
22 PlatformSocketFactory::PlatformSocketFactory() { 24 PlatformSocketFactory::PlatformSocketFactory() {
23 } 25 }
24 26
25 PlatformSocketFactory::~PlatformSocketFactory() { 27 PlatformSocketFactory::~PlatformSocketFactory() {
26 } 28 }
27 29
28 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) { 30 void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) {
29 g_socket_factory = factory; 31 g_socket_factory = factory;
30 } 32 }
31 33
32 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) { 34 SocketDescriptor CreateSocketDefault(int family, int type, int protocol) {
33 #if defined(OS_WIN) 35 #if defined(OS_WIN)
34 EnsureWinsockInit(); 36 EnsureWinsockInit();
35 return ::WSASocket(family, type, protocol, NULL, 0, WSA_FLAG_OVERLAPPED); 37 SocketDescriptor result = ::WSASocket(family, type, protocol, NULL, 0,
38 WSA_FLAG_OVERLAPPED);
39 if (result != kInvalidSocket && family == AF_INET6 &&
40 base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) {
41 DWORD value = 0;
42 if (setsockopt(result, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&value,
jar (doing other things) 2013/10/04 02:49:19 nit: please use C++ style reinterpret_cast<const
halyavin 2013/10/04 13:16:59 Done.
43 sizeof(value))) {
44 closesocket(result);
45 result = kInvalidSocket;
jar (doing other things) 2013/10/04 02:49:19 nit: easier to read is a direct: return kInvalidSo
halyavin 2013/10/04 13:16:59 Done.
46 }
47 }
48 return result;
36 #else // OS_WIN 49 #else // OS_WIN
37 return ::socket(family, type, protocol); 50 return ::socket(family, type, protocol);
38 #endif // OS_WIN 51 #endif // OS_WIN
39 } 52 }
40 53
41 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) { 54 SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
42 if (g_socket_factory) 55 if (g_socket_factory)
43 return g_socket_factory->CreateSocket(family, type, protocol); 56 return g_socket_factory->CreateSocket(family, type, protocol);
44 else 57 else
45 return CreateSocketDefault(family, type, protocol); 58 return CreateSocketDefault(family, type, protocol);
46 } 59 }
47 60
48 } // namespace net 61 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698