From 936763ade224c377837516230dd2e3b520a8efaa Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 2 Dec 2019 19:01:01 +0100 Subject: removed superfluous if statement Signed-off-by: Toni Uhlig --- src/pkt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkt.c b/src/pkt.c index 3b58b8a..339eb51 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -385,8 +385,9 @@ void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int cur->recv_wait_send++; cur->recv_idx++; } - else if (cur->recv_ring[cur->recv_idx]) + else { pt_log(kLog_debug, "Dup packet?\n"); + } cur->next_remote_seq++; if (cur->recv_idx >= cur->window_size) -- cgit v1.2.3 From 32ab6ecdc0082479744a7c0bec4e138fd69c177f Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 3 Dec 2019 23:32:03 +0100 Subject: fixed missing challenge response memcpy Signed-off-by: Toni Uhlig --- src/pkt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pkt.c b/src/pkt.c index 339eb51..0dae386 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -241,6 +241,7 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a generate_response_md5(&challenge->plain, &challenge->digest); } + memcpy(cur->buf, challenge, sizeof(challenge_t)); queue_packet(icmp_sock, cur, cur->buf, sizeof(challenge_t), 0, 0, kProto_authenticate | cur->type_flag); /* We have authenticated locally. -- cgit v1.2.3 From 9af622e80841e3c5d56006801f47ce9062cf488d Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 3 Dec 2019 23:35:08 +0100 Subject: fixed missing variable initialize - before used in condition Signed-off-by: Toni Uhlig --- src/options.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/options.c b/src/options.c index ee8e249..69d842c 100644 --- a/src/options.c +++ b/src/options.c @@ -323,6 +323,7 @@ static void print_multiline(const char *prefix, const char *multiline) { const char *start, *end; start = multiline; + end = NULL; do { if (start) { end = strstr(start, sep); -- cgit v1.2.3 From eb00e46daf4c41764c005fc35245a67d116d3aae Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 3 Dec 2019 23:37:49 +0100 Subject: reduced function signature and removed dead code in acknowledge handling Signed-off-by: Toni Uhlig --- src/pkt.c | 84 +++++++++++++++++---------------------------------------------- src/pkt.h | 4 +-- 2 files changed, 24 insertions(+), 64 deletions(-) diff --git a/src/pkt.c b/src/pkt.c index 0dae386..485ed72 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -315,9 +315,7 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a } handle_data(pkt, bytes, cur, 0); } - handle_ack((uint16_t)pt_pkt->ack, cur->send_ring, &cur->send_wait_ack, - 0, cur->send_idx, &cur->send_first_ack, &cur->remote_ack_val, - is_pcap, cur->window_size); + handle_ack((uint16_t)pt_pkt->ack, cur); cur->last_activity = now; } } @@ -463,68 +461,32 @@ void handle_extended_options(proxy_desc_t *cur) } } -void handle_ack(uint16_t seq_no, icmp_desc_t ring[], int *packets_awaiting_ack, - int one_ack_only, int insert_idx, int *first_ack, - uint16_t *remote_ack, int is_pcap, uint16_t window_size) +void handle_ack(uint16_t seq_no, proxy_desc_t *cur) { - int i, j, k; - ping_tunnel_pkt_t *pt_pkt; + if (cur->send_wait_ack > 0) { + int i, can_ack = 0, count = 0; + i = cur->send_idx - 1; + if (i < 0) + i = cur->window_size - 1; - if (*packets_awaiting_ack > 0) { - if (one_ack_only) { - for (i = 0; i < window_size; i++) { - if (ring[i].pkt && ring[i].seq_no == seq_no && !is_pcap) { - pt_log(kLog_debug, "Received ack for only seq %d\n", seq_no); - pt_pkt = (ping_tunnel_pkt_t*)ring[i].pkt->data; - /* WARNING: We make the dangerous assumption here that packets arrive in order! */ - *remote_ack = (uint16_t) ntohl(pt_pkt->ack); - free(ring[i].pkt); - ring[i].pkt = 0; - ring[i].pkt_len = 0; - (*packets_awaiting_ack)--; - if (i == *first_ack) { - for (j = 1; j < window_size; j += 2) { - k = (i + j) % window_size; - if (ring[k].pkt) { - *first_ack = k; - break; - } - /* we have looped through everything */ - if (k == i) - *first_ack = insert_idx; - } - } - return; - } + pt_log(kLog_debug, "Received ack-series starting at seq %d\n", seq_no); + while (count < cur->window_size) { + if (!cur->send_ring[i].pkt) + break; + if (cur->send_ring[i].seq_no == seq_no) + can_ack = 1; + else if (!can_ack) + cur->send_first_ack = i; + if (can_ack) { + free(cur->send_ring[i].pkt); + cur->send_ring[i].pkt = 0; + cur->send_ring[i].pkt_len = 0; + cur->send_wait_ack--; } - } - else { - int i, can_ack = 0, count = 0; - i = insert_idx-1; + i--; if (i < 0) - i = window_size - 1; - - pt_log(kLog_debug, "Received ack-series starting at seq %d\n", seq_no); - while (count < window_size) { - if (!ring[i].pkt) - break; - - if (ring[i].seq_no == seq_no) - can_ack = 1; - else if (!can_ack) - *first_ack = i; - - if (can_ack) { - free(ring[i].pkt); - ring[i].pkt = 0; - ring[i].pkt_len = 0; - (*packets_awaiting_ack)--; - } - i--; - if (i < 0) - i = window_size - 1; - count++; - } + i = cur->window_size - 1; + count++; } } else { diff --git a/src/pkt.h b/src/pkt.h index 0b7ee65..c400aed 100644 --- a/src/pkt.h +++ b/src/pkt.h @@ -142,8 +142,6 @@ void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int void handle_extended_options(proxy_desc_t *cur); -void handle_ack(uint16_t seq_no, icmp_desc_t *ring, int *packets_awaiting_ack, - int one_ack_only, int insert_idx, int *first_ack, - uint16_t *remote_ack, int is_pcap, uint16_t window_size); +void handle_ack(uint16_t seq_no, proxy_desc_t *cur); #endif -- cgit v1.2.3 From a3d99b2774bb37061f247535945573bd0f218230 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 4 Dec 2019 19:35:50 +0100 Subject: log at least an info message if our receive window is not big enough Signed-off-by: Toni Uhlig --- src/pkt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pkt.c b/src/pkt.c index 485ed72..11570f0 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -416,8 +416,9 @@ void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int pos = (cur->recv_idx + d) % cur->window_size; } } - else if (cur->window_size && d < cur->window_size) + else if (cur->window_size && d < cur->window_size) { pos = (cur->recv_idx + d) % cur->window_size; + } if (pos != -1) { if (!cur->recv_ring[pos]) { @@ -428,9 +429,9 @@ void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int cur->recv_wait_send++; } } - /* else - * pt_log(kLog_debug, "Packet discarded - outside receive window.\n"); - */ + else { + pt_log(kLog_info, "Packet discarded - outside receive window.\n"); + } } } -- cgit v1.2.3 From 79ab49285ecf23a7b1e5179e5b4cd59ee58bb282 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Thu, 5 Dec 2019 19:28:23 +0100 Subject: removed superfluous explicit numeric casts Signed-off-by: Toni Uhlig --- src/pkt.c | 7 ++++--- src/pkt.h | 2 +- src/ptunnel.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pkt.c b/src/pkt.c index 11570f0..5f6583b 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -122,8 +122,9 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a if (!is_pcap) cur->xfer.icmp_in++; } - else + else { type_flag = kProxy_flag; + } pkt_flag = pt_pkt->state & kFlag_mask; pt_pkt->state &= ~kFlag_mask; @@ -315,7 +316,7 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a } handle_data(pkt, bytes, cur, 0); } - handle_ack((uint16_t)pt_pkt->ack, cur); + handle_ack(pt_pkt->ack, cur); cur->last_activity = now; } } @@ -462,7 +463,7 @@ void handle_extended_options(proxy_desc_t *cur) } } -void handle_ack(uint16_t seq_no, proxy_desc_t *cur) +void handle_ack(uint32_t seq_no, proxy_desc_t *cur) { if (cur->send_wait_ack > 0) { int i, can_ack = 0, count = 0; diff --git a/src/pkt.h b/src/pkt.h index c400aed..1c59932 100644 --- a/src/pkt.h +++ b/src/pkt.h @@ -142,6 +142,6 @@ void handle_data(icmp_echo_packet_t *pkt, int total_len, proxy_desc_t *cur, int void handle_extended_options(proxy_desc_t *cur); -void handle_ack(uint16_t seq_no, proxy_desc_t *cur); +void handle_ack(uint32_t seq_no, proxy_desc_t *cur); #endif diff --git a/src/ptunnel.c b/src/ptunnel.c index dde63d3..a8c0a40 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -385,7 +385,7 @@ void pt_forwarder(void) { } } addr = dest_addr; - rand_id = (uint16_t) pt_random(); + rand_id = pt_random(); create_and_insert_proxy_desc(rand_id, rand_id, new_sock, &addr, opts.given_dst_ip, opts.given_dst_port, kProxy_start, kUser_flag); pthread_mutex_unlock(&num_threads_lock); } -- cgit v1.2.3 From 057bcf9b019c9aaec332d4a44eab93a991731a9a Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 5 Jan 2020 18:53:12 +0100 Subject: gitlab-ci: switched from finalduty/archlinux to archlinux/base docker container Signed-off-by: Toni Uhlig --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6bb6ce6..873d889 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ build-debian: when: always build-archlinux: - image: finalduty/archlinux:daily + image: archlinux/base:latest script: - useradd builduser -m - passwd -d builduser -- cgit v1.2.3