mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-07 05:29:22 +00:00
msvc build fixes for libnatpmp and miniupnpc
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13534 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
43cc68d811
commit
558ba02d18
@ -18,7 +18,9 @@
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#endif
|
||||||
/* There is no portable method to get the default route gateway.
|
/* There is no portable method to get the default route gateway.
|
||||||
* So below are three differents functions implementing this.
|
* So below are three differents functions implementing this.
|
||||||
* Parsing /proc/net/route is for linux.
|
* Parsing /proc/net/route is for linux.
|
||||||
@ -271,10 +273,10 @@ int getdefaultgateway(in_addr_t * addr)
|
|||||||
DWORD numSubKeys = 0;
|
DWORD numSubKeys = 0;
|
||||||
TCHAR keyName[MAX_KEY_LENGTH];
|
TCHAR keyName[MAX_KEY_LENGTH];
|
||||||
DWORD keyNameLength = MAX_KEY_LENGTH;
|
DWORD keyNameLength = MAX_KEY_LENGTH;
|
||||||
TCHAR keyValue[MAX_VALUE_LENGTH];
|
BYTE keyValue[MAX_VALUE_LENGTH];
|
||||||
DWORD keyValueLength = MAX_VALUE_LENGTH;
|
DWORD keyValueLength = MAX_VALUE_LENGTH;
|
||||||
DWORD keyValueType = REG_SZ;
|
DWORD keyValueType = REG_SZ;
|
||||||
TCHAR gatewayValue[MAX_VALUE_LENGTH];
|
BYTE gatewayValue[MAX_VALUE_LENGTH];
|
||||||
DWORD gatewayValueLength = MAX_VALUE_LENGTH;
|
DWORD gatewayValueLength = MAX_VALUE_LENGTH;
|
||||||
DWORD gatewayValueType = REG_MULTI_SZ;
|
DWORD gatewayValueType = REG_MULTI_SZ;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
@ -369,7 +371,7 @@ int getdefaultgateway(in_addr_t * addr)
|
|||||||
{
|
{
|
||||||
//printf("keyValue: %s\n", keyValue);
|
//printf("keyValue: %s\n", keyValue);
|
||||||
|
|
||||||
if(RegOpenKeyEx(interfacesKey, keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS)
|
if(RegOpenKeyEx(interfacesKey, (char *)keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
gatewayValueLength = MAX_VALUE_LENGTH;
|
gatewayValueLength = MAX_VALUE_LENGTH;
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
|
if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
|
||||||
@ -413,7 +415,7 @@ int getdefaultgateway(in_addr_t * addr)
|
|||||||
|
|
||||||
if(done)
|
if(done)
|
||||||
{
|
{
|
||||||
*addr = inet_addr(gatewayValue);
|
*addr = inet_addr((char *)gatewayValue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,11 @@
|
|||||||
#define __GETGATEWAY_H__
|
#define __GETGATEWAY_H__
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef unsigned __int32 uint32_t;
|
||||||
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
#define in_addr_t uint32_t
|
#define in_addr_t uint32_t
|
||||||
#endif
|
#endif
|
||||||
#include "declspec.h"
|
#include "declspec.h"
|
||||||
|
@ -16,13 +16,28 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <Ws2tcpip.h>
|
#include <Ws2tcpip.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
|
|
||||||
|
static int gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
|
||||||
|
union {
|
||||||
|
long long ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||||
|
FILETIME ft;
|
||||||
|
} _now;
|
||||||
|
|
||||||
|
GetSystemTimeAsFileTime( &(_now.ft) );
|
||||||
|
p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
|
||||||
|
p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -150,7 +165,7 @@ int sendnewportmappingrequest(natpmp_t * p, int protocol,
|
|||||||
if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP))
|
if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP))
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
return NATPMP_ERR_INVALIDARGS;
|
||||||
p->pending_request[0] = 0;
|
p->pending_request[0] = 0;
|
||||||
p->pending_request[1] = protocol;
|
p->pending_request[1] = (char)protocol;
|
||||||
p->pending_request[2] = 0;
|
p->pending_request[2] = 0;
|
||||||
p->pending_request[3] = 0;
|
p->pending_request[3] = 0;
|
||||||
*((uint16_t *)(p->pending_request + 4)) = htons(privateport);
|
*((uint16_t *)(p->pending_request + 4)) = htons(privateport);
|
||||||
@ -162,7 +177,7 @@ int sendnewportmappingrequest(natpmp_t * p, int protocol,
|
|||||||
|
|
||||||
int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response)
|
int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response)
|
||||||
{
|
{
|
||||||
unsigned char buf[16];
|
char buf[16];
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
socklen_t addrlen = sizeof(addr);
|
socklen_t addrlen = sizeof(addr);
|
||||||
int n;
|
int n;
|
||||||
|
@ -21,10 +21,17 @@
|
|||||||
#define NATPMP_PORT (5351)
|
#define NATPMP_PORT (5351)
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef unsigned __int32 uint32_t;
|
||||||
|
typedef unsigned __int16 uint16_t;
|
||||||
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
#define in_addr_t uint32_t
|
#define in_addr_t uint32_t
|
||||||
#include "declspec.h"
|
#include "declspec.h"
|
||||||
#else
|
#else
|
||||||
@ -36,7 +43,7 @@ typedef struct {
|
|||||||
int s; /* socket */
|
int s; /* socket */
|
||||||
in_addr_t gateway; /* default gateway (IPv4) */
|
in_addr_t gateway; /* default gateway (IPv4) */
|
||||||
int has_pending_request;
|
int has_pending_request;
|
||||||
unsigned char pending_request[12];
|
char pending_request[12];
|
||||||
int pending_request_len;
|
int pending_request_len;
|
||||||
int try_number;
|
int try_number;
|
||||||
struct timeval retry_time;
|
struct timeval retry_time;
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
#ifdef WIN32
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
typedef struct _FILETIME {
|
|
||||||
unsigned long dwLowDateTime;
|
|
||||||
unsigned long dwHighDateTime;
|
|
||||||
} FILETIME;
|
|
||||||
|
|
||||||
void __stdcall GetSystemTimeAsFileTime(FILETIME*);
|
|
||||||
|
|
||||||
//void gettimeofday(struct timeval* p, void* tz /* IGNORED */);
|
|
||||||
|
|
||||||
void gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
|
|
||||||
union {
|
|
||||||
long long ns100; /*time since 1 Jan 1601 in 100ns units */
|
|
||||||
FILETIME ft;
|
|
||||||
} _now;
|
|
||||||
|
|
||||||
GetSystemTimeAsFileTime( &(_now.ft) );
|
|
||||||
p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
|
|
||||||
p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
|||||||
do { n = (n << 7) | (*p & 0x7f); } \
|
do { n = (n << 7) | (*p & 0x7f); } \
|
||||||
while(*(p++)&0x80);
|
while(*(p++)&0x80);
|
||||||
|
|
||||||
#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \
|
#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (unsigned char)((n >> 28) | 0x80); \
|
||||||
if(n>=2097152) *(p++) = (n >> 21) | 0x80; \
|
if(n>=2097152) *(p++) = (unsigned char)((n >> 21) | 0x80); \
|
||||||
if(n>=16384) *(p++) = (n >> 14) | 0x80; \
|
if(n>=16384) *(p++) = (unsigned char)((n >> 14) | 0x80); \
|
||||||
if(n>=128) *(p++) = (n >> 7) | 0x80; \
|
if(n>=128) *(p++) = (unsigned char)((n >> 7) | 0x80); \
|
||||||
*(p++) = n & 0x7f;
|
*(p++) = (unsigned char)(n & 0x7f);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8,7 +8,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <io.h>
|
||||||
|
typedef intptr_t ssize_t;
|
||||||
|
#define read _read
|
||||||
|
#define write _write
|
||||||
|
#define close _close
|
||||||
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@ -27,6 +35,10 @@
|
|||||||
struct UPNPDev *
|
struct UPNPDev *
|
||||||
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
/* sockaddr_un not supported on msvc*/
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
struct UPNPDev * tmp;
|
struct UPNPDev * tmp;
|
||||||
struct UPNPDev * devlist = NULL;
|
struct UPNPDev * devlist = NULL;
|
||||||
unsigned char buffer[2048];
|
unsigned char buffer[2048];
|
||||||
@ -105,5 +117,6 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath)
|
|||||||
}
|
}
|
||||||
close(s);
|
close(s);
|
||||||
return devlist;
|
return devlist;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user