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 PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
| 6 #define PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
| 7 #include <errno.h> |
| 8 #ifndef __GLIBC__ |
| 9 #include <nacl-mounts/net/newlib_compat.h> |
| 10 #endif |
| 11 #include <nacl-mounts/net/Socket.h> |
| 12 #include <nacl-mounts/util/PthreadHelpers.h> |
| 13 #include <stdarg.h> |
| 14 #include <stdio.h> |
| 15 #include <sys/types.h> |
| 16 #include <unistd.h> |
| 17 |
| 18 #include <map> |
| 19 #include <string> |
| 20 |
| 21 class BaseSocketSubSystem { |
| 22 public: |
| 23 BaseSocketSubSystem() {} |
| 24 virtual ~BaseSocketSubSystem() {} |
| 25 |
| 26 // Syscall implementations |
| 27 virtual int close(Socket* stream) = 0; |
| 28 virtual int read(Socket* stream, char* buf, size_t count, |
| 29 size_t* nread) = 0; |
| 30 virtual int write(Socket* stream, const char* buf, size_t count, |
| 31 size_t* nwrote) = 0; |
| 32 virtual int seek(Socket* stream, nacl_abi_off_t offset, int whence, |
| 33 nacl_abi_off_t* new_offset) = 0; |
| 34 virtual int fstat(Socket* stream, nacl_abi_stat* out) = 0; |
| 35 |
| 36 virtual int fcntl(Socket* stream, int cmd, va_list ap) = 0; |
| 37 virtual int ioctl(Socket* stream, int request, va_list ap) = 0; |
| 38 |
| 39 virtual uint32_t gethostbyname(const char* name) = 0; |
| 40 virtual int getaddrinfo(const char* hostname, const char* servname, |
| 41 const addrinfo* hints, addrinfo** res) = 0; |
| 42 virtual void freeaddrinfo(addrinfo* ai) = 0; |
| 43 virtual int getnameinfo(const sockaddr *sa, socklen_t salen, |
| 44 char* host, size_t hostlen, |
| 45 char* serv, size_t servlen, int flags) = 0; |
| 46 virtual int connect(Socket** stream, const sockaddr* serv_addr, |
| 47 socklen_t addrlen) = 0; |
| 48 virtual int bind(Socket** stream, const sockaddr* addr, |
| 49 socklen_t addrlen) = 0; |
| 50 virtual int shutdown(Socket* stream, int how) = 0; |
| 51 virtual int listen(Socket* stream, int backlog) = 0; |
| 52 virtual Socket* accept(Socket* stream, struct sockaddr *addr, |
| 53 socklen_t* addrlen) = 0; |
| 54 }; |
| 55 |
| 56 #endif // PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
| 57 |
OLD | NEW |