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

Side by Side Diff: libraries/nacl-mounts/net/SocketSubSystem.cc

Issue 10556007: changes in memory mount and socket subsystem to port thttpd (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 6 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) 2012 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2012 The Native Client 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 <string.h> 5 #include <string.h>
6 #ifdef __GLIBC__ 6 #ifdef __GLIBC__
7 #include <arpa/inet.h> 7 #include <arpa/inet.h>
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <netinet/in.h> 9 #include <netinet/in.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 11 matching lines...) Expand all
22 #include "ppapi/cpp/file_ref.h" 22 #include "ppapi/cpp/file_ref.h"
23 #include <signal.h> 23 #include <signal.h>
24 24
25 SocketSubSystem::SocketSubSystem(pp::Instance* instance) 25 SocketSubSystem::SocketSubSystem(pp::Instance* instance)
26 : pp_instance_(instance) 26 : pp_instance_(instance)
27 , factory_(this) 27 , factory_(this)
28 , host_resolver_(NULL) { 28 , host_resolver_(NULL) {
29 AddHostAddress("localhost", 0x7F000001); 29 AddHostAddress("localhost", 0x7F000001);
30 } 30 }
31 31
32 int SocketSubSystem::setsockopt(Socket* stream, int level, int optname,
33 const void* optval, socklen_t optlen) {
34 // this is just a placeholder, chromium does not provide api for this yet
35 return 0;
36 }
37
32 uint32_t SocketSubSystem::AddHostAddress(const char* name, uint32_t addr) { 38 uint32_t SocketSubSystem::AddHostAddress(const char* name, uint32_t addr) {
33 return addr; 39 return addr;
34 } 40 }
35 41
36 struct addrinfo* SocketSubSystem::CreateAddrInfo( 42 struct addrinfo* SocketSubSystem::CreateAddrInfo(
37 const PP_NetAddress_Private& netaddr, 43 const PP_NetAddress_Private& netaddr,
38 const addrinfo* hints, 44 const addrinfo* hints,
39 const char* name) { 45 const char* name) {
40 struct addrinfo* ai = new addrinfo(); 46 struct addrinfo* ai = new addrinfo();
41 struct sockaddr_in6* addr = new sockaddr_in6(); 47 struct sockaddr_in6* addr = new sockaddr_in6();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 const char* hostname = params->hostname; 100 const char* hostname = params->hostname;
95 const char* servname = params->servname; 101 const char* servname = params->servname;
96 const addrinfo* hints = params->hints; 102 const addrinfo* hints = params->hints;
97 addrinfo** res = params->res; 103 addrinfo** res = params->res;
98 104
99 if (hints && hints->ai_family != AF_UNSPEC && 105 if (hints && hints->ai_family != AF_UNSPEC &&
100 hints->ai_family != AF_INET && 106 hints->ai_family != AF_INET &&
101 hints->ai_family != AF_INET6) { 107 hints->ai_family != AF_INET6) {
102 *pres = PP_ERROR_FAILED; 108 *pres = PP_ERROR_FAILED;
103 cond().broadcast(); 109 cond().broadcast();
104 dbgprintf("SSS::Resolve failed: incorrect ai_family\n");
105 return; 110 return;
106 } 111 }
107 112
108 uint32_t port = 0; 113 uint32_t port = 0;
109 if (servname != NULL) { 114 if (servname != NULL) {
110 char* cp; 115 char* cp;
111 port = strtol(servname, &cp, 10); 116 port = strtol(servname, &cp, 10);
112 if (port > 0 && port <= 65535 && *cp == '\0') { 117 if (port > 0 && port <= 65535 && *cp == '\0') {
113 port = htons(port); 118 port = htons(port);
114 } else { 119 } else {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (resource) { 444 if (resource) {
440 TCPSocket* socket = new TCPSocket(this, O_RDWR); 445 TCPSocket* socket = new TCPSocket(this, O_RDWR);
441 if (socket->acceptFrom(resource)) { 446 if (socket->acceptFrom(resource)) {
442 return socket; 447 return socket;
443 } else { 448 } else {
444 socket->release(); 449 socket->release();
445 } 450 }
446 } 451 }
447 errno = EINVAL; 452 errno = EINVAL;
448 return 0; 453 return 0;
449 } else {
450 errno = EBADF;
451 return 0;
452 } 454 }
455 errno = EBADF;
456 return 0;
453 } 457 }
454 458
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698