aboutsummaryrefslogtreecommitdiff
path: root/src/common/tortls.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-01-15 21:21:05 +0000
committerNick Mathewson <nickm@torproject.org>2007-01-15 21:21:05 +0000
commit380f8983c7e32dd26e8746f6cf75d12d08f962f7 (patch)
tree128c9c6149c3c173f9e12450b56cb7237eb2846d /src/common/tortls.h
parentead35ef9440a4d20a559441b2c6779954d3c02d5 (diff)
downloadtor-380f8983c7e32dd26e8746f6cf75d12d08f962f7.tar
tor-380f8983c7e32dd26e8746f6cf75d12d08f962f7.tar.gz
r11966@Kushana: nickm | 2007-01-15 16:12:17 -0500
Tidy up ORCONN reason patch from Mike Perry. Changes: make some of the handling of TLS error codes less error prone. Enforce house style wrt spaces. Make it compile with --enable-gcc-warnings. Only set or_conn->tls_error in the case of an actual error. Add a changelog entry. svn:r9355
Diffstat (limited to 'src/common/tortls.h')
-rw-r--r--src/common/tortls.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/tortls.h b/src/common/tortls.h
index 5a6631dd5..e2b738da4 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -19,6 +19,7 @@
typedef struct tor_tls_t tor_tls_t;
/* Possible return values for most tor_tls_* functions. */
+#define _MIN_TOR_TLS_ERROR_VAL -9
#define TOR_TLS_ERROR_MISC -9
#define TOR_TLS_ERROR_IO -8
#define TOR_TLS_ERROR_CONNREFUSED -7
@@ -30,6 +31,18 @@ typedef struct tor_tls_t tor_tls_t;
#define TOR_TLS_WANTWRITE -1
#define TOR_TLS_DONE 0
+/* Use this macro in a switch statement to catch _any_ TLS error. That way,
+ * if more errors are added, your switches will still work. */
+#define CASE_TOR_TLS_ERROR_ANY \
+ case TOR_TLS_ERROR_MISC: \
+ case TOR_TLS_ERROR_IO: \
+ case TOR_TLS_ERROR_CONNREFUSED: \
+ case TOR_TLS_ERROR_CONNRESET: \
+ case TOR_TLS_ERROR_NO_ROUTE: \
+ case TOR_TLS_ERROR_TIMEOUT
+
+#define TOR_TLS_IS_ERROR(rv) ((rv) < TOR_TLS_CLOSE)
+
void tor_tls_free_all(void);
int tor_tls_context_new(crypto_pk_env_t *rsa,
const char *nickname, unsigned int key_lifetime);