From 306c52ece5ba5fb69953854df18b71bc3c7ee2e3 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Fri, 15 Jan 2010 15:18:07 +0000 Subject: [PATCH] MODENDP-281 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16319 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia_reg.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index e8f4f4fe75..4c370b84e6 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -93,11 +93,17 @@ static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr) } -static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway) { +static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase) { switch_event_t *s_event; if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_STATE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Gateway", gateway->name); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "State", sofia_state_string(gateway->state)); + if (!zstr(phrase)) { + switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Phrase", phrase); + } + if (status) { + switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Status", "%d", status); + } switch_event_fire(&s_event); } } @@ -398,7 +404,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) break; } if (ostate != gateway_ptr->state) { - sofia_reg_fire_custom_gateway_state_event(gateway_ptr); + sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL); } } } @@ -1477,7 +1483,7 @@ void sofia_reg_handle_sip_r_register(int status, break; } if (ostate != sofia_private->gateway->state) { - sofia_reg_fire_custom_gateway_state_event(sofia_private->gateway); + sofia_reg_fire_custom_gateway_state_event(sofia_private->gateway, status, phrase); } } } @@ -2169,7 +2175,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, gateway_ptr->state = REG_STATE_UNREGISTER; } if (ostate != gateway_ptr->state) { - sofia_reg_fire_custom_gateway_state_event(gateway_ptr); + sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL); } sofia_reg_release_gateway(gateway_ptr); } @@ -2195,7 +2201,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, gateway_ptr->state = REG_STATE_UNREGISTER; } if (ostate != gateway_ptr->state) { - sofia_reg_fire_custom_gateway_state_event(gateway_ptr); + sofia_reg_fire_custom_gateway_state_event(gateway_ptr, 0, NULL); } sofia_reg_release_gateway(gateway_ptr); } else {