summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2013-01-24 17:31:49 +0100
committerLinus Nordberg <linus@nordberg.se>2013-02-18 16:39:16 +0100
commit214a29955b9c7a8eafc90997ee29f86a284e3a12 (patch)
tree09448898e08c1ee237a8adeeb4f57b9bb94970ac /lib
parent046bcd92b3eea69b61a6362e599d75fb912791eb (diff)
Add two helper functions to conn.[ch].
Diffstat (limited to 'lib')
-rw-r--r--lib/conn.c17
-rw-r--r--lib/conn.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/conn.c b/lib/conn.c
index 90f1e61..815784f 100644
--- a/lib/conn.c
+++ b/lib/conn.c
@@ -61,6 +61,23 @@ conn_activate_timeout (struct rs_connection *conn)
return RSE_OK;
}
+int
+conn_type_tls (const struct rs_connection *conn)
+{
+ assert (conn->active_peer);
+ return conn->realm->type == RS_CONN_TYPE_TLS
+ || conn->realm->type == RS_CONN_TYPE_DTLS;
+}
+
+int
+conn_cred_psk (const struct rs_connection *conn)
+{
+ assert (conn->active_peer);
+ return conn->active_peer->transport_cred &&
+ conn->active_peer->transport_cred->type == RS_CRED_TLS_PSK;
+}
+
+
/* Public functions. */
int
rs_conn_create (struct rs_context *ctx,
diff --git a/lib/conn.h b/lib/conn.h
index cf15b80..c538a8c 100644
--- a/lib/conn.h
+++ b/lib/conn.h
@@ -4,3 +4,5 @@
int conn_close (struct rs_connection **connp);
int conn_user_dispatch_p (const struct rs_connection *conn);
int conn_activate_timeout (struct rs_connection *conn);
+int conn_type_tls (const struct rs_connection *conn);
+int conn_cred_psk (const struct rs_connection *conn);