6#if defined(DART_HOST_OS_FUCHSIA)
13#include <netinet/tcp.h>
32#if defined(SOCKET_LOG_INFO) || defined(SOCKET_LOG_ERROR)
33#define LOG_ERR(msg, ...) \
36 Syslog::PrintErr("Dart Socket ERROR: %s:%d: " msg, __FILE__, __LINE__, \
40#if defined(SOCKET_LOG_INFO)
41#define LOG_INFO(msg, ...) \
42 Syslog::Print("Dart Socket INFO: %s:%d: " msg, __FILE__, __LINE__, \
45#define LOG_INFO(msg, ...)
48#define LOG_ERR(msg, ...)
49#define LOG_INFO(msg, ...)
57 if (unnamed_unix_socket) {
58 FATAL(
"Fuchsia does not support unix domain sockets.");
60 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
62 as_string_, INET6_ADDRSTRLEN)) {
65 socklen_t salen =
GetAddrLength(*
reinterpret_cast<RawAddr*
>(sa));
66 memmove(
reinterpret_cast<void*
>(&addr_), sa, salen);
78 LOG_INFO(
"SocketBase::FormatNumericAddress: calling getnameinfo\n");
80 nullptr, 0, NI_NUMERICHOST) == 0));
84 return error_number == EADDRINUSE || error_number == EADDRNOTAVAIL ||
85 error_number == EINVAL;
89 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
90 return handle->AvailableBytes();
97 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
99 LOG_INFO(
"SocketBase::Read: calling read(%ld, %p, %ld)\n", handle->fd(),
101 intptr_t read_bytes = handle->Read(
buffer, num_bytes);
102 ASSERT(EAGAIN == EWOULDBLOCK);
103 if ((sync ==
kAsync) && (read_bytes == -1) && (errno == EWOULDBLOCK)) {
107 }
else if (read_bytes == -1) {
108 LOG_ERR(
"SocketBase::Read: read(%ld, %p, %ld) failed\n", handle->fd(),
111 LOG_INFO(
"SocketBase::Read: read(%ld, %p, %ld) succeeded\n", handle->fd(),
132 int64_t* p_buffer_num_bytes,
133 SocketControlMessage** p_messages,
135 OSError* p_oserror) {
142 intptr_t num_bytes) {
146intptr_t SocketBase::WriteImpl(intptr_t fd,
150 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
151 ASSERT(handle->fd() >= 0);
152 LOG_INFO(
"SocketBase::WriteImpl: calling write(%ld, %p, %ld)\n", handle->fd(),
154 intptr_t written_bytes = handle->Write(
buffer, num_bytes);
155 if (written_bytes == -1 && !(sync ==
kAsync && errno == EWOULDBLOCK)) {
156 LOG_ERR(
"SocketBase::WriteImpl: write(%ld, %p, %ld) failed\n", handle->fd(),
159 LOG_INFO(
"SocketBase::WriteImpl: write(%ld, %p, %ld) succeeded\n",
160 handle->fd(),
buffer, num_bytes);
162 return written_bytes;
177 SocketControlMessage* messages,
178 intptr_t num_messages,
180 OSError* p_oserror) {
189 socklen_t
size =
sizeof(raw);
197 new (p_sa) SocketAddress(&raw.addr,
198 size ==
sizeof(sa_family_t));
203 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
204 ASSERT(handle->fd() >= 0);
206 socklen_t
size =
sizeof(raw);
207 LOG_INFO(
"SocketBase::GetPort: calling getsockname(%ld)\n", handle->fd());
215 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
216 ASSERT(handle->fd() >= 0);
218 socklen_t
size =
sizeof(raw);
223 return new SocketAddress(&raw.addr);
227 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
228 ASSERT(handle->fd() >= 0);
229 int len =
sizeof(errno);
232 reinterpret_cast<socklen_t*
>(&
len)));
248 OSError** os_error) {
250 struct addrinfo hints;
251 memset(&hints, 0,
sizeof(hints));
253 hints.ai_socktype = SOCK_STREAM;
254 hints.ai_flags = AI_ADDRCONFIG;
255 hints.ai_protocol = IPPROTO_TCP;
256 struct addrinfo*
info =
nullptr;
257 LOG_INFO(
"SocketBase::LookupAddress: calling getaddrinfo\n");
263 LOG_INFO(
"SocketBase::LookupAddress: calling getaddrinfo again\n");
266 ASSERT(*os_error ==
nullptr);
273 for (
struct addrinfo* c =
info; c !=
nullptr; c = c->ai_next) {
274 if ((c->ai_family == AF_INET) || (c->ai_family == AF_INET6)) {
279 AddressList<SocketAddress>* addresses =
new AddressList<SocketAddress>(
count);
280 for (
struct addrinfo* c =
info; c !=
nullptr; c = c->ai_next) {
281 if ((c->ai_family == AF_INET) || (c->ai_family == AF_INET6)) {
282 addresses->SetAt(
i,
new SocketAddress(c->ai_addr));
293 OSError** os_error) {
311 if (
addr->addr.sa_family == AF_INET) {
312 return inet_ntop(AF_INET, &
addr->in.sin_addr, str, INET_ADDRSTRLEN) !=
316 return inet_ntop(AF_INET6, &
addr->in6.sin6_addr, str, INET6_ADDRSTRLEN) !=
321static bool ShouldIncludeIfaAddrs(
struct ifaddrs* ifa,
int lookup_family) {
322 if (ifa->ifa_addr ==
nullptr) {
326 int family = ifa->ifa_addr->sa_family;
327 return ((lookup_family == family) ||
328 (((lookup_family == AF_UNSPEC) &&
329 ((family == AF_INET) || (family == AF_INET6)))));
334 OSError** os_error) {
335 struct ifaddrs* ifaddr;
339 ASSERT(*os_error ==
nullptr);
348 for (
struct ifaddrs* ifa = ifaddr; ifa !=
nullptr; ifa = ifa->ifa_next) {
349 if (ShouldIncludeIfaAddrs(ifa, lookup_family)) {
354 AddressList<InterfaceSocketAddress>* addresses =
355 new AddressList<InterfaceSocketAddress>(
count);
357 for (
struct ifaddrs* ifa = ifaddr; ifa !=
nullptr; ifa = ifa->ifa_next) {
358 if (ShouldIncludeIfaAddrs(ifa, lookup_family)) {
361 i,
new InterfaceSocketAddress(ifa->ifa_addr, ifa_name,
362 if_nametoindex(ifa->ifa_name)));
371 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
372 ASSERT(handle->fd() >= 0);
382 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
383 int on = enabled ? 1 : 0;
385 reinterpret_cast<char*
>(&on),
428 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
438 IOHandle* handle =
reinterpret_cast<IOHandle*
>(fd);
439 socklen_t optlen =
static_cast<socklen_t
>(*length);
442 *
length =
static_cast<unsigned int>(optlen);
449 int interfaceIndex) {
457 int interfaceIndex) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static char * ScopedCopyCString(const char *str)
static int16_t FromType(int type)
static intptr_t GetAddrLength(const RawAddr &addr, bool unnamed_unix_socket=false)
SocketAddress(struct sockaddr *sa, bool unnamed_unix_socket=false)
static intptr_t GetAddrPort(const RawAddr &addr)
static bool LeaveMulticast(intptr_t fd, const RawAddr &addr, const RawAddr &interface, int interfaceIndex)
static bool AvailableDatagram(intptr_t fd, void *buffer, intptr_t num_bytes)
static int GetType(intptr_t fd)
static AddressList< SocketAddress > * LookupAddress(const char *host, int type, OSError **os_error)
static bool SetMulticastHops(intptr_t fd, intptr_t protocol, int value)
static intptr_t GetStdioHandle(intptr_t num)
static intptr_t ReceiveMessage(intptr_t fd, void *buffer, int64_t *p_buffer_num_bytes, SocketControlMessage **p_messages, SocketOpKind sync, OSError *p_oserror)
static bool SetOption(intptr_t fd, int level, int option, const char *data, int length)
static SocketAddress * GetRemotePeer(intptr_t fd, intptr_t *port)
static bool FormatNumericAddress(const RawAddr &addr, char *address, int len)
static bool SetNoDelay(intptr_t fd, bool enabled)
static bool GetSocketName(intptr_t fd, SocketAddress *p_sa)
static bool ParseAddress(int type, const char *address, RawAddr *addr)
static intptr_t Available(intptr_t fd)
static void Close(intptr_t fd)
static void GetError(intptr_t fd, OSError *os_error)
static intptr_t RecvFrom(intptr_t fd, void *buffer, intptr_t num_bytes, RawAddr *addr, SocketOpKind sync)
static bool IsBindError(intptr_t error_number)
static intptr_t Read(intptr_t fd, void *buffer, intptr_t num_bytes, SocketOpKind sync)
static bool SetBroadcast(intptr_t fd, bool value)
static bool GetNoDelay(intptr_t fd, bool *enabled)
static bool SetMulticastLoop(intptr_t fd, intptr_t protocol, bool enabled)
static bool GetOption(intptr_t fd, int level, int option, char *data, unsigned int *length)
static bool ReverseLookup(const RawAddr &addr, char *host, intptr_t host_len, OSError **os_error)
static bool RawAddrToString(RawAddr *addr, char *str)
static intptr_t SendTo(intptr_t fd, const void *buffer, intptr_t num_bytes, const RawAddr &addr, SocketOpKind sync)
static bool GetMulticastHops(intptr_t fd, intptr_t protocol, int *value)
static bool GetMulticastLoop(intptr_t fd, intptr_t protocol, bool *enabled)
static bool JoinMulticast(intptr_t fd, const RawAddr &addr, const RawAddr &interface, int interfaceIndex)
static intptr_t SendMessage(intptr_t fd, void *buffer, size_t buffer_num_bytes, SocketControlMessage *messages, intptr_t num_messages, SocketOpKind sync, OSError *p_oserror)
static AddressList< InterfaceSocketAddress > * ListInterfaces(int type, OSError **os_error)
static bool GetBroadcast(intptr_t fd, bool *value)
static intptr_t GetPort(intptr_t fd)
bool is_file_descriptors_control_message()
static int8_t data[kExtLength]
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service host
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
#define NO_RETRY_EXPECTED(expression)
#define VOID_NO_RETRY_EXPECTED(expression)