OLD | NEW |
---|---|
(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 | |
8 #include <assert.h> | |
9 #include <errno.h> | |
10 #include <memory.h> | |
11 #include <stdarg.h> | |
12 #include <stdio.h> | |
13 #include <sys/ioctl.h> | |
14 #include <sys/types.h> | |
15 #include <unistd.h> | |
16 | |
17 #include <map> | |
18 #include <string> | |
19 | |
20 #include "../base/KernelProxy.h" | |
21 #include "../net/BaseSocketSubSystem.h" | |
22 #include "../net/IOInterfaces.h" | |
23 #include "ppapi/cpp/file_ref.h" | |
24 #include "ppapi/cpp/file_system.h" | |
25 #include "ppapi/utility/completion_callback_factory.h" | |
26 | |
27 class SocketSubSystem : public BaseSocketSubSystem { | |
28 public: | |
29 explicit SocketSubSystem(pp::Instance* instance); | |
30 ~SocketSubSystem(); | |
Dmitry Polukhin
2012/05/29 15:00:51
Please add virtual, because base class d-tor is vi
vissi
2012/05/30 08:10:51
Done.
| |
31 pp::Instance* instance() { return pp_instance_; } | |
32 | |
33 // Syscall implementations | |
34 int close(FileStream* stream); | |
35 int read(FileStream* stream, char* buf, size_t count, size_t* nread); | |
36 int write(FileStream* stream, const char* buf, size_t count, size_t* nwrote); | |
37 int seek(FileStream* stream, nacl_abi_off_t offset, int whence, | |
38 nacl_abi_off_t* new_offset); | |
39 int fstat(FileStream* stream, nacl_abi_stat* out); | |
40 | |
41 int fcntl(FileStream* stream, int cmd, va_list ap); | |
42 int ioctl(FileStream* stream, int request, va_list ap); | |
43 | |
44 unsigned long gethostbyname(const char* name); | |
45 int connect(FileStream** stream, unsigned long addr, unsigned short port); | |
46 int shutdown(FileStream* stream, int how); | |
47 int bind(FileStream** stream, unsigned long addr, unsigned short port); | |
48 int listen(FileStream* stream, int backlog); | |
49 FileStream* accept(FileStream* stream, struct sockaddr *addr, | |
50 socklen_t* addrlen); | |
Dmitry Polukhin
2012/05/29 15:00:51
Need 2 idents.
vissi
2012/05/30 08:10:51
Done.
| |
51 Mutex& mutex() { return KernelProxy::KPInstance()->select_mutex(); } | |
52 Cond& cond() { return KernelProxy::KPInstance()->select_cond(); } | |
53 private: | |
54 // protect hosts_ and addrs_ | |
55 Mutex mutex_; | |
56 unsigned long first_unused_addr_; | |
57 pp::Instance* pp_instance_; | |
58 | |
59 typedef std::map<std::string, unsigned long> HostMap; | |
60 typedef std::map<unsigned long, std::string> AddressMap; | |
61 | |
62 // we store a map of virtual addresses here, as PPAPA sockes are name-bound | |
Evgeniy Stepanov
2012/05/29 14:28:20
a TODO about getting rid of this with the new reso
vissi
2012/05/30 08:10:51
Done.
| |
63 void AddHostAddress(const char* name, unsigned long addr); | |
64 std::string GetHostByAddr(unsigned long addr); | |
65 | |
66 HostMap hosts_; | |
67 AddressMap addrs_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(SocketSubSystem); | |
70 }; | |
71 | |
72 #endif // SOCKET_SUBSYSTEM_H | |
73 | |
OLD | NEW |