| OLD | NEW |
| (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 class MountSocket; |
| 21 |
| 22 class MountNodeSocket : public MountNode { |
| 23 public: |
| 24 explicit MountNodeSocket(Mount* mount); |
| 25 |
| 26 protected: |
| 27 virtual void Destroy(); |
| 28 virtual Error Init(int flags) = 0; |
| 29 |
| 30 public: |
| 31 virtual uint32_t GetEventStatus(); |
| 32 |
| 33 // Normal read/write operations on a file (recv/send). |
| 34 virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes); |
| 35 virtual Error Write(size_t offs, |
| 36 const void* buf, |
| 37 size_t count, |
| 38 int* out_bytes); |
| 39 |
| 40 // Unsuported Functions |
| 41 virtual Error Accept(const struct sockaddr* addr, socklen_t len); |
| 42 virtual Error Listen(int backlog); |
| 43 virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len); |
| 44 virtual Error SetSockOpt(int lvl, |
| 45 int optname, |
| 46 const void* optval, |
| 47 socklen_t len); |
| 48 virtual Error Shutdown(int how); |
| 49 virtual Error MMap(void* addr, |
| 50 size_t length, |
| 51 int prot, |
| 52 int flags, |
| 53 size_t offset, |
| 54 void** out_addr); |
| 55 |
| 56 // Normal Functions. |
| 57 virtual Error Bind(const struct sockaddr* addr, socklen_t len); |
| 58 virtual Error Connect(const struct sockaddr* addr, socklen_t len); |
| 59 virtual Error Recv(void* buf, size_t len, int flags, int* out_len); |
| 60 virtual Error RecvFrom(void* buf, |
| 61 size_t len, |
| 62 int flags, |
| 63 struct sockaddr* src_addr, |
| 64 socklen_t* addrlen, |
| 65 int* out_len); |
| 66 |
| 67 virtual Error Send(const void* buf, size_t len, int flags, int* out_len); |
| 68 virtual Error SendTo(const void* buf, |
| 69 size_t len, |
| 70 int flags, |
| 71 const struct sockaddr* dest_addr, |
| 72 socklen_t addrlen, |
| 73 int* out_len); |
| 74 |
| 75 virtual Error GetPeerName(struct sockaddr* addr, socklen_t* len); |
| 76 virtual Error GetSockName(struct sockaddr* addr, socklen_t* len); |
| 77 |
| 78 protected: |
| 79 NetAddressInterface* NetAddress(); |
| 80 PP_Resource SockAddrToResource(const struct sockaddr* addr, socklen_t len); |
| 81 socklen_t ResourceToSockAddr(PP_Resource addr, |
| 82 socklen_t len, |
| 83 struct sockaddr* out_addr); |
| 84 |
| 85 bool IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2); |
| 86 |
| 87 protected: |
| 88 PP_Resource socket_resource_; |
| 89 PP_Resource local_addr_; |
| 90 PP_Resource remote_addr_; |
| 91 |
| 92 friend class KernelProxy; |
| 93 friend class MountSocket; |
| 94 }; |
| 95 |
| 96 |
| 97 } // namespace nacl_io |
| 98 |
| 99 |
| 100 #endif // PROVIDES_SOCKET_API |
| 101 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ |
| OLD | NEW |