Changes to logging - nothing (other than some parts of pc.c) uses the global pclog anymore (and logs will be almost empty (until the base set logging flags is agreed upon);
Fixes to various hard disk controllers; Added the Packard Bell PB640; Fixed the InPort mouse emulation - now it works correctly on Windows NT 3.1; Removed the status window and the associated variables; Completely removed the Green B 486 machine; Fixed the MDSI Genius; Fixed the single-sided 5.25" floppy drive; Ported a CPU-related commit from VARCem.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle WinPcap library processing.
|
||||
*
|
||||
* Version: @(#)net_pcap.c 1.0.3 2018/03/15
|
||||
* Version: @(#)net_pcap.c 1.0.4 2018/04/29
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -44,12 +44,13 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
// #include <pcap/pcap.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include "../86box.h"
|
||||
#include "../config.h"
|
||||
#include "../device.h"
|
||||
@@ -136,6 +137,26 @@ static dllimp_t pcap_imports[] = {
|
||||
};
|
||||
|
||||
|
||||
#ifdef ENABLE_PCAP_LOG
|
||||
int pcap_do_log = ENABLE_PCAP_LOG;
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
pcap_log(const char *format, ...)
|
||||
{
|
||||
#ifdef ENABLE_PCAP_LOG
|
||||
va_list ap;
|
||||
|
||||
if (pcap_do_log) {
|
||||
va_start(ap, format);
|
||||
pclog_ex(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Handle the receiving of frames from the channel. */
|
||||
static void
|
||||
poll_thread(void *arg)
|
||||
@@ -147,7 +168,7 @@ poll_thread(void *arg)
|
||||
uint16_t mac_cmp16[2];
|
||||
event_t *evt;
|
||||
|
||||
pclog("PCAP: polling started.\n");
|
||||
pcap_log("PCAP: polling started.\n");
|
||||
thread_set_event(poll_state);
|
||||
|
||||
/* Create a waitable event. */
|
||||
@@ -195,7 +216,7 @@ poll_thread(void *arg)
|
||||
if (evt != NULL)
|
||||
thread_destroy_event(evt);
|
||||
|
||||
pclog("PCAP: polling stopped.\n");
|
||||
pcap_log("PCAP: polling stopped.\n");
|
||||
thread_set_event(poll_state);
|
||||
}
|
||||
|
||||
@@ -227,7 +248,7 @@ net_pcap_prepare(netdev_t *list)
|
||||
|
||||
/* Retrieve the device list from the local machine */
|
||||
if (f_pcap_findalldevs(&devlist, errbuf) == -1) {
|
||||
pclog("PCAP: error in pcap_findalldevs: %s\n", errbuf);
|
||||
pcap_log("PCAP: error in pcap_findalldevs: %s\n", errbuf);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -277,11 +298,11 @@ net_pcap_init(void)
|
||||
strcpy(errbuf, f_pcap_lib_version());
|
||||
str = strchr(errbuf, '(');
|
||||
if (str != NULL) *(str-1) = '\0';
|
||||
pclog("PCAP: initializing, %s\n", errbuf);
|
||||
pcap_log("PCAP: initializing, %s\n", errbuf);
|
||||
|
||||
/* Get the value of our capture interface. */
|
||||
if ((network_host[0] == '\0') || !strcmp(network_host, "none")) {
|
||||
pclog("PCAP: no interface configured!\n");
|
||||
pcap_log("PCAP: no interface configured!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -301,7 +322,7 @@ net_pcap_close(void)
|
||||
|
||||
if (pcap == NULL) return;
|
||||
|
||||
pclog("PCAP: closing.\n");
|
||||
pcap_log("PCAP: closing.\n");
|
||||
|
||||
/* Tell the polling thread to shut down. */
|
||||
pc = (void *)pcap; pcap = NULL;
|
||||
@@ -311,9 +332,9 @@ net_pcap_close(void)
|
||||
network_busy(0);
|
||||
|
||||
/* Wait for the thread to finish. */
|
||||
pclog("PCAP: waiting for thread to end...\n");
|
||||
pcap_log("PCAP: waiting for thread to end...\n");
|
||||
thread_wait_event(poll_state, -1);
|
||||
pclog("PCAP: thread ended\n");
|
||||
pcap_log("PCAP: thread ended\n");
|
||||
thread_destroy_event(poll_state);
|
||||
|
||||
poll_tid = NULL;
|
||||
@@ -360,13 +381,13 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
||||
1, /* promiscuous mode? */
|
||||
10, /* timeout in msec */
|
||||
errbuf)) == NULL) { /* error buffer */
|
||||
pclog(" Unable to open device: %s!\n", network_host);
|
||||
pcap_log(" Unable to open device: %s!\n", network_host);
|
||||
return(-1);
|
||||
}
|
||||
pclog("PCAP: interface: %s\n", network_host);
|
||||
pcap_log("PCAP: interface: %s\n", network_host);
|
||||
|
||||
/* Create a MAC address based packet filter. */
|
||||
pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
pcap_log("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
sprintf(filter_exp,
|
||||
"( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )",
|
||||
@@ -374,12 +395,12 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
if (f_pcap_compile((void *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) {
|
||||
if (f_pcap_setfilter((void *)pcap, &fp) != 0) {
|
||||
pclog("PCAP: error installing filter (%s) !\n", filter_exp);
|
||||
pcap_log("PCAP: error installing filter (%s) !\n", filter_exp);
|
||||
f_pcap_close((void *)pcap);
|
||||
return(-1);
|
||||
}
|
||||
} else {
|
||||
pclog("PCAP: could not compile filter (%s) !\n", filter_exp);
|
||||
pcap_log("PCAP: could not compile filter (%s) !\n", filter_exp);
|
||||
f_pcap_close((void *)pcap);
|
||||
return(-1);
|
||||
}
|
||||
@@ -387,7 +408,7 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
||||
/* Save the callback info. */
|
||||
poll_card = card;
|
||||
|
||||
pclog("PCAP: starting thread..\n");
|
||||
pcap_log("PCAP: starting thread..\n");
|
||||
poll_state = thread_create_event();
|
||||
poll_tid = thread_create(poll_thread, mac);
|
||||
thread_wait_event(poll_state, -1);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle SLiRP library processing.
|
||||
*
|
||||
* Version: @(#)net_slirp.c 1.0.2 2018/03/15
|
||||
* Version: @(#)net_slirp.c 1.0.3 2018/04/29
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -44,11 +44,13 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include "slirp/slirp.h"
|
||||
#include "slirp/queue.h"
|
||||
#include "../86box.h"
|
||||
@@ -64,6 +66,26 @@ static const netcard_t *poll_card; /* netcard attached to us */
|
||||
static event_t *poll_state;
|
||||
|
||||
|
||||
#ifdef ENABLE_SLIRP_LOG
|
||||
int slirp_do_log = ENABLE_SLIRP_LOG;
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
slirp_log(const char *format, ...)
|
||||
{
|
||||
#ifdef ENABLE_SLIRP_LOG
|
||||
va_list ap;
|
||||
|
||||
if (slirp_do_log) {
|
||||
va_start(ap, format);
|
||||
pclog_ex(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
slirp_tic(void)
|
||||
{
|
||||
@@ -100,7 +122,7 @@ poll_thread(UNUSED(void *arg))
|
||||
struct queuepacket *qp;
|
||||
event_t *evt;
|
||||
|
||||
pclog("SLiRP: polling started.\n");
|
||||
slirp_log("SLiRP: polling started.\n");
|
||||
thread_set_event(poll_state);
|
||||
|
||||
/* Create a waitable event. */
|
||||
@@ -123,10 +145,8 @@ poll_thread(UNUSED(void *arg))
|
||||
if (QueuePeek(slirpq) != 0) {
|
||||
/* Grab a packet from the queue. */
|
||||
qp = QueueDelete(slirpq);
|
||||
#if 0
|
||||
pclog("SLiRP: inQ:%d got a %dbyte packet @%08lx\n",
|
||||
slirp_log("SLiRP: inQ:%d got a %dbyte packet @%08lx\n",
|
||||
QueuePeek(slirpq), qp->len, qp);
|
||||
#endif
|
||||
|
||||
poll_card->rx(poll_card->priv, (uint8_t *)qp->data, qp->len);
|
||||
|
||||
@@ -145,7 +165,7 @@ poll_thread(UNUSED(void *arg))
|
||||
if (evt != NULL)
|
||||
thread_destroy_event(evt);
|
||||
|
||||
pclog("SLiRP: polling stopped.\n");
|
||||
slirp_log("SLiRP: polling stopped.\n");
|
||||
thread_set_event(poll_state);
|
||||
}
|
||||
|
||||
@@ -154,10 +174,10 @@ poll_thread(UNUSED(void *arg))
|
||||
int
|
||||
net_slirp_init(void)
|
||||
{
|
||||
pclog("SLiRP: initializing..\n");
|
||||
slirp_log("SLiRP: initializing..\n");
|
||||
|
||||
if (slirp_init() != 0) {
|
||||
pclog("SLiRP could not be initialized!\n");
|
||||
slirp_log("SLiRP could not be initialized!\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -178,7 +198,7 @@ net_slirp_reset(const netcard_t *card, uint8_t *mac)
|
||||
/* Save the callback info. */
|
||||
poll_card = card;
|
||||
|
||||
pclog("SLiRP: creating thread..\n");
|
||||
slirp_log("SLiRP: creating thread..\n");
|
||||
poll_state = thread_create_event();
|
||||
poll_tid = thread_create(poll_thread, mac);
|
||||
thread_wait_event(poll_state, -1);
|
||||
@@ -194,7 +214,7 @@ net_slirp_close(void)
|
||||
|
||||
if (slirpq == NULL) return;
|
||||
|
||||
pclog("SLiRP: closing.\n");
|
||||
slirp_log("SLiRP: closing.\n");
|
||||
|
||||
/* Tell the polling thread to shut down. */
|
||||
sl = slirpq; slirpq = NULL;
|
||||
@@ -204,9 +224,9 @@ net_slirp_close(void)
|
||||
network_busy(0);
|
||||
|
||||
/* Wait for the thread to finish. */
|
||||
pclog("SLiRP: waiting for thread to end...\n");
|
||||
slirp_log("SLiRP: waiting for thread to end...\n");
|
||||
thread_wait_event(poll_state, -1);
|
||||
pclog("SLiRP: thread ended\n");
|
||||
slirp_log("SLiRP: thread ended\n");
|
||||
thread_destroy_event(poll_state);
|
||||
|
||||
poll_tid = NULL;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* it should be malloc'ed and then linked to the NETCARD def.
|
||||
* Will be done later.
|
||||
*
|
||||
* Version: @(#)network.c 1.0.3 2018/03/15
|
||||
* Version: @(#)network.c 1.0.4 2018/04/29
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -48,14 +48,13 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#ifdef WALTJE
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#define HAVE_STDARG_H
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../plat.h"
|
||||
@@ -103,85 +102,24 @@ static struct {
|
||||
} poll_data;
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
# define is_print(c) (isalnum((int)(c)) || ((c) == ' '))
|
||||
|
||||
|
||||
#if 0
|
||||
/* Dump a buffer in hex, standard output. */
|
||||
static void
|
||||
hexdump(uint8_t *bufp, int len)
|
||||
{
|
||||
char asci[20];
|
||||
uint8_t c;
|
||||
int addr;
|
||||
|
||||
addr = 0;
|
||||
while (len-- > 0) {
|
||||
c = bufp[addr];
|
||||
if ((addr % 16) == 0) {
|
||||
printf("%06X %02X", addr, c);
|
||||
} else {
|
||||
printf(" %02X", c);
|
||||
}
|
||||
asci[(addr & 15)] = (char)((is_print(c) ? c : '.') & 0xff);
|
||||
if ((++addr % 16) == 0) {
|
||||
asci[16] = '\0';
|
||||
printf(" | %s |\n", asci);
|
||||
}
|
||||
}
|
||||
|
||||
if (addr % 16) {
|
||||
while (addr % 16) {
|
||||
printf(" ");
|
||||
asci[(addr & 15)] = ' ';
|
||||
addr++;
|
||||
}
|
||||
asci[16] = '\0';
|
||||
printf(" | %s |\n", asci);
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_NETWORK_LOG
|
||||
int network_do_log = ENABLE_NETWORK_LOG;
|
||||
#endif
|
||||
|
||||
|
||||
/* Dump a buffer in hex to output buffer. */
|
||||
static void
|
||||
hexdump_p(char *ptr, uint8_t *bufp, int len)
|
||||
network_log(const char *format, ...)
|
||||
{
|
||||
char asci[20];
|
||||
uint8_t c;
|
||||
int addr;
|
||||
#ifdef ENABLE_NETWORK_LOG
|
||||
va_list ap;
|
||||
|
||||
addr = 0;
|
||||
while (len-- > 0) {
|
||||
c = bufp[addr];
|
||||
if ((addr % 16) == 0) {
|
||||
sprintf(ptr, "%06X %02X", addr, c);
|
||||
} else {
|
||||
sprintf(ptr, " %02X", c);
|
||||
}
|
||||
ptr += strlen(ptr);
|
||||
asci[(addr & 15)] = (char)((is_print(c) ? c : '.') & 0xff);
|
||||
if ((++addr % 16) == 0) {
|
||||
asci[16] = '\0';
|
||||
sprintf(ptr, " | %s |\n", asci);
|
||||
ptr += strlen(ptr);
|
||||
}
|
||||
if (network_do_log) {
|
||||
va_start(ap, format);
|
||||
pclog_ex(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
if (addr % 16) {
|
||||
while (addr % 16) {
|
||||
sprintf(ptr, " ");
|
||||
ptr += strlen(ptr);
|
||||
asci[(addr & 15)] = ' ';
|
||||
addr++;
|
||||
}
|
||||
asci[16] = '\0';
|
||||
sprintf(ptr, " | %s |\n", asci);
|
||||
ptr += strlen(ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@@ -311,7 +249,7 @@ network_close(void)
|
||||
network_mutex = NULL;
|
||||
network_mac = NULL;
|
||||
|
||||
pclog("NETWORK: closed.\n");
|
||||
network_log("NETWORK: closed.\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -329,10 +267,10 @@ network_reset(void)
|
||||
int i = -1;
|
||||
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
pclog("NETWORK: reset (type=%d, card=%d) debug=%d\n",
|
||||
network_log("NETWORK: reset (type=%d, card=%d) debug=%d\n",
|
||||
network_type, network_card, nic_do_log);
|
||||
#else
|
||||
pclog("NETWORK: reset (type=%d, card=%d)\n",
|
||||
network_log("NETWORK: reset (type=%d, card=%d)\n",
|
||||
network_type, network_card);
|
||||
#endif
|
||||
ui_sb_update_icon(SB_NETWORK, 0);
|
||||
@@ -370,13 +308,13 @@ network_reset(void)
|
||||
return;
|
||||
}
|
||||
|
||||
pclog("NETWORK: set up for %s, card='%s'\n",
|
||||
network_log("NETWORK: set up for %s, card='%s'\n",
|
||||
(network_type==NET_TYPE_SLIRP)?"SLiRP":"Pcap",
|
||||
net_cards[network_card].name);
|
||||
|
||||
/* Add the (new?) card to the I/O system. */
|
||||
if (net_cards[network_card].device) {
|
||||
pclog("NETWORK: adding device '%s'\n",
|
||||
network_log("NETWORK: adding device '%s'\n",
|
||||
net_cards[network_card].name);
|
||||
device_add(net_cards[network_card].device);
|
||||
}
|
||||
@@ -389,14 +327,6 @@ network_tx(uint8_t *bufp, int len)
|
||||
{
|
||||
ui_sb_update_icon(SB_NETWORK, 1);
|
||||
|
||||
#ifdef WALTJE
|
||||
{
|
||||
char temp[4096];
|
||||
hexdump_p(temp, bufp, len);
|
||||
pclog("NETWORK: >> len=%d\n%s\n", len, temp);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(network_type) {
|
||||
case NET_TYPE_PCAP:
|
||||
net_pcap_in(bufp, len);
|
||||
|
||||
Reference in New Issue
Block a user