Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #if !defined(DART_IO_DISABLED) | |
| 6 | |
| 7 #include "bin/socket_base.h" | |
| 8 #include "bin/socket.h" | |
|
zra
2017/04/03 03:40:23
Is this still needed? If so, it should be sorted d
bkonyi
2017/04/03 16:09:57
Nope, just an old include. Removed.
| |
| 9 | |
| 10 #include "bin/dartutils.h" | |
| 11 #include "bin/io_buffer.h" | |
| 12 #include "bin/isolate_data.h" | |
| 13 #include "bin/lockers.h" | |
| 14 #include "bin/thread.h" | |
| 15 #include "bin/utils.h" | |
| 16 | |
| 17 #include "include/dart_api.h" | |
| 18 | |
| 19 #include "platform/globals.h" | |
| 20 #include "platform/utils.h" | |
| 21 | |
| 22 namespace dart { | |
| 23 namespace bin { | |
| 24 | |
| 25 void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) { | |
| 26 const char* address = | |
| 27 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | |
| 28 ASSERT(address != NULL); | |
| 29 RawAddr raw; | |
| 30 memset(&raw, 0, sizeof(raw)); | |
| 31 int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4 | |
| 32 : SocketAddress::TYPE_IPV6; | |
| 33 if (type == SocketAddress::TYPE_IPV4) { | |
| 34 raw.addr.sa_family = AF_INET; | |
| 35 } else { | |
| 36 raw.addr.sa_family = AF_INET6; | |
| 37 } | |
| 38 bool ok = SocketBase::ParseAddress(type, address, &raw); | |
| 39 if (!ok) { | |
| 40 Dart_SetReturnValue(args, Dart_Null()); | |
| 41 } else { | |
| 42 Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw)); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 | |
| 47 void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) { | |
| 48 Dart_SetReturnValue(args, | |
| 49 Dart_NewBoolean(SocketBase::ListInterfacesSupported())); | |
| 50 } | |
| 51 | |
| 52 | |
| 53 void FUNCTION_NAME(SocketBase_IsBindError)(Dart_NativeArguments args) { | |
| 54 intptr_t error_number = | |
| 55 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); | |
| 56 bool is_bind_error = SocketBase::IsBindError(error_number); | |
| 57 Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False()); | |
| 58 } | |
| 59 | |
| 60 } // namespace bin | |
| 61 } // namespace dart | |
| 62 | |
| 63 #endif // !defined(DART_IO_DISABLED) | |
| OLD | NEW |