q931.c: Lucent switch implementation bug workaround.

A bug in a Lucent switch implementation sets the Connected Number
information element octet 3 extension bit.  When set that means octet 3 is
complete and thus there is no optional octet 3a.  However, the buggy
switch still sends octet 3a.  The unexpected octet 3a is interpreted as
the first octet 4 and thus the first character in the connected line
number is a garbage character.

* Work around the switch bug by checking octet 3 and the potential octet
3a extension bits.  If they are both set then assume that octet 3a is
actually present for the buggy switch types.

PRI-183 #close
Reported by: Richard Mudgett

Change-Id: I378af37bfd852737a0bfe6263ef3473ea6acfbad
This commit is contained in:
Richard Mudgett 2016-07-01 13:07:17 -05:00
parent 90019b935a
commit d2585d6da2

51
q931.c
View File

@ -2351,7 +2351,30 @@ static int receive_connected_number(int full_ie, struct pri *ctrl, q931_call *ca
switch (i) { switch (i) {
case 0: case 0:
call->remote_id.number.plan = ie->data[i] & 0x7f; call->remote_id.number.plan = ie->data[i] & 0x7f;
/*
* Work around a bug in a Lucent switch implementation that
* sets the extension bit in octet 3 even though octet 3a
* is present.
*/
if (ie->data[i] & 0x80) {
/* Octet 3 extension bit is set */
if (ctrl->switchtype != PRI_SWITCH_LUCENT5E
&& ctrl->switchtype != PRI_SWITCH_ATT4ESS) {
/* Not a potentially buggy switch type. */
break; break;
}
if (!(ie->data[i + 1] & 0x80)) {
/*
* The possible octet 3a doesn't have the extension
* bit set. It is likely not the erroneous octet 3a.
*/
break;
}
}
/* Octet 3a is present */
++i;
/* Fall through */
case 1: case 1:
/* Keep only the presentation and screening fields */ /* Keep only the presentation and screening fields */
call->remote_id.number.presentation = call->remote_id.number.presentation =
@ -2393,7 +2416,35 @@ static void dump_connected_number(int full_ie, struct pri *ctrl, q931_ie *ie, in
prefix, ie2str(full_ie), len, ie->data[0] >> 7, prefix, ie2str(full_ie), len, ie->data[0] >> 7,
ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f); npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
/*
* Work around a bug in a Lucent switch implementation that
* sets the extension bit in octet 3 even though octet 3a
* is present.
*/
if (ie->data[i] & 0x80) {
/* Octet 3 extension bit is set */
if (ctrl->switchtype != PRI_SWITCH_LUCENT5E
&& ctrl->switchtype != PRI_SWITCH_ATT4ESS) {
/* Not a potentially buggy switch type. */
break; break;
}
if (!(ie->data[i + 1] & 0x80)) {
/*
* The possible octet 3a doesn't have the extension
* bit set. It is likely not the erroneous octet 3a.
*/
break;
}
pri_message(ctrl, "\n");
pri_message(ctrl, "%c Switch bug workaround.\n",
prefix);
pri_message(ctrl, "%c Assuming octet 3a is present.",
prefix);
}
/* Octet 3a is present */
++i;
/* Fall through */
case 1: /* Octet 3a */ case 1: /* Octet 3a */
pri_message(ctrl, "\n"); pri_message(ctrl, "\n");
pri_message(ctrl, "%c Ext: %d Presentation: %s (%d)", pri_message(ctrl, "%c Ext: %d Presentation: %s (%d)",