replace use of ani in favor of dnis in caller_data structure for the destiny number in outgoing calls

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@1017 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva 2010-02-01 21:40:01 +00:00
parent 3e8ee9b3e8
commit 926f140754
8 changed files with 36 additions and 30 deletions

View File

@ -1130,24 +1130,24 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
if (!zstr(dest)) {
ftdm_set_string(caller_data.ani.digits, dest);
ftdm_set_string(caller_data.dnis.digits, dest);
}
if ((var = switch_event_get_header(var_event, "freetdm_outbound_ton")) || (var = switch_core_get_variable("freetdm_outbound_ton"))) {
if (!strcasecmp(var, "national")) {
caller_data.ani.type = FTDM_TON_NATIONAL;
caller_data.dnis.type = FTDM_TON_NATIONAL;
} else if (!strcasecmp(var, "international")) {
caller_data.ani.type = FTDM_TON_INTERNATIONAL;
caller_data.dnis.type = FTDM_TON_INTERNATIONAL;
} else if (!strcasecmp(var, "local")) {
caller_data.ani.type = FTDM_TON_SUBSCRIBER_NUMBER;
caller_data.dnis.type = FTDM_TON_SUBSCRIBER_NUMBER;
} else if (!strcasecmp(var, "unknown")) {
caller_data.ani.type = FTDM_TON_UNKNOWN;
caller_data.dnis.type = FTDM_TON_UNKNOWN;
}
} else {
caller_data.ani.type = outbound_profile->destination_number_ton;
caller_data.dnis.type = outbound_profile->destination_number_ton;
}
caller_data.ani.plan = outbound_profile->destination_number_numplan;
caller_data.dnis.plan = outbound_profile->destination_number_numplan;
#if 0

View File

@ -669,11 +669,11 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj)
ftdm_log(FTDM_LOG_ERROR, "Failure indication detected!\n");
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY);
} else if (ftdmchan->detected_tones[FTDM_TONEMAP_DIAL]) {
if (ftdm_strlen_zero(ftdmchan->caller_data.ani.digits)) {
if (ftdm_strlen_zero(ftdmchan->caller_data.dnis.digits)) {
ftdm_log(FTDM_LOG_ERROR, "No Digits to send!\n");
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY);
} else {
if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.ani.digits) != FTDM_SUCCESS) {
if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.dnis.digits) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Send Digits Failed [%s]\n", ftdmchan->last_error);
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY);
} else {
@ -683,7 +683,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj)
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL1] = 1;
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL2] = 1;
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL3] = 1;
dial_timeout = ((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.ani.digits)) + 2000;
dial_timeout = ((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.dnis.digits)) + 2000;
}
}
} else if (ftdmchan->detected_tones[FTDM_TONEMAP_RING]) {

View File

@ -248,11 +248,11 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj)
{
if (! ftdmchan->needed_tones[FTDM_TONEMAP_RING]
&& ftdm_test_flag(ftdmchan, FTDM_CHANNEL_WINK)) {
if (ftdm_strlen_zero(ftdmchan->caller_data.ani.digits)) {
if (ftdm_strlen_zero(ftdmchan->caller_data.dnis.digits)) {
ftdm_log(FTDM_LOG_ERROR, "No Digits to send!\n");
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY);
} else {
if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.ani.digits) != FTDM_SUCCESS) {
if (ftdm_channel_command(ftdmchan, FTDM_COMMAND_SEND_DTMF, ftdmchan->caller_data.dnis.digits) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Send Digits Failed [%s]\n", ftdmchan->last_error);
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY);
} else {
@ -262,7 +262,7 @@ static void *ftdm_analog_em_channel_run(ftdm_thread_t *me, void *obj)
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL1] = 1;
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL2] = 1;
ftdmchan->needed_tones[FTDM_TONEMAP_FAIL3] = 1;
dial_timeout = ((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.ani.digits)) + 2000;
dial_timeout = ((ftdmchan->dtmf_on + ftdmchan->dtmf_off) * strlen(ftdmchan->caller_data.dnis.digits)) + 2000;
}
}
break;

View File

