| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 5 #ifndef LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 
| 6 #define LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 6 #define LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 
| 7 | 7 | 
| 8 #include "nacl_io/ossocket.h" | 8 #include "nacl_io/ossocket.h" | 
| 9 #ifdef PROVIDES_SOCKET_API | 9 #ifdef PROVIDES_SOCKET_API | 
| 10 | 10 | 
| 11 #include <ppapi/c/pp_errors.h> | 11 #include <ppapi/c/pp_errors.h> | 
| 12 #include <ppapi/c/pp_resource.h> | 12 #include <ppapi/c/pp_resource.h> | 
| 13 #include <ppapi/c/ppb_net_address.h> | 13 #include <ppapi/c/ppb_net_address.h> | 
| 14 | 14 | 
| 15 #include "nacl_io/mount.h" | 15 #include "nacl_io/mount.h" | 
|  | 16 #include "nacl_io/mount_node.h" | 
|  | 17 #include "nacl_io/mount_node_stream.h" | 
| 16 #include "nacl_io/pepper_interface.h" | 18 #include "nacl_io/pepper_interface.h" | 
| 17 | 19 | 
| 18 namespace nacl_io { | 20 namespace nacl_io { | 
| 19 | 21 | 
| 20 /* Only allow single maximum transfers of 64K or less. Socket users | 22 /* Only allow single maximum transfers of 64K or less. Socket users | 
| 21  * should be looping on Send/Recv size. */ | 23  * should be looping on Send/Recv size. */ | 
| 22 static const size_t MAX_SOCK_TRANSFER = 65536; | 24 static const size_t MAX_SOCK_TRANSFER = 65536; | 
| 23 | 25 | 
| 24 class MountSocket; | 26 class MountStream; | 
| 25 | 27 | 
| 26 class MountNodeSocket : public MountNode { | 28 class MountNodeSocket : public MountNodeStream { | 
| 27  public: | 29  public: | 
| 28   explicit MountNodeSocket(Mount* mount); | 30   explicit MountNodeSocket(Mount* mount); | 
| 29 | 31 | 
| 30  protected: | 32  protected: | 
| 31   virtual void Destroy(); | 33   virtual void Destroy(); | 
| 32   virtual Error Init(int flags) = 0; | 34   virtual Error Init(int flags) = 0; | 
| 33 | 35 | 
| 34  public: | 36  public: | 
| 35   virtual uint32_t GetEventStatus(); |  | 
| 36 |  | 
| 37   // Normal read/write operations on a file (recv/send). | 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); | 38   virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes); | 
| 39   virtual Error Write(size_t offs, | 39   virtual Error Write(size_t offs, | 
| 40                       const void* buf, | 40                       const void* buf, | 
| 41                       size_t count, | 41                       size_t count, | 
| 42                       int* out_bytes); | 42                       int* out_bytes); | 
| 43 | 43 | 
| 44   // Unsuported Functions | 44   // Unsuported Functions | 
| 45   virtual Error Accept(const struct sockaddr* addr, socklen_t len); | 45   virtual Error Accept(const struct sockaddr* addr, socklen_t len); | 
| 46   virtual Error Listen(int backlog); | 46   virtual Error Listen(int backlog); | 
| 47   virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len); | 47   virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len); | 
| 48   virtual Error SetSockOpt(int lvl, | 48   virtual Error SetSockOpt(int lvl, | 
| 49                            int optname, | 49                            int optname, | 
| 50                            const void* optval, | 50                            const void* optval, | 
| 51                            socklen_t len); | 51                            socklen_t len); | 
| 52   virtual Error Shutdown(int how); | 52   virtual Error Shutdown(int how); | 
| 53   virtual Error MMap(void* addr, | 53   virtual Error MMap(void* addr, | 
| 54                      size_t length, | 54                      size_t length, | 
| 55                      int prot, | 55                      int prot, | 
| 56                      int flags, | 56                      int flags, | 
| 57                      size_t offset, | 57                      size_t offset, | 
| 58                      void** out_addr); | 58                      void** out_addr); | 
| 59 | 59 | 
| 60   // Normal Functions. | 60   // Socket Functions. | 
| 61   virtual Error Bind(const struct sockaddr* addr, socklen_t len); | 61   virtual Error Bind(const struct sockaddr* addr, socklen_t len); | 
| 62   virtual Error Connect(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); | 63   virtual Error Recv(void* buf, size_t len, int flags, int* out_len); | 
| 64   virtual Error RecvFrom(void* buf, | 64   virtual Error RecvFrom(void* buf, | 
| 65                          size_t len, | 65                          size_t len, | 
| 66                          int flags, | 66                          int flags, | 
| 67                          struct sockaddr* src_addr, | 67                          struct sockaddr* src_addr, | 
| 68                          socklen_t* addrlen, | 68                          socklen_t* addrlen, | 
| 69                          int* out_len); | 69                          int* out_len); | 
| 70 | 70 | 
| 71   virtual Error Send(const void* buf, size_t len, int flags, int* out_len); | 71   virtual Error Send(const void* buf, size_t len, int flags, int* out_len); | 
| 72   virtual Error SendTo(const void* buf, | 72   virtual Error SendTo(const void* buf, | 
| 73                        size_t len, | 73                        size_t len, | 
| 74                        int flags, | 74                        int flags, | 
| 75                        const struct sockaddr* dest_addr, | 75                        const struct sockaddr* dest_addr, | 
| 76                        socklen_t addrlen, | 76                        socklen_t addrlen, | 
| 77                        int* out_len); | 77                        int* out_len); | 
| 78 | 78 | 
| 79   virtual Error GetPeerName(struct sockaddr* addr, socklen_t* len); | 79   virtual Error GetPeerName(struct sockaddr* addr, socklen_t* len); | 
| 80   virtual Error GetSockName(struct sockaddr* addr, socklen_t* len); | 80   virtual Error GetSockName(struct sockaddr* addr, socklen_t* len); | 
| 81 | 81 | 
|  | 82   PP_Resource socket_resource() { return socket_resource_; } | 
|  | 83 | 
| 82  protected: | 84  protected: | 
| 83   NetAddressInterface* NetAddress(); | 85   NetAddressInterface* NetInterface(); | 
|  | 86   TCPSocketInterface* TCPInterface(); | 
|  | 87   UDPSocketInterface* UDPInterface(); | 
|  | 88 | 
| 84   PP_Resource SockAddrToResource(const struct sockaddr* addr, socklen_t len); | 89   PP_Resource SockAddrToResource(const struct sockaddr* addr, socklen_t len); | 
| 85   socklen_t ResourceToSockAddr(PP_Resource addr, | 90   socklen_t ResourceToSockAddr(PP_Resource addr, | 
| 86                                socklen_t len, | 91                                socklen_t len, | 
| 87                                struct sockaddr* out_addr); | 92                                struct sockaddr* out_addr); | 
| 88 | 93 | 
| 89   bool IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2); | 94   bool IsEquivalentAddress(PP_Resource addr1, PP_Resource addr2); | 
| 90 | 95 | 
| 91  protected: | 96  protected: | 
| 92   PP_Resource socket_resource_; | 97   PP_Resource socket_resource_; | 
| 93   PP_Resource local_addr_; | 98   PP_Resource local_addr_; | 
| 94   PP_Resource remote_addr_; | 99   PP_Resource remote_addr_; | 
|  | 100   uint32_t socket_flags_; | 
|  | 101 | 
| 95 | 102 | 
| 96   friend class KernelProxy; | 103   friend class KernelProxy; | 
| 97   friend class MountSocket; | 104   friend class MountStream; | 
| 98 }; | 105 }; | 
| 99 | 106 | 
| 100 | 107 | 
| 101 }  // namespace nacl_io | 108 }  // namespace nacl_io | 
| 102 | 109 | 
| 103 | 110 | 
| 104 #endif  // PROVIDES_SOCKET_API | 111 #endif  // PROVIDES_SOCKET_API | 
| 105 #endif  // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 112 #endif  // LIBRARIES_NACL_IO_MOUNT_NODE_SOCKET_H_ | 
| OLD | NEW | 
|---|