Commit 48428cda authored by Youness Alaoui's avatar Youness Alaoui Committed by Olivier Crête

Add a socket type for socket layer

parent 57393333
......@@ -123,7 +123,7 @@ nice_http_socket_new (NiceSocket *base_socket,
priv->recv_buf_fill = 0;
priv->content_length = 0;
sock->type = NICE_SOCKET_TYPE_HTTP;
sock->fileno = priv->base_socket->fileno;
sock->addr = priv->base_socket->addr;
sock->send_messages = socket_send_messages;
......
......@@ -111,6 +111,7 @@ nice_pseudossl_socket_new (NiceSocket *base_socket)
priv->handshaken = FALSE;
priv->base_socket = base_socket;
sock->type = NICE_SOCKET_TYPE_PSEUDOSSL;
sock->fileno = priv->base_socket->fileno;
sock->addr = priv->base_socket->addr;
sock->send_messages = socket_send_messages;
......
......@@ -55,9 +55,23 @@ G_BEGIN_DECLS
typedef struct _NiceSocket NiceSocket;
typedef enum {
NICE_SOCKET_TYPE_UDP_BSD,
NICE_SOCKET_TYPE_TCP_BSD,
NICE_SOCKET_TYPE_PSEUDOSSL,
NICE_SOCKET_TYPE_HTTP,
NICE_SOCKET_TYPE_SOCKS5,
NICE_SOCKET_TYPE_TURN,
NICE_SOCKET_TYPE_TCP_TURN,
NICE_SOCKET_TYPE_TCP_ACTIVE,
NICE_SOCKET_TYPE_TCP_PASSIVE,
NICE_SOCKET_TYPE_TCP_SO
} NiceSocketType;
struct _NiceSocket
{
NiceAddress addr;
NiceSocketType type;
GSocket *fileno;
/* Implementations must handle any value of n_recv_messages, including 0. Iff
* n_recv_messages is 0, recv_messages may be NULL. */
......
......@@ -104,6 +104,7 @@ nice_socks5_socket_new (NiceSocket *base_socket,
priv->username = g_strdup (username);
priv->password = g_strdup (password);
sock->type = NICE_SOCKET_TYPE_SOCKS5;
sock->fileno = priv->base_socket->fileno;
sock->addr = priv->base_socket->addr;
sock->send_messages = socket_send_messages;
......
......@@ -172,6 +172,7 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
priv->server_addr = *addr;
priv->error = FALSE;
sock->type = NICE_SOCKET_TYPE_TCP_BSD;
sock->fileno = gsock;
sock->send_messages = socket_send_messages;
sock->recv_messages = socket_recv_messages;
......
......@@ -84,6 +84,7 @@ nice_tcp_turn_socket_new (NiceSocket *base_socket,
priv->compatibility = compatibility;
priv->base_socket = base_socket;
sock->type = NICE_SOCKET_TYPE_TCP_TURN;
sock->fileno = priv->base_socket->fileno;
sock->addr = priv->base_socket->addr;
sock->send_messages = socket_send_messages;
......
......@@ -227,13 +227,16 @@ nice_turn_socket_new (GMainContext *ctx, NiceAddress *addr,
(GEqualFunc) nice_address_equal,
(GDestroyNotify) nice_address_free,
priv_send_data_queue_destroy);
sock->addr = *addr;
sock->type = NICE_SOCKET_TYPE_TURN;
sock->fileno = base_socket->fileno;
sock->addr = *addr;
sock->send_messages = socket_send_messages;
sock->recv_messages = socket_recv_messages;
sock->is_reliable = socket_is_reliable;
sock->close = socket_close;
sock->priv = (void *) priv;
return sock;
}
......
......@@ -141,6 +141,7 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
priv = sock->priv = g_slice_new0 (struct UdpBsdSocketPrivate);
nice_address_init (&priv->niceaddr);
sock->type = NICE_SOCKET_TYPE_UDP_BSD;
sock->fileno = gsock;
sock->send_messages = socket_send_messages;
sock->recv_messages = socket_recv_messages;
......
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