Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc

Issue 23456045: [NaCl SDK] nacl_io: Add initial support for getsockopt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 return 0;
216 }
217 }
218
noelallen1 2013/09/30 22:56:16 Clear last_errno_: The SO_ERROR option obtains and
Sam Clegg 2013/10/01 00:15:49 Done.
219 return ENOPROTOOPT;
208 } 220 }
209 221
210 Error MountNodeSocket::SetSockOpt(int lvl, 222 Error MountNodeSocket::SetSockOpt(int lvl,
211 int optname, 223 int optname,
212 const void* optval, 224 const void* optval,
213 socklen_t len) { 225 socklen_t len) {
214 return EINVAL; 226 return ENOPROTOOPT;
215 } 227 }
216 228
217 Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) { 229 Error MountNodeSocket::Bind(const struct sockaddr* addr, socklen_t len) {
218 return EINVAL; 230 return EINVAL;
219 } 231 }
220 232
221 233
222 Error MountNodeSocket::Recv(void* buf, size_t len, int flags, int* out_len) { 234 Error MountNodeSocket::Recv(void* buf, size_t len, int flags, int* out_len) {
223 return RecvFrom(buf, len, flags, NULL, 0, out_len); 235 return RecvFrom(buf, len, flags, NULL, 0, out_len);
224 } 236 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (local_addr_ != 0) { 377 if (local_addr_ != 0) {
366 *len = ResourceToSockAddr(local_addr_, *len, addr); 378 *len = ResourceToSockAddr(local_addr_, *len, addr);
367 return 0; 379 return 0;
368 } 380 }
369 381
370 return ENOTCONN; 382 return ENOTCONN;
371 } 383 }
372 384
373 } // namespace nacl_io 385 } // namespace nacl_io
374 386
375 #endif // PROVIDES_SOCKET_API 387 #endif // PROVIDES_SOCKET_API
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698