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