From a6e868f588572034dbf41866432138aa54a10aa4 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Thu, 16 Feb 2012 14:49:18 -0500 Subject: [PATCH 01/26] freetdm: Fix spirou certification native bridge issue - The outgoing tdm leg should not move to UP until after the IAM is sent at the end of the function - The UP state should be processed immediately otherwise the state processor is not run due to the way the main ss7 processing loop currently works --- libs/freetdm/src/ftdm_state.c | 10 +++++++-- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 21 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c index 30ef3ce478..03f2cd8e18 100644 --- a/libs/freetdm/src/ftdm_state.c +++ b/libs/freetdm/src/ftdm_state.c @@ -48,9 +48,15 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c ftdm_time_t diff = 0; ftdm_channel_state_t state = fchan->state; + if (fchan->state_status == FTDM_STATE_STATUS_NEW) { + ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_CRIT, + "Asking to complete state change from %s to %s in %llums, but the state is still unprocessed (this might be a bug!)\n", + ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(state), diff); + /* We should probably return here with FTDM_FAIL if we don't see this message in production environments for a while (2012-02-16) */ + } + if (fchan->state_status == FTDM_STATE_STATUS_COMPLETED) { - ftdm_assert_return(!ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE), FTDM_FAIL, - "State change flag set but state is not completed\n"); + ftdm_assert_return(!ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE), FTDM_FAIL, "State change flag set but state is already completed\n"); return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 00d06905dd..7ad510079f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -46,6 +46,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) { const char *var = NULL; SiConEvnt iam; + ftdm_bool_t native_going_up = FTDM_FALSE; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;; SS7_FUNC_TRACE_ENTER (__FUNCTION__); @@ -81,9 +82,11 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* flush our own queue */ sngss7_flush_queue(sngss7_info->event_queue); - /* go up until release comes, note that state processing is done different and much simpler when there is a peer */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); - ftdm_channel_advance_states(ftdmchan); + /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, + We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function + because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped + and we still need those variables for further IAM processing */ + native_going_up = FTDM_TRUE; } } } @@ -211,6 +214,18 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) &iam, 0); + if (native_going_up) { + /* + Note that this function (ft_to_sngss7_iam) is run within the main SS7 processing loop in + response to the DIALING state handler, we can set the state to UP here and that will + implicitly complete the DIALING state, but we *MUST* also advance the state handler + right away for a native bridge, otherwise, the processing state function (ftdm_sangoma_ss7_process_state_change) + will complete the state without having executed the handler for FTDM_CHANNEL_STATE_UP, and we won't notify + the user sending FTDM_SIGEVENT_UP which can cause the application to misbehave (ie, no audio) */ + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); + ftdm_channel_advance_states(ftdmchan); + } + SS7_FUNC_TRACE_EXIT (__FUNCTION__); return; } From 8c8d649221b6d700d9738c619ceef0689aa0e134 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 16 Feb 2012 15:14:06 -0500 Subject: [PATCH 02/26] freetdm: Add support to set/receive location and original call number SS7 elements through variables (including SIP X headers) --- libs/freetdm/mod_freetdm/mod_freetdm.c | 55 ++++++++++++- .../ftmod_sangoma_ss7_main.h | 3 + .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 21 ++++- .../ftmod_sangoma_ss7_support.c | 81 ++++++++++++++++--- 4 files changed, 148 insertions(+), 12 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index b78cc078d4..01d7c282c3 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1400,6 +1400,22 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ftdm_set_string(caller_data.loc.digits, sipvar); } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-Screen"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_screen_ind", sipvar); + } + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-Presentation"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_pres_ind", sipvar); + } + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-NADI"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_loc_nadi", sipvar); + } + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-TON"); if (sipvar) { caller_data.dnis.type = (uint8_t)atoi(sipvar); @@ -1514,6 +1530,24 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (sipvar) { ftdm_usrmsg_add_var(&usrmsg, "ss7_rdinfo_reason", sipvar); } + + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-NADI"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_nadi", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-Plan"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_plan", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-OCN-Presentation"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_pres", sipvar); + } } if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { @@ -1944,10 +1978,29 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session } var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_nadi"); - printf ( "ss7_loc_nadi = %s \n " , var_value ); if (!ftdm_strlen_zero(var_value)) { switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-NADI", "%s", var_value); } + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN", "%s", var_value); + } + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_nadi"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-NADI", "%s", var_value); + } + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_plan"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-Plan", "%s", var_value); + } + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_ocn_pres"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OCN-Presentation", "%s", var_value); + } } /* Add any call variable to the dial plan */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index fb60183bf8..86cdc73bc9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -868,6 +868,9 @@ ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *red ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum); ftdm_status_t copy_redirgInfo_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo); ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *redirInfo); +ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); +ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); + ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 7ad510079f..930457c7c8 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -135,6 +135,11 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Redirecting Information */ copy_redirgInfo_to_sngss7(ftdmchan, &iam.redirInfo); } + + if (iam.origCdNum.eh.pres != PRSNT_NODEF) { + /* Original Called Number */ + copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); + } } /* since this is the first time we dequeue an event from the peer, make sure our main thread process any other events, this will trigger the interrupt in our span peer_chans queue which will wake up our main thread if it is sleeping */ @@ -157,6 +162,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Forward Call Indicators */ copy_fwdCallInd_to_sngss7(ftdmchan, &iam.fwdCallInd); + + /* Original Called Number */ + copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); } else { /* Nature of Connection Indicators */ copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd); @@ -193,6 +201,8 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Redirecting Information */ copy_redirgInfo_to_sngss7(ftdmchan, &iam.redirInfo); + /* Original Called Number */ + copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); /* Access Transport */ copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt); @@ -236,6 +246,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; SiCnStEvnt acm; + const char *backwardInd = NULL; memset (&acm, 0x0, sizeof (acm)); @@ -253,8 +264,16 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) acm.bckCallInd.intInd.val = INTIND_NOINTW; acm.bckCallInd.end2EndInfoInd.pres = PRSNT_NODEF; acm.bckCallInd.end2EndInfoInd.val = E2EINF_NOINFO; + acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF; - acm.bckCallInd.isdnUsrPrtInd.val = ISUP_USED; + acm.bckCallInd.isdnUsrPrtInd.val = ISUP_NOTUSED; + backwardInd = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "acm_bi_iup"); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied backward indicator ISDN user part indicator ACM, value \"%s\"\n", backwardInd); + if (!ftdm_strlen_zero(backwardInd)) { + if (atoi(backwardInd) != 0 ) { + acm.bckCallInd.isdnUsrPrtInd.val = ISUP_USED; + } + } acm.bckCallInd.holdInd.pres = PRSNT_NODEF; acm.bckCallInd.holdInd.val = HOLD_NOTREQD; acm.bckCallInd.isdnAccInd.pres = PRSNT_NODEF; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index 2088f240b6..4557c00a10 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -259,20 +259,20 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc locPtyNum->scrnInd.pres = pres_val; val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_screen_ind"); if (!ftdm_strlen_zero(val)) { - locPtyNum->scrnInd.val = atoi(val); + locPtyNum->scrnInd.val = atoi(val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Screening Ind %d\n", locPtyNum->scrnInd.val); } else { - locPtyNum->scrnInd.val = caller_data->screen; + locPtyNum->scrnInd.val = caller_data->screen; } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Location Reference Code Screening Ind %d\n", locPtyNum->scrnInd.val); locPtyNum->presRest.pres = pres_val; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_pres_ind"); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_pres_ind"); if (!ftdm_strlen_zero(val)) { - locPtyNum->presRest.val = atoi(val); + locPtyNum->presRest.val = atoi(val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Presentation Ind %d\n", locPtyNum->presRest.val); } else { - locPtyNum->presRest.val = caller_data->pres; + locPtyNum->presRest.val = caller_data->pres; } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", locPtyNum->presRest.val); locPtyNum->numPlan.pres = pres_val; locPtyNum->numPlan.val = 0x01; @@ -286,11 +286,10 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Reference NADI value \"%s\"\n", loc_nadi); locPtyNum->natAddrInd.val = atoi(loc_nadi); } else { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val); locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi; locPtyNum->natAddrInd.val = 0x03; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val); } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Location Reference Presentation Ind %d\n", locPtyNum->presRest.val); return copy_tknStr_to_sngss7(caller_data->loc.digits, &locPtyNum->addrSig, &locPtyNum->oddEven); } @@ -439,7 +438,7 @@ ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *red return FTDM_FAIL; } } else if (!ftdm_strlen_zero(caller_data->rdnis.digits)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Redirection Number\"%s\"\n", caller_data->rdnis.digits); if (copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven) != FTDM_SUCCESS) { return FTDM_FAIL; } @@ -639,6 +638,68 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r return FTDM_SUCCESS; } +ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) +{ + return FTDM_FAIL; +} + +ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) +{ + + const char *val = NULL; + int bProceed = 0; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn"); + if (!ftdm_strlen_zero(val)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number \"%s\"\n", val); + if (copy_tknStr_to_sngss7((char*)val, &origCdNum->addrSig, &origCdNum->oddEven) != FTDM_SUCCESS) { + return FTDM_FAIL; + } + origCdNum->addrSig.pres = 1; + } else { + return FTDM_SUCCESS; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_nadi"); + if (!ftdm_strlen_zero(val)) { + origCdNum->natAddr.val = atoi(val); + origCdNum->natAddr.pres = 1; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number NADI value \"%s\"\n", val); + bProceed = 1; + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number NADI value\n"); + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_plan"); + if (!ftdm_strlen_zero(val)) { + origCdNum->numPlan.val = atoi(val); + origCdNum->numPlan.pres = 1; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number Plan value \"%s\"\n", val); + bProceed = 1; + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Plan value\n"); + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_pres"); + if (!ftdm_strlen_zero(val)) { + origCdNum->presRest.val = atoi(val); + origCdNum->presRest.pres = 1; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number Presentation value \"%s\"\n", val); + bProceed = 1; + } else { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Presentation value\n"); + } + + if( bProceed == 1 ) { + origCdNum->eh.pres = PRSNT_NODEF; + } else { + origCdNum->eh.pres = NOTPRSNT; + } + + + return FTDM_SUCCESS; +} + ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat) { ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; From 4ccc26f08b94404246c951d13d62dbafe2ecc781 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 16 Feb 2012 15:15:22 -0500 Subject: [PATCH 03/26] freetdm: Fix improper logging statement when doing native ss7 bridge (peer_chan was set to the SIP leg) --- libs/freetdm/mod_freetdm/mod_freetdm.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 01d7c282c3..f9381ce133 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1650,11 +1650,13 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi our_chan = switch_core_session_get_channel(*new_session); + /* Figure out if there is a native bridge requested through SIP x headers */ if (network_peer_uuid) { switch_core_session_t *network_peer = switch_core_session_locate(network_peer_uuid); if (network_peer) { const char *my_uuid = switch_core_session_get_uuid(*new_session); private_t *peer_private = switch_core_session_get_private(network_peer); + peer_chan = switch_core_session_get_channel(network_peer); switch_set_string(tech_pvt->network_peer_uuid, network_peer_uuid); switch_set_string(peer_private->network_peer_uuid, my_uuid); @@ -1665,6 +1667,15 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ftdm_channel_get_span_id(peer_private->ftdmchan), ftdm_channel_get_id(peer_private->ftdmchan)); switch_core_session_rwunlock(network_peer); } + /* Figure out if there is a native bridge requested through dial plan variable and the originating channel is also freetdm (not going through SIP) */ + } else if (session + && (var = channel_get_variable(session, var_event, FREETDM_VAR_PREFIX "native_sigbridge")) + && switch_true(var) + && switch_core_session_compare(*new_session, session)) { + private_t *peer_pvt = switch_core_session_get_private(session); + peer_chan = switch_core_session_get_channel(session); + snprintf(sigbridge_peer, sizeof(sigbridge_peer), "%u:%u", + ftdm_channel_get_span_id(peer_pvt->ftdmchan), ftdm_channel_get_id(peer_pvt->ftdmchan)); } caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); @@ -1678,21 +1689,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi hunt_data.tech_pvt = tech_pvt; caller_data.priv = &hunt_data; - if (session - && (var = channel_get_variable(session, var_event, FREETDM_VAR_PREFIX "native_sigbridge")) - && switch_true(var) - && switch_core_session_compare(*new_session, session)) { - private_t *peer_pvt = switch_core_session_get_private(session); - snprintf(sigbridge_peer, sizeof(sigbridge_peer), "%u:%u", - ftdm_channel_get_span_id(peer_pvt->ftdmchan), ftdm_channel_get_id(peer_pvt->ftdmchan)); - } - if (session && !zstr(sigbridge_peer)) { peer_chan = switch_core_session_get_channel(session); ftdm_usrmsg_add_var(&usrmsg, "sigbridge_peer", sigbridge_peer); } - if ((status = ftdm_call_place_ex(&caller_data, &hunting, &usrmsg)) != FTDM_SUCCESS) { if (tech_pvt->read_codec.implementation) { switch_core_codec_destroy(&tech_pvt->read_codec); From 1f34c9301e6a737890f9d756f87554afc8a96f4e Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Thu, 16 Feb 2012 16:08:21 -0500 Subject: [PATCH 04/26] freetdm: Remove optimistic sanity check, prints spurious error messages --- libs/freetdm/src/ftdm_state.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c index 03f2cd8e18..c6d45c3c3c 100644 --- a/libs/freetdm/src/ftdm_state.c +++ b/libs/freetdm/src/ftdm_state.c @@ -48,12 +48,22 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c ftdm_time_t diff = 0; ftdm_channel_state_t state = fchan->state; +#if 0 + /* I could not perform this sanity check without more disruptive changes. Ideally we should check here if the signaling module completing the state + executed a state processor (called ftdm_channel_advance_states() which call fchan->span->state_processor(fchan)) for the state. That is just a + sanity check, as in the past we had at least one bug where the signaling module set the state and then accidentally changed the state to a new one + without calling ftdm_channel_advance_states(), meaning the state processor for the first state was not executed and that lead to unexpected behavior. + + If we want to be able to perform this kind of sanity check it would be nice to add a new state status (FTDM_STATE_STATUS_PROCESSING), the function + ftdm_channel_advance_states() would set the state_status to PROCESSING and then the check below for STATUS_NEW would be valid. Currently is not + valid because the signaling module may be completing the state at the end of the state_processor callback and therefore the state will still be + in STATUS_NEW, and is perfectly valid ... */ if (fchan->state_status == FTDM_STATE_STATUS_NEW) { ftdm_log_chan_ex(fchan, file, func, line, FTDM_LOG_LEVEL_CRIT, "Asking to complete state change from %s to %s in %llums, but the state is still unprocessed (this might be a bug!)\n", ftdm_channel_state2str(fchan->last_state), ftdm_channel_state2str(state), diff); - /* We should probably return here with FTDM_FAIL if we don't see this message in production environments for a while (2012-02-16) */ } +#endif if (fchan->state_status == FTDM_STATE_STATUS_COMPLETED) { ftdm_assert_return(!ftdm_test_flag(fchan, FTDM_CHANNEL_STATE_CHANGE), FTDM_FAIL, "State change flag set but state is already completed\n"); From 3f43b053a07cd26d40bc4bb069b7a8cff8315ce7 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 16 Feb 2012 16:49:51 -0500 Subject: [PATCH 05/26] freetdm: adding x-ocn-* headers for incoming sip calls --- libs/freetdm/mod_freetdm/mod_freetdm.c | 1 + .../ftmod_sangoma_ss7_handle.c | 1 + .../ftmod_sangoma_ss7_support.c | 36 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index f9381ce133..c3e5c486db 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -26,6 +26,7 @@ * Anthony Minessale II * Moises Silva * David Yat Sin + * James Zhang * * * mod_freetdm.c -- FreeTDM Endpoint Module diff --git 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 index 9c3bd65426..f080352d4a 100644 --- 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 @@ -200,6 +200,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); } + copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum); copy_redirgInfo_from_sngss7(ftdmchan, &siConEvnt->redirInfo); copy_genNmb_from_sngss7(ftdmchan, &siConEvnt->genNmb); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index 4557c00a10..e7af4bb6e0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -640,7 +640,41 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) { - return FTDM_FAIL; + + char val[20]; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + if (origCdNum->eh.pres != PRSNT_NODEF ) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Original Called Number available\n"); + return FTDM_SUCCESS; + } + + + if (origCdNum->addrSig.pres == PRSNT_NODEF) { + copy_tknStr_from_sngss7(origCdNum->addrSig, val, origCdNum->oddEven); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number digits:%s\n", val); + sngss7_add_var(sngss7_info, "ss7_ocn", val); + } + + if (origCdNum->natAddr.pres == PRSNT_NODEF) { + snprintf(val, sizeof(val), "%d", origCdNum->natAddr.val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - NADI:%s\n", val); + sngss7_add_var(sngss7_info, "ss7_ocn_nadi", val); + } + + if (origCdNum->numPlan.pres == PRSNT_NODEF) { + snprintf(val, sizeof(val), "%d", origCdNum->numPlan.val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number -plan:%s\n", val); + sngss7_add_var(sngss7_info, "ss7_ocn_plan", val); + } + + if (origCdNum->presRest.pres == PRSNT_NODEF) { + snprintf(val, sizeof(val), "%d", origCdNum->presRest.val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - presentation:%s\n", val); + sngss7_add_var(sngss7_info, "ss7_ocn_pres", val); + } + + return FTDM_SUCCESS; } ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) From 713b55cd585aab9c6ea7969e6f03b30d10a5a7e6 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 16 Feb 2012 18:33:00 -0500 Subject: [PATCH 06/26] freetdm: fixing improper log position in tx acm function --- .../freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 930457c7c8..84b9a9b7f2 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -268,8 +268,8 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF; acm.bckCallInd.isdnUsrPrtInd.val = ISUP_NOTUSED; backwardInd = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "acm_bi_iup"); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied backward indicator ISDN user part indicator ACM, value \"%s\"\n", backwardInd); if (!ftdm_strlen_zero(backwardInd)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied backward indicator ISDN user part indicator ACM, value \"%s\"\n", backwardInd); if (atoi(backwardInd) != 0 ) { acm.bckCallInd.isdnUsrPrtInd.val = ISUP_USED; } From eeec65265aa2bcce552df6effd0c18ecda473d8a Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 24 Feb 2012 16:32:44 -0500 Subject: [PATCH 07/26] freetdm: fixing format and loc_nadi value according to review board No. 98 --- .../ftmod_sangoma_ss7_support.c | 55 +++++++++---------- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 1 - 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index e7af4bb6e0..4bfa5d2065 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -257,21 +257,21 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi; locPtyNum->scrnInd.pres = pres_val; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_screen_ind"); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_screen_ind"); if (!ftdm_strlen_zero(val)) { locPtyNum->scrnInd.val = atoi(val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Screening Ind %d\n", locPtyNum->scrnInd.val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Screening Ind %d\n", locPtyNum->scrnInd.val); } else { locPtyNum->scrnInd.val = caller_data->screen; } locPtyNum->presRest.pres = pres_val; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_pres_ind"); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_pres_ind"); if (!ftdm_strlen_zero(val)) { locPtyNum->presRest.val = atoi(val); ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Presentation Ind %d\n", locPtyNum->presRest.val); } else { - locPtyNum->presRest.val = caller_data->pres; + locPtyNum->presRest.val = caller_data->pres; } locPtyNum->numPlan.pres = pres_val; @@ -286,10 +286,9 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Reference NADI value \"%s\"\n", loc_nadi); locPtyNum->natAddrInd.val = atoi(loc_nadi); } else { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val); locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi; - locPtyNum->natAddrInd.val = 0x03; - } + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val); + } return copy_tknStr_to_sngss7(caller_data->loc.digits, &locPtyNum->addrSig, &locPtyNum->oddEven); } @@ -640,7 +639,6 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) { - char val[20]; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; @@ -649,43 +647,41 @@ ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCd return FTDM_SUCCESS; } - if (origCdNum->addrSig.pres == PRSNT_NODEF) { copy_tknStr_from_sngss7(origCdNum->addrSig, val, origCdNum->oddEven); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number digits:%s\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Digits: %s\n", val); sngss7_add_var(sngss7_info, "ss7_ocn", val); } - + if (origCdNum->natAddr.pres == PRSNT_NODEF) { snprintf(val, sizeof(val), "%d", origCdNum->natAddr.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - NADI:%s\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - NADI: %s\n", val); sngss7_add_var(sngss7_info, "ss7_ocn_nadi", val); } - + if (origCdNum->numPlan.pres == PRSNT_NODEF) { snprintf(val, sizeof(val), "%d", origCdNum->numPlan.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number -plan:%s\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Plan: %s\n", val); sngss7_add_var(sngss7_info, "ss7_ocn_plan", val); } if (origCdNum->presRest.pres == PRSNT_NODEF) { snprintf(val, sizeof(val), "%d", origCdNum->presRest.val); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - presentation:%s\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Original Called Number - Presentation: %s\n", val); sngss7_add_var(sngss7_info, "ss7_ocn_pres", val); } - + return FTDM_SUCCESS; } ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) { - const char *val = NULL; int bProceed = 0; - + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn"); if (!ftdm_strlen_zero(val)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number \"%s\"\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Digits: %s\n", val); if (copy_tknStr_to_sngss7((char*)val, &origCdNum->addrSig, &origCdNum->oddEven) != FTDM_SUCCESS) { return FTDM_FAIL; } @@ -698,39 +694,38 @@ ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNu if (!ftdm_strlen_zero(val)) { origCdNum->natAddr.val = atoi(val); origCdNum->natAddr.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number NADI value \"%s\"\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - NADI: %s\n", val); bProceed = 1; - } else { + } else { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number NADI value\n"); } - + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_plan"); if (!ftdm_strlen_zero(val)) { origCdNum->numPlan.val = atoi(val); origCdNum->numPlan.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number Plan value \"%s\"\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Plan: %s\n", val); bProceed = 1; - } else { + } else { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Plan value\n"); } - + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_ocn_pres"); if (!ftdm_strlen_zero(val)) { origCdNum->presRest.val = atoi(val); origCdNum->presRest.pres = 1; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number Presentation value \"%s\"\n", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Original Called Number - Presentation: %s\n", val); bProceed = 1; - } else { + } else { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Original Called Number Presentation value\n"); } - + if( bProceed == 1 ) { origCdNum->eh.pres = PRSNT_NODEF; } else { origCdNum->eh.pres = NOTPRSNT; } - - + return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index e76397580e..24293ef0ee 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -1978,7 +1978,6 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) flag_loc_nadi = 1; sng_ccSpan.loc_nadi = atoi(parm->val); SS7_DEBUG("Found default LOC_NADI parm->value = %d\n", sng_ccSpan.loc_nadi); - printf( " --- jz: we got loc nadi from XML, val = %d \n" , sng_ccSpan.loc_nadi); /**********************************************************************/ } else if (!strcasecmp(parm->var, "lpa_on_cot")) { From 3c4fdca9e0bb43f9656fa70f00e4ddf738a2169b Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 7 Mar 2012 19:04:31 -0500 Subject: [PATCH 08/26] freetdm: Fix redmine issue #2931 - Crash on SIP to SS7 call after sigbridge call The code was improperly using peer_data as an indicator that the sigbridge ss7 mode was enabled. The channel flag FTDM_CHANNEL_NATIVE_SIGBRDIGE should be used instead --- libs/freetdm/src/ftdm_io.c | 6 ++++++ .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 3b11611d49..513fc0c595 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2449,6 +2449,12 @@ FT_DECLARE(ftdm_status_t) ftdm_get_channel_from_string(const char *string_id, ft *out_span = NULL; *out_channel = NULL; + if (!string_id) { + ftdm_log(FTDM_LOG_ERROR, "Cannot parse NULL channel id string\n"); + status = FTDM_EINVAL; + goto done; + } + rc = sscanf(string_id, "%u:%u", &span_id, &chan_id); if (rc != 2) { ftdm_log(FTDM_LOG_ERROR, "Failed to parse channel id string '%s'\n", string_id); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 84b9a9b7f2..5f0a0f0960 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -57,12 +57,12 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) memset (&iam, 0x0, sizeof (iam)); - var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer"); - if (!ftdm_strlen_zero(var)) { + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { ftdm_span_t *peer_span = NULL; ftdm_channel_t *peer_chan = NULL; sngss7_chan_data_t *peer_info = NULL; + var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer"); ftdm_get_channel_from_string(var, &peer_span, &peer_chan); if (!peer_chan) { SS7_ERROR_CHAN(ftdmchan, "Failed to find sigbridge peer from string '%s'\n", var); @@ -91,7 +91,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) } } - if (sngss7_info->peer_data) { + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && sngss7_info->peer_data) { sngss7_span_data_t *span_data = ftdmchan->span->signal_data; sngss7_event_data_t *event_clone = ftdm_queue_dequeue(sngss7_info->peer_data->event_queue); /* Retrieve IAM from our peer */ From 19f01bf50a1b478b7206f2b9f083b08ac357ff12 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 15 Mar 2012 18:05:47 -0400 Subject: [PATCH 09/26] freetdm: fixing a potential crash on a rarely happened situation --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 4 +++ .../ftmod_sangoma_ss7_main.c | 26 ++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index cb5584760f..60b44cec1e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -1314,6 +1314,10 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, }else { stream->write_function(stream, "relay=N"); } + +#ifdef SMG_RELAY_DBG + stream->write_function(stream, "| flag=0x%llx", ftdmchan->flags); +#endif } #ifdef SMG_RELAY_DBG diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index fa36c7280a..ecd83a14d4 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -614,20 +614,22 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev break; case SNGSS7_REL_CFM_EVENT: { - ftdm_channel_t *peer_chan = sngss7_info->peer_data->ftdmchan; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - if (peer_chan) { - /* we need to unlock our chan or we risk deadlock */ - ftdm_channel_advance_states(ftdmchan); - ftdm_channel_unlock(ftdmchan); + if (sngss7_info->peer_data) { + ftdm_channel_t *peer_chan = sngss7_info->peer_data->ftdmchan; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + if (peer_chan) { + /* we need to unlock our chan or we risk deadlock */ + ftdm_channel_advance_states(ftdmchan); + ftdm_channel_unlock(ftdmchan); - ftdm_channel_lock(peer_chan); - if (peer_chan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state(peer_chan, FTDM_CHANNEL_STATE_DOWN); + ftdm_channel_lock(peer_chan); + if (peer_chan->state != FTDM_CHANNEL_STATE_DOWN) { + ftdm_set_state(peer_chan, FTDM_CHANNEL_STATE_DOWN); + } + ftdm_channel_unlock(peer_chan); + + ftdm_channel_lock(ftdmchan); } - ftdm_channel_unlock(peer_chan); - - ftdm_channel_lock(ftdmchan); } } break; From 10277be8d6b2df8a97f1ee9564cb6468691bb2cc Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 16 Mar 2012 11:40:21 -0400 Subject: [PATCH 10/26] freetdm: synchronizing fixes in releases.3.5 version - glare - cgb/cgu range bug - inhibit/uninhibit --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 17 +- .../ftmod_sangoma_ss7_handle.c | 256 ++++++++++-------- .../ftmod_sangoma_ss7_main.c | 50 +++- .../ftmod_sangoma_ss7_main.h | 23 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 52 +++- 5 files changed, 257 insertions(+), 141 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index 60b44cec1e..3f1a03f4d8 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -784,16 +784,24 @@ static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 set ftrace X Y\n"); stream->write_function(stream, "ftdm ss7 set mtrace X Y\n"); stream->write_function(stream, "\n"); - stream->write_function(stream, "ftmod_sangoma_ss7 information:\n"); - stream->write_function(stream, "ftdm ss7 show status mtp3 X\n"); + + stream->write_function(stream, "ftmod_sangoma_ss7 signaling information:\n"); + stream->write_function(stream, "ftdm ss7 show \n"); stream->write_function(stream, "ftdm ss7 show status mtp2 X\n"); + stream->write_function(stream, "ftdm ss7 show status mtp3 X\n"); + stream->write_function(stream, "ftdm ss7 show status linkset X\n"); + stream->write_function(stream, "\n"); + + stream->write_function(stream, "ftmod_sangoma_ss7 circuit information:\n"); + stream->write_function(stream, "ftdm ss7 show span all\n"); + stream->write_function(stream, "ftdm ss7 show span X\n"); stream->write_function(stream, "ftdm ss7 show status span X chan Y\n"); stream->write_function(stream, "ftdm ss7 show free span X chan Y\n"); stream->write_function(stream, "ftdm ss7 show blocks span X chan Y\n"); - stream->write_function(stream, "ftdm ss7 show inuse span X chan Y\n"); stream->write_function(stream, "ftdm ss7 show inreset span X chan Y\n"); stream->write_function(stream, "\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 circuit control:\n"); stream->write_function(stream, "ftdm ss7 blo span X chan Y\n"); stream->write_function(stream, "ftdm ss7 ubl span X chan Y\n"); @@ -802,9 +810,12 @@ static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 cgb span X chan Y range Z\n"); stream->write_function(stream, "ftdm ss7 cgu span X chan Y range Z\n"); stream->write_function(stream, "\n"); + stream->write_function(stream, "ftmod_sangoma_ss7 link control:\n"); + /* stream->write_function(stream, "ftdm ss7 inhibit link X\n"); stream->write_function(stream, "ftdm ss7 uninhibit link X\n"); + */ stream->write_function(stream, "ftdm ss7 activate link X\n"); stream->write_function(stream, "ftdm ss7 deactivate link X\n"); stream->write_function(stream, "ftdm ss7 activate linkset X\n"); diff --git 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 index f080352d4a..d9816dfa0e 100644 --- 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 @@ -33,6 +33,7 @@ * Contributors: * * Ricardo BarroetaveƱa + * James Zhang * */ @@ -199,7 +200,6 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ } else { SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); } - copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum); copy_redirgInfo_from_sngss7(ftdmchan, &siConEvnt->redirInfo); @@ -316,13 +316,13 @@ handle_glare: /* setup the hangup cause */ ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ - - /* this is a remote hangup request */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - - /* move the state of the channel to Terminating to end the call */ + + /* move the state of the channel to Terminating to end the call + in TERMINATING state, the release cause is set to REMOTE_REL + in any means. So we don't have to set the release reason here. + */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); - } /* if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) */ + } break; /**************************************************************************/ default: /* should not have gotten an IAM while in this state */ @@ -1283,6 +1283,7 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci /* the glare flag is already up so it was caught ... do nothing */ SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " "); } else { + int bHangup = 0; SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " "); /* glare, throw the flag */ sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE); @@ -1290,14 +1291,45 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci /* clear any existing glare data from the channel */ memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t)); + if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_DOWN) { + /* If I'm in DOWN mode, I will always hangup my call. */ + bHangup = 1; + } + else if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_PC) { + /* I'm in PointCode mode. + Case 1: My point code is higher than the other side. + If the CIC number is even, I'm trying to control. + If the CIC number is odd, I'll hangup my call and back off. + Case 2: My point code is lower than the other side. + If the CIC number is odd, I'm trying to control. + If the CIC number is even, I'll hangup my call and back off. + */ + if( g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc > g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ) + { + if ((sngss7_info->circuit->cic % 2) == 1 ) { + bHangup = 1; + } + } else { + if( (sngss7_info->circuit->cic % 2) == 0 ) { + bHangup = 1; + } + } + } + else { + /* If I'm in CONTROL mode, I will not hangup my call. */ + bHangup = 0; + } + + if (bHangup) { /* setup the hangup cause */ ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ - /* this is a remote hangup request */ - sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); - - /* move the state of the channel to Terminating to end the call */ - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); + /* move the state of the channel to Terminating to end the call + in TERMINATING state, the release cause is set to REMOTE_REL + in any means. So we don't have to set the release reason here. + */ + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); + } } /* unlock the channel again before we exit */ @@ -2340,7 +2372,8 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ int blockType = 0; int byte = 0; int bit = 0; - int x; + int x; + int loop_range=0; ftdm_running_return(FTDM_FAIL); @@ -2407,61 +2440,54 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ } /* loop over the cics starting from circuit until range+1 */ - for (x = circuit; x < (circuit + range + 1); x++) { - /* confirm this is a voice channel */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) continue; - - /* grab the circuit in question */ - if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); - break; + loop_range = circuit + range + 1; + x = circuit; + while( x < loop_range ) { + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) { + loop_range++; } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); + else { + if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { + SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); + } else { + ftdm_mutex_lock(ftdmchan->mutex); + if (status[byte] & (1 << bit)) { + switch (blockType) { + /**********************************************************************/ + case 0: /* maintenance oriented */ + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); + break; + /**********************************************************************/ + case 1: /* hardware failure oriented */ + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); + break; + /**********************************************************************/ + case 2: /* reserved for national use */ + break; + /**********************************************************************/ + default: + break; + /**********************************************************************/ + } + } -#if 0 - SS7_ERROR("KONRAD -> circuit=%d, byte=%d, bit=%d, status[byte]=%d, math=%d\n", - x, - byte, - bit, - status[byte], - (status[byte] & (1 << bit))); -#endif - if (status[byte] & (1 << bit)) { - switch (blockType) { - /**********************************************************************/ - case 0: /* maintenance oriented */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - break; - /**********************************************************************/ - case 1: /* hardware failure oriented */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - break; - /**********************************************************************/ - case 2: /* reserved for national use */ - break; - /**********************************************************************/ - default: - break; - /**********************************************************************/ - } /* switch (blockType) */ + /* bring the sig status down */ + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + + /* unlock the channel again before we exit */ + ftdm_mutex_unlock(ftdmchan->mutex); + + /* update the bit and byte counter*/ + bit ++; + if (bit == 8) { + byte++; + bit = 0; + } + } } + x++; + } - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - - } /* for (x = circuit; x < (circuit + range + 1); x++) */ /* get the ftdmchan and ss7_chan_data from the circuit */ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { @@ -2488,7 +2514,8 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ int blockType = 0; int byte = 0; int bit = 0; - int x; + int x; + int loop_range=0; ftdm_sigmsg_t sigev; ftdm_running_return(FTDM_FAIL); @@ -2558,59 +2585,62 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ } /* loop over the cics starting from circuit until range+1 */ - for (x = circuit; x < (circuit + range + 1); x++) { - if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) continue; - /* grab the circuit in question */ - if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { - SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); - break; + loop_range = circuit + range + 1; + x = circuit; + while( x < loop_range ) { + if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) { + loop_range++; } - - /* lock the channel */ - ftdm_mutex_lock(ftdmchan->mutex); + else { + if (extract_chan_data(x, &sngss7_info, &ftdmchan)) { + SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x); + } + else { + ftdm_mutex_lock(ftdmchan->mutex); - if (status[byte] & (1 << bit)) { - switch (blockType) { - /**********************************************************************/ - case 0: /* maintenance oriented */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); - break; - /**********************************************************************/ - case 1: /* hardware failure oriented */ - sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); - break; - /**********************************************************************/ - case 2: /* reserved for national use */ - break; - /**********************************************************************/ - default: - break; - /**********************************************************************/ - } /* switch (blockType) */ - } /* if (status[byte] & (1 << bit)) */ + if (status[byte] & (1 << bit)) { + switch (blockType) { + /**********************************************************************/ + case 0: /* maintenance oriented */ + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN); + break; + /**********************************************************************/ + case 1: /* hardware failure oriented */ + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX); + break; + /**********************************************************************/ + case 2: /* reserved for national use */ + break; + /**********************************************************************/ + default: + break; + /**********************************************************************/ + } /* switch (blockType) */ + } /* if (status[byte] & (1 << bit)) */ - sigev.chan_id = ftdmchan->chan_id; - sigev.span_id = ftdmchan->span_id; - sigev.channel = ftdmchan; + sigev.chan_id = ftdmchan->chan_id; + sigev.span_id = ftdmchan->span_id; + sigev.channel = ftdmchan; - /* bring the sig status down */ - if (sngss7_channel_status_clear(sngss7_info)) { - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + /* bring the sig status down */ + if (sngss7_channel_status_clear(sngss7_info)) { + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + } + + ftdm_mutex_unlock(ftdmchan->mutex); + + /* update the bit and byte counter*/ + bit ++; + if (bit == 8) { + byte++; + bit = 0; + } + } } - - /* unlock the channel again before we exit */ - ftdm_mutex_unlock(ftdmchan->mutex); - - /* update the bit and byte counter*/ - bit ++; - if (bit == 8) { - byte++; - bit = 0; - } - - } /* for (x = circuit; x < (circuit + range + 1); x++) */ + x++; + } /* get the ftdmchan and ss7_chan_data from the circuit */ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index ecd83a14d4..fe129c0f73 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -35,6 +35,7 @@ * * Moises Silva * David Yat Sin + * James Zhang * */ @@ -1474,14 +1475,14 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", ""); /* all flags are down so we can bring up the sig status */ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); - } /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */ + } } else { state_flag = 0; SS7_DEBUG_CHAN(ftdmchan,"Down detected blocked flags go to SUSPEND %s\n", " "); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); break; - } /* if !blocked */ + } } else { SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags); @@ -1489,7 +1490,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) state_flag = 0; ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); } - } /* if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) */ + } /* check if t35 is active */ if (sngss7_info->t35.hb_timer_id) { @@ -1532,20 +1533,47 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) /* check if there is a glared call that needs to be processed */ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) { - - /* clear the glare flag */ sngss7_clear_ckt_flag (sngss7_info, FLAG_GLARE); - /* check if we have an IAM stored...if we don't have one just exit */ if (sngss7_info->glare.circuit != 0) { - /* send the saved call back in to us */ - handle_con_ind (0, - sngss7_info->glare.spInstId, - sngss7_info->glare.circuit, - &sngss7_info->glare.iam); + int bHandle=0; + switch (g_ftdm_sngss7_data.cfg.glareResolution) { + case SNGSS7_GLARE_DOWN: + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Giving control to the other side, handling copied IAM from glare. \n", sngss7_info->circuit->cic); + bHandle = 1; + break; + case SNGSS7_GLARE_PC: + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Trying to handle IAM copied from glare. \n", sngss7_info->circuit->cic); + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]My PC = %d, incoming PC = %d. \n", sngss7_info->circuit->cic, + g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc, + g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ); + + if( g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc > g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc ) + { + if ((sngss7_info->circuit->cic % 2) == 1 ) { + bHandle = 1; + } + } else { + if( (sngss7_info->circuit->cic % 2) == 0 ) { + bHandle = 1; + } + } + + break; + default: /* if configured as SNGSS7_GLARE_CONTROL, always abandon incoming glared IAM. */ + bHandle = 0; + break; + } + + if (!bHandle) { + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Handling glare IAM. \n", sngss7_info->circuit->cic); + handle_con_ind (0, sngss7_info->glare.spInstId, sngss7_info->glare.circuit, &sngss7_info->glare.iam); + } + /* clear the glare info */ memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t)); + state_flag = 0; } } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index 86cdc73bc9..63d4ded203 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -29,6 +29,12 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Contributors: + * + * James Zhang + * */ /******************************************************************************/ #ifndef __FTMOD_SNG_SS7_H__ @@ -195,6 +201,21 @@ typedef struct sng_mtp2_link { uint32_t t7; } sng_mtp2_link_t; +/* defining glare handling methods: + SNGSS7_GLARE_PC: + higher PointCode controls even number CIC + lower PointCode controls odd number CIC + SNGSS7_GLARE_DOWN: + always give control to the other side + SNGSS7_GLARE_CONTROL: + always trying to control +*/ +typedef enum { + SNGSS7_GLARE_PC = 0, + SNGSS7_GLARE_DOWN, + SNGSS7_GLARE_CONTROL +} sng_glare_resolution; + typedef struct sng_mtp3_link { char name[MAX_NAME_LEN]; uint32_t flags; @@ -444,6 +465,7 @@ typedef struct sng_ss7_cfg { sng_isup_ckt_t isupCkt[10000]; /* KONRAD - only need 2000 ( and 0-1000 aren't used) since other servers are registerd else where */ sng_nsap_t nsap[MAX_NSAPS+1]; sng_isap_t isap[MAX_ISAPS+1]; + sng_glare_resolution glareResolution; } sng_ss7_cfg_t; typedef struct ftdm_sngss7_data { @@ -871,7 +893,6 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); - ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index 24293ef0ee..ad47f0cbb4 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -29,6 +29,12 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Contributors: + * + * James Zhang + * */ /* INCLUDE ********************************************************************/ @@ -191,6 +197,7 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan); static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot); +static void ftmod_ss7_set_glare_resolution (const char *method); /******************************************************************************/ @@ -239,11 +246,11 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa if (!strcasecmp(var, "dialplan")) { /**********************************************************************/ - /* do i give a shit about this??? */ + /* don't care for now */ /**********************************************************************/ } else if (!strcasecmp(var, "context")) { /**********************************************************************/ - /* do i give a shit about this??? */ + /* don't care for now */ /**********************************************************************/ } else if (!strcasecmp(var, "ccSpanId")) { /**********************************************************************/ @@ -451,6 +458,26 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup) return FTDM_SUCCESS; } +static void ftmod_ss7_set_glare_resolution (const char *method) +{ + sng_glare_resolution iMethod=SNGSS7_GLARE_PC; + if (!method || (strlen (method) <=0) ) { + SS7_ERROR( "Wrong glare resolution parameter, using default. \n" ); + } else { + if (!strcasecmp( method, "PointCode")) { + iMethod = SNGSS7_GLARE_PC; + } else if (!strcasecmp( method, "Down")) { + iMethod = SNGSS7_GLARE_DOWN; + } else if (!strcasecmp( method, "Control")) { + iMethod = SNGSS7_GLARE_CONTROL; + } else { + SS7_ERROR( "Wrong glare resolution parameter, using default. \n" ); + iMethod = SNGSS7_GLARE_DOWN; + } + } + g_ftdm_sngss7_data.cfg.glareResolution = iMethod; +} + /******************************************************************************/ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen) { @@ -463,28 +490,27 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen) /* extract all the information from the parameters */ for (i = 0; i < num_parms; i++) { - /**************************************************************************/ - if (!strcasecmp(parm->var, "procId")) { - /**********************************************************************/ g_ftdm_sngss7_data.cfg.procId = atoi(parm->val); SS7_DEBUG("Found a procId = %d\n", g_ftdm_sngss7_data.cfg.procId); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "license")) { - /**********************************************************************/ + } + else if (!strcasecmp(parm->var, "license")) { ftdm_set_string(g_ftdm_sngss7_data.cfg.license, parm->val); snprintf(g_ftdm_sngss7_data.cfg.signature, sizeof(g_ftdm_sngss7_data.cfg.signature), "%s.sig", parm->val); SS7_DEBUG("Found license file = %s\n", g_ftdm_sngss7_data.cfg.license); SS7_DEBUG("Found signature file = %s\n", g_ftdm_sngss7_data.cfg.signature); - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "transparent_iam_max_size")) { + } + else if (!strcasecmp(parm->var, "transparent_iam_max_size")) { g_ftdm_sngss7_data.cfg.transparent_iam_max_size = atoi(parm->val); SS7_DEBUG("Found a transparent_iam max size = %d\n", g_ftdm_sngss7_data.cfg.transparent_iam_max_size); - } else { - /**********************************************************************/ + } + else if (!strcasecmp(parm->var, "glare-reso")) { + ftmod_ss7_set_glare_resolution (parm->val); + SS7_DEBUG("Found glare resolution configuration = %d %s\n", g_ftdm_sngss7_data.cfg.glareResolution, parm->val ); + } + else { SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); return FTDM_FAIL; - /**********************************************************************/ } /* move to the next parmeter */ From f1d80cd25d13d78deab88ea7f559e63aa899f319 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 16 Mar 2012 16:09:54 -0400 Subject: [PATCH 11/26] freetdm: fixing default values for ISUP --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index ad47f0cbb4..230476d8e1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -2788,7 +2788,7 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t1 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t1 = sng_isap->t1; } else { - g_ftdm_sngss7_data.cfg.isap[i].t1 = 200; + g_ftdm_sngss7_data.cfg.isap[i].t1 = 150; } if (sng_isap->t2 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t2 = sng_isap->t2; @@ -2803,17 +2803,17 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t6 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t6 = sng_isap->t6; } else { - g_ftdm_sngss7_data.cfg.isap[i].t6 = 200; + g_ftdm_sngss7_data.cfg.isap[i].t6 = 600; } if (sng_isap->t7 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t7 = sng_isap->t7; } else { - g_ftdm_sngss7_data.cfg.isap[i].t7 = 250; + g_ftdm_sngss7_data.cfg.isap[i].t7 = 200; } if (sng_isap->t8 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t8 = sng_isap->t8; } else { - g_ftdm_sngss7_data.cfg.isap[i].t8 = 120; + g_ftdm_sngss7_data.cfg.isap[i].t8 = 100; } if (sng_isap->t9 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t9 = sng_isap->t9; From e560ddccdec0232a040851f088db1adec2cbc7f4 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Tue, 20 Mar 2012 11:56:29 -0400 Subject: [PATCH 12/26] freeswitch: taking out -Ox cflags and have them replaced with -O0 we dont want to optimize out symbols for debugging --- build/config/ax_cc_maxopt.m4 | 16 ++++++------ libs/apr/build/NWGNUenvironment.inc | 2 +- libs/apr/build/apr_hints.m4 | 2 +- libs/apr/configure.in | 8 +++--- libs/broadvoice/configure.ac | 8 +++--- libs/broadvoice/debian/rules | 2 +- libs/curl/lib/Makefile.b32 | 2 +- libs/curl/lib/Makefile.m32 | 2 +- libs/curl/src/Makefile.b32 | 2 +- libs/curl/src/makefile.amiga | 2 +- libs/js/nsprpub/configure.in | 20 +++++++------- libs/libg722_1/configure.ac | 8 +++--- libs/libsndfile/INSTALL | 2 +- libs/pcre/configure.ac | 10 +++---- libs/portaudio/Makefile.darwin | 2 +- libs/portaudio/SConstruct | 2 +- .../bindings/cpp/build/gnu/configure | 14 +++++----- .../bindings/cpp/build/gnu/configure.ac | 2 +- libs/portaudio/bindings/cpp/configure.ac | 2 +- libs/portaudio/build/dev-cpp/Makefile-static | 6 ++--- libs/portaudio/configure.in | 2 +- libs/sqlite/Makefile.linux-gcc | 6 ++--- libs/sqlite/mkso.sh | 2 +- libs/sqlite/publish.sh | 2 +- libs/srtp/INSTALL | 2 +- libs/srtp/build/config/ax_cc_maxopt.m4 | 16 ++++++------ libs/srtp/configure.in | 10 +++---- libs/yaml/aclocal.m4 | 2 +- libs/yaml/configure | 18 ++++++------- src/mod/applications/mod_avmd/Makefile | 4 +-- .../endpoints/mod_gsmopen/asterisk/Makefile | 2 +- .../gsmlib-1.10-patched-12ubuntu1/configure | 26 +++++++++---------- src/mod/languages/mod_lua/lua/Makefile | 4 +-- 33 files changed, 105 insertions(+), 105 deletions(-) diff --git a/build/config/ax_cc_maxopt.m4 b/build/config/ax_cc_maxopt.m4 index 6205ee84c8..40bb95c8b7 100644 --- a/build/config/ax_cc_maxopt.m4 +++ b/build/config/ax_cc_maxopt.m4 @@ -10,7 +10,7 @@ AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disa if test "$ac_test_CFLAGS" != "set"; then CFLAGS="" case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" + dec) CFLAGS="-newc -w0 -O0 -ansi_alias -ansi_args -fp_reorder -tune host" if test "x$acx_maxopt_portable" = xno; then CFLAGS="$CFLAGS -arch host" fi;; @@ -31,13 +31,13 @@ if test "$ac_test_CFLAGS" != "set"; then xlc_opt="-qtune=auto" fi AX_CHECK_COMPILER_FLAGS($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" + CFLAGS="-O0 -qansialias -w $xlc_opt", + [CFLAGS="-O0 -qansialias -w" echo "******************************************************" echo "* You seem to have the IBM C compiler. It is *" echo "* recommended for best performance that you use: *" echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" + echo "* CFLAGS=-O0 -qarch=xxx -qtune=xxx -qansialias -w *" echo "* ^^^ ^^^ *" echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" echo "* CPU you have. (Set the CFLAGS environment var. *" @@ -45,7 +45,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "******************************************************"]) ;; - intel) CFLAGS="-O3 -ansi_alias" + intel) CFLAGS="-O0 -ansi_alias" if test "x$acx_maxopt_portable" = xno; then icc_archflag=unknown icc_flags="" @@ -78,7 +78,7 @@ if test "$ac_test_CFLAGS" != "set"; then gnu) # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" + CFLAGS="-O0 -fomit-frame-pointer" # -malign-double for x86 systems AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double") @@ -99,10 +99,10 @@ if test "$ac_test_CFLAGS" != "set"; then echo "********************************************************" echo "* WARNING: Don't know the best CFLAGS for this system *" echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" + echo "* (otherwise, a default of CFLAGS=-O0 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O3" + CFLAGS="-O0" fi AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [ diff --git a/libs/apr/build/NWGNUenvironment.inc b/libs/apr/build/NWGNUenvironment.inc index fd54b487c9..884330fbb7 100644 --- a/libs/apr/build/NWGNUenvironment.inc +++ b/libs/apr/build/NWGNUenvironment.inc @@ -161,7 +161,7 @@ endif # -O4,p level 4 optimizations, optimize for speed ifeq "$(RELEASE)" "optimized" -CFLAGS += -O4,p +CFLAGS += -O0,p endif # -prefix apr_arch_pre_nw.h #include pre_nw.h for all files diff --git a/libs/apr/build/apr_hints.m4 b/libs/apr/build/apr_hints.m4 index 1347653659..a7011db555 100644 --- a/libs/apr/build/apr_hints.m4 +++ b/libs/apr/build/apr_hints.m4 @@ -326,7 +326,7 @@ dnl # Not a problem in 10.20. Otherwise, who knows? ;; *convex-v11*) APR_ADDTO(CPPFLAGS, [-DCONVEXOS11]) - APR_SETIFNULL(CFLAGS, [-O1]) + APR_SETIFNULL(CFLAGS, [-O0]) APR_ADDTO(CFLAGS, [-ext]) ;; i860-intel-osf1) diff --git a/libs/apr/configure.in b/libs/apr/configure.in index 68c030e124..a1d375d768 100644 --- a/libs/apr/configure.in +++ b/libs/apr/configure.in @@ -239,7 +239,7 @@ nl=' ' echo "${nl}Check for compiler flags..." -dnl AC_PROG_CC sets -g in CFLAGS (and -O2 for gcc) by default. +dnl AC_PROG_CC sets -g in CFLAGS (and -O0 for gcc) by default. dnl On OS/390 this causes the compiler to insert extra debugger dnl hook instructions. That's fine for debug/maintainer builds, not fine dnl otherwise. @@ -287,8 +287,8 @@ AC_ARG_ENABLE(profile,[ --enable-profile Turn on profiling for the build APR_ADDTO(CFLAGS, -pg) APR_REMOVEFROM(CFLAGS, -g) if test "$host" = "i586-pc-beos"; then - APR_REMOVEFROM(CFLAGS, -O2) - APR_ADDTO(CFLAGS, -O1) + APR_REMOVEFROM(CFLAGS, -O0) + APR_ADDTO(CFLAGS, -O0) APR_ADDTO(LDFLAGS, -p) fi fi @@ -340,7 +340,7 @@ AC_ARG_ENABLE(pool-debug, if test "$host" = "i586-pc-beos"; then AC_ARG_ENABLE(malloc-debug,[ --enable-malloc-debug Switch on malloc_debug for BeOS], - APR_REMOVEFROM(CFLAGS, -O2) + APR_REMOVEFROM(CFLAGS, -O0) APR_ADDTO(CPPFLAGS, -fcheck-memory-usage -D_KERNEL_MODE) ) dnl fi diff --git a/libs/broadvoice/configure.ac b/libs/broadvoice/configure.ac index ceb92a57cb..10d279ed8a 100644 --- a/libs/broadvoice/configure.ac +++ b/libs/broadvoice/configure.ac @@ -71,9 +71,9 @@ then CC_FOR_BUILD=${CC_FOR_BUILD-gcc} CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O0"} CXX=${CXX-${host_alias}-c++} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CXXFLAGS=${CXXFLAGS-"-g -O0"} else # Set reasonable default values for some tools even if not Canadian. # Of course, these are different reasonable default values, originally @@ -108,8 +108,8 @@ else fi CXX=${CXX-"c++"} - CFLAGS=${CFLAGS-"-g -O2"} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O0"} + CXXFLAGS=${CXXFLAGS-"-g -O0"} fi AC_DEFUN([REMOVE_FROM_VAR],[ diff --git a/libs/broadvoice/debian/rules b/libs/broadvoice/debian/rules index 636e1b42ae..b4f11d6876 100644 --- a/libs/broadvoice/debian/rules +++ b/libs/broadvoice/debian/rules @@ -21,7 +21,7 @@ CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else - CFLAGS += -O2 + CFLAGS += -O0 endif include /usr/share/dpatch/dpatch.make diff --git a/libs/curl/lib/Makefile.b32 b/libs/curl/lib/Makefile.b32 index 4544d7e7be..97c27ddf12 100644 --- a/libs/curl/lib/Makefile.b32 +++ b/libs/curl/lib/Makefile.b32 @@ -35,7 +35,7 @@ RM = del LIB = tlib IMPLIB = implib -CXXFLAGS = -q -5 -O2 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM +CXXFLAGS = -q -5 -O0 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM LIBFLAGS = /C /P32 LDFLAGS = -q -lq -laa -tWD diff --git a/libs/curl/lib/Makefile.m32 b/libs/curl/lib/Makefile.m32 index 77085c6b08..1e7977f24c 100644 --- a/libs/curl/lib/Makefile.m32 +++ b/libs/curl/lib/Makefile.m32 @@ -26,7 +26,7 @@ STRIP = strip -g ## Nothing more to do below this line! INCLUDES = -I. -I../include -CFLAGS = -g -O2 -DMINGW32 -DBUILDING_LIBCURL -DHAVE_LONGLONG +CFLAGS = -g -O0 -DMINGW32 -DBUILDING_LIBCURL -DHAVE_LONGLONG ifdef SSL INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl" CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \ diff --git a/libs/curl/src/Makefile.b32 b/libs/curl/src/Makefile.b32 index d4c1a073c9..b7ad61733a 100644 --- a/libs/curl/src/Makefile.b32 +++ b/libs/curl/src/Makefile.b32 @@ -32,7 +32,7 @@ CP = copy RM = del LIB = tlib -CXXFLAGS = -q -5 -O2 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM +CXXFLAGS = -q -5 -O0 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM LDFLAGS = -q -lq -lap INCDIRS = -I.;../include;../lib diff --git a/libs/curl/src/makefile.amiga b/libs/curl/src/makefile.amiga index 9e03e070f0..15234d422c 100755 --- a/libs/curl/src/makefile.amiga +++ b/libs/curl/src/makefile.amiga @@ -8,7 +8,7 @@ ATCPSDKI= /GG/netinclude CC = m68k-amigaos-gcc -CFLAGS = -I$(ATCPSDKI) -m68020-60 -O2 -msoft-float -noixemul -g -I. -I../include -W -Wall +CFLAGS = -I$(ATCPSDKI) -m68020-60 -O0 -msoft-float -noixemul -g -I. -I../include -W -Wall LIBS = ../lib/libcurl.a -lssl -lcrypto -lz MANPAGE = ../docs/curl.1 README = ../docs/MANUAL diff --git a/libs/js/nsprpub/configure.in b/libs/js/nsprpub/configure.in index 93d3bd9f85..b3fcffe60c 100644 --- a/libs/js/nsprpub/configure.in +++ b/libs/js/nsprpub/configure.in @@ -62,7 +62,7 @@ USE_CPLUS= USE_IPV6= USE_MDUPDATE= _MACOSX_DEPLOYMENT_TARGET= -_OPTIMIZE_FLAGS=-O +_OPTIMIZE_FLAGS=-O0 _DEBUG_FLAGS=-g MOZ_DEBUG=1 MOZ_OPTIMIZE= @@ -176,7 +176,7 @@ AC_ARG_WITH(mozilla, fi]) AC_ARG_ENABLE(optimize, - [ --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ], + [ --enable-optimize(=val) Enable code optimizations (val, ie. -O0) ], [ if test "$enableval" != "no"; then MOZ_OPTIMIZE=1 if test -n "$enableval" && test "$enableval" != "yes"; then @@ -887,7 +887,7 @@ case "$target" in RESOLVE_LINK_SYMBOLS=1 case "${target_cpu}" in i*86) - _OPTIMIZE_FLAGS=-O2 + _OPTIMIZE_FLAGS=-O0 _DEBUG_FLAGS='-gdwarf-2 -O0' MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"]) @@ -897,7 +897,7 @@ case "$target" in CCC=mwcc LD=mwld DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' - _OPTIMIZE_FLAGS=-O2 + _OPTIMIZE_FLAGS=-O0 _DEBUG_FLAGS='-g -O0' ;; esac @@ -1115,7 +1115,7 @@ tools are selected during the Xcode/Developer Tools installation.]) AC_DEFINE(_DGUX_SOURCE) AC_DEFINE(_POSIX4A_DRAFT6_SOURCE) DSO_LDOPTS=-G - _OPTIMIZE_FLAGS=-O2 + _OPTIMIZE_FLAGS=-O0 _DEBUG_FLAGS= MDCPUCFG_H=_dgux.cfg PR_MD_CSRCS=dgux.c @@ -1334,7 +1334,7 @@ tools are selected during the Xcode/Developer Tools installation.]) dnl AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' CFLAGS="$CFLAGS -Wall -Wno-format" - _OPTIMIZE_FLAGS="-O6" + _OPTIMIZE_FLAGS="-O0" else if test -n "$USE_N32"; then AS='as -D_ASM $(INCLUDES) -n32' @@ -1408,7 +1408,7 @@ tools are selected during the Xcode/Developer Tools installation.]) MKSHLIB='$(CC) $(DSO_LDOPTS) $(OS_LDFLAGS) -o $@' DSO_CFLAGS=-fPIC DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - _OPTIMIZE_FLAGS=-O2 + _OPTIMIZE_FLAGS=-O0 _DEBUG_FLAGS="-g" # most people on linux use gcc/gdb, and that # combo is not yet good at debugging inlined # functions (even when using DWARF2 as the @@ -1485,7 +1485,7 @@ tools are selected during the Xcode/Developer Tools installation.]) CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" DLLFLAGS='-OUT:"$@"' _DEBUG_FLAGS=-Z7 - _OPTIMIZE_FLAGS=-O2 + _OPTIMIZE_FLAGS=-O0 if test -z "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS -Od" fi @@ -1724,7 +1724,7 @@ mips-sony-newsos*) DSO_CFLAGS=-fPIC DSO_LDOPTS=-shared OS_LIBS="$OS_LIBS -lsocket" - _OPTIMIZE_FLAGS="-O1" + _OPTIMIZE_FLAGS="-O0" _DEBUG_FLAGS="-gstabs" ;; @@ -2082,7 +2082,7 @@ mips-sony-newsos*) DSO_CFLAGS= DSO_LDOPTS='-Zomf -Zdll -Zmap' LDFLAGS='-Zmap' - _OPTIMIZE_FLAGS="-O2 -s" + _OPTIMIZE_FLAGS="-O0 -s" _DEBUG_FLAGS="-g -fno-inline" if test -n "$MOZ_OPTIMIZE"; then DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" diff --git a/libs/libg722_1/configure.ac b/libs/libg722_1/configure.ac index 62095ce374..e5385d4091 100644 --- a/libs/libg722_1/configure.ac +++ b/libs/libg722_1/configure.ac @@ -64,9 +64,9 @@ then CC_FOR_BUILD=${CC_FOR_BUILD-gcc} CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O0"} CXX=${CXX-${host_alias}-c++} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CXXFLAGS=${CXXFLAGS-"-g -O0"} else # Set reasonable default values for some tools even if not Canadian. # Of course, these are different reasonable default values, originally @@ -101,8 +101,8 @@ else fi CXX=${CXX-"c++"} - CFLAGS=${CFLAGS-"-g -O2"} - CXXFLAGS=${CXXFLAGS-"-g -O2"} + CFLAGS=${CFLAGS-"-g -O0"} + CXXFLAGS=${CXXFLAGS-"-g -O0"} fi AC_DEFUN([REMOVE_FROM_VAR],[ diff --git a/libs/libsndfile/INSTALL b/libs/libsndfile/INSTALL index b42a17ac46..d520a54b6b 100644 --- a/libs/libsndfile/INSTALL +++ b/libs/libsndfile/INSTALL @@ -59,7 +59,7 @@ the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + CC=c89 CFLAGS=-O0 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure diff --git a/libs/pcre/configure.ac b/libs/pcre/configure.ac index b6f79f98cf..7bf7c95b35 100644 --- a/libs/pcre/configure.ac +++ b/libs/pcre/configure.ac @@ -26,7 +26,7 @@ CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" -# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just +# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O0" for gcc and just # "-g" for any other compiler. There doesn't seem to be a standard way of # getting rid of the -g (which I don't think is needed for a production # library). This fudge seems to achieve the necessary. First, we remember the @@ -44,9 +44,9 @@ AC_PROG_CXX if test "x$remember_set_CFLAGS" = "x" then - if test "$CFLAGS" = "-g -O2" + if test "$CFLAGS" = "-g -O0" then - CFLAGS="-O2" + CFLAGS="-O0" elif test "$CFLAGS" = "-g" then CFLAGS="" @@ -55,9 +55,9 @@ fi if test "x$remember_set_CXXFLAGS" = "x" then - if test "$CXXFLAGS" = "-g -O2" + if test "$CXXFLAGS" = "-g -O0" then - CXXFLAGS="-O2" + CXXFLAGS="-O0" elif test "$CXXFLAGS" = "-g" then CXXFLAGS="" diff --git a/libs/portaudio/Makefile.darwin b/libs/portaudio/Makefile.darwin index 9aec51de24..0d37963f04 100644 --- a/libs/portaudio/Makefile.darwin +++ b/libs/portaudio/Makefile.darwin @@ -11,7 +11,7 @@ top_srcdir = . srcdir = . top_builddir = . -OPT_LEVEL := -O2 +OPT_LEVEL := -O0 PREFIX = /usr/local prefix = $(PREFIX) exec_prefix = ${prefix} diff --git a/libs/portaudio/SConstruct b/libs/portaudio/SConstruct index 15d36bad57..3c4bca0df7 100644 --- a/libs/portaudio/SConstruct +++ b/libs/portaudio/SConstruct @@ -39,7 +39,7 @@ if Platform in Posix: baseLinkFlags = threadCFlags = "-pthread" baseCxxFlags = baseCFlags = "-Wall -pedantic -pipe " + threadCFlags debugCxxFlags = debugCFlags = "-g" - optCxxFlags = optCFlags = "-O2" + optCxxFlags = optCFlags = "-O0" env["CCFLAGS"] = baseCFlags.split() env["CXXFLAGS"] = baseCxxFlags.split() env["LINKFLAGS"] = baseLinkFlags.split() diff --git a/libs/portaudio/bindings/cpp/build/gnu/configure b/libs/portaudio/bindings/cpp/build/gnu/configure index 69070c66d4..e91013c07c 100644 --- a/libs/portaudio/bindings/cpp/build/gnu/configure +++ b/libs/portaudio/bindings/cpp/build/gnu/configure @@ -1263,7 +1263,7 @@ PORTAUDIO="$PACPP_ROOT/../portaudio" PACPP_INC="$PACPP_ROOT/include" INCLUDES="-I$PACPP_INC -I$PORTAUDIO -I$PORTAUDIO/pa_common" -CFLAGS="-g -O2 -Wall -ansi -pedantic $INCLUDES" +CFLAGS="-g -O0 -Wall -ansi -pedantic $INCLUDES" CXXFLAGS="$CFLAGS" PALIBDIR="$PORTAUDIO/lib" @@ -1908,13 +1908,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O2" + CFLAGS="-g -O0" else - CFLAGS="-g" + CFLAGS="-g -O0" fi else if test "$GCC" = yes; then - CFLAGS="-O2" + CFLAGS="-O0" else CFLAGS= fi @@ -2350,13 +2350,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O2" + CXXFLAGS="-g -O0" else - CXXFLAGS="-g" + CXXFLAGS="-g -O0" fi else if test "$GXX" = yes; then - CXXFLAGS="-O2" + CXXFLAGS="-O0" else CXXFLAGS= fi diff --git a/libs/portaudio/bindings/cpp/build/gnu/configure.ac b/libs/portaudio/bindings/cpp/build/gnu/configure.ac index 5457c53420..071a7e94ef 100644 --- a/libs/portaudio/bindings/cpp/build/gnu/configure.ac +++ b/libs/portaudio/bindings/cpp/build/gnu/configure.ac @@ -24,7 +24,7 @@ PORTAUDIO="$PACPP_ROOT/../portaudio" PACPP_INC="$PACPP_ROOT/include" INCLUDES="-I$PACPP_INC -I$PORTAUDIO -I$PORTAUDIO/pa_common" -CFLAGS="-g -O2 -Wall -ansi -pedantic $INCLUDES" +CFLAGS="-g -O0 -Wall -ansi -pedantic $INCLUDES" CXXFLAGS="$CFLAGS" PALIBDIR="$PORTAUDIO/lib" diff --git a/libs/portaudio/bindings/cpp/configure.ac b/libs/portaudio/bindings/cpp/configure.ac index 100656ac41..94baff8fc3 100644 --- a/libs/portaudio/bindings/cpp/configure.ac +++ b/libs/portaudio/bindings/cpp/configure.ac @@ -25,7 +25,7 @@ PORTAUDIO_ROOT="../.." # Various other variables and flags DEFAULT_INCLUDES="-I$PACPP_ROOT/include -I$PACPP_ROOT/$PORTAUDIO_ROOT/include" -CFLAGS=${CFLAGS-"-g -O2 -Wall -ansi -pedantic"} +CFLAGS=${CFLAGS-"-g -O0 -Wall -ansi -pedantic"} CXXFLAGS=${CXXFLAGS-"${CFLAGS}"} LT_VERSION_INFO="lt_current:lt_revision:lt_age" diff --git a/libs/portaudio/build/dev-cpp/Makefile-static b/libs/portaudio/build/dev-cpp/Makefile-static index 2a1647ddc5..65fcb5dacf 100644 --- a/libs/portaudio/build/dev-cpp/Makefile-static +++ b/libs/portaudio/build/dev-cpp/Makefile-static @@ -7,12 +7,12 @@ WINDRES = windres.exe RES = OBJ = ./pa_skeleton.o ./pa_stream.o ./pa_trace.o ./pa_allocation.o ./pa_converters.o ./pa_cpuload.o ./pa_dither.o ./pa_front.o ./pa_process.o ./pa_asio.o ./pa_win_util.o ./pa_win_hostapis.o ./pa_win_ds.o ./dsound_wrapper.o ./pa_win_wmme.o ./iasiothiscallresolver.o $(RES) LINKOBJ = ./pa_skeleton.o ./pa_stream.o ./pa_trace.o ./pa_allocation.o ./pa_converters.o ./pa_cpuload.o ./pa_dither.o ./pa_front.o ./pa_process.o ./pa_asio.o ./pa_win_util.o ./pa_win_hostapis.o ./pa_win_ds.o ./dsound_wrapper.o ./pa_win_wmme.o ./iasiothiscallresolver.o $(RES) -LIBS = -L"C:/Dev-CPP/lib" -fmessage-length=0 -O3 -s +LIBS = -L"C:/Dev-CPP/lib" -fmessage-length=0 -O0 -s INCS = -I"C:/Dev-CPP/include" -I"../../../asiosdk2" -I"../../../asiosdk2/common" -I"../../../asiosdk2/host" -I"../../../asiosdk2/host/pc" -I"../../pa_common" CXXINCS = -I"C:/Dev-CPP/include/c++" -I"C:/Dev-CPP/include/c++/mingw32" -I"C:/Dev-CPP/include/c++/backward" -I"C:/Dev-CPP/include" -I"../../../asiosdk2" -I"../../../asiosdk2/common" -I"../../../asiosdk2/host" -I"../../../asiosdk2/host/pc" -I"../../pa_common" BIN = portaudio-static.a -CXXFLAGS = $(CXXINCS)-O3 -fmessage-length=0 -Wall -CFLAGS = $(INCS)-O3 -fmessage-length=0 -Wall +CXXFLAGS = $(CXXINCS)-O0 -fmessage-length=0 -Wall +CFLAGS = $(INCS)-O0 -fmessage-length=0 -Wall .PHONY: all all-before all-after clean clean-custom diff --git a/libs/portaudio/configure.in b/libs/portaudio/configure.in index f4ef9abbee..24deaf701c 100644 --- a/libs/portaudio/configure.in +++ b/libs/portaudio/configure.in @@ -130,7 +130,7 @@ AC_SUBST(CXXFLAGS) AC_SUBST(NASM) AC_SUBST(NASMOPT) -CFLAGS=${CFLAGS:-"-g -O2 -Wall -pedantic -pipe -fPIC"} +CFLAGS=${CFLAGS:-"-g -O0 -Wall -pedantic -pipe -fPIC"} if [[ $ac_cv_c_bigendian = "yes" ]] ; then CFLAGS="$CFLAGS -DPA_BIG_ENDIAN" diff --git a/libs/sqlite/Makefile.linux-gcc b/libs/sqlite/Makefile.linux-gcc index c865024b44..e3a3d385dd 100644 --- a/libs/sqlite/Makefile.linux-gcc +++ b/libs/sqlite/Makefile.linux-gcc @@ -19,7 +19,7 @@ TOP = ../sqlite #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # -BCC = gcc -g -O2 +BCC = gcc -g -O0 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system @@ -70,10 +70,10 @@ EXE = # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # -TCC = gcc -O6 +TCC = gcc -O0 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage -#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6 +#TCC = /opt/mingw/bin/i386-mingw32-gcc -O0 #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. diff --git a/libs/sqlite/mkso.sh b/libs/sqlite/mkso.sh index 9050d74255..d6afb0198d 100755 --- a/libs/sqlite/mkso.sh +++ b/libs/sqlite/mkso.sh @@ -14,7 +14,7 @@ TCLSTUBLIB=$TCLDIR/libtclstub8.4g.a OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DHAVE_DLOPEN=1' for i in *.c; do if test $i != 'keywordhash.c'; then - CMD="cc -fPIC $OPTS -O2 -I. -I$TCLDIR -c $i" + CMD="cc -fPIC $OPTS -O0 -I. -I$TCLDIR -c $i" echo $CMD $CMD fi diff --git a/libs/sqlite/publish.sh b/libs/sqlite/publish.sh index 043c89a039..68d7c7f6e8 100755 --- a/libs/sqlite/publish.sh +++ b/libs/sqlite/publish.sh @@ -66,7 +66,7 @@ make target_source cd tsrc rm tclsqlite.c OPTS='-DSTATIC_BUILD=1 -DNDEBUG=1' -i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR *.c -o sqlite3.exe +i386-mingw32msvc-gcc -O0 $OPTS -I. -I$TCLDIR *.c -o sqlite3.exe zip ../doc/sqlite-$VERSW.zip sqlite3.exe cd .. diff --git a/libs/srtp/INSTALL b/libs/srtp/INSTALL index 23e5f25d0e..7d2c51bb9d 100644 --- a/libs/srtp/INSTALL +++ b/libs/srtp/INSTALL @@ -78,7 +78,7 @@ details on some of the pertinent environment variables. by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c89 CFLAGS=-O0 LIBS=-lposix *Note Defining Variables::, for more details. diff --git a/libs/srtp/build/config/ax_cc_maxopt.m4 b/libs/srtp/build/config/ax_cc_maxopt.m4 index 6205ee84c8..40bb95c8b7 100644 --- a/libs/srtp/build/config/ax_cc_maxopt.m4 +++ b/libs/srtp/build/config/ax_cc_maxopt.m4 @@ -10,7 +10,7 @@ AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disa if test "$ac_test_CFLAGS" != "set"; then CFLAGS="" case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" + dec) CFLAGS="-newc -w0 -O0 -ansi_alias -ansi_args -fp_reorder -tune host" if test "x$acx_maxopt_portable" = xno; then CFLAGS="$CFLAGS -arch host" fi;; @@ -31,13 +31,13 @@ if test "$ac_test_CFLAGS" != "set"; then xlc_opt="-qtune=auto" fi AX_CHECK_COMPILER_FLAGS($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" + CFLAGS="-O0 -qansialias -w $xlc_opt", + [CFLAGS="-O0 -qansialias -w" echo "******************************************************" echo "* You seem to have the IBM C compiler. It is *" echo "* recommended for best performance that you use: *" echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" + echo "* CFLAGS=-O0 -qarch=xxx -qtune=xxx -qansialias -w *" echo "* ^^^ ^^^ *" echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" echo "* CPU you have. (Set the CFLAGS environment var. *" @@ -45,7 +45,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "******************************************************"]) ;; - intel) CFLAGS="-O3 -ansi_alias" + intel) CFLAGS="-O0 -ansi_alias" if test "x$acx_maxopt_portable" = xno; then icc_archflag=unknown icc_flags="" @@ -78,7 +78,7 @@ if test "$ac_test_CFLAGS" != "set"; then gnu) # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" + CFLAGS="-O0 -fomit-frame-pointer" # -malign-double for x86 systems AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double") @@ -99,10 +99,10 @@ if test "$ac_test_CFLAGS" != "set"; then echo "********************************************************" echo "* WARNING: Don't know the best CFLAGS for this system *" echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" + echo "* (otherwise, a default of CFLAGS=-O0 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O3" + CFLAGS="-O0" fi AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [ diff --git a/libs/srtp/configure.in b/libs/srtp/configure.in index 2495a55f95..8584be880e 100644 --- a/libs/srtp/configure.in +++ b/libs/srtp/configure.in @@ -49,7 +49,7 @@ case "$host" in IN_LINE="" elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" IN_LINE=inline fi @@ -71,7 +71,7 @@ case "$host" in FUNC_DEF=__func__ elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" fi DYNAMIC_LIB_EXTEN="so" @@ -84,20 +84,20 @@ case "$host" in FUNC_DEF=__func__ elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fpic -Wall -O4 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fpic -Wall -O0 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" fi DYNAMIC_LIB_EXTEN="so" ;; i*6*-*-freebsd*) SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" DYNAMIC_LIB_EXTEN="so" ;; x86_64-*-freebsd*|amd64-*-freebsd*) SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" DYNAMIC_LIB_EXTEN="so" ;; diff --git a/libs/yaml/aclocal.m4 b/libs/yaml/aclocal.m4 index b7984f0f01..ba1ed63878 100644 --- a/libs/yaml/aclocal.m4 +++ b/libs/yaml/aclocal.m4 @@ -6311,7 +6311,7 @@ ifelse([AC_DISABLE_FAST_INSTALL]) AC_DEFUN([LT_AC_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj, no) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O0" AC_SUBST(GCJFLAGS) ]) diff --git a/libs/yaml/configure b/libs/yaml/configure index 66e708215a..f66fa4972c 100755 --- a/libs/yaml/configure +++ b/libs/yaml/configure @@ -3222,13 +3222,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O2" + CFLAGS="-g -O0" else - CFLAGS="-g" + CFLAGS="-g -O0" fi else if test "$GCC" = yes; then - CFLAGS="-O2" + CFLAGS="-O0" else CFLAGS= fi @@ -5579,13 +5579,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O2" + CXXFLAGS="-g -O0" else - CXXFLAGS="-g" + CXXFLAGS="-g -O0" fi else if test "$GXX" = yes; then - CXXFLAGS="-O2" + CXXFLAGS="-O0" else CXXFLAGS= fi @@ -6180,13 +6180,13 @@ if test "$ac_test_FFLAGS" = set; then FFLAGS=$ac_save_FFLAGS elif test $ac_cv_prog_f77_g = yes; then if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O2" + FFLAGS="-g -O0" else - FFLAGS="-g" + FFLAGS="-g -O0" fi else if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O2" + FFLAGS="-O0" else FFLAGS= fi diff --git a/src/mod/applications/mod_avmd/Makefile b/src/mod/applications/mod_avmd/Makefile index c4a62d4120..fbf7ccb023 100644 --- a/src/mod/applications/mod_avmd/Makefile +++ b/src/mod/applications/mod_avmd/Makefile @@ -1,6 +1,6 @@ BASE=../../../.. -MOD_CFLAGS= -O2 -#MOD_CFLAGS= -march=core2 -g -O2 -malign-double -mtune=core2 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -ffast-math -funroll-loops -fprefetch-loop-arrays -funit-at-a-time -ftracer --save-temps +MOD_CFLAGS= -O0 +#MOD_CFLAGS= -march=core2 -g -O0 -malign-double -mtune=core2 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -ffast-math -funroll-loops -fprefetch-loop-arrays -funit-at-a-time -ftracer --save-temps #MOD_LDFLAGS= --save-temps LOCAL_SOURCES=amplitude.c buffer.c desa2.c goertzel.c fast_acosf.c LOCAL_OBJS=amplitude.o buffer.o desa2.o goertzel.o fast_acosf.o diff --git a/src/mod/endpoints/mod_gsmopen/asterisk/Makefile b/src/mod/endpoints/mod_gsmopen/asterisk/Makefile index 6aed86266e..f1b2d54450 100644 --- a/src/mod/endpoints/mod_gsmopen/asterisk/Makefile +++ b/src/mod/endpoints/mod_gsmopen/asterisk/Makefile @@ -33,7 +33,7 @@ CFLAGS+=-g3 CFLAGS+=-I$(AST_INCLUDE_DIR) -I. CFLAGS+=-D_REENTRANT -D_GNU_SOURCE -#CFLAGS+=-O6 +#CFLAGS+=-O0 #CFLAGS+=-march=i586 CFLAGS+=-fomit-frame-pointer ifeq ($(shell uname -m),x86_64) diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure index 5918af81fb..23bae83868 100755 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure @@ -2261,13 +2261,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O2" + CFLAGS="-g -O0" else - CFLAGS="-g" + CFLAGS="-g -O0" fi else if test "$GCC" = yes; then - CFLAGS="-O2" + CFLAGS="-O0" else CFLAGS= fi @@ -3144,7 +3144,7 @@ fi; if test "$CXXFLAGS" = ""; then - CXXFLAGS="-O2" + CXXFLAGS="-O0" fi @@ -4748,13 +4748,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O2" + CXXFLAGS="-g -O0" else - CXXFLAGS="-g" + CXXFLAGS="-g -O0" fi else if test "$GXX" = yes; then - CXXFLAGS="-O2" + CXXFLAGS="-O0" else CXXFLAGS= fi @@ -5431,13 +5431,13 @@ if test "$ac_test_FFLAGS" = set; then FFLAGS=$ac_save_FFLAGS elif test $ac_cv_prog_f77_g = yes; then if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O2" + FFLAGS="-g -O0" else - FFLAGS="-g" + FFLAGS="-g -O0" fi else if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O2" + FFLAGS="-O0" else FFLAGS= fi @@ -20153,13 +20153,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O2" + CXXFLAGS="-g -O0" else - CXXFLAGS="-g" + CXXFLAGS="-g -O0" fi else if test "$GXX" = yes; then - CXXFLAGS="-O2" + CXXFLAGS="-O0" else CXXFLAGS= fi diff --git a/src/mod/languages/mod_lua/lua/Makefile b/src/mod/languages/mod_lua/lua/Makefile index e4a3cd6108..4e0b5480d6 100644 --- a/src/mod/languages/mod_lua/lua/Makefile +++ b/src/mod/languages/mod_lua/lua/Makefile @@ -8,7 +8,7 @@ PLAT= none CC= gcc -CFLAGS= -O2 -Wall $(MYCFLAGS) +CFLAGS= -O0 -Wall $(MYCFLAGS) AR= ar rcu RANLIB= ranlib RM= rm -f @@ -81,7 +81,7 @@ none: @echo " $(PLATS)" aix: - $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + $(MAKE) all CC="xlc" CFLAGS="-O0 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" ansi: $(MAKE) all MYCFLAGS=-DLUA_ANSI From 012bc154b07aec248fe4b91581ba1a5ea1d3f0d9 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 21 Mar 2012 10:00:27 -0400 Subject: [PATCH 13/26] Revert "freetdm: fixing default values for ISUP" This reverts commit f1d80cd25d13d78deab88ea7f559e63aa899f319. --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index 230476d8e1..ad47f0cbb4 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -2788,7 +2788,7 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t1 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t1 = sng_isap->t1; } else { - g_ftdm_sngss7_data.cfg.isap[i].t1 = 150; + g_ftdm_sngss7_data.cfg.isap[i].t1 = 200; } if (sng_isap->t2 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t2 = sng_isap->t2; @@ -2803,17 +2803,17 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t6 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t6 = sng_isap->t6; } else { - g_ftdm_sngss7_data.cfg.isap[i].t6 = 600; + g_ftdm_sngss7_data.cfg.isap[i].t6 = 200; } if (sng_isap->t7 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t7 = sng_isap->t7; } else { - g_ftdm_sngss7_data.cfg.isap[i].t7 = 200; + g_ftdm_sngss7_data.cfg.isap[i].t7 = 250; } if (sng_isap->t8 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t8 = sng_isap->t8; } else { - g_ftdm_sngss7_data.cfg.isap[i].t8 = 100; + g_ftdm_sngss7_data.cfg.isap[i].t8 = 120; } if (sng_isap->t9 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t9 = sng_isap->t9; From a8e21663ce6684eb665dfddfd1757e76ad13a152 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 21 Mar 2012 10:05:51 -0400 Subject: [PATCH 14/26] Revert "freeswitch: taking out -Ox cflags and have them replaced with -O0" This reverts commit e560ddccdec0232a040851f088db1adec2cbc7f4. --- build/config/ax_cc_maxopt.m4 | 16 ++++++------ libs/apr/build/NWGNUenvironment.inc | 2 +- libs/apr/build/apr_hints.m4 | 2 +- libs/apr/configure.in | 8 +++--- libs/broadvoice/configure.ac | 8 +++--- libs/broadvoice/debian/rules | 2 +- libs/curl/lib/Makefile.b32 | 2 +- libs/curl/lib/Makefile.m32 | 2 +- libs/curl/src/Makefile.b32 | 2 +- libs/curl/src/makefile.amiga | 2 +- libs/js/nsprpub/configure.in | 20 +++++++------- libs/libg722_1/configure.ac | 8 +++--- libs/libsndfile/INSTALL | 2 +- libs/pcre/configure.ac | 10 +++---- libs/portaudio/Makefile.darwin | 2 +- libs/portaudio/SConstruct | 2 +- .../bindings/cpp/build/gnu/configure | 14 +++++----- .../bindings/cpp/build/gnu/configure.ac | 2 +- libs/portaudio/bindings/cpp/configure.ac | 2 +- libs/portaudio/build/dev-cpp/Makefile-static | 6 ++--- libs/portaudio/configure.in | 2 +- libs/sqlite/Makefile.linux-gcc | 6 ++--- libs/sqlite/mkso.sh | 2 +- libs/sqlite/publish.sh | 2 +- libs/srtp/INSTALL | 2 +- libs/srtp/build/config/ax_cc_maxopt.m4 | 16 ++++++------ libs/srtp/configure.in | 10 +++---- libs/yaml/aclocal.m4 | 2 +- libs/yaml/configure | 18 ++++++------- src/mod/applications/mod_avmd/Makefile | 4 +-- .../endpoints/mod_gsmopen/asterisk/Makefile | 2 +- .../gsmlib-1.10-patched-12ubuntu1/configure | 26 +++++++++---------- src/mod/languages/mod_lua/lua/Makefile | 4 +-- 33 files changed, 105 insertions(+), 105 deletions(-) diff --git a/build/config/ax_cc_maxopt.m4 b/build/config/ax_cc_maxopt.m4 index 40bb95c8b7..6205ee84c8 100644 --- a/build/config/ax_cc_maxopt.m4 +++ b/build/config/ax_cc_maxopt.m4 @@ -10,7 +10,7 @@ AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disa if test "$ac_test_CFLAGS" != "set"; then CFLAGS="" case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O0 -ansi_alias -ansi_args -fp_reorder -tune host" + dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" if test "x$acx_maxopt_portable" = xno; then CFLAGS="$CFLAGS -arch host" fi;; @@ -31,13 +31,13 @@ if test "$ac_test_CFLAGS" != "set"; then xlc_opt="-qtune=auto" fi AX_CHECK_COMPILER_FLAGS($xlc_opt, - CFLAGS="-O0 -qansialias -w $xlc_opt", - [CFLAGS="-O0 -qansialias -w" + CFLAGS="-O3 -qansialias -w $xlc_opt", + [CFLAGS="-O3 -qansialias -w" echo "******************************************************" echo "* You seem to have the IBM C compiler. It is *" echo "* recommended for best performance that you use: *" echo "* *" - echo "* CFLAGS=-O0 -qarch=xxx -qtune=xxx -qansialias -w *" + echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" echo "* ^^^ ^^^ *" echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" echo "* CPU you have. (Set the CFLAGS environment var. *" @@ -45,7 +45,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "******************************************************"]) ;; - intel) CFLAGS="-O0 -ansi_alias" + intel) CFLAGS="-O3 -ansi_alias" if test "x$acx_maxopt_portable" = xno; then icc_archflag=unknown icc_flags="" @@ -78,7 +78,7 @@ if test "$ac_test_CFLAGS" != "set"; then gnu) # default optimization flags for gcc on all systems - CFLAGS="-O0 -fomit-frame-pointer" + CFLAGS="-O3 -fomit-frame-pointer" # -malign-double for x86 systems AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double") @@ -99,10 +99,10 @@ if test "$ac_test_CFLAGS" != "set"; then echo "********************************************************" echo "* WARNING: Don't know the best CFLAGS for this system *" echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O0 will be used) *" + echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O0" + CFLAGS="-O3" fi AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [ diff --git a/libs/apr/build/NWGNUenvironment.inc b/libs/apr/build/NWGNUenvironment.inc index 884330fbb7..fd54b487c9 100644 --- a/libs/apr/build/NWGNUenvironment.inc +++ b/libs/apr/build/NWGNUenvironment.inc @@ -161,7 +161,7 @@ endif # -O4,p level 4 optimizations, optimize for speed ifeq "$(RELEASE)" "optimized" -CFLAGS += -O0,p +CFLAGS += -O4,p endif # -prefix apr_arch_pre_nw.h #include pre_nw.h for all files diff --git a/libs/apr/build/apr_hints.m4 b/libs/apr/build/apr_hints.m4 index a7011db555..1347653659 100644 --- a/libs/apr/build/apr_hints.m4 +++ b/libs/apr/build/apr_hints.m4 @@ -326,7 +326,7 @@ dnl # Not a problem in 10.20. Otherwise, who knows? ;; *convex-v11*) APR_ADDTO(CPPFLAGS, [-DCONVEXOS11]) - APR_SETIFNULL(CFLAGS, [-O0]) + APR_SETIFNULL(CFLAGS, [-O1]) APR_ADDTO(CFLAGS, [-ext]) ;; i860-intel-osf1) diff --git a/libs/apr/configure.in b/libs/apr/configure.in index a1d375d768..68c030e124 100644 --- a/libs/apr/configure.in +++ b/libs/apr/configure.in @@ -239,7 +239,7 @@ nl=' ' echo "${nl}Check for compiler flags..." -dnl AC_PROG_CC sets -g in CFLAGS (and -O0 for gcc) by default. +dnl AC_PROG_CC sets -g in CFLAGS (and -O2 for gcc) by default. dnl On OS/390 this causes the compiler to insert extra debugger dnl hook instructions. That's fine for debug/maintainer builds, not fine dnl otherwise. @@ -287,8 +287,8 @@ AC_ARG_ENABLE(profile,[ --enable-profile Turn on profiling for the build APR_ADDTO(CFLAGS, -pg) APR_REMOVEFROM(CFLAGS, -g) if test "$host" = "i586-pc-beos"; then - APR_REMOVEFROM(CFLAGS, -O0) - APR_ADDTO(CFLAGS, -O0) + APR_REMOVEFROM(CFLAGS, -O2) + APR_ADDTO(CFLAGS, -O1) APR_ADDTO(LDFLAGS, -p) fi fi @@ -340,7 +340,7 @@ AC_ARG_ENABLE(pool-debug, if test "$host" = "i586-pc-beos"; then AC_ARG_ENABLE(malloc-debug,[ --enable-malloc-debug Switch on malloc_debug for BeOS], - APR_REMOVEFROM(CFLAGS, -O0) + APR_REMOVEFROM(CFLAGS, -O2) APR_ADDTO(CPPFLAGS, -fcheck-memory-usage -D_KERNEL_MODE) ) dnl fi diff --git a/libs/broadvoice/configure.ac b/libs/broadvoice/configure.ac index 10d279ed8a..ceb92a57cb 100644 --- a/libs/broadvoice/configure.ac +++ b/libs/broadvoice/configure.ac @@ -71,9 +71,9 @@ then CC_FOR_BUILD=${CC_FOR_BUILD-gcc} CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O0"} + CFLAGS=${CFLAGS-"-g -O2"} CXX=${CXX-${host_alias}-c++} - CXXFLAGS=${CXXFLAGS-"-g -O0"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} else # Set reasonable default values for some tools even if not Canadian. # Of course, these are different reasonable default values, originally @@ -108,8 +108,8 @@ else fi CXX=${CXX-"c++"} - CFLAGS=${CFLAGS-"-g -O0"} - CXXFLAGS=${CXXFLAGS-"-g -O0"} + CFLAGS=${CFLAGS-"-g -O2"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} fi AC_DEFUN([REMOVE_FROM_VAR],[ diff --git a/libs/broadvoice/debian/rules b/libs/broadvoice/debian/rules index b4f11d6876..636e1b42ae 100644 --- a/libs/broadvoice/debian/rules +++ b/libs/broadvoice/debian/rules @@ -21,7 +21,7 @@ CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else - CFLAGS += -O0 + CFLAGS += -O2 endif include /usr/share/dpatch/dpatch.make diff --git a/libs/curl/lib/Makefile.b32 b/libs/curl/lib/Makefile.b32 index 97c27ddf12..4544d7e7be 100644 --- a/libs/curl/lib/Makefile.b32 +++ b/libs/curl/lib/Makefile.b32 @@ -35,7 +35,7 @@ RM = del LIB = tlib IMPLIB = implib -CXXFLAGS = -q -5 -O0 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM +CXXFLAGS = -q -5 -O2 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM LIBFLAGS = /C /P32 LDFLAGS = -q -lq -laa -tWD diff --git a/libs/curl/lib/Makefile.m32 b/libs/curl/lib/Makefile.m32 index 1e7977f24c..77085c6b08 100644 --- a/libs/curl/lib/Makefile.m32 +++ b/libs/curl/lib/Makefile.m32 @@ -26,7 +26,7 @@ STRIP = strip -g ## Nothing more to do below this line! INCLUDES = -I. -I../include -CFLAGS = -g -O0 -DMINGW32 -DBUILDING_LIBCURL -DHAVE_LONGLONG +CFLAGS = -g -O2 -DMINGW32 -DBUILDING_LIBCURL -DHAVE_LONGLONG ifdef SSL INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl" CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \ diff --git a/libs/curl/src/Makefile.b32 b/libs/curl/src/Makefile.b32 index b7ad61733a..d4c1a073c9 100644 --- a/libs/curl/src/Makefile.b32 +++ b/libs/curl/src/Makefile.b32 @@ -32,7 +32,7 @@ CP = copy RM = del LIB = tlib -CXXFLAGS = -q -5 -O0 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM +CXXFLAGS = -q -5 -O2 -w-aus -w-ccc -w-csu -w-par -w-pia -w-rch -w-inl -w-ngu -w-pro -tWM LDFLAGS = -q -lq -lap INCDIRS = -I.;../include;../lib diff --git a/libs/curl/src/makefile.amiga b/libs/curl/src/makefile.amiga index 15234d422c..9e03e070f0 100755 --- a/libs/curl/src/makefile.amiga +++ b/libs/curl/src/makefile.amiga @@ -8,7 +8,7 @@ ATCPSDKI= /GG/netinclude CC = m68k-amigaos-gcc -CFLAGS = -I$(ATCPSDKI) -m68020-60 -O0 -msoft-float -noixemul -g -I. -I../include -W -Wall +CFLAGS = -I$(ATCPSDKI) -m68020-60 -O2 -msoft-float -noixemul -g -I. -I../include -W -Wall LIBS = ../lib/libcurl.a -lssl -lcrypto -lz MANPAGE = ../docs/curl.1 README = ../docs/MANUAL diff --git a/libs/js/nsprpub/configure.in b/libs/js/nsprpub/configure.in index b3fcffe60c..93d3bd9f85 100644 --- a/libs/js/nsprpub/configure.in +++ b/libs/js/nsprpub/configure.in @@ -62,7 +62,7 @@ USE_CPLUS= USE_IPV6= USE_MDUPDATE= _MACOSX_DEPLOYMENT_TARGET= -_OPTIMIZE_FLAGS=-O0 +_OPTIMIZE_FLAGS=-O _DEBUG_FLAGS=-g MOZ_DEBUG=1 MOZ_OPTIMIZE= @@ -176,7 +176,7 @@ AC_ARG_WITH(mozilla, fi]) AC_ARG_ENABLE(optimize, - [ --enable-optimize(=val) Enable code optimizations (val, ie. -O0) ], + [ --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ], [ if test "$enableval" != "no"; then MOZ_OPTIMIZE=1 if test -n "$enableval" && test "$enableval" != "yes"; then @@ -887,7 +887,7 @@ case "$target" in RESOLVE_LINK_SYMBOLS=1 case "${target_cpu}" in i*86) - _OPTIMIZE_FLAGS=-O0 + _OPTIMIZE_FLAGS=-O2 _DEBUG_FLAGS='-gdwarf-2 -O0' MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"]) @@ -897,7 +897,7 @@ case "$target" in CCC=mwcc LD=mwld DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o' - _OPTIMIZE_FLAGS=-O0 + _OPTIMIZE_FLAGS=-O2 _DEBUG_FLAGS='-g -O0' ;; esac @@ -1115,7 +1115,7 @@ tools are selected during the Xcode/Developer Tools installation.]) AC_DEFINE(_DGUX_SOURCE) AC_DEFINE(_POSIX4A_DRAFT6_SOURCE) DSO_LDOPTS=-G - _OPTIMIZE_FLAGS=-O0 + _OPTIMIZE_FLAGS=-O2 _DEBUG_FLAGS= MDCPUCFG_H=_dgux.cfg PR_MD_CSRCS=dgux.c @@ -1334,7 +1334,7 @@ tools are selected during the Xcode/Developer Tools installation.]) dnl AS='$(CC) -Wp,-P -x assembler-with-cpp -D_ASM -mips2 $(INCLUDES)' CFLAGS="$CFLAGS -Wall -Wno-format" - _OPTIMIZE_FLAGS="-O0" + _OPTIMIZE_FLAGS="-O6" else if test -n "$USE_N32"; then AS='as -D_ASM $(INCLUDES) -n32' @@ -1408,7 +1408,7 @@ tools are selected during the Xcode/Developer Tools installation.]) MKSHLIB='$(CC) $(DSO_LDOPTS) $(OS_LDFLAGS) -o $@' DSO_CFLAGS=-fPIC DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - _OPTIMIZE_FLAGS=-O0 + _OPTIMIZE_FLAGS=-O2 _DEBUG_FLAGS="-g" # most people on linux use gcc/gdb, and that # combo is not yet good at debugging inlined # functions (even when using DWARF2 as the @@ -1485,7 +1485,7 @@ tools are selected during the Xcode/Developer Tools installation.]) CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" DLLFLAGS='-OUT:"$@"' _DEBUG_FLAGS=-Z7 - _OPTIMIZE_FLAGS=-O0 + _OPTIMIZE_FLAGS=-O2 if test -z "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS -Od" fi @@ -1724,7 +1724,7 @@ mips-sony-newsos*) DSO_CFLAGS=-fPIC DSO_LDOPTS=-shared OS_LIBS="$OS_LIBS -lsocket" - _OPTIMIZE_FLAGS="-O0" + _OPTIMIZE_FLAGS="-O1" _DEBUG_FLAGS="-gstabs" ;; @@ -2082,7 +2082,7 @@ mips-sony-newsos*) DSO_CFLAGS= DSO_LDOPTS='-Zomf -Zdll -Zmap' LDFLAGS='-Zmap' - _OPTIMIZE_FLAGS="-O0 -s" + _OPTIMIZE_FLAGS="-O2 -s" _DEBUG_FLAGS="-g -fno-inline" if test -n "$MOZ_OPTIMIZE"; then DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" diff --git a/libs/libg722_1/configure.ac b/libs/libg722_1/configure.ac index e5385d4091..62095ce374 100644 --- a/libs/libg722_1/configure.ac +++ b/libs/libg722_1/configure.ac @@ -64,9 +64,9 @@ then CC_FOR_BUILD=${CC_FOR_BUILD-gcc} CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)" CC=${CC-${host_alias}-gcc} - CFLAGS=${CFLAGS-"-g -O0"} + CFLAGS=${CFLAGS-"-g -O2"} CXX=${CXX-${host_alias}-c++} - CXXFLAGS=${CXXFLAGS-"-g -O0"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} else # Set reasonable default values for some tools even if not Canadian. # Of course, these are different reasonable default values, originally @@ -101,8 +101,8 @@ else fi CXX=${CXX-"c++"} - CFLAGS=${CFLAGS-"-g -O0"} - CXXFLAGS=${CXXFLAGS-"-g -O0"} + CFLAGS=${CFLAGS-"-g -O2"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} fi AC_DEFUN([REMOVE_FROM_VAR],[ diff --git a/libs/libsndfile/INSTALL b/libs/libsndfile/INSTALL index d520a54b6b..b42a17ac46 100644 --- a/libs/libsndfile/INSTALL +++ b/libs/libsndfile/INSTALL @@ -59,7 +59,7 @@ the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: - CC=c89 CFLAGS=-O0 LIBS=-lposix ./configure + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure diff --git a/libs/pcre/configure.ac b/libs/pcre/configure.ac index 7bf7c95b35..b6f79f98cf 100644 --- a/libs/pcre/configure.ac +++ b/libs/pcre/configure.ac @@ -26,7 +26,7 @@ CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" -# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O0" for gcc and just +# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just # "-g" for any other compiler. There doesn't seem to be a standard way of # getting rid of the -g (which I don't think is needed for a production # library). This fudge seems to achieve the necessary. First, we remember the @@ -44,9 +44,9 @@ AC_PROG_CXX if test "x$remember_set_CFLAGS" = "x" then - if test "$CFLAGS" = "-g -O0" + if test "$CFLAGS" = "-g -O2" then - CFLAGS="-O0" + CFLAGS="-O2" elif test "$CFLAGS" = "-g" then CFLAGS="" @@ -55,9 +55,9 @@ fi if test "x$remember_set_CXXFLAGS" = "x" then - if test "$CXXFLAGS" = "-g -O0" + if test "$CXXFLAGS" = "-g -O2" then - CXXFLAGS="-O0" + CXXFLAGS="-O2" elif test "$CXXFLAGS" = "-g" then CXXFLAGS="" diff --git a/libs/portaudio/Makefile.darwin b/libs/portaudio/Makefile.darwin index 0d37963f04..9aec51de24 100644 --- a/libs/portaudio/Makefile.darwin +++ b/libs/portaudio/Makefile.darwin @@ -11,7 +11,7 @@ top_srcdir = . srcdir = . top_builddir = . -OPT_LEVEL := -O0 +OPT_LEVEL := -O2 PREFIX = /usr/local prefix = $(PREFIX) exec_prefix = ${prefix} diff --git a/libs/portaudio/SConstruct b/libs/portaudio/SConstruct index 3c4bca0df7..15d36bad57 100644 --- a/libs/portaudio/SConstruct +++ b/libs/portaudio/SConstruct @@ -39,7 +39,7 @@ if Platform in Posix: baseLinkFlags = threadCFlags = "-pthread" baseCxxFlags = baseCFlags = "-Wall -pedantic -pipe " + threadCFlags debugCxxFlags = debugCFlags = "-g" - optCxxFlags = optCFlags = "-O0" + optCxxFlags = optCFlags = "-O2" env["CCFLAGS"] = baseCFlags.split() env["CXXFLAGS"] = baseCxxFlags.split() env["LINKFLAGS"] = baseLinkFlags.split() diff --git a/libs/portaudio/bindings/cpp/build/gnu/configure b/libs/portaudio/bindings/cpp/build/gnu/configure index e91013c07c..69070c66d4 100644 --- a/libs/portaudio/bindings/cpp/build/gnu/configure +++ b/libs/portaudio/bindings/cpp/build/gnu/configure @@ -1263,7 +1263,7 @@ PORTAUDIO="$PACPP_ROOT/../portaudio" PACPP_INC="$PACPP_ROOT/include" INCLUDES="-I$PACPP_INC -I$PORTAUDIO -I$PORTAUDIO/pa_common" -CFLAGS="-g -O0 -Wall -ansi -pedantic $INCLUDES" +CFLAGS="-g -O2 -Wall -ansi -pedantic $INCLUDES" CXXFLAGS="$CFLAGS" PALIBDIR="$PORTAUDIO/lib" @@ -1908,13 +1908,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O0" + CFLAGS="-g -O2" else - CFLAGS="-g -O0" + CFLAGS="-g" fi else if test "$GCC" = yes; then - CFLAGS="-O0" + CFLAGS="-O2" else CFLAGS= fi @@ -2350,13 +2350,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O0" + CXXFLAGS="-g -O2" else - CXXFLAGS="-g -O0" + CXXFLAGS="-g" fi else if test "$GXX" = yes; then - CXXFLAGS="-O0" + CXXFLAGS="-O2" else CXXFLAGS= fi diff --git a/libs/portaudio/bindings/cpp/build/gnu/configure.ac b/libs/portaudio/bindings/cpp/build/gnu/configure.ac index 071a7e94ef..5457c53420 100644 --- a/libs/portaudio/bindings/cpp/build/gnu/configure.ac +++ b/libs/portaudio/bindings/cpp/build/gnu/configure.ac @@ -24,7 +24,7 @@ PORTAUDIO="$PACPP_ROOT/../portaudio" PACPP_INC="$PACPP_ROOT/include" INCLUDES="-I$PACPP_INC -I$PORTAUDIO -I$PORTAUDIO/pa_common" -CFLAGS="-g -O0 -Wall -ansi -pedantic $INCLUDES" +CFLAGS="-g -O2 -Wall -ansi -pedantic $INCLUDES" CXXFLAGS="$CFLAGS" PALIBDIR="$PORTAUDIO/lib" diff --git a/libs/portaudio/bindings/cpp/configure.ac b/libs/portaudio/bindings/cpp/configure.ac index 94baff8fc3..100656ac41 100644 --- a/libs/portaudio/bindings/cpp/configure.ac +++ b/libs/portaudio/bindings/cpp/configure.ac @@ -25,7 +25,7 @@ PORTAUDIO_ROOT="../.." # Various other variables and flags DEFAULT_INCLUDES="-I$PACPP_ROOT/include -I$PACPP_ROOT/$PORTAUDIO_ROOT/include" -CFLAGS=${CFLAGS-"-g -O0 -Wall -ansi -pedantic"} +CFLAGS=${CFLAGS-"-g -O2 -Wall -ansi -pedantic"} CXXFLAGS=${CXXFLAGS-"${CFLAGS}"} LT_VERSION_INFO="lt_current:lt_revision:lt_age" diff --git a/libs/portaudio/build/dev-cpp/Makefile-static b/libs/portaudio/build/dev-cpp/Makefile-static index 65fcb5dacf..2a1647ddc5 100644 --- a/libs/portaudio/build/dev-cpp/Makefile-static +++ b/libs/portaudio/build/dev-cpp/Makefile-static @@ -7,12 +7,12 @@ WINDRES = windres.exe RES = OBJ = ./pa_skeleton.o ./pa_stream.o ./pa_trace.o ./pa_allocation.o ./pa_converters.o ./pa_cpuload.o ./pa_dither.o ./pa_front.o ./pa_process.o ./pa_asio.o ./pa_win_util.o ./pa_win_hostapis.o ./pa_win_ds.o ./dsound_wrapper.o ./pa_win_wmme.o ./iasiothiscallresolver.o $(RES) LINKOBJ = ./pa_skeleton.o ./pa_stream.o ./pa_trace.o ./pa_allocation.o ./pa_converters.o ./pa_cpuload.o ./pa_dither.o ./pa_front.o ./pa_process.o ./pa_asio.o ./pa_win_util.o ./pa_win_hostapis.o ./pa_win_ds.o ./dsound_wrapper.o ./pa_win_wmme.o ./iasiothiscallresolver.o $(RES) -LIBS = -L"C:/Dev-CPP/lib" -fmessage-length=0 -O0 -s +LIBS = -L"C:/Dev-CPP/lib" -fmessage-length=0 -O3 -s INCS = -I"C:/Dev-CPP/include" -I"../../../asiosdk2" -I"../../../asiosdk2/common" -I"../../../asiosdk2/host" -I"../../../asiosdk2/host/pc" -I"../../pa_common" CXXINCS = -I"C:/Dev-CPP/include/c++" -I"C:/Dev-CPP/include/c++/mingw32" -I"C:/Dev-CPP/include/c++/backward" -I"C:/Dev-CPP/include" -I"../../../asiosdk2" -I"../../../asiosdk2/common" -I"../../../asiosdk2/host" -I"../../../asiosdk2/host/pc" -I"../../pa_common" BIN = portaudio-static.a -CXXFLAGS = $(CXXINCS)-O0 -fmessage-length=0 -Wall -CFLAGS = $(INCS)-O0 -fmessage-length=0 -Wall +CXXFLAGS = $(CXXINCS)-O3 -fmessage-length=0 -Wall +CFLAGS = $(INCS)-O3 -fmessage-length=0 -Wall .PHONY: all all-before all-after clean clean-custom diff --git a/libs/portaudio/configure.in b/libs/portaudio/configure.in index 24deaf701c..f4ef9abbee 100644 --- a/libs/portaudio/configure.in +++ b/libs/portaudio/configure.in @@ -130,7 +130,7 @@ AC_SUBST(CXXFLAGS) AC_SUBST(NASM) AC_SUBST(NASMOPT) -CFLAGS=${CFLAGS:-"-g -O0 -Wall -pedantic -pipe -fPIC"} +CFLAGS=${CFLAGS:-"-g -O2 -Wall -pedantic -pipe -fPIC"} if [[ $ac_cv_c_bigendian = "yes" ]] ; then CFLAGS="$CFLAGS -DPA_BIG_ENDIAN" diff --git a/libs/sqlite/Makefile.linux-gcc b/libs/sqlite/Makefile.linux-gcc index e3a3d385dd..c865024b44 100644 --- a/libs/sqlite/Makefile.linux-gcc +++ b/libs/sqlite/Makefile.linux-gcc @@ -19,7 +19,7 @@ TOP = ../sqlite #### C Compiler and options for use in building executables that # will run on the platform that is doing the build. # -BCC = gcc -g -O0 +BCC = gcc -g -O2 #BCC = /opt/ancic/bin/c89 -0 #### If the target operating system supports the "usleep()" system @@ -70,10 +70,10 @@ EXE = # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. # -TCC = gcc -O0 +TCC = gcc -O6 #TCC = gcc -g -O0 -Wall #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage -#TCC = /opt/mingw/bin/i386-mingw32-gcc -O0 +#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6 #TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive #### Tools used to build a static library. diff --git a/libs/sqlite/mkso.sh b/libs/sqlite/mkso.sh index d6afb0198d..9050d74255 100755 --- a/libs/sqlite/mkso.sh +++ b/libs/sqlite/mkso.sh @@ -14,7 +14,7 @@ TCLSTUBLIB=$TCLDIR/libtclstub8.4g.a OPTS='-DUSE_TCL_STUBS=1 -DNDEBUG=1 -DHAVE_DLOPEN=1' for i in *.c; do if test $i != 'keywordhash.c'; then - CMD="cc -fPIC $OPTS -O0 -I. -I$TCLDIR -c $i" + CMD="cc -fPIC $OPTS -O2 -I. -I$TCLDIR -c $i" echo $CMD $CMD fi diff --git a/libs/sqlite/publish.sh b/libs/sqlite/publish.sh index 68d7c7f6e8..043c89a039 100755 --- a/libs/sqlite/publish.sh +++ b/libs/sqlite/publish.sh @@ -66,7 +66,7 @@ make target_source cd tsrc rm tclsqlite.c OPTS='-DSTATIC_BUILD=1 -DNDEBUG=1' -i386-mingw32msvc-gcc -O0 $OPTS -I. -I$TCLDIR *.c -o sqlite3.exe +i386-mingw32msvc-gcc -O2 $OPTS -I. -I$TCLDIR *.c -o sqlite3.exe zip ../doc/sqlite-$VERSW.zip sqlite3.exe cd .. diff --git a/libs/srtp/INSTALL b/libs/srtp/INSTALL index 7d2c51bb9d..23e5f25d0e 100644 --- a/libs/srtp/INSTALL +++ b/libs/srtp/INSTALL @@ -78,7 +78,7 @@ details on some of the pertinent environment variables. by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O0 LIBS=-lposix + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Defining Variables::, for more details. diff --git a/libs/srtp/build/config/ax_cc_maxopt.m4 b/libs/srtp/build/config/ax_cc_maxopt.m4 index 40bb95c8b7..6205ee84c8 100644 --- a/libs/srtp/build/config/ax_cc_maxopt.m4 +++ b/libs/srtp/build/config/ax_cc_maxopt.m4 @@ -10,7 +10,7 @@ AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disa if test "$ac_test_CFLAGS" != "set"; then CFLAGS="" case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O0 -ansi_alias -ansi_args -fp_reorder -tune host" + dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" if test "x$acx_maxopt_portable" = xno; then CFLAGS="$CFLAGS -arch host" fi;; @@ -31,13 +31,13 @@ if test "$ac_test_CFLAGS" != "set"; then xlc_opt="-qtune=auto" fi AX_CHECK_COMPILER_FLAGS($xlc_opt, - CFLAGS="-O0 -qansialias -w $xlc_opt", - [CFLAGS="-O0 -qansialias -w" + CFLAGS="-O3 -qansialias -w $xlc_opt", + [CFLAGS="-O3 -qansialias -w" echo "******************************************************" echo "* You seem to have the IBM C compiler. It is *" echo "* recommended for best performance that you use: *" echo "* *" - echo "* CFLAGS=-O0 -qarch=xxx -qtune=xxx -qansialias -w *" + echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" echo "* ^^^ ^^^ *" echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" echo "* CPU you have. (Set the CFLAGS environment var. *" @@ -45,7 +45,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "******************************************************"]) ;; - intel) CFLAGS="-O0 -ansi_alias" + intel) CFLAGS="-O3 -ansi_alias" if test "x$acx_maxopt_portable" = xno; then icc_archflag=unknown icc_flags="" @@ -78,7 +78,7 @@ if test "$ac_test_CFLAGS" != "set"; then gnu) # default optimization flags for gcc on all systems - CFLAGS="-O0 -fomit-frame-pointer" + CFLAGS="-O3 -fomit-frame-pointer" # -malign-double for x86 systems AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double") @@ -99,10 +99,10 @@ if test "$ac_test_CFLAGS" != "set"; then echo "********************************************************" echo "* WARNING: Don't know the best CFLAGS for this system *" echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O0 will be used) *" + echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O0" + CFLAGS="-O3" fi AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [ diff --git a/libs/srtp/configure.in b/libs/srtp/configure.in index 8584be880e..2495a55f95 100644 --- a/libs/srtp/configure.in +++ b/libs/srtp/configure.in @@ -49,7 +49,7 @@ case "$host" in IN_LINE="" elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then SOLINK="-Bdynamic -dy -G" - new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" IN_LINE=inline fi @@ -71,7 +71,7 @@ case "$host" in FUNC_DEF=__func__ elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" fi DYNAMIC_LIB_EXTEN="so" @@ -84,20 +84,20 @@ case "$host" in FUNC_DEF=__func__ elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fpic -Wall -O0 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fpic -Wall -O4 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" fi DYNAMIC_LIB_EXTEN="so" ;; i*6*-*-freebsd*) SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" DYNAMIC_LIB_EXTEN="so" ;; x86_64-*-freebsd*|amd64-*-freebsd*) SOLINK="-shared -Xlinker -x" - new_AM_CFLAGS="-fPIC -Wall -O0 -fexpensive-optimizations -funroll-loops" + new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops" new_AM_LDFLAGS="" DYNAMIC_LIB_EXTEN="so" ;; diff --git a/libs/yaml/aclocal.m4 b/libs/yaml/aclocal.m4 index ba1ed63878..b7984f0f01 100644 --- a/libs/yaml/aclocal.m4 +++ b/libs/yaml/aclocal.m4 @@ -6311,7 +6311,7 @@ ifelse([AC_DISABLE_FAST_INSTALL]) AC_DEFUN([LT_AC_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj, no) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O0" + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS) ]) diff --git a/libs/yaml/configure b/libs/yaml/configure index f66fa4972c..66e708215a 100755 --- a/libs/yaml/configure +++ b/libs/yaml/configure @@ -3222,13 +3222,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O0" + CFLAGS="-g -O2" else - CFLAGS="-g -O0" + CFLAGS="-g" fi else if test "$GCC" = yes; then - CFLAGS="-O0" + CFLAGS="-O2" else CFLAGS= fi @@ -5579,13 +5579,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O0" + CXXFLAGS="-g -O2" else - CXXFLAGS="-g -O0" + CXXFLAGS="-g" fi else if test "$GXX" = yes; then - CXXFLAGS="-O0" + CXXFLAGS="-O2" else CXXFLAGS= fi @@ -6180,13 +6180,13 @@ if test "$ac_test_FFLAGS" = set; then FFLAGS=$ac_save_FFLAGS elif test $ac_cv_prog_f77_g = yes; then if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O0" + FFLAGS="-g -O2" else - FFLAGS="-g -O0" + FFLAGS="-g" fi else if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O0" + FFLAGS="-O2" else FFLAGS= fi diff --git a/src/mod/applications/mod_avmd/Makefile b/src/mod/applications/mod_avmd/Makefile index fbf7ccb023..c4a62d4120 100644 --- a/src/mod/applications/mod_avmd/Makefile +++ b/src/mod/applications/mod_avmd/Makefile @@ -1,6 +1,6 @@ BASE=../../../.. -MOD_CFLAGS= -O0 -#MOD_CFLAGS= -march=core2 -g -O0 -malign-double -mtune=core2 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -ffast-math -funroll-loops -fprefetch-loop-arrays -funit-at-a-time -ftracer --save-temps +MOD_CFLAGS= -O2 +#MOD_CFLAGS= -march=core2 -g -O2 -malign-double -mtune=core2 -mmmx -msse -msse2 -msse3 -mssse3 -mfpmath=sse -ffast-math -funroll-loops -fprefetch-loop-arrays -funit-at-a-time -ftracer --save-temps #MOD_LDFLAGS= --save-temps LOCAL_SOURCES=amplitude.c buffer.c desa2.c goertzel.c fast_acosf.c LOCAL_OBJS=amplitude.o buffer.o desa2.o goertzel.o fast_acosf.o diff --git a/src/mod/endpoints/mod_gsmopen/asterisk/Makefile b/src/mod/endpoints/mod_gsmopen/asterisk/Makefile index f1b2d54450..6aed86266e 100644 --- a/src/mod/endpoints/mod_gsmopen/asterisk/Makefile +++ b/src/mod/endpoints/mod_gsmopen/asterisk/Makefile @@ -33,7 +33,7 @@ CFLAGS+=-g3 CFLAGS+=-I$(AST_INCLUDE_DIR) -I. CFLAGS+=-D_REENTRANT -D_GNU_SOURCE -#CFLAGS+=-O0 +#CFLAGS+=-O6 #CFLAGS+=-march=i586 CFLAGS+=-fomit-frame-pointer ifeq ($(shell uname -m),x86_64) diff --git a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure index 23bae83868..5918af81fb 100755 --- a/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure +++ b/src/mod/endpoints/mod_gsmopen/gsmlib/gsmlib-1.10-patched-12ubuntu1/configure @@ -2261,13 +2261,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O0" + CFLAGS="-g -O2" else - CFLAGS="-g -O0" + CFLAGS="-g" fi else if test "$GCC" = yes; then - CFLAGS="-O0" + CFLAGS="-O2" else CFLAGS= fi @@ -3144,7 +3144,7 @@ fi; if test "$CXXFLAGS" = ""; then - CXXFLAGS="-O0" + CXXFLAGS="-O2" fi @@ -4748,13 +4748,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O0" + CXXFLAGS="-g -O2" else - CXXFLAGS="-g -O0" + CXXFLAGS="-g" fi else if test "$GXX" = yes; then - CXXFLAGS="-O0" + CXXFLAGS="-O2" else CXXFLAGS= fi @@ -5431,13 +5431,13 @@ if test "$ac_test_FFLAGS" = set; then FFLAGS=$ac_save_FFLAGS elif test $ac_cv_prog_f77_g = yes; then if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O0" + FFLAGS="-g -O2" else - FFLAGS="-g -O0" + FFLAGS="-g" fi else if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O0" + FFLAGS="-O2" else FFLAGS= fi @@ -20153,13 +20153,13 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O0" + CXXFLAGS="-g -O2" else - CXXFLAGS="-g -O0" + CXXFLAGS="-g" fi else if test "$GXX" = yes; then - CXXFLAGS="-O0" + CXXFLAGS="-O2" else CXXFLAGS= fi diff --git a/src/mod/languages/mod_lua/lua/Makefile b/src/mod/languages/mod_lua/lua/Makefile index 4e0b5480d6..e4a3cd6108 100644 --- a/src/mod/languages/mod_lua/lua/Makefile +++ b/src/mod/languages/mod_lua/lua/Makefile @@ -8,7 +8,7 @@ PLAT= none CC= gcc -CFLAGS= -O0 -Wall $(MYCFLAGS) +CFLAGS= -O2 -Wall $(MYCFLAGS) AR= ar rcu RANLIB= ranlib RM= rm -f @@ -81,7 +81,7 @@ none: @echo " $(PLATS)" aix: - $(MAKE) all CC="xlc" CFLAGS="-O0 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" + $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" ansi: $(MAKE) all MYCFLAGS=-DLUA_ANSI From bfefbb55220f48e3c397c8f48c39cfe740cb9325 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 21 Mar 2012 10:12:59 -0400 Subject: [PATCH 15/26] freetdm: fix isup timers default values --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index ad47f0cbb4..230476d8e1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -2788,7 +2788,7 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t1 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t1 = sng_isap->t1; } else { - g_ftdm_sngss7_data.cfg.isap[i].t1 = 200; + g_ftdm_sngss7_data.cfg.isap[i].t1 = 150; } if (sng_isap->t2 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t2 = sng_isap->t2; @@ -2803,17 +2803,17 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap) if (sng_isap->t6 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t6 = sng_isap->t6; } else { - g_ftdm_sngss7_data.cfg.isap[i].t6 = 200; + g_ftdm_sngss7_data.cfg.isap[i].t6 = 600; } if (sng_isap->t7 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t7 = sng_isap->t7; } else { - g_ftdm_sngss7_data.cfg.isap[i].t7 = 250; + g_ftdm_sngss7_data.cfg.isap[i].t7 = 200; } if (sng_isap->t8 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t8 = sng_isap->t8; } else { - g_ftdm_sngss7_data.cfg.isap[i].t8 = 120; + g_ftdm_sngss7_data.cfg.isap[i].t8 = 100; } if (sng_isap->t9 != 0) { g_ftdm_sngss7_data.cfg.isap[i].t9 = sng_isap->t9; From a2db3c24b38eb260bda331f8ec5ae512661b5b5f Mon Sep 17 00:00:00 2001 From: James Zhang Date: Tue, 27 Mar 2012 18:00:24 -0400 Subject: [PATCH 16/26] freetdm: fixing more potential null pointers in native bridge mode. --- .../ftmod_sangoma_ss7_main.c | 45 ++++++++++++------- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 26 ++++++----- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index fe129c0f73..3d30a534cd 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -426,24 +426,33 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) /* note that the channels being dequeued here may not belong to this span they may belong to just about any other span that one of our channels happens to be bridged to */ - sngss7_chan_data_t *peer_info = peerchan->call_data; - sngss7_chan_data_t *chan_info = peer_info->peer_data; - ftdmchan = chan_info->ftdmchan; + sngss7_chan_data_t *peer_info; + sngss7_chan_data_t *chan_info; - /* - if there is any state changes at all, those will be done in the opposite channel - to peerchan (where the original event was received), therefore we must lock ftdmchan, - but do not need to lock peerchan as we only read its event queue, which is already - locked when dequeueing */ - ftdm_channel_lock(ftdmchan); + peer_info = peerchan->call_data; + if (peer_info) { + chan_info = peer_info->peer_data; + if (chan_info) { + ftdmchan = chan_info->ftdmchan; + if (ftdmchan) { - /* clean out all pending stack events in the peer channel */ - while ((sngss7_event = ftdm_queue_dequeue(peer_info->event_queue))) { - ftdm_sangoma_ss7_process_peer_stack_event(ftdmchan, sngss7_event); - ftdm_safe_free(sngss7_event); + /* + if there is any state changes at all, those will be done in the opposite channel + to peerchan (where the original event was received), therefore we must lock ftdmchan, + but do not need to lock peerchan as we only read its event queue, which is already + locked when dequeueing */ + ftdm_channel_lock(ftdmchan); + + /* clean out all pending stack events in the peer channel */ + while ((sngss7_event = ftdm_queue_dequeue(peer_info->event_queue))) { + ftdm_sangoma_ss7_process_peer_stack_event(ftdmchan, sngss7_event); + ftdm_safe_free(sngss7_event); + } + + ftdm_channel_unlock(ftdmchan); + } + } } - - ftdm_channel_unlock(ftdmchan); } /* clean out all pending stack events */ @@ -1519,9 +1528,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) */ if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { sngss7_chan_data_t *peer_info = sngss7_info->peer_data; - sngss7_info->peer_data = NULL; if (peer_info) { - peer_info->peer_data = NULL; + sngss7_info->peer_data = NULL; + if (peer_info) { + peer_info->peer_data = NULL; + } } } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 5f0a0f0960..c44c7bd7b2 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -72,21 +72,23 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) var, peer_span->signal_type); } else { peer_info = peer_chan->call_data; - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", - sngss7_info->circuit->cic, peer_info->circuit->cic); + if (peer_info) { + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", + sngss7_info->circuit->cic, peer_info->circuit->cic); - /* make each one of us aware of the native bridge */ - peer_info->peer_data = sngss7_info; - sngss7_info->peer_data = peer_info; + /* make each one of us aware of the native bridge */ + peer_info->peer_data = sngss7_info; + sngss7_info->peer_data = peer_info; - /* flush our own queue */ - sngss7_flush_queue(sngss7_info->event_queue); + /* flush our own queue */ + sngss7_flush_queue(sngss7_info->event_queue); - /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, - We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function - because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped - and we still need those variables for further IAM processing */ - native_going_up = FTDM_TRUE; + /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, + We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function + because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped + and we still need those variables for further IAM processing */ + native_going_up = FTDM_TRUE; + } } } } From 8a589435de7b8656bd18a1a10ff66529380b7f09 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 30 Mar 2012 16:50:00 -0400 Subject: [PATCH 17/26] freetdm: Adding condition to parse sip headers only for non-freetdm channels. This fixes an issue where ss7 native bridge was accidentally enabled any time two freetdm channels were bridged regardless of the freetdm_native_sigbridge variable value. --- libs/freetdm/mod_freetdm/mod_freetdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index c3e5c486db..6a32098b44 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1349,7 +1349,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi chan_id = 0; } - if (session && globals.sip_headers) { + if (session && globals.sip_headers && !switch_core_session_check_interface (session,freetdm_endpoint_interface) ) { switch_channel_t *channel = switch_core_session_get_channel(session); const char *sipvar; From b324f8679782957bc9db3bdfd6687aa42cba77dd Mon Sep 17 00:00:00 2001 From: James Zhang Date: Tue, 3 Apr 2012 11:23:49 -0400 Subject: [PATCH 18/26] freetdm: Clean up SS7 native bridge code to separate the call control, queuing and resource-cleanup responsibilities clearly between the 2 channels involved in the bridge - Each channel is responsible for clearning its own peer_data and event queue at the end of the call (when moving to DOWN state) - Each channel dequeues messages only from its own queue and enqueues messages in the peer's queue, with the only exception being messages received before the bridge is stablished (IAM for sure and possible SAM messages) because if the bridge is not yet stablished the messages must be queued by the channel in its own queue temporarily until the bridge is ready - When the bridge is ready it is the responsibility of the incoming channel to move the messages that stored temporarily in its own queue to the bridged peer queue - During hangup, each channel is responsible for moving itself to DOWN. The procedure however differs slightly depending on the hangup conditions If the user requests hangup (ie, FreeSWITCH) the request will be noted by setting the FTDM_CHANNEL_USER_HANGUP flag but will not be processed yet because call control is driven only by the link messages (so no hangup from ESL or command line allowed) When REL message comes, the channel receiving it must move to TERMINATING state and: - If the user has not hangup yet (FTDM_CHANNEL_USER_HANGUP flag not set) then notify the user via SIGEVENT_STOP and wait for the user to move to HANGUP state by calling ftdm_channel_call_hangup() before sending RLC - If the user did hangup already (FTDM_CHANNEL_USER_HANGUP flag is set) then skip user notification and move to HANGUP state directly where the RLC message will be sent - On HANGUP state the RLC is sent and the channel is moved to DOWN, final state The peer channel will forward the REL message and wait for RLC from the network, when RLC is received the channel can move straight to DOWN itself because the peer channel is completing its own shutdown procedure when it received the REL message --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c | 1 + .../ftmod_sangoma_ss7_main.c | 163 +++++++----------- .../ftmod_sangoma_ss7_main.h | 6 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 41 ++--- 4 files changed, 88 insertions(+), 123 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c index b13c98b1e6..92931c4b8d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c @@ -81,6 +81,7 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo /* initalize the sngss7_event */ sngss7_event = ftdm_malloc(sizeof(*sngss7_event)); + if (sngss7_event == NULL) { SS7_ERROR("Failed to allocate memory for sngss7_event!\n"); SS7_FUNC_TRACE_EXIT(__FUNCTION__); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index 3d30a534cd..76266f0d53 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -340,10 +340,9 @@ static void handle_hw_alarm(ftdm_event_t *e) /* MONITIOR THREADS ***********************************************************/ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) { - ftdm_interrupt_t *ftdm_sangoma_ss7_int[3]; + ftdm_interrupt_t *ftdm_sangoma_ss7_int[2]; ftdm_span_t *ftdmspan = (ftdm_span_t *) obj; ftdm_channel_t *ftdmchan = NULL; - ftdm_channel_t *peerchan = NULL; ftdm_event_t *event = NULL; sngss7_event_data_t *sngss7_event = NULL; sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data; @@ -368,12 +367,6 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) goto ftdm_sangoma_ss7_run_exit; } - /* get an interrupt queue for this span for peer channel events */ - if (ftdm_queue_get_interrupt (sngss7_span->peer_chans, &ftdm_sangoma_ss7_int[2]) != FTDM_SUCCESS) { - SS7_CRITICAL ("Failed to get a ftdm_interrupt for span = %d for peer channel events queue!\n", ftdmspan->span_id); - goto ftdm_sangoma_ss7_run_exit; - } - while (ftdm_running () && !(ftdm_test_flag (ftdmspan, FTDM_SPAN_STOP_THREAD))) { int x = 0; if (b_alarm_test) { @@ -410,51 +403,26 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj) /* clean out all pending channel state changes */ while ((ftdmchan = ftdm_queue_dequeue (ftdmspan->pendingchans))) { + sngss7_chan_data_t *chan_info = ftdmchan->call_data; /*first lock the channel */ ftdm_mutex_lock(ftdmchan->mutex); /* process state changes for this channel until they are all done */ ftdm_channel_advance_states(ftdmchan); + + if (chan_info->peer_data) { + /* clean out all pending stack events in the peer channel */ + while ((sngss7_event = ftdm_queue_dequeue(chan_info->event_queue))) { + ftdm_sangoma_ss7_process_peer_stack_event(ftdmchan, sngss7_event); + ftdm_safe_free(sngss7_event); + } + } /* unlock the channel */ ftdm_mutex_unlock (ftdmchan->mutex); } - /* clean out all peer pending channel events */ - while ((peerchan = ftdm_queue_dequeue (sngss7_span->peer_chans))) { - /* note that the channels being dequeued here may not belong to this span - they may belong to just about any other span that one of our channels - happens to be bridged to */ - sngss7_chan_data_t *peer_info; - sngss7_chan_data_t *chan_info; - - peer_info = peerchan->call_data; - if (peer_info) { - chan_info = peer_info->peer_data; - if (chan_info) { - ftdmchan = chan_info->ftdmchan; - if (ftdmchan) { - - /* - if there is any state changes at all, those will be done in the opposite channel - to peerchan (where the original event was received), therefore we must lock ftdmchan, - but do not need to lock peerchan as we only read its event queue, which is already - locked when dequeueing */ - ftdm_channel_lock(ftdmchan); - - /* clean out all pending stack events in the peer channel */ - while ((sngss7_event = ftdm_queue_dequeue(peer_info->event_queue))) { - ftdm_sangoma_ss7_process_peer_stack_event(ftdmchan, sngss7_event); - ftdm_safe_free(sngss7_event); - } - - ftdm_channel_unlock(ftdmchan); - } - } - } - } - /* clean out all pending stack events */ while ((sngss7_event = ftdm_queue_dequeue(sngss7_span->event_queue))) { ftdm_sangoma_ss7_process_stack_event(sngss7_event); @@ -570,16 +538,16 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev ftdm_channel_advance_states(ftdmchan); if (sngss7_event->event_id == SNGSS7_CON_IND_EVENT) { - /* this is the first event in a call, flush the event queue */ - sngss7_flush_queue(sngss7_info->event_queue); - /* clear the peer if any */ - sngss7_info->peer_data = NULL; clone_event++; } - /* if the call has already started and the event is not a release confirmation, clone the event */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED) && - sngss7_event->event_id != SNGSS7_REL_CFM_EVENT) { + /* If the call has already started (we only bridge events related to calls) + * and the event is not a release confirmation, then clone the event. + * We do not clone release cfm events because that is the only event (final event) that is not + * bridged to the other leg, the first Spirou customer we had explicitly requested to send + * release confirm as soon as the release is received and therefore not wait for the other leg + * to send release confirm (hence, not need to clone and enqueue in the other leg) */ + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED) && sngss7_event->event_id != SNGSS7_REL_CFM_EVENT) { clone_event++; } @@ -606,11 +574,38 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev event_clone = ftdm_calloc(1, sizeof(*sngss7_event)); if (event_clone) { memcpy(event_clone, sngss7_event, sizeof(*sngss7_event)); - ftdm_queue_enqueue(sngss7_info->event_queue, event_clone); + /* if we have already a peer channel then enqueue the event in their queue */ if (sngss7_info->peer_data) { - sngss7_span_data_t *sngss7_peer_span = (sngss7_span_data_t *)sngss7_info->peer_data->ftdmchan->span->signal_data; + ftdm_span_t *peer_span = sngss7_info->peer_data->ftdmchan->span; + if (sngss7_info->peer_event_transfer_cnt) { + sngss7_event_data_t *peer_event = NULL; + int qi = 0; + /* looks like for the first time we found our peer, transfer any messages we enqueued */ + for (qi = 0; qi < sngss7_info->peer_event_transfer_cnt; qi++) { + peer_event = ftdm_queue_dequeue(sngss7_info->event_queue); + if (peer_event) { + ftdm_queue_enqueue(sngss7_info->peer_data->event_queue, peer_event); + } else { + /* This should never happen! */ + SS7_CRIT_CHAN(ftdmchan,"[CIC:%d]What!? someone stole my messages!\n", sngss7_info->circuit->cic); + } + } + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Transferred %d messages into my peer's queue\n", + sngss7_info->circuit->cic, sngss7_info->peer_event_transfer_cnt); + sngss7_info->peer_event_transfer_cnt = 0; + } /* we already have a peer attached, wake him up */ - ftdm_queue_enqueue(sngss7_peer_span->peer_chans, sngss7_info->ftdmchan); + ftdm_queue_enqueue(sngss7_info->peer_data->event_queue, event_clone); + ftdm_queue_enqueue(peer_span->pendingchans, sngss7_info->peer_data->ftdmchan); + } else { + /* we don't have a peer yet, save the event on our own queue for later + * only the first event in this queue is directly consumed by our peer (IAM), subsequent events + * must be transferred by us to their queue as soon as we find our peer */ + ftdm_queue_enqueue(sngss7_info->event_queue, event_clone); + if (sngss7_event->event_id != SNGSS7_CON_IND_EVENT) { + /* This could be an SAM, save it for transfer once we know who our peer is (if we ever find that) */ + sngss7_info->peer_event_transfer_cnt++; + } } } } @@ -623,25 +618,7 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); break; case SNGSS7_REL_CFM_EVENT: - { - if (sngss7_info->peer_data) { - ftdm_channel_t *peer_chan = sngss7_info->peer_data->ftdmchan; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); - if (peer_chan) { - /* we need to unlock our chan or we risk deadlock */ - ftdm_channel_advance_states(ftdmchan); - ftdm_channel_unlock(ftdmchan); - - ftdm_channel_lock(peer_chan); - if (peer_chan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_set_state(peer_chan, FTDM_CHANNEL_STATE_DOWN); - } - ftdm_channel_unlock(peer_chan); - - ftdm_channel_lock(ftdmchan); - } - } - } + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); break; default: break; @@ -1021,6 +998,7 @@ static ftdm_status_t ftdm_sangoma_ss7_native_bridge_state_change(ftdm_channel_t sngss7_clear_ckt_flag(sngss7_info, FLAG_SUS_RECVD); sngss7_clear_ckt_flag(sngss7_info, FLAG_T6_CANCELED); sngss7_flush_queue(sngss7_info->event_queue); + sngss7_info->peer_data = NULL; ftdm_channel_close (&close_chan); } break; @@ -1035,9 +1013,22 @@ static ftdm_status_t ftdm_sangoma_ss7_native_bridge_state_change(ftdm_channel_t case FTDM_CHANNEL_STATE_TERMINATING: { - ft_to_sngss7_rlc(ftdmchan); + /* Release confirm is sent immediately, since Spirou customer asked us not to wait for the second call leg + * to come back with a release confirm ... */ /* when receiving REL we move to TERMINATING and notify the user that the bridge is ending */ - sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_STOP); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USER_HANGUP)) { + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP); + } else { + /* Notify the user and wait for their ack before sending RLC */ + sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_STOP); + } + } + break; + + case FTDM_CHANNEL_STATE_HANGUP: + { + ft_to_sngss7_rlc(ftdmchan); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN); } break; @@ -1062,11 +1053,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) sngss7_info->blk_flags); if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { - /* DIALING is the only state we process normally when doing an outgoing call that is natively bridged */ + /* DIALING is the only state we process normally when doing an outgoing call that is natively bridged, + * all other states are run by a different state machine (and the freetdm core does not do any checking) */ if (ftdmchan->state != FTDM_CHANNEL_STATE_DIALING) { return ftdm_sangoma_ss7_native_bridge_state_change(ftdmchan); } - sngss7_info->peer_data = NULL; } /*check what state we are supposed to be in */ @@ -1521,24 +1512,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) { ftdm_channel_t *close_chan = ftdmchan; - - /* detach native bridging if needed (only the outbound leg is responsible for that) - Inbound leg was responsible of flushing its queue of events, but peer attach/detach - is left as an outbound leg responsibility - */ - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { - sngss7_chan_data_t *peer_info = sngss7_info->peer_data; - if (peer_info) { - sngss7_info->peer_data = NULL; - if (peer_info) { - peer_info->peer_data = NULL; - } - } - } - /* close the channel */ SS7_DEBUG_CHAN(ftdmchan,"FTDM Channel Close %s\n", ""); - sngss7_flush_queue(sngss7_info->event_queue); ftdm_channel_close (&close_chan); } @@ -2415,12 +2390,6 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config) return FTDM_FAIL; } - /* create an peer channel queue for this span */ - if ((ftdm_queue_create(&(ss7_span_info)->peer_chans, SNGSS7_PEER_CHANS_QUEUE_SIZE)) != FTDM_SUCCESS) { - SS7_CRITICAL("Unable to create peer chans queue!\n"); - return FTDM_FAIL; - } - /*setup the span structure with the info so far */ g_ftdm_sngss7_data.sig_cb = sig_cb; span->start = ftdm_sangoma_ss7_start; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index 63d4ded203..fcf7b8ef28 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -522,7 +522,8 @@ typedef struct sngss7_chan_data { sngss7_group_data_t tx_grs; sngss7_group_data_t ucic; ftdm_queue_t *event_queue; - struct sngss7_chan_data *peer_data; + struct sngss7_chan_data *peer_data; + uint8_t peer_event_transfer_cnt; } sngss7_chan_data_t; #define SNGSS7_RX_GRS_PENDING (1 << 0) @@ -536,7 +537,6 @@ typedef struct sngss7_span_data { sngss7_group_data_t rx_cgu; sngss7_group_data_t tx_cgu; ftdm_queue_t *event_queue; - ftdm_queue_t *peer_chans; } sngss7_span_data_t; typedef struct sngss7_event_data @@ -970,7 +970,7 @@ if (ftdmchan->state == new_state) { \ #define SS7_INFO_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_INFO, msg , ##args) #define SS7_WARN_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_WARNING, msg , ##args) #define SS7_ERROR_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_ERROR, msg , ##args) -#define SS7_CTRIT_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args) +#define SS7_CRIT_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args) #ifdef SS7_CODE_DEVEL #define SS7_DEVEL_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ ); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index c44c7bd7b2..a228cb1ea1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -48,6 +48,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) SiConEvnt iam; ftdm_bool_t native_going_up = FTDM_FALSE; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;; + sngss7_event_data_t *event_clone = NULL; SS7_FUNC_TRACE_ENTER (__FUNCTION__); @@ -72,33 +73,28 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) var, peer_span->signal_type); } else { peer_info = peer_chan->call_data; - if (peer_info) { - SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", - sngss7_info->circuit->cic, peer_info->circuit->cic); + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Starting native bridge with peer CIC %d\n", + sngss7_info->circuit->cic, peer_info->circuit->cic); - /* make each one of us aware of the native bridge */ - peer_info->peer_data = sngss7_info; - sngss7_info->peer_data = peer_info; + /* retrieve only first message from the others guys queue (must be IAM) */ + event_clone = ftdm_queue_dequeue(peer_info->event_queue); - /* flush our own queue */ - sngss7_flush_queue(sngss7_info->event_queue); + /* make each one of us aware of the native bridge */ + peer_info->peer_data = sngss7_info; + sngss7_info->peer_data = peer_info; - /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, - We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function - because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped - and we still need those variables for further IAM processing */ - native_going_up = FTDM_TRUE; - } + /* Go to up until release comes, note that state processing is done different and much simpler when there is a peer, + We can't go to UP state right away yet though, so do not set the state to UP here, wait until the end of this function + because moving from one state to another causes the ftdmchan->usrmsg structure to be wiped + and we still need those variables for further IAM processing */ + native_going_up = FTDM_TRUE; } } } - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && sngss7_info->peer_data) { - sngss7_span_data_t *span_data = ftdmchan->span->signal_data; - sngss7_event_data_t *event_clone = ftdm_queue_dequeue(sngss7_info->peer_data->event_queue); - /* Retrieve IAM from our peer */ + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { if (!event_clone) { - SS7_ERROR_CHAN(ftdmchan, "No event clone in peer queue!%s\n", ""); + SS7_ERROR_CHAN(ftdmchan, "No IAM event clone in peer queue!%s\n", ""); } else if (event_clone->event_id != SNGSS7_CON_IND_EVENT) { /* first message in the queue should ALWAYS be an IAM */ SS7_ERROR_CHAN(ftdmchan, "Invalid initial peer message type '%d'\n", event_clone->event_id); @@ -143,9 +139,6 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); } } - /* since this is the first time we dequeue an event from the peer, make sure our main thread process any other events, - this will trigger the interrupt in our span peer_chans queue which will wake up our main thread if it is sleeping */ - ftdm_queue_enqueue(span_data->peer_chans, sngss7_info->peer_data->ftdmchan); } else if (sngss7_info->circuit->transparent_iam && sngss7_retrieve_iam(ftdmchan, &iam) == FTDM_SUCCESS) { SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Transparent)\n", sngss7_info->circuit->cic); @@ -236,7 +229,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) the user sending FTDM_SIGEVENT_UP which can cause the application to misbehave (ie, no audio) */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); ftdm_channel_advance_states(ftdmchan); - } + } + + ftdm_safe_free(event_clone); SS7_FUNC_TRACE_EXIT (__FUNCTION__); return; From 339c45b2cbfc8a07df3f06fdf483cce3aeb10022 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Tue, 3 Apr 2012 11:27:25 -0400 Subject: [PATCH 19/26] freetdm: Add documentation for SS7 native bridge --- libs/freetdm/docs/ss7-native-bridge.txt | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 libs/freetdm/docs/ss7-native-bridge.txt diff --git a/libs/freetdm/docs/ss7-native-bridge.txt b/libs/freetdm/docs/ss7-native-bridge.txt new file mode 100644 index 0000000000..d44b067b0a --- /dev/null +++ b/libs/freetdm/docs/ss7-native-bridge.txt @@ -0,0 +1,43 @@ +SS7 Native Bridge + +Native bridge is enabled on 2 conditions: + +* The SIP header FreeTDM-TransUUID is set in the originating leg and matches a freetdm channel +* The variable freetdm_native_sigbridge is true and the originating leg is also a freetdm channel + +Some coding rules apply to this feature: + +- Each channel is responsible for clearning its own peer_data and event queue + at the end of the call (when moving to DOWN state) + +- Each channel dequeues messages only from its own queue and enqueues messages + in the peer's queue, with the only exception being messages received before + the bridge is stablished (IAM for sure and possible SAM messages) because + if the bridge is not yet stablished the messages must be queued by the channel + in its own queue temporarily until the bridge is ready + +- When the bridge is ready it is the responsibility of the incoming channel to + move the messages that stored temporarily in its own queue to the bridged peer queue + +- During hangup, each channel is responsible for moving itself to DOWN. The procedure + however differs slightly depending on the hangup conditions + + If the user requests hangup (ie, FreeSWITCH) the request will be noted by setting the + FTDM_CHANNEL_USER_HANGUP flag but will not be processed yet because call control is + driven only by the link messages (so no hangup from ESL or command line allowed) + + When REL message comes, the channel receiving it must move to TERMINATING state and: + + - If the user has not hangup yet (FTDM_CHANNEL_USER_HANGUP flag not set) then + notify the user via SIGEVENT_STOP and wait for the user to move to HANGUP + state by calling ftdm_channel_call_hangup() before sending RLC + + - If the user did hangup already (FTDM_CHANNEL_USER_HANGUP flag is set) then + skip user notification and move to HANGUP state directly where the RLC message + will be sent + +- On HANGUP state the RLC is sent and the channel is moved to DOWN, final state + The peer channel will forward the REL message and wait for RLC from the network, when + RLC is received the channel can move straight to DOWN itself because the peer channel + is completing its own shutdown procedure when it received the REL message + From 7155001c864686dd005e25ef80bfa8b4aef05fc4 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 16 Jan 2012 12:45:25 -0600 Subject: [PATCH 20/26] FS-3810 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0fc8c3acfb..ca489f6db7 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -443,7 +443,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) } if (!((use_my_cause = switch_channel_get_variable(channel, "sip_ignore_remote_cause")) && switch_true(use_my_cause))) { - ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE); + ps_cause = switch_channel_get_variable(channel, "last_bridge_" SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE); } if (!zstr(ps_cause) && (!strncasecmp(ps_cause, "sip:", 4) || !strncasecmp(ps_cause, "sips:", 5))) { From 16d4f1f06313a26d45d0b61a188af6d01e79e59b Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 11 Apr 2012 11:20:32 -0400 Subject: [PATCH 21/26] freetdm: INR/INF implementation - When NSG receives INR from network, send back INF with calling party category information IE and calling number information IE. - Introduced a new global setting of "force-inr" for testing purpose. Stinga generated INR/INF packets are not acceptable by trillium stack since it misses call related information in the packets. If configure force-inr to true in freetdm.conf.xml, when NSG receives an incoming IAM, it'll send out INR packet regardless of incoming IAM's IEs, and keep waiting for INF response from the calling side. - T.39 timer is introduced in order to handle INR timeout. The default value of T.39 is 12 seconds and is configurable according to spec. - Only supports calling number IE and calling party category IE in current fix. The customer only needs the calling number IE right now. In ISUP spec, there are 6 optional IEs. NSG only supports calling party number and calling category information IE since the other IEs are not configurable in freetdm.conf.xml or included in IAM message. - In collect state, INR/INF implementation needs to work with existed SAM messages. If NSG sent out INR and wait for SAM, collect state check both INF received and enough dialed numbers received. If one of these conditions are not met, it'll stay in collect state and wait until either conditions met or timeout. After received INF and enough dailed number, state moves to dailing and proceed as regular calls. --- .../ftmod_sangoma_ss7_handle.c | 37 +++++++ .../ftmod_sangoma_ss7_main.c | 104 ++++++++++++++++-- .../ftmod_sangoma_ss7_main.h | 24 ++++ .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 79 +++++++++++++ .../ftmod_sangoma_ss7_support.c | 2 +- .../ftmod_sangoma_ss7_timers.c | 45 +++++++- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 28 +++++ 7 files changed, 304 insertions(+), 15 deletions(-) diff --git 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 index d9816dfa0e..ac309ddc3e 100644 --- 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 @@ -131,6 +131,16 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* KONRAD FIX ME : check in case there is a ckt and grp block */ } + + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX_DN); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_SENT); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX_DN); + sngss7_clear_ckt_flag(sngss7_info, FLAG_FULL_NUMBER); /* check whether the ftdm channel is in a state to accept a call */ switch (ftdmchan->state) { @@ -175,6 +185,12 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* fill in ANI */ ftdm_set_string(ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.cid_num.digits); } + else { + if (g_ftdm_sngss7_data.cfg.force_inr) { + sngss7_set_ckt_flag(sngss7_info, FLAG_INR_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); + } + } if (siConEvnt->cgPtyNum.scrnInd.pres) { /* fill in the screening indication value */ @@ -186,6 +202,11 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ ftdmchan->caller_data.pres = siConEvnt->cgPtyNum.presRest.val; } } else { + if (g_ftdm_sngss7_data.cfg.force_inr) { + sngss7_set_ckt_flag(sngss7_info, FLAG_INR_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); + } + SS7_INFO_CHAN(ftdmchan,"No Calling party (ANI) information in IAM!%s\n", " "); } @@ -437,10 +458,26 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ /**************************************************************************/ case (INFORMATION): SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx INF\n", sngss7_info->circuit->cic); + + SS7_DEBUG_CHAN (ftdmchan, "Cancelling T.39 timer %s\n", " "); + /* check if t39 is active */ + if (sngss7_info->t39.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); + SS7_DEBUG_CHAN (ftdmchan, "T.39 timer has been cancelled upon receiving INF message %s\n", " "); + } + + sngss7_set_ckt_flag(sngss7_info, FLAG_INF_RX_DN); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); + break; /**************************************************************************/ case (INFORMATREQ): SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx INR\n", sngss7_info->circuit->cic); + + ft_to_sngss7_inf(ftdmchan); + + sngss7_set_ckt_flag(sngss7_info, FLAG_INR_RX); + break; /**************************************************************************/ case (SUBSADDR): diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index 76266f0d53..d37a6111ab 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -1080,23 +1080,91 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) } /* check if the end of pulsing (ST) character has arrived or the right number of digits */ - if (ftdmchan->caller_data.dnis.digits[i-1] == 'F') { + if (ftdmchan->caller_data.dnis.digits[i-1] == 'F' + || sngss7_test_ckt_flag(sngss7_info, FLAG_FULL_NUMBER) ) + { SS7_DEBUG_CHAN(ftdmchan, "Received the end of pulsing character %s\n", ""); - /* remove the ST */ - ftdmchan->caller_data.dnis.digits[i-1] = '\0'; - - /*now go to the RING state */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_FULL_NUMBER)) { + /* remove the ST */ + ftdmchan->caller_data.dnis.digits[i-1] = '\0'; + sngss7_set_ckt_flag(sngss7_info, FLAG_FULL_NUMBER); + } + if (sngss7_test_ckt_flag(sngss7_info, FLAG_INR_TX)) { + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INR_SENT) ) { + ft_to_sngss7_inr(ftdmchan); + sngss7_set_ckt_flag(sngss7_info, FLAG_INR_SENT); + + SS7_DEBUG_CHAN (ftdmchan, "Scheduling T.39 timer %s \n", " "); + + /* start ISUP t39 */ + if (ftdm_sched_timer (sngss7_info->t39.sched, + "t39", + sngss7_info->t39.beat, + sngss7_info->t39.callback, + &sngss7_info->t39, + &sngss7_info->t39.hb_timer_id)) + { + + SS7_ERROR ("Unable to schedule timer T39, hanging up call!\n"); + + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; + sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); + + /* end the call */ + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); + } + }else { + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + } + } else { + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + } } else if (i >= sngss7_info->circuit->min_digits) { SS7_DEBUG_CHAN(ftdmchan, "Received %d digits (min digits = %d)\n", i, sngss7_info->circuit->min_digits); - /*now go to the RING state */ - state_flag = 0; - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); - + if (sngss7_test_ckt_flag(sngss7_info, FLAG_INR_TX)) { + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INR_SENT) ) { + ft_to_sngss7_inr(ftdmchan); + sngss7_set_ckt_flag(sngss7_info, FLAG_INR_SENT); + + SS7_DEBUG_CHAN (ftdmchan, "Scheduling T.39 timer %s\n", " " ); + + /* start ISUP t39 */ + if (ftdm_sched_timer (sngss7_info->t39.sched, + "t39", + sngss7_info->t39.beat, + sngss7_info->t39.callback, + &sngss7_info->t39, + &sngss7_info->t39.hb_timer_id)) + { + + SS7_ERROR ("Unable to schedule timer T39, hanging up call!\n"); + + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE; + sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL); + + /* end the call */ + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); + } + + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); + }else { + if (sngss7_test_ckt_flag(sngss7_info, FLAG_INF_RX_DN) ) { + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + } + } + } else { + state_flag = 0; + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); + } } else { /* if we are coming from idle state then we have already been here once before */ if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) { @@ -1152,6 +1220,15 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) /**************************************************************************/ case FTDM_CHANNEL_STATE_RING: /*incoming call request */ + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_SENT); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INR_RX_DN); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_TX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_SENT); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INF_RX_DN); + if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n"); break; @@ -1162,6 +1239,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id); } + /* cancel t39 timer */ + if (sngss7_info->t39.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); + } + SS7_DEBUG_CHAN(ftdmchan, "Sending incoming call from %s to %s to FTDM core\n", ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.dnis.digits); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index fcf7b8ef28..66732bf10e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -395,6 +395,7 @@ typedef struct sng_isup_ckt { uint16_t t16; uint16_t t17; uint32_t t35; + uint32_t t39; uint16_t tval; } sng_isup_ckt_t; @@ -466,6 +467,7 @@ typedef struct sng_ss7_cfg { sng_nsap_t nsap[MAX_NSAPS+1]; sng_isap_t isap[MAX_ISAPS+1]; sng_glare_resolution glareResolution; + uint32_t force_inr; } sng_ss7_cfg_t; typedef struct ftdm_sngss7_data { @@ -517,6 +519,7 @@ typedef struct sngss7_chan_data { sngss7_glare_data_t glare; sngss7_timer_data_t t35; sngss7_timer_data_t t10; + sngss7_timer_data_t t39; sngss7_group_data_t rx_grs; sngss7_group_data_t rx_gra; sngss7_group_data_t tx_grs; @@ -584,6 +587,15 @@ typedef enum { FLAG_SENT_CPG = (1 << 17), FLAG_SUS_RECVD = (1 << 18), FLAG_T6_CANCELED = (1 << 19), + FLAG_INR_TX = (1 << 20), + FLAG_INR_SENT = (1 << 21), + FLAG_INR_RX = (1 << 22), + FLAG_INR_RX_DN = (1 << 23), + FLAG_INF_TX = (1 << 24), + FLAG_INF_SENT = (1 << 25), + FLAG_INF_RX = (1 << 26), + FLAG_INF_RX_DN = (1 << 27), + FLAG_FULL_NUMBER = (1 << 28), FLAG_RELAY_DOWN = (1 << 30), FLAG_CKT_RECONFIG = (1 << 31) } sng_ckt_flag_t; @@ -606,6 +618,14 @@ typedef enum { "INF_RESUME", \ "INF_PAUSED", \ "TX_ACM_SENT" \ + "TX_INR" \ + "INR_SENT" \ + "RX_INR" \ + "RX_INR_DN" \ + "TX_INF" \ + "INF SENT" \ + "RX_INF" \ + "RX_INF_DN" \ "RELAY_DOWN", \ "CKT_RECONFIG" FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t) @@ -820,6 +840,9 @@ void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan); void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan); void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan); void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan); +void ft_to_sngss7_inr(ftdm_channel_t * ftdmchan); +void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan); + /* in ftmod_sangoma_ss7_in.c */ @@ -949,6 +972,7 @@ ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data /* in ftmod_sangoma_ss7_timers.c */ void handle_isup_t35(void *userdata); void handle_isup_t10(void *userdata); +void handle_isup_t39(void *userdata); /******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index a228cb1ea1..b5431d8fe8 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -237,6 +237,85 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) return; } +void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan) +{ + SiCnStEvnt evnt; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + /* + const char *CallerId = NULL; + const char *CallerCat = NULL; + const char *sipvar; + */ + + memset (&evnt, 0x0, sizeof (evnt)); + + evnt.infoInd.eh.pres = PRSNT_NODEF; + + evnt.infoInd.cgPtyAddrRespInd.pres = PRSNT_NODEF; + evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_INCL; + copy_cgPtyNum_to_sngss7 (ftdmchan, &evnt.cgPtyNum); + + + evnt.infoInd.cgPtyCatRespInd.pres = PRSNT_NODEF; + evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_INCL; + copy_cgPtyCat_to_sngss7 (ftdmchan, &evnt.cgPtyCat); + + evnt.infoInd.chrgInfoRespInd.pres = PRSNT_NODEF; + evnt.infoInd.chrgInfoRespInd.val = 0; + + evnt.infoInd.solInfoInd.pres = PRSNT_NODEF; + evnt.infoInd.solInfoInd.val = 0; + + evnt.infoInd.holdProvInd.pres = PRSNT_NODEF; + evnt.infoInd.holdProvInd.val = 0; + + evnt.infoInd.spare.pres = PRSNT_NODEF; + evnt.infoInd.spare.val = 0; + + sng_cc_inf(1, + sngss7_info->suInstId, + sngss7_info->spInstId, + sngss7_info->circuit->id, + &evnt, + INFORMATION); + + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx INF\n", sngss7_info->circuit->cic); + +} + +void ft_to_sngss7_inr(ftdm_channel_t *ftdmchan) +{ + SiCnStEvnt evnt; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + memset (&evnt, 0x0, sizeof (evnt)); + + evnt.infoReqInd.eh.pres = PRSNT_NODEF; + evnt.infoReqInd.cgPtyAdReqInd.pres = PRSNT_NODEF; + evnt.infoReqInd.cgPtyAdReqInd.val=CGPRTYADDREQ_REQ; + + evnt.infoReqInd.holdingInd.pres = PRSNT_NODEF; + evnt.infoReqInd.holdingInd.val = HOLD_NOTREQ; + + evnt.infoReqInd.cgPtyCatReqInd.pres = PRSNT_NODEF; + evnt.infoReqInd.cgPtyCatReqInd.val = CGPRTYCATREQ_REQ; + + evnt.infoReqInd.chrgInfoReqInd.pres = PRSNT_NODEF; + evnt.infoReqInd.chrgInfoReqInd.val = CHRGINFO_NOTREQ; + + evnt.infoReqInd.malCaIdReqInd.pres = PRSNT_NODEF; + evnt.infoReqInd.malCaIdReqInd.val = MLBG_INFONOTREQ; + + sng_cc_inr(1, + sngss7_info->suInstId, + sngss7_info->spInstId, + sngss7_info->circuit->id, + &evnt, + INFORMATREQ); + + SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx INR\n", sngss7_info->circuit->cic); +} + void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan) { SS7_FUNC_TRACE_ENTER (__FUNCTION__); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index 4bfa5d2065..96359ba595 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -186,7 +186,7 @@ ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPt ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Calling NADI value \"%s\"\n", clg_nadi); cgPtyNum->natAddrInd.val = atoi(clg_nadi); } - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", cgPtyNum->presRest.val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number NADI value %d\n", cgPtyNum->natAddrInd.val); return copy_tknStr_to_sngss7(caller_data->cid_num.digits, &cgPtyNum->addrSig, &cgPtyNum->oddEven); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c index 6138ea34b0..8cac996213 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c @@ -49,7 +49,7 @@ /******************************************************************************/ /* PROTOTYPES *****************************************************************/ -void handle_isup_t35(void *userdata); + /******************************************************************************/ /* FUNCTIONS ******************************************************************/ @@ -76,10 +76,13 @@ void handle_isup_t35(void *userdata) /* end the call */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); - /* kill t10 if active */ + /* kill t10 t39 if active */ if (sngss7_info->t10.hb_timer_id) { ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); } + if (sngss7_info->t39.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t39.sched, sngss7_info->t39.hb_timer_id); + } /*unlock*/ ftdm_channel_unlock(ftdmchan); @@ -108,7 +111,43 @@ void handle_isup_t10(void *userdata) SS7_FUNC_TRACE_EXIT(__FUNCTION__); } - + +void handle_isup_t39(void *userdata) +{ + SS7_FUNC_TRACE_ENTER(__FUNCTION__); + + sngss7_timer_data_t *timer = userdata; + sngss7_chan_data_t *sngss7_info = timer->sngss7_info; + ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan; + + /* now that we have the right channel...put a lock on it so no-one else can use it */ + ftdm_channel_lock(ftdmchan); + + /* Q.764 2.2.5 Address incomplete (T35 expiry action is hangup with cause 28 according to Table A.1/Q.764) */ + SS7_ERROR("[Call-Control] Timer 39 expired on CIC = %d\n", sngss7_info->circuit->cic); + + /* set the flag to indicate this hangup is started from the local side */ + sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL); + + /* hang up on timer expiry */ + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_INVALID_NUMBER_FORMAT; + + /* end the call */ + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL); + + /* kill t10 t35 if active */ + if (sngss7_info->t10.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t10.sched, sngss7_info->t10.hb_timer_id); + } + if (sngss7_info->t35.hb_timer_id) { + ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id); + } + + /*unlock*/ + ftdm_channel_unlock(ftdmchan); + + SS7_FUNC_TRACE_EXIT(__FUNCTION__); +} /******************************************************************************/ /* For Emacs: * Local Variables: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index 230476d8e1..ee726911af 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -146,6 +146,7 @@ typedef struct sng_ccSpan uint32_t t16; uint32_t t17; uint32_t t35; + uint32_t t39; uint32_t tval; } sng_ccSpan_t; @@ -487,6 +488,7 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen) /* Set the transparent_iam_max_size to default value */ g_ftdm_sngss7_data.cfg.transparent_iam_max_size=800; + g_ftdm_sngss7_data.cfg.force_inr = 0; /* extract all the information from the parameters */ for (i = 0; i < num_parms; i++) { @@ -508,6 +510,14 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen) ftmod_ss7_set_glare_resolution (parm->val); SS7_DEBUG("Found glare resolution configuration = %d %s\n", g_ftdm_sngss7_data.cfg.glareResolution, parm->val ); } + else if (!strcasecmp(parm->var, "force-inr")) { + if (!strcasecmp(parm->val, "true")) { + g_ftdm_sngss7_data.cfg.force_inr = 1; + } else { + g_ftdm_sngss7_data.cfg.force_inr = 0; + } + SS7_DEBUG("Found INR force configuration = %s\n", parm->val ); + } else { SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val); return FTDM_FAIL; @@ -2062,6 +2072,11 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) sng_ccSpan.t35 = atoi(parm->val); SS7_DEBUG("Found isup t35 = %d\n",sng_ccSpan.t35); /**********************************************************************/ + } else if (!strcasecmp(parm->var, "isup.t39")) { + /**********************************************************************/ + sng_ccSpan.t39 = atoi(parm->val); + SS7_DEBUG("Found isup t39 = %d\n",sng_ccSpan.t39); + /**********************************************************************/ } else if (!strcasecmp(parm->var, "isup.tval")) { /**********************************************************************/ sng_ccSpan.tval = atoi(parm->val); @@ -3044,6 +3059,12 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) } else { g_ftdm_sngss7_data.cfg.isupCkt[x].t35 = ccSpan->t35; } + if (ccSpan->t39 == 0) { + g_ftdm_sngss7_data.cfg.isupCkt[x].t39 = 120; + } else { + g_ftdm_sngss7_data.cfg.isupCkt[x].t39 = ccSpan->t39; + } + if (ccSpan->tval == 0) { g_ftdm_sngss7_data.cfg.isupCkt[x].tval = 10; } else { @@ -3148,6 +3169,13 @@ static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan) ss7_info->t10.callback = handle_isup_t10; ss7_info->t10.sngss7_info = ss7_info; + /* prepare the timer structures */ + ss7_info->t39.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched; + ss7_info->t39.counter = 1; + ss7_info->t39.beat = (isupCkt->t39) * 100; /* beat is in ms, t39 is in 100ms */ + ss7_info->t39.callback = handle_isup_t39; + ss7_info->t39.sngss7_info = ss7_info; + /**************************************************************************/ } /* for (i == 1; i < ftdmspan->chan_count; i++) */ From 8d1c382632e86df9bcbdf290b1b702580e6e513f Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 11 Apr 2012 15:14:29 -0400 Subject: [PATCH 22/26] freetdm: INR/INF implementation - fill in IEs in INF according to INR request - print debug information if IE requested but not supported --- .../ftmod_sangoma_ss7_handle.c | 2 +- .../ftmod_sangoma_ss7_main.h | 2 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 58 ++++++++++++------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git 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 index ac309ddc3e..04dff6ee5e 100644 --- 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 @@ -474,7 +474,7 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ case (INFORMATREQ): SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx INR\n", sngss7_info->circuit->cic); - ft_to_sngss7_inf(ftdmchan); + ft_to_sngss7_inf(ftdmchan, siCnStEvnt); sngss7_set_ckt_flag(sngss7_info, FLAG_INR_RX); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index 66732bf10e..4ccf4efe0e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -841,7 +841,7 @@ void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan); void ft_to_sngss7_itx (ftdm_channel_t * ftdmchan); void ft_to_sngss7_txa (ftdm_channel_t * ftdmchan); void ft_to_sngss7_inr(ftdm_channel_t * ftdmchan); -void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan); +void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan, SiCnStEvnt *inr); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index b5431d8fe8..9ba11ada58 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -237,41 +237,55 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) return; } -void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan) +void ft_to_sngss7_inf(ftdm_channel_t *ftdmchan, SiCnStEvnt *inr) { SiCnStEvnt evnt; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; - /* - const char *CallerId = NULL; - const char *CallerCat = NULL; - const char *sipvar; - */ - + memset (&evnt, 0x0, sizeof (evnt)); evnt.infoInd.eh.pres = PRSNT_NODEF; - evnt.infoInd.cgPtyAddrRespInd.pres = PRSNT_NODEF; - evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_INCL; - copy_cgPtyNum_to_sngss7 (ftdmchan, &evnt.cgPtyNum); - - evnt.infoInd.cgPtyCatRespInd.pres = PRSNT_NODEF; - evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_INCL; - copy_cgPtyCat_to_sngss7 (ftdmchan, &evnt.cgPtyCat); evnt.infoInd.chrgInfoRespInd.pres = PRSNT_NODEF; evnt.infoInd.chrgInfoRespInd.val = 0; - evnt.infoInd.solInfoInd.pres = PRSNT_NODEF; evnt.infoInd.solInfoInd.val = 0; - evnt.infoInd.holdProvInd.pres = PRSNT_NODEF; - evnt.infoInd.holdProvInd.val = 0; - + evnt.infoInd.holdProvInd.val = 0; evnt.infoInd.spare.pres = PRSNT_NODEF; evnt.infoInd.spare.val = 0; - + + if (inr->infoReqInd.eh.pres == PRSNT_NODEF) { + if ((inr->infoReqInd.holdingInd.pres == PRSNT_NODEF) && (inr->infoReqInd.holdingInd.val == HOLD_REQ)) { + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting holding information. Holding is not supported in INF.\n", sngss7_info->circuit->cic); + } + if ((inr->infoReqInd.chrgInfoReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.chrgInfoReqInd.val == CHRGINFO_REQ)) { + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting charging information. Charging is not supported in INF.\n", sngss7_info->circuit->cic); + } + if ((inr->infoReqInd.malCaIdReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.malCaIdReqInd.val == CHRGINFO_REQ)) { + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR requesting malicious call id. Malicious call id is not supported in INF.\n", sngss7_info->circuit->cic); + } + + if ((inr->infoReqInd.cgPtyAdReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.cgPtyAdReqInd.val == CGPRTYADDREQ_REQ)) { + evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_INCL; + copy_cgPtyNum_to_sngss7 (ftdmchan, &evnt.cgPtyNum); + } else { + evnt.infoInd.cgPtyAddrRespInd.val=CGPRTYADDRESP_NOTINCL; + } + + if ((inr->infoReqInd.cgPtyCatReqInd.pres == PRSNT_NODEF) && (inr->infoReqInd.cgPtyCatReqInd.val == CGPRTYCATREQ_REQ)) { + evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_INCL; + copy_cgPtyCat_to_sngss7 (ftdmchan, &evnt.cgPtyCat); + } else { + evnt.infoInd.cgPtyCatRespInd.val = CGPRTYCATRESP_NOTINCL; + } + } + else { + SS7_DEBUG_CHAN(ftdmchan,"[CIC:%d]Received INR with no information request. Sending back default INF.\n", sngss7_info->circuit->cic); + } + sng_cc_inf(1, sngss7_info->suInstId, sngss7_info->spInstId, @@ -295,16 +309,16 @@ void ft_to_sngss7_inr(ftdm_channel_t *ftdmchan) evnt.infoReqInd.cgPtyAdReqInd.val=CGPRTYADDREQ_REQ; evnt.infoReqInd.holdingInd.pres = PRSNT_NODEF; - evnt.infoReqInd.holdingInd.val = HOLD_NOTREQ; + evnt.infoReqInd.holdingInd.val = HOLD_REQ; evnt.infoReqInd.cgPtyCatReqInd.pres = PRSNT_NODEF; evnt.infoReqInd.cgPtyCatReqInd.val = CGPRTYCATREQ_REQ; evnt.infoReqInd.chrgInfoReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.chrgInfoReqInd.val = CHRGINFO_NOTREQ; + evnt.infoReqInd.chrgInfoReqInd.val = CHRGINFO_REQ; evnt.infoReqInd.malCaIdReqInd.pres = PRSNT_NODEF; - evnt.infoReqInd.malCaIdReqInd.val = MLBG_INFONOTREQ; + evnt.infoReqInd.malCaIdReqInd.val = MLBG_INFOREQ; sng_cc_inr(1, sngss7_info->suInstId, From a796c6849c4607c73d71e0080def3bda6b3e63b9 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 13 Apr 2012 11:18:53 -0400 Subject: [PATCH 23/26] freetdm: fixed no ACM/CPG sending in some situations after native bridge - clear up ACM_SENT & CPG_SENT flag in DOWN state in native bridge state machine --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index d37a6111ab..928db54d51 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -997,6 +997,9 @@ static ftdm_status_t ftdm_sangoma_ss7_native_bridge_state_change(ftdm_channel_t ftdm_channel_t *close_chan = ftdmchan; sngss7_clear_ckt_flag(sngss7_info, FLAG_SUS_RECVD); sngss7_clear_ckt_flag(sngss7_info, FLAG_T6_CANCELED); + sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM); + sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_CPG); + sngss7_flush_queue(sngss7_info->event_queue); sngss7_info->peer_data = NULL; ftdm_channel_close (&close_chan); From cd2d67ace17b036fcdc06e2a81a0dd0021c11c92 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Apr 2012 17:26:48 -0400 Subject: [PATCH 24/26] freetdm: fixed group block/unblock state dead lock when signal link is down and recovered later To re-produce this bug: 1. do CGB on one side 2. unplug signaling link cable 3. plug signaling link cable back 4. do CGU on the blocking side 5. cic state stay in RESTART for ever Fix this problem by sending cic to SUSPENDED state after receiving/sending CGU message --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 36 +++++-------------- .../ftmod_sangoma_ss7_handle.c | 7 ++-- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index 3f1a03f4d8..df872b260c 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -35,7 +35,7 @@ * */ -#if 0 +#if 0 #define SMG_RELAY_DBG #endif @@ -1332,7 +1332,7 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, } #ifdef SMG_RELAY_DBG - stream->write_function(stream," blk_flag=%x | ckt_flag=%x | chan_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags, ftdmchan->flags); + stream->write_function(stream," | blk_flag=%x | ckt_flag=%x", ss7_info->blk_flags, ss7_info->ckt_flags); #endif stream->write_function(stream, "\n"); } /* if ( hole, sig, voice) */ @@ -1374,36 +1374,26 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c } if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - /* now that we have the right channel...put a lock on it so no-one else can use it */ ftdm_mutex_lock(ftdmchan->mutex); /* check if there is a pending state change|give it a bit to clear */ if (check_for_state_change(ftdmchan)) { SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); - /* check if we need to die */ ftdm_assert(0, "State change not completed\n"); - /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); - /* move to the next channel */ continue; } else { - /* throw the ckt block flag */ sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX); - - /* set the channel to suspended state */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); } - - /* unlock the channel again before we exit */ + ftdm_mutex_unlock(ftdmchan->mutex); + } - } /* if ( span and chan) */ + } - } /* if ( cic != 0) */ - - /* go the next circuit */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */ + } handle_show_blocks(stream, span, chan, verbose); @@ -1440,33 +1430,22 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c } if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) { - /* now that we have the right channel...put a lock on it so no-one else can use it */ ftdm_mutex_lock(ftdmchan->mutex); /* check if there is a pending state change|give it a bit to clear */ if (check_for_state_change(ftdmchan)) { SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic); - /* check if we need to die */ ftdm_assert(0, "State change not completed\n"); - /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); - /* move to the next channel */ continue; } else { - /* throw the ckt block flag */ sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX); - - /* clear the block flag */ sngss7_clear_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX); - - /* check group blocking */ sngss7_clear_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX); - /* set the channel to suspended state */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); } - /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); } @@ -1812,6 +1791,8 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c /* throw the grp maint. block flag */ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); + /* bring the sig status down */ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); @@ -1945,6 +1926,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c /* bring the sig status up */ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); /* if this is the first channel in the range */ if (!main_chan) { diff --git 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 index 04dff6ee5e..d0d6c32867 100644 --- 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 @@ -1181,11 +1181,12 @@ ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ break; /**************************************************************************/ case SIT_STA_CGBRSP: /* mntc. oriented CGB response */ - /*handle_cgb_req(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);*/ + SS7_INFO(" Rx CGBA \n"); break; /**************************************************************************/ case SIT_STA_CGURSP: /* mntc. oriented CGU response */ /*SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));*/ + SS7_INFO(" Rx CGUA \n"); break; /**************************************************************************/ case SIT_STA_GRSREQ: /* circuit group reset request */ @@ -2510,6 +2511,7 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* bring the sig status down */ sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); @@ -2665,7 +2667,8 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ if (sngss7_channel_status_clear(sngss7_info)) { sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); } - + + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); ftdm_mutex_unlock(ftdmchan->mutex); /* update the bit and byte counter*/ From e2f1b4ab27ae10990d0db0537f3ee3300c8e9bd5 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Mon, 16 Apr 2012 13:48:35 -0400 Subject: [PATCH 25/26] freetdm: fix REL receiving leg always stay in TERMINATING stae in native bridge mode - This is supposed to be included in commit of b324f8679782957bc9db3bdfd6687aa42cba77dd. Somehow it's not included in that commit. Without this change, the REL receiving leg always stay in TERMINATING state when received an incoming REL message. --- libs/freetdm/src/ftdm_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 513fc0c595..1c05797102 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2199,9 +2199,12 @@ static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char * { ftdm_status_t status = FTDM_SUCCESS; - if (ftdm_test_flag(chan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { + /* In native sigbridge mode we ignore hangup requests from the user and hangup only when the signaling module decides it */ + if (ftdm_test_flag(chan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && chan->state != FTDM_CHANNEL_STATE_TERMINATING) { + ftdm_log_chan_ex(chan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Ignoring hangup in channel in state %s (native bridge enabled)\n", ftdm_channel_state2str(chan->state)); + ftdm_set_flag(chan, FTDM_CHANNEL_USER_HANGUP); goto done; } From 4f5a6557fce63fb739f734b87c50e09764f9cbef Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 18 Apr 2012 10:52:01 -0400 Subject: [PATCH 26/26] freetdm: fix queue full problem - restore flushing queue when channel state goes to down --- .../freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index 928db54d51..1098126890 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -1599,6 +1599,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan) ftdm_channel_t *close_chan = ftdmchan; /* close the channel */ SS7_DEBUG_CHAN(ftdmchan,"FTDM Channel Close %s\n", ""); + sngss7_flush_queue(sngss7_info->event_queue); ftdm_channel_close (&close_chan); }