Commit e048732f authored by Youness Alaoui's avatar Youness Alaoui

Update udp socket layers to new NiceSocket API

parent a972e826
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#include "udp-bsd.h" #include "udp-bsd.h"
/*** NiceUDPSocket ***/ /*** NiceSocket ***/
static int sock_recv_err (int fd) static int sock_recv_err (int fd)
{ {
#ifdef MSG_ERRQUEUE #ifdef MSG_ERRQUEUE
...@@ -74,7 +74,7 @@ static int sock_recv_err (int fd) ...@@ -74,7 +74,7 @@ static int sock_recv_err (int fd)
static gint static gint
socket_recv ( socket_recv (
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *from, NiceAddress *from,
guint len, guint len,
gchar *buf) gchar *buf)
...@@ -97,7 +97,7 @@ socket_recv ( ...@@ -97,7 +97,7 @@ socket_recv (
static gboolean static gboolean
socket_send ( socket_send (
NiceUDPSocket *sock, NiceSocket *sock,
const NiceAddress *to, const NiceAddress *to,
guint len, guint len,
const gchar *buf) const gchar *buf)
...@@ -116,18 +116,18 @@ socket_send ( ...@@ -116,18 +116,18 @@ socket_send (
} }
static void static void
socket_close (NiceUDPSocket *sock) socket_close (NiceSocket *sock)
{ {
close (sock->fileno); close (sock->fileno);
} }
/*** NiceUDPSocketFactory ***/ /*** NiceSocketFactory ***/
static gboolean static gboolean
socket_factory_init_socket ( socket_factory_init_socket (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man, NiceSocketFactory *man,
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *addr) NiceAddress *addr)
{ {
int sockfd = -1; int sockfd = -1;
...@@ -228,7 +228,7 @@ socket_factory_init_socket ( ...@@ -228,7 +228,7 @@ socket_factory_init_socket (
static void static void
socket_factory_close ( socket_factory_close (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceSocketFactory *man)
{ {
(void)man; (void)man;
} }
...@@ -236,7 +236,7 @@ socket_factory_close ( ...@@ -236,7 +236,7 @@ socket_factory_close (
NICEAPI_EXPORT void NICEAPI_EXPORT void
nice_udp_bsd_socket_factory_init ( nice_udp_bsd_socket_factory_init (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceSocketFactory *man)
{ {
man->init = socket_factory_init_socket; man->init = socket_factory_init_socket;
man->close = socket_factory_close; man->close = socket_factory_close;
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#ifndef _UDP_BSD_H #ifndef _UDP_BSD_H
#define _UDP_BSD_H #define _UDP_BSD_H
#include "udp.h" #include "socket.h"
G_BEGIN_DECLS G_BEGIN_DECLS
void void
nice_udp_bsd_socket_factory_init (NiceUDPSocketFactory *man); nice_udp_bsd_socket_factory_init (NiceSocketFactory *man);
G_END_DECLS G_END_DECLS
......
...@@ -75,7 +75,7 @@ typedef struct { ...@@ -75,7 +75,7 @@ typedef struct {
GList *channels; GList *channels;
GList *retransmissions; GList *retransmissions;
ChannelBinding *current_binding; ChannelBinding *current_binding;
NiceUDPSocket *udp_socket; NiceSocket *base_socket;
NiceAddress server_addr; NiceAddress server_addr;
uint8_t *username; uint8_t *username;
size_t username_len; size_t username_len;
...@@ -148,7 +148,7 @@ priv_send_channel_bind (turn_priv *priv, StunMessage *resp, ...@@ -148,7 +148,7 @@ priv_send_channel_bind (turn_priv *priv, StunMessage *resp,
priv->password, priv->password_len); priv->password, priv->password_len);
if (stun_len > 0) { if (stun_len > 0) {
nice_udp_socket_send (priv->udp_socket, &priv->server_addr, nice_socket_send (priv->base_socket, &priv->server_addr,
stun_len, (gchar *)buffer); stun_len, (gchar *)buffer);
return TRUE; return TRUE;
} }
...@@ -156,7 +156,7 @@ priv_send_channel_bind (turn_priv *priv, StunMessage *resp, ...@@ -156,7 +156,7 @@ priv_send_channel_bind (turn_priv *priv, StunMessage *resp,
return FALSE; return FALSE;
} }
NICEAPI_EXPORT gboolean NICEAPI_EXPORT gboolean
nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer) nice_udp_turn_socket_set_peer (NiceSocket *sock, NiceAddress *peer)
{ {
turn_priv *priv = (turn_priv *) sock->priv; turn_priv *priv = (turn_priv *) sock->priv;
StunMessage msg; StunMessage msg;
...@@ -217,7 +217,7 @@ nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer) ...@@ -217,7 +217,7 @@ nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer)
priv->current_binding = g_new0 (ChannelBinding, 1); priv->current_binding = g_new0 (ChannelBinding, 1);
priv->current_binding->channel = 0; priv->current_binding->channel = 0;
priv->current_binding->peer = *peer; priv->current_binding->peer = *peer;
nice_udp_socket_send (priv->udp_socket, &priv->server_addr, nice_socket_send (priv->base_socket, &priv->server_addr,
stun_len, (gchar *)buffer); stun_len, (gchar *)buffer);
} }
return TRUE; return TRUE;
...@@ -236,7 +236,7 @@ nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer) ...@@ -236,7 +236,7 @@ nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer)
gint gint
nice_udp_turn_socket_parse_recv ( nice_udp_turn_socket_parse_recv (
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *from, NiceAddress *from,
guint len, guint len,
gchar *buf, gchar *buf,
...@@ -366,7 +366,7 @@ nice_udp_turn_socket_parse_recv ( ...@@ -366,7 +366,7 @@ nice_udp_turn_socket_parse_recv (
static gint static gint
socket_recv ( socket_recv (
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *from, NiceAddress *from,
guint len, guint len,
gchar *buf) gchar *buf)
...@@ -376,7 +376,7 @@ socket_recv ( ...@@ -376,7 +376,7 @@ socket_recv (
gint recv_len; gint recv_len;
NiceAddress recv_from; NiceAddress recv_from;
recv_len = nice_udp_socket_recv (priv->udp_socket, &recv_from, recv_len = nice_socket_recv (priv->base_socket, &recv_from,
sizeof(recv_buf), (gchar *) recv_buf); sizeof(recv_buf), (gchar *) recv_buf);
return nice_udp_turn_socket_parse_recv (sock, from, len, buf, &recv_from, return nice_udp_turn_socket_parse_recv (sock, from, len, buf, &recv_from,
...@@ -385,7 +385,7 @@ socket_recv ( ...@@ -385,7 +385,7 @@ socket_recv (
static gboolean static gboolean
socket_send ( socket_send (
NiceUDPSocket *sock, NiceSocket *sock,
const NiceAddress *to, const NiceAddress *to,
guint len, guint len,
const gchar *buf) const gchar *buf)
...@@ -460,18 +460,18 @@ socket_send ( ...@@ -460,18 +460,18 @@ socket_send (
} }
if (msg_len > 0) { if (msg_len > 0) {
nice_udp_socket_send (priv->udp_socket, &priv->server_addr, nice_socket_send (priv->base_socket, &priv->server_addr,
msg_len, (gchar *)buffer); msg_len, (gchar *)buffer);
return TRUE; return TRUE;
} }
send: send:
nice_udp_socket_send (priv->udp_socket, to, len, buf); nice_socket_send (priv->base_socket, to, len, buf);
return TRUE; return TRUE;
} }
static void static void
socket_close (NiceUDPSocket *sock) socket_close (NiceSocket *sock)
{ {
turn_priv *priv = (turn_priv *) sock->priv; turn_priv *priv = (turn_priv *) sock->priv;
GList *i = priv->channels; GList *i = priv->channels;
...@@ -485,12 +485,12 @@ socket_close (NiceUDPSocket *sock) ...@@ -485,12 +485,12 @@ socket_close (NiceUDPSocket *sock)
g_free (priv); g_free (priv);
} }
/*** NiceUDPSocketFactory ***/ /*** NiceSocketFactory ***/
static gboolean static gboolean
socket_factory_init_socket ( socket_factory_init_socket (
NiceUDPSocketFactory *man, NiceSocketFactory *man,
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *addr) NiceAddress *addr)
{ {
return FALSE; return FALSE;
...@@ -498,10 +498,10 @@ socket_factory_init_socket ( ...@@ -498,10 +498,10 @@ socket_factory_init_socket (
NICEAPI_EXPORT gboolean NICEAPI_EXPORT gboolean
nice_udp_turn_create_socket_full ( nice_udp_turn_create_socket_full (
NiceUDPSocketFactory *man, NiceSocketFactory *man,
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *addr, NiceAddress *addr,
NiceUDPSocket *udp_socket, NiceSocket *base_socket,
NiceAddress *server_addr, NiceAddress *server_addr,
gchar *username, gchar *username,
gchar *password, gchar *password,
...@@ -527,7 +527,7 @@ nice_udp_turn_create_socket_full ( ...@@ -527,7 +527,7 @@ nice_udp_turn_create_socket_full (
priv->channels = NULL; priv->channels = NULL;
priv->current_binding = NULL; priv->current_binding = NULL;
priv->udp_socket = udp_socket; priv->base_socket = base_socket;
if (compatibility == NICE_UDP_TURN_SOCKET_COMPATIBILITY_MSN) { if (compatibility == NICE_UDP_TURN_SOCKET_COMPATIBILITY_MSN) {
priv->username = g_base64_decode (username, &priv->username_len); priv->username = g_base64_decode (username, &priv->username_len);
...@@ -546,7 +546,7 @@ nice_udp_turn_create_socket_full ( ...@@ -546,7 +546,7 @@ nice_udp_turn_create_socket_full (
priv->server_addr = *server_addr; priv->server_addr = *server_addr;
priv->compatibility = compatibility; priv->compatibility = compatibility;
sock->addr = *addr; sock->addr = *addr;
sock->fileno = udp_socket->fileno; sock->fileno = base_socket->fileno;
sock->send = socket_send; sock->send = socket_send;
sock->recv = socket_recv; sock->recv = socket_recv;
sock->close = socket_close; sock->close = socket_close;
...@@ -557,14 +557,14 @@ nice_udp_turn_create_socket_full ( ...@@ -557,14 +557,14 @@ nice_udp_turn_create_socket_full (
static void static void
socket_factory_close ( socket_factory_close (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceSocketFactory *man)
{ {
} }
NICEAPI_EXPORT void NICEAPI_EXPORT void
nice_udp_turn_socket_factory_init ( nice_udp_turn_socket_factory_init (
G_GNUC_UNUSED G_GNUC_UNUSED
NiceUDPSocketFactory *man) NiceSocketFactory *man)
{ {
man->init = socket_factory_init_socket; man->init = socket_factory_init_socket;
......
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
* file under either the MPL or the LGPL. * file under either the MPL or the LGPL.
*/ */
#ifndef _GOOGLE_RELAY_H #ifndef _UDP_TURN_H
#define _GOOGLE_RELAY_H #define _UDP_TURN_H
#include "udp.h" #include "socket.h"
G_BEGIN_DECLS G_BEGIN_DECLS
...@@ -50,7 +50,7 @@ typedef enum { ...@@ -50,7 +50,7 @@ typedef enum {
gint gint
nice_udp_turn_socket_parse_recv ( nice_udp_turn_socket_parse_recv (
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *from, NiceAddress *from,
guint len, guint len,
gchar *buf, gchar *buf,
...@@ -59,14 +59,14 @@ nice_udp_turn_socket_parse_recv ( ...@@ -59,14 +59,14 @@ nice_udp_turn_socket_parse_recv (
guint recv_len); guint recv_len);
gboolean gboolean
nice_udp_turn_socket_set_peer (NiceUDPSocket *sock, NiceAddress *peer); nice_udp_turn_socket_set_peer (NiceSocket *sock, NiceAddress *peer);
gboolean gboolean
nice_udp_turn_create_socket_full ( nice_udp_turn_create_socket_full (
NiceUDPSocketFactory *man, NiceSocketFactory *man,
NiceUDPSocket *sock, NiceSocket *sock,
NiceAddress *addr, NiceAddress *addr,
NiceUDPSocket *udp_socket, NiceSocket *udp_socket,
NiceAddress *server_addr, NiceAddress *server_addr,
gchar *username, gchar *username,
gchar *password, gchar *password,
...@@ -74,9 +74,9 @@ nice_udp_turn_create_socket_full ( ...@@ -74,9 +74,9 @@ nice_udp_turn_create_socket_full (
void void
nice_udp_turn_socket_factory_init (NiceUDPSocketFactory *man); nice_udp_turn_socket_factory_init (NiceSocketFactory *man);
G_END_DECLS G_END_DECLS
#endif /* _UDP_BSD_H */ #endif /* _UDP_TURN_H */
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