-Tue Oct 23 13:13:35 EDT 2012
+Fri Oct 26 14:14:41 CDT 2012
auth_challenge_digest(am, as, ach);
as->as_blacklist = am->am_blacklist;
}
- SU_DEBUG_5(("auth_method_digest: response did not match\n"));
+ SU_DEBUG_5(("auth_method_digest: response did not match\n" VA_NONE));
return;
}
if (am->am_challenge)
auth_challenge_digest(am, as, ach);
- SU_DEBUG_7(("auth_method_digest: successful authentication\n"));
+ SU_DEBUG_7(("auth_method_digest: successful authentication\n" VA_NONE));
as->as_status = 0; /* Successful authentication! */
as->as_phrase = "";
/* Check nonce */
if (!ar->ar_nonce) {
- SU_DEBUG_5(("auth_method_digest: no nonce\n"));
+ SU_DEBUG_5(("auth_method_digest: no nonce\n" VA_NONE));
return -1;
}
if (base64_d((void*)nonce, (sizeof nonce), ar->ar_nonce) != (sizeof nonce)) {
- SU_DEBUG_5(("auth_method_digest: too short nonce\n"));
+ SU_DEBUG_5(("auth_method_digest: too short nonce\n" VA_NONE));
return -1;
}
auth_md5_hmac_digest(am, md5, hmac, sizeof hmac);
if (memcmp(nonce->digest, hmac, sizeof nonce->digest)) {
- SU_DEBUG_5(("auth_method_digest: bad nonce\n"));
+ SU_DEBUG_5(("auth_method_digest: bad nonce\n" VA_NONE));
return -1;
}
throttle = min_throttle;
if (!url) {
- SU_DEBUG_5(("nea_server_create(): invalid url\n"));
+ SU_DEBUG_5(("nea_server_create(): invalid url\n" VA_NONE));
return NULL;
}
if (min_expires > expires || expires > max_expires) {
- SU_DEBUG_5(("nea_server_create(): invalid expiration range\n"));
+ SU_DEBUG_5(("nea_server_create(): invalid expiration range\n" VA_NONE));
return NULL;
}
if (next == latest) {
/* Do not set timer? */
- SU_DEBUG_9(("nta: timer not set\n"));
+ SU_DEBUG_9(("nta: timer not set\n" VA_NONE));
assert(!agent->sa_out.completed->q_head);
assert(!agent->sa_out.trying->q_head);
assert(!agent->sa_out.inv_calling->q_head);
if (url_string_p(uri))
SU_DEBUG_1(("nta: %s: invalid bind URL\n", uri->us_str));
else
- SU_DEBUG_1(("nta: invalid bind URL\n"));
+ SU_DEBUG_1(("nta: invalid bind URL\n" VA_NONE));
su_seterrno(EINVAL);
return -1;
}
/* XXX - when to use maddr? */
if ((agent_init_via(self, tport_primaries(self->sa_tports), 0)) < 0) {
error = su_errno();
- SU_DEBUG_1(("nta: cannot create Via headers\n"));
+ SU_DEBUG_1(("nta: cannot create Via headers\n" VA_NONE));
goto error;
}
else
- SU_DEBUG_9(("nta: Via fields initialized\n"));
+ SU_DEBUG_9(("nta: Via fields initialized\n" VA_NONE));
if ((agent_init_contact(self)) < 0) {
error = su_errno();
- SU_DEBUG_1(("nta: cannot create Contact header\n"));
+ SU_DEBUG_1(("nta: cannot create Contact header\n" VA_NONE));
goto error;
}
else
- SU_DEBUG_9(("nta: Contact header created\n"));
+ SU_DEBUG_9(("nta: Contact header created\n" VA_NONE));
su_free(self->sa_home, url);
ta_end(ta);
if (!self->sa_tports)
return -1;
- SU_DEBUG_9(("nta: master transport created\n"));
+ SU_DEBUG_9(("nta: master transport created\n" VA_NONE));
return 0;
}
home = msg_home(msg);
if (!sip->sip_request || sip_complete_message(msg) < 0) {
- SU_DEBUG_3(("nta: outgoing_create: incomplete request\n"));
+ SU_DEBUG_3(("nta: outgoing_create: incomplete request\n" VA_NONE));
return NULL;
}
}
}
else {
- SU_DEBUG_1(("outgoing_create: ACK without INVITE\n"));
+ SU_DEBUG_1(("outgoing_create: ACK without INVITE\n" VA_NONE));
assert(!"INVITE found for ACK");
}
}
outgoing_send_via(orq, tp);
}
else if (orq->orq_sips) {
- SU_DEBUG_3(("nta outgoing create: no secure transport\n"));
+ SU_DEBUG_3(("nta outgoing create: no secure transport\n" VA_NONE));
outgoing_reply(orq, SIP_416_UNSUPPORTED_URI, 1);
}
else {
- SU_DEBUG_3(("nta outgoing create: no transport protocol\n"));
+ SU_DEBUG_3(("nta outgoing create: no transport protocol\n" VA_NONE));
outgoing_reply(orq, 503, "No transport", 1);
}
}
if (old_tp) tport_unref(old_tp);
if (outgoing_insert_via(orq, agent_tport_via(tp)) < 0) {
- SU_DEBUG_3(("nta outgoing create: cannot insert Via line\n"));
+ SU_DEBUG_3(("nta outgoing create: cannot insert Via line\n" VA_NONE));
outgoing_reply(orq, 503, "Cannot insert Via", 1);
return;
}
if (orq->orq_destroyed && 200 <= status && status < 300) {
if (orq->orq_uas && su_strcasecmp(sip->sip_to->a_tag, orq->orq_tag) != 0) {
/* Orphan 200 Ok to INVITE. ACK and BYE it */
- SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE\n"));
+ SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE\n" VA_NONE));
return nta_msg_ackbye(sa, msg);
}
return -1; /* Proxy statelessly (RFC3261 section 16.11) */
return outgoing_duplicate(orq, msg, sip);
/* Orphan 200 Ok to INVITE. ACK and BYE it */
- SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE"));
+ SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE" VA_NONE));
return nta_msg_ackbye(sa, msg);
}
}
if (msg_serialize(msg, http) < 0) {
assert(hc->hc_tport);
- SU_DEBUG_3(("nth client create: invalid message"));
+ SU_DEBUG_3(("nth client create: invalid message" VA_NONE));
return -1;
}
is_path = url->url_path != NULL;
if (is_host && is_path) {
- SU_DEBUG_3(("nth_site_create(): virtual host and path simultanously\n"));
+ SU_DEBUG_3(("nth_site_create(): virtual host and path simultanously\n" VA_NONE));
errno = EINVAL;
goto error;
}
if (!parent && !is_host) {
- SU_DEBUG_3(("nth_site_create(): host is required\n"));
+ SU_DEBUG_3(("nth_site_create(): host is required\n" VA_NONE));
errno = EINVAL;
goto error;
}
if (parent) {
if (!parent->site_isdir) {
- SU_DEBUG_3(("nth_site_create(): invalid parent resource \n"));
+ SU_DEBUG_3(("nth_site_create(): invalid parent resource \n" VA_NONE));
errno = EINVAL;
goto error;
}
if (tport_tqsend(tport, response, NULL,
TPTAG_CLOSE_AFTER(close),
TAG_END()) == -1) {
- SU_DEBUG_3(("server_reply(): cannot queue response\n"));
+ SU_DEBUG_3(("server_reply(): cannot queue response\n" VA_NONE));
tport_shutdown(tport, 2);
}
if (tport && tport != nr->nr_tport) {
if (nr->nr_error_report_id) {
if (tport_release(nr->nr_tport, nr->nr_error_report_id, NULL, NULL, nr, 0) < 0)
- SU_DEBUG_1(("nua_register: tport_release() failed\n"));
+ SU_DEBUG_1(("nua_register: tport_release() failed\n" VA_NONE));
nr->nr_error_report_id = 0;
}
tport_unref(nr->nr_tport);
if (nr->nr_tport) {
if (nr->nr_error_report_id) {
if (tport_release(nr->nr_tport, nr->nr_error_report_id, NULL, NULL, nr, 0) < 0)
- SU_DEBUG_1(("nua_register: tport_release() failed\n"));
+ SU_DEBUG_1(("nua_register: tport_release() failed\n" VA_NONE));
nr->nr_error_report_id = 0;
}
pending = nr->nr_error_report_id;
if (tport_release(tport, pending, NULL, NULL, nr, 0) < 0)
- SU_DEBUG_1(("nua_register: tport_release() failed\n"));
+ SU_DEBUG_1(("nua_register: tport_release() failed\n" VA_NONE));
nr->nr_error_report_id = 0;
tpn = tport_name(nr->nr_tport);
ref->ref_event = sip_event_dup(nh->nh_home, event);
if (!nh_validate(nh->nh_nua, ref_handle)) {
- SU_DEBUG_3(("nua: invalid NOTIFY_REFER handle\n"));
+ SU_DEBUG_3(("nua: invalid NOTIFY_REFER handle\n" VA_NONE));
return -1;
}
else if (!ref->ref_event) {
- SU_DEBUG_3(("nua: NOTIFY event missing\n"));
+ SU_DEBUG_3(("nua: NOTIFY event missing\n" VA_NONE));
return -1;
}
dnh->nh_ds->ds_leg == NULL ||
nta_agent_set_params(nua->nua_nta, NTATAG_UA(1), TAG_END()) < 0 ||
nua_stack_init_transport(nua, nua->nua_args) < 0) {
- SU_DEBUG_1(("nua: initializing SIP stack failed\n"));
+ SU_DEBUG_1(("nua: initializing SIP stack failed\n" VA_NONE));
return -1;
}
m->m_offset = sizeof(m->m_packet.mp_header);
if (m->m_size < m->m_offset) {
- SU_DEBUG_5(("sres_decode_msg: truncated message\n"));
+ SU_DEBUG_5(("sres_decode_msg: truncated message\n" VA_NONE));
return -1;
}
srs->srs_timer = t;
if (!srs->srs_timer)
- SU_DEBUG_3(("sres: cannot create timer\n"));
+ SU_DEBUG_3(("sres: cannot create timer\n" VA_NONE));
#if nomore
else if (su_timer_set_for_ever(t, sres_sofia_timer, srs) < 0)
- SU_DEBUG_3(("sres: cannot set timer\n"));
+ SU_DEBUG_3(("sres: cannot set timer\n" VA_NONE));
#else
else if (sres_resolver_set_timer_cb(res, sres_sofia_set_timer, srs) < 0)
- SU_DEBUG_3(("sres: cannot set timer cb\n"));
+ SU_DEBUG_3(("sres: cannot set timer cb\n" VA_NONE));
#endif
else
return res; /* Success! */
SOFIAPUBVAR su_log_t SU_LOG[];
#endif
+#define VA_NONE "%s",""
+
#define SU_DEBUG_DEF(level) \
su_inline void su_debug_##level(char const *fmt, ...) \
__attribute__ ((__format__ (printf, 1, 2))); \
su_inline void su_debug_##level(char const *fmt, ...) \
- { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
+ { va_list ap; va_start(ap, fmt); su_vllog(SU_LOG, level, fmt, ap); va_end(ap); }
+
+//SU_DEBUG_DEF(0)
+#define su_debug_0(_f, ...) su_llog(SU_LOG, 0, _f, __VA_ARGS__)
-SU_DEBUG_DEF(0)
/** Log messages at level 0.
*
* Fatal errors and panic messages should be logged at level 0.
#endif
#if SU_DEBUG_MAX >= 1
-SU_DEBUG_DEF(1)
+//SU_DEBUG_DEF(1)
+#define su_debug_1(_f, ...) su_llog(SU_LOG, 1, _f, __VA_ARGS__)
+
+
/**Log messages at level 1.
*
* Critical errors and minimal progress at subsystem level should be logged
#endif
#if SU_DEBUG_MAX >= 2
-SU_DEBUG_DEF(2)
+//SU_DEBUG_DEF(2)
+#define su_debug_2(_f, ...) su_llog(SU_LOG, 2, _f, __VA_ARGS__)
/**Log messages at level 2.
*
* Non-critical errors should be logged at level 2.
#endif
#if SU_DEBUG_MAX >= 3
-SU_DEBUG_DEF(3)
+//SU_DEBUG_DEF(3)
+#define su_debug_3(_f, ...) su_llog(SU_LOG, 3, _f, __VA_ARGS__)
/** Log messages at level 3.
*
* Warnings and progress messages should be logged at level 3.
#endif
#if SU_DEBUG_MAX >= 4
-SU_DEBUG_DEF(4)
+//SU_DEBUG_DEF(4)
+#define su_debug_4(_f, ...) su_llog(SU_LOG, 4, _f, __VA_ARGS__)
/** Log messages at level 4. */
#define SU_DEBUG_4(x) (SU_LOG_LEVEL >= 4 ? (su_debug_4 x) : (void)0)
#else
#endif
#if SU_DEBUG_MAX >= 5
-SU_DEBUG_DEF(5)
+//SU_DEBUG_DEF(5)
+#define su_debug_5(_f, ...) su_llog(SU_LOG, 5, _f, __VA_ARGS__)
/** Log messages at level 5.
*
* Signaling protocol actions (incoming packets, etc.) should be logged
#endif
#if SU_DEBUG_MAX >= 6
-SU_DEBUG_DEF(6)
+//SU_DEBUG_DEF(6)
+#define su_debug_6(_f, ...) su_llog(SU_LOG, 6, _f, __VA_ARGS__)
/** Log messages at level 6. */
#define SU_DEBUG_6(x) (SU_LOG_LEVEL >= 6 ? (su_debug_6 x) : (void)0)
#else
#endif
#if SU_DEBUG_MAX >= 7
-SU_DEBUG_DEF(7)
+//SU_DEBUG_DEF(7)
+#define su_debug_7(_f, ...) su_llog(SU_LOG, 7, _f, __VA_ARGS__)
/** Log messages at level 7.
*
* Media protocol actions (incoming packets, etc) should be logged at level 7.
#endif
#if SU_DEBUG_MAX >= 8
-SU_DEBUG_DEF(8)
+//SU_DEBUG_DEF(8)
+#define su_debug_8(_f, ...) su_llog(SU_LOG, 8, _f, __VA_ARGS__)
/** Log messages at level 8. */
#define SU_DEBUG_8(x) (SU_LOG_LEVEL >= 8 ? (su_debug_8 x) : (void)0)
#else
#endif
#if SU_DEBUG_MAX >= 9
-SU_DEBUG_DEF(9)
+//SU_DEBUG_DEF(9)
+#define su_debug_9(_f, ...) su_llog(SU_LOG, 9, _f, __VA_ARGS__)
/** Log messages at level 9.
*
* Entering/exiting functions, very verbatim progress should be logged at
SOFIA_BEGIN_DECLS
+#ifdef _MSC_VER
+#define __SOFIA_FUNC__ __FUNCTION__
+#else
+#define __SOFIA_FUNC__ (const char *)__func__
+#endif
+
+
+
+
/** Prototype for logging function */
typedef void (su_logger_f)(void *stream, char const *fmt, va_list ap);
SOFIAPUBFUN void su_log(char const *fmt, ...)
__attribute__ ((__format__ (printf, 1, 2)));
-SOFIAPUBFUN void su_llog(su_log_t *log, unsigned level, char const *fmt, ...)
- __attribute__ ((__format__ (printf, 3, 4)));
-SOFIAPUBFUN void su_vllog(su_log_t *log, unsigned level,
+SOFIAPUBFUN void _su_llog(su_log_t *log, unsigned level, const char *file, const char *func, int line, char const *fmt, ...)
+ __attribute__ ((__format__ (printf, 6, 7)));
+SOFIAPUBFUN void _su_vllog(su_log_t *log, unsigned level, const char *file, const char *func, int line,
char const *fmt, va_list ap);
SOFIAPUBFUN void su_log_redirect(su_log_t *log, su_logger_f *f, void *stream);
SOFIAPUBFUN void su_log_set_level(su_log_t *log, unsigned level);
/** Log the latest su error message */
SOFIAPUBFUN void su_perror(char const *s);
+#define su_llog(_l, _ll, _f, ...) _su_llog(_l, _ll, __FILE__, __SOFIA_FUNC__, __LINE__, _f, __VA_ARGS__)
+#define su_vllog(_l, _ll, _f, ...) _su_vllog(_l, _ll, __FILE__, __SOFIA_FUNC__, __LINE__, _f, __VA_ARGS__)
+
/** Log the su error message. */
SOFIAPUBFUN void su_perror2(char const *s, int errcode);
flags |= LI_NUMERIC;
if (!(li = calloc(1, sizeof(*li) + sulen + ifnamelen))) {
- SU_DEBUG_1(("su_getlocalinfo: memory exhausted\n"));
+ SU_DEBUG_1(("su_getlocalinfo: memory exhausted\n" VA_NONE));
error = ELI_MEMORY;
break;
}
if (error) {
if ((flags & LI_NAMEREQD) == LI_NAMEREQD)
return 1;
- SU_DEBUG_7(("li_name: getnameinfo() failed\n"));
+ SU_DEBUG_7(("li_name: getnameinfo() failed\n" VA_NONE));
if (!su_inet_ntop(su->su_family, SU_ADDR(su), name, sizeof name))
return ELI_RESOLVER;
}
*
* @note This function is used mainly by SU_DEBUG_n() macros.
*/
-void su_llog(su_log_t *log, unsigned level, char const *fmt, ...)
+void _su_llog(su_log_t *log, unsigned level, const char *file, const char *func, int line,
+ char const *fmt, ...)
{
va_list ap;
-
+ char buf[512];
va_start(ap, fmt);
- su_vllog(log, level, fmt, ap);
+
+
+ snprintf(buf, sizeof(buf), "%s:%d %s() %s", file, line, func, fmt);
+
+ _su_vllog(log, level, file, func, line, buf, ap);
va_end(ap);
}
/** Log a message with level (stdarg version). */
-void su_vllog(su_log_t *log, unsigned level, char const *fmt, va_list ap)
+void _su_vllog(su_log_t *log, unsigned level, const char *file, const char *func, int line,
+ char const *fmt, va_list ap)
{
su_logger_f *logger;
void *stream;
stream = su_log_default->log_stream;
}
- if (logger)
- logger(stream, fmt, ap);
+ if (logger) {
+ logger(stream, fmt, ap);
+ }
}
static char const not_initialized[1];
if (!self) {
msg_set_errno(msg, su_errno());
- SU_DEBUG_9(("tport_socket failed in tsend\n"));
+ SU_DEBUG_9(("tport_socket failed in tsend\n" VA_NONE));
return NULL;
}
/* ...or we are connecting */
(self->tp_events & (SU_WAIT_CONNECT | SU_WAIT_OUT))) {
if (tport_queue(self, msg) < 0) {
- SU_DEBUG_9(("tport_queue failed in tsend\n"));
+ SU_DEBUG_9(("tport_queue failed in tsend\n" VA_NONE));
return -1;
}
return 0;
msg_set_next(response, thci->thci_stackmsg = tport_msg_alloc(tport, 512));
if (tport_send_msg(tport, msg, tpn, NULL) < 0) {
- SU_DEBUG_9(("tport_send_msg failed in tpot_http_connect\n"));
+ SU_DEBUG_9(("tport_send_msg failed in tpot_http_connect\n" VA_NONE));
msg_destroy(msg);
tport_zap_secondary(tport);
return NULL;