Compare commits

..

6 Commits

Author SHA1 Message Date
Sergey V. Lobanov
9ace221ca0 Makefile: Add the ability to build libpri on MacOS for Linux target.
This patch allows to redefine ar and ranlib tool using AR and
RANLIB make flags.

PRI-188 #close

Change-Id: I6554c57b6fab4d73bc752d4d9b878834aa86d1f1
2022-05-19 21:11:46 -05:00
bbabic
a7a2245b12 q931.c: Fix subaddress finding octet 4.
Some switches have extended subaddress ie octet 3 encoding to be
multi-octet.

* Update dump and receive helper functions to search for the end of octet
3 encoding to determine where octet 4 starts.

ASTERISK-27342

Change-Id: I5b2706f668e1a4664b020a58de41dad4cbc5c7e6
2017-10-23 12:27:42 -05:00
Tzafrir Cohen
c038af7892 Makefile: Use CPPFLAGS
* Include the value of CPPFLAGS in CFLAGS

Change-Id: Id8e6f3a231bf7581f3f37576b9ee6849ed59540a
2016-12-05 12:40:02 -06:00
Richard Mudgett
f8e6096bfe q931.c: Lucent switch implementation bug workaround (Part 2)
Work around a bug in a Lucent switch implementation that sets the
extension bit in octet 3 even though octet 3a is present.

The same issue was seen in a NI2 switch implementation.  It was probably a
Lucent switch configured for NI2 operation.  To avoid further surprises,
I'm going to enable the work around for all North American switch types.

PRI-183
Reported by: Richard Mudgett

Change-Id: I7eedbf68b7c3d9c868d9533012e4cea5142af281
2016-10-04 14:27:59 -05:00
Richard Mudgett
d2585d6da2 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
2016-07-20 16:36:41 -05:00
Richard Mudgett
90019b935a q931.c: Add number ie specification references.
Change-Id: I0d15804963501d1e4063a581db756ff26513065b
2016-06-30 20:15:50 -05:00
7 changed files with 112 additions and 2405 deletions

View File

@@ -1 +0,0 @@
0

View File

@@ -1 +0,0 @@
1.5.0

