Index: src/openr2/r2context.h =================================================================== --- src/openr2/r2context.h (revisión: 39) +++ src/openr2/r2context.h (copia de trabajo) @@ -216,6 +216,9 @@ /* whether or not to get the ANI before getting DNIS */ int get_ani_first; + /* whether or not accept the call bypassing the use of group B and II tones */ + int immediate_accept; + /* MF threshold time in ms */ int mf_threshold; @@ -247,6 +250,8 @@ int openr2_context_get_max_dnis(openr2_context_t *r2context); void openr2_context_set_ani_first(openr2_context_t *r2context, int ani_first); int openr2_context_get_ani_first(openr2_context_t *r2context); +void openr2_context_set_immediate_accept(openr2_context_t *r2context, int immediate_accept); +int openr2_context_get_immediate_accept(openr2_context_t *r2context); void openr2_context_set_log_level(openr2_context_t *r2context, openr2_log_level_t level); openr2_log_level_t openr2_context_get_log_level(openr2_context_t *r2context); void openr2_context_set_mf_threshold(openr2_context_t *r2context, int threshold); Index: src/r2proto.c =================================================================== --- src/r2proto.c (revisión: 39) +++ src/r2proto.c (copia de trabajo) @@ -289,6 +289,9 @@ and continuing with DNIS at the end */ r2context->get_ani_first = 1; + /* accept the call bypassing the use of group B and II tones */ + r2context->immediate_accept = 0; + /* Group A tones. Requests of ANI, DNIS and Calling Party Category */ r2context->mf_ga_tones.request_next_dnis_digit = OR2_MF_TONE_1; r2context->mf_ga_tones.request_next_ani_digit = OR2_MF_TONE_5; @@ -1034,6 +1037,19 @@ prepare_mf_tone(r2chan, change_tone); } +static void bypass_change_to_g2(openr2_chan_t *r2chan) +{ + OR2_CHAN_STACK; + /* Most variants of MFC/R2 offer a way to go directly to the call accepted state, + bypassing the use of group B and II tones */ + int accept_tone = GA_TONE(r2chan).address_complete_charge_setup; + r2chan->mf_state = OR2_MF_ACCEPTED_TXD; + r2chan->call_state = OR2_CALL_OFFERED; + openr2_log(r2chan, OR2_LOG_DEBUG, "By-passing B/II signals, accept the call with signal 0x%X\n", accept_tone); + prepare_mf_tone(r2chan, accept_tone); + EMI(r2chan)->on_call_offered(r2chan, r2chan->ani, r2chan->dnis, tone2category(r2chan)); +} + static void mf_back_cycle_timeout_expired(openr2_chan_t *r2chan, void *data) { OR2_CHAN_STACK; @@ -1056,8 +1072,13 @@ request_calling_party_category(r2chan); } else { /* ANI must have been retrieved already (before DNIS), - let's go directly to GII, the final stage */ - request_change_to_g2(r2chan); + let's go directly to GII or directly accept the call without changing + to GII if immediate_accept has been setted, the final stage */ + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } } else { openr2_log(r2chan, OR2_LOG_WARNING, "MF back cycle timed out!\n"); @@ -1093,7 +1114,11 @@ if (1 == r2chan->dnis_len || !r2chan->r2context->get_ani_first) { request_calling_party_category(r2chan); } else { - request_change_to_g2(r2chan); + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } } else if (1 == r2chan->dnis_len && r2chan->r2context->get_ani_first) { request_calling_party_category(r2chan); @@ -1106,7 +1131,11 @@ if (0 == r2chan->dnis_len || !r2chan->r2context->get_ani_first) { request_calling_party_category(r2chan); } else { - request_change_to_g2(r2chan); + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } } else { /* we were supposed to handle DNIS, but the tone @@ -1179,7 +1208,11 @@ } else { openr2_log(r2chan, OR2_LOG_DEBUG, "Done getting ANI!\n"); if (!r2chan->r2context->get_ani_first || DNIS_COMPLETE(r2chan)) { - request_change_to_g2(r2chan); + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } else { request_next_dnis_digit(r2chan); } @@ -1194,7 +1227,11 @@ r2chan->caller_ani_is_restricted = 1; } if (!r2chan->r2context->get_ani_first || DNIS_COMPLETE(r2chan)) { - request_change_to_g2(r2chan); + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } else { request_next_dnis_digit(r2chan); } @@ -1239,7 +1276,11 @@ mf_receive_expected_ani(r2chan, 0); } else { /* switch to Group B/II, we're ready to answer! */ - request_change_to_g2(r2chan); + if (r2chan->r2context->immediate_accept) { + bypass_change_to_g2(r2chan); + } else { + request_change_to_g2(r2chan); + } } break; /* we requested more ANI */ @@ -1318,8 +1359,19 @@ set_silence(r2chan); switch (r2chan->mf_group) { case OR2_MF_GA: - /* no further action required. The other end should - handle our previous request */ + switch (r2chan->mf_state) { + /* a bypass of the change to B/II signals has been setted, + proceed to accept the call */ + case OR2_MF_ACCEPTED_TXD: + r2chan->mf_state = OR2_MF_OFF_STATE; + r2chan->call_state = OR2_CALL_ACCEPTED; + openr2_chan_set_timer(r2chan, OR2_PROTO_ANSWER_WAIT_TIME, ready_to_answer, NULL); + break; + default: + /* no further action required. The other end should + handle our previous request */ + break; + } break; case OR2_MF_GB: switch (r2chan->mf_state) { Index: src/r2context.c =================================================================== --- src/r2context.c (revisión: 39) +++ src/r2context.c (copia de trabajo) @@ -365,6 +365,18 @@ return r2context->get_ani_first; } +void openr2_context_set_immediate_accept(openr2_context_t *r2context, int immediate_accept) +{ + OR2_CONTEXT_STACK; + r2context->immediate_accept = immediate_accept ? 1 : 0; +} + +int openr2_context_get_immediate_accept(openr2_context_t *r2context) +{ + OR2_CONTEXT_STACK; + return r2context->immediate_accept; +} + void openr2_context_set_log_level(openr2_context_t *r2context, openr2_log_level_t level) { OR2_CONTEXT_STACK;