Merge pull request #1034 from richardg867/master
Small non-critical changes to networking
This commit is contained in:
@@ -466,7 +466,7 @@ pipc_write(int func, int addr, uint8_t val, void *priv)
|
|||||||
if (func == 0) { /* PCI-ISA bridge */
|
if (func == 0) { /* PCI-ISA bridge */
|
||||||
/* Read-only addresses */
|
/* Read-only addresses */
|
||||||
if ((addr < 4) || (addr == 5) || ((addr >= 8) && (addr < 0x40)) || (addr == 0x49) || (addr == 0x4b) ||
|
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;
|
return;
|
||||||
|
|
||||||
if ((dev->local <= VIA_PIPC_586A) && ((addr >= 0x58) && (addr < 0x80)))
|
if ((dev->local <= VIA_PIPC_586A) && ((addr >= 0x58) && (addr < 0x80)))
|
||||||
|
@@ -117,6 +117,8 @@ timeout_timer(void *priv)
|
|||||||
dev->rx_pkt = NULL;
|
dev->rx_pkt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network_rx_pause = 0;
|
||||||
|
|
||||||
timer_disable(&dev->timeout_timer);
|
timer_disable(&dev->timeout_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -331,7 +331,7 @@ poll_thread(void *arg)
|
|||||||
char key[20];
|
char key[20];
|
||||||
while (1) {
|
while (1) {
|
||||||
sprintf(key, "%d_protocol", i);
|
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);
|
sprintf(key, "%d_external", i);
|
||||||
external = config_get_int(category, key, 0);
|
external = config_get_int(category, key, 0);
|
||||||
sprintf(key, "%d_internal", i);
|
sprintf(key, "%d_internal", i);
|
||||||
|
@@ -145,7 +145,8 @@ static struct {
|
|||||||
|
|
||||||
#ifdef ENABLE_NETWORK_LOG
|
#ifdef ENABLE_NETWORK_LOG
|
||||||
int network_do_log = 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
|
static void
|
||||||
@@ -175,9 +176,23 @@ network_dump_packet(netpkt_t *pkt)
|
|||||||
tv.tv_sec, tv.tv_usec, pkt->len, pkt->len
|
tv.tv_sec, tv.tv_usec, pkt->len, pkt->len
|
||||||
};
|
};
|
||||||
|
|
||||||
fwrite(&pcap_packet_hdr, sizeof(pcap_packet_hdr), 1, network_dump);
|
if (network_dump_mutex)
|
||||||
fwrite(pkt->data, pkt->len, 1, network_dump);
|
thread_wait_mutex(network_dump_mutex);
|
||||||
fflush(network_dump);
|
|
||||||
|
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
|
#else
|
||||||
#define network_log(fmt, ...)
|
#define network_log(fmt, ...)
|
||||||
@@ -452,6 +467,10 @@ network_close(void)
|
|||||||
thread_close_mutex(network_mutex);
|
thread_close_mutex(network_mutex);
|
||||||
network_mutex = NULL;
|
network_mutex = NULL;
|
||||||
network_mac = 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. */
|
/* Here is where we clear the queues. */
|
||||||
network_queue_clear(0);
|
network_queue_clear(0);
|
||||||
@@ -491,6 +510,9 @@ network_reset(void)
|
|||||||
if ((network_type==NET_TYPE_NONE) || (network_card==0)) return;
|
if ((network_type==NET_TYPE_NONE) || (network_card==0)) return;
|
||||||
|
|
||||||
network_mutex = thread_create_mutex();
|
network_mutex = thread_create_mutex();
|
||||||
|
#ifdef ENABLE_NETWORK_LOG
|
||||||
|
network_dump_mutex = thread_create_mutex();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the platform module. */
|
/* Initialize the platform module. */
|
||||||
switch(network_type) {
|
switch(network_type) {
|
||||||
|
Reference in New Issue
Block a user