struct IODescriptor;
struct IOEvent;
+struct IOSSLNode;
#define IOHANDLER_CALLBACK(NAME) void NAME(UNUSED_ARG(struct IOEvent *io_event))
typedef IOHANDLER_CALLBACK(iohandler_callback);
IO_CLOSED, /* descriptor is dead (socket waiting for removal or timer) */
IO_LISTENING, /* descriptor is waiting for connections (server socket) */
IO_CONNECTING, /* descriptor is waiting for connection approval (connecting client socket) */
- IO_CONNECTED /* descriptor is connected (connected client socket) */
+ IO_CONNECTED, /* descriptor is connected (connected client socket) */
+ IO_SSLWAIT /* waiting for SSL backend (e.g. handshake) */
};
enum IOEventType {
IOEVENT_NOTCONNECTED, /* client socket could not connect (errid valid) */
IOEVENT_CLOSED, /* client socket lost connection (errid valid) */
IOEVENT_ACCEPT, /* server socket accepted new connection (accept_fd valid) */
- IOEVENT_TIMEOUT /* timer timed out */
+ IOEVENT_TIMEOUT, /* timer timed out */
+ IOEVENT_SSLFAILED /* failed to initialize SSL session */
};
struct IOBuffer {
struct IOBuffer writebuf;
void *data;
int read_lines : 1;
+ int ssl : 1;
+ int ssl_active : 1;
+ int ssl_hs_read : 1;
+ int ssl_hs_write : 1;
+ struct IOSSLNode *sslnode;
struct IODescriptor *next, *prev;
};
} data;
};
-struct IODescriptor *iohandler_add(int sockfd, enum IOType type, iohandler_callback *callback);
+struct IODescriptor *iohandler_add(int sockfd, enum IOType type, struct timeval *timeout, iohandler_callback *callback);
struct IODescriptor *iohandler_timer(struct timeval timeout, iohandler_callback *callback);
-struct IODescriptor *iohandler_connect(const char *hostname, unsigned int port, const char *bind, iohandler_callback *callback);
+struct IODescriptor *iohandler_connect(const char *hostname, unsigned int port, int ssl, const char *bind, iohandler_callback *callback);
struct IODescriptor *iohandler_listen(const char *hostname, unsigned int port, iohandler_callback *callback);
void iohandler_write(struct IODescriptor *iofd, const char *line);
void iohandler_send(struct IODescriptor *iofd, const char *data, size_t datalen);
void iohandler_printf(struct IODescriptor *iofd, const char *text, ...);
void iohandler_close(struct IODescriptor *iofd);
void iohandler_update(struct IODescriptor *iofd);
+void iohandler_set_timeout(struct IODescriptor *iofd, struct timeval *timeout);
void iohandler_poll();