| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/kernel_proxy.h" | 5 #include "nacl_io/kernel_proxy.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <limits.h> | 10 #include <limits.h> |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 } | 1007 } |
| 1008 } | 1008 } |
| 1009 } | 1009 } |
| 1010 } | 1010 } |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 return event_cnt; | 1013 return event_cnt; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 | 1016 |
| 1017 | |
| 1018 // Socket Functions | 1017 // Socket Functions |
| 1019 int KernelProxy::accept(int fd, struct sockaddr* addr, socklen_t* len) { | 1018 int KernelProxy::accept(int fd, struct sockaddr* addr, socklen_t* len) { |
| 1020 if (NULL == addr || NULL == len) { | 1019 if (NULL == addr || NULL == len) { |
| 1021 errno = EFAULT; | 1020 errno = EFAULT; |
| 1022 return -1; | 1021 return -1; |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 ScopedKernelHandle handle; | 1024 ScopedKernelHandle handle; |
| 1026 if (AcquireSocketHandle(fd, &handle) == -1) | 1025 if (AcquireSocketHandle(fd, &handle) == -1) |
| 1027 return -1; | 1026 return -1; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 Error err = handle->socket_node()->GetSockName(addr, len); | 1103 Error err = handle->socket_node()->GetSockName(addr, len); |
| 1105 if (err != 0) { | 1104 if (err != 0) { |
| 1106 errno = err; | 1105 errno = err; |
| 1107 return -1; | 1106 return -1; |
| 1108 } | 1107 } |
| 1109 | 1108 |
| 1110 return 0; | 1109 return 0; |
| 1111 } | 1110 } |
| 1112 | 1111 |
| 1113 int KernelProxy::getsockopt(int fd, | 1112 int KernelProxy::getsockopt(int fd, |
| 1114 int lvl, | 1113 int lvl, |
| 1115 int optname, | 1114 int optname, |
| 1116 void* optval, | 1115 void* optval, |
| 1117 socklen_t* len) { | 1116 socklen_t* len) { |
| 1118 if (NULL == optval || NULL == len) { | 1117 if (NULL == optval || NULL == len) { |
| 1119 errno = EFAULT; | 1118 errno = EFAULT; |
| 1120 return -1; | 1119 return -1; |
| 1121 } | 1120 } |
| 1122 | 1121 |
| 1123 ScopedKernelHandle handle; | 1122 ScopedKernelHandle handle; |
| 1124 if (AcquireSocketHandle(fd, &handle) == -1) | 1123 if (AcquireSocketHandle(fd, &handle) == -1) |
| 1125 return -1; | 1124 return -1; |
| 1126 | 1125 |
| 1127 errno = EINVAL; | 1126 Error err = handle->socket_node()->GetSockOpt(lvl, optname, optval, len); |
| 1128 return -1; | 1127 if (err != 0) { |
| 1128 errno = err; |
| 1129 return -1; |
| 1130 } |
| 1131 |
| 1132 return 0; |
| 1129 } | 1133 } |
| 1130 | 1134 |
| 1131 int KernelProxy::listen(int fd, int backlog) { | 1135 int KernelProxy::listen(int fd, int backlog) { |
| 1132 ScopedKernelHandle handle; | 1136 ScopedKernelHandle handle; |
| 1133 if (AcquireSocketHandle(fd, &handle) == -1) | 1137 if (AcquireSocketHandle(fd, &handle) == -1) |
| 1134 return -1; | 1138 return -1; |
| 1135 | 1139 |
| 1136 errno = EOPNOTSUPP; | 1140 errno = EOPNOTSUPP; |
| 1137 return -1; | 1141 return -1; |
| 1138 } | 1142 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 socklen_t len) { | 1286 socklen_t len) { |
| 1283 if (NULL == optval) { | 1287 if (NULL == optval) { |
| 1284 errno = EFAULT; | 1288 errno = EFAULT; |
| 1285 return -1; | 1289 return -1; |
| 1286 } | 1290 } |
| 1287 | 1291 |
| 1288 ScopedKernelHandle handle; | 1292 ScopedKernelHandle handle; |
| 1289 if (AcquireSocketHandle(fd, &handle) == -1) | 1293 if (AcquireSocketHandle(fd, &handle) == -1) |
| 1290 return -1; | 1294 return -1; |
| 1291 | 1295 |
| 1292 errno = EINVAL; | 1296 Error err = handle->socket_node()->SetSockOpt(lvl, optname, optval, len); |
| 1293 return -1; | 1297 if (err != 0) { |
| 1298 errno = err; |
| 1299 return -1; |
| 1300 } |
| 1301 |
| 1302 return 0; |
| 1294 } | 1303 } |
| 1295 | 1304 |
| 1296 int KernelProxy::shutdown(int fd, int how) { | 1305 int KernelProxy::shutdown(int fd, int how) { |
| 1297 ScopedKernelHandle handle; | 1306 ScopedKernelHandle handle; |
| 1298 if (AcquireSocketHandle(fd, &handle) == -1) | 1307 if (AcquireSocketHandle(fd, &handle) == -1) |
| 1299 return -1; | 1308 return -1; |
| 1300 | 1309 |
| 1301 Error err = handle->socket_node()->Shutdown(how); | 1310 Error err = handle->socket_node()->Shutdown(how); |
| 1302 if (err != 0) { | 1311 if (err != 0) { |
| 1303 errno = err; | 1312 errno = err; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 errno = ENOTSOCK; | 1382 errno = ENOTSOCK; |
| 1374 return -1; | 1383 return -1; |
| 1375 } | 1384 } |
| 1376 | 1385 |
| 1377 return 0; | 1386 return 0; |
| 1378 } | 1387 } |
| 1379 | 1388 |
| 1380 #endif // PROVIDES_SOCKET_API | 1389 #endif // PROVIDES_SOCKET_API |
| 1381 | 1390 |
| 1382 } // namespace_nacl_io | 1391 } // namespace_nacl_io |
| OLD | NEW |