From 888f998c8dc2f7d25a65e7e491eed30135e346b5 Mon Sep 17 00:00:00 2001 From: Thomas Ries Date: Wed, 28 Dec 2005 19:01:59 +0000 Subject: [PATCH] - Call logging: display FROM & TO for calls. --- ChangeLog | 1 + src/proxy.c | 65 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52c4f3f..6070c79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.5.12 ====== + 28-Dec-2005: - Call logging: display FROM & TO for calls. 26-Dec-2005: - Added a short-dial feature ("pi_shortdial_*" config options) 18-Dec-2005: - Grandstream "unregister at startup" works now 9-Oct-2005: - Expiration timeout is now taken from the REGISTER response diff --git a/src/proxy.c b/src/proxy.c index c38b19f..f3c67c4 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -111,38 +111,47 @@ int proxy_request (sip_ticket_t *ticket) { * logging of passing calls */ if (configuration.log_calls) { - osip_uri_t *cont_url = NULL; - if (!osip_list_eol(request->contacts, 0)) - cont_url = ((osip_contact_t*)(request->contacts->node->element))->url; - + osip_uri_t *from_url = NULL; + osip_uri_t *to_url = NULL; + char *to_username =NULL; + char *to_host = NULL; + char *from_username =NULL; + char *from_host = NULL; + + /* From: 1st preference is contact header, then use From field */ + if (!osip_list_eol(request->contacts, 0)) { + from_url = ((osip_contact_t*)(request->contacts->node->element))->url; + } else { + from_url = request->from->url; + } + + to_url = request->to->url; + + if (to_url) { + to_username = to_url->username; + to_host = to_url->host; + } + + if (from_url) { + from_username = from_url->username; + from_host = from_url->host; + } + /* INVITE */ if (MSG_IS_INVITE(request)) { - if (cont_url) { - INFO("%s Call from: %s@%s", - (type==REQTYP_INCOMING) ? "Incoming":"Outgoing", - cont_url->username ? cont_url->username:"*NULL*", - cont_url->host ? cont_url->host : "*NULL*"); - } else { - INFO("%s Call (w/o contact header) from: %s@%s", - (type==REQTYP_INCOMING) ? "Incoming":"Outgoing", - request->from->url->username ? - request->from->url->username:"*NULL*", - request->from->url->host ? - request->from->url->host : "*NULL*"); - } + INFO("%s Call: %s@%s -> %s@%s", + (type==REQTYP_INCOMING) ? "Incoming":"Outgoing", + from_username ? from_username: "*NULL*", + from_host ? from_host : "*NULL*", + to_username ? to_username : "*NULL*", + to_host ? to_host : "*NULL*"); /* BYE / CANCEL */ } else if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) { - if (cont_url) { - INFO("Ending Call from: %s@%s", - cont_url->username ? cont_url->username:"*NULL*", - cont_url->host ? cont_url->host : "*NULL*"); - } else { - INFO("Ending Call (w/o contact header) from: %s@%s", - request->from->url->username ? - request->from->url->username:"*NULL*", - request->from->url->host ? - request->from->url->host : "*NULL*"); - } + INFO("Ending Call: %s@%s -> %s@%s", + from_username ? from_username: "*NULL*", + from_host ? from_host : "*NULL*", + to_username ? to_username : "*NULL*", + to_host ? to_host : "*NULL*"); } } /* log_calls */