From 9912cc10fe454bda2933b9e5679f75478dcfdc61 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 14 Nov 2019 20:59:51 +0100 Subject: [PATCH] Added the ability to pause and resume the network thread's reception. --- src/network/net_pcap.c | 9 ++++++--- src/network/net_slirp.c | 6 +++--- src/network/network.c | 12 ++++++++++-- src/network/network.h | 7 +++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 60d2b07a4..e704d1b00 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -8,11 +8,11 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.9 2018/10/19 + * Version: @(#)net_pcap.c 1.0.10 2019/11/14 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -185,7 +185,10 @@ poll_thread(void *arg) if (pcap == NULL) break; /* Wait for the next packet to arrive. */ - data = (uint8_t *)f_pcap_next((void *)pcap, &h); + if (network_wait) + data = NULL; + else + data = (uint8_t *)f_pcap_next((void *)pcap, &h); if (data != NULL) { // ui_sb_update_icon(SB_NETWORK, 1); diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index ec7bb1b09..a726d133d 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -8,11 +8,11 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.8 2018/10/19 + * Version: @(#)net_slirp.c 1.0.9 2019/11/14 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -148,7 +148,7 @@ poll_thread(void *arg) /* Wait for the next packet to arrive. */ data_valid = 0; - if (QueuePeek(slirpq) != 0) { + if (!network_wait && (QueuePeek(slirpq) != 0)) { /* Grab a packet from the queue. */ // ui_sb_update_icon(SB_NETWORK, 1); diff --git a/src/network/network.c b/src/network/network.c index 0db312a39..a36d64b9d 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -12,11 +12,11 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network.c 1.0.10 2018/11/18 + * Version: @(#)network.c 1.0.11 2019/11/14 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -99,6 +99,7 @@ static netcard_t net_cards[] = { int network_type; int network_ndev; int network_card; +volatile int network_wait; char network_host[522]; netdev_t network_devs[32]; #ifdef ENABLE_NIC_LOG @@ -442,3 +443,10 @@ network_card_get_from_internal_name(char *s) return(-1); } + + +void +network_set_wait(int wait) +{ + network_wait = wait; +} diff --git a/src/network/network.h b/src/network/network.h index bdd4beb54..e5c72ce5e 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -8,11 +8,11 @@ * * Definitions for the network module. * - * Version: @(#)network.h 1.0.2 2018/03/15 + * Version: @(#)network.h 1.0.3 2019/11/14 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -89,6 +89,7 @@ extern "C" { /* Global variables. */ extern int nic_do_log; /* config */ extern int network_ndev; +extern volatile int network_wait; extern netdev_t network_devs[32]; @@ -124,6 +125,8 @@ extern char *network_card_get_internal_name(int); extern int network_card_get_from_internal_name(char *); extern const device_t *network_card_getdevice(int); +extern void network_set_wait(int wait); + #ifdef __cplusplus } #endif