]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Rename oncp_rec_size → partial_rec_size
authorDaniel Lenski <dlenski@gmail.com>
Tue, 8 Jun 2021 18:13:39 +0000 (11:13 -0700)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 8 Jun 2021 20:32:08 +0000 (21:32 +0100)
This variable is used to track the size of partially-received tunnel packets
across mainloop invocations.

It was intially used by the oNCP protocol, where tunneled packets can be
split across TLS records.  We're now going to use it to deal with an
extremely similar mis-layering of packetisation for PPP-based protocols
as well.

Renaming it to partial_rec_size to emphasize its cross-protocol nature (cf.
https://gitlab.com/openconnect/openconnect/-/merge_requests/151).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
oncp.c
openconnect-internal.h

diff --git a/oncp.c b/oncp.c
index f1fc0b5f6fd883c00d34389e801f9b9f30daa23e..1c90918dd3cb7b1a5d9ac2693cac59051ca2b2fe 100644 (file)
--- a/oncp.c
+++ b/oncp.c
@@ -729,7 +729,7 @@ int oncp_connect(struct openconnect_info *vpninfo)
        }
        buf_free(reqbuf);
 
-       vpninfo->oncp_rec_size = 0;
+       vpninfo->partial_rec_size = 0;
        free(vpninfo->cstp_pkt);
        vpninfo->cstp_pkt = NULL;
 
@@ -780,7 +780,7 @@ static int oncp_record_read(struct openconnect_info *vpninfo, void *buf, int len
 {
        int ret;
 
-       if (!vpninfo->oncp_rec_size) {
+       if (!vpninfo->partial_rec_size) {
                unsigned char lenbuf[2];
 
                ret = ssl_nonblock_read(vpninfo, 0, lenbuf, 2);
@@ -793,8 +793,8 @@ static int oncp_record_read(struct openconnect_info *vpninfo, void *buf, int len
                                     _("Read only 1 byte of oNCP length field\n"));
                        return -EIO;
                }
-               vpninfo->oncp_rec_size = load_le16(lenbuf);
-               if (!vpninfo->oncp_rec_size) {
+               vpninfo->partial_rec_size = load_le16(lenbuf);
+               if (!vpninfo->partial_rec_size) {
                        ret = ssl_nonblock_read(vpninfo, 0, lenbuf, 1);
                        if (ret == 1) {
                                if (lenbuf[0] == 1) {
@@ -820,12 +820,12 @@ static int oncp_record_read(struct openconnect_info *vpninfo, void *buf, int len
                        }
                }
        }
-       if (len > vpninfo->oncp_rec_size)
-               len = vpninfo->oncp_rec_size;
+       if (len > vpninfo->partial_rec_size)
+               len = vpninfo->partial_rec_size;
 
        ret = ssl_nonblock_read(vpninfo, 0, buf, len);
        if (ret > 0)
-               vpninfo->oncp_rec_size -= ret;
+               vpninfo->partial_rec_size -= ret;
        return ret;
 }
 
index 7e57118581d95c9c7c8e287a6095e5b863c2abb9..34715a5916d647dd2292489f2aed44fa7ac174d8 100644 (file)
@@ -620,7 +620,7 @@ struct openconnect_info {
        struct pkt *deflate_pkt;                /* For compressing outbound packets into */
        struct pkt *pending_deflated_pkt;       /* The original packet associated with above */
        struct pkt *current_ssl_pkt;            /* Partially sent SSL packet */
-       int oncp_rec_size;                      /* For packetising incoming oNCP stream */
+       int partial_rec_size;                   /* For tracking partially-received packets */
        /* Packet buffers for receiving into */
        struct pkt *cstp_pkt;
        struct pkt *dtls_pkt;