From: Moises Silva Date: Sat, 17 Dec 2011 22:42:34 +0000 (-0500) Subject: Merge branch 'smgmaster' into releases.3.4.experimental_head X-Git-Tag: v1.2.3^2~71^2^2~217^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bd2d154d69702bed42d85ea5465c2c07f5fd287;p=thirdparty%2Ffreeswitch.git Merge branch 'smgmaster' into releases.3.4.experimental_head Conflicts: libs/freetdm/mod_freetdm/mod_freetdm.c libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c src/mod/endpoints/mod_sofia/mod_sofia.c src/mod/endpoints/mod_sofia/sofia_glue.c --- 7bd2d154d69702bed42d85ea5465c2c07f5fd287 diff --cc libs/freetdm/mod_freetdm/mod_freetdm.c index 003be91b17,0fc7906331..ab4639485a --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@@ -511,45 -519,64 +519,92 @@@ static switch_status_t channel_on_hangu tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); - /* ignore any further I/O requests, we're hanging up already! */ - switch_clear_flag_locked(tech_pvt, TFLAG_IO); + /* ignore any further I/O requests, we're hanging up already! */ + switch_clear_flag_locked(tech_pvt, TFLAG_IO); + + name = switch_channel_get_name(channel); + + span_id = tech_pvt->ftdmchan ? ftdm_channel_get_span_id(tech_pvt->ftdmchan) : 0; + chan_id = tech_pvt->ftdmchan ? ftdm_channel_get_id(tech_pvt->ftdmchan) : 0; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d] %s CHANNEL HANGUP ENTER\n", span_id, chan_id, name); + /* First verify this call has a device attached */ if (!tech_pvt->ftdmchan) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s does not have any ftdmchan attached\n", name); goto end; - } + } + + /* Now verify the device is still attached to this call :-) + * Sometimes the FS core takes too long (more than 3 seconds) in calling + * channel_on_hangup() and the FreeTDM core decides to take the brute + * force approach and hangup and detach themselves from the call. Later + * when FS finally comes around, we might end up hanging up the device + * attached to another call, this verification avoids that. */ + uuid = switch_core_session_get_uuid(session); + tokencnt = ftdm_channel_get_token_count(tech_pvt->ftdmchan); + for (t = 0; t < tokencnt; t++) { + token = ftdm_channel_get_token(tech_pvt->ftdmchan, t); + if (!zstr(token) && !strcasecmp(uuid, token)) { + uuid_found = 1; + break; + } + } + + if (!uuid_found) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Device [%d:%d] is no longer attached to %s. Nothing to do.\n", span_id, chan_id, name); + goto end; + } + + #ifdef CUDATEL_DEBUG + { + pid_t tid = 0; + size_t size = 0; + char **symbols = NULL; + void *stacktrace[50]; + int si = 0; + size = backtrace(stacktrace, ftdm_array_len(stacktrace)); + symbols = backtrace_symbols(stacktrace, size); + tid = syscall(SYS_gettid); + for (si = 0; si < size; si++) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n", + span_id, chan_id, tid, name, symbols[si]); + } + free(symbols); + } + #endif + name = switch_channel_get_name(channel); + + span_id = tech_pvt->ftdmchan ? ftdm_channel_get_span_id(tech_pvt->ftdmchan) : 0; + chan_id = tech_pvt->ftdmchan ? ftdm_channel_get_id(tech_pvt->ftdmchan) : 0; + + + /* Now verify the device is still attached to this call :-) + * Sometimes the FS core takes too long (more than 3 seconds) in calling + * channel_on_hangup() and the FreeTDM core decides to take the brute + * force approach and hangup and detach themselves from the call. Later + * when FS finally comes around, we might end up hanging up the device + * attached to another call, this verification avoids that. */ + uuid = switch_core_session_get_uuid(session); + tokencnt = ftdm_channel_get_token_count(tech_pvt->ftdmchan); + for (t = 0; t < tokencnt; t++) { + token = ftdm_channel_get_token(tech_pvt->ftdmchan, t); + if (!zstr(token) && !strcasecmp(uuid, token)) { + uuid_found = 1; + break; + } + } + + if (!uuid_found) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Device [%d:%d] is no longer attached to %s. Nothing to do.\n", span_id, chan_id, name); + goto end; + } + + ftdm_channel_clear_token(tech_pvt->ftdmchan, switch_core_session_get_uuid(session)); - chantype = ftdm_channel_get_type(tech_pvt->ftdmchan); + chantype = ftdm_channel_get_type(tech_pvt->ftdmchan); switch (chantype) { case FTDM_CHAN_TYPE_FXO: case FTDM_CHAN_TYPE_EM: diff --cc libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c index 0497955059,dab2035450..b8154f96e8 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c @@@ -221,34 -213,37 +221,62 @@@ ftdm_status_t handle_con_ind(uint32_t s sprintf(var, "%d", siConEvnt->cgPtyNum.natAddrInd.val); sngss7_add_var(sngss7_info, "ss7_clg_nadi", var); - sprintf(var, "%d", siConEvnt->cdPtyNum.natAddrInd.val); - sngss7_add_var(sngss7_info, "ss7_cld_nadi", var); + /* Retrieve the Location Number if present (see ITU Q.763, 3.30) */ + if (siConEvnt->cgPtyNum1.eh.pres) { + if (siConEvnt->cgPtyNum1.addrSig.pres) { + /* fill in the ss7 location address number */ + copy_tknStr_from_sngss7(siConEvnt->cgPtyNum1.addrSig, var, siConEvnt->cgPtyNum1.oddEven); + sngss7_add_var(sngss7_info, "ss7_loc_digits", var); + } + + if (siConEvnt->cgPtyNum1.scrnInd.pres) { + /* fill in the screening indication value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.scrnInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_screen_ind", var); + } + + if (siConEvnt->cgPtyNum1.presRest.pres) { + /* fill in the presentation value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.presRest.val); + sngss7_add_var(sngss7_info, "ss7_loc_pres_ind", var); + } + + if (siConEvnt->cgPtyNum1.natAddrInd.pres) { + sprintf(var, "%d", siConEvnt->cgPtyNum1.natAddrInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_nadi", var); + } + } else { + SS7_DEBUG_CHAN(ftdmchan, "No Location Number information in IAM%s\n", " "); + } + /* Retrieve the Location Number if present (see ITU Q.763, 3.30) */ + if (siConEvnt->cgPtyNum1.eh.pres) { + if (siConEvnt->cgPtyNum1.addrSig.pres) { + /* fill in the ss7 location address number */ + copy_tknStr_from_sngss7(siConEvnt->cgPtyNum1.addrSig, var, siConEvnt->cgPtyNum1.oddEven); + sngss7_add_var(sngss7_info, "ss7_loc_digits", var); + } + + if (siConEvnt->cgPtyNum1.scrnInd.pres) { + /* fill in the screening indication value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.scrnInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_screen_ind", var); + } + + if (siConEvnt->cgPtyNum1.presRest.pres) { + /* fill in the presentation value */ + sprintf(var, "%d", siConEvnt->cgPtyNum1.presRest.val); + sngss7_add_var(sngss7_info, "ss7_loc_pres_ind", var); + } + + if (siConEvnt->cgPtyNum1.natAddrInd.pres) { + sprintf(var, "%d", siConEvnt->cgPtyNum1.natAddrInd.val); + sngss7_add_var(sngss7_info, "ss7_loc_nadi", var); + } + } else { + SS7_DEBUG_CHAN(ftdmchan, "No Location Number information in IAM%s\n", " "); + } + sprintf(var, "%d", sngss7_info->circuit->cic); sngss7_add_var(sngss7_info, "ss7_cic", var);