From: David Woodhouse Date: Thu, 2 Oct 2008 07:55:32 +0000 (+0100) Subject: header in pkt for ssl too X-Git-Tag: v0.91~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99b37d66127b7e7b541075eae1d9186a88487a7a;p=platform%2Fupstream%2Fopenconnect.git header in pkt for ssl too --- diff --git a/ssl.c b/ssl.c index 573a352..43a672d 100644 --- a/ssl.c +++ b/ssl.c @@ -512,7 +512,12 @@ static int inflate_and_queue_packet(struct anyconnect_info *vpninfo, int type, v * 0008: data payload */ -static char data_hdr[8] = {'S', 'T', 'F', 1, 0, 0, 0, 0}; +static char data_hdr[8] = { + 'S', 'T', 'F', 1, + 0, 0, /* Length */ + AC_PKT_DATA, /* Type */ + 0 /* Unknown */ +}; int ssl_mainloop(struct anyconnect_info *vpninfo, int *timeout) { @@ -585,14 +590,14 @@ int ssl_mainloop(struct anyconnect_info *vpninfo, int *timeout) /* Don't send data over SSL if we have DTLS */ while (vpninfo->dtls_fd == -1 && vpninfo->outgoing_queue) { struct pkt *this = vpninfo->outgoing_queue; - char buf[2048]; - - memcpy(buf, data_hdr, 8); - vpninfo->outgoing_queue = this->next; if (vpninfo->deflate) { + char buf[2048]; int ret; + + memcpy(buf, data_hdr, 8); + vpninfo->deflate_strm.next_in = this->data; vpninfo->deflate_strm.avail_in = this->len; vpninfo->deflate_strm.next_out = (void *)buf + 8; @@ -605,7 +610,7 @@ int ssl_mainloop(struct anyconnect_info *vpninfo, int *timeout) goto uncompr; } - buf[6] = 8; + buf[6] = AC_PKT_COMPRESSED; buf[4] = (vpninfo->deflate_strm.total_out + 4) >> 8; buf[5] = (vpninfo->deflate_strm.total_out + 4) & 0xff; @@ -626,10 +631,11 @@ int ssl_mainloop(struct anyconnect_info *vpninfo, int *timeout) } } else { uncompr: - buf[4] = this->len >> 8; - buf[5] = this->len & 0xff; - memcpy(buf + 8, this->data, this->len); - SSL_write(vpninfo->https_ssl, buf, this->len + 8); + memcpy(this->hdr, data_hdr, 8); + this->hdr[4] = this->len >> 8; + this->hdr[5] = this->len & 0xff; + + SSL_write(vpninfo->https_ssl, this->hdr, this->len + 8); if (verbose) { printf("Sent uncompressed data packet of %d bytes\n", this->len);