fix bugs in wifi no-winpcap handling. make vs2008 debug build able to load savestates. add some notes for luigi with "luigi:"

This commit is contained in:
zeromus 2009-05-31 23:53:38 +00:00
parent 9c2369fac6
commit 1ce2cb86f5
3 changed files with 29 additions and 25 deletions

View File

@ -520,8 +520,7 @@ int NDS_Init( void) {
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI
WIFI_Init(&wifiMac) ; WIFI_Init(&wifiMac) ;
if(wifiMac.netEnabled) WIFI_SoftAP_Init(&wifiMac);
WIFI_SoftAP_Init(&wifiMac);
#endif #endif
nds.FW_ARM9BootCode = NULL; nds.FW_ARM9BootCode = NULL;
@ -541,8 +540,7 @@ void NDS_DeInit(void) {
gpu3D->NDS_3D_Close(); gpu3D->NDS_3D_Close();
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI
if(wifiMac.netEnabled) WIFI_SoftAP_Shutdown(&wifiMac);
WIFI_SoftAP_Shutdown(&wifiMac);
#endif #endif
} }
@ -1079,10 +1077,8 @@ void NDS_Reset(BOOL resetBySavestate)
#ifdef EXPERIMENTAL_WIFI #ifdef EXPERIMENTAL_WIFI
WIFI_Init(&wifiMac); WIFI_Init(&wifiMac);
if(wifiMac.netEnabled) { WIFI_SoftAP_Shutdown(&wifiMac);
WIFI_SoftAP_Shutdown(&wifiMac); WIFI_SoftAP_Init(&wifiMac);
WIFI_SoftAP_Init(&wifiMac);
}
#endif #endif
memcpy(FW_Mac, (MMU.fw.data + 0x36), 6); memcpy(FW_Mac, (MMU.fw.data + 0x36), 6);

View File

@ -483,9 +483,10 @@ static void WIFI_TXStart(wifimac_t *wifi,u8 slot)
{ {
u16 txLen ; u16 txLen ;
/* the address has to be somewhere in the circular buffer, so drop the other bits */ /* the address has to be somewhere in the circular buffer, so drop the other bits */
u16 address = (wifi->TXSlot[slot] & 0x7FFF) ; u16 address = (wifi->TXSlot[slot] & 0x7FFF) ; //luigi: shouldnt this be 0xFFF (see W_TXBUF_LOC3 in gbatek)
/* is there even enough space for the header (6 hwords) in the tx buffer? */ /* is there even enough space for the header (6 hwords) in the tx buffer? */
if (address > 0x1000-6) return ; if (address > 0x1000-6) return ; //luigi: you shouldnt do this. put assertions or LOG() calls in spots like this.
//when an emulation is in the state that wifi is at, silently swallowing errors will make it hard to debug
/* 12 byte header TX Header: http://www.akkit.org/info/dswifi.htm#FmtTx */ /* 12 byte header TX Header: http://www.akkit.org/info/dswifi.htm#FmtTx */
txLen = /*ntohs*/(wifi->circularBuffer[address+5]) ; txLen = /*ntohs*/(wifi->circularBuffer[address+5]) ;
@ -1155,28 +1156,34 @@ int WIFI_SoftAP_Init(wifimac_t *wifi)
SoftAP_CRC32Table[i] = reflect(SoftAP_CRC32Table[i], 32); SoftAP_CRC32Table[i] = reflect(SoftAP_CRC32Table[i], 32);
} }
if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) if(wifiMac.netEnabled)
{ {
printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf); if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)
return 0; {
} printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf);
return 0;
}
wifi->SoftAP.bridge = PCAP::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) if(wifi->SoftAP.bridge == NULL)
{ {
printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf); printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf);
return 0; return 0;
} }
PCAP::pcap_freealldevs(alldevs); PCAP::pcap_freealldevs(alldevs);
}
return 1; return 1;
} }
void WIFI_SoftAP_Shutdown(wifimac_t *wifi) void WIFI_SoftAP_Shutdown(wifimac_t *wifi)
{ {
if(wifiMac.netEnabled)
{
if(wifi->SoftAP.bridge != NULL) if(wifi->SoftAP.bridge != NULL)
PCAP::pcap_close(wifi->SoftAP.bridge); PCAP::pcap_close(wifi->SoftAP.bridge);
}
} }
void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len)
@ -1334,7 +1341,8 @@ void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len)
/* Checksum */ /* Checksum */
/* TODO ? */ /* TODO ? */
PCAP::pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen); if(wifi->netEnabled) //dont try to pcap out the packet unless network is enabled
PCAP::pcap_sendpacket(wifi->SoftAP.bridge, ethernetframe, eflen);
delete ethernetframe; delete ethernetframe;
} }

View File

@ -52,10 +52,10 @@
EnableFiberSafeOptimizations="false" EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false" WholeProgramOptimization="false"
AdditionalIncludeDirectories=".;..;"glib-2.20.1\build";"glib-2.20.1\build\glib";.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig" AdditionalIncludeDirectories=".;..;"glib-2.20.1\build";"glib-2.20.1\build\glib";.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig"
PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;WIN32;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;EXPERIMENTAL_WIFI;HAVE_LIBZZIP" PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;WIN32;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;EXPERIMENTAL_WIFI;HAVE_LIBZ;HAVE_LIBZZIP"
ExceptionHandling="1" ExceptionHandling="1"
BasicRuntimeChecks="0" BasicRuntimeChecks="3"
BufferSecurityCheck="false" BufferSecurityCheck="true"
EnableEnhancedInstructionSet="2" EnableEnhancedInstructionSet="2"
FloatingPointModel="2" FloatingPointModel="2"
DebugInformationFormat="4" DebugInformationFormat="4"