Commit 5bc8e4bc authored by Youness Alaoui's avatar Youness Alaoui Committed by Olivier Crête

Fix RFC4571 n_buffers when reading and frame outgoing STUN messages

parent 58943610
...@@ -2545,8 +2545,9 @@ static gboolean priv_add_remote_candidate ( ...@@ -2545,8 +2545,9 @@ static gboolean priv_add_remote_candidate (
gchar tmpbuf[INET6_ADDRSTRLEN] = {0}; gchar tmpbuf[INET6_ADDRSTRLEN] = {0};
if (addr) if (addr)
nice_address_to_string (addr, tmpbuf); nice_address_to_string (addr, tmpbuf);
nice_debug ("Agent %p : Adding remote candidate with addr [%s]:%u" nice_debug ("Agent %p : Adding %s remote candidate with addr [%s]:%u"
" for s%d/c%d. U/P '%s'/'%s' prio: %u", agent, tmpbuf, " for s%d/c%d. U/P '%s'/'%s' prio: %u", agent,
_transport_to_string (transport), tmpbuf,
addr? nice_address_get_port (addr) : 0, stream_id, component_id, addr? nice_address_get_port (addr) : 0, stream_id, component_id,
username, password, priority); username, password, priority);
} }
...@@ -3750,7 +3751,7 @@ nice_agent_send_messages_nonblocking_internal ( ...@@ -3750,7 +3751,7 @@ nice_agent_send_messages_nonblocking_internal (
((guint8 *) message->buffers[j].buffer) + offset_in_buffer; ((guint8 *) message->buffers[j].buffer) + offset_in_buffer;
local_bufs[local_message.n_buffers].size = local_bufs[local_message.n_buffers].size =
MIN (message->buffers[j].size, packet_len); MIN (message->buffers[j].size, packet_len);
packet_len -= local_bufs[local_message.n_buffers++].size; packet_len -= local_bufs[local_message.n_buffers].size;
offset += local_bufs[local_message.n_buffers++].size; offset += local_bufs[local_message.n_buffers++].size;
offset_in_buffer = 0; offset_in_buffer = 0;
} }
...@@ -5176,7 +5177,12 @@ agent_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len, ...@@ -5176,7 +5177,12 @@ agent_socket_send (NiceSocket *sock, const NiceAddress *addr, gsize len,
const gchar *buf) const gchar *buf)
{ {
if (nice_socket_is_reliable (sock)) { if (nice_socket_is_reliable (sock)) {
return nice_socket_send_reliable (sock, addr, len, buf); guint16 rfc4571_frame = htons (len);
GOutputVector local_buf[2] = {{&rfc4571_frame, 2}, { buf, len }};
NiceOutputMessage local_message = { local_buf, 2};
/* ICE-TCP requires that all packets be framed with RFC4571 */
return nice_socket_send_messages_reliable (sock, addr, &local_message, 1);
} else { } else {
gssize ret = nice_socket_send_reliable (sock, addr, len, buf); gssize ret = nice_socket_send_reliable (sock, addr, len, buf);
if (ret < 0) if (ret < 0)
......
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