From d611cc597822049b1bd091b6bf2f136e07ae53cf Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 28 Apr 2015 15:54:45 +0200 Subject: SSL support when talking to ADS --- types.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'types.h') diff --git a/types.h b/types.h index 71cd36d..373b52a 100644 --- a/types.h +++ b/types.h @@ -12,21 +12,28 @@ #define BASELEN 250 #define SIDLEN 28 #define MOUNTLEN 100 +#define FINGERPRINTLEN 20 #define REQLEN 4000 #define MAXMSGLEN 100000 #define BOOL uint8_t -#define TRUE 1 -#define FALSE 0 +#define TRUE (1) +#define FALSE (0) typedef struct _server_t_ server_t; +/** + * General epoll struct, to be implemented by every epoll struct. + */ typedef struct { void (*callback)(void *data, int haveIn, int haveOut, int doCleanup); int fd; } epoll_item_t; +/** + * epoll struct for listening sockets. + */ typedef struct { void (*callback)(void *data, int haveIn, int haveOut, int doCleanup); int fd; @@ -34,6 +41,9 @@ typedef struct { SSL_CTX *sslContext; // Listening for SSL connections, NULL otherwise } epoll_listen_t; +/** + * epoll struct for a client we're serving. + */ typedef struct { void (*callback)(void *data, int haveIn, int haveOut, int doCleanup); int fd; @@ -51,22 +61,32 @@ typedef struct { char readBuffer[REQLEN]; // Static, queries > 4000 bytes simply not supported } epoll_client_t; +/** + * epoll struct for a connection to AD. + */ typedef struct { void (*callback)(void *data, int haveIn, int haveOut, int doCleanup); int fd; + // // Send buffer (me to server) size_t sbPos, sbFill, sbLen; + SSL *ssl; // NULL if not encrypted char *sendBuffer; // Dynamically allocated, might or might not get huge // Recv buffer (server's response) size_t rbPos; char readBuffer[MAXMSGLEN]; - BOOL bound; + BOOL bound; // Already bound to server? BOOL dynamic; - //unsigned long messageId; // ID of message currently being received + BOOL sslConnected; + BOOL kill; // Should the connection be killed? + BOOL writeBlocked; // An SSL_write returned WANT_*, so we must not reallocate the current send buffer time_t lastActive; server_t *serverData; } epoll_server_t; +/** + * Configuration data for an ADS we're proxying. + */ struct _server_t_ { size_t baseLen; char ip[4]; @@ -77,6 +97,9 @@ struct _server_t_ { char base[BASELEN]; char sid[SIDLEN]; char homeTemplate[MOUNTLEN]; + unsigned char fingerprint[FINGERPRINTLEN]; + uint16_t port; + SSL_CTX *sslContext; epoll_server_t con; }; -- cgit v1.2.3-55-g7522