Changeset - r1343:ea7fb505ae74
[Not reviewed]
master
0 2 0
tron - 19 years ago 2005-02-08 15:42:28
tron@openttd.org
(svn r1847) Adjustment for MorphOS to unbreak the build there and removal of some now obsolete preprocessor magic
2 files changed with 3 insertions and 5 deletions:
0 comments (0 inline, 0 general)
network_core.h
Show inline comments
 
@@ -99,59 +99,61 @@ typedef struct ifreq IFREQ;
 
#	include <types.h>
 
#	include <unistd.h>
 
#	include <sys/ioctl.h>
 
#	include <sys/socket.h>
 
#	include <netinet/in.h>
 
#	include <netinet/tcp.h>
 
#	include <arpa/inet.h>
 
#	include <net/if.h>
 
#	include <errno.h>
 
#	include <sys/time.h>
 
#	include <netdb.h>
 
#	include <nerrno.h>
 
#	define INADDR_NONE 0xffffffff
 

	
 
typedef unsigned long in_addr_t;
 
#endif // OS/2
 

	
 
// MorphOS and Amiga stuff
 
#if defined(__MORPHOS__) || defined(__AMIGA__)
 
#	include <exec/types.h>
 
#	include <proto/exec.h>		// required for Open/CloseLibrary()
 
#	if defined(__MORPHOS__)
 
#		include <sys/filio.h> 	// FIO* defines
 
#		include <sys/sockio.h>  // SIO* defines
 
#		include <netinet/in.h>
 
#	else // __AMIGA__
 
#		include	<proto/socket.h>
 
#	endif
 

	
 
// Make the names compatible
 
#	define closesocket(s) CloseSocket(s)
 
#	define GET_LAST_ERROR() Errno()
 
#	define ioctlsocket(s,request,status) IoctlSocket((LONG)s,(ULONG)request,(char*)status)
 
#	define ioctl ioctlsocket
 

	
 
	typedef unsigned int in_addr_t;
 
	typedef long         socklen_t;
 
	extern struct Library *SocketBase;
 

	
 
#	ifdef __AMIGA__
 
	// for usleep() implementation
 
	extern struct Device      *TimerBase;
 
	extern struct MsgPort     *TimerPort;
 
	extern struct timerequest *TimerRequest;
 
#	endif
 
#endif // __MORPHOS__ || __AMIGA__
 

	
 
static inline bool SetNonBlocking(int d)
 
{
 
	int nonblocking = 1;
 
	#if defined(__BEOS__) && defined(BEOS_NET_SERVER)
 
	return setsockopt(d, SOL_SOCKET, SO_NONBLOCK, &nonblocking, sizeof(nonblocking)) == 0;
 
	#else
 
	return ioctlsocket(d, FIONBIO, &nonblocking) == 0;
 
	#endif
 
}
 

	
 
static inline bool SetNoDelay(int d)
 
{
 
	// XXX should this be done at all?
 
	#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server
network_udp.c
Show inline comments
 
@@ -381,53 +381,49 @@ void NetworkUDPClose(void)
 
			closesocket(_udp_server_socket);
 
			_udp_server_socket = INVALID_SOCKET;
 
		}
 

	
 
		if (_udp_master_socket != INVALID_SOCKET) {
 
			closesocket(_udp_master_socket);
 
			_udp_master_socket = INVALID_SOCKET;
 
		}
 

	
 
		_network_udp_server = false;
 
		_network_udp_broadcast = 0;
 
	} else {
 
		if (_udp_client_socket != INVALID_SOCKET) {
 
			closesocket(_udp_client_socket);
 
			_udp_client_socket = INVALID_SOCKET;
 
		}
 
		_network_udp_broadcast = 0;
 
	}
 
}
 

	
 
// Receive something on UDP level
 
void NetworkUDPReceive(SOCKET udp)
 
{
 
	struct sockaddr_in client_addr;
 
#ifndef __MORPHOS__
 
	int client_len;
 
#else
 
	LONG client_len; // for some reason we need a 'LONG' under MorphOS
 
#endif
 
	socklen_t client_len;
 
	int nbytes;
 
	static Packet *p = NULL;
 
	int packet_len;
 

	
 
	// If p is NULL, malloc him.. this prevents unneeded mallocs
 
	if (p == NULL)
 
		p = malloc(sizeof(Packet));
 

	
 
	packet_len = sizeof(p->buffer);
 
	client_len = sizeof(client_addr);
 

	
 
	// Try to receive anything
 
	nbytes = recvfrom(udp, p->buffer, packet_len, 0, (struct sockaddr *)&client_addr, &client_len);
 

	
 
	// We got some bytes.. just asume we receive the whole packet
 
	if (nbytes > 0) {
 
		// Get the size of the buffer
 
		p->size = (uint16)p->buffer[0];
 
		p->size += (uint16)p->buffer[1] << 8;
 
		// Put the position on the right place
 
		p->pos = 2;
 
		p->next = NULL;
 

	
 
		// Handle the packet
0 comments (0 inline, 0 general)