@ -411,10 +411,10 @@ static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request)
Q931InitIECalledNum(&CalledNum);
CalledNum.TypNum = Q931_TON_UNKNOWN;
CalledNum.NumPlanID = Q931_NUMPLAN_E164;
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(caller_data->ani.digits);
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(caller_data->dnis.digits);
gen->CalledNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CalledNum);
ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf);
ftdm_copy_string((char *)ptrCalledNum->Digit, caller_data->ani.digits, strlen(caller_data->ani.digits)+1);
ftdm_copy_string((char *)ptrCalledNum->Digit, caller_data->dnis.digits, strlen(caller_data->dnis.digits)+1);
/*
* High-Layer Compatibility IE (Note: Required for AVM FritzBox)
@ -1374,12 +1374,12 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
* CalledNum IE
*/
Q931InitIECalledNum(&CalledNum);
CalledNum.TypNum = Q931_TON_UNKNOWN;
CalledNum.TypNum = ftdmchan->caller_data.dnis.type;
CalledNum.NumPlanID = Q931_NUMPLAN_E164;
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(ftdmchan->caller_data.ani.digits);
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(ftdmchan->caller_data.dnis.digits);
gen->CalledNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CalledNum);
ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf);
ftdm_copy_string((char *)ptrCalledNum->Digit, ftdmchan->caller_data.ani.digits, strlen(ftdmchan->caller_data.ani.digits)+1);
ftdm_copy_string((char *)ptrCalledNum->Digit, ftdmchan->caller_data.dnis.digits, strlen(ftdmchan->caller_data.dnis.digits)+1);
/*
* High-Layer Compatibility IE (Note: Required for AVM FritzBox)

View File

@ -526,7 +526,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
}
dp = ftdmchan->caller_data.ani.type;
dp = ftdmchan->caller_data.dnis.type;
switch(dp) {
case FTDM_TON_NATIONAL:
dp = PRI_NATIONAL_ISDN;
@ -546,7 +546,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
assert(sr);
pri_sr_set_channel(sr, ftdmchan->chan_id, 0, 0);
pri_sr_set_bearer(sr, 0, isdn_data->l1);
pri_sr_set_called(sr, ftdmchan->caller_data.ani.digits, dp, 1);
pri_sr_set_called(sr, ftdmchan->caller_data.dnis.digits, dp, 1);
pri_sr_set_caller(sr, ftdmchan->caller_data.cid_num.digits, (isdn_data->opts & FTMOD_LIBPRI_OPT_OMIT_DISPLAY_IE ? NULL : ftdmchan->caller_data.cid_name),
dp, (ftdmchan->caller_data.pres != 1 ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_PROHIB_USER_NUMBER_NOT_SCREENED));

View File

@ -984,7 +984,7 @@ static void *ftdm_r2_channel_run(ftdm_thread_t *me, void *obj)
// FIXME: use user defined calling party
ftdm_channel_use(ftdmchan);
ftdm_log(FTDM_LOG_DEBUG, "DIALING: Starting processing of outgoing call in channel %d with interval %d\n", ftdmchan->physical_chan_id, interval);
if (openr2_chan_make_call(r2chan, ftdmchan->caller_data.cid_num.digits, ftdmchan->caller_data.ani.digits, OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER)) {
if (openr2_chan_make_call(r2chan, ftdmchan->caller_data.cid_num.digits, ftdmchan->caller_data.dnis.digits, OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER)) {
ftdm_log(FTDM_LOG_ERROR, "%d:%d Failed to make call in R2 channel, openr2_chan_make_call failed\n", ftdmchan->span_id, ftdmchan->chan_id);
ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER;
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);

View File

@ -294,7 +294,7 @@ static FIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
sangomabc_event_t event = {0};
int boost_request_timeout = 5000;
sangoma_boost_request_status_t st;
char ani[128] = "";
char dnis[128] = "";
char *gr = NULL;
uint32_t count = 0;
int tg=0;
@ -304,7 +304,7 @@ static FIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
return FTDM_FAIL;
}
ftdm_set_string(ani, caller_data->ani.digits);
ftdm_set_string(dnis, caller_data->dnis.digits);
r = next_request_id();
if (r == 0) {
@ -312,7 +312,7 @@ static FIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
*ftdmchan = NULL;
return FTDM_FAIL;
}
sangomabc_call_init(&event, caller_data->cid_num.digits, ani, r);
sangomabc_call_init(&event, caller_data->cid_num.digits, dnis, r);
if (sangoma_boost_data->sigmod) {
*ftdmchan = span->channels[chan_id];
@ -325,7 +325,7 @@ static FIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
OUTBOUND_REQUESTS[r].ftdmchan = *ftdmchan;
} else {
if ((gr = strchr(ani, '@'))) {
if ((gr = strchr(dnis, '@'))) {
*gr++ = '\0';
}

View File

@ -190,6 +190,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_signaling_event)
}
/* release any timer for this channel */
release_timers(sigmsg->channel);
/* acknowledge the hangup */
ftdm_set_state_locked(sigmsg->channel, FTDM_CHANNEL_STATE_HANGUP);
break;
default:
ftdm_log(FTDM_LOG_WARNING, "Unhandled event %s in channel %d:%d\n", ftdm_signal_event2str(sigmsg->event_id),
@ -205,28 +207,32 @@ static void place_call(const ftdm_span_t *span, const char *number)
ftdm_caller_data_t caller_data = {{ 0 }};
ftdm_status_t status = FTDM_FAIL;
caller_data.ani.type = FTDM_TON_NATIONAL;
/* set destiny number (FIXME: this should be DNIS member in FreeTDM core and signaling module) */
ftdm_set_string(caller_data.ani.digits, number);
/* set destiny number */
ftdm_set_string(caller_data.dnis.digits, number);
/* set callerid */
ftdm_set_string(caller_data.cid_name, "testsangomaboost");
ftdm_set_string(caller_data.cid_num.digits, "1234");
/* request to search for an outgoing channel top down with the given caller data */
/* request to search for an outgoing channel top down with the given caller data.
* it is also an option to use ftdm_channel_open_by_group to let freetdm hunt
* an available channel in a given group instead of per span
* */
status = ftdm_channel_open_by_span(span->span_id, FTDM_TOP_DOWN, &caller_data, &ftdmchan);
if (status != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
return;
}
g_outgoing_channel = ftdmchan;
status = ftdm_channel_outgoing_call(ftdmchan);
if (status != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
return;
}
/* this is required to initialize the outgoing channel */
ftdm_channel_init(ftdmchan);
}