header in pkt
authorDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 2 Oct 2008 07:55:22 +0000 (08:55 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 2 Oct 2008 07:55:22 +0000 (08:55 +0100)
anyconnect.h
dtls.c

index fb3396c..8d41a17 100644 (file)
@@ -28,6 +28,7 @@ struct pkt {
        int type;
        int len;
        struct pkt *next;
+       unsigned char hdr[8];
        unsigned char data[];
 };
        
diff --git a/dtls.c b/dtls.c
index 0acd7bb..6e3497f 100644 (file)
--- a/dtls.c
+++ b/dtls.c
@@ -284,10 +284,13 @@ int dtls_mainloop(struct anyconnect_info *vpninfo, int *timeout)
 
                vpninfo->outgoing_queue = this->next;
 
-               buf[0] = 0;
-               memcpy(buf + 1, this->data, this->len);
+               /* One byte of header */
+               this->hdr[7] = AC_PKT_DATA;
                
-               ret = SSL_write(vpninfo->dtls_ssl, buf, this->len + 1);
+               ret = SSL_write(vpninfo->dtls_ssl, &this->hdr[7], this->len + 1);
+               /* There's not a lot we can do if the write fails. If the link is
+                  really dead, DPD will kick in and we should fall back to SSL,
+                  if that's still working */
                vpninfo->last_dtls_tx = time(NULL);
                if (verbose) {
                        printf("Sent DTLS packet of %d bytes; SSL_write() returned %d\n",