Kill dtls_state, fix --no-dtls
authorDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 7 Oct 2008 12:53:11 +0000 (13:53 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 7 Oct 2008 12:53:11 +0000 (13:53 +0100)
dtls.c
main.c
mainloop.c
openconnect.h

diff --git a/dtls.c b/dtls.c
index 655a6bc..f291e1b 100644 (file)
--- a/dtls.c
+++ b/dtls.c
@@ -205,8 +205,6 @@ int dtls_try_handshake(struct openconnect_info *vpninfo)
        if (ret == 1) {
                vpninfo->progress(vpninfo, PRG_INFO, "Established DTLS connection\n");
 
-               vpninfo->dtls_state = DTLS_RUNNING;
-
                if (vpninfo->dtls_ssl) {
                        /* We are replacing an old connection */
                        SSL_free(vpninfo->dtls_ssl);
diff --git a/main.c b/main.c
index e5d4e5c..fb3e8a6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -160,7 +160,7 @@ int main(int argc, char **argv)
                        vpninfo->cafile = optarg;
                        break;
                case '1':
-                       vpninfo->dtls_state = DTLS_NEVER;
+                       vpninfo->dtls_attempt_period = 0;
                        break;
                case '2':
                        cookieonly = 1;
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       if (!vpninfo->dtls_state && setup_dtls(vpninfo))
+       if (vpninfo->dtls_attempt_period && setup_dtls(vpninfo))
                fprintf(stderr, "Set up DTLS failed; using SSL instead\n");
 
        printf("Connected %s as %s, using %s\n", vpninfo->ifname, vpninfo->vpn_addr,
index d8dd421..d892e85 100644 (file)
@@ -91,7 +91,7 @@ int vpn_mainloop(struct openconnect_info *vpninfo)
                if (vpninfo->new_dtls_ssl)
                        dtls_try_handshake(vpninfo);
 
-               if (!vpninfo->dtls_ssl && !vpninfo->new_dtls_ssl &&
+               if (vpninfo->dtls_attempt_period && !vpninfo->dtls_ssl && !vpninfo->new_dtls_ssl &&
                    vpninfo->new_dtls_started + vpninfo->dtls_attempt_period < time(NULL)) {
                        vpninfo->progress(vpninfo, PRG_TRACE, "Attempt new DTLS connection\n");
                        connect_dtls_socket(vpninfo);
index e883d46..2e9479a 100644 (file)
@@ -60,11 +60,6 @@ struct keepalive_info {
        time_t last_dpd;
 };
 
-#define DTLS_NEVER     -1
-#define DTLS_CLOSED    0
-#define DTLS_HANDSHAKE 1
-#define DTLS_RUNNING   2
-
 struct openconnect_info {
        char *redirect_url;
        
@@ -99,7 +94,6 @@ struct openconnect_info {
 
        int dtls_attempt_period;
        time_t new_dtls_started;
-       int dtls_state;
        SSL_CTX *dtls_ctx;
        SSL *dtls_ssl;
        SSL *new_dtls_ssl;