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

Side by Side Diff: runtime/bin/socket_patch.dart

Issue 95183002: Add the index information to network interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return "InternetAddress('$address', ${type.name})"; 190 return "InternetAddress('$address', ${type.name})";
191 } 191 }
192 192
193 static Uint8List _fixed(int id) native "InternetAddress_Fixed"; 193 static Uint8List _fixed(int id) native "InternetAddress_Fixed";
194 static Uint8List _parse(int type, String address) 194 static Uint8List _parse(int type, String address)
195 native "InternetAddress_Parse"; 195 native "InternetAddress_Parse";
196 } 196 }
197 197
198 class _NetworkInterface implements NetworkInterface { 198 class _NetworkInterface implements NetworkInterface {
199 final String name; 199 final String name;
200 final List<InternetAddress> addresses; 200 final int index;
201 final List<InternetAddress> addresses = [];
201 202
202 _NetworkInterface(String this.name, List<InternetAddress> this.addresses); 203 _NetworkInterface(this.name, this.index);
203 204
204 String toString() { 205 String toString() {
205 return "NetworkInterface('$name', $addresses)"; 206 return "NetworkInterface('$name', $addresses)";
206 } 207 }
207 } 208 }
208 209
209 210
210 // The _NativeSocket class encapsulates an OS socket. 211 // The _NativeSocket class encapsulates an OS socket.
211 class _NativeSocket extends NativeFieldWrapperClass1 { 212 class _NativeSocket extends NativeFieldWrapperClass1 {
212 // Bit flags used when communicating between the eventhandler and 213 // Bit flags used when communicating between the eventhandler and
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return _IOService.dispatch(_SOCKET_LIST_INTERFACES, [type._value]) 304 return _IOService.dispatch(_SOCKET_LIST_INTERFACES, [type._value])
304 .then((response) { 305 .then((response) {
305 if (isErrorResponse(response)) { 306 if (isErrorResponse(response)) {
306 throw createError(response, "Failed listing interfaces"); 307 throw createError(response, "Failed listing interfaces");
307 } else { 308 } else {
308 var list = new List<NetworkInterface>(); 309 var list = new List<NetworkInterface>();
309 var map = response.skip(1) 310 var map = response.skip(1)
310 .fold(new Map<String, List<InternetAddress>>(), (map, result) { 311 .fold(new Map<String, List<InternetAddress>>(), (map, result) {
311 var type = new InternetAddressType._from(result[0]); 312 var type = new InternetAddressType._from(result[0]);
312 var name = result[3]; 313 var name = result[3];
314 var index = result[4];
313 var address = new _InternetAddress( 315 var address = new _InternetAddress(
314 type, result[1], "", result[2]); 316 type, result[1], "", result[2]);
315 if (!includeLinkLocal && address.isLinkLocal) return map; 317 if (!includeLinkLocal && address.isLinkLocal) return map;
316 if (!includeLoopback && address.isLoopback) return map; 318 if (!includeLoopback && address.isLoopback) return map;
317 map.putIfAbsent(name, () => new List<InternetAddress>()); 319 map.putIfAbsent(
318 map[name].add(address); 320 name, () => new _NetworkInterface(name, index));
321 map[name].addresses.add(address);
319 return map; 322 return map;
320 }) 323 })
Anders Johnsen 2013/11/29 08:35:10 .values.toList();
Søren Gjesse 2013/11/29 10:01:20 Done.
321 .forEach((name, addresses) { 324 .forEach((name, interface) {
322 list.add(new _NetworkInterface(name, addresses)); 325 list.add(interface);
323 }); 326 });
324 return list; 327 return list;
325 } 328 }
326 }); 329 });
327 } 330 }
328 331
329 static Future<_NativeSocket> connect(host, int port) { 332 static Future<_NativeSocket> connect(host, int port) {
330 return new Future.value(host) 333 return new Future.value(host)
331 .then((host) { 334 .then((host) {
332 if (host is _InternetAddress) return host; 335 if (host is _InternetAddress) return host;
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 if (_detachReady != null) { 1275 if (_detachReady != null) {
1273 _detachReady.complete(null); 1276 _detachReady.complete(null);
1274 } else { 1277 } else {
1275 if (_raw != null) { 1278 if (_raw != null) {
1276 _raw.shutdown(SocketDirection.SEND); 1279 _raw.shutdown(SocketDirection.SEND);
1277 _disableWriteEvent(); 1280 _disableWriteEvent();
1278 } 1281 }
1279 } 1282 }
1280 } 1283 }
1281 } 1284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698