From 1d6926fa44d5d49f0d7e0bbef8a077d8641f7af1 Mon Sep 17 00:00:00 2001 From: rmudgett Date: Thu, 14 May 2009 22:03:49 +0000 Subject: Add outgoing_colp misdn.conf port parameter. Select what to do with outgoing COLP information on this port. 0 - Send out COLP information unaltered. (default) 1 - Force COLP to restricted on all outgoing COLP information. 2 - Do not send COLP information. outgoing_colp=0 Also fixed sending the EctInform message so it always has the required redirectionNumber parameter when the status is active. JIRA ABE-1853 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@194479 f38db490-d61c-443f-a65b-d21fe96a405b --- CHANGES | 2 ++ channels/chan_misdn.c | 66 ++++++++++++++++++++++++++++++++++---- channels/misdn/chan_misdn_config.h | 1 + channels/misdn/isdn_lib.c | 2 ++ channels/misdn/isdn_lib.h | 9 ++++++ channels/misdn/isdn_msg_parser.c | 51 +++++++++++++++++++++-------- channels/misdn_config.c | 6 ++++ configs/misdn.conf.sample | 7 ++++ 8 files changed, 124 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 59a736a7e..3496683d1 100644 --- a/CHANGES +++ b/CHANGES @@ -110,6 +110,8 @@ mISDN channel driver (chan_misdn) changes redirected-to party. You still have to set the REDIRECTING(to-xxx,i) and the REDIRECTING(from-xxx,i) values. The PTP call will update the redirecting-to presentation (COLR) when it becomes available. + * Added outgoing_colp parameter to misdn.conf to filter outgoing COLP + information. thirdparty mISDN enhancements ----------------------------- diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index b6639badd..01af221fe 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -5868,6 +5868,7 @@ static int read_config(struct chan_list *ch) misdn_cfg_get(port, MISDN_CFG_DISPLAY_CONNECTED, &bc->display_connected, sizeof(bc->display_connected)); misdn_cfg_get(port, MISDN_CFG_DISPLAY_SETUP, &bc->display_setup, sizeof(bc->display_setup)); + misdn_cfg_get(port, MISDN_CFG_OUTGOING_COLP, &bc->outgoing_colp, sizeof(bc->outgoing_colp)); misdn_cfg_get(port, MISDN_CFG_PICKUPGROUP, &pg, sizeof(pg)); misdn_cfg_get(port, MISDN_CFG_CALLGROUP, &cg, sizeof(cg)); @@ -6051,6 +6052,14 @@ static void misdn_update_connected_line(struct ast_channel *ast, struct misdn_bc } else { bc->redirecting.to = bc->caller; } + switch (bc->outgoing_colp) { + case 1:/* restricted */ + case 2:/* blocked */ + bc->redirecting.to.presentation = 1;/* restricted */ + break; + default: + break; + } ch = MISDN_ASTERISK_TECH_PVT(ast); if (ch->state == MISDN_CONNECTED @@ -6069,12 +6078,16 @@ static void misdn_update_connected_line(struct ast_channel *ast, struct misdn_bc bc->fac_out.Function = Fac_EctInform; bc->fac_out.u.EctInform.InvokeID = ++misdn_invoke_id; bc->fac_out.u.EctInform.Status = 1;/* active */ - if (bc->redirecting.to.number[0]) { - misdn_PresentedNumberUnscreened_fill(&bc->fac_out.u.EctInform.Redirection, - &bc->redirecting.to); - bc->fac_out.u.EctInform.RedirectionPresent = 1; - } else { - bc->fac_out.u.EctInform.RedirectionPresent = 0; + bc->fac_out.u.EctInform.RedirectionPresent = 1;/* Must be present when status is active */ + misdn_PresentedNumberUnscreened_fill(&bc->fac_out.u.EctInform.Redirection, + &bc->redirecting.to); + switch (bc->outgoing_colp) { + case 2:/* blocked */ + /* Block the number going out */ + bc->fac_out.u.EctInform.Redirection.Type = 1;/* presentationRestricted */ + break; + default: + break; } /* Send message */ @@ -6166,6 +6179,14 @@ static void misdn_update_redirecting(struct ast_channel *ast, struct misdn_bchan int is_ptmp; misdn_copy_redirecting_from_ast(bc, ast); + switch (bc->outgoing_colp) { + case 1:/* restricted */ + case 2:/* blocked */ + bc->redirecting.to.presentation = 1;/* restricted */ + break; + default: + break; + } if (originator != ORG_MISDN) { return; @@ -6192,6 +6213,14 @@ static void misdn_update_redirecting(struct ast_channel *ast, struct misdn_bchan bc->fac_out.u.DivertingLegInformation1.SubscriptionOption = 2;/* notificationWithDivertedToNr */ bc->fac_out.u.DivertingLegInformation1.DivertedToPresent = 1; misdn_PresentedNumberUnscreened_fill(&bc->fac_out.u.DivertingLegInformation1.DivertedTo, &bc->redirecting.to); + switch (bc->outgoing_colp) { + case 2:/* blocked */ + /* Block the number going out */ + bc->fac_out.u.DivertingLegInformation1.DivertedTo.Type = 1;/* presentationRestricted */ + break; + default: + break; + } print_facility(&bc->fac_out, bc); misdn_lib_send_event(bc, EVENT_FACILITY); } @@ -6368,6 +6397,14 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) } misdn_copy_redirecting_from_ast(newbc, ast); + switch (newbc->outgoing_colp) { + case 1:/* restricted */ + case 2:/* blocked */ + newbc->redirecting.from.presentation = 1;/* restricted */ + break; + default: + break; + } #if defined(AST_MISDN_ENHANCEMENTS) if (newbc->redirecting.from.number[0] && misdn_lib_is_ptp(port)) { /* Create DivertingLegInformation2 facility */ @@ -6381,6 +6418,14 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) misdn_PresentedNumberUnscreened_fill( &newbc->fac_out.u.DivertingLegInformation2.Diverting, &newbc->redirecting.from); + switch (newbc->outgoing_colp) { + case 2:/* blocked */ + /* Block the number going out */ + newbc->fac_out.u.DivertingLegInformation2.Diverting.Type = 1;/* presentationRestricted */ + break; + default: + break; + } newbc->fac_out.u.DivertingLegInformation2.OriginalCalledPresent = 0; if (1 < newbc->redirecting.count) { newbc->fac_out.u.DivertingLegInformation2.OriginalCalledPresent = 1; @@ -6512,6 +6557,15 @@ static int misdn_answer(struct ast_channel *ast) p->bc->connected.number_plan = p->bc->dialed.number_plan; } + switch (p->bc->outgoing_colp) { + case 1:/* restricted */ + case 2:/* blocked */ + p->bc->connected.presentation = 1;/* restricted */ + break; + default: + break; + } + #if defined(AST_MISDN_ENHANCEMENTS) if (p->bc->div_leg_3_tx_pending) { p->bc->div_leg_3_tx_pending = 0; diff --git a/channels/misdn/chan_misdn_config.h b/channels/misdn/chan_misdn_config.h index 140e1ee26..40df71f97 100644 --- a/channels/misdn/chan_misdn_config.h +++ b/channels/misdn/chan_misdn_config.h @@ -66,6 +66,7 @@ enum misdn_cfg_elements { MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ MISDN_CFG_ECHOCANCEL, /* int */ MISDN_CFG_CC_REQUEST_RETENTION,/* bool */ + MISDN_CFG_OUTGOING_COLP, /* int */ #ifdef MISDN_1_2 MISDN_CFG_PIPELINE, /* char[] */ #endif diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c index c0a4170e2..ec8f37f09 100644 --- a/channels/misdn/isdn_lib.c +++ b/channels/misdn/isdn_lib.c @@ -753,6 +753,8 @@ static void empty_bc(struct misdn_bchannel *bc) bc->display_connected = 0; /* none */ bc->display_setup = 0; /* none */ + bc->outgoing_colp = 0;/* pass */ + bc->presentation = 0; /* allowed */ bc->set_presentation = 0; diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h index df11659c3..934be9830 100644 --- a/channels/misdn/isdn_lib.h +++ b/channels/misdn/isdn_lib.h @@ -589,6 +589,15 @@ struct misdn_bchannel { */ int display_setup; + /*! + * \brief Select what to do with outgoing COLP information. + * \details + * 0 - pass (Send out COLP information unaltered.) + * 1 - restricted (Force COLP to restricted on all outgoing COLP information.) + * 2 - block (Do not send COLP information.) + */ + int outgoing_colp; + /*! \brief User set presentation restriction code * 0=Allowed, 1=Restricted, 2=Unavailable * \note It is settable by the misdn_set_opt() application. diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c index 4201cab2e..fa1560e5d 100644 --- a/channels/misdn/isdn_msg_parser.c +++ b/channels/misdn/isdn_msg_parser.c @@ -519,18 +519,26 @@ static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, in enc_ie_called_pn(&setup->CALLED_PN, msg, bc->dialed.number_type, bc->dialed.number_plan, bc->dialed.number, nt, bc); } - if (bc->redirecting.from.number[0]) { + switch (bc->outgoing_colp) { + case 0:/* pass */ + case 1:/* restricted */ + if (bc->redirecting.from.number[0]) { #if 1 - /* ETSI and Q.952 do not define the screening field */ - enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, bc->redirecting.from.number_plan, - bc->redirecting.from.presentation, 0, bc->redirecting.reason, - bc->redirecting.from.number, nt, bc); + /* ETSI and Q.952 do not define the screening field */ + enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, + bc->redirecting.from.number_plan, bc->redirecting.from.presentation, 0, + bc->redirecting.reason, bc->redirecting.from.number, nt, bc); #else - /* Q.931 defines the screening field */ - enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, bc->redirecting.from.number_plan, - bc->redirecting.from.presentation, bc->redirecting.from.screening, bc->redirecting.reason, - bc->redirecting.from.number, nt, bc); + /* Q.931 defines the screening field */ + enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, + bc->redirecting.from.number_plan, bc->redirecting.from.presentation, + bc->redirecting.from.screening, bc->redirecting.reason, + bc->redirecting.from.number, nt, bc); #endif + } + break; + default: + break; } if (bc->keypad[0]) { @@ -667,8 +675,16 @@ static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, enc_ie_date(&connect->DATE, msg, now, nt,bc); } - enc_ie_connected_pn(&connect->CONNECT_PN, msg, bc->connected.number_type, bc->connected.number_plan, - bc->connected.presentation, bc->connected.screening, bc->connected.number, nt, bc); + switch (bc->outgoing_colp) { + case 0:/* pass */ + case 1:/* restricted */ + enc_ie_connected_pn(&connect->CONNECT_PN, msg, bc->connected.number_type, + bc->connected.number_plan, bc->connected.presentation, + bc->connected.screening, bc->connected.number, nt, bc); + break; + default: + break; + } if (nt && bc->connected.presentation == 0) { char display[sizeof(bc->display)]; @@ -1456,9 +1472,16 @@ static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, i if (bc->redirecting.to_changed) { bc->redirecting.to_changed = 0; - enc_ie_redir_dn(¬ify->REDIR_DN, msg, bc->redirecting.to.number_type, - bc->redirecting.to.number_plan, bc->redirecting.to.presentation, - bc->redirecting.to.number, nt, bc); + switch (bc->outgoing_colp) { + case 0:/* pass */ + case 1:/* restricted */ + enc_ie_redir_dn(¬ify->REDIR_DN, msg, bc->redirecting.to.number_type, + bc->redirecting.to.number_plan, bc->redirecting.to.presentation, + bc->redirecting.to.number, nt, bc); + break; + default: + break; + } } return msg; } diff --git a/channels/misdn_config.c b/channels/misdn_config.c index 293b8f8cb..1b645f27c 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -221,6 +221,12 @@ static const struct misdn_cfg_spec port_spec[] = { "\n" "\tscreen=0, presentation=0 -> callerid presented\n" "\tscreen=1, presentation=1 -> callerid restricted (the remote end doesn't see it!)" }, + { "outgoing_colp", MISDN_CFG_OUTGOING_COLP, MISDN_CTYPE_INT, "0", NONE, + "Select what to do with outgoing COLP information on this port.\n" + "\n" + "\t0 - Send out COLP information unaltered.\n" + "\t1 - Force COLP to restricted on all outgoing COLP information.\n" + "\t2 - Do not send COLP information." }, { "display_connected", MISDN_CFG_DISPLAY_CONNECTED, MISDN_CTYPE_INT, "0", NONE, "Put a display ie in the CONNECT message containing the following\n" "\tinformation if it is available (nt port only):\n" diff --git a/configs/misdn.conf.sample b/configs/misdn.conf.sample index 07cff4de4..f4ca486e9 100644 --- a/configs/misdn.conf.sample +++ b/configs/misdn.conf.sample @@ -397,6 +397,13 @@ nodialtone=no presentation=-1 screen=-1 +; Select what to do with outgoing COLP information on this port. +; +; 0 - Send out COLP information unaltered. (default) +; 1 - Force COLP to restricted on all outgoing COLP information. +; 2 - Do not send COLP information. +outgoing_colp=0 + ; Put a display ie in the CONNECT message containing the following ; information if it is available (nt port only): ; -- cgit v1.2.3