OLD | NEW |
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 #ifndef BIN_SOCKET_H_ | 5 #ifndef BIN_SOCKET_H_ |
6 #define BIN_SOCKET_H_ | 6 #define BIN_SOCKET_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } else { | 138 } else { |
139 return ntohs(addr.in6.sin6_port); | 139 return ntohs(addr.in6.sin6_port); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 static Dart_Handle ToTypedData(const RawAddr& addr) { | 143 static Dart_Handle ToTypedData(const RawAddr& addr) { |
144 int len = GetInAddrLength(addr); | 144 int len = GetInAddrLength(addr); |
145 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, len); | 145 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, len); |
146 if (Dart_IsError(result)) Dart_PropagateError(result); | 146 if (Dart_IsError(result)) Dart_PropagateError(result); |
147 Dart_Handle err; | 147 Dart_Handle err; |
148 RawAddr& raw = const_cast<RawAddr&>(addr); | |
149 if (addr.addr.sa_family == AF_INET6) { | 148 if (addr.addr.sa_family == AF_INET6) { |
150 err = Dart_ListSetAsBytes( | 149 err = Dart_ListSetAsBytes( |
151 result, 0, reinterpret_cast<uint8_t*>(&raw.in6.sin6_addr), len); | 150 result, 0, |
| 151 reinterpret_cast<const uint8_t*>(&addr.in6.sin6_addr), len); |
152 } else { | 152 } else { |
153 err = Dart_ListSetAsBytes( | 153 err = Dart_ListSetAsBytes( |
154 result, 0, reinterpret_cast<uint8_t*>(&raw.in.sin_addr), len); | 154 result, 0, reinterpret_cast<const uint8_t*>(&addr.in.sin_addr), len); |
155 } | 155 } |
156 if (Dart_IsError(err)) Dart_PropagateError(err); | 156 if (Dart_IsError(err)) Dart_PropagateError(err); |
157 return result; | 157 return result; |
158 } | 158 } |
159 | 159 |
160 static CObjectUint8Array* ToCObject(const RawAddr& addr) { | 160 static CObjectUint8Array* ToCObject(const RawAddr& addr) { |
161 int in_addr_len = SocketAddress::GetInAddrLength(addr); | 161 int in_addr_len = SocketAddress::GetInAddrLength(addr); |
162 void* in_addr; | 162 const void* in_addr; |
163 RawAddr& raw = const_cast<RawAddr&>(addr); | |
164 CObjectUint8Array* data = | 163 CObjectUint8Array* data = |
165 new CObjectUint8Array(CObject::NewUint8Array(in_addr_len)); | 164 new CObjectUint8Array(CObject::NewUint8Array(in_addr_len)); |
166 if (addr.addr.sa_family == AF_INET6) { | 165 if (addr.addr.sa_family == AF_INET6) { |
167 in_addr = reinterpret_cast<void*>(&raw.in6.sin6_addr); | 166 in_addr = reinterpret_cast<const void*>(&addr.in6.sin6_addr); |
168 } else { | 167 } else { |
169 in_addr = reinterpret_cast<void*>(&raw.in.sin_addr); | 168 in_addr = reinterpret_cast<const void*>(&addr.in.sin_addr); |
170 } | 169 } |
171 memmove(data->Buffer(), in_addr, in_addr_len); | 170 memmove(data->Buffer(), in_addr, in_addr_len); |
172 return data; | 171 return data; |
173 } | 172 } |
174 | 173 |
175 private: | 174 private: |
176 char as_string_[INET6_ADDRSTRLEN]; | 175 char as_string_[INET6_ADDRSTRLEN]; |
177 RawAddr addr_; | 176 RawAddr addr_; |
178 | 177 |
179 DISALLOW_COPY_AND_ASSIGN(SocketAddress); | 178 DISALLOW_COPY_AND_ASSIGN(SocketAddress); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 415 |
417 private: | 416 private: |
418 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); | 417 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); |
419 }; | 418 }; |
420 | 419 |
421 | 420 |
422 } // namespace bin | 421 } // namespace bin |
423 } // namespace dart | 422 } // namespace dart |
424 | 423 |
425 #endif // BIN_SOCKET_H_ | 424 #endif // BIN_SOCKET_H_ |
OLD | NEW |