Merge pull request #1034 from richardg867/master

Small non-critical changes to networking
This commit is contained in:
Miran Grča
2020-10-18 13:51:19 +02:00
committed by GitHub
4 changed files with 30 additions and 6 deletions

View File

@@ -466,7 +466,7 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
if (func == 0) { /* PCI-ISA bridge */
/* Read-only addresses */
if ((addr < 4) || (addr == 5) || ((addr >= 8) && (addr < 0x40)) || (addr == 0x49) || (addr == 0x4b) ||
(addr == 0x53) || ((addr >= 0x5d) && (addr < 0x5f)) || ((addr >= 0x71) && (addr < 0x74)) || (addr >= 0x90))
(addr == 0x53) || ((addr >= 0x5d) && (addr < 0x5f)) || (addr >= 0x90))
return;
if ((dev->local <= VIA_PIPC_586A) && ((addr >= 0x58) && (addr < 0x80)))

View File

@@ -117,6 +117,8 @@ timeout_timer(void *priv)
dev->rx_pkt = NULL;
}
network_rx_pause = 0;
timer_disable(&dev->timeout_timer);
}

View File

@@ -331,7 +331,7 @@ poll_thread(void *arg)
char key[20];
while (1) {
sprintf(key, "%d_protocol", i);
udp = strncmp(config_get_string(category, key, "tcp"), "udp", -1) == 0;
udp = strcmp(config_get_string(category, key, "tcp"), "udp") == 0;
sprintf(key, "%d_external", i);
external = config_get_int(category, key, 0);
sprintf(key, "%d_internal", i);

View File

@@ -145,7 +145,8 @@ static struct {
#ifdef ENABLE_NETWORK_LOG
int network_do_log = ENABLE_NETWORK_LOG;
FILE *network_dump = NULL;
static FILE *network_dump = NULL;
static mutex_t *network_dump_mutex;
static void
@@ -175,9 +176,23 @@ network_dump_packet(netpkt_t *pkt)
tv.tv_sec, tv.tv_usec, pkt->len, pkt->len
};
fwrite(&pcap_packet_hdr, sizeof(pcap_packet_hdr), 1, network_dump);
fwrite(pkt->data, pkt->len, 1, network_dump);
fflush(network_dump);
if (network_dump_mutex)
thread_wait_mutex(network_dump_mutex);
size_t written;
if ((written = fwrite(&pcap_packet_hdr, 1, sizeof(pcap_packet_hdr), network_dump)) < sizeof(pcap_packet_hdr)) {
network_log("NETWORK: failed to write dump packet header\n");
fseek(network_dump, -written, SEEK_CUR);
} else {
if ((written = fwrite(pkt->data, 1, pkt->len, network_dump)) < pkt->len) {
network_log("NETWORK: failed to write dump packet data\n");
fseek(network_dump, -written - sizeof(pcap_packet_hdr), SEEK_CUR);
}
fflush(network_dump);
}
if (network_dump_mutex)
thread_release_mutex(network_dump_mutex);
}
#else
#define network_log(fmt, ...)
@@ -452,6 +467,10 @@ network_close(void)
thread_close_mutex(network_mutex);
network_mutex = NULL;
network_mac = NULL;
#ifdef ENABLE_NETWORK_LOG
thread_close_mutex(network_dump_mutex);
network_dump_mutex = NULL;
#endif
/* Here is where we clear the queues. */
network_queue_clear(0);
@@ -491,6 +510,9 @@ network_reset(void)
if ((network_type==NET_TYPE_NONE) || (network_card==0)) return;
network_mutex = thread_create_mutex();
#ifdef ENABLE_NETWORK_LOG
network_dump_mutex = thread_create_mutex();
#endif
/* Initialize the platform module. */
switch(network_type) {