diff --git a/libupnp/ChangeLog b/libupnp/ChangeLog index e7f9f42..1d65171 100644 --- a/libupnp/ChangeLog +++ b/libupnp/ChangeLog @@ -1,3 +1,7 @@ +2006-07-03 Marcelo Jimenez + + * Patch for FreeBSD, thanks to Markus Strobl. + 2006-06-26 Marcelo Jimenez * Fix for missing "else" in httpreadwrite.c. Thanks to npapadop diff --git a/libupnp/threadutil/src/LinkedList.c b/libupnp/threadutil/src/LinkedList.c index c1b2950..d1f418e 100644 --- a/libupnp/threadutil/src/LinkedList.c +++ b/libupnp/threadutil/src/LinkedList.c @@ -30,7 +30,11 @@ /////////////////////////////////////////////////////////////////////////// #include "LinkedList.h" +#ifdef __FreeBSD__ +#include +#else #include +#endif #include static int diff --git a/libupnp/threadutil/src/ThreadPool.c b/libupnp/threadutil/src/ThreadPool.c index 7ff818c..ee30b51 100644 --- a/libupnp/threadutil/src/ThreadPool.c +++ b/libupnp/threadutil/src/ThreadPool.c @@ -345,10 +345,12 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: struct timeb t; ftime( &t ); -#ifndef WIN32 - srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) ); -#else +#if defined(WIN32) srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ).p ); +#elif defined(__FreeBSD__) + srand( ( unsigned int )t.millitm + (unsigned int)ithread_get_current_thread_id( ) ); +#else + srand( ( unsigned int )t.millitm + ithread_get_current_thread_id( ) ); #endif } @@ -1463,7 +1465,11 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff; break; default: assert( stats != NULL ); if( stats == NULL ) { return;} + #ifdef __FreeBSD__ + printf( "ThreadPoolStats at Time: %d\n", time( NULL ) ); + #else printf( "ThreadPoolStats at Time: %ld\n", time( NULL ) ); + #endif printf ( "Average Wait in High Priority Q in milliseconds: %lf\n", stats->avgWaitHQ ); diff --git a/libupnp/threadutil/src/iasnprintf.c b/libupnp/threadutil/src/iasnprintf.c index cf03295..57d9f72 100644 --- a/libupnp/threadutil/src/iasnprintf.c +++ b/libupnp/threadutil/src/iasnprintf.c @@ -31,7 +31,11 @@ #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include "iasnprintf.h" diff --git a/libupnp/upnp/inc/upnp.h b/libupnp/upnp/inc/upnp.h index 7a53ea9..9e68bb2 100644 --- a/libupnp/upnp/inc/upnp.h +++ b/libupnp/upnp/inc/upnp.h @@ -37,6 +37,9 @@ //@{ #include +#ifdef __FreeBSD__ +#include +#endif #include "ixml.h" #include "upnpconfig.h" #if UPNP_HAVE_DEBUG diff --git a/libupnp/upnp/src/genlib/net/uri/uri.c b/libupnp/upnp/src/genlib/net/uri/uri.c index 38f6f98..588ef4b 100644 --- a/libupnp/upnp/src/genlib/net/uri/uri.c +++ b/libupnp/upnp/src/genlib/net/uri/uri.c @@ -33,6 +33,9 @@ * Purpose: This file contains functions for uri, url parsing utility. ************************************************************************/ +#ifdef __FreeBSD__ +#include +#endif #include "config.h" #include "uri.h" @@ -608,21 +611,27 @@ parse_hostport( char *in, int errCode = 0; //call gethostbyname_r (reentrant form of gethostbyname) - #ifdef WIN32 - h=gethostbyname(temp_host_name); - #else - #ifndef SPARC_SOLARIS - errCode = gethostbyname_r( temp_host_name, - &h_buf, - temp_hostbyname_buff, - BUFFER_SIZE, &h, &errcode ); - #else - errCode = gethostbyname_r( temp_host_name, - &h, - temp_hostbyname_buff, - BUFFER_SIZE, &errcode ); - #endif - #endif +#if defined(WIN32) + h=gethostbyname(temp_host_name); +#elif defined(SPARC_SOLARIS) + errCode = gethostbyname_r( temp_host_name, + &h, + temp_hostbyname_buff, + BUFFER_SIZE, &errcode ); +#elif defined(__FreeBSD__) + h = lwres_gethostbyname_r( temp_host_name, + &h_buf, + temp_hostbyname_buff, + BUFFER_SIZE, &errcode ); + if ( h == NULL ) { + errCode = 1; + } +#else + errCode = gethostbyname_r( temp_host_name, + &h_buf, + temp_hostbyname_buff, + BUFFER_SIZE, &h, &errcode ); +#endif if( errCode == 0 ) { if( h ) { diff --git a/libupnp/upnp/src/ssdp/ssdp_server.c b/libupnp/upnp/src/ssdp/ssdp_server.c index 0da0839..f9b19cb 100644 --- a/libupnp/upnp/src/ssdp/ssdp_server.c +++ b/libupnp/upnp/src/ssdp/ssdp_server.c @@ -960,6 +960,22 @@ get_ssdp_sockets( MiniServerSockArray * out ) UpnpCloseSocket( ssdpSock ); return UPNP_E_SOCKET_ERROR; } + + #ifdef __FreeBSD__ + if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT, + ( char * )&onOff, sizeof( onOff ) ) != 0 ) { + + DBGONLY( UpnpPrintf( UPNP_CRITICAL, + SSDP, __FILE__, __LINE__, + "Error in set reuse port !!!\n" ); + ) + CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) ); + CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) ); + shutdown( ssdpSock, SD_BOTH ); + UpnpCloseSocket( ssdpSock ); + return UPNP_E_SOCKET_ERROR; + } + #endif memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) ); ssdpAddr.sin_family = AF_INET;