Commit 822c9056 authored by Kai Vehmanen's avatar Kai Vehmanen

Updated test coverage of udp submodule. Fixed compile errors from anonymous...

Updated test coverage of udp submodule. Fixed compile errors from anonymous unions. Added NICEAPI_EXPORT attributes.

darcs-hash:20070619080102-77cd4-53bf984380ed5f56fc89ad57a4750926d0887afb.gz
parent 307d62f7
...@@ -32,6 +32,7 @@ udp_client_LDADD = $(COMMON_LDADD) ...@@ -32,6 +32,7 @@ udp_client_LDADD = $(COMMON_LDADD)
udp_echo_server_LDADD = $(COMMON_LDADD) udp_echo_server_LDADD = $(COMMON_LDADD)
check_PROGRAMS = test-fake test-bsd check_PROGRAMS = test-fake test-bsd
dist_check_SCRIPTS = test-echo.sh
test_fake_LDADD = $(COMMON_LDADD) test_fake_LDADD = $(COMMON_LDADD)
...@@ -40,9 +41,7 @@ test_bsd_LDADD = $(COMMON_LDADD) ...@@ -40,9 +41,7 @@ test_bsd_LDADD = $(COMMON_LDADD)
test-echo.sh:: test-echo.sh::
chmod +x $(srcdir)/$@ chmod +x $(srcdir)/$@
EXTRA_DIST = test-echo.sh TESTS = $(dist_check_SCRIPTS) $(check_PROGRAMS)
TESTS = test-echo.sh $(check_PROGRAMS)
pkginclude_HEADERS = udp.h udp-fake.h udp-bsd.h pkginclude_HEADERS = udp.h udp-fake.h udp-bsd.h
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h> #include <string.h>
...@@ -53,13 +56,13 @@ main (void) ...@@ -53,13 +56,13 @@ main (void)
g_assert (nice_udp_socket_factory_make (&factory, &server, NULL)); g_assert (nice_udp_socket_factory_make (&factory, &server, NULL));
// not bound to a particular interface // not bound to a particular interface
g_assert (server.addr.addr_ipv4 == 0); g_assert (server.addr.addr.addr_ipv4 == 0);
// is bound to a particular port // is bound to a particular port
g_assert (server.addr.port != 0); g_assert (server.addr.port != 0);
g_assert (nice_udp_socket_factory_make (&factory, &client, NULL)); g_assert (nice_udp_socket_factory_make (&factory, &client, NULL));
// not bound to a particular interface // not bound to a particular interface
g_assert (client.addr.addr_ipv4 == 0); g_assert (client.addr.addr.addr_ipv4 == 0);
// is bound to a particular port // is bound to a particular port
g_assert (client.addr.port != 0); g_assert (client.addr.port != 0);
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h> #include <string.h>
...@@ -63,7 +66,7 @@ main (void) ...@@ -63,7 +66,7 @@ main (void)
memcpy (buf, "he\0lo", 5); memcpy (buf, "he\0lo", 5);
len = 5; len = 5;
addr.addr_ipv4 = 0x01020304; addr.addr.addr_ipv4 = 0x01020304;
addr.port = 2345; addr.port = 2345;
nice_udp_fake_socket_push_recv (&sock, &addr, len, buf); nice_udp_fake_socket_push_recv (&sock, &addr, len, buf);
...@@ -73,7 +76,7 @@ main (void) ...@@ -73,7 +76,7 @@ main (void)
len = nice_udp_socket_recv (&sock, &addr, sizeof (buf), buf); len = nice_udp_socket_recv (&sock, &addr, sizeof (buf), buf);
g_assert (len == 5); g_assert (len == 5);
g_assert (memcmp (buf, "he\0lo", 5) == 0); g_assert (memcmp (buf, "he\0lo", 5) == 0);
g_assert (addr.addr_ipv4 == 0x01020304); g_assert (addr.addr.addr_ipv4 == 0x01020304);
g_assert (addr.port == 2345); g_assert (addr.port == 2345);
/* test send */ /* test send */
...@@ -88,7 +91,7 @@ main (void) ...@@ -88,7 +91,7 @@ main (void)
len = nice_udp_fake_socket_pop_send (&sock, &addr, sizeof (buf), buf); len = nice_udp_fake_socket_pop_send (&sock, &addr, sizeof (buf), buf);
g_assert (len == 5); g_assert (len == 5);
g_assert (0 == memcmp (buf, "la\0la", 5)); g_assert (0 == memcmp (buf, "la\0la", 5));
g_assert (addr.addr_ipv4 == 0x01020304); g_assert (addr.addr.addr_ipv4 == 0x01020304);
g_assert (addr.port == 2345); g_assert (addr.port == 2345);
nice_udp_socket_close (&sock); nice_udp_socket_close (&sock);
......
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
* Implementation of UDP socket interface using Berkeley sockets. (See * Implementation of UDP socket interface using Berkeley sockets. (See
* http://en.wikipedia.org/wiki/Berkeley_sockets.) * http://en.wikipedia.org/wiki/Berkeley_sockets.)
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -65,7 +68,7 @@ socket_recv ( ...@@ -65,7 +68,7 @@ socket_recv (
&from_len); &from_len);
from->type = NICE_ADDRESS_TYPE_IPV4; from->type = NICE_ADDRESS_TYPE_IPV4;
from->addr_ipv4 = ntohl (sin.sin_addr.s_addr); from->addr.addr_ipv4 = ntohl (sin.sin_addr.s_addr);
from->port = ntohs (sin.sin_port); from->port = ntohs (sin.sin_port);
return recvd; return recvd;
...@@ -81,7 +84,7 @@ socket_send ( ...@@ -81,7 +84,7 @@ socket_send (
struct sockaddr_in sin; struct sockaddr_in sin;
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl (to->addr_ipv4); sin.sin_addr.s_addr = htonl (to->addr.addr_ipv4);
sin.sin_port = htons (to->port); sin.sin_port = htons (to->port);
sendto (sock->fileno, buf, len, 0, (struct sockaddr *) &sin, sizeof (sin)); sendto (sock->fileno, buf, len, 0, (struct sockaddr *) &sin, sizeof (sin));
...@@ -107,6 +110,7 @@ socket_factory_init_socket ( ...@@ -107,6 +110,7 @@ socket_factory_init_socket (
struct sockaddr_in name; struct sockaddr_in name;
guint name_len = sizeof (name); guint name_len = sizeof (name);
(void)man;
memset (&name, 0, sizeof (name)); memset (&name, 0, sizeof (name));
sockfd = socket (PF_INET, SOCK_DGRAM, 0); sockfd = socket (PF_INET, SOCK_DGRAM, 0);
...@@ -117,8 +121,8 @@ socket_factory_init_socket ( ...@@ -117,8 +121,8 @@ socket_factory_init_socket (
if (addr != NULL) if (addr != NULL)
{ {
if (addr->addr_ipv4 != 0) if (addr->addr.addr_ipv4 != 0)
name.sin_addr.s_addr = htonl (addr->addr_ipv4); name.sin_addr.s_addr = htonl (addr->addr.addr_ipv4);
else else
name.sin_addr.s_addr = INADDR_ANY; name.sin_addr.s_addr = INADDR_ANY;
...@@ -139,9 +143,9 @@ socket_factory_init_socket ( ...@@ -139,9 +143,9 @@ socket_factory_init_socket (
} }
if (name.sin_addr.s_addr == INADDR_ANY) if (name.sin_addr.s_addr == INADDR_ANY)
sock->addr.addr_ipv4 = 0; sock->addr.addr.addr_ipv4 = 0;
else else
sock->addr.addr_ipv4 = ntohl (name.sin_addr.s_addr); sock->addr.addr.addr_ipv4 = ntohl (name.sin_addr.s_addr);
sock->addr.port = ntohs (name.sin_port); sock->addr.port = ntohs (name.sin_port);
...@@ -157,9 +161,10 @@ socket_factory_close ( ...@@ -157,9 +161,10 @@ socket_factory_close (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceUDPSocketFactory *man)
{ {
(void)man;
} }
void NICEAPI_EXPORT void
nice_udp_bsd_socket_factory_init ( nice_udp_bsd_socket_factory_init (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceUDPSocketFactory *man)
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "udp-bsd.h" #include "udp-bsd.h"
#include <string.h> #include <string.h>
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h> #include <string.h>
...@@ -112,7 +115,7 @@ fake_socket_init ( ...@@ -112,7 +115,7 @@ fake_socket_init (
sock->fileno = fds[1]; sock->fileno = fds[1];
sock->addr.type = addr->type; sock->addr.type = addr->type;
sock->addr.addr_ipv4 = addr->addr_ipv4; sock->addr.addr.addr_ipv4 = addr->addr.addr_ipv4;
if (addr->port == 0) if (addr->port == 0)
sock->addr.port = port++; sock->addr.port = port++;
...@@ -126,7 +129,7 @@ fake_socket_init ( ...@@ -126,7 +129,7 @@ fake_socket_init (
return TRUE; return TRUE;
} }
void NICEAPI_EXPORT void
nice_udp_fake_socket_push_recv ( nice_udp_fake_socket_push_recv (
NiceUDPSocket *sock, NiceUDPSocket *sock,
NiceAddress *from, NiceAddress *from,
...@@ -142,7 +145,7 @@ nice_udp_fake_socket_push_recv ( ...@@ -142,7 +145,7 @@ nice_udp_fake_socket_push_recv (
write (priv->net_sock, buf, len); write (priv->net_sock, buf, len);
} }
guint NICEAPI_EXPORT guint
nice_udp_fake_socket_pop_send ( nice_udp_fake_socket_pop_send (
NiceUDPSocket *sock, NiceUDPSocket *sock,
NiceAddress *to, NiceAddress *to,
...@@ -160,7 +163,7 @@ nice_udp_fake_socket_pop_send ( ...@@ -160,7 +163,7 @@ nice_udp_fake_socket_pop_send (
return len; return len;
} }
guint NICEAPI_EXPORT guint
nice_udp_fake_socket_get_peer_fd ( nice_udp_fake_socket_get_peer_fd (
NiceUDPSocket *sock) NiceUDPSocket *sock)
{ {
...@@ -177,7 +180,7 @@ fake_socket_factory_close ( ...@@ -177,7 +180,7 @@ fake_socket_factory_close (
{ {
} }
void NICEAPI_EXPORT void
nice_udp_fake_socket_factory_init (NiceUDPSocketFactory *man) nice_udp_fake_socket_factory_init (NiceUDPSocketFactory *man)
{ {
man->init = fake_socket_init; man->init = fake_socket_init;
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
* not delete the provisions above, a recipient may use your version of this * not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -41,7 +44,7 @@ ...@@ -41,7 +44,7 @@
#include <udp.h> #include <udp.h>
gboolean NICEAPI_EXPORT gboolean
nice_udp_socket_factory_make ( nice_udp_socket_factory_make (
NiceUDPSocketFactory *man, NiceUDPSocketFactory *man,
NiceUDPSocket *sock, NiceUDPSocket *sock,
...@@ -50,13 +53,13 @@ nice_udp_socket_factory_make ( ...@@ -50,13 +53,13 @@ nice_udp_socket_factory_make (
return man->init (man, sock, addr); return man->init (man, sock, addr);
} }
void NICEAPI_EXPORT void
nice_udp_socket_factory_close (NiceUDPSocketFactory *man) nice_udp_socket_factory_close (NiceUDPSocketFactory *man)
{ {
man->close (man); man->close (man);
} }
guint NICEAPI_EXPORT guint
nice_udp_socket_recv ( nice_udp_socket_recv (
NiceUDPSocket *sock, NiceUDPSocket *sock,
NiceAddress *from, NiceAddress *from,
...@@ -66,7 +69,7 @@ nice_udp_socket_recv ( ...@@ -66,7 +69,7 @@ nice_udp_socket_recv (
return sock->recv (sock, from, len, buf); return sock->recv (sock, from, len, buf);
} }
void NICEAPI_EXPORT void
nice_udp_socket_send ( nice_udp_socket_send (
NiceUDPSocket *sock, NiceUDPSocket *sock,
NiceAddress *to, NiceAddress *to,
...@@ -76,7 +79,7 @@ nice_udp_socket_send ( ...@@ -76,7 +79,7 @@ nice_udp_socket_send (
sock->send (sock, to, len, buf); sock->send (sock, to, len, buf);
} }
void NICEAPI_EXPORT void
nice_udp_socket_close (NiceUDPSocket *sock) nice_udp_socket_close (NiceUDPSocket *sock)
{ {
sock->close (sock); sock->close (sock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment