From cf83867f09b3258ce9a3f2ac169046af46eeccb5 Mon Sep 17 00:00:00 2001 From: "root@Bsd32.srh-uni-berlin.de" Date: Wed, 16 Mar 2016 14:34:24 +0000 Subject: [PATCH] Separated establishing of dtls connection. FossilOrigin-Name: c5f4d97816e785eef70020b65623cb70f550036bb41252ddedd5b50117834d6c --- src/ac/wtpman.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/ac/wtpman.c b/src/ac/wtpman.c index 53df04c3..c7826f12 100644 --- a/src/ac/wtpman.c +++ b/src/ac/wtpman.c @@ -378,22 +378,22 @@ static void wtpman_run(void *arg) /* reject connections to our multi- or broadcast sockets */ - if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET) { +/* if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET) { cw_dbg(DBG_DTLS, "Dropping connection from %s to non-unicast socket.", CLIENT_IP); wtpman_remove(wtpman); return; } - +*/ time_t timer = cw_timer_start(wtpman->conn->wait_dtls); /* establish dtls session */ - if (!wtpman_establish_dtls(wtpman)) { +/* if (!wtpman_establish_dtls(wtpman)) { wtpman_remove(wtpman); return; } - +*/ /* dtls is established, goto join state */ if (!wtpman_join(wtpman, timer)) { @@ -480,6 +480,38 @@ static void wtpman_run(void *arg) } +static void wtpman_run_dtls(void *arg) +{ + + struct wtpman *wtpman = (struct wtpman *) arg; + + + + /* reject connections to our multi- or broadcast sockets */ + if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET) { + cw_dbg(DBG_DTLS, "Dropping connection from %s to non-unicast socket.", + CLIENT_IP); + wtpman_remove(wtpman); + return; + } + + + time_t timer = cw_timer_start(wtpman->conn->wait_dtls); + + /* establish dtls session */ + if (!wtpman_establish_dtls(wtpman)) { + wtpman_remove(wtpman); + return; + } + + + + + wtpman_run(arg); +} + + + void wtpman_destroy(struct wtpman *wtpman) { if (wtpman->conn) @@ -620,12 +652,12 @@ void wtpman_start(struct wtpman *wtpman, int dtlsmode) if (dtlsmode) { cw_dbg(DBG_INFO, "Starting wtpman in DTLS mode"); - pthread_create(&wtpman->thread, NULL, (void *) &wtpman_run, + pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_dtls, (void *) wtpman); } else { cw_dbg(DBG_INFO, "Starting wtpman in non-dtls mode"); - pthread_create(&wtpman->thread, NULL, (void *) &wtpman_run_discovery, + pthread_create(&wtpman->thread, NULL, (void *) wtpman_run_discovery, (void *) wtpman); } }