/* * Copyright (C) 2002-2011 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "dosbox.h" #if C_IPX #include "dosbox.h" #include "ipxserver.h" #include "timer.h" #include #include #include "ipx.h" IPaddress ipxServerIp; // IPAddress for server's listening port UDPsocket ipxServerSocket; // Listening server socket packetBuffer connBuffer[SOCKETTABLESIZE]; Bit8u inBuffer[IPXBUFFERSIZE]; IPaddress ipconn[SOCKETTABLESIZE]; // Active TCP/IP connection UDPsocket tcpconn[SOCKETTABLESIZE]; // Active TCP/IP connections SDLNet_SocketSet serverSocketSet; TIMER_TickHandler* serverTimer; Bit8u packetCRC(Bit8u *buffer, Bit16u bufSize) { Bit8u tmpCRC = 0; Bit16u i; for(i=0;isrc.addr.byIP.host; desthost = tmpHeader->dest.addr.byIP.host; srcport = tmpHeader->src.addr.byIP.port; destport = tmpHeader->dest.addr.byIP.port; if(desthost == 0xffffffff) { // Broadcast for(i=0;i= SOCKETTABLESIZE) return false; *ptrAddr = &ipconn[tableNum]; return connBuffer[tableNum].connected; } static void ackClient(IPaddress clientAddr) { IPXHeader regHeader; UDPpacket regPacket; Bits result; SDLNet_Write16(0xffff, regHeader.checkSum); SDLNet_Write16(sizeof(regHeader), regHeader.length); SDLNet_Write32(0, regHeader.dest.network); PackIP(clientAddr, ®Header.dest.addr.byIP); SDLNet_Write16(0x2, regHeader.dest.socket); SDLNet_Write32(1, regHeader.src.network); PackIP(ipxServerIp, ®Header.src.addr.byIP); SDLNet_Write16(0x2, regHeader.src.socket); regHeader.transControl = 0; regPacket.data = (Uint8 *)®Header; regPacket.len = sizeof(regHeader); regPacket.maxlen = sizeof(regHeader); regPacket.address = clientAddr; // Send registration string to client. If client doesn't get this, client will not be registered result = SDLNet_UDP_Send(ipxServerSocket,-1,®Packet); } static void IPX_ServerLoop() { UDPpacket inPacket; IPaddress tmpAddr; //char regString[] = "IPX Register\0"; Bit16u i; Bit32u host; Bits result; inPacket.channel = -1; inPacket.data = &inBuffer[0]; inPacket.maxlen = IPXBUFFERSIZE; result = SDLNet_UDP_Recv(ipxServerSocket, &inPacket); if (result != 0) { // Check to see if incoming packet is a registration packet // For this, I just spoofed the echo protocol packet designation 0x02 IPXHeader *tmpHeader; tmpHeader = (IPXHeader *)&inBuffer[0]; // Check to see if echo packet if(SDLNet_Read16(tmpHeader->dest.socket) == 0x2) { // Null destination node means its a server registration packet if(tmpHeader->dest.addr.byIP.host == 0x0) { UnpackIP(tmpHeader->src.addr.byIP, &tmpAddr); for(i=0;i