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

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

Issue 155618: Use manually constructed IPv6 socket addresses for tests, rather than system ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 11 years, 5 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 | « net/base/address_list.h ('k') | net/base/host_resolver_impl_unittest.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_list.h" 5 #include "net/base/address_list.h"
6 6
7 #ifdef OS_WIN 7 #ifdef OS_WIN
8 #include <ws2tcpip.h> 8 #include <ws2tcpip.h>
9 #include <wspiapi.h> // Needed for Win2k compat. 9 #include <wspiapi.h> // Needed for Win2k compat.
10 #else 10 #else
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Otherwise we need to make a copy in order to change the port number. 120 // Otherwise we need to make a copy in order to change the port number.
121 Copy(src.head()); 121 Copy(src.head());
122 SetPort(port); 122 SetPort(port);
123 } 123 }
124 } 124 }
125 125
126 void AddressList::Reset() { 126 void AddressList::Reset() {
127 data_ = NULL; 127 data_ = NULL;
128 } 128 }
129 129
130 // static
131 AddressList AddressList::CreateIPv6Address(unsigned char data[16]) {
132 struct addrinfo* ai = new struct addrinfo;
133 memset(ai, 0, sizeof(struct addrinfo));
134
135 ai->ai_family = AF_INET6;
136 ai->ai_socktype = SOCK_STREAM;
137 ai->ai_addrlen = sizeof(sockaddr_in6);
138
139 struct sockaddr_in6* addr6 = new sockaddr_in6;
140 memset(addr6, 0, sizeof(sockaddr_in6));
141
142 ai->ai_addr = reinterpret_cast<sockaddr*>(addr6);
143 addr6->sin6_family = AF_INET6;
144 memcpy(&addr6->sin6_addr, data, 16);
145
146 return AddressList(new Data(ai, false /*is_system_created*/));
147 }
148
130 AddressList::Data::~Data() { 149 AddressList::Data::~Data() {
131 // Call either freeaddrinfo(head), or FreeMyAddrinfo(head), depending who 150 // Call either freeaddrinfo(head), or FreeMyAddrinfo(head), depending who
132 // created the data. 151 // created the data.
133 if (is_system_created) 152 if (is_system_created)
134 freeaddrinfo(head); 153 freeaddrinfo(head);
135 else 154 else
136 FreeMyAddrinfo(head); 155 FreeMyAddrinfo(head);
137 } 156 }
138 157
139 } // namespace net 158 } // namespace net
OLDNEW
« no previous file with comments | « net/base/address_list.h ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698