From 59572533adbcb70d3603a6bd87d8332d8863dc7f Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Tue, 8 Jun 2021 11:13:39 -0700 Subject: [PATCH] =?utf8?q?Rename=20oncp=5Frec=5Fsize=20=E2=86=92=20partial?= =?utf8?q?=5Frec=5Fsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: David Woodhouse --- oncp.c | 14 +++++++------- openconnect-internal.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/oncp.c b/oncp.c index f1fc0b5f..1c90918d 100644 --- 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; } diff --git a/openconnect-internal.h b/openconnect-internal.h index 7e571185..34715a59 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -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; -- 2.49.0