diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index 5f120871f..0214262f4 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -1149,27 +1149,27 @@ int WIFI_SoftAP_Init(wifimac_t *wifi) SoftAP_CRC32Table[i] = reflect(SoftAP_CRC32Table[i], 32); } - if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) { printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf); return 0; } - wifi->SoftAP.bridge = pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, NULL, errbuf); + wifi->SoftAP.bridge = PCAP::pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, NULL, errbuf); if(wifi->SoftAP.bridge == NULL) { printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf); return 0; } - pcap_freealldevs(alldevs); + PCAP::pcap_freealldevs(alldevs); return 1; } void WIFI_SoftAP_Shutdown(wifimac_t *wifi) { - pcap_close(wifi->SoftAP.bridge); + PCAP::pcap_close(wifi->SoftAP.bridge); } void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) @@ -1327,7 +1327,7 @@ void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) /* Checksum */ /* TODO ? */ - pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen); + PCAP::pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen); delete ethernetframe; } diff --git a/desmume/src/wifi.h b/desmume/src/wifi.h index 0cd56ac03..9494dface 100644 --- a/desmume/src/wifi.h +++ b/desmume/src/wifi.h @@ -31,6 +31,7 @@ #include #define socket_t SOCKET #define sockaddr_t SOCKADDR + #include "windriver.h" #else #include #include @@ -51,8 +52,6 @@ #define PACKET_SIZE 65535 #define _INC_STDIO -#include -#include //uh? #define REG_WIFI_ID 0x000 #define REG_WIFI_MODE 0x004 diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 9a4a7cf71..d54f3fa08 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -141,7 +141,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;NDEBUG" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;NDEBUG;EXPERIMENTAL_WIFI" StringPooling="true" ExceptionHandling="1" BufferSecurityCheck="false" @@ -163,7 +163,7 @@ /> - - - - - - @@ -850,6 +826,14 @@ Name="MASM" /> + + + #include #include -#ifdef EXPERIMENTAL_WIFI -#include -#endif #include "CWindow.h" #include "../MMU.h" #include "../armcpu.h" @@ -2149,16 +2146,20 @@ void RunConfig(CONFIGSCREEN which) break; case CONFIGSCREEN_EMULATION: DialogBox(hAppInst, MAKEINTRESOURCE(IDD_EMULATIONSETTINGS), hwnd, (DLGPROC)EmulationSettingsDlgProc); - break; + break; case CONFIGSCREEN_WIFI: +#ifdef EXPERIMENTAL_WIFI if(wifiMac.netEnabled) { DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); } else { +#endif MessageBox(MainWindow->getHWnd(),"winpcap failed to initialize, and so wifi cannot be configured.","wifi system failure",0); +#ifdef EXPERIMENTAL_WIFI } +#endif break; } @@ -3295,7 +3296,7 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM int i; HWND cur; - if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) { EndDialog(hDlg, TRUE); return TRUE; diff --git a/desmume/src/windows/windriver.h b/desmume/src/windows/windriver.h index 025244b85..a8d99ee8f 100644 --- a/desmume/src/windows/windriver.h +++ b/desmume/src/windows/windriver.h @@ -5,6 +5,24 @@ #include "../common.h" #include "CWindow.h" +#ifdef EXPERIMENTAL_WIFI +#include +#include //uh? + +//because the pcap headers are written poorly, we need to declare these as cdecl +//this may cause the code to fail to compile on non-windows platforms; +//we may have to use a macro to call these functions which chooses whether to call them +//through the namespace +namespace PCAP { + extern "C" __declspec(dllexport) int __cdecl pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); + extern "C" __declspec(dllexport) int __cdecl pcap_sendpacket(pcap_t *, const u_char *, int); + extern "C" __declspec(dllexport) void __cdecl pcap_close(pcap_t *); + extern "C" __declspec(dllexport) pcap_t* __cdecl pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); + extern "C" __declspec(dllexport) void __cdecl pcap_freealldevs(pcap_if_t *); +} + +#endif + extern WINCLASS *MainWindow; class Lock {