Chromium Code Reviews| 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 "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 | 58 |
| 59 int GetType() { | 59 int GetType() { |
| 60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6; | 60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6; |
| 61 return TYPE_IPV4; | 61 return TYPE_IPV4; |
| 62 } | 62 } |
| 63 | 63 |
| 64 const char* as_string() const { return as_string_; } | 64 const char* as_string() const { return as_string_; } |
| 65 const RawAddr& addr() const { return addr_; } | 65 const RawAddr& addr() const { return addr_; } |
| 66 | 66 |
| 67 static intptr_t GetAddrLength(const RawAddr* addr) { | 67 static intptr_t GetAddrLength(const RawAddr* addr) { |
| 68 ASSERT(addr->ss.ss_family == AF_INET || addr->ss.ss_family == AF_INET6); | |
| 68 return addr->ss.ss_family == AF_INET6 ? | 69 return addr->ss.ss_family == AF_INET6 ? |
| 69 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in); | 70 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in); |
| 70 } | 71 } |
| 71 | 72 |
| 72 static int16_t FromType(int type) { | 73 static int16_t FromType(int type) { |
| 73 if (type == TYPE_ANY) return AF_UNSPEC; | 74 if (type == TYPE_ANY) return AF_UNSPEC; |
| 74 if (type == TYPE_IPV4) return AF_INET; | 75 if (type == TYPE_IPV4) return AF_INET; |
| 75 ASSERT(type == TYPE_IPV6 && "Invalid type"); | 76 ASSERT(type == TYPE_IPV6 && "Invalid type"); |
| 76 return AF_INET6; | 77 return AF_INET6; |
| 77 } | 78 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 enum SocketRequest { | 160 enum SocketRequest { |
| 160 kLookupRequest = 0, | 161 kLookupRequest = 0, |
| 161 kListInterfacesRequest = 1, | 162 kListInterfacesRequest = 1, |
| 162 kReverseLookupRequest = 2, | 163 kReverseLookupRequest = 2, |
| 163 }; | 164 }; |
| 164 | 165 |
| 165 static bool Initialize(); | 166 static bool Initialize(); |
| 166 static intptr_t Available(intptr_t fd); | 167 static intptr_t Available(intptr_t fd); |
| 167 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes); | 168 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes); |
| 168 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes); | 169 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes); |
| 170 static int SendTo(intptr_t fd, const void* buffer, intptr_t num_bytes, | |
|
Anders Johnsen
2013/11/29 12:36:54
All on one line or each on its own?
Søren Gjesse
2013/12/12 11:38:46
Done.
| |
| 171 RawAddr addr); | |
| 172 static int RecvFrom(intptr_t fd, void* buffer, intptr_t num_bytes, | |
|
Anders Johnsen
2013/11/29 12:36:54
Ditto
Søren Gjesse
2013/12/12 11:38:46
Done.
| |
| 173 RawAddr* addr); | |
| 169 static intptr_t Create(RawAddr addr); | 174 static intptr_t Create(RawAddr addr); |
| 170 static intptr_t Connect(intptr_t fd, RawAddr addr, const intptr_t port); | 175 static intptr_t Connect(intptr_t fd, RawAddr addr, const intptr_t port); |
| 171 static intptr_t CreateConnect(RawAddr addr, | 176 static intptr_t CreateConnect(RawAddr addr, |
| 172 const intptr_t port); | 177 const intptr_t port); |
| 178 static intptr_t CreateBindDatagram( | |
| 179 RawAddr* addr, intptr_t port, bool reuseAddress); | |
| 173 static intptr_t GetPort(intptr_t fd); | 180 static intptr_t GetPort(intptr_t fd); |
| 174 static SocketAddress* GetRemotePeer(intptr_t fd, intptr_t* port); | 181 static SocketAddress* GetRemotePeer(intptr_t fd, intptr_t* port); |
| 175 static void GetError(intptr_t fd, OSError* os_error); | 182 static void GetError(intptr_t fd, OSError* os_error); |
| 176 static int GetType(intptr_t fd); | 183 static int GetType(intptr_t fd); |
| 177 static intptr_t GetStdioHandle(intptr_t num); | 184 static intptr_t GetStdioHandle(intptr_t num); |
| 178 static void Close(intptr_t fd); | 185 static void Close(intptr_t fd); |
| 179 static bool SetNonBlocking(intptr_t fd); | 186 static bool SetNonBlocking(intptr_t fd); |
| 180 static bool SetBlocking(intptr_t fd); | 187 static bool SetBlocking(intptr_t fd); |
| 188 static bool GetNoDelay(intptr_t fd, bool* enabled); | |
| 181 static bool SetNoDelay(intptr_t fd, bool enabled); | 189 static bool SetNoDelay(intptr_t fd, bool enabled); |
| 190 static bool GetMulticastLoop(intptr_t fd, intptr_t protocol, bool* enabled); | |
| 191 static bool SetMulticastLoop(intptr_t fd, intptr_t protocol, bool enabled); | |
| 192 static bool GetMulticastHops(intptr_t fd, intptr_t protocol, int* value); | |
| 193 static bool SetMulticastHops(intptr_t fd, intptr_t protocol, int value); | |
| 194 static bool GetBroadcast(intptr_t fd, bool* value); | |
| 195 static bool SetBroadcast(intptr_t fd, bool value); | |
| 196 static bool JoinMulticast(intptr_t fd, RawAddr* addr, int interfaceIndex); | |
| 197 static bool LeaveMulticast(intptr_t fd, RawAddr* addr, int interfaceIndex); | |
| 182 | 198 |
| 183 // Perform a hostname lookup. Returns a AddressList of SocketAddress's. | 199 // Perform a hostname lookup. Returns a AddressList of SocketAddress's. |
| 184 static AddressList<SocketAddress>* LookupAddress(const char* host, | 200 static AddressList<SocketAddress>* LookupAddress(const char* host, |
| 185 int type, | 201 int type, |
| 186 OSError** os_error); | 202 OSError** os_error); |
| 203 | |
| 187 static bool ReverseLookup(RawAddr addr, | 204 static bool ReverseLookup(RawAddr addr, |
| 188 char* host, | 205 char* host, |
| 189 intptr_t host_len, | 206 intptr_t host_len, |
| 190 OSError** os_error); | 207 OSError** os_error); |
| 191 | 208 |
| 192 static bool ParseAddress(int type, const char* address, RawAddr* addr); | 209 static bool ParseAddress(int type, const char* address, RawAddr* addr); |
| 210 static bool FormatNumericAddress(RawAddr* addr, char* address, int len); | |
| 193 | 211 |
| 194 // List interfaces. Returns a AddressList of InterfaceSocketAddress's. | 212 // List interfaces. Returns a AddressList of InterfaceSocketAddress's. |
| 195 static AddressList<InterfaceSocketAddress>* ListInterfaces( | 213 static AddressList<InterfaceSocketAddress>* ListInterfaces( |
| 196 int type, | 214 int type, |
| 197 OSError** os_error); | 215 OSError** os_error); |
| 198 | 216 |
| 199 static CObject* LookupRequest(const CObjectArray& request); | 217 static CObject* LookupRequest(const CObjectArray& request); |
| 200 static CObject* ListInterfacesRequest(const CObjectArray& request); | 218 static CObject* ListInterfacesRequest(const CObjectArray& request); |
| 201 static CObject* ReverseLookupRequest(const CObjectArray& request); | 219 static CObject* ReverseLookupRequest(const CObjectArray& request); |
| 202 | 220 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 252 |
| 235 private: | 253 private: |
| 236 DISALLOW_ALLOCATION(); | 254 DISALLOW_ALLOCATION(); |
| 237 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); | 255 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); |
| 238 }; | 256 }; |
| 239 | 257 |
| 240 } // namespace bin | 258 } // namespace bin |
| 241 } // namespace dart | 259 } // namespace dart |
| 242 | 260 |
| 243 #endif // BIN_SOCKET_H_ | 261 #endif // BIN_SOCKET_H_ |
| OLD | NEW |