SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
Submitted By: Nick Leverton (leveret) Fix the order of header inclusion for FreeBSD. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@504 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
0c578f7962
commit
cbbbb14e21
@ -2,6 +2,11 @@
|
|||||||
Version 1.8.0
|
Version 1.8.0
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
* SF Patch Tracker [ 2969188 ] 1.8.0: patch for FreeBSD compilation
|
||||||
|
Submitted By: Nick Leverton (leveret)
|
||||||
|
Fix the order of header inclusion for FreeBSD.
|
||||||
|
|
||||||
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2010-03-20 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Forward port of svn revision 502:
|
* Forward port of svn revision 502:
|
||||||
SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
|
SF Patch Tracker [ 2836704 ] Search for nested serviceList (not
|
||||||
|
@ -58,7 +58,12 @@
|
|||||||
};
|
};
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/time.h> /* for gettimeofday() */
|
#include <sys/time.h> /* for gettimeofday() */
|
||||||
|
#if defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||||
|
#include <sys/resource.h> /* for setpriority() */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
* \file
|
* \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if ! defined(WIN32)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "UpnpGlobal.h" /* For EXPORT_SPEC */
|
#include "UpnpGlobal.h" /* For EXPORT_SPEC */
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#if defined(BSD)
|
||||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined(WIN32)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
|
|
||||||
|
|
||||||
@ -214,11 +218,11 @@ static int CmpThreadPoolJob( void *jobA, void *jobB )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* ThreadPoolJob *tpj - must be allocated with CreateThreadPoolJob
|
* ThreadPoolJob *tpj - must be allocated with CreateThreadPoolJob
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void FreeThreadPoolJob( ThreadPool *tp, ThreadPoolJob *tpj )
|
static void FreeThreadPoolJob(ThreadPool *tp, ThreadPoolJob *tpj)
|
||||||
{
|
{
|
||||||
assert( tp != NULL );
|
assert(tp != NULL);
|
||||||
|
|
||||||
FreeListFree( &tp->jobFreeList, tpj );
|
FreeListFree(&tp->jobFreeList, tpj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -228,28 +232,30 @@ static void FreeThreadPoolJob( ThreadPool *tp, ThreadPoolJob *tpj )
|
|||||||
* Sets the scheduling policy of the current process.
|
* Sets the scheduling policy of the current process.
|
||||||
* Internal only.
|
* Internal only.
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* PolocyType in
|
* PolicyType in
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 on success, nonzero on failure
|
* 0 on success, nonzero on failure
|
||||||
* Returns result of GetLastError() on failure.
|
* Returns result of GetLastError() on failure.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPolicyType( PolicyType in )
|
static int SetPolicyType(PolicyType in)
|
||||||
{
|
{
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
/* TODO not currently working... */
|
/* TODO not currently working... */
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(__OSX__) || defined(__APPLE__)
|
#elif defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
|
||||||
setpriority( PRIO_PROCESS, 0, 0 );
|
setpriority(PRIO_PROCESS, 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
return sched_setscheduler( 0, in );
|
return sched_setscheduler(0, in);
|
||||||
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
struct sched_param current;
|
struct sched_param current;
|
||||||
|
int sched_result;
|
||||||
|
|
||||||
sched_getparam( 0, ¤t );
|
sched_getparam(0, ¤t);
|
||||||
current.sched_priority = DEFAULT_SCHED_PARAM;
|
current.sched_priority = DEFAULT_SCHED_PARAM;
|
||||||
return sched_setscheduler( 0, in, ¤t );
|
sched_result = sched_setscheduler(0, in, ¤t);
|
||||||
|
return (-1 != sched_result || EPERM == errno) ? 0 : -1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@ -269,7 +275,7 @@ static int SetPolicyType( PolicyType in )
|
|||||||
* Returns result of GerLastError on failure.
|
* Returns result of GerLastError on failure.
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int SetPriority( ThreadPriority priority )
|
static int SetPriority(ThreadPriority priority)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
#if defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
|
||||||
int currentPolicy;
|
int currentPolicy;
|
||||||
@ -278,6 +284,7 @@ static int SetPriority( ThreadPriority priority )
|
|||||||
int actPriority = 0;
|
int actPriority = 0;
|
||||||
int midPriority = 0;
|
int midPriority = 0;
|
||||||
struct sched_param newPriority;
|
struct sched_param newPriority;
|
||||||
|
int sched_result;
|
||||||
|
|
||||||
pthread_getschedparam( ithread_self(), ¤tPolicy, &newPriority );
|
pthread_getschedparam( ithread_self(), ¤tPolicy, &newPriority );
|
||||||
minPriority = sched_get_priority_min( currentPolicy );
|
minPriority = sched_get_priority_min( currentPolicy );
|
||||||
@ -299,7 +306,8 @@ static int SetPriority( ThreadPriority priority )
|
|||||||
|
|
||||||
newPriority.sched_priority = actPriority;
|
newPriority.sched_priority = actPriority;
|
||||||
|
|
||||||
return pthread_setschedparam(ithread_self(), currentPolicy, &newPriority );
|
sched_result = pthread_setschedparam(ithread_self(), currentPolicy, &newPriority);
|
||||||
|
return (0 == sched_result || EPERM == errno) ? 0 : -1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
@ -399,7 +407,7 @@ static void SetSeed()
|
|||||||
gettimeofday(&t, NULL);
|
gettimeofday(&t, NULL);
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id().p );
|
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id().p );
|
||||||
#elif defined(__FreeBSD__) || defined(__OSX__) || defined(__APPLE__)
|
#elif defined(BSD) || defined(__OSX__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
|
||||||
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id() );
|
srand( ( unsigned int )t.tv_usec + (unsigned int)ithread_get_current_thread_id() );
|
||||||
#elif defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined(__GLIBC__)
|
#elif defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined(__GLIBC__)
|
||||||
srand( ( unsigned int )t.tv_usec + ithread_get_current_thread_id() );
|
srand( ( unsigned int )t.tv_usec + ithread_get_current_thread_id() );
|
||||||
@ -1525,11 +1533,8 @@ void ThreadPoolPrintStats(ThreadPoolStats *stats)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
/* some OSses time_t length may depending on platform, promote it to long for safety */
|
||||||
printf("ThreadPoolStats at Time: %d\n", StatsTime(NULL));
|
printf("ThreadPoolStats at Time: %ld\n", (long)StatsTime(NULL));
|
||||||
#else /* __FreeBSD__ */
|
|
||||||
printf("ThreadPoolStats at Time: %ld\n", StatsTime(NULL));
|
|
||||||
#endif /* __FreeBSD__ */
|
|
||||||
printf("High Jobs pending: %d\n", stats->currentJobsHQ);
|
printf("High Jobs pending: %d\n", stats->currentJobsHQ);
|
||||||
printf("Med Jobs Pending: %d\n", stats->currentJobsMQ);
|
printf("Med Jobs Pending: %d\n", stats->currentJobsMQ);
|
||||||
printf("Low Jobs Pending: %d\n", stats->currentJobsLQ);
|
printf("Low Jobs Pending: %d\n", stats->currentJobsLQ);
|
||||||
|
@ -15,6 +15,13 @@
|
|||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <Ws2tcpip.h>
|
#include <Ws2tcpip.h>
|
||||||
#else
|
#else
|
||||||
|
#include <sys/param.h>
|
||||||
|
#if (defined(BSD) && BSD >= 199306) || defined (__FreeBSD_kernel__)
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
/* Do not move or remove the include below for "sys/socket"!
|
||||||
|
* Will break FreeBSD builds. */
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,6 +50,17 @@
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* Do not include these files */
|
/* Do not include these files */
|
||||||
#else
|
#else
|
||||||
|
#include <sys/param.h>
|
||||||
|
#if defined(_sun)
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#elif defined(BSD) && BSD >= 199306
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
/* Do not move or remove the include below for "sys/socket"!
|
||||||
|
* Will break FreeBSD builds. */
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -58,17 +69,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(_sun)
|
|
||||||
#include <sys/sockio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#elif defined(BSD) && BSD >= 199306
|
|
||||||
#include <ifaddrs.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -2961,7 +2962,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
|
|
||||||
inet_ntop(AF_INET, &v4_addr, gIF_IPV4, sizeof(gIF_IPV4));
|
inet_ntop(AF_INET, &v4_addr, gIF_IPV4, sizeof(gIF_IPV4));
|
||||||
inet_ntop(AF_INET6, &v6_addr, gIF_IPV6, sizeof(gIF_IPV6));
|
inet_ntop(AF_INET6, &v6_addr, gIF_IPV6, sizeof(gIF_IPV6));
|
||||||
#elif (defined(BSD) && BSD >= 199306)
|
#elif (defined(BSD) && BSD >= 199306) || defined(__FreeBSD_kernel__)
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
struct in_addr v4_addr;
|
struct in_addr v4_addr;
|
||||||
struct in6_addr v6_addr;
|
struct in6_addr v6_addr;
|
||||||
@ -3478,7 +3479,7 @@ int getlocalhostname(char *out, const int out_len)
|
|||||||
h = gethostbyname(out);
|
h = gethostbyname(out);
|
||||||
if (h != NULL) {
|
if (h != NULL) {
|
||||||
memcpy(&LocalAddr.sin_addr, h->h_addr_list[0], 4);
|
memcpy(&LocalAddr.sin_addr, h->h_addr_list[0], 4);
|
||||||
p = inet_ntop(AF_INET, &LocalAddr.sin_addr, tempstr, 16);
|
p = inet_ntop(AF_INET, &LocalAddr.sin_addr, tempstr, sizeof(tempstr));
|
||||||
if (p) {
|
if (p) {
|
||||||
strncpy(out, p, out_len);
|
strncpy(out, p, out_len);
|
||||||
} else {
|
} else {
|
||||||
@ -3492,9 +3493,8 @@ int getlocalhostname(char *out, const int out_len)
|
|||||||
ret = UPNP_E_INIT;
|
ret = UPNP_E_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined(BSD) && BSD >= 199306)
|
#elif (defined(BSD) && BSD >= 199306) || defined(__FreeBSD_kernel__)
|
||||||
struct ifaddrs *ifap, *ifa;
|
struct ifaddrs *ifap, *ifa;
|
||||||
char tempstr[16];
|
|
||||||
|
|
||||||
if (getifaddrs(&ifap) != 0) {
|
if (getifaddrs(&ifap) != 0) {
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
@ -3517,12 +3517,14 @@ int getlocalhostname(char *out, const int out_len)
|
|||||||
htonl(INADDR_LOOPBACK)) {
|
htonl(INADDR_LOOPBACK)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p = inet_ntop(AF_INET, &LocalAddr.sin_addr, tempstr, 16);
|
p = inet_ntop(AF_INET,
|
||||||
|
&((struct sockaddr_in *)(ifa->ifa_addr))->sin_addr,
|
||||||
|
tempstr, sizeof(tempstr));
|
||||||
if (p) {
|
if (p) {
|
||||||
strncpy(out, p, out_len);
|
strncpy(out, p, out_len);
|
||||||
} else {
|
} else {
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"getlocalhostname: inet_ntop returned error\n" );
|
"getlocalhostname: inet_ntop returned error\n");
|
||||||
ret = UPNP_E_INIT;
|
ret = UPNP_E_INIT;
|
||||||
}
|
}
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
@ -3596,7 +3598,7 @@ int getlocalhostname(char *out, const int out_len)
|
|||||||
}
|
}
|
||||||
close(LocalSock);
|
close(LocalSock);
|
||||||
|
|
||||||
p = inet_ntop(AF_INET, &LocalAddr.sin_addr, tempstr, 16);
|
p = inet_ntop(AF_INET, &LocalAddr.sin_addr, tempstr, sizeof(tempstr));
|
||||||
if (p) {
|
if (p) {
|
||||||
strncpy(out, p, out_len);
|
strncpy(out, p, out_len);
|
||||||
} else {
|
} else {
|
||||||
|
@ -668,9 +668,10 @@ static int get_miniserver_sockets(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (listenfd4 != INVALID_SOCKET) {
|
if (listenfd4 != INVALID_SOCKET) {
|
||||||
|
unsigned short orig_listen_port4 = listen_port4;
|
||||||
do {
|
do {
|
||||||
serverAddr4->sin_port = htons(listen_port4++);
|
serverAddr4->sin_port = htons(listen_port4++);
|
||||||
sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4, sizeof(__ss_v4));
|
sockError = bind(listenfd4, (struct sockaddr *)serverAddr4, sizeof(*serverAddr4));
|
||||||
if (sockError == -1) {
|
if (sockError == -1) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
errCode = WSAGetLastError();
|
errCode = WSAGetLastError();
|
||||||
@ -683,7 +684,7 @@ static int get_miniserver_sockets(
|
|||||||
} else {
|
} else {
|
||||||
errCode = 0;
|
errCode = 0;
|
||||||
}
|
}
|
||||||
} while ( errCode != 0 );
|
} while ( errCode != 0 && (listen_port4 >= orig_listen_port4) );
|
||||||
|
|
||||||
if (sockError == -1) {
|
if (sockError == -1) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
@ -699,9 +700,10 @@ static int get_miniserver_sockets(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (listenfd6 != INVALID_SOCKET) {
|
if (listenfd6 != INVALID_SOCKET) {
|
||||||
|
unsigned short orig_listen_port6 = listen_port6;
|
||||||
do {
|
do {
|
||||||
serverAddr6->sin6_port = htons(listen_port6++);
|
serverAddr6->sin6_port = htons(listen_port6++);
|
||||||
sockError = bind(listenfd6, (struct sockaddr *)&__ss_v6, sizeof(__ss_v6));
|
sockError = bind(listenfd6, (struct sockaddr *)serverAddr6, sizeof(*serverAddr6));
|
||||||
if (sockError == -1) {
|
if (sockError == -1) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
errCode = WSAGetLastError();
|
errCode = WSAGetLastError();
|
||||||
@ -714,7 +716,7 @@ static int get_miniserver_sockets(
|
|||||||
} else {
|
} else {
|
||||||
errCode = 0;
|
errCode = 0;
|
||||||
}
|
}
|
||||||
} while (errCode != 0);
|
} while (errCode != 0 && (listen_port6 >= orig_listen_port6));
|
||||||
|
|
||||||
if (sockError == -1) {
|
if (sockError == -1) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
|
@ -38,6 +38,10 @@
|
|||||||
* \file
|
* \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(WIN32)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "UpnpGlobal.h" /* for */
|
#include "UpnpGlobal.h" /* for */
|
||||||
#include "UpnpInet.h"
|
#include "UpnpInet.h"
|
||||||
@ -48,6 +52,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#if defined(BSD)
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(WIN32)
|
||||||
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@ -1034,7 +1037,7 @@ int create_ssdp_sock_v4( SOCKET* ssdpSock )
|
|||||||
u_char ttl = 4;
|
u_char ttl = 4;
|
||||||
struct ip_mreq ssdpMcastAddr;
|
struct ip_mreq ssdpMcastAddr;
|
||||||
struct sockaddr_storage __ss;
|
struct sockaddr_storage __ss;
|
||||||
struct sockaddr_in* ssdpAddr4 = (struct sockaddr_in*)&__ss;
|
struct sockaddr_in *ssdpAddr4 = (struct sockaddr_in *)&__ss;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
@ -1061,7 +1064,7 @@ int create_ssdp_sock_v4( SOCKET* ssdpSock )
|
|||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__OSX__) || defined(__APPLE__)
|
#if defined(BSD) || defined(__OSX__) || defined(__APPLE__)
|
||||||
onOff = 1;
|
onOff = 1;
|
||||||
ret = setsockopt( *ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
ret = setsockopt( *ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||||
(char *)&onOff, sizeof(onOff) );
|
(char *)&onOff, sizeof(onOff) );
|
||||||
@ -1074,14 +1077,13 @@ int create_ssdp_sock_v4( SOCKET* ssdpSock )
|
|||||||
|
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
#endif /* __FreeBSD__ */
|
#endif /* BSD */
|
||||||
|
|
||||||
memset( &__ss, 0, sizeof( __ss ) );
|
memset( &__ss, 0, sizeof( __ss ) );
|
||||||
ssdpAddr4->sin_family = AF_INET;
|
ssdpAddr4->sin_family = AF_INET;
|
||||||
// ssdpAddr.sin_addr.s_addr = inet_addr(gIF_IPV4);
|
|
||||||
ssdpAddr4->sin_addr.s_addr = htonl( INADDR_ANY );
|
ssdpAddr4->sin_addr.s_addr = htonl( INADDR_ANY );
|
||||||
ssdpAddr4->sin_port = htons( SSDP_PORT );
|
ssdpAddr4->sin_port = htons( SSDP_PORT );
|
||||||
ret = bind( *ssdpSock, (struct sockaddr *)&__ss, sizeof(__ss) );
|
ret = bind( *ssdpSock, (struct sockaddr *)ssdpAddr4, sizeof(*ssdpAddr4) );
|
||||||
if ( ret == -1 ) {
|
if ( ret == -1 ) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
@ -1161,7 +1163,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
|
|||||||
char errorBuffer[ERROR_BUFFER_LEN];
|
char errorBuffer[ERROR_BUFFER_LEN];
|
||||||
struct ipv6_mreq ssdpMcastAddr;
|
struct ipv6_mreq ssdpMcastAddr;
|
||||||
struct sockaddr_storage __ss;
|
struct sockaddr_storage __ss;
|
||||||
struct sockaddr_in6* ssdpAddr6 = (struct sockaddr_in6*)&__ss;
|
struct sockaddr_in6 *ssdpAddr6 = (struct sockaddr_in6 *)&__ss;
|
||||||
int onOff;
|
int onOff;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -1187,7 +1189,7 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
|
|||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__OSX__) || defined(__APPLE__)
|
#if defined(BSD) || defined(__OSX__) || defined(__APPLE__)
|
||||||
onOff = 1;
|
onOff = 1;
|
||||||
ret = setsockopt( *ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
ret = setsockopt( *ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||||
(char*)&onOff, sizeof (onOff) );
|
(char*)&onOff, sizeof (onOff) );
|
||||||
@ -1200,15 +1202,14 @@ int create_ssdp_sock_v6( SOCKET* ssdpSock )
|
|||||||
|
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
#endif /* __FreeBSD__ */
|
#endif /* BSD */
|
||||||
|
|
||||||
memset( &__ss, 0, sizeof( __ss ) );
|
memset( &__ss, 0, sizeof( __ss ) );
|
||||||
ssdpAddr6->sin6_family = AF_INET6;
|
ssdpAddr6->sin6_family = AF_INET6;
|
||||||
ssdpAddr6->sin6_addr = in6addr_any;
|
ssdpAddr6->sin6_addr = in6addr_any;
|
||||||
//inet_pton( AF_INET6, gIF_IPV6, &ssdpAddr6->sin6_addr );
|
|
||||||
ssdpAddr6->sin6_scope_id = gIF_INDEX;
|
ssdpAddr6->sin6_scope_id = gIF_INDEX;
|
||||||
ssdpAddr6->sin6_port = htons( SSDP_PORT );
|
ssdpAddr6->sin6_port = htons( SSDP_PORT );
|
||||||
ret = bind( *ssdpSock, (struct sockaddr *)&__ss, sizeof(__ss) );
|
ret = bind( *ssdpSock, (struct sockaddr *)ssdpAddr6, sizeof(*ssdpAddr6) );
|
||||||
if ( ret == -1 ) {
|
if ( ret == -1 ) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user