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

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

Issue 22587003: [NaCl SDK] Add UDP and TCP Sockets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to browser tester fix. Created 7 years, 4 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) 2013 The Chromium 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 LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
6 #define LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
7
8 #include "nacl_io/ossocket.h"
9 #ifdef PROVIDES_SOCKET_API
10
11 #include <ppapi/c/pp_errors.h>
12 #include <ppapi/c/pp_resource.h>
13 #include <ppapi/c/ppb_net_address.h>
14
15 #include "nacl_io/mount.h"
16 #include "nacl_io/pepper_interface.h"
17
18 namespace nacl_io {
19
20 /* Only allow single maximum transfers of 64K or less. Socket users
21 * should be looping on Send/Recv size. */
22 static const size_t MAX_SOCK_TRANSFER = 65536;
23
24 class MountSocket;
25
26 class MountNodeSocket : public MountNode {
27 public:
28 explicit MountNodeSocket(Mount* mount);
29
30 protected:
31 virtual void Destroy();
32 virtual Error Init(int flags) = 0;
33
34 public:
35 virtual uint32_t GetEventStatus();
36
37 // Normal read/write operations on a file (recv/send).
38 virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes);
39 virtual Error Write(size_t offs,
40 const void* buf,
41 size_t count,
42 int* out_bytes);
43
44 // Unsuported Functions
45 virtual Error Accept(const struct sockaddr* addr, socklen_t len);
46 virtual Error Listen(int backlog);
47 virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len);
48 virtual Error SetSockOpt(int lvl,
49 int optname,
50 const void* optval,
51 socklen_t len);
52 virtual Error Shutdown(int how);
53 virtual Error MMap(void* addr,
54 size_t length,
55 int prot,
56 int flags,
57 size_t offset,
58 void** out_addr);
59
60 // Normal Functions.
61 virtual Error Bind(const struct sockaddr* addr, socklen_t len);
62 virtual Error Connect(const struct sockaddr* addr, socklen_t len);
63 virtual Error Recv(void* buf, size_t len, int flags, int* out_len);
64 virtual Error RecvFrom(void* buf,
65 size_t len,
66 int flags,
67 struct sockaddr* src_addr,
68 socklen_t* addrlen,
69 int* out_len);
70
71 virtual Error Send(const void* buf, size_t len, int flags, int* out_len);
72 virtual Error SendTo(const void* buf,
73 size_t len,
74 int flags,
75 const struct sockaddr* dest_addr,
76 socklen_t addrlen,
77 int* out_len);
78
79 virtual Error GetPeerName(struct sockaddr* addr, socklen_t* len);
80 virtual Error GetSockName(struct sockaddr* addr, socklen_t* len);
81
82 protected:
83 NetAddressInterface* NetAddress();
84 PP_Resource SockAddrToResource(const struct sockaddr* addr, socklen_t len);
85 socklen_t ResourceToSockAddr(PP_Resource addr,
86 socklen_t len,
87 struct sockaddr* out_addr);
88
89 bool IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2);
90
91 protected:
92 PP_Resource socket_resource_;
93 PP_Resource local_addr_;
94 PP_Resource remote_addr_;
95
96 friend class KernelProxy;
97 friend class MountSocket;
98 };
99
100
101 } // namespace nacl_io
102
103
104 #endif // PROVIDES_SOCKET_API
105 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node.cc ('k') | native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698