Commit 7dea3231 authored by Olivier Crête's avatar Olivier Crête

debug: Make debug messages ready for g_log()

Send thing one line at a time, so no explicit \n

Also make it possible to set a log handler explicitly
parent 5ab7c883
......@@ -1021,15 +1021,14 @@ void conn_check_remote_candidates_set(NiceAgent *agent)
component->id, rcand, lcand,
uname, sizeof (uname), TRUE);
stun_debug ("pending check, comparing username '");
stun_debug_bytes (icheck->username,
stun_debug ("pending check, comparing usernames of len %d and %d, equal=%d",
icheck->username_len, uname_len,
icheck->username && uname_len == icheck->username_len &&
memcmp (uname, icheck->username, icheck->username_len) == 0);
stun_debug_bytes (" first username: ",
icheck->username,
icheck->username? icheck->username_len : 0);
stun_debug ("' (%d) with '", icheck->username_len);
stun_debug_bytes (uname, uname_len);
stun_debug ("' (%d) : %d\n",
uname_len, icheck->username &&
uname_len == icheck->username_len &&
memcmp (icheck->username, uname, uname_len) == 0);
stun_debug_bytes (" second username: ", uname, uname_len);
if (icheck->username &&
uname_len == icheck->username_len &&
......@@ -2853,13 +2852,11 @@ static bool conncheck_stun_validater (StunAgent *agent,
if (ufrag == NULL)
continue;
stun_debug ("Comparing username '");
stun_debug_bytes (username, username_len);
stun_debug ("' (%d) with '", username_len);
stun_debug_bytes (ufrag, ufrag_len);
stun_debug ("' (%" G_GSIZE_FORMAT ") : %d\n",
ufrag_len, username_len >= ufrag_len ?
stun_debug ("Comparing username/ufrag of len %d and %zu, equal=%d",
username_len, ufrag_len, username_len >= ufrag_len ?
memcmp (username, ufrag, ufrag_len) : 0);
stun_debug_bytes (" username: ", username, username_len);
stun_debug_bytes (" ufrag: ", ufrag, ufrag_len);
if (ufrag_len > 0 && username_len >= ufrag_len &&
memcmp (username, ufrag, ufrag_len) == 0) {
gchar *pass = NULL;
......@@ -2885,7 +2882,7 @@ static bool conncheck_stun_validater (StunAgent *agent,
if (msn_msoc_nice_compatibility)
g_free (ufrag);
stun_debug ("Found valid username, returning password: '%s'\n", *password);
stun_debug ("Found valid username, returning password: '%s'", *password);
return TRUE;
}
......@@ -3085,13 +3082,14 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
component->id, rcand, lcand,
uname, sizeof (uname), inbound);
stun_debug ("Comparing username '");
stun_debug_bytes (username, username? username_len : 0);
stun_debug ("' (%d) with '", username_len);
stun_debug_bytes (uname, uname_len);
stun_debug ("' (%d) : %d\n",
uname_len, username && uname_len == username_len &&
stun_debug ("Comparing usernames of size %d and %d: %d",
username_len, uname_len, username && uname_len == username_len &&
memcmp (username, uname, uname_len) == 0);
stun_debug_bytes (" First username: ", username,
username ? username_len : 0);
stun_debug_bytes (" Second uname: ", uname, uname_len);
if (username &&
uname_len == username_len &&
......
......@@ -1079,7 +1079,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
/* case: not ready complete, so schedule next timeout */
unsigned int timeout = stun_timer_remainder (&cand->timer);
stun_debug ("STUN transaction retransmitted (timeout %dms).\n",
stun_debug ("STUN transaction retransmitted (timeout %dms).",
timeout);
/* retransmit */
......
......@@ -55,22 +55,51 @@ void stun_debug_disable (void) {
debug_enabled = 0;
}
static void
default_handler (const char *format, va_list ap)
{
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
}
static StunDebugHandler handler = default_handler;
void stun_debug (const char *fmt, ...)
{
va_list ap;
if (debug_enabled) {
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
handler (fmt, ap);
va_end (ap);
}
}
void stun_debug_bytes (const void *data, size_t len)
void stun_debug_bytes (const char *prefix, const void *data, size_t len)
{
size_t i;
size_t prefix_len = strlen (prefix);
char bytes[prefix_len + 2 + (len * 2) + 1];
if (!debug_enabled)
return;
bytes[0] = 0;
strcpy (bytes, prefix);
strcpy (bytes + prefix_len, "0x");
stun_debug ("0x");
for (i = 0; i < len; i++)
stun_debug ("%02x", ((const unsigned char *)data)[i]);
snprintf (bytes + prefix_len + 2 + (i * 2), 3, "%02x", ((const unsigned char *)data)[i]);
stun_debug ("%s", bytes);
}
void stun_set_debug_handler (StunDebugHandler _handler)
{
if (_handler == NULL)
_handler = default_handler;
handler = _handler;
}
......@@ -38,6 +38,7 @@
#define STUN_DEBUG_H
#include <stddef.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
......@@ -58,6 +59,9 @@ void stun_debug_enable (void);
*/
void stun_debug_disable (void);
typedef void (*StunDebugHandler) (const char *format, va_list ap);
void stun_set_debug_handler (StunDebugHandler handler);
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4))
void stun_debug (const char *fmt, ...)
......@@ -65,7 +69,7 @@ void stun_debug (const char *fmt, ...)
#else
void stun_debug (const char *fmt, ...);
#endif
void stun_debug_bytes (const void *data, size_t len);
void stun_debug_bytes (const char *prefix, const void *data, size_t len);
# ifdef __cplusplus
......
......@@ -77,17 +77,19 @@ bool stun_agent_default_validater (StunAgent *agent,
int i;
for (i = 0; val && val[i].username ; i++) {
stun_debug ("Comparing username '");
stun_debug_bytes (username, username_len);
stun_debug ("' (%d) with '", username_len);
stun_debug_bytes (val[i].username, val[i].username_len);
stun_debug ("' (%" PRIuPTR ") : %d\n",
val[i].username_len, memcmp (username, val[i].username, username_len));
#if 0
stun_debug ("Comparing username of size %d and %" PRIuPTR ": %d",
username_len, val[i].username_len,
(memcmp (username, val[i].username, username_len) == 0));
#endif
stun_debug_bytes (" First username: ", username, username_len);
stun_debug_bytes (" Second username: ", val[i].username,
val[i].username_len);
if (username_len == val[i].username_len &&
memcmp (username, val[i].username, username_len) == 0) {
*password = (uint8_t *) val[i].password;
*password_len = val[i].password_len;
stun_debug ("Found valid username, returning password : '%s'\n", *password);
stun_debug ("Found valid username, returning password : '%s'", *password);
return TRUE;
}
}
......@@ -139,7 +141,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
!stun_message_has_cookie (msg)) {
stun_debug ("STUN demux error: no cookie!\n");
stun_debug ("STUN demux error: no cookie!");
return STUN_VALIDATION_BAD_REQUEST;
}
......@@ -149,7 +151,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
/* Looks for FINGERPRINT */
if (stun_message_find32 (msg, STUN_ATTRIBUTE_FINGERPRINT, &fpr) !=
STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug ("STUN demux error: no FINGERPRINT attribute!\n");
stun_debug ("STUN demux error: no FINGERPRINT attribute!");
return STUN_VALIDATION_BAD_REQUEST;
}
/* Checks FINGERPRINT */
......@@ -158,11 +160,11 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
fpr = ntohl (fpr);
if (fpr != crc32) {
stun_debug ("STUN demux error: bad fingerprint: 0x%08x,"
" expected: 0x%08x!\n", fpr, crc32);
" expected: 0x%08x!", fpr, crc32);
return STUN_VALIDATION_BAD_REQUEST;
}
stun_debug ("STUN demux: OK!\n");
stun_debug ("STUN demux: OK!");
}
if (stun_message_get_class (msg) == STUN_RESPONSE ||
......@@ -284,27 +286,23 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
}
stun_debug (" Message HMAC-SHA1 fingerprint:");
stun_debug ("\nkey : ");
stun_debug_bytes (key, key_len);
stun_debug ("\n expected: ");
stun_debug_bytes (sha, sizeof (sha));
stun_debug ("\n received: ");
stun_debug_bytes (hash, sizeof (sha));
stun_debug ("\n");
stun_debug_bytes (" key : ", key, key_len);
stun_debug_bytes (" expected: ", sha, sizeof (sha));
stun_debug_bytes (" received: ", hash, sizeof (sha));
if (memcmp (sha, hash, sizeof (sha))) {
stun_debug ("STUN auth error: SHA1 fingerprint mismatch!\n");
stun_debug ("STUN auth error: SHA1 fingerprint mismatch!");
return STUN_VALIDATION_UNAUTHORIZED;
}
stun_debug ("STUN auth: OK!\n");
stun_debug ("STUN auth: OK!");
msg->key = key;
msg->key_len = key_len;
} else if (!(stun_message_get_class (msg) == STUN_ERROR &&
stun_message_find_error (msg, &error_code) ==
STUN_MESSAGE_RETURN_SUCCESS &&
(error_code == 400 || error_code == 401))) {
stun_debug ("STUN auth error: No message integrity attribute!\n");
stun_debug ("STUN auth error: No message integrity attribute!");
return STUN_VALIDATION_UNAUTHORIZED;
}
}
......@@ -600,12 +598,9 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
}
}
stun_debug (" Message HMAC-SHA1 message integrity:"
"\n key : ");
stun_debug_bytes (key, key_len);
stun_debug ("\n sent : ");
stun_debug_bytes (ptr, 20);
stun_debug ("\n");
stun_debug (" Message HMAC-SHA1 message integrity:");
stun_debug_bytes (" key : ", key, key_len);
stun_debug_bytes (" sent : ", ptr, 20);
}
}
......@@ -621,9 +616,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
agent->compatibility == STUN_COMPATIBILITY_WLM2009);
memcpy (ptr, &fpr, sizeof (fpr));
stun_debug (" Message HMAC-SHA1 fingerprint: ");
stun_debug_bytes (ptr, 4);
stun_debug ("\n");
stun_debug_bytes (" Message HMAC-SHA1 fingerprint: ", ptr, 4);
}
......@@ -678,7 +671,7 @@ stun_agent_find_unknowns (StunAgent *agent, const StunMessage * msg,
if (!stun_optional (atype) && stun_agent_is_unknown (agent, atype))
{
stun_debug ("STUN unknown: attribute 0x%04x(%u bytes)\n",
stun_debug ("STUN unknown: attribute 0x%04x(%u bytes)",
(unsigned)atype, (unsigned)alen);
list[count++] = htons (atype);
}
......@@ -689,7 +682,7 @@ stun_agent_find_unknowns (StunAgent *agent, const StunMessage * msg,
offset += STUN_ATTRIBUTE_VALUE_POS + alen;
}
stun_debug ("STUN unknown: %u mandatory attribute(s)!\n", count);
stun_debug ("STUN unknown: %u mandatory attribute(s)!", count);
return count;
}
......
......@@ -544,19 +544,19 @@ ssize_t stun_message_validate_buffer_length_fast (StunInputVector *buffers,
if (total_length < 1 || n_buffers == 0 || buffers[0].buffer == NULL)
{
stun_debug ("STUN error: No data!\n");
stun_debug ("STUN error: No data!");
return STUN_MESSAGE_BUFFER_INVALID;
}
if (buffers[0].buffer[0] >> 6)
{
stun_debug ("STUN error: RTP or other non-protocol packet!\n");
stun_debug ("STUN error: RTP or other non-protocol packet!");
return STUN_MESSAGE_BUFFER_INVALID; // RTP or other non-STUN packet
}
if (total_length < STUN_MESSAGE_LENGTH_POS + STUN_MESSAGE_LENGTH_LEN)
{
stun_debug ("STUN error: Incomplete STUN message header!\n");
stun_debug ("STUN error: Incomplete STUN message header!");
return STUN_MESSAGE_BUFFER_INCOMPLETE;
}
......@@ -590,12 +590,12 @@ ssize_t stun_message_validate_buffer_length_fast (StunInputVector *buffers,
mlen += STUN_MESSAGE_HEADER_LENGTH;
if (has_padding && stun_padding (mlen)) {
stun_debug ("STUN error: Invalid message length: %u!\n", (unsigned)mlen);
stun_debug ("STUN error: Invalid message length: %u!", (unsigned)mlen);
return STUN_MESSAGE_BUFFER_INVALID; // wrong padding
}
if (total_length < mlen) {
stun_debug ("STUN error: Incomplete message: %u of %u bytes!\n",
stun_debug ("STUN error: Incomplete message: %u of %u bytes!",
(unsigned) total_length, (unsigned) mlen);
return STUN_MESSAGE_BUFFER_INCOMPLETE; // partial message
}
......@@ -631,7 +631,7 @@ int stun_message_validate_buffer_length (const uint8_t *msg, size_t length,
if (len < 4)
{
stun_debug ("STUN error: Incomplete STUN attribute header of length "
"%u bytes!\n", (unsigned)len);
"%u bytes!", (unsigned)len);
return STUN_MESSAGE_BUFFER_INVALID;
}
......@@ -645,7 +645,7 @@ int stun_message_validate_buffer_length (const uint8_t *msg, size_t length,
if (len < alen)
{
stun_debug ("STUN error: %u instead of %u bytes for attribute!\n",
stun_debug ("STUN error: %u instead of %u bytes for attribute!",
(unsigned)len, (unsigned)alen);
return STUN_MESSAGE_BUFFER_INVALID; // no room for attribute value + padding
}
......
......@@ -717,13 +717,9 @@ static void test_hash_creds (void)
(uint8_t *) "user", strlen ("user"),
(uint8_t *) "pass", strlen ("pass"), md5);
stun_debug ("key for user:realm:pass is : ");
stun_debug_bytes (md5, 16);
stun_debug ("\n\n");
stun_debug_bytes ("key for user:realm:pass is : ", md5, 16);
stun_debug ("RFC key for user:realm:pass is : ");
stun_debug_bytes (real_md5, 16);
stun_debug ("\n\n");
stun_debug_bytes ("RFC key for user:realm:pass is : ", real_md5, 16);
if(memcmp (md5, real_md5, sizeof(md5)) != 0)
fatal ("MD5 hashes are different!");
......
......@@ -120,7 +120,7 @@ StunUsageBindReturn stun_usage_bind_process (StunMessage *msg,
/* NOTE: currently we ignore unauthenticated messages if the context
* is authenticated, for security reasons. */
stun_debug (" STUN error message received (code: %d)\n", code);
stun_debug (" STUN error message received (code: %d)", code);
/* ALTERNATE-SERVER mechanism */
if ((code / 100) == 3) {
......@@ -128,17 +128,17 @@ StunUsageBindReturn stun_usage_bind_process (StunMessage *msg,
if (stun_message_find_addr (msg, STUN_ATTRIBUTE_ALTERNATE_SERVER,
(struct sockaddr_storage *) alternate_server,
alternate_server_len) != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute\n");
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute");
return STUN_USAGE_BIND_RETURN_ERROR;
}
} else {
if (!stun_message_has_attribute (msg, STUN_ATTRIBUTE_ALTERNATE_SERVER)) {
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute\n");
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute");
return STUN_USAGE_BIND_RETURN_ERROR;
}
}
stun_debug ("Found alternate server\n");
stun_debug ("Found alternate server");
return STUN_USAGE_BIND_RETURN_ALTERNATE_SERVER;
}
......@@ -149,25 +149,25 @@ StunUsageBindReturn stun_usage_bind_process (StunMessage *msg,
break;
}
stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg));
stun_debug ("Received %u-bytes STUN message", stun_message_length (msg));
val = stun_message_find_xor_addr (msg,
STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS, (struct sockaddr_storage *)addr,
addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS)
{
stun_debug (" No XOR-MAPPED-ADDRESS: %d\n", val);
stun_debug (" No XOR-MAPPED-ADDRESS: %d", val);
val = stun_message_find_addr (msg,
STUN_ATTRIBUTE_MAPPED_ADDRESS, (struct sockaddr_storage *)addr,
addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS)
{
stun_debug (" No MAPPED-ADDRESS: %d\n", val);
stun_debug (" No MAPPED-ADDRESS: %d", val);
return STUN_USAGE_BIND_RETURN_ERROR;
}
}
stun_debug (" Mapped address found!\n");
stun_debug (" Mapped address found!");
return STUN_USAGE_BIND_RETURN_SUCCESS;
}
......@@ -478,19 +478,19 @@ StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv,
ret = stun_trans_create (&trans, SOCK_DGRAM, 0, srv, srvlen);
if (ret != STUN_USAGE_TRANS_RETURN_SUCCESS) {
stun_debug ("STUN transaction failed: couldn't create transport.\n");
stun_debug ("STUN transaction failed: couldn't create transport.");
return STUN_USAGE_BIND_RETURN_ERROR;
}
val = stun_trans_send (&trans, req_buf, len);
if (val < -1) {
stun_debug ("STUN transaction failed: couldn't send request.\n");
stun_debug ("STUN transaction failed: couldn't send request.");
return STUN_USAGE_BIND_RETURN_ERROR;
}
stun_timer_start (&timer, STUN_TIMER_DEFAULT_TIMEOUT,
STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS);
stun_debug ("STUN transaction started (timeout %dms).\n",
stun_debug ("STUN transaction started (timeout %dms).",
stun_timer_remainder (&timer));
do
......@@ -501,14 +501,14 @@ StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv,
if (ret == STUN_USAGE_TRANS_RETURN_RETRY) {
switch (stun_timer_refresh (&timer)) {
case STUN_USAGE_TIMER_RETURN_TIMEOUT:
stun_debug ("STUN transaction failed: time out.\n");
stun_debug ("STUN transaction failed: time out.");
return STUN_USAGE_BIND_RETURN_TIMEOUT; // fatal error!
case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
stun_debug ("STUN transaction retransmitted (timeout %dms).\n",
stun_debug ("STUN transaction retransmitted (timeout %dms).",
stun_timer_remainder (&timer));
val = stun_trans_send (&trans, req_buf, len);
if (val < -1) {
stun_debug ("STUN transaction failed: couldn't resend request.\n");
stun_debug ("STUN transaction failed: couldn't resend request.");
return STUN_USAGE_BIND_RETURN_ERROR;
}
continue;
......
......@@ -160,12 +160,12 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
/* NOTE: currently we ignore unauthenticated messages if the context
* is authenticated, for security reasons. */
stun_debug (" STUN error message received (code: %d)\n", code);
stun_debug (" STUN error message received (code: %d)", code);
return STUN_USAGE_ICE_RETURN_ERROR;
}
stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg));
stun_debug ("Received %u-bytes STUN message", stun_message_length (msg));
if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_MSN) {
union {
......@@ -184,17 +184,17 @@ StunUsageIceReturn stun_usage_ice_conncheck_process (StunMessage *msg,
}
if (val != STUN_MESSAGE_RETURN_SUCCESS)
{
stun_debug (" No XOR-MAPPED-ADDRESS: %d\n", val);
stun_debug (" No XOR-MAPPED-ADDRESS: %d", val);
val = stun_message_find_addr (msg,
STUN_ATTRIBUTE_MAPPED_ADDRESS, addr, addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS)
{
stun_debug (" No MAPPED-ADDRESS: %d\n", val);
stun_debug (" No MAPPED-ADDRESS: %d", val);
return STUN_USAGE_ICE_RETURN_NO_MAPPED_ADDRESS;
}
}
stun_debug ("Mapped address found!\n");
stun_debug ("Mapped address found!");
return STUN_USAGE_ICE_RETURN_SUCCESS;
}
......@@ -207,7 +207,7 @@ stun_bind_error (StunAgent *agent, StunMessage *msg,
int val;
*plen = 0;
stun_debug ("STUN Error Reply (buffer size: %u)...\n", (unsigned)len);
stun_debug ("STUN Error Reply (buffer size: %u)...", (unsigned)len);
val = stun_agent_init_error (agent, msg, buf, len, req, code);
if (!val)
......@@ -218,7 +218,7 @@ stun_bind_error (StunAgent *agent, StunMessage *msg,
return 0;
*plen = len;
stun_debug (" Error response (%u) of %u bytes\n", (unsigned)code,
stun_debug (" Error response (%u) of %u bytes", (unsigned)code,
(unsigned)*plen);
return 1;
}
......@@ -243,18 +243,18 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
*plen = len
*plen = 0;
stun_debug ("STUN Reply (buffer size = %u)...\n", (unsigned)len);
stun_debug ("STUN Reply (buffer size = %u)...", (unsigned)len);
if (stun_message_get_class (req) != STUN_REQUEST)
{
stun_debug (" Unhandled non-request (class %u) message.\n",
stun_debug (" Unhandled non-request (class %u) message.",
stun_message_get_class (req));
return STUN_USAGE_ICE_RETURN_INVALID_REQUEST;
}
if (stun_message_get_method (req) != STUN_BINDING)
{
stun_debug (" Bad request (method %u) message.\n",
stun_debug (" Bad request (method %u) message.",
stun_message_get_method (req));
err (STUN_ERROR_BAD_REQUEST);
return STUN_USAGE_ICE_RETURN_INVALID_METHOD;
......@@ -265,28 +265,28 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
if (stun_message_find64 (req, *control ? STUN_ATTRIBUTE_ICE_CONTROLLING
: STUN_ATTRIBUTE_ICE_CONTROLLED, &q) == STUN_MESSAGE_RETURN_SUCCESS)
{
stun_debug ("STUN Role Conflict detected:\n");
stun_debug ("STUN Role Conflict detected:");
if (tie < q)
{
stun_debug (" switching role from \"controll%s\" to \"controll%s\"\n",
stun_debug (" switching role from \"controll%s\" to \"controll%s\"",
*control ? "ing" : "ed", *control ? "ed" : "ing");
*control = !*control;
ret = STUN_USAGE_ICE_RETURN_ROLE_CONFLICT;
}
else
{
stun_debug (" staying \"controll%s\" (sending error)\n",
stun_debug (" staying \"controll%s\" (sending error)",
*control ? "ing" : "ed");
err (STUN_ERROR_ROLE_CONFLICT);
return STUN_USAGE_ICE_RETURN_SUCCESS;
}
} else {
stun_debug ("STUN Role not specified by peer!\n");
stun_debug ("STUN Role not specified by peer!");
}
if (stun_agent_init_response (agent, msg, buf, len, req) == FALSE) {
stun_debug ("Unable to create response\n");
stun_debug ("Unable to create response");
goto failure;
}
if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_MSN) {
......@@ -309,7 +309,7 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
}
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" Mapped address problem: %d\n", val);
stun_debug (" Mapped address problem: %d", val);
goto failure;
}
......@@ -321,7 +321,7 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
}
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug ("Error appending username: %d\n", val);
stun_debug ("Error appending username: %d", val);
goto failure;
}
......@@ -333,12 +333,12 @@ stun_usage_ice_conncheck_create_reply (StunAgent *agent, StunMessage *req,
goto failure;
*plen = len;
stun_debug (" All done (response size: %u)\n", (unsigned)len);
stun_debug (" All done (response size: %u)", (unsigned)len);
return ret;
failure:
assert (*plen == 0);
stun_debug (" Fatal error formatting Response: %d\n", val);
stun_debug (" Fatal error formatting Response: %d", val);
switch (val)
{
......
......@@ -291,7 +291,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
/* NOTE: currently we ignore unauthenticated messages if the context
* is authenticated, for security reasons. */
stun_debug (" STUN error message received (code: %d)\n", code);
stun_debug (" STUN error message received (code: %d)", code);
/* ALTERNATE-SERVER mechanism */
if ((code / 100) == 3) {
......@@ -299,18 +299,18 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
if (stun_message_find_addr (msg, STUN_ATTRIBUTE_ALTERNATE_SERVER,
alternate_server, alternate_server_len) !=
STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute\n");
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute");
return STUN_USAGE_TURN_RETURN_ERROR;
}
} else {
if (!stun_message_has_attribute (msg,
STUN_ATTRIBUTE_ALTERNATE_SERVER)) {
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute\n");
stun_debug (" Unexpectedly missing ALTERNATE-SERVER attribute");
return STUN_USAGE_TURN_RETURN_ERROR;
}
}
stun_debug ("Found alternate server\n");
stun_debug ("Found alternate server");
return STUN_USAGE_TURN_RETURN_ALTERNATE_SERVER;
}
......@@ -321,7 +321,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
break;
}
stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg));
stun_debug ("Received %u-bytes STUN message", stun_message_length (msg));
if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 ||
compatibility == STUN_USAGE_TURN_COMPATIBILITY_RFC5766) {
......@@ -333,14 +333,14 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
val = stun_message_find_xor_addr (msg,
STUN_ATTRIBUTE_RELAY_ADDRESS, relay_addr, relay_addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" No RELAYED-ADDRESS: %d\n", val);
stun_debug (" No RELAYED-ADDRESS: %d", val);
return STUN_USAGE_TURN_RETURN_ERROR;
}
} else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_GOOGLE) {
val = stun_message_find_addr (msg,
STUN_ATTRIBUTE_MAPPED_ADDRESS, relay_addr, relay_addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" No MAPPED-ADDRESS: %d\n", val);
stun_debug (" No MAPPED-ADDRESS: %d", val);
return STUN_USAGE_TURN_RETURN_ERROR;
}
} else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_MSN) {
......@@ -353,7 +353,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
val = stun_message_find_addr (msg,
STUN_ATTRIBUTE_MAPPED_ADDRESS, relay_addr, relay_addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" No MAPPED-ADDRESS: %d\n", val);
stun_debug (" No MAPPED-ADDRESS: %d", val);
return STUN_USAGE_TURN_RETURN_ERROR;
}
} else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_OC2007) {
......@@ -376,7 +376,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
val = stun_message_find_addr (msg,
STUN_ATTRIBUTE_MAPPED_ADDRESS, relay_addr, relay_addrlen);
if (val != STUN_MESSAGE_RETURN_SUCCESS) {
stun_debug (" No MAPPED-ADDRESS: %d\n", val);
stun_debug (" No MAPPED-ADDRESS: %d", val);
return STUN_USAGE_TURN_RETURN_ERROR;
}
}
......@@ -384,7 +384,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg,
stun_message_find32 (msg, STUN_ATTRIBUTE_LIFETIME, lifetime);
stun_message_find32 (msg, STUN_ATTRIBUTE_BANDWIDTH, bandwidth);
stun_debug (" Mapped address found!\n");
stun_debug (" Mapped address found!");
return ret;
}
......@@ -430,7 +430,7 @@ StunUsageTurnReturn stun_usage_turn_refresh_process (StunMessage *msg,
stun_message_find32 (msg, STUN_ATTRIBUTE_LIFETIME, lifetime);
stun_debug ("TURN Refresh successful!\n");
stun_debug ("TURN Refresh successful!");
return ret;
}
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