summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2009-08-17 17:03:11 -0400
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2009-08-17 17:03:11 -0400
commit4dc7fab1fa0d09e4bb4827a68007ca085db7be9a (patch)
tree89c33cf653b0ea54a667c818dc31e89e2b79661e
parent577dd5c7ef31eace9086989b54e3990c59068533 (diff)
downloadlibnice-4dc7fab1fa0d09e4bb4827a68007ca085db7be9a.tar.gz
Only keep the srv-reflexive candidates alive by resending our initial STUN discovery during keepalive phase... this should fix the sending of over 300 completely useless connchecks that just spammed the network and filled our max saved ids for the stun agent requests, thus rendering future connchecks useless
-rw-r--r--agent/conncheck.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 34c4fe7..90a5f5b 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -554,7 +554,7 @@ static gboolean priv_conn_keepalive_retransmissions_tick (gpointer pointer)
*/
static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
{
- GSList *i, *j;
+ GSList *i, *j, *k;
int errors = 0;
gboolean ret = FALSE;
size_t buf_len = 0;
@@ -657,12 +657,36 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
* (ref ICE sect 4.1.1.4 "Keeping Candidates Alive" ID-19) */
for (i = agent->streams; i; i = i->next) {
Stream *stream = i->data;
- if (stream->conncheck_state == NICE_CHECKLIST_RUNNING) {
- for (j = stream->conncheck_list; j ; j = j->next) {
- CandidateCheckPair *p = j->data;
-
- nice_debug ("Agent %p : resending STUN-CC to keep the candidate alive (pair %p).", agent, p);
- conn_check_send (agent, p);
+ for (j = stream->components; j; j = j->next) {
+ Component *component = j->data;
+ if (component->state < NICE_COMPONENT_STATE_READY &&
+ agent->stun_server_ip) {
+ NiceAddress stun_server;
+ if (nice_address_set_from_string (&stun_server, agent->stun_server_ip)) {
+ StunAgent stun_agent;
+ uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE];
+ StunMessage stun_message;
+ size_t buffer_len = 0;
+
+ nice_address_set_port (&stun_server, agent->stun_server_port);
+
+ stun_agent_init (&stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
+ STUN_COMPATIBILITY_RFC3489, 0);
+
+ buffer_len = stun_usage_bind_create (&stun_agent,
+ &stun_message, stun_buffer, sizeof(stun_buffer));
+
+ for (k = component->local_candidates; k; k = k->next) {
+ NiceCandidate *candidate = (NiceCandidate *) k->data;
+ if (candidate->type == NICE_CANDIDATE_TYPE_HOST) {
+ /* send the conncheck */
+ nice_debug ("Agent %p : resending STUN on %s to keep the "
+ "candidate alive.", agent, candidate->foundation);
+ nice_socket_send (candidate->sockptr, &stun_server,
+ buffer_len, (gchar *)stun_buffer);
+ }
+ }
+ }
}
}
}