diff options
-rw-r--r-- | agent/agent-priv.h | 2 | ||||
-rw-r--r-- | agent/agent.c | 41 | ||||
-rw-r--r-- | agent/agent.h | 11 | ||||
-rw-r--r-- | agent/discovery.c | 1 | ||||
-rw-r--r-- | agent/stream.h | 1 | ||||
-rw-r--r-- | nice/libnice.sym | 1 |
6 files changed, 43 insertions, 14 deletions
diff --git a/agent/agent-priv.h b/agent/agent-priv.h index 2f89730..eef0115 100644 --- a/agent/agent-priv.h +++ b/agent/agent-priv.h @@ -172,4 +172,6 @@ StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent); StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent); NiceTurnSocketCompatibility agent_to_turn_socket_compatibility (NiceAgent *agent); +void _priv_set_socket_tos (NiceAgent *agent, NiceSocket *sock, gint tos); + #endif /*_NICE_AGENT_PRIV_H */ diff --git a/agent/agent.c b/agent/agent.c index 2bfaccd..17087ad 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -968,6 +968,7 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, new_socket = nice_udp_bsd_socket_new (&addr); if (new_socket) { + _priv_set_socket_tos (agent, new_socket, stream->tos); agent_attach_stream_component_socket (agent, stream, component, new_socket); socket_modified_list = g_slist_append (component->sockets, new_socket); @@ -992,6 +993,7 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, socket = nice_tcp_bsd_socket_new (agent, component->ctx, &proxy_server); if (socket) { + _priv_set_socket_tos (agent, socket, stream->tos); if (agent->proxy_type == NICE_PROXY_TYPE_SOCKS5) { socket = nice_socks5_socket_new (socket, &turn->server, agent->proxy_username, agent->proxy_password); @@ -1007,6 +1009,7 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent, } if (socket == NULL) { socket = nice_tcp_bsd_socket_new (agent, component->ctx, &turn->server); + _priv_set_socket_tos (agent, socket, stream->tos); } if (turn->type == NICE_RELAY_TYPE_TURN_TLS && agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { @@ -2316,34 +2319,46 @@ nice_agent_set_selected_remote_candidate ( return ret; } -void nice_agent_set_stream_type_of_service (NiceAgent *agent, +void +_priv_set_socket_tos (NiceAgent *agent, NiceSocket *sock, gint tos) +{ + if (setsockopt (sock->fileno, IPPROTO_IP, + IP_TOS, &tos, sizeof (tos)) < 0) { + nice_debug ("Agent %p: Could not set socket ToS", agent, + g_strerror (errno)); + } +#ifdef IPV6_TCLASS + if (setsockopt (sock->fileno, IPPROTO_IPV6, + IPV6_TCLASS, &tos, sizeof (tos)) < 0) { + nice_debug ("Agent %p: Could not set IPV6 socket ToS", agent, + g_strerror (errno)); + } +#endif +} + + +void nice_agent_set_stream_tos (NiceAgent *agent, guint stream_id, gint tos) { GSList *i, *j, *k; + agent_lock(); + for (i = agent->streams; i; i = i->next) { Stream *stream = i->data; if (stream->id == stream_id) { + stream->tos = tos; for (j = stream->components; j; j = j->next) { Component *component = j->data; for (k = component->local_candidates; k; k = k->next) { NiceCandidate *local_candidate = k->data; - if (setsockopt (local_candidate->sockptr->fileno, IPPROTO_IP, - IP_TOS, &tos, sizeof (tos)) < 0) { - nice_debug ("Agent %p: Could not set socket ToS", agent, - g_strerror (errno)); - } -#ifdef IPV6_TCLASS - if (setsockopt (local_candidate->sockptr->fileno, IPPROTO_IPV6, - IPV6_TCLASS, &tos, sizeof (tos)) < 0) { - nice_debug ("Agent %p: Could not set IPV6 socket ToS", agent, - g_strerror (errno)); - } -#endif + _priv_set_socket_tos (agent, local_candidate->sockptr, tos); } } } } + + agent_unlock(); } diff --git a/agent/agent.h b/agent/agent.h index f995ec8..4e40100 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -621,7 +621,16 @@ nice_agent_set_selected_remote_candidate ( NiceCandidate *candidate); -void nice_agent_set_stream_type_of_service ( +/** + * nice_agent_set_stream_tos: + * @agent: The #NiceAgent Object + * @stream_id: The ID of the stream + * @tos: The ToS to set + * + * Sets the ToS on the stream's sockets + * + */ +void nice_agent_set_stream_tos ( NiceAgent *agent, guint stream_id, gint tos); diff --git a/agent/discovery.c b/agent/discovery.c index 505af3f..53bed02 100644 --- a/agent/discovery.c +++ b/agent/discovery.c @@ -481,6 +481,7 @@ NiceCandidate *discovery_add_local_host_candidate ( if (udp_socket) { gboolean result; + _priv_set_socket_tos (agent, udp_socket, stream->tos); agent_attach_stream_component_socket (agent, stream, component, udp_socket); diff --git a/agent/stream.h b/agent/stream.h index cc39595..ce91e02 100644 --- a/agent/stream.h +++ b/agent/stream.h @@ -83,6 +83,7 @@ struct _Stream gchar remote_ufrag[NICE_STREAM_MAX_UFRAG]; gchar remote_password[NICE_STREAM_MAX_PWD]; gboolean gathering; + gint tos; }; Stream * diff --git a/nice/libnice.sym b/nice/libnice.sym index dc751c6..6c5472d 100644 --- a/nice/libnice.sym +++ b/nice/libnice.sym @@ -30,6 +30,7 @@ nice_agent_set_remote_candidates nice_agent_set_remote_credentials nice_agent_set_selected_pair nice_agent_set_selected_remote_candidate +nice_agent_set_stream_tos nice_candidate_free nice_candidate_new nice_debug_disable |