diff options
author | Richard Mudgett <rmudgett@digium.com> | 2011-09-22 21:42:35 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2011-09-22 21:42:35 +0000 |
commit | e39f6bba334793858a81f9558e3b5c1dae435d93 (patch) | |
tree | d72e87d1994386e44cb701385eac794384cf7ee7 /channels/sig_pri.c | |
parent | cbde0c243135a1390b1fb379ac0b82893711891d (diff) |
Merged revisions 337721 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10
................
r337721 | rmudgett | 2011-09-22 16:37:41 -0500 (Thu, 22 Sep 2011) | 25 lines
Merged revisions 337720 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r337720 | rmudgett | 2011-09-22 16:29:46 -0500 (Thu, 22 Sep 2011) | 18 lines
Made ISDN not add numbering plan prefix strings to empty numbers.
When the Caller-ID is restricted, the expected behavior is for the
Caller-ID to be blank. In chan_dahdi, the national prefix is placed onto
the Caller-ID number even if it is restricted (empty) causing the
Caller-ID to be the national prefix rather than blank.
This behavior was lost when sig_pri was extracted from chan_dahdi.
* Made not add prefix strings to empty connected line, calling, and ANI
number strings.
(closes issue ASTERISK-18577)
Reported by: Kris Shaw
Patches:
jira_asterisk_18577_v1.8.patch (license #5621) patch uploaded by rmudgett
Tested by: Kris Shaw
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sig_pri.c')
-rw-r--r-- | channels/sig_pri.c | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 5da65a268..533d6ccd5 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -1544,7 +1544,19 @@ static char *dialplan2str(int dialplan) return (pri_plan2str(dialplan)); } -static void apply_plan_to_number(char *buf, size_t size, const struct sig_pri_span *pri, const char *number, const int plan) +/*! + * \internal + * \brief Apply numbering plan prefix to the given number. + * + * \param buf Buffer to put number into. + * \param size Size of given buffer. + * \param pri PRI span control structure. + * \param number Number to apply numbering plan. + * \param plan Numbering plan to apply. + * + * \return Nothing + */ +static void apply_plan_to_number(char *buf, size_t size, const struct sig_pri_span *pri, const char *number, int plan) { switch (plan) { case PRI_INTERNATIONAL_ISDN: /* Q.931 dialplan == 0x11 international dialplan => prepend international prefix digits */ @@ -1570,6 +1582,30 @@ static void apply_plan_to_number(char *buf, size_t size, const struct sig_pri_sp /*! * \internal + * \brief Apply numbering plan prefix to the given number if the number exists. + * + * \param buf Buffer to put number into. + * \param size Size of given buffer. + * \param pri PRI span control structure. + * \param number Number to apply numbering plan. + * \param plan Numbering plan to apply. + * + * \return Nothing + */ +static void apply_plan_to_existing_number(char *buf, size_t size, const struct sig_pri_span *pri, const char *number, int plan) +{ + /* Make sure a number exists so the prefix isn't placed on an empty string. */ + if (ast_strlen_zero(number)) { + if (size) { + *buf = '\0'; + } + return; + } + apply_plan_to_number(buf, size, pri, number, plan); +} + +/*! + * \internal * \brief Restart the next channel we think is idle on the span. * * \param pri PRI span control structure. @@ -1950,7 +1986,8 @@ static void sig_pri_party_number_convert(struct ast_party_number *ast_number, co { char number[AST_MAX_EXTENSION]; - apply_plan_to_number(number, sizeof(number), pri, pri_number->str, pri_number->plan); + apply_plan_to_existing_number(number, sizeof(number), pri, pri_number->str, + pri_number->plan); ast_number->str = ast_strdup(number); ast_number->plan = pri_number->plan; ast_number->presentation = pri_to_ast_presentation(pri_number->presentation); @@ -5541,7 +5578,7 @@ static void *pri_dchannel(void *vpri) if (e) { if (pri->debug) { - ast_verbose("Span: %d Processing event: %s(%d)\n", + ast_verbose("Span %d: Processing event %s(%d)\n", pri->span, pri_event2str(e->e), e->e); } @@ -5870,24 +5907,23 @@ static void *pri_dchannel(void *vpri) pri->pvts[chanpos]->call = e->ring.call; /* Use plancallingnum as a scratch buffer since it is initialized next. */ - apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, + apply_plan_to_existing_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.redirectingnum, e->ring.callingplanrdnis); sig_pri_set_rdnis(pri->pvts[chanpos], plancallingnum); /* Setup caller-id info */ - apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan); + apply_plan_to_existing_number(plancallingnum, sizeof(plancallingnum), pri, + e->ring.callingnum, e->ring.callingplan); pri->pvts[chanpos]->cid_ani2 = 0; if (pri->pvts[chanpos]->use_callerid) { ast_shrink_phone_number(plancallingnum); ast_copy_string(pri->pvts[chanpos]->cid_num, plancallingnum, sizeof(pri->pvts[chanpos]->cid_num)); #ifdef PRI_ANI - if (!ast_strlen_zero(e->ring.callingani)) { - apply_plan_to_number(plancallingani, sizeof(plancallingani), pri, e->ring.callingani, e->ring.callingplanani); - ast_shrink_phone_number(plancallingani); - ast_copy_string(pri->pvts[chanpos]->cid_ani, plancallingani, sizeof(pri->pvts[chanpos]->cid_ani)); - } else { - pri->pvts[chanpos]->cid_ani[0] = '\0'; - } + apply_plan_to_existing_number(plancallingani, sizeof(plancallingani), + pri, e->ring.callingani, e->ring.callingplanani); + ast_shrink_phone_number(plancallingani); + ast_copy_string(pri->pvts[chanpos]->cid_ani, plancallingani, + sizeof(pri->pvts[chanpos]->cid_ani)); #endif pri->pvts[chanpos]->cid_subaddr[0] = '\0'; #if defined(HAVE_PRI_SUBADDR) |