| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/ossocket.h" | 5 #include "nacl_io/ossocket.h" |
| 6 #ifdef PROVIDES_SOCKET_API | 6 #ifdef PROVIDES_SOCKET_API |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/fcntl.h> | 10 #include <sys/fcntl.h> |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 | 198 |
| 199 Error MountNodeSocket::Listen(int backlog) { | 199 Error MountNodeSocket::Listen(int backlog) { |
| 200 return EOPNOTSUPP; | 200 return EOPNOTSUPP; |
| 201 } | 201 } |
| 202 | 202 |
| 203 Error MountNodeSocket::GetSockOpt(int lvl, | 203 Error MountNodeSocket::GetSockOpt(int lvl, |
| 204 int optname, | 204 int optname, |
| 205 void* optval, | 205 void* optval, |
| 206 socklen_t* len) { | 206 socklen_t* len) { |
| 207 return EINVAL; | 207 if (lvl != SOL_SOCKET) |
| 208 return ENOPROTOOPT; |
| 209 |
| 210 switch (optname) { |
| 211 case SO_ERROR: { |
| 212 int copy_bytes = std::min(sizeof(int), *len); |
| 213 memcpy(optval, &last_errno_, copy_bytes); |
| 214 *len = sizeof(int); |
| 215 last_errno_ = 0; |
| 216 return 0; |
| 217 } |
| 218 } |
| 219 |
| 220 return ENOPROTOOPT; |
| 208 } | 221 } |
| 209 | 222 |
| 210 Error MountNodeSocket::SetSockOpt(int lvl, | 223 Error MountNodeSocket::SetSockOpt(int lvl, |
| 211 int optname, | 224 int optname, |
| 212 const void* optval, | 225 const void* optval, |
| 213 socklen_t len) { | 226 socklen_t len) { |
| 214 return EINVAL; | 227 return ENOPROTOOPT; |
| 215 } | 228 } |
| 216 | 229 |
| 217 Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) { | 230 Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) { |
| 218 return EINVAL; | 231 return EINVAL; |
| 219 } | 232 } |
| 220 | 233 |
| 221 | 234 |
| 222 Error MountNodeSocket::Recv(void* buf, size_t len, int flags, int* out_len) { | 235 Error MountNodeSocket::Recv(void* buf, size_t len, int flags, int* out_len) { |
| 223 return RecvFrom(buf, len, flags, NULL, 0, out_len); | 236 return RecvFrom(buf, len, flags, NULL, 0, out_len); |
| 224 } | 237 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (local_addr_ != 0) { | 378 if (local_addr_ != 0) { |
| 366 *len = ResourceToSockAddr(local_addr_, *len, addr); | 379 *len = ResourceToSockAddr(local_addr_, *len, addr); |
| 367 return 0; | 380 return 0; |
| 368 } | 381 } |
| 369 | 382 |
| 370 return ENOTCONN; | 383 return ENOTCONN; |
| 371 } | 384 } |
| 372 | 385 |
| 373 } // namespace nacl_io | 386 } // namespace nacl_io |
| 374 | 387 |
| 375 #endif // PROVIDES_SOCKET_API | 388 #endif // PROVIDES_SOCKET_API |
| OLD | NEW |