added SSL backend for IOMultiplexer
[TransparentIRC.git] / src / IOHandler.h
index 76fb2cf82c89dd492352ea622a12f416e8065785..6d57ca541901329f2d485523279db163cc3f1078 100644 (file)
@@ -20,6 +20,7 @@
 
 struct IODescriptor;
 struct IOEvent;
+struct IOSSLNode;
 
 #define IOHANDLER_CALLBACK(NAME) void NAME(UNUSED_ARG(struct IOEvent *io_event))
 typedef IOHANDLER_CALLBACK(iohandler_callback);
@@ -36,7 +37,8 @@ enum IOStatus {
     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 {
@@ -47,7 +49,8 @@ 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 {
@@ -66,6 +69,10 @@ struct IODescriptor {
     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;
 };
@@ -83,7 +90,7 @@ struct IOEvent {
 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, int ssl, const char *bind, iohandler_callback *callback);
-struct IODescriptor *iohandler_listen(const char *hostname, unsigned int port, int ssl, 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, ...);