Commit 97beec8d authored by Youness Alaoui's avatar Youness Alaoui

Removed g_debug messages and replaced with nice_debug, en/disable-able with...

Removed g_debug messages and replaced with nice_debug, en/disable-able with nice_debug_en/disable API
parent 1d7714b6
......@@ -37,6 +37,8 @@ BUILT_SOURCES = \
CLEANFILES += $(BUILT_SOURCES)
libagent_la_SOURCES = \
debug.h \
debug.c \
candidate.h \
candidate.c \
component.h \
......
......@@ -55,6 +55,8 @@
#include <glib.h>
#include "debug.h"
#include "udp.h"
#include "udp-bsd.h"
#include "udp-turn.h"
......@@ -618,7 +620,7 @@ void agent_signal_component_state_change (NiceAgent *agent, guint stream_id, gui
return;
if (component->state != state && state < NICE_COMPONENT_STATE_LAST) {
g_debug ("Agent %p : stream %u component %u STATE-CHANGE %u -> %u.", agent,
nice_debug ("Agent %p : stream %u component %u STATE-CHANGE %u -> %u.", agent,
stream_id, component_id, component->state, state);
component->state = state;
......@@ -662,7 +664,7 @@ priv_add_new_candidate_discovery (NiceAgent *agent,
cdisco->stream = stream;
cdisco->component = stream_find_component_by_id (stream, component_id);
cdisco->agent = agent;
g_debug ("Agent %p : Adding new srv-rflx candidate discovery %p\n", agent, cdisco);
nice_debug ("Agent %p : Adding new srv-rflx candidate discovery %p\n", agent, cdisco);
agent->discovery_list = modified_list;
++agent->discovery_unsched_items;
}
......@@ -706,7 +708,7 @@ nice_agent_add_stream (
modified_list = g_slist_append (agent->streams, stream);
if (modified_list) {
stream->id = agent->next_stream_id++;
g_debug ("Agent %p : allocating stream id %u (%p)", agent, stream->id, stream);
nice_debug ("Agent %p : allocating stream id %u (%p)", agent, stream->id, stream);
stream_initialize_credentials (stream, agent->rng);
......@@ -773,7 +775,7 @@ nice_agent_gather_candidates (
goto done;
}
g_debug ("Agent %p : In %s mode, starting candidate gathering.", agent, agent->full_mode ? "ICE-FULL" : "ICE-LITE");
nice_debug ("Agent %p : In %s mode, starting candidate gathering.", agent, agent->full_mode ? "ICE-FULL" : "ICE-LITE");
/* generate a local host candidate for each local address */
......@@ -960,7 +962,7 @@ static gboolean priv_add_remote_candidate (
/* step: check whether the candidate already exists */
candidate = component_find_remote_candidate(component, addr, transport);
if (candidate) {
g_debug ("Agent %p : Update existing remote candidate %p.", agent, candidate);
nice_debug ("Agent %p : Update existing remote candidate %p.", agent, candidate);
/* case 1: an existing candidate, update the attributes */
candidate->type = type;
if (base_addr)
......@@ -996,7 +998,7 @@ static gboolean priv_add_remote_candidate (
{
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (addr, tmpbuf);
g_debug ("Agent %p : Adding remote candidate with addr [%s]:%u.", agent, tmpbuf,
nice_debug ("Agent %p : Adding remote candidate with addr [%s]:%u.", agent, tmpbuf,
nice_address_get_port (addr));
}
#endif
......@@ -1226,7 +1228,7 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo
if (added > 0) {
gboolean res = conn_check_schedule_next (agent);
if (res != TRUE)
g_debug ("Agent %p : Warning: unable to schedule any conn checks!", agent);
nice_debug ("Agent %p : Warning: unable to schedule any conn checks!", agent);
}
g_static_rec_mutex_unlock (&agent->mutex);
......@@ -1259,7 +1261,7 @@ _nice_agent_recv (
if (len >= 0) {
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&from, tmpbuf);
g_debug ("Agent %p : Packet received on local socket %u from [%s]:%u (%u octets).", agent,
nice_debug ("Agent %p : Packet received on local socket %u from [%s]:%u (%u octets).", agent,
udp_socket->fileno, tmpbuf, nice_address_get_port (&from), len);
}
#endif
......@@ -1276,7 +1278,7 @@ _nice_agent_recv (
if (nice_address_equal (&from, &component->turn_server)) {
GSList * i = NULL;
g_debug ("Agent %p : Packet received from TURN server candidate.", agent);
nice_debug ("Agent %p : Packet received from TURN server candidate.", agent);
for (i = component->local_candidates; i; i = i->next) {
NiceCandidate *cand = i->data;
if (cand->type == NICE_CANDIDATE_TYPE_RELAYED) {
......@@ -1568,7 +1570,7 @@ nice_agent_send (
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&component->selected_pair.remote->addr, tmpbuf);
g_debug ("Agent %p : s%d:%d: sending %d bytes to [%s]:%d", agent, stream_id, component_id,
nice_debug ("Agent %p : s%d:%d: sending %d bytes to [%s]:%d", agent, stream_id, component_id,
len, tmpbuf,
nice_address_get_port (&component->selected_pair.remote->addr));
#endif
......@@ -1843,7 +1845,7 @@ priv_attach_stream_component_socket (NiceAgent *agent,
ctx = io_ctx_new (agent, stream, component, udp_socket);
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free);
g_debug ("Agent %p : Attach source %p (stream %u).", agent, source, stream->id);
nice_debug ("Agent %p : Attach source %p (stream %u).", agent, source, stream->id);
g_source_attach (source, component->ctx);
component->gsources = g_slist_append (component->gsources, source);
}
......@@ -1878,7 +1880,7 @@ static void priv_detach_stream_component (Stream *stream, Component *component)
for (i = component->gsources; i; i = i->next) {
GSource *source = i->data;
g_debug ("Detach source %p (stream %u).", source, stream->id);
nice_debug ("Detach source %p (stream %u).", source, stream->id);
g_source_destroy (source);
}
......
......@@ -47,6 +47,8 @@
#include <string.h>
#include "debug.h"
#include "component.h"
#include "agent-priv.h"
......@@ -218,7 +220,7 @@ void component_update_selected_pair (Component *component, const CandidatePair *
{
g_assert (component);
g_assert (pair);
g_debug ("setting SELECTED PAIR for component %u: %s:%s (prio:%lu).",
nice_debug ("setting SELECTED PAIR for component %u: %s:%s (prio:%lu).",
component->id, pair->local->foundation, pair->remote->foundation, (long unsigned)pair->priority);
component->selected_pair.local = pair->local;
component->selected_pair.remote = pair->remote;
......
......@@ -50,6 +50,8 @@
#include <glib.h>
#include "debug.h"
#include "agent.h"
#include "agent-priv.h"
#include "conncheck.h"
......@@ -163,7 +165,7 @@ static gboolean priv_conn_check_unfreeze_next (NiceAgent *agent)
}
if (pair) {
g_debug ("Agent %p : Pair %p with s/c-id %u/%u (%s) unfrozen.", agent, pair, pair->stream_id, pair->component_id, pair->foundation);
nice_debug ("Agent %p : Pair %p with s/c-id %u/%u (%s) unfrozen.", agent, pair, pair->stream_id, pair->component_id, pair->foundation);
pair->state = NICE_CHECK_WAITING;
return TRUE;
}
......@@ -199,7 +201,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, Stream *stream,
if (p->stream_id == ok_check->stream_id) {
if (p->state == NICE_CHECK_FROZEN &&
strcmp (p->foundation, ok_check->foundation) == 0) {
g_debug ("Agent %p : Unfreezing check %p (after succesful check %p).", agent, p, ok_check);
nice_debug ("Agent %p : Unfreezing check %p (after succesful check %p).", agent, p, ok_check);
p->state = NICE_CHECK_WAITING;
++unfrozen;
}
......@@ -219,7 +221,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, Stream *stream,
p->stream_id != ok_check->stream_id) {
if (p->state == NICE_CHECK_FROZEN &&
strcmp (p->foundation, ok_check->foundation) == 0) {
g_debug ("Agent %p : Unfreezing check %p from stream %u (after succesful check %p).", agent, p, s->id, ok_check);
nice_debug ("Agent %p : Unfreezing check %p from stream %u (after succesful check %p).", agent, p, s->id, ok_check);
p->state = NICE_CHECK_WAITING;
++unfrozen;
......@@ -256,14 +258,14 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
if (p->state == NICE_CHECK_IN_PROGRESS) {
if (p->stun_message.buffer == NULL) {
g_debug ("Agent %p : STUN connectivity check was cancelled, marking as done.", agent);
nice_debug ("Agent %p : STUN connectivity check was cancelled, marking as done.", agent);
p->state = NICE_CHECK_FAILED;
} else if (priv_timer_expired (&p->next_tick, now)) {
int timeout = stun_timer_refresh (&p->timer);
switch (timeout) {
case -1:
/* case: error, abort processing */
g_debug ("Agent %p : Retransmissions failed, giving up on connectivity check %p", agent, p);
nice_debug ("Agent %p : Retransmissions failed, giving up on connectivity check %p", agent, p);
p->state = NICE_CHECK_FAILED;
p->stun_message.buffer = NULL;
p->stun_message.buffer_len = 0;
......@@ -272,7 +274,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
{
/* case: not ready, so schedule a new timeout */
unsigned int timeout = stun_timer_remainder (&p->timer);
g_debug ("Agent %p :STUN transaction retransmitted (timeout %dms).",
nice_debug ("Agent %p :STUN transaction retransmitted (timeout %dms).",
agent, timeout);
nice_udp_socket_send (p->local->sockptr, &p->remote->addr,
......@@ -334,7 +336,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
/* note: highest priority item selected (list always sorted) */
if (p->state == NICE_CHECK_SUCCEEDED ||
p->state == NICE_CHECK_DISCOVERED) {
g_debug ("Agent %p : restarting check %p as the nominated pair.", agent, p);
nice_debug ("Agent %p : restarting check %p as the nominated pair.", agent, p);
p->nominated = TRUE;
priv_conn_check_initiate (agent, p);
break; /* move to the next component */
......@@ -348,7 +350,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
{
static int tick_counter = 0;
if (tick_counter++ % 50 == 0 || keep_timer_going != TRUE)
g_debug ("Agent %p : timer(%p) tick #%u: %u frozen, %u in-progress, %u waiting, %u succeeded, %u nominated, %u waiting-for-nom.", agent,
nice_debug ("Agent %p : timer(%p) tick #%u: %u frozen, %u in-progress, %u waiting, %u succeeded, %u nominated, %u waiting-for-nom.", agent,
agent, tick_counter, frozen, s_inprogress, waiting, s_succeeded, s_nominated, s_waiting_for_nomination);
}
#endif
......@@ -404,7 +406,7 @@ static gboolean priv_conn_check_tick_unlocked (gpointer pointer)
/* step: stop timer if no work left */
if (keep_timer_going != TRUE) {
g_debug ("Agent %p : %s: stopping conncheck timer", agent, G_STRFUNC);
nice_debug ("Agent %p : %s: stopping conncheck timer", agent, G_STRFUNC);
for (i = agent->streams; i; i = i->next) {
Stream *stream = i->data;
priv_update_check_list_failed_components (agent, stream);
......@@ -412,7 +414,7 @@ static gboolean priv_conn_check_tick_unlocked (gpointer pointer)
}
conn_check_free (agent);
/* XXX: what to signal, is all processing now really done? */
g_debug ("Agent %p : changing conncheck state to COMPLETED.", agent);
nice_debug ("Agent %p : changing conncheck state to COMPLETED.", agent);
}
return keep_timer_going;
......@@ -470,7 +472,7 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer)
nice_udp_socket_send (p->local->sockptr, &p->remote->addr, buf_len, (gchar *)buf);
g_debug ("Agent %p : stun_bind_keepalive for pair %p res %d.",
nice_debug ("Agent %p : stun_bind_keepalive for pair %p res %d.",
agent, p, (int) buf_len);
if (buf_len == 0)
++errors;
......@@ -488,7 +490,7 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer)
CandidateCheckPair *p = j->data;
if (p->traffic_after_tick != TRUE) {
g_debug ("Agent %p : resending STUN-CC to keep the candidate alive (pair %p).", agent, p);
nice_debug ("Agent %p : resending STUN-CC to keep the candidate alive (pair %p).", agent, p);
conn_check_send (agent, p);
}
p->traffic_after_tick = FALSE;
......@@ -497,7 +499,7 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer)
}
if (errors) {
g_debug ("Agent %p : %s: stopping keepalive timer", agent, G_STRFUNC);
nice_debug ("Agent %p : %s: stopping keepalive timer", agent, G_STRFUNC);
goto done;
}
......@@ -516,15 +518,15 @@ static gboolean priv_conn_keepalive_tick (gpointer pointer)
gboolean conn_check_schedule_next (NiceAgent *agent)
{
gboolean res = priv_conn_check_unfreeze_next (agent);
g_debug ("Agent %p : priv_conn_check_unfreeze_next returned %d", agent, res);
nice_debug ("Agent %p : priv_conn_check_unfreeze_next returned %d", agent, res);
if (agent->discovery_unsched_items > 0)
g_debug ("Agent %p : WARN: starting conn checks before local candidate gathering is finished.", agent);
nice_debug ("Agent %p : WARN: starting conn checks before local candidate gathering is finished.", agent);
if (res == TRUE) {
/* step: call once imediately */
res = priv_conn_check_tick_unlocked ((gpointer) agent);
g_debug ("Agent %p : priv_conn_check_tick_unlocked returned %d", agent, res);
nice_debug ("Agent %p : priv_conn_check_tick_unlocked returned %d", agent, res);
/* step: schedule timer if not running yet */
if (res && agent->conncheck_timer_id == 0) {
......@@ -538,7 +540,7 @@ gboolean conn_check_schedule_next (NiceAgent *agent)
}
g_debug ("Agent %p : conn_check_schedule_next returning %d", agent, res);
nice_debug ("Agent %p : conn_check_schedule_next returning %d", agent, res);
return res;
}
......@@ -574,7 +576,7 @@ static void priv_preprocess_conn_check_pending_data (NiceAgent *agent, Stream *s
IncomingCheck *icheck = i->data;
if (nice_address_equal (&icheck->from, &pair->remote->addr) &&
icheck->local_socket == pair->local->sockptr) {
g_debug ("Agent %p : Updating check %p with stored early-icheck %p, %p/%u/%u (agent/stream/component).", agent, pair, icheck, agent, stream->id, component->id);
nice_debug ("Agent %p : Updating check %p with stored early-icheck %p, %p/%u/%u (agent/stream/component).", agent, pair, icheck, agent, stream->id, component->id);
if (icheck->use_candidate)
priv_mark_pair_nominated (agent, stream, component, pair->remote);
priv_schedule_triggered_check (agent, stream, component, icheck->local_socket, pair->remote, icheck->use_candidate);
......@@ -684,7 +686,7 @@ static gboolean priv_update_selected_pair (NiceAgent *agent, Component *componen
g_assert (component);
g_assert (pair);
if (pair->priority > component->selected_pair.priority) {
g_debug ("Agent %p : changing SELECTED PAIR for component %u: %s:%s (prio:%lu).", agent,
nice_debug ("Agent %p : changing SELECTED PAIR for component %u: %s:%s (prio:%lu).", agent,
component->id, pair->local->foundation, pair->remote->foundation, (long unsigned)pair->priority);
component->selected_pair.local = pair->local;
component->selected_pair.remote = pair->remote;
......@@ -772,7 +774,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, Stream *st
}
}
g_debug ("Agent %p : conn.check list status: %u nominated, %u succeeded, c-id %u.", agent, nominated, succeeded, component->id);
nice_debug ("Agent %p : conn.check list status: %u nominated, %u succeeded, c-id %u.", agent, nominated, succeeded, component->id);
}
/**
......@@ -793,7 +795,7 @@ static void priv_mark_pair_nominated (NiceAgent *agent, Stream *stream, Componen
* check was sent to? let's mark all matching pairs
* as nominated instead */
if (pair->remote == remotecand) {
g_debug ("Agent %p : marking pair %p (%s) as nominated", agent, pair, pair->foundation);
nice_debug ("Agent %p : marking pair %p (%s) as nominated", agent, pair, pair->foundation);
pair->nominated = TRUE;
if (pair->state == NICE_CHECK_SUCCEEDED ||
pair->state == NICE_CHECK_DISCOVERED)
......@@ -836,7 +838,7 @@ static gboolean priv_add_new_check_pair (NiceAgent *agent, guint stream_id, Comp
stream->conncheck_list = modified_list;
result = TRUE;
g_debug ("Agent %p : added a new conncheck %p with foundation of '%s' to list %u.", agent, pair, pair->foundation, stream_id);
nice_debug ("Agent %p : added a new conncheck %p with foundation of '%s' to list %u.", agent, pair, pair->foundation, stream_id);
/* implement the hard upper limit for number of
checks (see sect 5.7.3 ICE ID-19): */
......@@ -1178,7 +1180,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
{
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&pair->remote->addr, tmpbuf);
g_debug ("Agent %p : STUN-CC REQ to '%s:%u', socket=%u, pair=%s (c-id:%u), tie=%llu, username='%s', password='%s', priority=%u.", agent,
nice_debug ("Agent %p : STUN-CC REQ to '%s:%u', socket=%u, pair=%s (c-id:%u), tie=%llu, username='%s', password='%s', priority=%u.", agent,
tmpbuf,
ntohs(((struct sockaddr_in*)(&sockaddr))->sin_port),
pair->local->sockptr->fileno,
......@@ -1270,7 +1272,7 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
p->remote == remote_cand &&
p->local->sockptr == local_socket) {
g_debug ("Agent %p : Found a matching pair %p for triggered check.", agent, p);
nice_debug ("Agent %p : Found a matching pair %p for triggered check.", agent, p);
if (p->state == NICE_CHECK_WAITING ||
p->state == NICE_CHECK_FROZEN)
......@@ -1279,11 +1281,11 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
if (p->state == NICE_CHECK_IN_PROGRESS) {
/* XXX: according to ICE 7.2.1.4 "Triggered Checks" (ID-19),
* we should cancel the existing one, and send a new one...? :P */
g_debug ("Agent %p : Skipping triggered check, already in progress..", agent);
nice_debug ("Agent %p : Skipping triggered check, already in progress..", agent);
}
else if (p->state == NICE_CHECK_SUCCEEDED ||
p->state == NICE_CHECK_DISCOVERED) {
g_debug ("Agent %p : Skipping triggered check, already completed..", agent);
nice_debug ("Agent %p : Skipping triggered check, already completed..", agent);
/* note: this is a bit unsure corner-case -- let's do the
same state update as for processing responses to our own checks */
priv_update_check_list_state_for_ready (agent, stream, component);
......@@ -1311,11 +1313,11 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
break;
}
if (i) {
g_debug ("Agent %p : Adding a triggered check to conn.check list (local=%p).", agent, local);
nice_debug ("Agent %p : Adding a triggered check to conn.check list (local=%p).", agent, local);
result = priv_add_new_check_pair (agent, stream->id, component, local, remote_cand, NICE_CHECK_WAITING, use_candidate);
}
else
g_debug ("Agent %p : Didn't find a matching pair for triggered check (remote-cand=%p).", agent, remote_cand);
nice_debug ("Agent %p : Didn't find a matching pair for triggered check (remote-cand=%p).", agent, remote_cand);
}
return result;
......@@ -1348,7 +1350,7 @@ static void priv_reply_to_conn_check (NiceAgent *agent, Stream *stream, Componen
{
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (toaddr, tmpbuf);
g_debug ("Agent %p : STUN-CC RESP to '%s:%u', socket=%u, len=%u, cand=%p (c-id:%u), use-cand=%d.", agent,
nice_debug ("Agent %p : STUN-CC RESP to '%s:%u', socket=%u, len=%u, cand=%p (c-id:%u), use-cand=%d.", agent,
tmpbuf,
nice_address_get_port (toaddr),
udp_socket->fileno,
......@@ -1380,12 +1382,12 @@ static void priv_reply_to_conn_check (NiceAgent *agent, Stream *stream, Componen
static int priv_store_pending_check (NiceAgent *agent, Component *component, const NiceAddress *from, NiceUDPSocket *udp_socket, uint32_t priority, gboolean use_candidate)
{
IncomingCheck *icheck;
g_debug ("Agent %p : Storing pending check.", agent);
nice_debug ("Agent %p : Storing pending check.", agent);
if (component->incoming_checks &&
g_slist_length (component->incoming_checks) >=
NICE_AGENT_MAX_REMOTE_CANDIDATES) {
g_debug ("Agent %p : WARN: unable to store information for early incoming check.", agent);
nice_debug ("Agent %p : WARN: unable to store information for early incoming check.", agent);
return -1;
}
......@@ -1432,7 +1434,7 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint
pair->priority = nice_candidate_pair_priority (parent_pair->priority, local_cand->priority);
pair->nominated = FALSE;
pair->controlling = agent->controlling_mode;
g_debug ("Agent %p : added a new peer-discovered pair with foundation of '%s'.", agent, pair->foundation);
nice_debug ("Agent %p : added a new peer-discovered pair with foundation of '%s'.", agent, pair->foundation);
return pair;
}
}
......@@ -1466,14 +1468,14 @@ static void priv_check_for_role_conflict (NiceAgent *agent, gboolean control)
{
/* role conflict, change mode; wait for a new conn. check */
if (control != agent->controlling_mode) {
g_debug ("Agent %p : Role conflict, changing agent role to %d.", agent, control);
nice_debug ("Agent %p : Role conflict, changing agent role to %d.", agent, control);
agent->controlling_mode = control;
/* the pair priorities depend on the roles, so recalculation
* is needed */
priv_recalculate_pair_priorities (agent);
}
else
g_debug ("Agent %p : Role conflict, agent role already changed to %d.", agent, control);
nice_debug ("Agent %p : Role conflict, agent role already changed to %d.", agent, control);
}
/**
......@@ -1511,7 +1513,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
/* note: this is same as "adding to VALID LIST" in the spec
text */
p->state = NICE_CHECK_SUCCEEDED;
g_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p);
nice_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p);
priv_conn_check_unfreeze_related (agent, stream, p);
}
else {
......@@ -1528,7 +1530,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
/* step: add a new discovered pair (see ICE 7.1.2.2.2
"Constructing a Valid Pair" (ID-19)) */
new_pair = priv_add_peer_reflexive_pair (agent, stream->id, component->id, cand, p);
g_debug ("Agent %p : conncheck %p FAILED, %p DISCOVERED.", agent, p, new_pair);
nice_debug ("Agent %p : conncheck %p FAILED, %p DISCOVERED.", agent, p, new_pair);
}
return new_pair;
......@@ -1564,7 +1566,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
res = stun_usage_ice_conncheck_process (resp, &sockaddr, &socklen,
&alternate, &alternatelen,
priv_agent_to_usage_compatibility (agent));
g_debug ("Agent %p : stun_bind_process/conncheck for %p res %d "
nice_debug ("Agent %p : stun_bind_process/conncheck for %p res %d "
"(controlling=%d).", agent, p, (int)res, agent->controlling_mode);
......@@ -1575,7 +1577,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
CandidateCheckPair *ok_pair = NULL;
g_debug ("Agent %p : conncheck %p MATCHED.", agent, p);
nice_debug ("Agent %p : conncheck %p MATCHED.", agent, p);
p->stun_message.buffer = NULL;
p->stun_message.buffer_len = 0;
......@@ -1584,7 +1586,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
* Cases") */
if (nice_address_equal (from, &p->remote->addr) != TRUE) {
p->state = NICE_CHECK_FAILED;
g_debug ("Agent %p : conncheck %p FAILED"
nice_debug ("Agent %p : conncheck %p FAILED"
" (mismatch of source address).", agent, p);
trans_found = TRUE;
break;
......@@ -1622,7 +1624,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
trans_found = TRUE;
} else if (res == STUN_USAGE_ICE_RETURN_ROLE_CONFLICT) {
/* case: role conflict error, need to restart with new role */
g_debug ("Agent %p : conncheck %p ROLE CONFLICT, restarting", agent, p);
nice_debug ("Agent %p : conncheck %p ROLE CONFLICT, restarting", agent, p);
/* note: our role might already have changed due to an
* incoming request, but if not, change role now;
* follows ICE 7.1.2.1 "Failure Cases" (ID-19) */
......@@ -1634,7 +1636,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
trans_found = TRUE;
} else if (res == STUN_USAGE_ICE_RETURN_ERROR) {
/* case: STUN error, the check STUN context was freed */
g_debug ("Agent %p : conncheck %p FAILED.", agent, p);
nice_debug ("Agent %p : conncheck %p FAILED.", agent, p);
p->stun_message.buffer = NULL;
p->stun_message.buffer_len = 0;
trans_found = TRUE;
......@@ -1674,7 +1676,7 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
if (memcmp (discovery_id, response_id, sizeof(stun_transid_t)) == 0) {
res = stun_usage_bind_process (resp, &sockaddr, &socklen,
&alternate, &alternatelen);
g_debug ("Agent %p : stun_bind_process/disc for %p res %d.",
nice_debug ("Agent %p : stun_bind_process/disc for %p res %d.",
agent, d, (int)res);
if (res == STUN_USAGE_BIND_RETURN_ALTERNATE_SERVER) {
......@@ -1794,7 +1796,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
/* note: contents of 'buf' already validated, so it is
* a valid and fully received STUN message */
g_debug ("Agent %p : inbound STUN packet for %u/%u (stream/component):",
nice_debug ("Agent %p : inbound STUN packet for %u/%u (stream/component):",
agent, stream->id, component->id);
/* note: ICE 7.2. "STUN Server Procedures" (ID-19) */
......@@ -1812,12 +1814,12 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
valid == STUN_VALIDATION_INCOMPLETE_STUN ||
valid == STUN_VALIDATION_BAD_REQUEST)
{
g_debug ("Agent %p : Incorrectly multiplexed STUN message ignored.", agent);
nice_debug ("Agent %p : Incorrectly multiplexed STUN message ignored.", agent);
return FALSE;
}
if (valid == STUN_VALIDATION_UNKNOWN_REQUEST_ATTRIBUTE) {
g_debug ("Agent %p : Unknown mandatory attributes in message.", agent);
nice_debug ("Agent %p : Unknown mandatory attributes in message.", agent);
rbuf_len = stun_agent_build_unknown_attributes_error (&agent->stun_agent,
&msg, rbuf, rbuf_len, &req);
if (len == 0)
......@@ -1830,7 +1832,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
}
if (valid == STUN_VALIDATION_UNAUTHORIZED) {
g_debug ("Agent %p : Integrity check failed.", agent);
nice_debug ("Agent %p : Integrity check failed.", agent);
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
&req, STUN_ERROR_UNAUTHORIZED)) {
......@@ -1841,7 +1843,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
return TRUE;
}
if (valid == STUN_VALIDATION_UNAUTHORIZED_BAD_REQUEST) {
g_debug ("Agent %p : Integrity check failed.", agent);
nice_debug ("Agent %p : Integrity check failed.", agent);
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
&req, STUN_ERROR_BAD_REQUEST)) {
rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0);
......@@ -1883,7 +1885,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
local_candidate == NULL) {
/* if we couldn't match the username and the stun agent has
IGNORE_CREDENTIALS then we have an integrity check failing */
g_debug ("Agent %p : Username check failed.", agent);
nice_debug ("Agent %p : Username check failed.", agent);
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
&req, STUN_ERROR_UNAUTHORIZED)) {
rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0);
......@@ -1894,7 +1896,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
}
if (valid != STUN_VALIDATION_SUCCESS) {
g_debug ("Agent %p : STUN message is unsuccessfull, ignoring", agent);
nice_debug ("Agent %p : STUN message is unsuccessfull, ignoring", agent);
return FALSE;
}
......@@ -1939,7 +1941,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
agent_signal_initial_binding_request_received (agent, stream);
if (component->remote_candidates && remote_candidate == NULL) {
g_debug ("Agent %p : No matching remote candidate for incoming check ->"
nice_debug ("Agent %p : No matching remote candidate for incoming check ->"
"peer-reflexive candidate.", agent);
remote_candidate = discovery_learn_remote_peer_reflexive_candidate (
agent, stream, component, priority, from, udp_socket);
......@@ -1960,7 +1962,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
priority, use_candidate);
}
} else {
g_debug ("Agent %p : Invalid STUN packet, ignoring... %s",
nice_debug ("Agent %p : Invalid STUN packet, ignoring... %s",
agent, strerror(errno));
return FALSE;
}
......@@ -1980,7 +1982,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
trans_found = priv_map_reply_to_discovery_request (agent, &req);
if (trans_found != TRUE)
g_debug ("Agent %p : Unable to match to an existing transaction, "
nice_debug ("Agent %p : Unable to match to an existing transaction, "
"probably a keepalive.", agent);
}
......
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* (C) 2008 Nokia Corporation. All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
* Contributors:
* Youness Alaoui, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debug.h"
#include <glib.h>
static int debug_enabled = 1;
void nice_debug_enable (void) {
debug_enabled = 1;
}
void nice_debug_disable (void) {
debug_enabled = 0;
}
void nice_debug (const char *fmt, ...)
{
va_list ap;
if (debug_enabled) {
va_start (ap, fmt);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, fmt, ap);
va_end (ap);
}
}
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2008 Collabora Ltd.
* (C) 2008 Nokia Corporation. All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
* Contributors:
* Youness Alaoui, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifndef _DEBUG_H
#define _DEBUG_H
void nice_debug_enable (void);
void nice_debug_disable (void);
void nice_debug (const char *fmt, ...);
#endif /* _DEBUG_H */
......@@ -51,6 +51,8 @@
#include <glib.h>
#include "debug.h"
#include "agent.h"
#include "agent-priv.h"
#include "agent-signals-marshal.h"
......@@ -138,7 +140,7 @@ static gboolean priv_add_local_candidate_pruned (Component *component, NiceCandi
if (nice_address_equal (&c->base_addr, &candidate->base_addr) &&
nice_address_equal (&c->addr, &candidate->addr)) {
g_debug ("Candidate %p (component-id %u) redundant, ignoring.", candidate, component->id);
nice_debug ("Candidate %p (component-id %u) redundant, ignoring.", candidate, component->id);
return FALSE;
}
}
......@@ -638,7 +640,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
{
static int tick_counter = 0;
if (tick_counter++ % 50 == 0)
g_debug ("Agent %p : discovery tick #%d with list %p (1)", agent, tick_counter, agent->discovery_list);
nice_debug ("Agent %p : discovery tick #%d with list %p (1)", agent, tick_counter, agent->discovery_list);
}
#endif
......@@ -655,7 +657,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
{
gchar tmpbuf[INET6_ADDRSTRLEN];
nice_address_to_string (&cand->server, tmpbuf);
g_debug ("Agent %p : discovery - scheduling cand type %u addr %s and socket %d.\n", agent,
nice_debug ("Agent %p : discovery - scheduling cand type %u addr %s and socket %d.\n", agent,
cand->type, tmpbuf, cand->socket);
}
#endif
......@@ -715,7 +717,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
g_get_current_time (&now);
if (cand->stun_message.buffer == NULL) {
g_debug ("Agent %p : STUN discovery was cancelled, marking discovery done.", agent);
nice_debug ("Agent %p : STUN discovery was cancelled, marking discovery done.", agent);
cand->done = TRUE;
}
else if (priv_timer_expired (&cand->next_tick, &now)) {
......@@ -726,7 +728,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
cand->done = TRUE;
cand->stun_message.buffer = NULL;
cand->stun_message.buffer_len = 0;
g_debug ("Agent %p : bind discovery timed out, aborting discovery item.", agent);
nice_debug ("Agent %p : bind discovery timed out, aborting discovery item.", agent);
break;
case 0:
{
......@@ -765,7 +767,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
}
if (not_done == 0) {
g_debug ("Agent %p : Candidate gathering FINISHED, stopping discovery timer.", agent);
nice_debug ("Agent %p : Candidate gathering FINISHED, stopping discovery timer.", agent);
discovery_free (agent);
......
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