Ported the WinPcap thread's packet sanity checks to the SLiRP thread - SLiRP is now more stable;

Unified all three NIC families' DP8390 chip implementations in net_dp8390.c/h;
Some fixes for the WD8013EBT NIC;
Network status bar icon updating is now done at WinPcap/SLiRP handler level, not at the NIC level anymore.
This commit is contained in:
OBattler
2018-10-19 00:37:25 +02:00
parent c663147d11
commit d56df03a53
8 changed files with 1737 additions and 3351 deletions

View File

@@ -8,7 +8,7 @@
*
* Handle WinPcap library processing.
*
* Version: @(#)net_pcap.c 1.0.5 2018/10/02
* Version: @(#)net_pcap.c 1.0.6 2018/10/17
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -55,6 +55,7 @@
#include "../device.h"
#include "../plat.h"
#include "../plat_dynld.h"
#include "../ui.h"
#include "network.h"
@@ -138,22 +139,22 @@ static dllimp_t pcap_imports[] = {
#ifdef ENABLE_PCAP_LOG
int pcap_do_log = ENABLE_PCAP_LOG;
#endif
static void
pcap_log(const char *format, ...)
pcap_log(const char *fmt, ...)
{
#ifdef ENABLE_PCAP_LOG
va_list ap;
if (pcap_do_log) {
va_start(ap, format);
pclog_ex(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
#else
#define pcap_log(fmt, ...)
#endif
/* Handle the receiving of frames from the channel. */
@@ -186,6 +187,8 @@ poll_thread(void *arg)
/* Wait for the next packet to arrive. */
data = (uint8_t *)f_pcap_next((void *)pcap, &h);
if (data != NULL) {
ui_sb_update_icon(SB_NETWORK, 1);
/* Received MAC. */
mac_cmp32[0] = *(uint32_t *)(data+6);
mac_cmp16[0] = *(uint16_t *)(data+10);
@@ -204,8 +207,10 @@ poll_thread(void *arg)
}
/* If we did not get anything, wait a while. */
if (data == NULL)
if (data == NULL) {
ui_sb_update_icon(SB_NETWORK, 0);
thread_wait_event(evt, 10);
}
/* Release ownership of the device. */
network_wait(0);
@@ -319,6 +324,8 @@ net_pcap_close(void)
{
void *pc;
ui_sb_update_icon(SB_NETWORK, 0);
if (pcap == NULL) return;
pcap_log("PCAP: closing.\n");
@@ -374,6 +381,8 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac)
char filter_exp[255];
struct bpf_program fp;
ui_sb_update_icon(SB_NETWORK, 0);
/* Open a PCAP live channel. */
if ((pcap = f_pcap_open_live(network_host, /* interface name */
1518, /* max packet size */
@@ -422,9 +431,13 @@ net_pcap_in(uint8_t *bufp, int len)
{
if (pcap == NULL) return;
ui_sb_update_icon(SB_NETWORK, 1);
network_busy(1);
f_pcap_sendpacket((void *)pcap, bufp, len);
network_busy(0);
ui_sb_update_icon(SB_NETWORK, 0);
}