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

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

Issue 10392070: Socket subsystem implementation (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
(Empty)
1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SOCKET_SUBSYSTEM_H
6 #define SOCKET_SUBSYSTEM_H
7 #ifdef __GLIBC__
8
9 #include <assert.h>
10 #include <errno.h>
11 //#include <memory.h>
Dmitry Polukhin 2012/05/31 14:06:45 Remove if you don't need it.
vissi 2012/06/01 09:12:57 Done.
12 #include <stdarg.h>
13 #include <stdio.h>
14 #include <sys/ioctl.h>
15 #include <sys/types.h>
16 #include <unistd.h>
17
18 #include <map>
19 #include <string>
20
21 #include "../base/KernelProxy.h"
22 #include "../net/BaseSocketSubSystem.h"
23 #include "../net/IOInterfaces.h"
24 #include "ppapi/cpp/file_ref.h"
25 #include "ppapi/cpp/file_system.h"
26 #include "ppapi/utility/completion_callback_factory.h"
27
28 class SocketSubSystem : public BaseSocketSubSystem {
29 public:
30 explicit SocketSubSystem(pp::Instance* instance);
31 virtual ~SocketSubSystem();
32 pp::Instance* instance() { return pp_instance_; }
33
34 // Syscall implementations
35 int close(FileStream* stream);
36 int read(FileStream* stream, char* buf, size_t count, size_t* nread);
37 int write(FileStream* stream, const char* buf, size_t count, size_t* nwrote);
38 int seek(FileStream* stream, nacl_abi_off_t offset, int whence,
39 nacl_abi_off_t* new_offset);
40 int fstat(FileStream* stream, nacl_abi_stat* out);
41
42 int fcntl(FileStream* stream, int cmd, va_list ap);
43 int ioctl(FileStream* stream, int request, va_list ap);
44
45 unsigned long gethostbyname(const char* name);
46 int connect(FileStream** stream, unsigned long addr, unsigned short port);
47 int shutdown(FileStream* stream, int how);
48 int bind(FileStream** stream, unsigned long addr, unsigned short port);
49 int listen(FileStream* stream, int backlog);
50 FileStream* accept(FileStream* stream, struct sockaddr *addr,
51 socklen_t* addrlen);
52 Mutex& mutex() { return KernelProxy::KPInstance()->select_mutex(); }
53 Cond& cond() { return KernelProxy::KPInstance()->select_cond(); }
54 private:
55 // protect hosts_ and addrs_
56 Mutex mutex_;
57 unsigned long first_unused_addr_;
58 pp::Instance* pp_instance_;
59
60 typedef std::map<std::string, unsigned long> HostMap;
61 typedef std::map<unsigned long, std::string> AddressMap;
62
63 // we store a map of virtual addresses here, as PPAPI sockes are name-bound
64 // TODO(vissi): use new NetAddressPrivate interface
65 void AddHostAddress(const char* name, unsigned long addr);
66 std::string GetHostByAddr(unsigned long addr);
67
68 HostMap hosts_;
69 AddressMap addrs_;
70
71 DISALLOW_COPY_AND_ASSIGN(SocketSubSystem);
72 };
73
74 #endif // __GLIBC__
75 #endif // SOCKET_SUBSYSTEM_H
76
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698