Modified:
/trunk/sipXportLib/include/os/OsDatagramSocket.h
/trunk/sipXportLib/src/os/OsDatagramSocket.cpp
=======================================
--- /trunk/sipXportLib/include/os/OsDatagramSocket.h Fri Jan 25 11:54:11
2008
+++ /trunk/sipXportLib/include/os/OsDatagramSocket.h Mon Feb 7 14:39:35
2011
@@ -79,7 +79,7 @@
//! param: buffer - the bytes to be written to the socket
//! param: bufferLength - the number of bytes contained in buffer
//! param: ipAddress - remote host to send datagram(s) to
- //! param: port - port on the remote host to send the datgram(s)
+ //! param: port - port on the remote host to send the datagram(s)
//! returns: the number of bytes actually written to the socket
virtual int read(char* buffer, int bufferLength);
@@ -140,6 +140,7 @@
virtual UtlBoolean getToSockaddr(void);
+ void makeICMPPortUnreachableResistant();
};
/* ============================ INLINE METHODS
============================ */
=======================================
--- /trunk/sipXportLib/src/os/OsDatagramSocket.cpp Fri Jan 25 11:54:11 2008
+++ /trunk/sipXportLib/src/os/OsDatagramSocket.cpp Mon Feb 7 14:39:35 2011
@@ -22,6 +22,7 @@
#if defined(_WIN32)
# include <winsock2.h>
# include <time.h>
+#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)
#elif defined(_VXWORKS)
# undef resolvGetHostByName
# include <inetLib.h>
@@ -141,6 +142,8 @@
close();
return error;
}
+
+ makeICMPPortUnreachableResistant();
return 0;
}
@@ -197,7 +200,6 @@
mLocalIp = localHost;
}
#endif
-
error = ::bind( socketDescriptor, (struct sockaddr*) &localAddr,
sizeof(localAddr));
@@ -564,6 +566,19 @@
return FALSE ;
}
+void OsDatagramSocket::makeICMPPortUnreachableResistant()
+{
+#if defined(_WIN32)
+ int newValue = FALSE;
+ unsigned long bytesReturned = 0;
+
+ int error = WSAIoctl(socketDescriptor, SIO_UDP_CONNRESET, &newValue,
sizeof(newValue), NULL, 0, &bytesReturned, NULL, NULL);
+ if(error == SOCKET_ERROR)
+ {
+ osPrintf("WSAIoctl call failed with error: %d in
OsSocket::OsSocket\n", error);
+ }
+#endif
+}
/* ============================ INQUIRY
=================================== */