#include <socket_base.h>
Definition at line 41 of file socket_base.h.
◆ anonymous enum
Enumerator |
---|
TYPE_ANY | |
TYPE_IPV4 | |
TYPE_IPV6 | |
TYPE_UNIX | |
Definition at line 43 of file socket_base.h.
◆ anonymous enum
Enumerator |
---|
ADDRESS_LOOPBACK_IP_V4 | |
ADDRESS_LOOPBACK_IP_V6 | |
ADDRESS_ANY_IP_V4 | |
ADDRESS_ANY_IP_V6 | |
ADDRESS_FIRST | |
ADDRESS_LAST | |
Definition at line 50 of file socket_base.h.
◆ SocketAddress()
dart::bin::SocketAddress::SocketAddress |
( |
struct sockaddr * |
sa, |
|
|
bool |
unnamed_unix_socket = false |
|
) |
| |
|
explicit |
◆ ~SocketAddress()
dart::bin::SocketAddress::~SocketAddress |
( |
| ) |
|
|
inline |
◆ addr()
const RawAddr & dart::bin::SocketAddress::addr |
( |
| ) |
const |
|
inline |
◆ AreAddressesEqual()
bool dart::bin::SocketAddress::AreAddressesEqual |
( |
const RawAddr & |
a, |
|
|
const RawAddr & |
b |
|
) |
| |
|
static |
Definition at line 80 of file socket_base.cc.
80 {
81 if (
a.ss.ss_family !=
b.ss.ss_family) {
82 return false;
83 }
84 if (
a.ss.ss_family == AF_INET) {
85 return memcmp(&
a.in.sin_addr, &
b.in.sin_addr,
sizeof(
a.in.sin_addr)) == 0;
86 }
else if (
a.ss.ss_family == AF_INET6) {
87 return memcmp(&
a.in6.sin6_addr, &
b.in6.sin6_addr,
88 sizeof(
a.in6.sin6_addr)) == 0 &&
89 a.in6.sin6_scope_id ==
b.in6.sin6_scope_id;
90 }
else if (
a.ss.ss_family == AF_UNIX) {
91
92
93 int len =
sizeof(
a.un.sun_path);
94 for (
int i = 0;
i <
len;
i++) {
95 if (
a.un.sun_path[
i] !=
b.un.sun_path[
i])
return false;
96 if (
a.un.sun_path[
i] ==
'\0')
return true;
97 }
98 return true;
99 } else {
101 return false;
102 }
103}
◆ as_string()
const char * dart::bin::SocketAddress::as_string |
( |
| ) |
const |
|
inline |
◆ FromType()
int16_t dart::bin::SocketAddress::FromType |
( |
int |
type | ) |
|
|
static |
Definition at line 163 of file socket_base.cc.
163 {
165 return AF_UNSPEC;
166 }
168 return AF_INET;
169 }
171 return AF_UNIX;
172 }
174 return AF_INET6;
175}
◆ GetAddrLength()
intptr_t dart::bin::SocketAddress::GetAddrLength |
( |
const RawAddr & |
addr, |
|
|
bool |
unnamed_unix_socket = false |
|
) |
| |
|
static |
Definition at line 39 of file socket_base.cc.
40 {
42 (
addr.
ss.ss_family == AF_UNIX));
43 switch (
addr.
ss.ss_family) {
44 case AF_INET6:
45 return sizeof(struct sockaddr_in6);
46 case AF_INET:
47 return sizeof(struct sockaddr_in);
48 case AF_UNIX: {
49
50
51
52
53
54
55
56
57
58 intptr_t nulls = 0;
59 if (!unnamed_unix_socket &&
addr.
un.sun_path[0] ==
'\0') {
60 intptr_t
i =
sizeof(
addr.
un.sun_path) - 1;
61 while (
addr.
un.sun_path[
i] ==
'\0') {
62 nulls++;
64 }
65 }
66 return sizeof(struct sockaddr_un) - nulls;
67 }
68 default:
70 return 0;
71 }
72}
const RawAddr & addr() const
struct sockaddr_storage ss
◆ GetAddrPort()
intptr_t dart::bin::SocketAddress::GetAddrPort |
( |
const RawAddr & |
addr | ) |
|
|
static |
Definition at line 187 of file socket_base.cc.
187 {
188 if (
addr.
ss.ss_family == AF_INET) {
189 return ntohs(
addr.
in.sin_port);
190 }
else if (
addr.
ss.ss_family == AF_INET6) {
191 return ntohs(
addr.
in6.sin6_port);
192 }
else if (
addr.
ss.ss_family == AF_UNIX) {
193 return 0;
194 } else {
196 return -1;
197 }
198}
◆ GetAddrScope()
intptr_t dart::bin::SocketAddress::GetAddrScope |
( |
const RawAddr & |
addr | ) |
|
|
static |
Definition at line 237 of file socket_base.cc.
237 {
238 if (
addr.
addr.sa_family == AF_INET6) {
240 } else {
241 return 0;
242 }
243}
◆ GetInAddrLength()
intptr_t dart::bin::SocketAddress::GetInAddrLength |
( |
const RawAddr & |
addr | ) |
|
|
static |
Definition at line 74 of file socket_base.cc.
74 {
76 return (
addr.
ss.ss_family == AF_INET6) ?
sizeof(
struct in6_addr)
77 : sizeof(struct in_addr);
78}
◆ GetSockAddr()
Definition at line 105 of file socket_base.cc.
105 {
107 uint8_t*
data =
nullptr;
110 obj, &data_type,
reinterpret_cast<void**
>(&
data), &
len);
113 }
115 ((
len !=
sizeof(in_addr)) && (
len !=
sizeof(in6_addr)))) {
117 }
118 memset(
reinterpret_cast<void*
>(
addr), 0,
sizeof(RawAddr));
119 if (
len ==
sizeof(in_addr)) {
120 addr->
in.sin_family = AF_INET;
121 memmove(
reinterpret_cast<void*
>(&
addr->
in.sin_addr),
data,
len);
122 } else {
124 addr->
in6.sin6_family = AF_INET6;
125 memmove(
reinterpret_cast<void*
>(&
addr->
in6.sin6_addr),
data,
len);
126 }
128}
struct _Dart_Handle * Dart_Handle
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
static int8_t data[kExtLength]
◆ GetType()
int dart::bin::SocketAddress::GetType |
( |
| ) |
|
Definition at line 25 of file socket_base.cc.
25 {
26 switch (addr_.
ss.ss_family) {
27 case AF_INET6:
29 case AF_INET:
31 case AF_UNIX:
33 default:
36 }
37}
◆ GetUnixDomainSockAddr()
Definition at line 130 of file socket_base.cc.
132 {
133#if defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)
134 NamespaceScope ns(namespc,
path);
136 bool is_abstract = (
path[0] ==
'@');
137 if (is_abstract) {
138
139
140
141
143 }
144#endif
145 if (
sizeof(
path) >
sizeof(
addr->
un.sun_path)) {
146 OSError os_error(-1,
147 "The length of path exceeds the limit. "
148 "Check out man 7 unix page",
151 }
152 addr->
un.sun_family = AF_UNIX;
154#if defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)
155
156 if (is_abstract) {
157 addr->
un.sun_path[0] =
'\0';
158 }
159#endif
161}
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static Dart_Handle NewDartOSError()
DART_EXPORT Dart_Handle Dart_Null()
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
◆ SetAddrPort()
void dart::bin::SocketAddress::SetAddrPort |
( |
RawAddr * |
addr, |
|
|
intptr_t |
port |
|
) |
| |
|
static |
Definition at line 177 of file socket_base.cc.
177 {
178 if (
addr->
ss.ss_family == AF_INET) {
180 }
else if (
addr->
ss.ss_family == AF_INET6) {
182 } else {
184 }
185}
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
◆ SetAddrScope()
void dart::bin::SocketAddress::SetAddrScope |
( |
RawAddr * |
addr, |
|
|
intptr_t |
scope_id |
|
) |
| |
|
static |
◆ ToCObject()
Definition at line 220 of file socket_base.cc.
220 {
222 const void* in_addr;
223 if (
addr.
addr.sa_family == AF_INET6) {
224 in_addr =
reinterpret_cast<const void*
>(&
addr.
in6.sin6_addr);
225 } else {
226 in_addr =
reinterpret_cast<const void*
>(&
addr.
in.sin_addr);
227 }
228 CObjectUint8Array*
data =
231}
static Dart_CObject * NewUint8Array(const void *data, intptr_t length)
static intptr_t GetInAddrLength(const RawAddr &addr)
◆ ToTypedData()
Definition at line 200 of file socket_base.cc.
200 {
205 }
207 if (
addr.
addr.sa_family == AF_INET6) {
210 } else {
213 }
216 }
218}
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, intptr_t offset, const uint8_t *native_array, intptr_t length)
The documentation for this class was generated from the following files: