From e40e8696fc61d9a623d4433ed619aa74c9b73b45 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 31 Jul 2012 14:01:56 -0500 Subject: [PATCH] update 4579 stuff --- src/mod/endpoints/mod_sofia/sofia.c | 50 ++++++++++++++++++----------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 3ded1dccd2..6c7c0382b3 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1216,38 +1216,49 @@ static void our_sofia_event_callback(nua_event_t event, char *refer_to = NULL, *referred_by = NULL, *method = NULL, *full_url = NULL; char *params = NULL; switch_event_t *event; + char *tmp; if (sip->sip_refer_to) { ref_to_user = sip->sip_refer_to->r_url->url_user; ref_to_host = sip->sip_refer_to->r_url->url_host; - refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to); - if ((params = strchr(refer_to, ';'))) { - if (strchr(refer_to, '<')) { - *params++ = '>'; - } else { + if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) { + + if ((params = strrchr(refer_to, ';'))) { *params++ = '\0'; } - - if (!(method = switch_find_parameter(params, "method", NULL))) { - method = strdup("INVITE"); - } - full_url = switch_find_parameter(params, "full_url", NULL); - - if (!strcasecmp(method, "INVITE")) { - action = "call"; - } else if (!strcasecmp(method, "BYE")) { - action = "end"; - } else { - action = method; + if ((tmp = sofia_glue_get_url_from_contact(refer_to, 0))) { + refer_to = tmp; } } - refer_to = sofia_glue_get_url_from_contact(refer_to, 0); - + if (!params || !switch_stristr("method=", params)) { + if ((params = strchr(refer_to, ';'))) { + *params++ = '\0'; + } + } + + if (params) { + method = switch_find_parameter(params, "method", NULL); + full_url = switch_find_parameter(params, "full_url", NULL); + } + + } + if (!method) { + method = strdup("INVITE"); + } + + if (!strcasecmp(method, "INVITE")) { + action = "call"; + } else if (!strcasecmp(method, "BYE")) { + action = "end"; + } else { + action = method; + } + if (sip->sip_referred_by) { referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_referred_by), 0); ref_by_user = sip->sip_referred_by->b_url->url_user; @@ -1278,6 +1289,7 @@ static void our_sofia_event_callback(nua_event_t event, switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_number", ref_by_user); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "var_origination_caller_id_name", ref_by_user); + DUMP_EVENT(event); switch_event_fire(&event); }