From 38a1931a85a4313de25affbe93627d1aaa296fee Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 11 May 2020 15:34:34 -0700 Subject: [PATCH] =?utf8?q?oncp=5Fcontrol=5Fqueue=20=E2=86=92=20tcp=5Fcontr?= =?utf8?q?ol=5Fqueue?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is a queue for outgoing packets which must be sent over the TCP-based transport; that is, they cannot be sent over the UDP-based transport. This queue was initially used by oNCP protocol for ESP enable/disable packets, and it is now also used by Pulse. It will likely be used for control packets by some PPP-based protocols as well. Renaming it to TCP control queue to emphasize its cross-protocol nature (cf. https://gitlab.com/openconnect/openconnect/-/merge_requests/151). Signed-off-by: Daniel Lenski --- esp.c | 2 +- library.c | 2 +- mainloop.c | 4 ++-- oncp.c | 6 +++--- openconnect-internal.h | 2 +- pulse.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/esp.c b/esp.c index b25a468a..03f38343 100644 --- a/esp.c +++ b/esp.c @@ -320,7 +320,7 @@ int esp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) store_be32(&this->pulse.vendor, 0xa4c); store_be32(&this->pulse.type, 4); store_be32(&this->pulse.len, this->len + 16); - queue_packet(&vpninfo->oncp_control_queue, this); + queue_packet(&vpninfo->tcp_control_queue, this); work_done = 1; continue; } diff --git a/library.c b/library.c index e6d27184..fe21dcde 100644 --- a/library.c +++ b/library.c @@ -71,7 +71,7 @@ struct openconnect_info *openconnect_vpninfo_new(const char *useragent, #endif init_pkt_queue(&vpninfo->incoming_queue); init_pkt_queue(&vpninfo->outgoing_queue); - init_pkt_queue(&vpninfo->oncp_control_queue); + init_pkt_queue(&vpninfo->tcp_control_queue); vpninfo->dtls_tos_current = 0; vpninfo->dtls_pass_tos = 0; vpninfo->ssl_fd = vpninfo->dtls_fd = -1; diff --git a/mainloop.c b/mainloop.c index 2c1ce94e..b8f401f8 100644 --- a/mainloop.c +++ b/mainloop.c @@ -80,7 +80,7 @@ int tun_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) work_done = 1; if (queue_packet(&vpninfo->outgoing_queue, out_pkt) + - vpninfo->oncp_control_queue.count >= vpninfo->max_qlen) { + vpninfo->tcp_control_queue.count >= vpninfo->max_qlen) { out_pkt = NULL; unmonitor_read_fd(vpninfo, tun); break; @@ -88,7 +88,7 @@ int tun_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) out_pkt = NULL; } vpninfo->tun_pkt = out_pkt; - } else if (vpninfo->outgoing_queue.count + vpninfo->oncp_control_queue.count < vpninfo->max_qlen) { + } else if (vpninfo->outgoing_queue.count + vpninfo->tcp_control_queue.count < vpninfo->max_qlen) { monitor_read_fd(vpninfo, tun); } diff --git a/oncp.c b/oncp.c index 188fd68c..7e8feac3 100644 --- a/oncp.c +++ b/oncp.c @@ -443,7 +443,7 @@ static int queue_esp_control(struct openconnect_info *vpninfo, int enable) memcpy(new, &esp_enable_pkt, sizeof(*new) + 13); new->data[12] = enable; - queue_packet(&vpninfo->oncp_control_queue, new); + queue_packet(&vpninfo->tcp_control_queue, new); return 0; } @@ -815,7 +815,7 @@ static int oncp_receive_espkeys(struct openconnect_info *vpninfo, int len) store_le16(vpninfo->cstp_pkt->oncp.rec, (p - vpninfo->cstp_pkt->oncp.kmp)); - queue_packet(&vpninfo->oncp_control_queue, vpninfo->cstp_pkt); + queue_packet(&vpninfo->tcp_control_queue, vpninfo->cstp_pkt); vpninfo->cstp_pkt = NULL; print_esp_keys(vpninfo, _("new incoming"), esp); @@ -1224,7 +1224,7 @@ int oncp_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) goto handle_outgoing; } - vpninfo->current_ssl_pkt = dequeue_packet(&vpninfo->oncp_control_queue); + vpninfo->current_ssl_pkt = dequeue_packet(&vpninfo->tcp_control_queue); if (vpninfo->current_ssl_pkt) goto handle_outgoing; diff --git a/openconnect-internal.h b/openconnect-internal.h index 2f5e9e63..04776bdb 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -557,7 +557,6 @@ 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 */ - struct pkt_q oncp_control_queue; /* Control packets to be sent on oNCP next */ int oncp_rec_size; /* For packetising incoming oNCP stream */ /* Packet buffers for receiving into */ struct pkt *cstp_pkt; @@ -658,6 +657,7 @@ struct openconnect_info { struct pkt_q incoming_queue; struct pkt_q outgoing_queue; + struct pkt_q tcp_control_queue; /* Control packets to be sent via TCP */ int max_qlen; struct oc_stats stats; openconnect_stats_vfn stats_handler; diff --git a/pulse.c b/pulse.c index fbe62c76..c07b21b5 100644 --- a/pulse.c +++ b/pulse.c @@ -2701,7 +2701,7 @@ int pulse_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) } vpninfo->cstp_pkt = NULL; pkt->len = load_be32(&pkt->pulse.len) - 16; - queue_packet(&vpninfo->oncp_control_queue, pkt); + queue_packet(&vpninfo->tcp_control_queue, pkt); print_esp_keys(vpninfo, _("new incoming"), &vpninfo->esp_in[vpninfo->current_esp_in]); print_esp_keys(vpninfo, _("new outgoing"), &vpninfo->esp_out); @@ -2878,7 +2878,7 @@ int pulse_mainloop(struct openconnect_info *vpninfo, int *timeout, int readable) work_done = 1; } - vpninfo->current_ssl_pkt = dequeue_packet(&vpninfo->oncp_control_queue); + vpninfo->current_ssl_pkt = dequeue_packet(&vpninfo->tcp_control_queue); if (vpninfo->current_ssl_pkt) { /* Anything on the control queue will have the rest of its header filled in already. */ -- 2.49.0