Changes to how network providers are loaded.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle WinPcap library processing.
|
||||
*
|
||||
* Version: @(#)net_pcap.c 1.0.9 2018/11/06
|
||||
* Version: @(#)net_pcap.c 1.0.10 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -174,7 +174,6 @@ static int
|
||||
net_pcap_init(netdev_t *list)
|
||||
{
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
wchar_t temp[512];
|
||||
pcap_if_t *devlist, *dev;
|
||||
char *str = PCAP_DLL_PATH;
|
||||
int i = 0;
|
||||
@@ -185,9 +184,9 @@ net_pcap_init(netdev_t *list)
|
||||
/* Try loading the DLL. */
|
||||
pcap_handle = dynld_module(str, pcap_imports);
|
||||
if (pcap_handle == NULL) {
|
||||
swprintf(temp, sizeof_w(temp),
|
||||
get_string(IDS_ERR_NOLIB), "PCap", str);
|
||||
ui_msgbox(MBX_ERROR, temp);
|
||||
/* Forward module name back to caller. */
|
||||
strcpy(list->description, str);
|
||||
|
||||
ERRLOG("PCAP: unable to load '%s', PCAP not available!\n", str);
|
||||
return(-1);
|
||||
} else {
|
||||
@@ -325,6 +324,14 @@ net_pcap_reset(uint8_t *mac)
|
||||
}
|
||||
|
||||
|
||||
/* Are we available or not? */
|
||||
static int
|
||||
net_pcap_available(void)
|
||||
{
|
||||
return((pcap_handle != NULL) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
/* Send a packet to the Pcap interface. */
|
||||
static void
|
||||
net_pcap_send(uint8_t *bufp, int len)
|
||||
@@ -348,5 +355,6 @@ const network_t network_pcap = {
|
||||
net_pcap_init,
|
||||
net_pcap_close,
|
||||
net_pcap_reset,
|
||||
net_pcap_available,
|
||||
net_pcap_send
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle SLiRP library processing.
|
||||
*
|
||||
* Version: @(#)net_slirp.c 1.0.5 2018/11/06
|
||||
* Version: @(#)net_slirp.c 1.0.6 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -50,7 +50,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdarg.h>
|
||||
//#include <libslirp.h>
|
||||
#ifdef USE_LIBSLIRP
|
||||
# include <libslirp.h>
|
||||
#else
|
||||
typedef void slirp_t; /* nicer than void.. */
|
||||
#endif
|
||||
#define HAVE_STDARG_H
|
||||
#define netdbg network_log
|
||||
#include "../../emu.h"
|
||||
@@ -67,9 +71,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
typedef void slirp_t; /* nicer than void.. */
|
||||
|
||||
|
||||
static volatile void *slirp_handle; /* handle to SLiRP DLL */
|
||||
static slirp_t *slirp; /* SLiRP library handle */
|
||||
static volatile thread_t *poll_tid;
|
||||
@@ -204,18 +205,17 @@ slirp_can_output(void)
|
||||
* be properly initialized.
|
||||
*/
|
||||
static int
|
||||
net_slirp_init(UNUSED(netdev_t *arg))
|
||||
net_slirp_init(netdev_t *list)
|
||||
{
|
||||
wchar_t temp[512];
|
||||
char tempA[128];
|
||||
char temp[128];
|
||||
const char *fn = SLIRP_DLL_PATH;
|
||||
|
||||
/* Try loading the DLL. */
|
||||
slirp_handle = dynld_module(fn, slirp_imports);
|
||||
if (slirp_handle == NULL) {
|
||||
swprintf(temp, sizeof_w(temp),
|
||||
get_string(IDS_ERR_NOLIB), "SLiRP", fn);
|
||||
ui_msgbox(MBX_ERROR, temp);
|
||||
/* Forward module name back to caller. */
|
||||
strcpy(list->description, fn);
|
||||
|
||||
ERRLOG("SLIRP: unable to load '%s', SLiRP not available!\n", fn);
|
||||
return(-1);
|
||||
} else {
|
||||
@@ -226,11 +226,11 @@ net_slirp_init(UNUSED(netdev_t *arg))
|
||||
SLIRP_debug(handle_logging);
|
||||
|
||||
/* Get the library version. */
|
||||
if (SLIRP_version(tempA, sizeof(tempA)) <= 0) {
|
||||
if (SLIRP_version(temp, sizeof(temp)) <= 0) {
|
||||
ERRLOG("SLiRP could not get version!\n");
|
||||
return(-1);
|
||||
}
|
||||
INFO("SLiRP: initializing, version %s ..\n", tempA);
|
||||
INFO("SLiRP: initializing, version %s ..\n", temp);
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -292,6 +292,14 @@ net_slirp_close(void)
|
||||
}
|
||||
|
||||
|
||||
/* Are we available or not? */
|
||||
static int
|
||||
net_slirp_available(void)
|
||||
{
|
||||
return((slirp_handle != NULL) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
/* Send a packet to the SLiRP interface. */
|
||||
static void
|
||||
net_slirp_send(uint8_t *pkt, int pkt_len)
|
||||
@@ -311,5 +319,6 @@ const network_t network_slirp = {
|
||||
net_slirp_init,
|
||||
net_slirp_close,
|
||||
net_slirp_reset,
|
||||
net_slirp_available,
|
||||
net_slirp_send
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the network module.
|
||||
*
|
||||
* Version: @(#)network.c 1.0.17 2018/11/06
|
||||
* Version: @(#)network.c 1.0.18 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -92,11 +92,13 @@ static const struct {
|
||||
const network_t *net;
|
||||
} networks[] = {
|
||||
{ "none", NULL },
|
||||
|
||||
{ "slirp", &network_slirp },
|
||||
{ "pcap", &network_pcap },
|
||||
#ifdef USE_VNS
|
||||
{ "vns", &network_vns },
|
||||
#endif
|
||||
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -141,10 +143,8 @@ network_getname(int net)
|
||||
int
|
||||
network_available(int net)
|
||||
{
|
||||
#if 0
|
||||
if (networks[net].net != NULL)
|
||||
if (networks[net].net && networks[net].net->available)
|
||||
return(networks[net].net->available());
|
||||
#endif
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -256,6 +256,7 @@ network_end(void)
|
||||
void
|
||||
network_init(void)
|
||||
{
|
||||
wchar_t temp[512];
|
||||
int i, k;
|
||||
|
||||
/* Clear the local data. */
|
||||
@@ -271,14 +272,24 @@ network_init(void)
|
||||
network_host_ndev = 1;
|
||||
|
||||
/* Initialize the network provider modules, if present. */
|
||||
i = 0;
|
||||
while (networks[i].internal_name != NULL) {
|
||||
if (networks[i].net != NULL) {
|
||||
k = networks[i].net->init(&network_host_devs[network_host_ndev]);
|
||||
if (k > 0)
|
||||
network_host_ndev += k;
|
||||
for (i = 0; networks[i].internal_name != NULL; i++) {
|
||||
if (networks[i].net == NULL) continue;
|
||||
|
||||
/* Try to load network provider module. */
|
||||
k = networks[i].net->init(&network_host_devs[network_host_ndev]);
|
||||
if ((k < 0) && (i == network_type)) {
|
||||
/* Provider not available. */
|
||||
swprintf(temp, sizeof_w(temp),
|
||||
get_string(IDS_ERR_NOLIB),
|
||||
networks[i].net->name,
|
||||
network_host_devs[network_host_ndev].description);
|
||||
ui_msgbox(MBX_ERROR, temp);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
|
||||
/* If they have interfaces, add them. */
|
||||
if (k > 0)
|
||||
network_host_ndev += k;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +317,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
|
||||
if (networks[network_type].net->reset(mac) < 0) {
|
||||
/* Tell user we can't do this (at the moment.) */
|
||||
swprintf(temp, sizeof_w(temp),
|
||||
get_string(IDS_ERR_PCAP), networks[network_type].net->name);
|
||||
get_string(IDS_ERR_NONET), networks[network_type].net->name);
|
||||
ui_msgbox(MBX_ERROR, temp);
|
||||
|
||||
// FIXME: we should ask in the dialog if they want to
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the network module.
|
||||
*
|
||||
* Version: @(#)network.h 1.0.7 2018/11/06
|
||||
* Version: @(#)network.h 1.0.8 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -59,17 +59,20 @@ enum {
|
||||
|
||||
typedef void (*NETRXCB)(void *, uint8_t *bufp, int);
|
||||
|
||||
/* Define a host interface entry for a network provider. */
|
||||
typedef struct {
|
||||
char device[128];
|
||||
char description[128];
|
||||
} netdev_t;
|
||||
|
||||
/* Define a network provider. */
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
||||
int (*init)(netdev_t *);
|
||||
void (*close)(void);
|
||||
int (*reset)(uint8_t *);
|
||||
int (*available)(void);
|
||||
void (*send)(uint8_t *, int);
|
||||
} network_t;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of Intel mainboards.
|
||||
*
|
||||
* Version: @(#)intel.c 1.0.6 2018/11/08
|
||||
* Version: @(#)intel.c 1.0.7 2018/11/11
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -115,7 +115,7 @@ timer_read(uint16_t addr, void *priv)
|
||||
if (dev->timer < 0)
|
||||
return 0;
|
||||
|
||||
latch = dev->timer / TIMER_USEC;
|
||||
latch = (uint16_t)(dev->timer / TIMER_USEC);
|
||||
|
||||
if (addr & 1)
|
||||
ret = latch >> 8;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* String table for the application, shared by all platforms.
|
||||
*
|
||||
* Version: @(#)VARCem.def 1.0.3 2018/10/18
|
||||
* Version: @(#)VARCem.def 1.0.4 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -58,7 +58,7 @@ STRTBL( IDS_WARNING, STR_2103 )
|
||||
/* System errors (2200.) */
|
||||
STRTBL( IDS_ERR_ACCEL, STR_2200 )
|
||||
STRTBL( IDS_ERR_INPUT, STR_2201 )
|
||||
STRTBL( IDS_ERR_PCAP, STR_2202 )
|
||||
STRTBL( IDS_ERR_NONET, STR_2202 )
|
||||
STRTBL( IDS_ERR_PCAP_NO, STR_2203 )
|
||||
STRTBL( IDS_ERR_PCAP_DEV, STR_2204 )
|
||||
STRTBL( IDS_ERR_NOLIB, STR_2205 )
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* those are not used by the platform code. This is easier to
|
||||
* maintain.
|
||||
*
|
||||
* Version: @(#)ui_resource.h 1.0.18 2018/10/18
|
||||
* Version: @(#)ui_resource.h 1.0.19 2018/11/12
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -262,7 +262,7 @@
|
||||
/* System errors (2200.) */
|
||||
#define IDS_ERR_ACCEL 2200 /* "Unable to load Accelerators" */
|
||||
#define IDS_ERR_INPUT 2201 /* "Unable to register Raw Input" */
|
||||
#define IDS_ERR_PCAP 2202 /* "PCap failed to set up.." */
|
||||
#define IDS_ERR_NONET 2202 /* "%s failed to set up.." */
|
||||
#define IDS_ERR_PCAP_NO 2203 /* "No PCap devices found" */
|
||||
#define IDS_ERR_PCAP_DEV 2204 /* "Invalid PCap device" */
|
||||
#define IDS_ERR_NOLIB 2205 /* "Unable to initialize %s.." */
|
||||
|
||||
Reference in New Issue
Block a user