Monster patch to clean up a lot of cruft in the code, and reduce the RAM footptiny of a running XT machine from about 680MB down to about 80MB. Yes, 600MB of unused 0x00's.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* - Realtek RTL8019AS (ISA 16-bit, PnP);
|
||||
* - Realtek RTL8029AS (PCI).
|
||||
*
|
||||
* Version: @(#)net_ne2000.c 1.0.2 2018/02/26
|
||||
* Version: @(#)net_ne2000.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy
|
||||
*
|
||||
@@ -2377,7 +2377,7 @@ nic_rom_init(nic_t *dev, wchar_t *s)
|
||||
|
||||
|
||||
static void *
|
||||
nic_init(device_t *info)
|
||||
nic_init(const device_t *info)
|
||||
{
|
||||
uint32_t mac;
|
||||
wchar_t *rom;
|
||||
@@ -2385,9 +2385,9 @@ nic_init(device_t *info)
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
int i;
|
||||
#endif
|
||||
int c;
|
||||
char *ansi_id = "REALTEK PLUG & PLAY ETHERNET CARD";
|
||||
uint64_t *eeprom_pnp_id;
|
||||
int c;
|
||||
char *ansi_id = "REALTEK PLUG & PLAY ETHERNET CARD";
|
||||
uint64_t *eeprom_pnp_id;
|
||||
|
||||
/* Get the desired debug level. */
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
@@ -2403,6 +2403,8 @@ nic_init(device_t *info)
|
||||
switch(dev->board) {
|
||||
case NE2K_NE1000:
|
||||
dev->is_8bit = 1;
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
case NE2K_NE2000:
|
||||
dev->maclocal[0] = 0x00; /* 00:00:D8 (Novell OID) */
|
||||
dev->maclocal[1] = 0x00;
|
||||
@@ -2445,8 +2447,11 @@ nic_init(device_t *info)
|
||||
/* See if we have a local MAC address configured. */
|
||||
mac = device_get_config_mac("mac", -1);
|
||||
|
||||
/* Make this device known to the I/O system. */
|
||||
if (dev->board < NE2K_RTL8019AS) /* PnP and PCI devices start with address spaces inactive. */
|
||||
/*
|
||||
* Make this device known to the I/O system.
|
||||
* PnP and PCI devices start with address spaces inactive.
|
||||
*/
|
||||
if (dev->board < NE2K_RTL8019AS)
|
||||
nic_ioset(dev, dev->base_address);
|
||||
|
||||
/* Set up our BIOS ROM space, if any. */
|
||||
@@ -2488,21 +2493,21 @@ nic_init(device_t *info)
|
||||
dev->pci_regs[0x02] = (PCI_DEVID&0xff);
|
||||
dev->pci_regs[0x03] = (PCI_DEVID>>8);
|
||||
|
||||
dev->pci_regs[0x04] = 0x03; /* IOEN */
|
||||
dev->pci_regs[0x04] = 0x03; /* IOEN */
|
||||
dev->pci_regs[0x05] = 0x00;
|
||||
dev->pci_regs[0x07] = 0x02; /* DST0, medium devsel */
|
||||
dev->pci_regs[0x07] = 0x02; /* DST0, medium devsel */
|
||||
|
||||
dev->pci_regs[0x09] = 0x00; /* PIFR */
|
||||
dev->pci_regs[0x09] = 0x00; /* PIFR */
|
||||
|
||||
dev->pci_regs[0x0B] = 0x02; /* BCR: Network Controller */
|
||||
dev->pci_regs[0x0A] = 0x00; /* SCR: Ethernet */
|
||||
dev->pci_regs[0x0B] = 0x02; /* BCR: Network Controller */
|
||||
dev->pci_regs[0x0A] = 0x00; /* SCR: Ethernet */
|
||||
|
||||
dev->pci_regs[0x2C] = (PCI_VENDID&0xff);
|
||||
dev->pci_regs[0x2D] = (PCI_VENDID>>8);
|
||||
dev->pci_regs[0x2E] = (PCI_DEVID&0xff);
|
||||
dev->pci_regs[0x2F] = (PCI_DEVID>>8);
|
||||
|
||||
dev->pci_regs[0x3D] = PCI_INTA; /* PCI_IPR */
|
||||
dev->pci_regs[0x3D] = PCI_INTA; /* PCI_IPR */
|
||||
|
||||
/* Enable our address space in PCI. */
|
||||
dev->pci_bar[0].addr_regs[0] = 0x01;
|
||||
@@ -2518,8 +2523,9 @@ nic_init(device_t *info)
|
||||
|
||||
mem_mapping_disable(&dev->bios_rom.mapping);
|
||||
|
||||
/* Insert this device onto the PCI bus, keep its slot number. */
|
||||
dev->card = pci_add_card(PCI_ADD_NORMAL, nic_pci_read, nic_pci_write, dev);
|
||||
/* Add device to the PCI bus, keep its slot number. */
|
||||
dev->card = pci_add_card(PCI_ADD_NORMAL,
|
||||
nic_pci_read, nic_pci_write, dev);
|
||||
} else {
|
||||
io_sethandler(0x0279, 1,
|
||||
NULL, NULL, NULL,
|
||||
@@ -2551,52 +2557,52 @@ nic_init(device_t *info)
|
||||
eeprom_pnp_id = (uint64_t *) &dev->eeprom[0x12];
|
||||
*eeprom_pnp_id = dev->pnp_id;
|
||||
|
||||
/* TAG: Plug and Play Version Number */
|
||||
dev->eeprom[0x1B] = 0x0A; /* Item byte */
|
||||
dev->eeprom[0x1C] = 0x10; /* PnP version */
|
||||
dev->eeprom[0x1D] = 0x10; /* Vendor version */
|
||||
/* TAG: Plug and Play Version Number. */
|
||||
dev->eeprom[0x1B] = 0x0A; /* Item byte */
|
||||
dev->eeprom[0x1C] = 0x10; /* PnP version */
|
||||
dev->eeprom[0x1D] = 0x10; /* Vendor version */
|
||||
|
||||
/* TAG: ANSI Identifier String */
|
||||
dev->eeprom[0x1E] = 0x82; /* Item byte */
|
||||
dev->eeprom[0x1F] = 0x22; /* Length bits 7-0 */
|
||||
dev->eeprom[0x20] = 0x00; /* Length bits 15-8 */
|
||||
memcpy(&dev->eeprom[0x21], ansi_id, 0x22); /* Identifier string */
|
||||
/* TAG: ANSI Identifier String. */
|
||||
dev->eeprom[0x1E] = 0x82; /* Item byte */
|
||||
dev->eeprom[0x1F] = 0x22; /* Length bits 7-0 */
|
||||
dev->eeprom[0x20] = 0x00; /* Length bits 15-8 */
|
||||
memcpy(&dev->eeprom[0x21], ansi_id, 0x22);
|
||||
|
||||
/* TAG: Logical Device ID */
|
||||
dev->eeprom[0x43] = 0x16; /* Item byte */
|
||||
dev->eeprom[0x44] = 0x4A; /* Logical device ID0 */
|
||||
dev->eeprom[0x45] = 0x8C; /* Logical device ID1 */
|
||||
dev->eeprom[0x46] = 0x80; /* Logical device ID2 */
|
||||
dev->eeprom[0x47] = 0x19; /* Logical device ID3 */
|
||||
dev->eeprom[0x48] = 0x02; /* Flag 0 (02 = BROM is disabled) */
|
||||
dev->eeprom[0x49] = 0x00; /* Flag 1 */
|
||||
/* TAG: Logical Device ID. */
|
||||
dev->eeprom[0x43] = 0x16; /* Item byte */
|
||||
dev->eeprom[0x44] = 0x4A; /* Logical device ID0 */
|
||||
dev->eeprom[0x45] = 0x8C; /* Logical device ID1 */
|
||||
dev->eeprom[0x46] = 0x80; /* Logical device ID2 */
|
||||
dev->eeprom[0x47] = 0x19; /* Logical device ID3 */
|
||||
dev->eeprom[0x48] = 0x02; /* Flag0 (02=BROM/disabled) */
|
||||
dev->eeprom[0x49] = 0x00; /* Flag 1 */
|
||||
|
||||
/* TAG: Compatible Device ID (NE2000) */
|
||||
dev->eeprom[0x4A] = 0x1C; /* Item byte */
|
||||
dev->eeprom[0x4B] = 0x41; /* Compatible ID0 */
|
||||
dev->eeprom[0x4C] = 0xD0; /* Compatible ID1 */
|
||||
dev->eeprom[0x4D] = 0x80; /* Compatible ID2 */
|
||||
dev->eeprom[0x4E] = 0xD6; /* Compatible ID3 */
|
||||
/* TAG: Compatible Device ID (NE2000) */
|
||||
dev->eeprom[0x4A] = 0x1C; /* Item byte */
|
||||
dev->eeprom[0x4B] = 0x41; /* Compatible ID0 */
|
||||
dev->eeprom[0x4C] = 0xD0; /* Compatible ID1 */
|
||||
dev->eeprom[0x4D] = 0x80; /* Compatible ID2 */
|
||||
dev->eeprom[0x4E] = 0xD6; /* Compatible ID3 */
|
||||
|
||||
/* TAG: I/O Format */
|
||||
dev->eeprom[0x4F] = 0x47; /* Item byte */
|
||||
dev->eeprom[0x50] = 0x00; /* I/O information */
|
||||
dev->eeprom[0x51] = 0x20; /* Min. I/O base bits 7-0 */
|
||||
dev->eeprom[0x52] = 0x02; /* Min. I/O base bits 15-8 */
|
||||
dev->eeprom[0x53] = 0x80; /* Max. I/O base bits 7-0 */
|
||||
dev->eeprom[0x54] = 0x03; /* Max. I/O base bits 15-8 */
|
||||
dev->eeprom[0x55] = 0x20; /* Base alignment */
|
||||
dev->eeprom[0x56] = 0x20; /* Range length */
|
||||
/* TAG: I/O Format */
|
||||
dev->eeprom[0x4F] = 0x47; /* Item byte */
|
||||
dev->eeprom[0x50] = 0x00; /* I/O information */
|
||||
dev->eeprom[0x51] = 0x20; /* Min. I/O base bits 7-0 */
|
||||
dev->eeprom[0x52] = 0x02; /* Min. I/O base bits 15-8 */
|
||||
dev->eeprom[0x53] = 0x80; /* Max. I/O base bits 7-0 */
|
||||
dev->eeprom[0x54] = 0x03; /* Max. I/O base bits 15-8 */
|
||||
dev->eeprom[0x55] = 0x20; /* Base alignment */
|
||||
dev->eeprom[0x56] = 0x20; /* Range length */
|
||||
|
||||
/* TAG: IRQ Format */
|
||||
dev->eeprom[0x57] = 0x23; /* Item byte */
|
||||
dev->eeprom[0x58] = 0x38; /* IRQ mask bits 7-0 */
|
||||
dev->eeprom[0x59] = 0x9E; /* IRQ mask bits 15-8 */
|
||||
dev->eeprom[0x5A] = 0x01; /* IRQ information */
|
||||
/* TAG: IRQ Format. */
|
||||
dev->eeprom[0x57] = 0x23; /* Item byte */
|
||||
dev->eeprom[0x58] = 0x38; /* IRQ mask bits 7-0 */
|
||||
dev->eeprom[0x59] = 0x9E; /* IRQ mask bits 15-8 */
|
||||
dev->eeprom[0x5A] = 0x01; /* IRQ information */
|
||||
|
||||
/* TAG: END Tag */
|
||||
dev->eeprom[0x5B] = 0x79; /* Item byte */
|
||||
for (c = 0x1B; c < 0x5C; c++) /* Checksum (2's complement) */
|
||||
/* TAG: END Tag */
|
||||
dev->eeprom[0x5B] = 0x79; /* Item byte */
|
||||
for (c = 0x1b; c < 0x5c; c++) /* Checksum (2's compl) */
|
||||
dev->eeprom[0x5C] += dev->eeprom[c];
|
||||
dev->eeprom[0x5C] = -dev->eeprom[0x5C];
|
||||
|
||||
@@ -2635,7 +2641,7 @@ nic_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_config_t ne1000_config[] =
|
||||
static const device_config_t ne1000_config[] =
|
||||
{
|
||||
{
|
||||
"base", "Address", CONFIG_HEX16, "", 0x300,
|
||||
@@ -2694,7 +2700,7 @@ static device_config_t ne1000_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t ne2000_config[] =
|
||||
static const device_config_t ne2000_config[] =
|
||||
{
|
||||
{
|
||||
"base", "Address", CONFIG_HEX16, "", 0x300,
|
||||
@@ -2779,7 +2785,7 @@ static device_config_t ne2000_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t rtl8019as_config[] =
|
||||
static const device_config_t rtl8019as_config[] =
|
||||
{
|
||||
{
|
||||
"mac", "MAC Address", CONFIG_MAC, "", -1
|
||||
@@ -2789,7 +2795,7 @@ static device_config_t rtl8019as_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t rtl8029as_config[] =
|
||||
static const device_config_t rtl8029as_config[] =
|
||||
{
|
||||
{
|
||||
"bios", "Enable BIOS", CONFIG_BINARY, "", 0
|
||||
@@ -2803,7 +2809,7 @@ static device_config_t rtl8029as_config[] =
|
||||
};
|
||||
|
||||
|
||||
device_t ne1000_device = {
|
||||
const device_t ne1000_device = {
|
||||
"Novell NE1000",
|
||||
DEVICE_ISA,
|
||||
NE2K_NE1000,
|
||||
@@ -2812,7 +2818,7 @@ device_t ne1000_device = {
|
||||
ne1000_config
|
||||
};
|
||||
|
||||
device_t ne2000_device = {
|
||||
const device_t ne2000_device = {
|
||||
"Novell NE2000",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
NE2K_NE2000,
|
||||
@@ -2821,7 +2827,7 @@ device_t ne2000_device = {
|
||||
ne2000_config
|
||||
};
|
||||
|
||||
device_t rtl8019as_device = {
|
||||
const device_t rtl8019as_device = {
|
||||
"Realtek RTL8019AS",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
NE2K_RTL8019AS,
|
||||
@@ -2830,7 +2836,7 @@ device_t rtl8019as_device = {
|
||||
rtl8019as_config
|
||||
};
|
||||
|
||||
device_t rtl8029as_device = {
|
||||
const device_t rtl8029as_device = {
|
||||
"Realtek RTL8029AS",
|
||||
DEVICE_PCI,
|
||||
NE2K_RTL8029AS,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the NE2000 ethernet controller.
|
||||
*
|
||||
* Version: @(#)net_ne2000.h 1.0.1 2018/02/14
|
||||
* Version: @(#)net_ne2000.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -45,10 +45,10 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
extern device_t ne1000_device;
|
||||
extern device_t ne2000_device;
|
||||
extern device_t rtl8019as_device;
|
||||
extern device_t rtl8029as_device;
|
||||
extern const device_t ne1000_device;
|
||||
extern const device_t ne2000_device;
|
||||
extern const device_t rtl8019as_device;
|
||||
extern const device_t rtl8029as_device;
|
||||
|
||||
|
||||
#endif /*NET_NE2000_H*/
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle WinPcap library processing.
|
||||
*
|
||||
* Version: @(#)net_pcap.c 1.0.2 2018/03/10
|
||||
* Version: @(#)net_pcap.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -60,7 +60,7 @@
|
||||
static volatile void *pcap_handle; /* handle to WinPcap DLL */
|
||||
static volatile pcap_t *pcap; /* handle to WinPcap library */
|
||||
static volatile thread_t *poll_tid;
|
||||
static netcard_t *poll_card; /* netcard linked to us */
|
||||
static const netcard_t *poll_card; /* netcard linked to us */
|
||||
static event_t *poll_state;
|
||||
|
||||
|
||||
@@ -233,9 +233,7 @@ net_pcap_init(void)
|
||||
pclog("PCAP: initializing, %s\n", errbuf);
|
||||
|
||||
/* Get the value of our capture interface. */
|
||||
if ((network_pcap == NULL) ||
|
||||
(network_pcap[0] == '\0') ||
|
||||
!strcmp(network_pcap, "none")) {
|
||||
if ((network_host[0] == '\0') || !strcmp(network_host, "none")) {
|
||||
pclog("PCAP: no interface configured!\n");
|
||||
return(-1);
|
||||
}
|
||||
@@ -303,33 +301,30 @@ net_pcap_close(void)
|
||||
* tries to attach to the network module.
|
||||
*/
|
||||
int
|
||||
net_pcap_reset(netcard_t *card)
|
||||
net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
||||
{
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
char filter_exp[255];
|
||||
struct bpf_program fp;
|
||||
|
||||
/* Open a PCAP live channel. */
|
||||
if ((pcap = f_pcap_open_live(network_pcap, /* interface name */
|
||||
if ((pcap = f_pcap_open_live(network_host, /* interface name */
|
||||
1518, /* max packet size */
|
||||
1, /* promiscuous mode? */
|
||||
10, /* timeout in msec */
|
||||
errbuf)) == NULL) { /* error buffer */
|
||||
pclog(" Unable to open device: %s!\n", network_pcap);
|
||||
pclog(" Unable to open device: %s!\n", network_host);
|
||||
return(-1);
|
||||
}
|
||||
pclog("PCAP: interface: %s\n", network_pcap);
|
||||
pclog("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",
|
||||
card->mac[0], card->mac[1], card->mac[2],
|
||||
card->mac[3], card->mac[4], card->mac[5]);
|
||||
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) )",
|
||||
card->mac[0], card->mac[1], card->mac[2],
|
||||
card->mac[3], card->mac[4], card->mac[5],
|
||||
card->mac[0], card->mac[1], card->mac[2],
|
||||
card->mac[3], card->mac[4], card->mac[5]);
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) {
|
||||
if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) {
|
||||
pclog("PCAP: error installing filter (%s) !\n", filter_exp);
|
||||
@@ -347,7 +342,7 @@ net_pcap_reset(netcard_t *card)
|
||||
|
||||
pclog("PCAP: starting thread..\n");
|
||||
poll_state = thread_create_event();
|
||||
poll_tid = thread_create(poll_thread, card->mac);
|
||||
poll_tid = thread_create(poll_thread, mac);
|
||||
thread_wait_event(poll_state, -1);
|
||||
|
||||
return(0);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Handle SLiRP library processing.
|
||||
*
|
||||
* Version: @(#)net_slirp.c 1.0.1 2018/02/14
|
||||
* Version: @(#)net_slirp.c 1.0.2 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
static volatile queueADT slirpq; /* SLiRP library handle */
|
||||
static volatile thread_t *poll_tid;
|
||||
static netcard_t *poll_card; /* netcard attached to us */
|
||||
static const netcard_t *poll_card; /* netcard attached to us */
|
||||
static event_t *poll_state;
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ net_slirp_init(void)
|
||||
|
||||
/* Initialize SLiRP for use. */
|
||||
int
|
||||
net_slirp_reset(netcard_t *card)
|
||||
net_slirp_reset(const netcard_t *card, uint8_t *mac)
|
||||
{
|
||||
/* Save the callback info. */
|
||||
poll_card = card;
|
||||
|
||||
pclog("SLiRP: creating thread..\n");
|
||||
poll_state = thread_create_event();
|
||||
poll_tid = thread_create(poll_thread, card->mac);
|
||||
poll_tid = thread_create(poll_thread, mac);
|
||||
thread_wait_event(poll_state, -1);
|
||||
|
||||
return(0);
|
||||
|
||||
@@ -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.2 2018/02/22
|
||||
* Version: @(#)network.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -66,17 +66,17 @@
|
||||
|
||||
static netcard_t net_cards[] = {
|
||||
{ "None", "none", NULL,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[ISA] Novell NE1000", "ne1k", &ne1000_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[ISA] Novell NE2000", "ne2k", &ne2000_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[ISA] Realtek RTL8019AS", "ne2kpnp", &rtl8019as_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[PCI] Realtek RTL8029AS", "ne2kpci", &rtl8029as_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "", "", NULL,
|
||||
NULL, NULL }
|
||||
NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -84,12 +84,13 @@ static netcard_t net_cards[] = {
|
||||
int network_type;
|
||||
int network_ndev;
|
||||
int network_card;
|
||||
netdev_t network_devs[32];
|
||||
char network_pcap[512];
|
||||
netdev_t network_devs[32];
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
int nic_do_log = ENABLE_NIC_LOG;
|
||||
#endif
|
||||
static mutex_t *network_mutex;
|
||||
static uint8_t *network_mac;
|
||||
|
||||
|
||||
static struct {
|
||||
@@ -263,7 +264,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
|
||||
/* Save the card's info. */
|
||||
net_cards[network_card].priv = dev;
|
||||
net_cards[network_card].rx = rx;
|
||||
net_cards[network_card].mac = mac;
|
||||
network_mac = mac;
|
||||
|
||||
/* Create the network events. */
|
||||
poll_data.wake_poll_thread = thread_create_event();
|
||||
@@ -272,11 +273,11 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
|
||||
/* Activate the platform module. */
|
||||
switch(network_type) {
|
||||
case NET_TYPE_PCAP:
|
||||
(void)net_pcap_reset(&net_cards[network_card]);
|
||||
(void)net_pcap_reset(&net_cards[network_card], network_mac);
|
||||
break;
|
||||
|
||||
case NET_TYPE_SLIRP:
|
||||
(void)net_slirp_reset(&net_cards[network_card]);
|
||||
(void)net_slirp_reset(&net_cards[network_card], network_mac);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -308,6 +309,7 @@ network_close(void)
|
||||
/* Close the network thread mutex. */
|
||||
thread_close_mutex(network_mutex);
|
||||
network_mutex = NULL;
|
||||
network_mac = NULL;
|
||||
|
||||
pclog("NETWORK: closed.\n");
|
||||
}
|
||||
@@ -455,7 +457,7 @@ network_card_getname(int card)
|
||||
|
||||
|
||||
/* UI */
|
||||
device_t *
|
||||
const device_t *
|
||||
network_card_getdevice(int card)
|
||||
{
|
||||
return(net_cards[card].device);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Definitions for the network module.
|
||||
*
|
||||
* Version: @(#)network.h 1.0.1 2018/02/14
|
||||
* Version: @(#)network.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
@@ -68,18 +68,17 @@ typedef void (*NETRXCB)(void *, uint8_t *, int);
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
device_t *device;
|
||||
void *priv;
|
||||
int (*poll)(void *);
|
||||
NETRXCB rx;
|
||||
uint8_t *mac;
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
const device_t *device;
|
||||
void *priv;
|
||||
int (*poll)(void *);
|
||||
NETRXCB rx;
|
||||
} netcard_t;
|
||||
|
||||
typedef struct {
|
||||
char device[128];
|
||||
char description[128];
|
||||
char device[128];
|
||||
char description[128];
|
||||
} netdev_t;
|
||||
|
||||
|
||||
@@ -89,9 +88,6 @@ extern "C" {
|
||||
|
||||
/* Global variables. */
|
||||
extern int nic_do_log; /* config */
|
||||
extern int network_card; /* config */
|
||||
extern int network_type; /* config */
|
||||
extern char network_pcap[512]; /* config */
|
||||
extern int network_ndev;
|
||||
extern netdev_t network_devs[32];
|
||||
|
||||
@@ -111,12 +107,12 @@ extern void network_tx(uint8_t *, int);
|
||||
|
||||
extern int net_pcap_prepare(netdev_t *);
|
||||
extern int net_pcap_init(void);
|
||||
extern int net_pcap_reset(netcard_t *);
|
||||
extern int net_pcap_reset(const netcard_t *, uint8_t *);
|
||||
extern void net_pcap_close(void);
|
||||
extern void net_pcap_in(uint8_t *, int);
|
||||
|
||||
extern int net_slirp_init(void);
|
||||
extern int net_slirp_reset(netcard_t *);
|
||||
extern int net_slirp_reset(const netcard_t *, uint8_t *);
|
||||
extern void net_slirp_close(void);
|
||||
extern void net_slirp_in(uint8_t *, int);
|
||||
|
||||
@@ -126,7 +122,7 @@ extern char *network_card_getname(int);
|
||||
extern int network_card_has_config(int);
|
||||
extern char *network_card_get_internal_name(int);
|
||||
extern int network_card_get_from_internal_name(char *);
|
||||
extern device_t *network_card_getdevice(int);
|
||||
extern const device_t *network_card_getdevice(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user