Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
1fe527be
Commit
1fe527be
authored
Nov 30, 2011
by
Nader Morshed
Committed by
Youness Alaoui
Nov 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for windows's compilation through MinGW
parent
1b44dca9
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
101 additions
and
53 deletions
+101
-53
agent/Makefile.am
agent/Makefile.am
+7
-1
agent/address.h
agent/address.h
+0
-1
agent/agent.c
agent/agent.c
+4
-3
agent/interfaces.c
agent/interfaces.c
+21
-3
agent/pseudotcp.c
agent/pseudotcp.c
+25
-24
configure.ac
configure.ac
+17
-0
socket/tcp-bsd.c
socket/tcp-bsd.c
+1
-1
socket/udp-bsd.c
socket/udp-bsd.c
+1
-3
stun/Makefile.am
stun/Makefile.am
+4
-0
stun/rand.c
stun/rand.c
+4
-1
stun/tools/Makefile.am
stun/tools/Makefile.am
+4
-0
stun/tools/stunbdc.c
stun/tools/stunbdc.c
+6
-8
stun/tools/stund.c
stun/tools/stund.c
+1
-1
stun/usages/bind.c
stun/usages/bind.c
+3
-1
stun/usages/bind.h
stun/usages/bind.h
+1
-1
stun/usages/turn.h
stun/usages/turn.h
+1
-1
stun/win32_common.h
stun/win32_common.h
+1
-2
tests/Makefile.am
tests/Makefile.am
+0
-2
No files found.
agent/Makefile.am
View file @
1fe527be
...
...
@@ -18,7 +18,9 @@ AM_CFLAGS = \
-I
$(top_srcdir)
/socket
\
-I
$(top_srcdir)
/stun
COMMON_LDADD
=
libagent.la
$(GLIB_LIBS)
(
GUPNP_LIBS
)
if
WINDOWS
AM_CFLAGS
+=
-DWINVER
=
0x0501
# _WIN32_WINNT_WINXP
endif
dist_noinst_DATA
=
agent-signals-marshal.list
noinst_LTLIBRARIES
=
libagent.la
...
...
@@ -71,3 +73,7 @@ libagent_la_DEPENDENCIES = \
$(top_builddir)
/stun/libstun.la
pkginclude_HEADERS
=
agent.h candidate.h debug.h address.h interfaces.h pseudotcp.h
if
WINDOWS
libagent_la_LIBADD
+=
-lws2_32
endif
agent/address.h
View file @
1fe527be
...
...
@@ -55,7 +55,6 @@
#ifdef G_OS_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <wspiapi.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
...
...
agent/agent.c
View file @
1fe527be
...
...
@@ -50,7 +50,8 @@
#include <errno.h>
#ifdef G_OS_WIN32
#include <winsock2.h>
# include <winsock2.h>
# define EWOULDBLOCK WSAEWOULDBLOCK
#else
#include <sys/socket.h>
#include <netinet/in.h>
...
...
@@ -2878,13 +2879,13 @@ void
_priv_set_socket_tos
(
NiceAgent
*
agent
,
NiceSocket
*
sock
,
gint
tos
)
{
if
(
setsockopt
(
sock
->
fileno
,
IPPROTO_IP
,
IP_TOS
,
&
tos
,
sizeof
(
tos
))
<
0
)
{
IP_TOS
,
(
const
char
*
)
&
tos
,
sizeof
(
tos
))
<
0
)
{
nice_debug
(
"Agent %p: Could not set socket ToS"
,
agent
,
g_strerror
(
errno
));
}
#ifdef IPV6_TCLASS
if
(
setsockopt
(
sock
->
fileno
,
IPPROTO_IPV6
,
IPV6_TCLASS
,
&
tos
,
sizeof
(
tos
))
<
0
)
{
IPV6_TCLASS
,
(
const
char
*
)
&
tos
,
sizeof
(
tos
))
<
0
)
{
nice_debug
(
"Agent %p: Could not set IPV6 socket ToS"
,
agent
,
g_strerror
(
errno
));
}
...
...
agent/interfaces.c
View file @
1fe527be
...
...
@@ -350,6 +350,20 @@ nice_interfaces_get_ip_for_interface (gchar *interface_name)
#include <winsock2.h>
#include <Iphlpapi.h>
// Should be in Iphlpapi.h, but mingw doesn't seem to have these
// Values copied directly from:
// http://msdn.microsoft.com/en-us/library/aa366845(v=vs.85).aspx
// (Title: MIB_IPADDRROW structure)
#ifndef MIB_IPADDR_DISCONNECTED
#define MIB_IPADDR_DISCONNECTED 0x0008
#endif
#ifndef MIB_IPADDR_DELETED
#define MIB_IPADDR_DELETED 0x0040
#endif
#if 0
static gboolean started_wsa_engine = FALSE;
/*
...
...
@@ -383,6 +397,7 @@ SOCKET nice_interfaces_get_WSA_socket ()
return sock;
}
#endif
GList
*
nice_interfaces_get_local_interfaces
()
{
...
...
@@ -450,7 +465,7 @@ GList * nice_interfaces_get_local_ips (gboolean include_loopback)
continue
;
}
ipstr
=
g_strdup_printf
(
"%
d.%d.%d.%d
"
,
ipstr
=
g_strdup_printf
(
"%
lu.%lu.%lu.%lu
"
,
(
ipaddr
->
dwAddr
)
&
0xFF
,
(
ipaddr
->
dwAddr
>>
8
)
&
0xFF
,
(
ipaddr
->
dwAddr
>>
16
)
&
0xFF
,
...
...
@@ -471,8 +486,11 @@ GList * nice_interfaces_get_local_ips (gboolean include_loopback)
/*
* returns ip address as an utf8 string
*/
// Source for idx's type (Was IF_INDEX):
// http://msdn.microsoft.com/en-us/library/aa366836(v=VS.85).aspx
// (Title: MIB_IFROW structure)
static
gchar
*
win32_get_ip_for_interface
(
IF_INDEX
idx
)
win32_get_ip_for_interface
(
DWORD
idx
)
{
ULONG
size
=
0
;
PMIB_IPADDRTABLE
ip_table
;
...
...
@@ -491,7 +509,7 @@ win32_get_ip_for_interface (IF_INDEX idx)
PMIB_IPADDRROW
ipaddr
=
&
ip_table
->
table
[
i
];
if
(
ipaddr
->
dwIndex
==
idx
&&
!
(
ipaddr
->
wType
&
(
MIB_IPADDR_DISCONNECTED
|
MIB_IPADDR_DELETED
)))
{
ret
=
g_strdup_printf
(
"%
d.%d.%d.%d
"
,
ret
=
g_strdup_printf
(
"%
lu.%lu.%lu.%lu
"
,
(
ipaddr
->
dwAddr
)
&
0xFF
,
(
ipaddr
->
dwAddr
>>
8
)
&
0xFF
,
(
ipaddr
->
dwAddr
>>
16
)
&
0xFF
,
...
...
agent/pseudotcp.c
View file @
1fe527be
...
...
@@ -64,11 +64,19 @@
*/
#include <stdlib.h>
#include <arpa/inet.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#ifdef G_OS_WIN32
# include <winsock2.h>
# define ECONNABORTED WSAECONNABORTED
# define ENOTCONN WSAENOTCONN
# define EWOULDBLOCK WSAEWOULDBLOCK
# define ECONNRESET WSAECONNRESET
#else
# include <arpa/inet.h>
#endif
#include "pseudotcp.h"
...
...
@@ -176,17 +184,10 @@ const guint16 PACKET_MAXIMUMS[] = {
//////////////////////////////////////////////////////////////////////
// Helper Functions
//////////////////////////////////////////////////////////////////////
static
guint32
min
(
guint32
first
,
guint32
second
)
{
return
(
first
<
second
?
first
:
second
);
}
static
guint32
max
(
guint32
first
,
guint32
second
)
{
return
(
first
>
second
?
first
:
second
);
}
#ifndef G_OS_WIN32
# define min(first, second) ((first) < (second) ? (first) : (second))
# define max(first, second) ((first) > (second) ? (first) : (second))
#endif
static
guint32
bound
(
guint32
lower
,
guint32
middle
,
guint32
upper
)
...
...
@@ -792,16 +793,16 @@ packet(PseudoTcpSocket *self, guint32 seq, guint8 flags,
g_assert
(
HEADER_SIZE
+
len
<=
MAX_PACKET
);
*
((
uint32_t
*
)
buffer
)
=
htonl
(
priv
->
conv
);
*
((
uint32_t
*
)
(
buffer
+
4
))
=
htonl
(
seq
);
*
((
uint32_t
*
)
(
buffer
+
8
))
=
htonl
(
priv
->
rcv_nxt
);
*
((
guint32
*
)
buffer
)
=
htonl
(
priv
->
conv
);
*
((
guint32
*
)
(
buffer
+
4
))
=
htonl
(
seq
);
*
((
guint32
*
)
(
buffer
+
8
))
=
htonl
(
priv
->
rcv_nxt
);
buffer
[
12
]
=
0
;
buffer
[
13
]
=
flags
;
*
((
uint16_t
*
)
(
buffer
+
14
))
=
htons
((
uint16_t
)
priv
->
rcv_wnd
);
*
((
guint16
*
)
(
buffer
+
14
))
=
htons
((
guint16
)
priv
->
rcv_wnd
);
// Timestamp computations
*
((
uint32_t
*
)
(
buffer
+
16
))
=
htonl
(
now
);
*
((
uint32_t
*
)
(
buffer
+
20
))
=
htonl
(
priv
->
ts_recent
);
*
((
guint32
*
)
(
buffer
+
16
))
=
htonl
(
now
);
*
((
guint32
*
)
(
buffer
+
20
))
=
htonl
(
priv
->
ts_recent
);
priv
->
ts_lastack
=
priv
->
rcv_nxt
;
if
(
data
!=
NULL
)
...
...
@@ -839,14 +840,14 @@ parse(PseudoTcpSocket *self, const guint8 * buffer, guint32 size)
if
(
size
<
12
)
return
FALSE
;
seg
.
conv
=
ntohl
(
*
(
uint32_t
*
)
buffer
);
seg
.
seq
=
ntohl
(
*
(
uint32_t
*
)(
buffer
+
4
));
seg
.
ack
=
ntohl
(
*
(
uint32_t
*
)(
buffer
+
8
));
seg
.
conv
=
ntohl
(
*
(
guint32
*
)
buffer
);
seg
.
seq
=
ntohl
(
*
(
guint32
*
)(
buffer
+
4
));
seg
.
ack
=
ntohl
(
*
(
guint32
*
)(
buffer
+
8
));
seg
.
flags
=
buffer
[
13
];
seg
.
wnd
=
ntohs
(
*
(
uint16_t
*
)(
buffer
+
14
));
seg
.
wnd
=
ntohs
(
*
(
guint16
*
)(
buffer
+
14
));
seg
.
tsval
=
ntohl
(
*
(
uint32_t
*
)(
buffer
+
16
));
seg
.
tsecr
=
ntohl
(
*
(
uint32_t
*
)(
buffer
+
20
));
seg
.
tsval
=
ntohl
(
*
(
guint32
*
)(
buffer
+
16
));
seg
.
tsecr
=
ntohl
(
*
(
guint32
*
)(
buffer
+
20
));
seg
.
data
=
((
gchar
*
)
buffer
)
+
HEADER_SIZE
;
seg
.
len
=
size
-
HEADER_SIZE
;
...
...
configure.ac
View file @
1fe527be
...
...
@@ -6,9 +6,12 @@ dnl use a three digit version number for releases, and four for cvs/prerelease
AC_INIT(libnice, 0.1.1.0)
LIBNICE_RELEASE="no"
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([agent/agent.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([
Makefile
agent/Makefile
...
...
@@ -53,6 +56,20 @@ AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_LIBTOOL
# Check Operating System
AC_MSG_CHECKING([operating system])
case "$host" in
*-*-*mingw*|*-*-*cygwin*)
platform=win32
AC_MSG_RESULT($platform)
;;
*)
platform=linux/other
AC_MSG_RESULT($platform)
;;
esac
AM_CONDITIONAL([WINDOWS], [test "$platform" = "win32"])
# Checks for compiler features
...
...
socket/tcp-bsd.c
View file @
1fe527be
...
...
@@ -91,7 +91,7 @@ nice_tcp_bsd_socket_new (NiceAgent *agent, GMainContext *ctx, NiceAddress *addr)
int
sockfd
=
-
1
;
int
ret
;
struct
sockaddr_storage
name
;
guin
t
name_len
=
sizeof
(
name
);
socklen_
t
name_len
=
sizeof
(
name
);
NiceSocket
*
sock
;
TcpPriv
*
priv
;
...
...
socket/udp-bsd.c
View file @
1fe527be
...
...
@@ -51,9 +51,7 @@
#include "udp-bsd.h"
#ifdef G_OS_WIN32
typedef
unsigned
long
ssize_t
;
#else
#ifndef G_OS_WIN32
#include <unistd.h>
#endif
...
...
stun/Makefile.am
View file @
1fe527be
...
...
@@ -13,6 +13,10 @@ include $(top_srcdir)/common.mk
AM_CFLAGS
=
-std
=
gnu99
-DG_LOG_DOMAIN
=
\"
libnice-stun
\"
$(ERROR_CFLAGS)
AM_CPPFLAGS
=
-I
$(top_srcdir)
if
WINDOWS
AM_CFLAGS
+=
-DWINVER
=
0x0501
# _WIN32_WINNT_WINXP
endif
noinst_LTLIBRARIES
=
libstun.la
libstun_la_SOURCES
=
constants.h
\
...
...
stun/rand.c
View file @
1fe527be
...
...
@@ -43,6 +43,7 @@
#ifdef _WIN32
#include <windows.h>
#include <Wincrypt.h>
void
RAND_bytes
(
uint8_t
*
dst
,
int
len
)
{
...
...
@@ -51,7 +52,9 @@ void RAND_bytes (uint8_t *dst, int len)
if
(
!
CryptAcquireContext
(
&
hCryptProv
,
container
,
NULL
,
PROV_RSA_FULL
,
0
))
{
/* non existing container. try to create a new one */
if
(
GetLastError
()
==
NTE_BAD_KEYSET
)
{
// I hope this cast here doesn't cause issues
// gcc was complaining about comparing signed and unsigned values
if
(
GetLastError
()
==
(
DWORD
)
NTE_BAD_KEYSET
)
{
if
(
!
CryptAcquireContext
(
&
hCryptProv
,
container
,
NULL
,
PROV_RSA_FULL
,
CRYPT_NEWKEYSET
))
{
return
;
}
...
...
stun/tools/Makefile.am
View file @
1fe527be
...
...
@@ -23,3 +23,7 @@ stunbdc_SOURCES = stunbdc.c
stunbdc_LDADD
=
$(top_builddir)
/stun/libstun.la
if
WINDOWS
AM_CFLAGS
+=
-DWINVER
=
0x0501
# _WIN32_WINNT_WINXP
stunbdc_LDADD
+=
-lws2_32
endif
stun/tools/stunbdc.c
View file @
1fe527be
...
...
@@ -40,9 +40,12 @@
# include <config.h>
#endif
#ifndef _WIN32
#include <sys/socket.h>
#include <netdb.h>
#ifdef _WIN32
# include <winsock2.h>
#else
# include <sys/socket.h>
# include <netdb.h>
#endif
#include <sys/types.h>
#include "stun/stunagent.h"
...
...
@@ -184,8 +187,3 @@ int main (int argc, char *argv[])
return
run
(
family
,
server
,
port
)
?
1
:
0
;
}
#else
int
main
()
{
return
0
;
}
#endif
stun/tools/stund.c
View file @
1fe527be
...
...
@@ -346,7 +346,7 @@ int main (int argc, char *argv[])
}
#else
int
main
()
{
int
main
(
int
argc
,
char
**
argv
)
{
return
0
;
}
#endif
stun/usages/bind.c
View file @
1fe527be
...
...
@@ -54,6 +54,7 @@
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <fcntl.h>
#endif
...
...
@@ -70,7 +71,6 @@
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include "timer.h"
...
...
@@ -394,11 +394,13 @@ stun_trans_recv (StunTransport *tr, uint8_t *buf, size_t maxlen)
}
#ifdef HAVE_POLL
static
int
stun_trans_fd
(
const
StunTransport
*
tr
)
{
assert
(
tr
!=
NULL
);
return
tr
->
fd
;
}
#endif
/*
...
...
stun/usages/bind.h
View file @
1fe527be
...
...
@@ -52,7 +52,7 @@
#ifdef _WIN32
#
include "
win32_common.h"
#
include "../
win32_common.h"
#else
# include <stdbool.h>
# include <stdint.h>
...
...
stun/usages/turn.h
View file @
1fe527be
...
...
@@ -53,7 +53,7 @@
#ifdef _WIN32
#
include "
win32_common.h"
#
include "../
win32_common.h"
#else
# include <stdbool.h>
# include <stdint.h>
...
...
stun/win32_common.h
View file @
1fe527be
...
...
@@ -57,6 +57,7 @@
#ifndef _WIN32_COMMON_H
#define _WIN32_COMMON_H
#include <sys/types.h>
/* 7.18.1.1 Exact-width integer types */
typedef
signed
char
int8_t
;
...
...
@@ -67,8 +68,6 @@ typedef int int32_t;
typedef
unsigned
uint32_t
;
typedef
long
long
int64_t
;
typedef
unsigned
long
long
uint64_t
;
typedef
unsigned
int
size_t
;
typedef
unsigned
long
ssize_t
;
typedef
uint8_t
bool
;
#define true 1
...
...
tests/Makefile.am
View file @
1fe527be
...
...
@@ -62,8 +62,6 @@ test_restart_LDADD = $(COMMON_LDADD)
test_fallback_LDADD
=
$(COMMON_LDADD)
test_thread_LDADD
=
$(COMMON_LDADD)
test_dribble_LDADD
=
$(COMMON_LDADD)
all-local
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment