Split off the Network configuration from Other peripherals in the Settings dialog and made PCap device configurable;

Overhauled the configuration files so that the global variables are now subdivided into sections;
Fixed CD-ROM MODE SENSE page 0x2A which was being incorrectly reported as not implemented, fixes among other things Rayman 1 and Spellcross: The Last Battle (both now see the CD-ROM and play CD Audio fine).
This commit is contained in:
OBattler
2017-05-17 21:56:31 +02:00
parent 34c08faf46
commit 1a9a55c35e
25 changed files with 1523 additions and 899 deletions

View File

@@ -29,6 +29,34 @@ static thread_t *poll_tid;
static NETRXCB poll_rx; /* network RX function to call */
static void *poll_arg; /* network RX function arg */
int netdev_num;
netdev_t netdev_list[512];
#ifdef WALTJE
int pcap_do_log = 1;
# define ENABLE_PCAP_LOG
#else
int pcap_do_log = 0;
#endif
static void
pcap_log(const char *format, ...)
{
#ifdef ENABLE_PCAP_LOG
va_list ap;
if (pcap_do_log) {
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
}
#endif
}
#define pclog pcap_log
/* Check if the interface has a packet for us. */
static void
@@ -80,6 +108,8 @@ poll_thread(void *arg)
}
char pcap_dev[512];
/* Initialize WinPcap for us. */
int
network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg)
@@ -105,12 +135,11 @@ network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg)
pclog("Initializing WinPcap, version %s\n", temp);
/* Get the value of our capture interface. */
dev = config_get_string(NULL, "pcap_device", NULL);
if (dev == NULL) {
if (pcap_dev == NULL) {
pclog(" No network device configured!\n");
return(-1);
}
pclog(" Network interface: '%s'\n", dev);
pclog(" Network interface: '%s'\n", pcap_dev);
pcap = pcap_open_live(dev, /* interface name */
1518, /* maximum packet size */
@@ -198,10 +227,16 @@ network_devlist(netdev_t *list)
pcap_if_t *devlist, *dev;
int i = 0;
/* Note by Kotori: Add the first (and guaranteed to be always present) device - "None". */
strcpy(list->device, "none");
strcpy(list->description, "None");
list++;
i++;
/* Retrieve the device list from the local machine */
if (pcap_findalldevs(&devlist, errbuf) == -1) {
pclog("NETWORK: error in pcap_findalldevs_ex: %s\n", errbuf);
return(-1);
return(i); /* Note by Kotori: The list will always have at least one entry - "None". */
}
for (dev=devlist; dev!=NULL; dev=dev->next) {
@@ -219,3 +254,19 @@ network_devlist(netdev_t *list)
return(i);
}
int network_dev_to_id(char *dev)
{
int i = 0;
for (i = 0; i < netdev_num; i++)
{
if (!strcmp(netdev_list[i].device, dev))
{
return i;
}
}
/* If the device does not match the list, consider it as if it was set to "none". */
return 0;
}