Skip to content

Commit

Permalink
Move DTLS reconnect handling into dtls.c
Browse files Browse the repository at this point in the history
There's no good reason for this to be in mainloop.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 11, 2014
1 parent 65f8c5d commit 958c87f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
12 changes: 12 additions & 0 deletions dtls.c
Expand Up @@ -666,6 +666,18 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout)
int work_done = 0;
char magic_pkt;

if (vpninfo->new_dtls_ssl)
dtls_try_handshake(vpninfo);

if (vpninfo->dtls_attempt_period && !vpninfo->dtls_ssl && !vpninfo->new_dtls_ssl &&
vpninfo->new_dtls_started + vpninfo->dtls_attempt_period < time(NULL) &&
vpninfo->ssl_fd != -1) {
vpn_progress(vpninfo, PRG_TRACE, _("Attempt new DTLS connection\n"));
connect_dtls_socket(vpninfo);
}
if (!vpninfo->dtls_ssl)
return 0;

while (1) {
int len = vpninfo->ip_info.mtu;
unsigned char *buf;
Expand Down
17 changes: 3 additions & 14 deletions mainloop.c
Expand Up @@ -74,22 +74,11 @@ int openconnect_mainloop(struct openconnect_info *vpninfo,
fd_set rfds, wfds, efds;

#ifdef HAVE_DTLS
if (vpninfo->new_dtls_ssl)
dtls_try_handshake(vpninfo);

if (vpninfo->dtls_attempt_period && !vpninfo->dtls_ssl && !vpninfo->new_dtls_ssl &&
vpninfo->new_dtls_started + vpninfo->dtls_attempt_period < time(NULL) &&
vpninfo->ssl_fd != -1) {
vpn_progress(vpninfo, PRG_TRACE, _("Attempt new DTLS connection\n"));
connect_dtls_socket(vpninfo);
}
if (vpninfo->dtls_ssl) {
ret = dtls_mainloop(vpninfo, &timeout);
did_work += ret;
}
#endif
ret = dtls_mainloop(vpninfo, &timeout);
if (vpninfo->quit_reason)
break;
did_work += ret;
#endif

ret = cstp_mainloop(vpninfo, &timeout);
if (vpninfo->quit_reason)
Expand Down

0 comments on commit 958c87f

Please sign in to comment.