Chromium Code Reviews| Index: runtime/bin/socket_base.cc |
| diff --git a/runtime/bin/socket_base.cc b/runtime/bin/socket_base.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7b9f71d9e67b6d8da4e7c258289a3c3a21fab373 |
| --- /dev/null |
| +++ b/runtime/bin/socket_base.cc |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#if !defined(DART_IO_DISABLED) |
| + |
| +#include "bin/socket_base.h" |
| +#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.
|
| + |
| +#include "bin/dartutils.h" |
| +#include "bin/io_buffer.h" |
| +#include "bin/isolate_data.h" |
| +#include "bin/lockers.h" |
| +#include "bin/thread.h" |
| +#include "bin/utils.h" |
| + |
| +#include "include/dart_api.h" |
| + |
| +#include "platform/globals.h" |
| +#include "platform/utils.h" |
| + |
| +namespace dart { |
| +namespace bin { |
| + |
| +void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) { |
| + const char* address = |
| + DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| + ASSERT(address != NULL); |
| + RawAddr raw; |
| + memset(&raw, 0, sizeof(raw)); |
| + int type = strchr(address, ':') == NULL ? SocketAddress::TYPE_IPV4 |
| + : SocketAddress::TYPE_IPV6; |
| + if (type == SocketAddress::TYPE_IPV4) { |
| + raw.addr.sa_family = AF_INET; |
| + } else { |
| + raw.addr.sa_family = AF_INET6; |
| + } |
| + bool ok = SocketBase::ParseAddress(type, address, &raw); |
| + if (!ok) { |
| + Dart_SetReturnValue(args, Dart_Null()); |
| + } else { |
| + Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw)); |
| + } |
| +} |
| + |
| + |
| +void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) { |
| + Dart_SetReturnValue(args, |
| + Dart_NewBoolean(SocketBase::ListInterfacesSupported())); |
| +} |
| + |
| + |
| +void FUNCTION_NAME(SocketBase_IsBindError)(Dart_NativeArguments args) { |
| + intptr_t error_number = |
| + DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); |
| + bool is_bind_error = SocketBase::IsBindError(error_number); |
| + Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False()); |
| +} |
| + |
| +} // namespace bin |
| +} // namespace dart |
| + |
| +#endif // !defined(DART_IO_DISABLED) |