2213
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,8 @@
CC=gcc
GREP=grep
AWK=awk
AR=ar
RANLIB=ranlib
OSARCH=$(shell uname -s)
PROC?=$(shell uname -m)
@@ -67,6 +69,7 @@ STATIC_OBJS= \
DYNAMIC_OBJS= \
$(STATIC_OBJS)
CFLAGS ?= -g
CFLAGS += $(CPPFLAGS)
CFLAGS += -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -fPIC $(ALERTING) $(LIBPRI_OPT) $(COVERAGE_CFLAGS)
INSTALL_PREFIX=$(DESTDIR)
@@ -192,8 +195,8 @@ MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
$(STATIC_LIBRARY): $(STATIC_OBJS)
ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
ranlib $(STATIC_LIBRARY)
$(AR) rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
$(RANLIB) $(STATIC_LIBRARY)
$(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
$(CC) $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><title>Release Summary - libpri-1.5.0</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">libpri-1.5.0</h3><h3 align="center">Date: 2016-03-25</h3><h3 align="center">&lt;asteriskteam@digium.com&gt;</h3><hr><h2 align="center">Table of Contents</h2><ol>
<li><a href="#summary">Summary</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#closed_issues">Closed Issues</a></li>
<li><a href="#commits">Other Changes</a></li>
<li><a href="#diffstat">Diffstat</a></li>
</ol><hr><a name="summary"><h2 align="center">Summary</h2></a><center><a href="#top">[Back to Top]</a></center><p>This release is a point release of an existing major version. The changes included were made to address problems that have been identified in this release series, or are minor, backwards compatible new features or improvements. Users should be able to safely upgrade to this version if this release series is already in use. Users considering upgrading from a previous version are strongly encouraged to review the UPGRADE.txt document as well as the CHANGES document for information about upgrading to this release series.</p><p>The data in this summary reflects changes that have been made since the previous release, libpri-1.4.15.</p><hr><a name="contributors"><h2 align="center">Contributors</h2></a><center><a href="#top">[Back to Top]</a></center><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were committed into this release. For testers, the number is the number of times their name was listed as assisting with testing a patch. Finally, for reporters, the number is the number of issues that they reported that were affected by commits that went into this release.</p><table width="100%" border="0">
<tr><th width="33%">Coders</th><th width="33%">Testers</th><th width="33%">Reporters</th></tr>
<tr valign="top"><td width="33%">8 Richard Mudgett <rmudgett@digium.com><br/>2 Kevin Harwell <kharwell@lunkwill><br/>1 Gerald Schnabel<br/>1 Kevin Harwell <kharwell@digium.com><br/></td><td width="33%"><td width="33%">2 Alexandr Dranchuk <alex.dranchuk@gmail.com><br/>2 Richard Mudgett<br/>2 Alexandr Dranchuk<br/>1 Gerald Schnabel<br/>1 Gerald Schnabel <gs@starface.de><br/>1 Alec Davis <sivad.a@paradise.net.nz><br/>1 James Wilson <james.wilson@integratedvoip.com.au><br/></td></tr>
</table><hr><a name="closed_issues"><h2 align="center">Closed Issues</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p><h3>Bug</h3><h4>Category: General</h4><a href="https://issues.asterisk.org/jira/browse/PRI-180">PRI-180</a>: Incorrect handling of DISCONNECT with Progress Indicator #8<br/>Reported by: Alexandr Dranchuk<ul>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=2952e95715f26ab239c58d1f0a8213c429514f05">[2952e95715]</a> Richard Mudgett -- q931.c: Fix DISCONNECT Progress Indicator ie handling.</li>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=7da3366cecf4641d4f27641f3ca5b2bc8dc147a4">[7da3366cec]</a> Richard Mudgett -- q931.c: Substitute PROGRESS for DISCONNECT with progress indicator #8</li>
</ul><a href="https://issues.asterisk.org/jira/browse/PRI-74">PRI-74</a>: Unexpected Channel selection<br/>Reported by: James Wilson<ul>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=fc96191788943877b1ab96113c4804be3ce49753">[fc96191788]</a> Richard Mudgett -- q931.c: Made not recognize ie 0x01 for switches other than 4ESS, 5ESS, NI2, and DMS-100.</li>
</ul><a href="https://issues.asterisk.org/jira/browse/PRI-76">PRI-76</a>: [patch] Limit octets received on Called Party Number and Calling Party Number<br/>Reported by: Alec Davis<ul>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=5fda3d8c68512cf2bdebce3e7cb573eb929eadbd">[5fda3d8c68]</a> Richard Mudgett -- q931.c: Send STATUS messages when receiving messages in the wrong call state.</li>
</ul><br><hr><a name="commits"><h2 align="center">Commits Not Associated with an Issue</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all changes that went into this release that did not reference a JIRA issue.</p><table width="100%" border="1">
<tr><th>Revision</th><th>Author</th><th>Summary</th></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=9a90caa65e131259172fc5167477390ea3237ceb">9a90caa65e</a></td><td>Kevin Harwell</td><td>.version: Update for 1.5.0</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=5414ca525e4c7372e0721060f2259702e3e7a84f">5414ca525e</a></td><td>Kevin Harwell</td><td>.lastclean: Update for 1.5.0</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=c71499df2986c44e25d70840e71bd233d4fe7472">c71499df29</a></td><td>Kevin Harwell</td><td>Adding .cleancount and .gitreview files</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=734e922301bd6154fca4732b2ed693e761772e8b">734e922301</a></td><td>Richard Mudgett</td><td>Add .gitignore</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=a9722804c14b11bdeb483dc2825839a5dc7cd869">a9722804c1</a></td><td>Richard Mudgett</td><td>q931.c: Tighten mandatory ie checks.</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=6b2cc87b301d1871795cc4cd2d15e53f13e88e02">6b2cc87b30</a></td><td>Richard Mudgett</td><td>q931.c: Update ALERTING_NO_PROGRESS conditional code.</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=af8a550ff9566626d1d64a5596434d742b1b0ee5">af8a550ff9</a></td><td>Richard Mudgett</td><td>q921.c: Send DM and DISC frames with only three data octets instead of an extra fourth octet.</td></tr>
</table><hr><a name="diffstat"><h2 align="center">Diffstat Results</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p><pre>ChangeLog | 2056 ---------------------------------------------
b/.cleancount | 1
b/.gitignore | 12
b/.gitreview | 4
b/.lastclean | 1
b/.version | 2
b/pri_internal.h | 7
b/pri_q931.h | 3
b/q921.c | 4
b/q931.c | 383 ++++++--
libpri-1.4.15-summary.html | 61 -
libpri-1.4.15-summary.txt | 91 -
12 files changed, 325 insertions(+), 2300 deletions(-)</pre><br></html>

View File

@@ -1,141 +0,0 @@
Release Summary
libpri-1.5.0
Date: 2016-03-25
<asteriskteam@digium.com>
----------------------------------------------------------------------
Table of Contents
1. Summary
2. Contributors
3. Closed Issues
4. Other Changes
5. Diffstat
----------------------------------------------------------------------
Summary
[Back to Top]
This release is a point release of an existing major version. The changes
included were made to address problems that have been identified in this
release series, or are minor, backwards compatible new features or
improvements. Users should be able to safely upgrade to this version if
this release series is already in use. Users considering upgrading from a
previous version are strongly encouraged to review the UPGRADE.txt
document as well as the CHANGES document for information about upgrading
to this release series.
The data in this summary reflects changes that have been made since the
previous release, libpri-1.4.15.
----------------------------------------------------------------------
Contributors
[Back to Top]
This table lists the people who have submitted code, those that have
tested patches, as well as those that reported issues on the issue tracker
that were resolved in this release. For coders, the number is how many of
their patches (of any size) were committed into this release. For testers,
the number is the number of times their name was listed as assisting with
testing a patch. Finally, for reporters, the number is the number of
issues that they reported that were affected by commits that went into
this release.
Coders Testers Reporters
8 Richard Mudgett 2 Alexandr Dranchuk
2 Kevin Harwell 2 Richard Mudgett
1 Gerald Schnabel 2 Alexandr Dranchuk
1 Kevin Harwell 1 Gerald Schnabel
1 Gerald Schnabel
1 Alec Davis
1 James Wilson
----------------------------------------------------------------------
Closed Issues
[Back to Top]
This is a list of all issues from the issue tracker that were closed by
changes that went into this release.
Bug
Category: General
PRI-180: Incorrect handling of DISCONNECT with Progress Indicator #8
Reported by: Alexandr Dranchuk
* [2952e95715] Richard Mudgett -- q931.c: Fix DISCONNECT Progress
Indicator ie handling.
* [7da3366cec] Richard Mudgett -- q931.c: Substitute PROGRESS for
DISCONNECT with progress indicator #8
PRI-74: Unexpected Channel selection
Reported by: James Wilson
* [fc96191788] Richard Mudgett -- q931.c: Made not recognize ie 0x01 for
switches other than 4ESS, 5ESS, NI2, and DMS-100.
PRI-76: [patch] Limit octets received on Called Party Number and Calling
Party Number
Reported by: Alec Davis
* [5fda3d8c68] Richard Mudgett -- q931.c: Send STATUS messages when
receiving messages in the wrong call state.
----------------------------------------------------------------------
Commits Not Associated with an Issue
[Back to Top]
This is a list of all changes that went into this release that did not
reference a JIRA issue.
+------------------------------------------------------------------------+
| Revision | Author | Summary |
|------------+-----------------+-----------------------------------------|
| 9a90caa65e | Kevin Harwell | .version: Update for 1.5.0 |
|------------+-----------------+-----------------------------------------|
| 5414ca525e | Kevin Harwell | .lastclean: Update for 1.5.0 |
|------------+-----------------+-----------------------------------------|
| c71499df29 | Kevin Harwell | Adding .cleancount and .gitreview files |
|------------+-----------------+-----------------------------------------|
| 734e922301 | Richard Mudgett | Add .gitignore |
|------------+-----------------+-----------------------------------------|
| a9722804c1 | Richard Mudgett | q931.c: Tighten mandatory ie checks. |
|------------+-----------------+-----------------------------------------|
| 6b2cc87b30 | Richard Mudgett | q931.c: Update ALERTING_NO_PROGRESS |
| | | conditional code. |
|------------+-----------------+-----------------------------------------|
| | | q921.c: Send DM and DISC frames with |
| af8a550ff9 | Richard Mudgett | only three data octets instead of an |
| | | extra fourth octet. |
+------------------------------------------------------------------------+
----------------------------------------------------------------------
Diffstat Results
[Back to Top]
This is a summary of the changes to the source code that went into this
release that was generated using the diffstat utility.
ChangeLog | 2056 ---------------------------------------------
b/.cleancount | 1
b/.gitignore | 12
b/.gitreview | 4
b/.lastclean | 1
b/.version | 2
b/pri_internal.h | 7
b/pri_q931.h | 3
b/q921.c | 4
b/q931.c | 383 ++++++--
libpri-1.4.15-summary.html | 61 -
libpri-1.4.15-summary.txt | 91 -
12 files changed, 325 insertions(+), 2300 deletions(-)

116
q931.c
View File

@@ -2196,17 +2196,33 @@ static int transmit_subaddr_helper(int full_ie, struct pri *ctrl, struct q931_pa
static int receive_subaddr_helper(int full_ie, struct pri *ctrl, struct q931_party_subaddress *q931_subaddress, int msgtype, q931_ie *ie, int offset, int len)
{
int i = -1;
if (len <= 0) {
return -1;
}
/*
* To follow Q.931 (4.5.1), we must search for start of octet 4 by
* walking through all bytes until one with ext bit (8) set to 1
*/
do {
++i;
switch (i) {
case 0: /* Octet 3 */
/* type: 0 = NSAP, 2 = User Specified */
q931_subaddress->type = ((ie->data[0] & 0x70) >> 4);
q931_subaddress->odd_even_indicator = (ie->data[0] & 0x08) ? 1 : 0;
break;
default: /* Octet 3* extra */
break;
}
} while (!(ie->data[i] & 0x80) && len - i);
q931_subaddress->valid = 1;
q931_subaddress->length = len;
/* type: 0 = NSAP, 2 = User Specified */
q931_subaddress->type = ((ie->data[0] & 0x70) >> 4);
q931_subaddress->odd_even_indicator = (ie->data[0] & 0x08) ? 1 : 0;
q931_subaddress->length = len - i;
q931_memget(q931_subaddress->data, sizeof(q931_subaddress->data),
ie->data + offset, len);
ie->data + offset + i, len - i);
return 0;
}
@@ -2214,13 +2230,22 @@ static int receive_subaddr_helper(int full_ie, struct pri *ctrl, struct q931_par
static void dump_subaddr_helper(int full_ie, struct pri *ctrl, q931_ie *ie, int offset, int len, int datalen, char prefix)
{
unsigned char cnum[256];
int i = -1;
/*
* To follow Q.931 (4.5.1), we must search for start of octet 4 by
* walking through all bytes until one with ext bit (8) set to 1
*/
do {
++i;
} while (!(ie->data[i] & 0x80) && datalen - i);
if (!(ie->data[0] & 0x70)) {
/* NSAP Get it as a string for dump display purposes only. */
q931_strget(cnum, sizeof(cnum), ie->data + offset, datalen);
q931_strget(cnum, sizeof(cnum), ie->data + offset + i, datalen - i);
} else {
/* User Specified */
q931_get_subaddr_specific(cnum, sizeof(cnum), ie->data + offset, datalen,
q931_get_subaddr_specific(cnum, sizeof(cnum), ie->data + offset + i, datalen - i,
ie->data[0] & 0x08);
}
@@ -2340,6 +2365,7 @@ static int receive_connected_number(int full_ie, struct pri *ctrl, q931_call *ca
{
int i = 0;
/* Reference Q.951 Section 5.4.1 for ie */
call->connected_number_in_message = 1;
call->remote_id.number.valid = 1;
call->remote_id.number.presentation =
@@ -2350,7 +2376,39 @@ static int receive_connected_number(int full_ie, struct pri *ctrl, q931_call *ca
switch (i) {
case 0:
call->remote_id.number.plan = ie->data[i] & 0x7f;
break;
/*
* Work around a bug in a Lucent switch implementation that
* sets the extension bit in octet 3 even though octet 3a
* is present.
*
* The same issue was seen in a NI2 switch implementation.
* It was probably a Lucent switch configured for NI2
* operation. To avoid further surprises, I'm going to
* enable the work around for all North American switch
* types.
*/
if (ie->data[i] & 0x80) {
/* Octet 3 extension bit is set */
if (ctrl->switchtype != PRI_SWITCH_LUCENT5E
&& ctrl->switchtype != PRI_SWITCH_ATT4ESS
&& ctrl->switchtype != PRI_SWITCH_NI1
&& ctrl->switchtype != PRI_SWITCH_NI2
&& ctrl->switchtype != PRI_SWITCH_DMS100) {
/* Not a potentially buggy switch type. */
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:
/* Keep only the presentation and screening fields */
call->remote_id.number.presentation =
@@ -2392,7 +2450,44 @@ static void dump_connected_number(int full_ie, struct pri *ctrl, q931_ie *ie, in
prefix, ie2str(full_ie), len, ie->data[0] >> 7,
ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
break;
/*
* Work around a bug in a Lucent switch implementation that
* sets the extension bit in octet 3 even though octet 3a
* is present.
*
* The same issue was seen in a NI2 switch implementation.
* It was probably a Lucent switch configured for NI2
* operation. To avoid further surprises, I'm going to
* enable the work around for all North American switch
* types.
*/
if (ie->data[i] & 0x80) {
/* Octet 3 extension bit is set */
if (ctrl->switchtype != PRI_SWITCH_LUCENT5E
&& ctrl->switchtype != PRI_SWITCH_ATT4ESS
&& ctrl->switchtype != PRI_SWITCH_NI1
&& ctrl->switchtype != PRI_SWITCH_NI2
&& ctrl->switchtype != PRI_SWITCH_DMS100) {
/* Not a potentially buggy switch type. */
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 */
pri_message(ctrl, "\n");
pri_message(ctrl, "%c Ext: %d Presentation: %s (%d)",
@@ -2429,6 +2524,7 @@ static int receive_redirecting_number(int full_ie, struct pri *ctrl, q931_call *
{
int i = 0;
/* Reference Q.952 Section 4.1.2 for ie */
call->redirecting_number_in_message = 1;
call->redirecting.from.number.valid = 1;
call->redirecting.from.number.presentation =
@@ -2507,6 +2603,7 @@ static int receive_redirection_number(int full_ie, struct pri *ctrl, q931_call *
{
int i = 0;
/* Reference Q.952 Section 4.1.3 for ie */
call->redirection_number.valid = 1;
call->redirection_number.presentation =
PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
@@ -2650,6 +2747,7 @@ static int receive_calling_party_number(int full_ie, struct pri *ctrl, q931_call
int i = 0;
struct q931_party_number number;
/* Reference Q.931 Section 4.5.10 for ie */
q931_party_number_init(&number);
number.valid = 1;
number.presentation = PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;