sys: add networking functions
Add networking related functions to the syscall wrapper.
Signed-off-by: Benjamin Fair <benjaminfair@google.com>
Change-Id: I0ccb4138963ce2a8c7bb6f6f3a556de1afcd0c08
diff --git a/internal/sys.hpp b/internal/sys.hpp
index 41fb46b..a399903 100644
--- a/internal/sys.hpp
+++ b/internal/sys.hpp
@@ -7,8 +7,11 @@
* other pieces.
*/
+#include <netdb.h>
#include <poll.h>
#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/types.h>
#include <cinttypes>
#include <cstddef>
@@ -39,6 +42,15 @@
virtual int getpagesize() const = 0;
virtual int ioctl(int fd, unsigned long request, void* param) const = 0;
virtual int poll(struct pollfd* fds, nfds_t nfds, int timeout) const = 0;
+ virtual int socket(int domain, int type, int protocol) const = 0;
+ virtual int connect(int sockfd, const struct sockaddr* addr,
+ socklen_t addrlen) const = 0;
+ virtual ssize_t sendfile(int out_fd, int in_fd, off_t* offset,
+ size_t count) const = 0;
+ virtual int getaddrinfo(const char* node, const char* service,
+ const struct addrinfo* hints,
+ struct addrinfo** res) const = 0;
+ virtual void freeaddrinfo(struct addrinfo* res) const = 0;
virtual std::int64_t getSize(const char* pathname) const = 0;
};
@@ -63,6 +75,15 @@
int getpagesize() const override;
int ioctl(int fd, unsigned long request, void* param) const override;
int poll(struct pollfd* fds, nfds_t nfds, int timeout) const override;
+ int socket(int domain, int type, int protocol) const override;
+ int connect(int sockfd, const struct sockaddr* addr,
+ socklen_t addrlen) const override;
+ ssize_t sendfile(int out_fd, int in_fd, off_t* offset,
+ size_t count) const override;
+ int getaddrinfo(const char* node, const char* service,
+ const struct addrinfo* hints,
+ struct addrinfo** res) const override;
+ void freeaddrinfo(struct addrinfo* res) const override;
/* returns 0 on failure, or if the file is zero bytes. */
std::int64_t getSize(const char* pathname) const override;
};