diff --git a/agent/agent.c b/agent/agent.c index 5c3fc93..5b94a02 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -2678,8 +2678,11 @@ agent_attach_stream_component_socket (NiceAgent *agent, if (!component->ctx) return; - +#ifndef G_OS_WIN32 io = g_io_channel_unix_new (socket->fileno); +#else + io = g_io_channel_win32_new_socket (socket->fileno); +#endif /* note: without G_IO_ERR the glib mainloop goes into * busyloop if errors are encountered */ source = g_io_create_watch (io, G_IO_IN | G_IO_ERR); diff --git a/agent/pseudotcp.c b/agent/pseudotcp.c index ce701d2..2ce00fd 100644 --- a/agent/pseudotcp.c +++ b/agent/pseudotcp.c @@ -353,7 +353,7 @@ static PseudoTcpDebugLevel debug_level = PSEUDO_TCP_DEBUG_NONE; #define DEBUG(level, fmt, ...) \ if (debug_level >= level) \ - g_debug ("PseudoTcpSocket %p: " fmt, self, ## __VA_ARGS__) + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "PseudoTcpSocket %p: " fmt, self, ## __VA_ARGS__) void pseudo_tcp_set_debug_level (PseudoTcpDebugLevel level) @@ -1142,10 +1142,10 @@ process(PseudoTcpSocket *self, Segment *seg) iter = priv->rlist; } } else { - DEBUG (PSEUDO_TCP_DEBUG_NORMAL, "Saving %d bytes (%d -> %d)", + GList *iter = NULL; + RSegment *rseg = g_slice_new0 (RSegment); + DEBUG (PSEUDO_TCP_DEBUG_NORMAL, "Saving %d bytes (%d -> %d)", seg->len, seg->seq, seg->seq + seg->len); - GList *iter = NULL; - RSegment *rseg = g_slice_new0 (RSegment); rseg->seq = seg->seq; rseg->len = seg->len; iter = priv->rlist; diff --git a/socket/tcp-bsd.c b/socket/tcp-bsd.c index ac90eaa..049398c 100644 --- a/socket/tcp-bsd.c +++ b/socket/tcp-bsd.c @@ -387,7 +387,11 @@ add_to_be_sent (NiceSocket *sock, const gchar *buf, guint len, gboolean head) g_queue_push_tail (&priv->send_queue, tbs); if (priv->io_channel == NULL) { +#ifndef G_OS_WIN32 priv->io_channel = g_io_channel_unix_new (sock->fileno); +#else + priv->io_channel = g_io_channel_win32_new_socket (sock->fileno); +#endif priv->io_source = g_io_create_watch (priv->io_channel, G_IO_OUT); g_source_set_callback (priv->io_source, (GSourceFunc) socket_send_more, sock, NULL); diff --git a/stun/sha1.h b/stun/sha1.h index 1383a6f..27ea014 100644 --- a/stun/sha1.h +++ b/stun/sha1.h @@ -15,7 +15,11 @@ #ifndef SHA1_H #define SHA1_H +#ifdef _WIN32 +#include "win32_common.h" +#else #include +#endif #include #define SHA1_MAC_LEN 20 diff --git a/stun/win32_common.h b/stun/win32_common.h index cfb862d..5f8e593 100644 --- a/stun/win32_common.h +++ b/stun/win32_common.h @@ -69,6 +69,11 @@ typedef unsigned uint32_t; typedef long long int64_t; typedef unsigned long long uint64_t; +#ifndef _SSIZE_T_ +typedef unsigned int size_t; +typedef unsigned long ssize_t; +#endif + typedef uint8_t bool; #define true 1 #define false 0 diff --git a/tests/test-dribble.c b/tests/test-dribble.c index 3c9f732..eb18055 100644 --- a/tests/test-dribble.c +++ b/tests/test-dribble.c @@ -44,6 +44,9 @@ #include #include +#ifdef _WIN32 +#define __func__ __FUNCTION__ +#endif static NiceComponentState global_lagent_state = NICE_COMPONENT_STATE_LAST; static NiceComponentState global_ragent_state = NICE_COMPONENT_STATE_LAST; @@ -207,6 +210,14 @@ int main (void) GSList *cands, *i; guint ls_id, rs_id; +#ifdef G_OS_WIN32 + WSADATA w; +#endif + +#ifdef G_OS_WIN32 + WSAStartup(0x0202, &w); +#endif + g_type_init (); #if !GLIB_CHECK_VERSION(2,31,8) g_thread_init (NULL); diff --git a/tests/test-fullmode.c b/tests/test-fullmode.c index 3a45acb..3fb2908 100644 --- a/tests/test-fullmode.c +++ b/tests/test-fullmode.c @@ -43,6 +43,9 @@ #include #include +#ifdef _WIN32 +#define __func__ __FUNCTION__ +#endif #define USE_TURN 0 #define USE_LOOPBACK 1 @@ -145,7 +148,7 @@ static void priv_print_global_status (void) static gboolean timer_cb (gpointer pointer) { - g_debug ("test-fullmode:%s: %p", G_STRFUNC, pointer); + g_debug ("test-fullmode:%s: %p", __func__, pointer); /* signal status via a global variable */ @@ -163,7 +166,7 @@ static void cb_writable (NiceAgent*agent, guint stream_id, guint component_id) static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id, guint len, gchar *buf, gpointer user_data) { - g_debug ("test-fullmode:%s: %p", G_STRFUNC, user_data); + g_debug ("test-fullmode:%s: %p", __func__, user_data); /* XXX: dear compiler, these are for you: */ (void)agent; (void)stream_id; (void)component_id; (void)buf; @@ -185,7 +188,7 @@ static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint component_id, static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer data) { - g_debug ("test-fullmode:%s: %p", G_STRFUNC, data); + g_debug ("test-fullmode:%s: %p", __func__, data); if (GPOINTER_TO_UINT (data) == 1) global_lagent_gathering_done = TRUE; @@ -803,6 +806,14 @@ int main (void) guint timer_id; const char *stun_server = NULL, *stun_server_port = NULL; +#ifdef G_OS_WIN32 + WSADATA w; +#endif + +#ifdef G_OS_WIN32 + WSAStartup(0x0202, &w); +#endif + g_type_init (); #if !GLIB_CHECK_VERSION(2,31,8) g_thread_init(NULL); diff --git a/tests/test-pseudotcp.c b/tests/test-pseudotcp.c index 363fcde..699c1ca 100644 --- a/tests/test-pseudotcp.c +++ b/tests/test-pseudotcp.c @@ -41,6 +41,17 @@ #include #include +#ifdef WIN32 +# include +# define ECONNABORTED WSAECONNABORTED +# define ENOTCONN WSAENOTCONN +# define EWOULDBLOCK WSAEWOULDBLOCK +# define ECONNRESET WSAECONNRESET +#else +# include +#endif + + #include "pseudotcp.h" PseudoTcpSocket *left; diff --git a/tests/test.c b/tests/test.c index 98e38d2..a580e6e 100644 --- a/tests/test.c +++ b/tests/test.c @@ -52,6 +52,14 @@ main (void) GSList *candidates, *i; guint stream_id; +#ifdef G_OS_WIN32 + WSADATA w; +#endif + +#ifdef G_OS_WIN32 + WSAStartup(0x0202, &w); +#endif + nice_address_init (&addr_local); nice_address_init (&addr_remote); g_type_init ();