Commit 5c235a86 authored by Olivier Crête's avatar Olivier Crête
Browse files

Remove the "to" parameter from NiceOutputMessage

We never send multiple messages to separate targets in practice, so
this will simplify the code
parent a5c8a141
...@@ -1316,10 +1316,9 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *socket, ...@@ -1316,10 +1316,9 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *socket,
local_buf.size = len; local_buf.size = len;
local_message.buffers = &local_buf; local_message.buffers = &local_buf;
local_message.n_buffers = 1; local_message.n_buffers = 1;
local_message.to = addr;
local_message.length = len; local_message.length = len;
if (nice_socket_send_messages (sock, &local_message, 1)) { if (nice_socket_send_messages (sock, addr, &local_message, 1)) {
return WR_SUCCESS; return WR_SUCCESS;
} }
} else { } else {
...@@ -3264,7 +3263,6 @@ nice_agent_send_messages_nonblocking ( ...@@ -3264,7 +3263,6 @@ nice_agent_send_messages_nonblocking (
} else if (component->selected_pair.local != NULL) { } else if (component->selected_pair.local != NULL) {
NiceSocket *sock; NiceSocket *sock;
NiceAddress *addr; NiceAddress *addr;
guint i;
#ifndef NDEBUG #ifndef NDEBUG
gchar tmpbuf[INET6_ADDRSTRLEN]; gchar tmpbuf[INET6_ADDRSTRLEN];
...@@ -3278,13 +3276,8 @@ nice_agent_send_messages_nonblocking ( ...@@ -3278,13 +3276,8 @@ nice_agent_send_messages_nonblocking (
sock = component->selected_pair.local->sockptr; sock = component->selected_pair.local->sockptr;
addr = &component->selected_pair.remote->addr; addr = &component->selected_pair.remote->addr;
/* Set the destination address. FIXME: This is ugly. */ n_sent_messages = nice_socket_send_messages (sock, addr, messages,
for (i = 0; i < n_messages; i++) { n_messages);
NiceOutputMessage *message = (NiceOutputMessage *) &messages[i];
message->to = addr;
}
n_sent_messages = nice_socket_send_messages (sock, messages, n_messages);
if (n_sent_messages < 0) { if (n_sent_messages < 0) {
g_set_error (&child_error, G_IO_ERROR, G_IO_ERROR_FAILED, g_set_error (&child_error, G_IO_ERROR, G_IO_ERROR_FAILED,
...@@ -3327,7 +3320,7 @@ nice_agent_send ( ...@@ -3327,7 +3320,7 @@ nice_agent_send (
const gchar *buf) const gchar *buf)
{ {
GOutputVector local_buf = { buf, len }; GOutputVector local_buf = { buf, len };
NiceOutputMessage local_message = { &local_buf, 1, NULL, len }; NiceOutputMessage local_message = { &local_buf, 1, len };
gint n_sent_messages; gint n_sent_messages;
n_sent_messages = nice_agent_send_messages_nonblocking (agent, stream_id, n_sent_messages = nice_agent_send_messages_nonblocking (agent, stream_id,
......
...@@ -176,14 +176,12 @@ typedef struct { ...@@ -176,14 +176,12 @@ typedef struct {
* which contain data to transmit for this message * which contain data to transmit for this message
* @n_buffers: number of #GOutputVectors in @buffers, or -1 to indicate @buffers * @n_buffers: number of #GOutputVectors in @buffers, or -1 to indicate @buffers
* is %NULL-terminated * is %NULL-terminated
* @to: (allow-none): address of the peer to transmit the message to, or %NULL
* to use the default address for the outbound socket
* @length: total number of valid bytes contiguously stored in @buffers * @length: total number of valid bytes contiguously stored in @buffers
* *
* Represents a single message to transmit on the network. For reliable * Represents a single message to transmit on the network. For
* connections, this is essentially just an array of buffers (specifically, * reliable connections, this is essentially just an array of
* @to can be ignored). for non-reliable connections, it represents a single * buffer. for non-reliable connections, it represents a single packet
* packet to send to the OS. * to send to the OS.
* *
* @n_buffers may be -1 to indicate that @buffers is terminated by a * @n_buffers may be -1 to indicate that @buffers is terminated by a
* #GOutputVector with a %NULL buffer pointer. * #GOutputVector with a %NULL buffer pointer.
...@@ -199,7 +197,6 @@ typedef struct { ...@@ -199,7 +197,6 @@ typedef struct {
typedef struct { typedef struct {
GOutputVector *buffers; GOutputVector *buffers;
gint n_buffers; gint n_buffers;
const NiceAddress *to;
gsize length; gsize length;
} NiceOutputMessage; } NiceOutputMessage;
......
...@@ -403,9 +403,7 @@ nice_output_stream_write (GOutputStream *stream, const void *buffer, gsize count ...@@ -403,9 +403,7 @@ nice_output_stream_write (GOutputStream *stream, const void *buffer, gsize count
do { do {
GOutputVector local_buf = { (const guint8 *) buffer + len, count - len }; GOutputVector local_buf = { (const guint8 *) buffer + len, count - len };
NiceOutputMessage local_message = { NiceOutputMessage local_message = {&local_buf, 1, count - len};
&local_buf, 1, NULL, count - len
};
/* Have to unlock while calling into the agent because /* Have to unlock while calling into the agent because
* it will take the agent lock which will cause a deadlock if one of * it will take the agent lock which will cause a deadlock if one of
...@@ -525,7 +523,7 @@ nice_output_stream_write_nonblocking (GPollableOutputStream *stream, ...@@ -525,7 +523,7 @@ nice_output_stream_write_nonblocking (GPollableOutputStream *stream,
NiceOutputStreamPrivate *priv = NICE_OUTPUT_STREAM (stream)->priv; NiceOutputStreamPrivate *priv = NICE_OUTPUT_STREAM (stream)->priv;
NiceAgent *agent; /* owned */ NiceAgent *agent; /* owned */
GOutputVector local_buf = { buffer, count }; GOutputVector local_buf = { buffer, count };
NiceOutputMessage local_message = { &local_buf, 1, NULL, count }; NiceOutputMessage local_message = { &local_buf, 1, count };
gint n_sent_messages; gint n_sent_messages;
/* Closed streams are not writeable. */ /* Closed streams are not writeable. */
......
...@@ -92,12 +92,12 @@ struct to_be_sent { ...@@ -92,12 +92,12 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock); static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock, static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock, static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock); static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs); static void free_to_be_sent (struct to_be_sent *tbs);
...@@ -165,10 +165,9 @@ nice_http_socket_new (NiceSocket *base_socket, ...@@ -165,10 +165,9 @@ nice_http_socket_new (NiceSocket *base_socket,
local_bufs.size = strlen (msg); local_bufs.size = strlen (msg);
local_messages.buffers = &local_bufs; local_messages.buffers = &local_bufs;
local_messages.n_buffers = 1; local_messages.n_buffers = 1;
local_messages.to = NULL;
local_messages.length = local_bufs.size; local_messages.length = local_bufs.size;
nice_socket_send_messages (priv->base_socket, &local_messages, 1); nice_socket_send_messages (priv->base_socket, NULL, &local_messages, 1);
priv->state = HTTP_STATE_INIT; priv->state = HTTP_STATE_INIT;
g_free (msg); g_free (msg);
} }
...@@ -547,8 +546,7 @@ retry: ...@@ -547,8 +546,7 @@ retry:
/* Send the pending data */ /* Send the pending data */
while ((tbs = g_queue_pop_head (&priv->send_queue))) { while ((tbs = g_queue_pop_head (&priv->send_queue))) {
nice_socket_send (priv->base_socket, &tbs->to, nice_socket_send (priv->base_socket, &tbs->to, tbs->length, tbs->buf);
tbs->length, tbs->buf);
g_free (tbs->buf); g_free (tbs->buf);
g_slice_free (struct to_be_sent, tbs); g_slice_free (struct to_be_sent, tbs);
} }
...@@ -576,8 +574,8 @@ retry: ...@@ -576,8 +574,8 @@ retry:
} }
static gint static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, socket_send_messages (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
HttpPriv *priv = sock->priv; HttpPriv *priv = sock->priv;
...@@ -586,11 +584,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -586,11 +584,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (!priv->base_socket) if (!priv->base_socket)
return -1; return -1;
return nice_socket_send_messages (priv->base_socket, messages, n_messages); return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else if (priv->state == HTTP_STATE_ERROR) { } else if (priv->state == HTTP_STATE_ERROR) {
return -1; return -1;
} else { } else {
add_to_be_sent (sock, messages, n_messages); add_to_be_sent (sock, to, messages, n_messages);
} }
return n_messages; return n_messages;
...@@ -605,8 +604,8 @@ socket_is_reliable (NiceSocket *sock) ...@@ -605,8 +604,8 @@ socket_is_reliable (NiceSocket *sock)
static void static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
HttpPriv *priv = sock->priv; HttpPriv *priv = sock->priv;
guint i; guint i;
...@@ -628,8 +627,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -628,8 +627,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
tbs = g_slice_new0 (struct to_be_sent); tbs = g_slice_new0 (struct to_be_sent);
tbs->buf = g_malloc (message->length); tbs->buf = g_malloc (message->length);
tbs->length = message->length; tbs->length = message->length;
if (message->to) if (to)
tbs->to = *message->to; tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs); g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0; for (j = 0;
......
...@@ -91,12 +91,12 @@ static const gchar SSL_CLIENT_HANDSHAKE[] = { ...@@ -91,12 +91,12 @@ static const gchar SSL_CLIENT_HANDSHAKE[] = {
static void socket_close (NiceSocket *sock); static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock, static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock, static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock); static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs); static void free_to_be_sent (struct to_be_sent *tbs);
...@@ -190,8 +190,8 @@ socket_recv_messages (NiceSocket *sock, ...@@ -190,8 +190,8 @@ socket_recv_messages (NiceSocket *sock,
} }
static gint static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, socket_send_messages (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
PseudoSSLPriv *priv = sock->priv; PseudoSSLPriv *priv = sock->priv;
...@@ -201,9 +201,10 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -201,9 +201,10 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (priv->base_socket == NULL) if (priv->base_socket == NULL)
return FALSE; return FALSE;
return nice_socket_send_messages (priv->base_socket, messages, n_messages); return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else { } else {
add_to_be_sent (sock, messages, n_messages); add_to_be_sent (sock, to, messages, n_messages);
} }
return TRUE; return TRUE;
} }
...@@ -217,8 +218,8 @@ socket_is_reliable (NiceSocket *sock) ...@@ -217,8 +218,8 @@ socket_is_reliable (NiceSocket *sock)
static void static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
PseudoSSLPriv *priv = sock->priv; PseudoSSLPriv *priv = sock->priv;
guint i; guint i;
...@@ -234,8 +235,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -234,8 +235,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
/* Compact the buffer. */ /* Compact the buffer. */
tbs->buf = g_malloc (message->length); tbs->buf = g_malloc (message->length);
tbs->length = message->length; tbs->length = message->length;
if (message->to != NULL) if (to != NULL)
tbs->to = *message->to; tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs); g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0; for (j = 0;
......
...@@ -129,13 +129,13 @@ nice_socket_recv_messages (NiceSocket *sock, ...@@ -129,13 +129,13 @@ nice_socket_recv_messages (NiceSocket *sock,
* Since: 0.1.5 * Since: 0.1.5
*/ */
gint gint
nice_socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, nice_socket_send_messages (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
g_return_val_if_fail (sock != NULL, -1); g_return_val_if_fail (sock != NULL, -1);
g_return_val_if_fail (n_messages == 0 || messages != NULL, -1); g_return_val_if_fail (n_messages == 0 || messages != NULL, -1);
return sock->send_messages (sock, messages, n_messages); return sock->send_messages (sock, to, messages, n_messages);
} }
/* Convenience wrapper around nice_socket_send_messages(). Returns the number of /* Convenience wrapper around nice_socket_send_messages(). Returns the number of
...@@ -146,10 +146,10 @@ nice_socket_send (NiceSocket *sock, const NiceAddress *to, gsize len, ...@@ -146,10 +146,10 @@ nice_socket_send (NiceSocket *sock, const NiceAddress *to, gsize len,
const gchar *buf) const gchar *buf)
{ {
GOutputVector local_buf = { buf, len }; GOutputVector local_buf = { buf, len };
NiceOutputMessage local_message = { &local_buf, 1, to, len }; NiceOutputMessage local_message = { &local_buf, 1, len };
gint ret; gint ret;
ret = nice_socket_send_messages (sock, &local_message, 1); ret = sock->send_messages (sock, to, &local_message, 1);
if (ret == 1) if (ret == 1)
return len; return len;
return ret; return ret;
......
...@@ -64,8 +64,8 @@ struct _NiceSocket ...@@ -64,8 +64,8 @@ struct _NiceSocket
gint (*recv_messages) (NiceSocket *sock, gint (*recv_messages) (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
/* As above, @n_messages may be zero. Iff so, @messages may be %NULL. */ /* As above, @n_messages may be zero. Iff so, @messages may be %NULL. */
gint (*send_messages) (NiceSocket *sock, const NiceOutputMessage *messages, gint (*send_messages) (NiceSocket *sock, const NiceAddress *to,
guint n_messages); const NiceOutputMessage *messages, guint n_messages);
gboolean (*is_reliable) (NiceSocket *sock); gboolean (*is_reliable) (NiceSocket *sock);
void (*close) (NiceSocket *sock); void (*close) (NiceSocket *sock);
void *priv; void *priv;
...@@ -77,8 +77,8 @@ nice_socket_recv_messages (NiceSocket *sock, ...@@ -77,8 +77,8 @@ nice_socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
gint gint
nice_socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, nice_socket_send_messages (NiceSocket *sock, const NiceAddress *addr,
guint n_messages); const NiceOutputMessage *messages, guint n_messages);
gssize gssize
nice_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len, nice_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len,
const gchar *buf); const gchar *buf);
......
...@@ -78,12 +78,12 @@ struct to_be_sent { ...@@ -78,12 +78,12 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock); static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock, static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock, static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock); static gboolean socket_is_reliable (NiceSocket *sock);
static void add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, static void add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static void free_to_be_sent (struct to_be_sent *tbs); static void free_to_be_sent (struct to_be_sent *tbs);
...@@ -419,8 +419,8 @@ socket_recv_messages (NiceSocket *sock, ...@@ -419,8 +419,8 @@ socket_recv_messages (NiceSocket *sock,
} }
static gint static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, socket_send_messages (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
Socks5Priv *priv = sock->priv; Socks5Priv *priv = sock->priv;
...@@ -429,11 +429,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -429,11 +429,12 @@ socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages,
if (priv->base_socket == NULL) if (priv->base_socket == NULL)
return FALSE; return FALSE;
return nice_socket_send_messages (priv->base_socket, messages, n_messages); return nice_socket_send_messages (priv->base_socket, to, messages,
n_messages);
} else if (priv->state == SOCKS_STATE_ERROR) { } else if (priv->state == SOCKS_STATE_ERROR) {
return FALSE; return FALSE;
} else { } else {
add_to_be_sent (sock, messages, n_messages); add_to_be_sent (sock, to, messages, n_messages);
} }
return TRUE; return TRUE;
} }
...@@ -447,8 +448,8 @@ socket_is_reliable (NiceSocket *sock) ...@@ -447,8 +448,8 @@ socket_is_reliable (NiceSocket *sock)
static void static void
add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, add_to_be_sent (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
Socks5Priv *priv = sock->priv; Socks5Priv *priv = sock->priv;
guint i; guint i;
...@@ -464,8 +465,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages, ...@@ -464,8 +465,8 @@ add_to_be_sent (NiceSocket *sock, const NiceOutputMessage *messages,
/* Compact the buffer. */ /* Compact the buffer. */
tbs->buf = g_malloc (message->length); tbs->buf = g_malloc (message->length);
tbs->length = message->length; tbs->length = message->length;
if (message->to != NULL) if (to != NULL)
tbs->to = *message->to; tbs->to = *to;
g_queue_push_tail (&priv->send_queue, tbs); g_queue_push_tail (&priv->send_queue, tbs);
for (j = 0; for (j = 0;
......
...@@ -72,7 +72,7 @@ struct to_be_sent { ...@@ -72,7 +72,7 @@ struct to_be_sent {
static void socket_close (NiceSocket *sock); static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock, static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock, static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock); static gboolean socket_is_reliable (NiceSocket *sock);
...@@ -316,8 +316,8 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message) ...@@ -316,8 +316,8 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
* dropped if the bandwidth isn't fast enough. So do not send a message in * dropped if the bandwidth isn't fast enough. So do not send a message in
* multiple chunks. */ * multiple chunks. */
static gint static gint
socket_send_messages (NiceSocket *sock, const NiceOutputMessage *messages, socket_send_messages (NiceSocket *sock, const NiceAddress *to,
guint n_messages) const NiceOutputMessage *messages, guint n_messages)
{ {
guint i; guint i;
...@@ -389,9 +389,7 @@ socket_send_more ( ...@@ -389,9 +389,7 @@ socket_send_more (
if (gerr != NULL && if (gerr != NULL &&
g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) { g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
GOutputVector local_buf = { tbs->buf, tbs->length }; GOutputVector local_buf = { tbs->buf, tbs->length };
NiceOutputMessage local_message = { NiceOutputMessage local_message = {&local_buf, 1, local_buf.size};
&local_buf, 1, NULL, local_buf.size
};
add_to_be_sent (sock, &local_message, 0, TRUE); add_to_be_sent (sock, &local_message, 0, TRUE);
free_to_be_sent (tbs); free_to_be_sent (tbs);
...@@ -401,9 +399,7 @@ socket_send_more ( ...@@ -401,9 +399,7 @@ socket_send_more (
g_error_free (gerr); g_error_free (gerr);
} else if (ret < (int) tbs->length) { } else if (ret < (int) tbs->length) {
GOutputVector local_buf = { tbs->buf + ret, tbs->length - ret }; GOutputVector local_buf = { tbs->buf + ret, tbs->length - ret };
NiceOutputMessage local_message = { NiceOutputMessage local_message = {&local_buf, 1, local_buf.size};
&local_buf, 1, NULL, local_buf.size
};
add_to_be_sent (sock, &local_message, 0, TRUE); add_to_be_sent (sock, &local_message, 0, TRUE);
free_to_be_sent (tbs); free_to_be_sent (tbs);
......
...@@ -69,7 +69,7 @@ typedef struct { ...@@ -69,7 +69,7 @@ typedef struct {
static void socket_close (NiceSocket *sock); static void socket_close (NiceSocket *sock);
static gint socket_recv_messages (NiceSocket *sock, static gint socket_recv_messages (NiceSocket *sock,
NiceInputMessage *recv_messages, guint n_recv_messages); NiceInputMessage *recv_messages, guint n_recv_messages);
static gint socket_send_messages (NiceSocket *sock, static gint socket_send_messages (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *messages, guint n_messages); const NiceOutputMessage *messages, guint n_messages);
static gboolean socket_is_reliable (NiceSocket *sock); static gboolean socket_is_reliable (NiceSocket *sock);
...@@ -223,7 +223,8 @@ socket_recv_messages (NiceSocket *socket, ...@@ -223,7 +223,8 @@ socket_recv_messages (NiceSocket *socket,
} }
static gssize static gssize
socket_send_message (NiceSocket *sock, const NiceOutputMessage *message) socket_send_message (NiceSocket *sock, const NiceAddress *to,
const NiceOutputMessage *message)
{ {
TurnTcpPriv *priv = sock->priv; TurnTcpPriv *priv = sock->priv;
guint8 padbuf[3] = {0, 0, 0}; guint8 padbuf[3] = {0, 0, 0};
...@@ -249,7 +250,6 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message) ...@@ -249,7 +250,6 @@ socket_send_message (NiceSocket *sock, const NiceOutputMessage *message)
local_bufs = g_malloc_n (n_bufs + 2, sizeof (GOutputVector)); local_bufs = g_malloc_n (n_bufs + 2, sizeof (GOutputVector));
local_message.buffers = local_bufs; local_message.buffers = local_bufs;
local_message.n_buffers = n_bufs + 2; local_message.n_buffers = n_bufs + 2;
local_message.to = message->to;
local_message.length = message->length; local_message.length = message->length;
/* Copy the existing buffers across. */