mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-14 02:17:36 +08:00
ne2000: Decouple emulator from pcap
Currently the ne2000 emulator explicitly depends on pcap. Decouple the ne2000 code and pcap code so we can always build with the emulator but optionally disable pcap. This also updates build defines and configuration to make this decoupling explicit to the user.
This commit is contained in:
10
configure.ac
10
configure.ac
@@ -974,20 +974,20 @@ else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
dnl FEATURE: Whether to use libpcap, and enable NE2000 emulation
|
||||
AH_TEMPLATE(C_NE2000,[Define to 1 to enable NE2000 ethernet passthrough, requires libpcap])
|
||||
dnl FEATURE: Whether to use libpcap, and enable ethernet passthrough
|
||||
AH_TEMPLATE(C_PCAP,[Define to 1 to enable ethernet passthrough, requires libpcap])
|
||||
case "$host" in
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
CFLAGS="$CFLAGS -I$pwd/vs2015/pcap"
|
||||
CXXFLAGS="$CXXFLAGS -I$pwd/vs2015/pcap"
|
||||
AC_DEFINE(C_NE2000,1)
|
||||
AC_DEFINE(C_PCAP,1)
|
||||
;;
|
||||
*)
|
||||
if test x$have_pcap_lib = xyes -a x$have_pcap_h = xyes ; then
|
||||
LIBS="$LIBS -lpcap";
|
||||
AC_DEFINE(C_NE2000,1)
|
||||
AC_DEFINE(C_PCAP,1)
|
||||
else
|
||||
AC_MSG_WARN([Can't find libpcap, NE2000 ethernet passthrough disabled])
|
||||
AC_MSG_WARN([Can't find libpcap, ethernet passthrough disabled])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@@ -87,8 +87,8 @@
|
||||
/* Define to 1 to enable internal modem support, requires SDL_net */
|
||||
#undef C_MODEM
|
||||
|
||||
/* Define to 1 to enable NE2000 ethernet passthrough, requires libpcap */
|
||||
#define C_NE2000 1
|
||||
/* Define to 1 to enable ethernet passthrough, requires libpcap */
|
||||
#define C_PCAP 1
|
||||
|
||||
/* Define to 1 to use opengl display output support */
|
||||
#if !defined(C_SDL2)
|
||||
|
@@ -92,8 +92,8 @@
|
||||
/* Define to 1 to enable MT32 emulation (x86/x86_64 only) */
|
||||
/* #undef C_MT32 */
|
||||
|
||||
/* Define to 1 to enable NE2000 ethernet passthrough, requires libpcap */
|
||||
/* #undef C_NE2000 */
|
||||
/* Define to 1 to enable ethernet passthrough, requires libpcap */
|
||||
/* #undef C_PCAP */
|
||||
|
||||
/* Define to 1 to use opengl display output support */
|
||||
//#define C_OPENGL 1
|
||||
|
@@ -114,8 +114,8 @@
|
||||
/* Define to 1 to enable MT32 emulation (x86/x86_64 only) */
|
||||
/* #undef C_MT32 */
|
||||
|
||||
/* Define to 1 to enable NE2000 ethernet passthrough, requires libpcap */
|
||||
#define C_NE2000 1
|
||||
/* Define to 1 to enable ethernet passthrough, requires libpcap */
|
||||
#define C_PCAP 1
|
||||
|
||||
/* Define to 1 to use opengl display output support */
|
||||
/*#define C_OPENGL 1*/
|
||||
|
@@ -3901,20 +3901,8 @@ void DOSBOX_SetupConfigSections(void) {
|
||||
Pbool->SetBasic(true);
|
||||
|
||||
secprop=control->AddSection_prop("ne2000",&Null_Init,true);
|
||||
MSG_Add("NE2000_CONFIGFILE_HELP",
|
||||
"macaddr -- The physical address the emulator will use on your network.\n"
|
||||
" If you have multiple DOSBox-Xes running on your network,\n"
|
||||
" this has to be changed. Modify the last three number blocks.\n"
|
||||
" I.e. AC:DE:48:88:99:AB.\n"
|
||||
"realnic -- Specifies which of your network interfaces is used.\n"
|
||||
" Write \'list\' here to see the list of devices from the Help\n"
|
||||
" menu (\'List network interfaces\') or from the Status Window.\n"
|
||||
" Then make your choice and put either the interface number\n"
|
||||
" (e.g. 2) or a part of your adapters name (e.g. VIA here)."
|
||||
);
|
||||
|
||||
Pbool = secprop->Add_bool("ne2000", Property::Changeable::WhenIdle, false);
|
||||
Pbool->Set_help("Enable Ethernet passthrough. Requires [Win]Pcap.");
|
||||
Pbool->Set_help("Enable NE2000 Ethernet emulation.");
|
||||
Pbool->SetBasic(true);
|
||||
|
||||
Phex = secprop->Add_hex("nicbase", Property::Changeable::WhenIdle, 0x300);
|
||||
@@ -3926,8 +3914,8 @@ void DOSBOX_SetupConfigSections(void) {
|
||||
Pint->SetBasic(true);
|
||||
|
||||
Pstring = secprop->Add_string("macaddr", Property::Changeable::WhenIdle,"AC:DE:48:88:99:AA");
|
||||
Pstring->Set_help("The physical address the emulator will use on your network.\n"
|
||||
"If you have multiple DOSBox-Xes running on your network,\n"
|
||||
Pstring->Set_help("The MAC address the emulator will use for its network adapter.\n"
|
||||
"If you have multiple DOSBox-Xes running on the same network,\n"
|
||||
"this has to be changed for each. AC:DE:48 is an address range reserved for\n"
|
||||
"private use, so modify the last three number blocks.\n"
|
||||
"I.e. AC:DE:48:88:99:AB.");
|
||||
@@ -3937,7 +3925,7 @@ void DOSBOX_SetupConfigSections(void) {
|
||||
* and the OS. Sort of like "NAT" mode in VirtualBox. When that works, we
|
||||
* can then compile NE2000 support with and without libpcap/winpcap support. */
|
||||
Pstring = secprop->Add_string("realnic", Property::Changeable::WhenIdle,"list");
|
||||
Pstring->Set_help("Specifies which of your network interfaces is used.\n"
|
||||
Pstring->Set_help("Specifies which of your network interfaces is used for pcap.\n"
|
||||
"Write \'list\' here to see the list of devices from the Help\n"
|
||||
"menu (\'List network interfaces\') or from the Status Window.\n"
|
||||
"Then make your choice and put either the interface number\n"
|
||||
|
@@ -2348,7 +2348,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::string niclist="NE2000 networking is not enabled. Check [ne2000] section of the configuration.";
|
||||
std::string niclist="pcap networking is not enabled. Check [ne2000] section of the configuration.";
|
||||
class ShowHelpNIC : public GUI::ToplevelWindow {
|
||||
protected:
|
||||
GUI::Input *name;
|
||||
|
@@ -12866,9 +12866,7 @@ int main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT {
|
||||
PRINTER_Init();
|
||||
#endif
|
||||
PARALLEL_Init();
|
||||
#if C_NE2000
|
||||
NE2K_Init();
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(C_SDL2)
|
||||
Reflect_Menu();
|
||||
|
@@ -1,7 +1,5 @@
|
||||
#include "config.h"
|
||||
|
||||
#if C_NE2000
|
||||
|
||||
#if defined(WIN32)
|
||||
#define HAVE_REMOTE
|
||||
#endif
|
||||
@@ -53,10 +51,13 @@
|
||||
|
||||
#include "ne2000.h"
|
||||
|
||||
static void NE2000_TX_Event(Bitu val);
|
||||
|
||||
#ifdef C_PCAP
|
||||
|
||||
#include "pcap.h"
|
||||
// Handle to WinPCap device
|
||||
pcap_t *adhandle = 0;
|
||||
static void NE2000_TX_Event(Bitu val);
|
||||
|
||||
#ifdef WIN32
|
||||
// DLL loading
|
||||
@@ -76,6 +77,8 @@ int (*PacketFindALlDevsEx)(char *, struct pcap_rmtauth *, pcap_if_t **, char *)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//Never completely fill the ne2k ring so that we never
|
||||
// hit the unclear completely full buffer condition.
|
||||
#define BX_NE2K_NEVER_FULL_RING (1)
|
||||
@@ -301,7 +304,9 @@ bx_ne2k_c::write_cr(uint32_t value)
|
||||
// Send the packet to the system driver
|
||||
/* TODO: Transmit packet */
|
||||
//BX_NE2K_THIS ethdev->sendpkt(& BX_NE2K_THIS s.mem[BX_NE2K_THIS s.tx_page_start*256 - BX_NE2K_MEMSTART], BX_NE2K_THIS s.tx_bytes);
|
||||
#ifdef C_PCAP
|
||||
pcap_sendpacket(adhandle,&s.mem[s.tx_page_start*256 - BX_NE2K_MEMSTART], s.tx_bytes);
|
||||
#endif
|
||||
// some more debug
|
||||
if (BX_NE2K_THIS s.tx_timer_active) {
|
||||
BX_PANIC(("CR write, tx timer still active"));
|
||||
@@ -1468,6 +1473,7 @@ static void NE2000_TX_Event(Bitu val) {
|
||||
}
|
||||
|
||||
static void NE2000_Poller(void) {
|
||||
#ifdef C_PCAP
|
||||
int res;
|
||||
struct pcap_pkthdr *header;
|
||||
u_char *pkt_data;
|
||||
@@ -1481,6 +1487,7 @@ static void NE2000_Poller(void) {
|
||||
theNE2kDevice->rx_frame(pkt_data, header->len);
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
@@ -1509,6 +1516,13 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef C_PCAP
|
||||
LOG_MSG("pcap support not enabled, disabling ne2000");
|
||||
load_success = false;
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef C_PCAP
|
||||
#ifdef WIN32
|
||||
/*
|
||||
int (*PacketSendPacket)(pcap_t *, const u_char *, int);
|
||||
@@ -1561,6 +1575,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// get irq and base
|
||||
@@ -1590,6 +1605,7 @@ public:
|
||||
mac[4]=macint[4]; mac[5]=macint[5];
|
||||
}
|
||||
|
||||
#ifdef C_PCAP
|
||||
// find out which pcap device to use
|
||||
const char* realnicstring=section->Get_string("realnic");
|
||||
pcap_if_t *alldevs;
|
||||
@@ -1701,6 +1717,7 @@ public:
|
||||
pcap_freealldevs(alldevs);
|
||||
#ifndef WIN32
|
||||
pcap_setnonblock(adhandle,1,errbuf);
|
||||
#endif
|
||||
#endif
|
||||
// create the bochs NIC class
|
||||
theNE2kDevice = new bx_ne2k_c ();
|
||||
@@ -1722,8 +1739,10 @@ public:
|
||||
}
|
||||
|
||||
~NE2K() {
|
||||
#ifdef C_PCAP
|
||||
if(adhandle) pcap_close(adhandle);
|
||||
adhandle=0;
|
||||
#endif
|
||||
if(theNE2kDevice != 0) delete theNE2kDevice;
|
||||
theNE2kDevice=0;
|
||||
TIMER_DelTickHandler(NE2000_Poller);
|
||||
@@ -1761,5 +1780,3 @@ void NE2K_Init() {
|
||||
AddExitFunction(AddExitFunctionFuncPair(NE2K_ShutDown),true);
|
||||
AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(NE2K_OnReset));
|
||||
}
|
||||
|
||||
#endif // C_NE2000
|
||||
|
@@ -1099,9 +1099,7 @@ extern void *VGA_VertInterrupt_PIC_Event;
|
||||
extern void *VGA_VerticalTimer_PIC_Event;
|
||||
extern void *PIC_IRQCheckDelayed_PIC_Event;
|
||||
|
||||
#if C_NE2000
|
||||
//extern void *NE2000_TX_Event_PIC_Event; // Ne2000.cpp
|
||||
#endif
|
||||
|
||||
|
||||
// PIC_TimerHandlers
|
||||
@@ -1114,9 +1112,7 @@ extern void *KEYBOARD_TickHandler_PIC_Timer; // Keyboard.cpp
|
||||
//extern void *MIXER_Mix_NoSound_PIC_Timer; // Mixer.cpp
|
||||
extern void *MIXER_Mix_PIC_Timer;
|
||||
|
||||
#if C_NE2000
|
||||
//extern void *NE2000_Poller_PIC_Event; // Ne2000.cpp
|
||||
#endif
|
||||
|
||||
extern void *fmport_a_pic_event_PIC_Event;
|
||||
extern void *fmport_b_pic_event_PIC_Event;
|
||||
@@ -1153,9 +1149,7 @@ const void *pic_state_event_table[] = {
|
||||
fmport_b_pic_event_PIC_Event,
|
||||
PIC_IRQCheckDelayed_PIC_Event,
|
||||
|
||||
#if C_NE2000
|
||||
//NE2000_TX_Event_PIC_Event,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -1170,9 +1164,7 @@ const void *pic_state_timer_table[] = {
|
||||
//MIXER_Mix_NoSound_PIC_Timer,
|
||||
MIXER_Mix_PIC_Timer,
|
||||
|
||||
#if C_NE2000
|
||||
//NE2000_Poller_PIC_Event,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@@ -130,8 +130,8 @@
|
||||
/* Define to 1 to enable internal printer redirection support*/
|
||||
#define C_PRINTER 1
|
||||
|
||||
/* Define to 1 to enable NE2000 ethernet passthrough, requires libpcap */
|
||||
#define C_NE2000 1
|
||||
/* Define to 1 to enable ethernet passthrough, requires libpcap */
|
||||
#define C_PCAP 1
|
||||
|
||||
/* Set to 1 to enable SDL 1.x support */
|
||||
#define C_SDL1 1
|
||||
|
Reference in New Issue
Block a user