Unfortunately it breaks off the binary compatibility
try it, the mac opentrasport version is not tested (i not have mac :-/)
See ya!--------------------------------------
Index: SDL_net.h
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDL_net.h,v
retrieving revision 1.22
diff -u -r1.22 SDL_net.h
— SDL_net.h 7 Aug 2003 01:34:23 -0000 1.22
+++ SDL_net.h 30 Aug 2003 20:52:24 -0000
@@ -99,10 +99,30 @@
*/
extern DECLSPEC const char * SDLCALL SDLNet_ResolveIP(IPaddress *ip);
+//
+/* ICMP network API patch by Emanuele “Goul_duKat” Trevisio
<@Goul_duKat>*/
+//
+#ifdef ACTIVATE_SDLNET_ICMP
+
+//Open a ICMP channel for send echo
+extern DECLSPEC int SDLCALL SDLNet_ICMP_Open(void);
+
+//Close the ICMP channel
+extern DECLSPEC int SDLCALL SDLNet_ICMP_Close(void);
+
+//Fast count rtt and hop (in win32 not need the open of the ICMP channel)
+extern DECLSPEC int SDLCALL SDLNet_ICMP_fast_routeping(Uint32 ip,Uint32
maxhop,Uint32* hop,Uint32* rtt);
+
+//Normal echo whit ttl for traceroute facilities
+//tristate function return -1 on error, 1 no error 2 TTL expired (add for
trace facilities)
+extern DECLSPEC int SDLCALL SDLNet_ICMP_echo(Uint32 ip,Uint8 ttl,Uint32
timeout,Uint32* rtt,Uint32* ipr);
+#endif
//
/* TCP network API */
//
+#define SDLNET_OPEN_NORMAL_MODE 0
+#define SDLNET_OPEN_BINDLOCAL 1
typedef struct _TCPsocket *TCPsocket;
@@ -114,7 +134,10 @@
SDLNet_ResolveHost() are already in the correct form).
The newly created socket is returned, or NULL if there was an error.
*/
-extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip);
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>/
+extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip,Uint8
open_mode);
/* Accept an incoming connection on the given server socket.
The newly created socket is returned, or NULL if there was an error.
@@ -186,7 +209,10 @@
internally in network (big endian) byte order, in addresses, etc.
This allows other systems to send to this socket via a known port.
*/
-extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port);
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>/
+extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(IPaddress *ip,Uint8
open_mode);
/* Bind the address ‘address’ to the requested channel on the UDP socket.
If the channel is -1, then the first unbound channel will be bound with
Index: SDLnet.c
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnet.c,v
retrieving revision 1.11
diff -u -r1.11 SDLnet.c
— SDLnet.c 30 Aug 2003 17:32:47 -0000 1.11
+++ SDLnet.c 30 Aug 2003 20:52:25 -0000
@@ -20,7 +20,7 @@
slouken at libsdl.org
*/
-/* $Id: SDLnet.c,v 1.11 2003/08/30 17:32:47 slouken Exp $ /
+/ $Id: SDLnet.c,v 1.10 2003/07/23 05:08:43 slouken Exp $ */
#include <string.h>
@@ -280,6 +280,16 @@
{
if ( !SDLNet_started ) {
#ifdef __USE_W32_SOCKETS
+#ifdef _WINSOCK2_H
- /* Start up the windows networking */
- WORD version_wanted = MAKEWORD(2,2);
- WSADATA wsaData;
- if ( WSAStartup(version_wanted, &wsaData) != 0 ) {
- SDLNet_SetError(“Couldn’t initialize Winsock 2.0\n”);
- return(-1);
- }
+#else
/* Start up the windows networking */
WORD version_wanted = MAKEWORD(1,1);
WSADATA wsaData;
@@ -288,6 +298,7 @@
SDLNet_SetError(“Couldn’t initialize Winsock 1.1\n”);
return(-1);
}
+#endif //_WINSOCK2_H
#else
;
#endif
Index: SDLnetTCP.c
===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetTCP.c,v
retrieving revision 1.11
diff -u -r1.11 SDLnetTCP.c
— SDLnetTCP.c 13 Apr 2002 14:50:37 -0000 1.11
+++ SDLnetTCP.c 30 Aug 2003 20:52:25 -0000
@@ -278,7 +278,10 @@
Now endpoint is created in Async mode.
01/02/20 )
*/
-TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>/
+TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode )
{
EndpointRef dummy = NULL;
@@ -287,7 +290,7 @@
return NULL;
// Determin whether bind locally, or connect to remote
- if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) )
- if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) && open_mode ==
SDLNET_OPEN_NORMAL_MODE )
{
// ######## Connect to remote
OTResult stat;
@@ -399,6 +402,8 @@
else
{
// ######## Bind locally - if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
compatibility - TBind bindReq;
InetAddress inAddr;
@@ -431,7 +436,7 @@
}
// Bind the socket
- OTInitInetAddress(&inAddr, ip->port, 0 );
- OTInitInetAddress(&inAddr, ip->port, ip->host );
inAddr.fAddressType = AF_INET;
bindReq.addr.len = sizeof( InetAddress );
bindReq.addr.buf = (unsigned char*)&inAddr;
@@ -695,7 +700,10 @@
otherwise a TCP connection to the remote host and port is attempted.
The newly created socket is returned, or NULL if there was an error.
*/
-TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>/
+TCPsocket SDLNet_TCP_Open(IPaddress *ip,Uint8 open_mode)
{
TCPsocket sock;
struct sockaddr_in sock_addr;
@@ -715,7 +723,7 @@
}
/* Connect to remote, or bind locally, as appropriate */
- if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
-
if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
open_mode==SDLNET_OPEN_NORMAL_MODE ) {// ######### Connecting to remote
@@ -734,16 +742,17 @@
} else {
// ########## Binding locally
- if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
compatibility - memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = INADDR_ANY;
-
sock_addr.sin_addr.s_addr = ip->host;
sock_addr.sin_port = ip->port;/* allow local address reuse */
- { int yes = 1;
- /{ int yes = 1;
setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char)&yes,
sizeof(yes));
- }
-
}*///Dangerous and non needed settings for normal use !!!
/* Bind the socket for listening */
if ( bind(sock->channel, (struct sockaddr )&sock_addr,
Index: SDLnetUDP.c
===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL_net/SDLnetUDP.c,v
retrieving revision 1.9
diff -u -r1.9 SDLnetUDP.c
— SDLnetUDP.c 14 Jun 2003 07:20:31 -0000 1.9
+++ SDLnetUDP.c 30 Aug 2003 20:52:26 -0000
@@ -272,7 +272,10 @@
/ Open a UDP network socket
If ‘port’ is non-zero, the UDP socket is bound to a fixed local port.
*/
-extern UDPsocket SDLNet_UDP_Open(Uint16 port)
+//use open mode for bind local ip = SDLNET_OPEN_BINDLOCAL
+/add open mode to listen local definite ip in IPaddress
+patch by Emanuele “Goul_duKat” Trevisio <@Goul_duKat>/
+extern UDPsocket SDLNet_UDP_Open(IPaddress *ip,Uint8 open_mode)
{
UDPsocket sock;
#ifdef MACOS_OPENTRANSPORT
@@ -329,18 +332,32 @@
assigned_addr.addr.len = sizeof(assigned);
assigned_addr.addr.buf = (UInt8 *) &assigned;
- if ( port ) {
- if ( ip->port ) {
status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );
if( status != kOTNoError )
goto error_return;
- OTInitInetAddress(&required, port, info.fAddress );
-
if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
open_mode==SDLNET_OPEN_NORMAL_MODE ) -
OTInitInetAddress(&required, ip->port, info.fAddress );
-
else OTInitInetAddress(&required, ip->port, ip->host );
req_addr.addr.maxlen = sizeof( required );
req_addr.addr.len = sizeof( required );
req_addr.addr.buf = (UInt8 *) &required;sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);
} else { -
if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
open_mode==SDLNET_OPEN_NORMAL_MODE )
sock->error = OTBind(sock->channel, nil, &assigned_addr ); -
else
-
{
-
status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );
-
if( status != kOTNoError )
-
goto error_return;
-
OTInitInetAddress(&required, 0, ip->host );
-
req_addr.addr.maxlen = sizeof( required );
-
req_addr.addr.len = sizeof( required );
-
req_addr.addr.buf = (UInt8 *) &required;
-
sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);
-
}
}
AsyncUDPPopEvent(sock);
@@ -363,13 +380,19 @@
}
#else
/* Bind locally, if appropriate */
- if ( port )
- //if ( ip->port ) //whit no else is broken ??? for port == 0 ???
{
struct sockaddr_in sock_addr;
memset(&sock_addr, 0, sizeof(sock_addr));
sock_addr.sin_family = AF_INET; - if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) &&
open_mode==SDLNET_OPEN_NORMAL_MODE )
sock_addr.sin_addr.s_addr = INADDR_ANY;
- sock_addr.sin_port = SDL_SwapBE16(port);
-
else
-
{
-
if (ip->host == INADDR_NONE) ip->host == INADDR_ANY; //need for
compatibility -
sock_addr.sin_addr.s_addr = ip->host;
-
}
-
sock_addr.sin_port = SDL_SwapBE16(ip->port);
/* Bind the socket for listening */
if ( bind(sock->channel, (struct sockaddr *)&sock_addr,