Work being done. Had to change MAC address to my current one, Was being lazy to get MAC address from the device. One hack I was working with to get commercial games to work is removed, only one hack left. Socket Test responds to the DHCP packets every few tries, kind of a fail still. Haven't tested in Windows yet. If only commercial games worked, and socket test didn't fail still

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3465 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2009-06-16 15:16:09 +00:00
parent 8b9b796ff5
commit 5b9f26c660
2 changed files with 44 additions and 24 deletions

View File

@ -27,8 +27,6 @@
#include <linux/if_tun.h>
#include <assert.h>
int fd = -1;
bool hasDHCP = false;
#define IGNOREARP true
bool CEXIETHERNET::deactivate()
{
close(fd);
@ -52,7 +50,7 @@ bool CEXIETHERNET::activate() {
#if !defined(__APPLE__)
int err;
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE;
strncpy(ifr.ifr_name, "Dolphin", IFNAMSIZ);
@ -64,6 +62,17 @@ bool CEXIETHERNET::activate() {
return false;
}
ioctl( fd, TUNSETNOCSUM, 1 );
/*int flags;
if ((flags = fcntl( fd, F_GETFL)) < 0)
{
DEBUGPRINT("getflags on tun device: %s", strerror (errno));
}
flags |= O_NONBLOCK;
if (fcntl( fd, F_SETFL, flags ) < 0)
{
DEBUGPRINT("set tun device flags: %s", strerror (errno));
}*/
#endif
DEBUGPRINT("Returned Socket name is: %s\n", ifr.ifr_name);
system("brctl addif pan0 Dolphin");
@ -80,7 +89,7 @@ bool CEXIETHERNET::CheckRecieved()
int maxfd;
int retval;
struct timeval tv;
int timeout = 3; // 3 seconds will kill him
int timeout = 9999; // 3 seconds will kill him
fd_set mask;
/* Find the largest file descriptor */
@ -129,28 +138,34 @@ THREAD_RETURN CpuThread(void *pArg)
if(self->CheckRecieved())
{
u8 B[1514];
if((self->mRecvBufferLength = read(fd, B, 1500)) > 0)
self->mRecvBufferLength = read(fd, B, 1500);
//DEBUGPRINT("read return of 0x%x\n", self->mRecvBufferLength);
if (self->mRecvBufferLength == 0xffffffff)
{
//Fail Boat
continue;
}
else if(self->mRecvBufferLength > 0)
{
//mRecvBuffer.write(B, BytesRead);
//strncat(mRecvBuffer.p(), B, BytesRead);
memcpy(self->mRecvBuffer, B, self->mRecvBufferLength);
}
if(IGNOREARP)
else if(self->mRecvBufferLength == -1)
{
if(self->mRecvBuffer[12] == 0x08 && self->mRecvBuffer[13] == 0x06)
{
DEBUGPRINT("ARP Packet!Skipping!\n");
memset(self->mRecvBuffer, 0, self->mRecvBufferLength);
self->mRecvBufferLength = 0;
continue;
}
continue;
}
else
{
DEBUGPRINT("Unknown read return of 0x%x\n", self->mRecvBufferLength);
exit(0);
}
DEBUGPRINT("Received %d bytes of data\n", self->mRecvBufferLength);
self->handleRecvdPacket();
self->mWaiting = false;
self->handleRecvdPacket();
return 0;
}
sleep(1);
//sleep(1);
}
return 0;
}
@ -184,12 +199,7 @@ bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size)
DEBUGPRINT("BBA sendPacket %i only got %i bytes sent!errno: %d\n", size, numBytesWrit, errno);
return false;
}
else
DEBUGPRINT("Sent out the correct number of bytes: %d\n", size);
if(size == 342)
hasDHCP = true;
recordSendComplete();
//exit(0);
return true;
}
bool CEXIETHERNET::handleRecvdPacket()

View File

@ -51,7 +51,7 @@ void DEBUGPRINT (const char * format, ...)
#define RISE(flags) ((SwappedData & (flags)) && !(mBbaMem[0x00] & (flags)))
int mPacketsSent = 0;
u8 mac_address[6] = {'D', 'O', 'L', 'P', 'H', 'I'}; // Looks Appropriate
u8 mac_address[6] = {0x00, 0x1A, 0x4D, 0x5E, 0x64, 0x2B}; // Looks Appropriate
unsigned int Expecting;
CEXIETHERNET::~CEXIETHERNET()
{
@ -159,7 +159,6 @@ void CEXIETHERNET::recordSendComplete()
m_bInterruptSet = true;
//interrupt.raiseEXI("BBA Send");
}
startRecv();
mPacketsSent++;
}
@ -222,7 +221,7 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
// Whinecube did nothing else as well
DEBUGPRINT( "\t\t[INFO]BBA Reset\n");
}
if (RISE(BBA_NCRA_SR) && isActivated())
if ((SwappedData & BBA_NCRA_SR) && isActivated())
{
DEBUGPRINT( "\t\t[INFO]BBA Start Recieve\n");
//exit(0);
@ -252,6 +251,14 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
activate();
mBbaMem[BBA_NWAYS] = (BBA_NWAYS_LS10 | BBA_NWAYS_LPNWAY | BBA_NWAYS_ANCLPT | BBA_NWAYS_10TXF);
}
else
{
if(_uData != 0x0)
{
DEBUGPRINT("Not activate!\n");
exit(0);
}
}
break;
case BBA_RRP: //RRP - Receive Buffer Read Page Pointer
@ -282,7 +289,10 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
// Size of 4 untested Though
SwappedData = Common::swap32(_uData);
if(_uSize == 4)
{
printf("\t\t\tData is 0x%08x\n", SwappedData);
exit(0);
}
}
else if( _uSize == 2)
{
@ -303,7 +313,6 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
DEBUGPRINT( "\t[INFO]Request Dev ID\n");
mSpecialImmData = EXI_DEVTYPE_ETHER;
mExpectSpecialImmRead = true;
mBbaMem[0x01] = 0x0; // Refuse to use BBA if not 0 on reset?
return;
}
else if ((_uSize == 4 && (_uData & 0xC0000000) == 0xC0000000) || (_uSize == 2 && ((u16)Common::swap32(_uData >> 8) & 0x4000) == 0x4000))
@ -406,6 +415,7 @@ void CEXIETHERNET::ImmWrite(u32 _uData, u32 _uSize)
case 0x5c: // These two go together
break;
case 0x31: // NWAYS - NWAY Status Register
// HACK
activate();
mBbaMem[BBA_NWAYS] = (BBA_NWAYS_LS10 | BBA_NWAYS_LPNWAY | BBA_NWAYS_ANCLPT | BBA_NWAYS_10TXF);
case 0x09: // IR