Index: libraries/nacl-mounts/net/BaseSocketSubSystem.h |
=================================================================== |
--- libraries/nacl-mounts/net/BaseSocketSubSystem.h (revision 0) |
+++ libraries/nacl-mounts/net/BaseSocketSubSystem.h (revision 0) |
@@ -0,0 +1,58 @@ |
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
+#define PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
+#include <assert.h> |
+#include <errno.h> |
+#include <memory.h> |
+#include <stdarg.h> |
+#include <stdio.h> |
+#include <sys/ioctl.h> |
+#include <sys/types.h> |
+#include <unistd.h> |
+ |
+#include <map> |
+#include <string> |
+ |
+#include "../net/Socket.h" |
+#include "../util/PthreadHelpers.h" |
+ |
+class BaseSocketSubSystem { |
+ public: |
+ BaseSocketSubSystem() {} |
+ virtual ~BaseSocketSubSystem() {} |
+ |
+ // Syscall implementations |
+ virtual int close(Socket* stream) = 0; |
+ virtual int read(Socket* stream, char* buf, size_t count, |
+ size_t* nread) = 0; |
+ virtual int write(Socket* stream, const char* buf, size_t count, |
+ size_t* nwrote) = 0; |
+ virtual int seek(Socket* stream, nacl_abi_off_t offset, int whence, |
+ nacl_abi_off_t* new_offset) = 0; |
+ virtual int fstat(Socket* stream, nacl_abi_stat* out) = 0; |
+ |
+ virtual int fcntl(Socket* stream, int cmd, va_list ap) = 0; |
+ virtual int ioctl(Socket* stream, int request, va_list ap) = 0; |
+ |
+ virtual unsigned long gethostbyname(const char* name) = 0; |
+ virtual int getaddrinfo(const char* hostname, const char* servname, |
+ const addrinfo* hints, addrinfo** res) = 0; |
+ virtual void freeaddrinfo(addrinfo* ai) = 0; |
+ virtual int getnameinfo(const sockaddr *sa, socklen_t salen, |
+ char *host, size_t hostlen, |
+ char *serv, size_t servlen, int flags) = 0; |
+ virtual int connect(Socket** stream, const sockaddr* serv_addr, |
+ socklen_t addrlen) = 0; |
+ virtual int bind(Socket** stream, const sockaddr* addr, |
+ socklen_t addrlen) = 0; |
+ virtual int shutdown(Socket* stream, int how) = 0; |
+ virtual int listen(Socket* stream, int backlog) = 0; |
+ virtual Socket* accept(Socket* stream, struct sockaddr *addr, |
+ socklen_t* addrlen) = 0; |
+}; |
+ |
+#endif // PACKAGES_LIBRARIES_NACL_MOUNTS_NET_BASESOCKETSUBSYSTEM_H_ |
+ |