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:
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);