diff th_network.h @ 132:11fa2bf90251

Network API changes due to preparation for fixes in proxy support.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 04 Jul 2014 02:18:26 +0300
parents aa2d608fb3f3
children 51eec969b07a
line wrap: on
line diff
--- a/th_network.h	Mon Jun 23 16:59:36 2014 +0300
+++ b/th_network.h	Fri Jul 04 02:18:26 2014 +0300
@@ -85,20 +85,8 @@
 };
 
 
-typedef struct _th_conn_t
+typedef struct _th_base_conn_t
 {
-    // Proxy settings and data
-    struct
-    {
-        char *host;
-        struct hostent *hst;
-        int type, auth_type;
-        int port;
-        struct in_addr addr;
-        char *userid, *passwd;
-        int mode, addr_type;
-    } proxy;
-
     // Target host data
     char *host;
     struct hostent *hst;
@@ -109,17 +97,35 @@
     struct in_addr addr;
     fd_set sockfds;
 
+    // Data buffer
+    char *buf, *ptr, *in_ptr;
+    ssize_t bufsize, got_bytes, total_bytes;
+
+} th_base_conn_t;
+
+
+typedef struct _th_conn_t
+{
+    // Connection
+    th_base_conn_t base;
+
+    // Proxy settings and data
+    struct
+    {
+        th_base_conn_t conn;
+        int type, auth_type;
+        int mode, addr_type;
+        char *userid, *passwd;
+    } proxy;
+
+    // Status
+    int err;
+    int status;
+
     // Error handling and status message functors
     void (*errfunc)(struct _th_conn_t *conn, int err, const char *msg);
     void (*msgfunc)(struct _th_conn_t *conn, int loglevel, const char *msg);
 
-    int err;
-    int status;
-
-    // Data buffer
-    char *buf, *ptr, *in_ptr;
-    ssize_t bufsize, got_bytes, total_bytes;
-
     void *node;
 } th_conn_t;
 
@@ -140,6 +146,7 @@
 int         th_conn_set_proxy_mode(th_conn_t *conn, const int mode);
 int         th_conn_set_proxy_addr_type(th_conn_t *conn, const int atype);
 int         th_conn_set_proxy_auth_user(th_conn_t *conn, const char *userid, const char *passwd);
+
 int         th_conn_open(th_conn_t *conn, const int port, const char *host);
 int         th_conn_close(th_conn_t *);
 void        th_conn_free(th_conn_t *);