diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-22 17:41:08 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-22 17:41:08 -0800 |
commit | c79527b7846eeba94eaccaab6a5ee7079255e6f2 (patch) | |
tree | 9abc643b0d644e1fce641d248db1b70feb088adb /src | |
parent | 70a2e1db1dd4e4aa0c01e2dfb50499123d69967c (diff) | |
download | teliva-c79527b7846eeba94eaccaab6a5ee7079255e6f2.tar.gz |
delete final vestiges of embedded luasocket
Diffstat (limited to 'src')
-rw-r--r-- | src/luasec/luasocket/io.h | 65 | ||||
-rw-r--r-- | src/luasec/luasocket/socket.h | 78 | ||||
-rw-r--r-- | src/luasec/luasocket/timeout.h | 28 | ||||
-rw-r--r-- | src/luasec/luasocket/usocket.h | 70 | ||||
-rw-r--r-- | src/luasec/ssl.c | 2 | ||||
-rw-r--r-- | src/luasec/ssl.h | 2 | ||||
-rw-r--r-- | src/luasocket/usocket.h | 5 |
7 files changed, 7 insertions, 243 deletions
diff --git a/src/luasec/luasocket/io.h b/src/luasec/luasocket/io.h deleted file mode 100644 index b1f35ad..0000000 --- a/src/luasec/luasocket/io.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef IO_H -#define IO_H -/*=========================================================================*\ -* Input/Output abstraction -* LuaSocket toolkit -* -* This module defines the interface that LuaSocket expects from the -* transport layer for streamed input/output. The idea is that if any -* transport implements this interface, then the buffer.c functions -* automatically work on it. -* -* The module socket.h implements this interface, and thus the module tcp.h -* is very simple. -\*=========================================================================*/ -#include <stdio.h> -#include "../../lua.h" - -#include "timeout.h" - -/* IO error codes */ -enum { - IO_DONE = 0, /* operation completed successfully */ - IO_TIMEOUT = -1, /* operation timed out */ - IO_CLOSED = -2, /* the connection has been closed */ - IO_UNKNOWN = -3 -}; - -/* interface to error message function */ -typedef const char *(*p_error) ( - void *ctx, /* context needed by send */ - int err /* error code */ -); - -/* interface to send function */ -typedef int (*p_send) ( - void *ctx, /* context needed by send */ - const char *data, /* pointer to buffer with data to send */ - size_t count, /* number of bytes to send from buffer */ - size_t *sent, /* number of bytes sent uppon return */ - p_timeout tm /* timeout control */ -); - -/* interface to recv function */ -typedef int (*p_recv) ( - void *ctx, /* context needed by recv */ - char *data, /* pointer to buffer where data will be written */ - size_t count, /* number of bytes to receive into buffer */ - size_t *got, /* number of bytes received uppon return */ - p_timeout tm /* timeout control */ -); - -/* IO driver definition */ -typedef struct t_io_ { - void *ctx; /* context needed by send/recv */ - p_send send; /* send function pointer */ - p_recv recv; /* receive function pointer */ - p_error error; /* strerror function */ -} t_io; -typedef t_io *p_io; - -void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx); -const char *io_strerror(int err); - -#endif /* IO_H */ - diff --git a/src/luasec/luasocket/socket.h b/src/luasec/luasocket/socket.h deleted file mode 100644 index 07c20fe..0000000 --- a/src/luasec/luasocket/socket.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef SOCKET_H -#define SOCKET_H -/*=========================================================================*\ -* Socket compatibilization module -* LuaSocket toolkit -* -* BSD Sockets and WinSock are similar, but there are a few irritating -* differences. Also, not all *nix platforms behave the same. This module -* (and the associated usocket.h and wsocket.h) factor these differences and -* creates a interface compatible with the io.h module. -\*=========================================================================*/ -#include "io.h" - -/*=========================================================================*\ -* Platform specific compatibilization -\*=========================================================================*/ -#ifdef _WIN32 -#include "wsocket.h" -#else -#include "usocket.h" -#endif - -/*=========================================================================*\ -* The connect and accept functions accept a timeout and their -* implementations are somewhat complicated. We chose to move -* the timeout control into this module for these functions in -* order to simplify the modules that use them. -\*=========================================================================*/ -#include "timeout.h" - -/* we are lazy... */ -typedef struct sockaddr SA; - -/*=========================================================================*\ -* Functions below implement a comfortable platform independent -* interface to sockets -\*=========================================================================*/ -int socket_open(void); -int socket_close(void); -void socket_destroy(p_socket ps); -void socket_shutdown(p_socket ps, int how); -int socket_sendto(p_socket ps, const char *data, size_t count, - size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm); -int socket_recvfrom(p_socket ps, char *data, size_t count, - size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm); - -void socket_setnonblocking(p_socket ps); -void socket_setblocking(p_socket ps); - -int socket_waitfd(p_socket ps, int sw, p_timeout tm); -int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, - p_timeout tm); - -int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm); -int socket_create(p_socket ps, int domain, int type, int protocol); -int socket_bind(p_socket ps, SA *addr, socklen_t addr_len); -int socket_listen(p_socket ps, int backlog); -int socket_accept(p_socket ps, p_socket pa, SA *addr, - socklen_t *addr_len, p_timeout tm); - -const char *socket_hoststrerror(int err); -const char *socket_gaistrerror(int err); -const char *socket_strerror(int err); - -/* these are perfect to use with the io abstraction module - and the buffered input module */ -int socket_send(p_socket ps, const char *data, size_t count, - size_t *sent, p_timeout tm); -int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm); -int socket_write(p_socket ps, const char *data, size_t count, - size_t *sent, p_timeout tm); -int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm); -const char *socket_ioerror(p_socket ps, int err); - -int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp); -int socket_gethostbyname(const char *addr, struct hostent **hp); - -#endif /* SOCKET_H */ diff --git a/src/luasec/luasocket/timeout.h b/src/luasec/luasocket/timeout.h deleted file mode 100644 index 69751da..0000000 --- a/src/luasec/luasocket/timeout.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef TIMEOUT_H -#define TIMEOUT_H -/*=========================================================================*\ -* Timeout management functions -* LuaSocket toolkit -\*=========================================================================*/ -#include "../../lua.h" - -/* timeout control structure */ -typedef struct t_timeout_ { - double block; /* maximum time for blocking calls */ - double total; /* total number of milliseconds for operation */ - double start; /* time of start of operation */ -} t_timeout; -typedef t_timeout *p_timeout; - -int timeout_open(lua_State *L); -void timeout_init(p_timeout tm, double block, double total); -double timeout_get(p_timeout tm); -double timeout_getretry(p_timeout tm); -p_timeout timeout_markstart(p_timeout tm); -double timeout_getstart(p_timeout tm); -double timeout_gettime(void); -int timeout_meth_settimeout(lua_State *L, p_timeout tm); - -#define timeout_iszero(tm) ((tm)->block == 0.0) - -#endif /* TIMEOUT_H */ diff --git a/src/luasec/luasocket/usocket.h b/src/luasec/luasocket/usocket.h deleted file mode 100644 index ecbcd8e..0000000 --- a/src/luasec/luasocket/usocket.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef USOCKET_H -#define USOCKET_H -/*=========================================================================*\ -* Socket compatibilization module for Unix -* LuaSocket toolkit -\*=========================================================================*/ - -/*=========================================================================*\ -* BSD include files -\*=========================================================================*/ -/* error codes */ -#include <errno.h> -/* close function */ -#include <unistd.h> -/* fnctnl function and associated constants */ -#include <fcntl.h> -/* struct sockaddr */ -#include <sys/types.h> -/* socket function */ -#include <sys/socket.h> -/* struct timeval */ -#include <sys/time.h> -/* gethostbyname and gethostbyaddr functions */ -#include <netdb.h> -/* sigpipe handling */ -#include <signal.h> -/* IP stuff*/ -#include <netinet/in.h> -#include <arpa/inet.h> -/* TCP options (nagle algorithm disable) */ -#include <netinet/tcp.h> -#include <net/if.h> - -#ifndef SOCKET_SELECT -#include <sys/poll.h> -#define WAITFD_R POLLIN -#define WAITFD_W POLLOUT -#define WAITFD_C (POLLIN|POLLOUT) -#else -#define WAITFD_R 1 -#define WAITFD_W 2 -#define WAITFD_C (WAITFD_R|WAITFD_W) -#endif - -#ifndef SO_REUSEPORT -#define SO_REUSEPORT SO_REUSEADDR -#endif - -/* Some platforms use IPV6_JOIN_GROUP instead if - * IPV6_ADD_MEMBERSHIP. The semantics are same, though. */ -#ifndef IPV6_ADD_MEMBERSHIP -#ifdef IPV6_JOIN_GROUP -#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#endif /* IPV6_JOIN_GROUP */ -#endif /* !IPV6_ADD_MEMBERSHIP */ - -/* Same with IPV6_DROP_MEMBERSHIP / IPV6_LEAVE_GROUP. */ -#ifndef IPV6_DROP_MEMBERSHIP -#ifdef IPV6_LEAVE_GROUP -#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP -#endif /* IPV6_LEAVE_GROUP */ -#endif /* !IPV6_DROP_MEMBERSHIP */ - -typedef int t_socket; -typedef t_socket *p_socket; -typedef struct sockaddr_storage t_sockaddr_storage; - -#define SOCKET_INVALID (-1) - -#endif /* USOCKET_H */ diff --git a/src/luasec/ssl.c b/src/luasec/ssl.c index 123d34f..c2a579e 100644 --- a/src/luasec/ssl.c +++ b/src/luasec/ssl.c @@ -26,7 +26,7 @@ #include "../luasocket/io.h" #include "../luasocket/buffer.h" #include "../luasocket/timeout.h" -#include "luasocket/socket.h" +#include "../luasocket/socket.h" #include "x509.h" #include "context.h" diff --git a/src/luasec/ssl.h b/src/luasec/ssl.h index 7640ae0..385d541 100644 --- a/src/luasec/ssl.h +++ b/src/luasec/ssl.h @@ -14,7 +14,7 @@ #include "../luasocket/io.h" #include "../luasocket/buffer.h" #include "../luasocket/timeout.h" -#include "luasocket/socket.h" +#include "../luasocket/socket.h" #include "compat.h" #include "context.h" diff --git a/src/luasocket/usocket.h b/src/luasocket/usocket.h index 45f2f99..3da449b 100644 --- a/src/luasocket/usocket.h +++ b/src/luasocket/usocket.h @@ -31,6 +31,11 @@ #include <netinet/tcp.h> #include <net/if.h> +#include <sys/poll.h> +#define WAITFD_R POLLIN +#define WAITFD_W POLLOUT +#define WAITFD_C (POLLIN|POLLOUT) + #ifndef SO_REUSEPORT #define SO_REUSEPORT SO_REUSEADDR #endif |