Compare commits

...

38 Commits

Author SHA1 Message Date
Richard Mudgett
7f91151e6b Update for 1.6.0 2017-01-27 11:25:12 -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
Kevin Harwell
c71499df29 Adding .cleancount and .gitreview files
Change-Id: I0e5accd0e43c049578241b2841fc2efa821c24f4
2016-03-24 14:55:28 -05:00
Richard Mudgett
2952e95715 q931.c: Fix DISCONNECT Progress Indicator ie handling.
There are two scenarios that are exposed by DISCONNECT not initializing
the progress indicator value before processing the message when the
chan_dahdi.conf inbanddisconnect=yes option is set.

1) If a DISCONNECT comes in without a Progress Indicator ie and an earlier
message (such as SETUP-ACKNOWLEDGE or PROCEEDING) came in with the
indicator #8 (Inband audio present) then the DISCONNECT would not cause an
immediate hangup.  We would be letting the user hear the inband audio even
though there isn't any.

2) If a DISCONNECT message comes in with the indicator #8 (Inband audio
present) and then later the DISCONNECT message is repeated without a
Progress Indicator ie we would still ignore the second DISCONNECT to let
the user hear inband audio even though it likely isn't there anymore.

PRI-180 #close
Reported by: Alexandr Dranchuk

Change-Id: Ic88aafb45053146b5701d666e6212f7555573624
2016-03-17 11:43:10 -05:00
Richard Mudgett
7da3366cec q931.c: Substitute PROGRESS for DISCONNECT with progress indicator #8
When the pri_set_inbanddisconnect() option is enabled and the call has not
been answered when a DISCONNECT with progress indicator #8 (Inband audio
present) is received, then report the event as a PROGRESS with progress
indicator #8 (Inband audio present) instead.  Substituting a PROGRESS
event allows the upper layer to open the media path if it isn't already
open so the user can hear the inband audio message.

PRI-180
Reported by: Alexandr Dranchuk

Change-Id: I62313bf9cc1d2f3b0231f0c07a784717ddba0415
2016-03-17 11:43:10 -05:00
Richard Mudgett
734e922301 Add .gitignore
Change-Id: I11ac3b47a9d5d0a0c1ea4559280b75ef5d866d62
2016-03-16 16:09:24 -05:00
Richard Mudgett
a9722804c1 q931.c: Tighten mandatory ie checks.
Libpri was lax in checking if a missing channel identification ie is
mandatory for the SETUP ACKNOWLEDGE, PROCEEDING, ALERTING, and CONNECT
messages.  That ie is mandatory when those messages are the first response
to a SETUP message sent by the CPE side.

* Made those messages check if a missing channel identification ie is
mandatory and send a STATUS with cause 96 "Mandatory information element
is missing" in response.

Libpri did not care if a mandatory ie had a coding error.

* Made coding errors in mandatory ie's send a STATUS with cause 100
"Invalid information element contents" in response.

* Fixed detection of coding errors in channel identification ie.

SWP-8721
SWP-8722


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2337 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2016-02-17 20:21:18 +00:00
Richard Mudgett
6b2cc87b30 q931.c: Update ALERTING_NO_PROGRESS conditional code.
The conditional is to only remove the Progress Indicator ie from being
added to select messages.

* Made so the ALERTING message can have the User-User ie if needed when
ALERTING_NO_PROGRESS is defined.


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2335 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2016-02-09 21:46:26 +00:00
Richard Mudgett
fc96191788 q931.c: Made not recognize ie 0x01 for switches other than 4ESS, 5ESS, NI2, and DMS-100.
An incoming SETUP message needs to reject the invalid ie 0x01 on switches
other than 4ESS, 5ESS, NI2, and DMS-100.

LIBPRI-74 #close
Reported by: Richard Mudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2333 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-11-17 23:26:55 +00:00
Richard Mudgett
5fda3d8c68 q931.c: Send STATUS messages when receiving messages in the wrong call state.
* Add checks to send STATUS messages when receiving SETUP ACKNOWLEDGE,
ALERTING, and CONNECT ACKNOWLEDGE messages when in the wrong call state.

LIBPRI-76 #close
Reported by: Richard Mudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2331 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-11-17 20:07:53 +00:00
Richard Mudgett
af8a550ff9 q921.c: Send DM and DISC frames with only three data octets instead of an extra fourth octet.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2329 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-11-04 22:19:02 +00:00
Richard Mudgett
a50516c1e4 q931.c: Make always post a PRI_EVENT_KEYPAD_DIGIT if keypad digits come in an INFO message.
Q.931 Section 3.1.6 INFORMATION message.  The keypad-facility or
called-party-number ie could be used to convey called party digits.  The
keypad-facility ie can also be used to convey supplementary service
information.

PRI-173 #close
Reported by: Gerald Schnabel
Patches:
      libpri_q931_keypad_digits.patch (license #6297) patch uploaded by Gerald Schnabel


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2327 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-08-18 22:44:04 +00:00
Richard Mudgett
998e6ba598 Adjust T202 default value to the minimum.
The minimum T202 time specified in Q.921 Section 5.9.7 is 2 seconds.  It
makes sense to set the value to the minimum 2 seconds in order to more
likely get a TEI value before an outgoing call request aborts from T303
timeouts.

PRI-171 #close
Reported by: dcolombo


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2322 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-06-02 16:27:13 +00:00
Richard Mudgett
cfac266390 libpri: Add control of inband audio progress indication ie to the SETUP_ACKNOWLEDGE message.
Added support to the libpri API to control the inband audio available
progress indication ie on the SETUP_ACKNOWLEDGE message.

* Added the progress indication ie progressmask value to the struct
pri_event_setup_ack so the PRI_EVENT_SETUP_ACK event can indicate when a
SETUP_ACKNOWLEDGE comes in with inband audio (ie dialtone).

* Added pri_setup_ack() so when the SETUP_ACKNOWLEDGE message is sent it
can indicate if inband audio is present (ie dialtone).

This patch and a corresponding change in Asterisk work together to allow
Asterisk to control the inband audio available progress indication ie on
the SETUP_ACKNOWLEDGE message when dialtone is present.

AST-1338 #close
Reported by: Tyler Stewart

Review: https://reviewboard.asterisk.org/r/3520/


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2320 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-05-12 22:45:13 +00:00
Richard Mudgett
13beaacc80 libpri: Make TE-PTP mode respond to MDL TEI check requests.
Some BRI devices in France insist on checking TEI's when in point-to-point
mode.  If they don't get a response for TEI 0 they drop layer 1 even
though libpri keeps trying to bring layer 2 up.

* Made q921_mdl_receive() handle TEI check request messages in TE-PTP
mode.  Had to change q921_mdl_send()/Q921_INIT() because the PTP modes do
not setup a link structure specifically for MDL as the PTMP modes do.

* Fixed q921_tei_check()/t201_expire() to check TEI's even if the network
side doesn't have any assigned.  This should make TE's that request the
TEI verify procedure (Q.921 Section 5.3.5) happy when the network side
doesn't have any TEI's allocated.

PRI-165
Reported by: Denis Alberto Martinez
Patches:
      jira_pri_165_ptp_respond_tei_check.patch (license #5621) patch uploaded by rmudgett
Review: https://reviewboard.asterisk.org/r/3434/



git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2318 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2014-04-18 17:44:31 +00:00
Richard Mudgett
84b2560da5 Fix hole in layer2_persistence option for TE PTMP links.
If the network stops responding, according to Q.921 we are supposed to
remove the TEI.  With the layer2_persistence option enabled, we are
supposed to keep trying to bring layer 2 back up.  Unfortunately, when the
network stops responding, we stopped the restart timer and removed the
TEI.  As a result, layer 2 does not immediately come back up.

* Made not stop the restart timer if we are removing the TEI on the CPE
side.  Also handle the timer expiration in relevant unassigned TEI states.

(closes issue LIBPRI-72)
Reported by: Trey Blancher
Patches:
      jira_dahdi_1001_libpri_v1.4.patch (license #5621) patch uploaded by rmudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2315 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2013-03-28 16:40:22 +00:00
Richard Mudgett
28553ff8cb Handle optional Recommendation octet 3a in Cause IE.
If the MSB of octet 3 is 0 then the optional Recommendation octet 3a is
present.

References: ITU-T Q.850 Section 2.1 and ETSI ETS 300 102-1 Section 4.5.12.

(closes issue PRI-151)
Reported by: Tzafrir Cohen
Patches:
      0001-handle-optional-Recommendation-in-Cause-IE.patch (license #5035) patch uploaded by Tzafrir Cohen
      Modified


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2310 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-12-10 18:28:55 +00:00
Richard Mudgett
1a0927ca23 Q.SIG: Allow PROGRESS when in the Active state.
ECMA-143 Section 10.1.7.2 indicates that PROGRESS is allowed when in the
Active state.

* Made Q.SIG ignore the PROGRESS message when in the Active call state.

(closes issue PRI-147)
Reported by: Nick Merrett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2308 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-11-13 19:59:50 +00:00
Richard Mudgett
de78c8d37f Fix compiler error with ALERTING_NO_PROGRESS define.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2307 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-11-13 19:42:17 +00:00
Richard Mudgett
cdb844c16b Fix compiler warning in pritest.c.
* Made do_channel() exit on a failed write().

(closes issue PRI-145)
Reported by: Tzafrir Cohen
Patches:
      fix_unused_write.patch (license #5035) patch uploaded by Tzafrir Cohen
      Modified


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2305 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-10-29 21:19:52 +00:00
Richard Mudgett
75bf8f0a20 Allow passing compiler flags (CFLAGS, LDFLAGS)
(closes issue PRI-144)
Reported by: Tzafrir Cohen
Patches:
      flags.diff (license #5035) patch uploaded by Tzafrir Cohen


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2300 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-09-26 15:46:23 +00:00
Richard Mudgett
5e3581c977 Fix compile error in pridump.c.
With gcc 4.6.3 it's possible to get the following error:

  $ make
  gcc -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC  -O2  -MD -MT pridump.o -MF .pridump.o.d -MP -c -o pridump.o pridump.c
  pridump.c: In function \u2018pri_bridge\u2019:
  pridump.c:117:1: error: no return statement in function returning non-void [-Werror=return-type]
  cc1: all warnings being treated as errors
  make: *** [pridump.o] Error 1

Changing the function return value to void fixes the issue since there
were no places in the code that used the return value.

(closes issue PRI-143)
Reported by: Birger "WIMPy" Harzenetter
Patches:
      0001-Fix-no-return-statement-in-function-returning-non-vo.patch (license #5417) patch uploaded by Shaun Ruffell


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2298 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-09-10 15:52:31 +00:00
Richard Mudgett
d9c6cc68a5 SVN ignore built utilities.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2295 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-08-11 01:38:57 +00:00
Richard Mudgett
27808e3640 * Made no longer compile *.lo files they are identical to *.o files.
* Made compile the pritest, rosetest, and testprilib utilities using the
static libpri library.  No more forgetting to install the library after a
change and wondering why it still did not work.  The pridump utility is
still dynamically linked.

* Made compile the utilities by default.


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2294 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-08-11 01:37:58 +00:00
Richard Mudgett
4af121db62 Make pridump and testprilib compile again.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2292 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-08-11 00:42:04 +00:00
Richard Mudgett
053a38202e Removed MDL/TEI management configuration warning message.
Some telco switches send out MDL messages even though they are configured
for PTP.  Usually they are checking for assigned TEI's.  Since these
switches periodically poll for assigned TEI's, the message needlessly
fills up log files.

* Changed message warning level to a normal debug message level and
reworded.

(closes issue PRI-137)
Reported by: Bart Coninckx


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2290 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-07-30 16:20:47 +00:00
Richard Mudgett
fffb7babaf Implement T316 to allow RESTART messages to be automatically retransmitted.
Q.931 defines the T316 timer to retransmit RESTART messages if a RESTART
ACKNOWLEDGE message is not received before the timer expires.  Q.931
defaults the time of T316 to 2 minutes with the default number of
consecutive RESTART failures as two.

* To support legacy behavior, the T316 timer is disabled by default.  It
is also disabled because the user cannot configure it to disabled if it is
enabled.

* The N316 count is created to allow the number of RESTART attempts to be
configurable.  Note you will need to recompile Asterisk to be able to
configure N316.

(issue ASTERISK-19608)
(issue AST-815)
(closes issue PRI-133)
Reported by: Mike Boylan
Tested by: rmudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2288 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-06-28 00:16:33 +00:00
Richard Mudgett
f78400fc07 Make pri_pres2str() return correct string.
* Fix pri_pres2str() mask creation.

(closes issue PRI-139)
Reported by: Pavel Troller
Patches:
      q931.c.diff (license #6302) patch uploaded by Pavel Troller


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2286 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-05-14 14:54:01 +00:00
Richard Mudgett
a7eaec1aaa Make number not available presentation also set screening to network provided.
Q.951 indicates that when the presentation indicator is "Number not
available due to interworking" for a number then the screening indicator
field should be "Network provided".

Released versions of Asterisk starting with v1.8 relesed before this patch
only recognized the PRES_NUMBER_NOT_AVAILABLE value as an unavailable
number.  This patch improves compatibility as a result.

* Made mask the presentation value for names and numbers from the upper
layer.

* Made pri_mwi_indicate_v2() also call q931_party_id_fixup() for
completeness even though it is a noop in this case.

* Made pri_pres2str() deceoode better.


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2284 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-03-23 19:35:23 +00:00
Kinsey Moore
17649b363b Make PRI_DEBUG_Q921_RAW work independantly of PRI_DEBUG_Q921_DUMP
Ensure that the DUMP and RAW flags work independently in q921_dump().

(closes issue PRI-119)
Patch-by: wimpy


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2282 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-02-03 23:12:57 +00:00
Richard Mudgett
2c159d4685 Use ie2str(full_ie) where possible in q931.c.
Initial patch by Alec Davis.

Review: https://reviewboard.asterisk.org/r/1633/


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2280 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2012-01-26 20:19:50 +00:00
Richard Mudgett
6078b21698 Remove nul octets from IE data that is normally treated as strings.
Sometimes ie values received from carriers contain nul octets in values
normally treated by libpri as nul terminated strings.  A discussion on the
asterisk-users list determined that the best thing to do in the situation
is to delete the nul octets and unconditionally report/log when that
happens.

* Remove nul octets from the following ie's and generate an unconditional
log message to the upper layer when they are removed:
Connected Number
Connected Address
Redirecting Number
Original Called Number
Redirection Number
Called Party Number
Calling Party Number
Display
Keypad Facility

(closes issue PRI-128)
Reported by: phsultan
Patches:
      jira_pri_128.patch (license #5621) patch uploaded by rmudgett (modified)
Tested by: rmudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2278 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2011-12-16 20:01:46 +00:00
Richard Mudgett
4e7c3d1462 Implement handling a multi-channel RESTART request.
The channel id ie can supply a slotmap or list of channels.  For a RESTART
message, this can be handy to indicate multiple channels that need to be
restarted at the same time.

An incoming RESTART request will now generate a PRI_EVENT_RESTART to the
upper layer for each channel indicated in the request.  If the event is
successfully generated for all indicated channels then a
RESTART_ACKNOWLEDGE is sent back to the peer indicating all channels
restarted.

* Add the ability to process a channel id ie channel list with a RESTART
request.

* Add the ability to process slotmaps with a RESTART request.

(closes issue PRI-93)
Reported by: Marcin Kowalczyk
Patches:
      jira_pri_93.patch (license #5621) patch uploaded by rmudgett
Tested by: zvision, rmudgett

(closes issue PRI-71)
Reported by: Torrey Searle
Tested by: rmudgett


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2277 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2011-12-16 19:26:56 +00:00
Richard Mudgett
5947536965 Fix message typo: Weird
(closes issue PRI-126)
Reported by: Tzafrir Cohen


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2275 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2011-09-26 22:54:46 +00:00
Richard Mudgett
c5ec479bd2 Outgoing BRI calls fail when using Asterisk 1.8 with HA8, HB8, and B410P cards.
France Telecom brings layer 2 and layer 1 down on BRI lines when the line
is idle.  When layer 1 goes down Asterisk cannot make outgoing calls and
the HA8 and HB8 cards also get IRQ misses.

The inability to make outgoing calls is because the line is in red alarm
and Asterisk will not make calls over a line it considers unavailable.
The IRQ misses for the HA8 and HB8 card are because the hardware is
switching clock sources from the line which just brought layer 1 down to
internal timing.

There is a DAHDI option for the B410P card to not tell Asterisk that layer
1 went down so Asterisk will allow outgoing calls: "modprobe wcb4xxp
teignored=1".  There is a similar DAHDI option for the HA8 and HB8 cards:
"modprobe wctdm24xxp bri_teignored=1".  Unfortunately that will not clear
up the IRQ misses when the telco brings layer 1 down.

* Add layer 2 persistence option to customize the layer 2 behavior on BRI
PTMP lines.  The new option has three settings: 1) Use libpri default
layer 2 setting.  2) Keep layer 2 up.  Bring layer 2 back up when the peer
brings it down.  3) Leave layer 2 down when the peer brings it down.
Layer 2 will be brought up as needed for outgoing calls.

(issue AST-598)
Reported by: Trey Blancher


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2273 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2011-08-17 15:48:54 +00:00
21 changed files with 4037 additions and 620 deletions

1
.cleancount Normal file
View File

@@ -0,0 +1 @@
0

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
*.o
*.o.d
*.lo
*.so
*.a
libpri.so.*
pridump
pritest
rosetest
testprilib
version.c

4
.gitreview Normal file
View File

@@ -0,0 +1,4 @@
[gerrit]
host=gerrit.asterisk.org
port=29418
project=libpri.git

1
.lastclean Normal file
View File

@@ -0,0 +1 @@
0

1
.version Normal file
View File

@@ -0,0 +1 @@
1.6.0

2267
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,15 +10,15 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Uncomment if you want libpri not send PROGRESS_INDICATOR w/ALERTING
@@ -65,43 +65,22 @@ STATIC_OBJS= \
rose_qsig_name.o \
version.o
DYNAMIC_OBJS= \
copy_string.lo \
pri.lo \
q921.lo \
prisched.lo \
q931.lo \
pri_aoc.lo \
pri_cc.lo \
pri_facility.lo \
asn1_primitive.lo \
rose.lo \
rose_address.lo \
rose_etsi_aoc.lo \
rose_etsi_cc.lo \
rose_etsi_diversion.lo \
rose_etsi_ect.lo \
rose_etsi_mwi.lo \
rose_other.lo \
rose_q931.lo \
rose_qsig_aoc.lo \
rose_qsig_cc.lo \
rose_qsig_ct.lo \
rose_qsig_diversion.lo \
rose_qsig_mwi.lo \
rose_qsig_name.lo \
version.lo
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_OPT) $(COVERAGE_CFLAGS)
$(STATIC_OBJS)
CFLAGS ?= -g
CFLAGS += $(CPPFLAGS)
CFLAGS += -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -fPIC $(ALERTING) $(LIBPRI_OPT) $(COVERAGE_CFLAGS)
INSTALL_PREFIX=$(DESTDIR)
INSTALL_BASE=/usr
libdir?=$(INSTALL_BASE)/lib
ifneq ($(findstring Darwin,$(OSARCH)),)
SOFLAGS=-dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
SOFLAGS=$(LDFLAGS) -dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
SOFLAGS+=/usr/lib/bundle1.o
endif
LDCONFIG=/usr/bin/true
else
SOFLAGS=-shared -Wl,-h$(DYNAMIC_LIBRARY) $(COVERAGE_LDFLAGS)
SOFLAGS=$(LDFLAGS) -shared -Wl,-h$(DYNAMIC_LIBRARY) $(COVERAGE_LDFLAGS)
LDCONFIG = /sbin/ldconfig
endif
ifneq (,$(findstring X$(OSARCH)X, XLinuxX XGNU/kFreeBSDX XGNUX))
@@ -115,11 +94,13 @@ endif
endif
ifeq (${OSARCH},SunOS)
CFLAGS += -DSOLARIS -I../zaptel-solaris
LDCONFIG =
LDCONFIG =
LDCONFIG_FLAGS = \# # Trick to comment out the period in the command below
#INSTALL_PREFIX = /opt/asterisk # Uncomment out to install in standard Solaris location for 3rd party code
endif
UTILITIES= pridump pritest rosetest testprilib
export PRIVERSION
PRIVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
@@ -145,7 +126,7 @@ CFLAGS += -m32
SOFLAGS += -m32
endif
all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY) $(UTILITIES)
update:
@if [ -d .svn ]; then \
@@ -171,37 +152,37 @@ ifneq (${OSARCH},SunOS)
install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
#if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libpri.so)
install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi
else
install -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include -m 644 libpri.h
install -f $(INSTALL_PREFIX)$(libdir) -m 755 $(DYNAMIC_LIBRARY)
( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libpri.so)
install -f $(INSTALL_PREFIX)$(libdir) -m 644 $(STATIC_LIBRARY)
endif
uninstall:
@echo "Removing Libpri"
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so.$(SONAME)
rm -f $(INSTALL_PREFIX)$(libdir)/$(STATIC_LIBRARY)
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.a
rm -f $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY)
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include/libpri.h
pritest: pritest.o
$(CC) -o pritest pritest.o -L. -lpri $(CFLAGS)
pritest: pritest.o $(STATIC_LIBRARY)
$(CC) -o $@ $< $(STATIC_LIBRARY) $(CFLAGS)
testprilib.o: testprilib.c
$(CC) $(CFLAGS) -D_REENTRANT -D_GNU_SOURCE -o $@ -c $<
$(CC) $(CFLAGS) -D_REENTRANT -D_GNU_SOURCE $(MAKE_DEPS) -c -o $@ $<
testprilib: testprilib.o
$(CC) -o testprilib testprilib.o -L. -lpri -lpthread $(CFLAGS)
testprilib: testprilib.o $(STATIC_LIBRARY)
$(CC) -o $@ $< $(STATIC_LIBRARY) -lpthread $(CFLAGS)
pridump: pridump.o
$(CC) -o pridump pridump.o -L. -lpri $(CFLAGS)
pridump: pridump.o $(DYNAMIC_LIBRARY)
$(CC) -o $@ $< -L. -lpri $(CFLAGS)
rosetest: rosetest.o
$(CC) -o rosetest rosetest.o -L. -lpri $(CFLAGS)
rosetest: rosetest.o $(STATIC_LIBRARY)
$(CC) -o $@ $< $(STATIC_LIBRARY) $(CFLAGS)
MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
@@ -218,7 +199,7 @@ $(STATIC_LIBRARY): $(STATIC_OBJS)
$(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
$(CC) $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
$(LDCONFIG) $(LDCONFIG_FLAGS) .
ln -sf libpri.so.$(SONAME) libpri.so
ln -sf $(DYNAMIC_LIBRARY) libpri.so
version.c: FORCE
@build_tools/make_version_c > $@.tmp
@@ -226,9 +207,9 @@ version.c: FORCE
@rm -f $@.tmp
clean:
rm -f *.o *.so *.lo *.so.$(SONAME)
rm -f testprilib $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
rm -f pritest pridump
rm -f *.o *.so *.lo
rm -f $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
rm -f $(UTILITIES)
rm -f .*.d
.PHONY:

24
libpri-1.6.0-summary.html Normal file
View File

@@ -0,0 +1,24 @@
<!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.6.0</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">libpri-1.6.0</h3><h3 align="center">Date: 2017-01-27</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.5.0.</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%">3 Richard Mudgett <rmudgett@digium.com><br/>1 Tzafrir Cohen <tzafrir.cohen@xorcom.com><br/></td><td width="33%"><td width="33%">2 Richard Mudgett <rmudgett@digium.com><br/>2 Richard Mudgett<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-183">PRI-183</a>: Garbage character in the received connected line number from a Lucent 5ESS switch.<br/>Reported by: Richard Mudgett<ul>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=f8e6096bfec3507895c8d7db91e78871ee47c6fe">[f8e6096bfe]</a> Richard Mudgett -- q931.c: Lucent switch implementation bug workaround (Part 2)</li>
<li><a href="https://code.asterisk.org/code/changelog/libpri?cs=d2585d6da2d30f116ef99339f79ce502f78697d4">[d2585d6da2]</a> Richard Mudgett -- q931.c: Lucent switch implementation bug workaround.</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=c038af789232458942020dd64f0c09a1bb4d78b9">c038af7892</a></td><td>Tzafrir Cohen</td><td>Makefile: Use CPPFLAGS</td></tr>
<tr><td><a href="https://code.asterisk.org/code/changelog/libpri?cs=90019b935a16240afee3f1e2f5649081b2999199">90019b935a</a></td><td>Richard Mudgett</td><td>q931.c: Add number ie specification references.</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>.lastclean | 1
.version | 1
ChangeLog | 2213 ----------------------------------------------
b/Makefile | 1
b/q931.c | 6
libpri-1.5.0-summary.html | 38
libpri-1.5.0-summary.txt | 141 --
7 files changed, 6 insertions(+), 2395 deletions(-)</pre><br></html>

111
libpri-1.6.0-summary.txt Normal file
View File

@@ -0,0 +1,111 @@
Release Summary
libpri-1.6.0
Date: 2017-01-27
<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.5.0.
----------------------------------------------------------------------
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
3 Richard Mudgett 2 Richard Mudgett
1 Tzafrir Cohen 2 Richard Mudgett
----------------------------------------------------------------------
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-183: Garbage character in the received connected line number from a
Lucent 5ESS switch.
Reported by: Richard Mudgett
* [f8e6096bfe] Richard Mudgett -- q931.c: Lucent switch implementation
bug workaround (Part 2)
* [d2585d6da2] Richard Mudgett -- q931.c: Lucent switch implementation
bug workaround.
----------------------------------------------------------------------
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 |
|------------+-----------------+-----------------------------------------|
| c038af7892 | Tzafrir Cohen | Makefile: Use CPPFLAGS |
|------------+-----------------+-----------------------------------------|
| 90019b935a | Richard Mudgett | q931.c: Add number ie specification |
| | | references. |
+------------------------------------------------------------------------+
----------------------------------------------------------------------
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.
.lastclean | 1
.version | 1
ChangeLog | 2213 ----------------------------------------------
b/Makefile | 1
b/q931.c | 6
libpri-1.5.0-summary.html | 38
libpri-1.5.0-summary.txt | 141 --
7 files changed, 6 insertions(+), 2395 deletions(-)

View File

@@ -1213,6 +1213,7 @@ typedef struct pri_event_setup_ack {
int channel;
q931_call *call;
struct pri_subcommands *subcmds;
int progressmask;
} pri_event_setup_ack;
typedef struct pri_event_notify {
@@ -1408,8 +1409,17 @@ const char *pri_facility_error2str(int facility_error_code);
*/
const char *pri_facility_reject2str(int facility_reject_code);
/* Acknowledge a call and place it on the given channel. Set info to non-zero if there
is in-band data available on the channel */
/*!
* \brief Send the ALERTING message.
*
* \param pri D channel controller.
* \param call Q.931 call leg.
* \param channel Encoded channel id to use. If zero do not change channel id.
* \param info Nonzero to include a progress ie indicating inband audio available (ie ringback).
*
* \retval 0 on success.
* \retval -1 on error.
*/
int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info);
/* Send a digit in overlap mode */
@@ -1419,12 +1429,44 @@ int pri_information(struct pri *pri, q931_call *call, char digit);
/* Send a keypad facility string of digits */
int pri_keypad_facility(struct pri *pri, q931_call *call, const char *digits);
/* Answer the incomplete(call without called number) call on the given channel.
Set non-isdn to non-zero if you are not connecting to ISDN equipment */
/*!
* \brief Send the SETUP_ACKNOWLEDGE message.
*
* \param pri D channel controller.
* \param call Q.931 call leg.
* \param channel Encoded channel id to use. If zero do not change channel id.
* \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
*
* \retval 0 on success.
* \retval -1 on error.
*/
int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
/* Answer(CONNECT) the call on the given channel.
Set non-isdn to non-zero if you are not connecting to ISDN equipment */
/*!
* \brief Send the SETUP_ACKNOWLEDGE message.
*
* \param ctrl D channel controller.
* \param call Q.931 call leg.
* \param channel Encoded channel id to use. If zero do not change channel id.
* \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
* \param inband Nonzero to include a progress ie indicating inband audio available (ie dialtone).
*
* \retval 0 on success.
* \retval -1 on error.
*/
int pri_setup_ack(struct pri *ctrl, q931_call *call, int channel, int nonisdn, int inband);
/*!
* \brief Send the CONNECT message.
*
* \param pri D channel controller.
* \param call Q.931 call leg.
* \param channel Encoded channel id to use. If zero do not change channel id.
* \param nonisdn Nonzero to include a progress ie indicating non-end-to-end-ISDN.
*
* \retval 0 on success.
* \retval -1 on error.
*/
int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
/*!
@@ -1692,7 +1734,17 @@ int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
int pri_progress_with_cause(struct pri *pri, q931_call *c, int channel, int info, int cause);
#define PRI_PROCEEDING_FULL
/* Send call proceeding */
/*!
* \brief Send the PROCEEDING message.
*
* \param pri D channel controller.
* \param c Q.931 call leg.
* \param channel Encoded channel id to use. If zero do not change channel id.
* \param info Nonzero to include a progress ie indicating inband audio available.
*
* \retval 0 on success.
* \retval -1 on error.
*/
int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
/* Enable inband progress when a DISCONNECT is received */
@@ -1892,6 +1944,31 @@ int pri_transfer_rsp(struct pri *ctrl, q931_call *call, int invoke_id, int is_su
*/
void pri_aoc_events_enable(struct pri *ctrl, int enable);
enum pri_layer2_persistence {
PRI_L2_PERSISTENCE_DEFAULT,
/*! Immediately bring layer 2 back up if the peer brings layer 2 down. */
PRI_L2_PERSISTENCE_KEEP_UP,
/*! Leave layer 2 down if the peer brings layer 2 down. */
PRI_L2_PERSISTENCE_LEAVE_DOWN,
#if 0 /* Possible future option. Would need to define how long to idle before dropping. */
/*! Drop layer 2 on D channel idle. */
PRI_L2_PERSISTENCE_IDLE_DROP,
#endif
};
/*!
* \brief Set the layer2 persistence option.
*
* \param ctrl D channel controller.
* \param option Layer 2 persistence to apply.
*
* \note
* Not all values are supported by all modes.
*
* \return Nothing
*/
void pri_persistent_layer2_option(struct pri *ctrl, enum pri_layer2_persistence option);
#define PRI_DISPLAY_OPTION_BLOCK (1 << 0) /*!< Do not pass display text. */
#define PRI_DISPLAY_OPTION_NAME_INITIAL (1 << 1) /*!< Use display in SETUP/CONNECT for name. */
#define PRI_DISPLAY_OPTION_NAME_UPDATE (1 << 2) /*!< Use display in FACILITY/NOTIFY for COLP name if appropriate. */
@@ -2154,7 +2231,7 @@ enum PRI_TIMERS_AND_COUNTERS {
PRI_TIMER_T310, /*!< Maximum time between receiving a CALL_PROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */
PRI_TIMER_T313, /*!< Wait for CONNECT acknowledge, CPE side only */
PRI_TIMER_T314,
PRI_TIMER_T316, /*!< Maximum time between transmitting a RESTART and receiving a RESTART ACK */
PRI_TIMER_T316, /*!< Time to wait for a RESTART ACK before retransmitting RESTART. (Timer enabled if greater than zero.) */
PRI_TIMER_T317,
PRI_TIMER_T318,
PRI_TIMER_T319,
@@ -2196,6 +2273,7 @@ enum PRI_TIMERS_AND_COUNTERS {
PRI_TIMER_QSIG_CC_T4, /*!< Path reservation supervision timeout. */
PRI_TIMER_T312, /*!< Supervise broadcast SETUP message call reference retention. */
PRI_TIMER_N316, /*!< Number of times to transmit RESTART before giving up if T316 enabled. */
/* Must be last in the enum list */
PRI_MAX_TIMERS

76
pri.c
View File

@@ -81,6 +81,7 @@ static const struct pri_timer_table pri_timer[] = {
{ "T313", PRI_TIMER_T313, PRI_ALL_SWITCHES },
{ "T314", PRI_TIMER_T314, PRI_ALL_SWITCHES },
{ "T316", PRI_TIMER_T316, PRI_ALL_SWITCHES },
{ "N316", PRI_TIMER_N316, PRI_ALL_SWITCHES },
{ "T317", PRI_TIMER_T317, PRI_ALL_SWITCHES },
{ "T318", PRI_TIMER_T318, PRI_ALL_SWITCHES },
{ "T319", PRI_TIMER_T319, PRI_ALL_SWITCHES },
@@ -175,7 +176,7 @@ static void pri_default_timers(struct pri *ctrl, int switchtype)
ctrl->timers[PRI_TIMER_T200] = 1000; /* Time between SABME's */
ctrl->timers[PRI_TIMER_T201] = ctrl->timers[PRI_TIMER_T200];/* Time between TEI Identity Checks (Default same as T200) */
ctrl->timers[PRI_TIMER_T202] = 10 * 1000; /* Min time between transmission of TEI Identity request messages */
ctrl->timers[PRI_TIMER_T202] = 2 * 1000; /* Min time between transmission of TEI Identity request messages */
ctrl->timers[PRI_TIMER_T203] = 10 * 1000; /* Max time without exchanging packets */
ctrl->timers[PRI_TIMER_T303] = 4 * 1000; /* Length between SETUP retransmissions and timeout */
@@ -184,6 +185,10 @@ static void pri_default_timers(struct pri *ctrl, int switchtype)
ctrl->timers[PRI_TIMER_T309] = 6 * 1000; /* Time to wait before clearing calls in case of D-channel transient event. Q.931 specifies 6-90 seconds */
ctrl->timers[PRI_TIMER_T312] = (4 + 2) * 1000;/* Supervise broadcast SETUP message call reference retention. T303 + 2 seconds */
ctrl->timers[PRI_TIMER_T313] = 4 * 1000; /* Wait for CONNECT acknowledge, CPE side only */
#if 0 /* Default disable the T316 timer otherwise the user cannot disable it. */
ctrl->timers[PRI_TIMER_T316] = 2 * 60 * 1000; /* RESTART retransmit timer */
#endif
ctrl->timers[PRI_TIMER_N316] = 2; /* Send RESTART this many times before giving up. */
ctrl->timers[PRI_TIMER_TM20] = 2500; /* Max time awaiting XID response - Q.921 Appendix IV */
ctrl->timers[PRI_TIMER_NM20] = 3; /* Number of XID retransmits - Q.921 Appendix IV */
@@ -290,6 +295,27 @@ static int __pri_write(struct pri *pri, void *buf, int buflen)
return res;
}
/*!
* \internal
* \brief Determine the default layer 2 persistence option.
*
* \param ctrl D channel controller.
*
* \return Default layer 2 persistence option. (legacy behaviour default)
*/
static enum pri_layer2_persistence pri_l2_persistence_option_default(struct pri *ctrl)
{
enum pri_layer2_persistence persistence;
if (PTMP_MODE(ctrl)) {
persistence = PRI_L2_PERSISTENCE_LEAVE_DOWN;
} else {
persistence = PRI_L2_PERSISTENCE_KEEP_UP;
}
return persistence;
}
/*!
* \internal
* \brief Determine the default display text send options.
@@ -558,6 +584,7 @@ static struct pri *pri_ctrl_new(int fd, int node, int switchtype, pri_io_cb rd,
ctrl->q931_rxcount = 0;
ctrl->q931_txcount = 0;
ctrl->l2_persistence = pri_l2_persistence_option_default(ctrl);
ctrl->display_flags.send = pri_display_options_send_default(ctrl);
ctrl->display_flags.receive = pri_display_options_receive_default(ctrl);
switch (switchtype) {
@@ -912,7 +939,15 @@ int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisd
if (!pri || !pri_is_call_valid(pri, call)) {
return -1;
}
return q931_setup_ack(pri, call, channel, nonisdn);
return q931_setup_ack(pri, call, channel, nonisdn, 0);
}
int pri_setup_ack(struct pri *ctrl, q931_call *call, int channel, int nonisdn, int inband)
{
if (!ctrl || !pri_is_call_valid(ctrl, call)) {
return -1;
}
return q931_setup_ack(ctrl, call, channel, nonisdn, inband);
}
int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn)
@@ -951,7 +986,7 @@ void pri_copy_party_name_to_q931(struct q931_party_name *q931_name, const struct
q931_party_name_init(q931_name);
if (pri_name->valid) {
q931_name->valid = 1;
q931_name->presentation = pri_name->presentation;
q931_name->presentation = pri_name->presentation & PRI_PRES_RESTRICTION;
q931_name->char_set = pri_name->char_set;
libpri_copy_string(q931_name->str, pri_name->str, sizeof(q931_name->str));
}
@@ -970,7 +1005,8 @@ void pri_copy_party_number_to_q931(struct q931_party_number *q931_number, const
q931_party_number_init(q931_number);
if (pri_number->valid) {
q931_number->valid = 1;
q931_number->presentation = pri_number->presentation;
q931_number->presentation = pri_number->presentation
& (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
q931_number->plan = pri_number->plan;
libpri_copy_string(q931_number->str, pri_number->str, sizeof(q931_number->str));
}
@@ -1772,7 +1808,8 @@ char *pri_dump_info_str(struct pri *ctrl)
enum PRI_TIMERS_AND_COUNTERS tmr;
tmr = pri_timer[idx].number;
if (0 <= ctrl->timers[tmr]) {
if (0 <= ctrl->timers[tmr]
|| tmr == PRI_TIMER_T316) {
used = pri_snprintf(buf, used, buf_size, " %s: %d\n",
pri_timer[idx].name, ctrl->timers[tmr]);
}
@@ -1940,13 +1977,14 @@ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int cal
q931_party_id_init(&sr->caller);
if (caller) {
sr->caller.number.valid = 1;
sr->caller.number.presentation = callerpres;
sr->caller.number.presentation = callerpres
& (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
sr->caller.number.plan = callerplan;
libpri_copy_string(sr->caller.number.str, caller, sizeof(sr->caller.number.str));
if (callername) {
sr->caller.name.valid = 1;
sr->caller.name.presentation = callerpres;
sr->caller.name.presentation = callerpres & PRI_PRES_RESTRICTION;
sr->caller.name.char_set = PRI_CHAR_SET_ISO8859_1;
libpri_copy_string(sr->caller.name.str, callername,
sizeof(sr->caller.name.str));
@@ -1970,7 +2008,8 @@ int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int
q931_party_redirecting_init(&sr->redirecting);
if (num && num[0]) {
sr->redirecting.from.number.valid = 1;
sr->redirecting.from.number.presentation = pres;
sr->redirecting.from.number.presentation = pres
& (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
sr->redirecting.from.number.plan = plan;
libpri_copy_string(sr->redirecting.from.number.str, num,
sizeof(sr->redirecting.from.number.str));
@@ -2165,6 +2204,27 @@ void pri_cc_retain_signaling_rsp(struct pri *ctrl, int signaling_retention)
}
}
void pri_persistent_layer2_option(struct pri *ctrl, enum pri_layer2_persistence option)
{
if (!ctrl) {
return;
}
if (PTMP_MODE(ctrl)) {
switch (option) {
case PRI_L2_PERSISTENCE_DEFAULT:
ctrl->l2_persistence = pri_l2_persistence_option_default(ctrl);
break;
case PRI_L2_PERSISTENCE_KEEP_UP:
case PRI_L2_PERSISTENCE_LEAVE_DOWN:
ctrl->l2_persistence = option;
break;
}
if (ctrl->l2_persistence == PRI_L2_PERSISTENCE_KEEP_UP) {
q921_bring_layer2_up(ctrl);
}
}
}
void pri_display_options_send(struct pri *ctrl, unsigned long flags)
{
if (!ctrl) {

View File

@@ -2219,8 +2219,7 @@ void pri_cc_ptp_request(struct pri *ctrl, q931_call *call, int msgtype, const st
party_a.number.presentation =
PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
} else {
party_a.number.presentation =
PRI_PRES_UNAVAILABLE | PRI_PRES_USER_NUMBER_UNSCREENED;
party_a.number.presentation = PRES_NUMBER_NOT_AVAILABLE;
}
} else {
party_a.number.presentation =

View File

@@ -632,6 +632,9 @@ void rose_copy_presented_number_screened_to_q931(struct pri *ctrl,
rose_copy_number_to_q931(ctrl, q931_number,
&rose_presented->screened.number);
break;
case 2: /* numberNotAvailableDueToInterworking */
q931_number->presentation = PRES_NUMBER_NOT_AVAILABLE;
break;
default:
q931_number->presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
break;
@@ -660,6 +663,9 @@ void rose_copy_presented_number_unscreened_to_q931(struct pri *ctrl,
case 3: /* presentationRestrictedNumber */
rose_copy_number_to_q931(ctrl, q931_number, &rose_presented->number);
break;
case 2: /* numberNotAvailableDueToInterworking */
q931_number->presentation = PRES_NUMBER_NOT_AVAILABLE;
break;
default:
break;
}
@@ -693,6 +699,9 @@ void rose_copy_presented_address_screened_to_id_q931(struct pri *ctrl,
rose_copy_subaddress_to_q931(ctrl, &q931_address->subaddress,
&rose_presented->screened.subaddress);
break;
case 2: /* numberNotAvailableDueToInterworking */
q931_address->number.presentation = PRES_NUMBER_NOT_AVAILABLE;
break;
default:
q931_address->number.presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
break;
@@ -1871,6 +1880,7 @@ int pri_mwi_indicate_v2(struct pri *ctrl, const struct pri_party_id *mailbox,
}
pri_copy_party_id_to_q931(&called, mailbox);
q931_party_id_fixup(ctrl, &called);
if (rose_mwi_indicate_encode(ctrl, call, vm_id, basic_service, num_messages,
caller_id, timestamp, message_reference, message_status)
|| q931_facility_called(ctrl, call, &called)) {
@@ -4564,8 +4574,7 @@ void rose_handle_invoke(struct pri *ctrl, q931_call *call, int msgtype, q931_ie
party_id.number.presentation =
PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
} else {
party_id.number.presentation =
PRI_PRES_UNAVAILABLE | PRI_PRES_USER_NUMBER_UNSCREENED;
party_id.number.presentation = PRES_NUMBER_NOT_AVAILABLE;
}
} else {
q931_party_number_init(&party_id.number);

View File

@@ -120,6 +120,8 @@ struct pri {
/*! Layer 2 link control for D channel. */
struct q921_link link;
/*! Layer 2 persistence option. */
enum pri_layer2_persistence l2_persistence;
/*! T201 TEI Identity Check timer. */
int t201_timer;
/*! Number of times T201 has expired. */
@@ -623,7 +625,9 @@ struct q931_call {
/*! Display text ie contents. */
struct {
/*! Display ie text. NULL if not present or consumed as remote name. */
const char *text;
const unsigned char *text;
/*! Full IE code of received display text */
int full_ie;
/*! Length of display text. */
unsigned char length;
/*!
@@ -643,8 +647,34 @@ struct q931_call {
unsigned char char_set;
} display;
/* AOC charge requesting on Setup */
/*! AOC charge requesting on Setup */
int aoc_charging_request;
/*! TRUE if the slotmap is E1 (32 bits). */
unsigned int slotmap_size:1;
/*! TRUE if need to see the channel id ie in first response to SETUP. */
unsigned int channel_id_ie_mandatory:1;
/*! Control the RESTART reception to the upper layer. */
struct {
/*! Timer ID of RESTART notification events to upper layer. */
int timer;
/*! Current RESTART notification index. */
int idx;
/*! Number of channels in the channel ID list. */
int count;
/*! Channel ID list */
char chan_no[32];
} restart;
/*! Control the RESTART retransmissions. */
struct {
/*! T316 RESTART retransmit timer. */
int t316_timer;
/*! Number of times remaining that RESTART can be transmitted. */
int remain;
/*! Encoded RESTART channel id. */
int channel;
} restart_tx;
};
enum CC_STATES {

View File

@@ -252,7 +252,7 @@ struct q921_link {
int n202_counter;
/*! Max idle time */
int t203_timer;
/*! PTP restart delay timer */
/*! Layer 2 persistence restart delay timer */
int restart_timer;
/* MDL variables */
@@ -273,10 +273,11 @@ static inline int Q921_ADD(int a, int b)
}
/* Dumps a *known good* Q.921 packet */
extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx);
extern void q921_dump(struct pri *pri, q921_h *h, int len, int debugflags, int txrx);
/* Bring up the D-channel */
void q921_start(struct q921_link *link);
void q921_bring_layer2_up(struct pri *ctrl);
//extern void q921_reset(struct pri *pri, int reset_iqueue);

View File

@@ -138,9 +138,6 @@ typedef struct q931_ie {
#define SERVICE_CHANGE_STATUS_REQCONTINUITYCHECK 3 /* not supported */
#define SERVICE_CHANGE_STATUS_SHUTDOWN 4 /* not supported */
/* Special codeset 0 IE */
#define NATIONAL_CHANGE_STATUS 0x1
/* Q.931 / National ISDN Information Elements */
#define Q931_LOCKING_SHIFT 0x90
#define Q931_NON_LOCKING_SHIFT 0x98
@@ -468,7 +465,7 @@ extern int q931_notify(struct pri *pri, q931_call *call, int channel, int info);
extern int q931_call_proceeding(struct pri *pri, q931_call *call, int channel, int info);
extern int q931_setup_ack(struct pri *pri, q931_call *call, int channel, int nonisdn);
extern int q931_setup_ack(struct pri *ctrl, q931_call *c, int channel, int nonisdn, int inband);
extern int q931_information(struct pri *pri, q931_call *call, char digit);

View File

@@ -42,7 +42,7 @@
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/types.h>
#include <zaptel/zaptel.h>
#include <dahdi/user.h>
#include "libpri.h"
#include "pri_q921.h"
#include "pri_q931.h"
@@ -50,18 +50,18 @@
static int pri_open(char *dev)
{
int dfd;
struct zt_params p;
struct dahdi_params p;
dfd = open(dev, O_RDWR);
if (dfd < 0) {
fprintf(stderr, "Failed to open dchannel '%s': %s\n", dev, strerror(errno));
return -1;
}
if (ioctl(dfd, ZT_GET_PARAMS, &p)) {
if (ioctl(dfd, DAHDI_GET_PARAMS, &p)) {
fprintf(stderr, "Unable to get parameters on '%s': %s\n", dev, strerror(errno));
return -1;
}
if ((p.sigtype != ZT_SIG_HDLCRAW) && (p.sigtype != ZT_SIG_HDLCFCS)) {
if ((p.sigtype != DAHDI_SIG_HDLCRAW) && (p.sigtype != DAHDI_SIG_HDLCFCS)) {
fprintf(stderr, "%s is in %d signalling, not FCS HDLC or RAW HDLC mode\n", dev, p.sigtype);
return -1;
}
@@ -71,7 +71,7 @@ static int pri_open(char *dev)
static void dump_packet(struct pri *pri, char *buf, int len, int txrx)
{
q921_h *h = (q921_h *)buf;
q921_dump(pri, h, len, 1, txrx);
q921_dump(pri, h, len, PRI_DEBUG_ALL, txrx);
if (!((h->h.data[0] & Q921_FRAMETYPE_MASK) & 0x3)) {
q931_dump(pri, h->h.tei, (q931_h *)(h->i.data), len - 4 - 2 /* FCS */, txrx);
}
@@ -80,7 +80,7 @@ static void dump_packet(struct pri *pri, char *buf, int len, int txrx)
}
static int pri_bridge(int d1, int d2)
static void pri_bridge(int d1, int d2)
{
char buf[1024];
fd_set fds;
@@ -94,8 +94,8 @@ static int pri_bridge(int d1, int d2)
max = d1;
if (max < d2)
max = d2;
ioctl(d1, ZT_GETEVENT, &e);
ioctl(d2, ZT_GETEVENT, &e);
ioctl(d1, DAHDI_GETEVENT, &e);
ioctl(d2, DAHDI_GETEVENT, &e);
res = select(max + 1, &fds, NULL, NULL, NULL);
if (res < 0) {
fprintf(stderr, "Select returned %d: %s\n", res, strerror(errno));

View File

@@ -68,7 +68,10 @@ static void do_channel(int fd)
int i=0;
while ((res = read(fd, buf, READ_SIZE)) > 0 && (i++ < 1000)) {
write(fd, buf, res);
if (write(fd, buf, res) == -1) {
fprintf(stderr, "--!! Failed write: %d\n", errno);
break;
}
}
}

579
q921.c
View File

@@ -45,13 +45,19 @@
*/
//#define RANDOM_DROPS 1
#define Q921_INIT(link, hf) do { \
memset(&(hf),0,sizeof(hf)); \
(hf).h.sapi = (link)->sapi; \
(hf).h.ea1 = 0; \
(hf).h.ea2 = 1; \
(hf).h.tei = (link)->tei; \
} while (0)
#define Q921_INIT(fr, l_sapi, l_tei) \
do { \
(fr)->h.sapi = l_sapi; \
(fr)->h.ea1 = 0; \
(fr)->h.ea2 = 1; \
(fr)->h.tei = l_tei; \
} while (0)
#define Q921_CLEAR_INIT(fr, l_sapi, l_tei) \
do { \
memset((fr), 0, sizeof(*(fr))); \
Q921_INIT((fr), (l_sapi), (l_tei)); \
} while (0)
static void q921_dump_pri(struct q921_link *link, char direction_tag);
static void q921_establish_data_link(struct q921_link *link);
@@ -186,7 +192,7 @@ static int q921_transmit(struct pri *ctrl, q921_h *h, int len)
ctrl->q921_txcount++;
/* Just send it raw */
if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 1);
q921_dump(ctrl, h, len, ctrl->debug, 1);
/* Write an extra two bytes for the FCS */
res = ctrl->write_func ? ctrl->write_func(ctrl, h, len + 2) : 0;
if (res != (len + 2)) {
@@ -196,17 +202,14 @@ static int q921_transmit(struct pri *ctrl, q921_h *h, int len)
return 0;
}
static void q921_send_tei(struct pri *ctrl, enum q921_tei_identity message, int ri, int ai, int iscommand)
static void q921_mdl_send(struct pri *ctrl, enum q921_tei_identity message, int ri, int ai, int iscommand)
{
q921_u *f;
struct q921_link *link;
link = &ctrl->link;
if (!(f = calloc(1, sizeof(*f) + 5)))
return;
Q921_INIT(link, *f);
Q921_INIT(f, Q921_SAPI_LAYER2_MANAGEMENT, Q921_TEI_GROUP);
f->h.c_r = (ctrl->localtype == PRI_NETWORK) ? iscommand : !iscommand;
f->ft = Q921_FRAMETYPE_U;
f->data[0] = 0x0f; /* Management entity */
@@ -216,7 +219,7 @@ static void q921_send_tei(struct pri *ctrl, enum q921_tei_identity message, int
f->data[4] = (ai << 1) | 1;
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl,
"Sending TEI management message %d(%s), TEI=%d\n",
"Sending MDL message: %d(%s), TEI=%d\n",
message, q921_tei_mgmt2str(message), ai);
}
q921_transmit(ctrl, (q921_h *)f, 8);
@@ -235,7 +238,10 @@ static void t202_expire(void *vlink)
link->t202_timer =
pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T202], t202_expire, link);
++link->n202_counter;
if (ctrl->l2_persistence != PRI_L2_PERSISTENCE_KEEP_UP) {
/* Only try to get a TEI for N202 times if layer 2 is not persistent. */
++link->n202_counter;
}
if (!link->t202_timer || link->n202_counter > ctrl->timers[PRI_TIMER_N202]) {
if (!link->t202_timer) {
pri_error(ctrl, "Could not start T202 timer.");
@@ -262,7 +268,7 @@ static void t202_expire(void *vlink)
/* Send TEI request */
link->ri = random() % 65535;
q921_send_tei(ctrl, Q921_TEI_IDENTITY_REQUEST, link->ri, Q921_TEI_GROUP, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_REQUEST, link->ri, Q921_TEI_GROUP, 1);
}
static void q921_tei_request(struct q921_link *link)
@@ -277,8 +283,8 @@ static void q921_tei_remove(struct pri *ctrl, int tei)
* Q.921 Section 5.3.2 says we should send the remove message
* twice, in case of message loss.
*/
q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1);
q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1);
}
static void q921_send_dm(struct q921_link *link, int fbit)
@@ -288,7 +294,7 @@ static void q921_send_dm(struct q921_link *link, int fbit)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.u.m3 = 0; /* M3 = 0 */
h.u.m2 = 3; /* M2 = 3 */
h.u.p_f = fbit; /* Final set appropriately */
@@ -307,7 +313,7 @@ static void q921_send_dm(struct q921_link *link, int fbit)
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "TEI=%d Sending DM\n", link->tei);
}
q921_transmit(ctrl, &h, 4);
q921_transmit(ctrl, &h, 3);
}
static void q921_send_disc(struct q921_link *link, int pbit)
@@ -317,7 +323,7 @@ static void q921_send_disc(struct q921_link *link, int pbit)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.u.m3 = 2; /* M3 = 2 */
h.u.m2 = 0; /* M2 = 0 */
h.u.p_f = pbit; /* Poll set appropriately */
@@ -336,7 +342,7 @@ static void q921_send_disc(struct q921_link *link, int pbit)
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "TEI=%d Sending DISC\n", link->tei);
}
q921_transmit(ctrl, &h, 4);
q921_transmit(ctrl, &h, 3);
}
static void q921_send_ua(struct q921_link *link, int fbit)
@@ -346,7 +352,7 @@ static void q921_send_ua(struct q921_link *link, int fbit)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.u.m3 = 3; /* M3 = 3 */
h.u.m2 = 0; /* M2 = 0 */
h.u.p_f = fbit; /* Final set appropriately */
@@ -375,7 +381,7 @@ static void q921_send_sabme(struct q921_link *link)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.u.m3 = 3; /* M3 = 3 */
h.u.m2 = 3; /* M2 = 3 */
h.u.p_f = 1; /* Poll bit set */
@@ -530,6 +536,49 @@ static void stop_t200(struct q921_link *link)
}
}
/*!
* \internal
* \brief Initiate bringing up layer 2 link.
*
* \param link Layer 2 link to bring up.
*
* \return Nothing
*/
static void kick_start_link(struct q921_link *link)
{
struct pri *ctrl;
ctrl = link->ctrl;
switch (link->state) {
case Q921_TEI_UNASSIGNED:
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Kick starting link from no TEI.\n");
}
q921_setstate(link, Q921_ESTABLISH_AWAITING_TEI);
q921_tei_request(link);
break;
case Q921_ASSIGN_AWAITING_TEI:
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Kick starting link when awaiting TEI.\n");
}
q921_setstate(link, Q921_ESTABLISH_AWAITING_TEI);
break;
case Q921_TEI_ASSIGNED:
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "SAPI/TEI=%d/%d Kick starting link\n", link->sapi,
link->tei);
}
q921_discard_iqueue(link);
q921_establish_data_link(link);
link->l3_initiated = 1;
q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
break;
default:
break;
}
}
static void restart_timer_expire(void *vlink)
{
struct q921_link *link = vlink;
@@ -537,19 +586,14 @@ static void restart_timer_expire(void *vlink)
ctrl = link->ctrl;
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "SAPI/TEI=%d/%d Kick starting link\n", link->sapi, link->tei);
}
link->restart_timer = 0;
switch (link->state) {
case Q921_TEI_UNASSIGNED:
case Q921_ASSIGN_AWAITING_TEI:
case Q921_TEI_ASSIGNED:
/* Try to bring layer 2 up. */
q921_discard_iqueue(link);
q921_establish_data_link(link);
link->l3_initiated = 1;
q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
kick_start_link(link);
break;
default:
/* Looks like someone forgot to stop the restart timer. */
@@ -568,6 +612,7 @@ static void restart_timer_stop(struct q921_link *link)
link->restart_timer = 0;
}
/*! \note Only call on the transition to state Q921_TEI_ASSIGNED or already there. */
static void restart_timer_start(struct q921_link *link)
{
struct pri *ctrl;
@@ -583,21 +628,27 @@ static void restart_timer_start(struct q921_link *link)
pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], restart_timer_expire, link);
}
static pri_event *q921_ptp_delay_restart(struct q921_link *link)
/*! \note Only call on the transition to state Q921_TEI_ASSIGNED or already there. */
static pri_event *q921_check_delay_restart(struct q921_link *link)
{
pri_event *ev;
struct pri *ctrl;
ctrl = link->ctrl;
if (PTP_MODE(ctrl)) {
if (ctrl->l2_persistence == PRI_L2_PERSISTENCE_KEEP_UP) {
/*
* For PTP links:
* This is where we act a bit like L3 instead of L2, since we've
* got an L3 that depends on us keeping L2 automatically alive
* and happy for PTP links.
* and happy.
*
* For PTMP links:
* We can optionally keep L2 automatically alive and happy.
*/
restart_timer_start(link);
}
if (PTP_MODE(ctrl)) {
switch (link->state) {
case Q921_MULTI_FRAME_ESTABLISHED:
case Q921_TIMER_RECOVERY:
@@ -616,6 +667,31 @@ static pri_event *q921_ptp_delay_restart(struct q921_link *link)
return ev;
}
/*!
* \brief Bring all layer 2 links up.
*
* \param ctrl D channel controller.
*
* \return Nothing
*/
void q921_bring_layer2_up(struct pri *ctrl)
{
struct q921_link *link;
if (PTMP_MODE(ctrl)) {
/* Don't start with the broadcast link. */
link = ctrl->link.next;
} else {
link = &ctrl->link;
}
for (; link; link = link->next) {
if (!link->restart_timer) {
/* A restart on the link is not already in the works. */
kick_start_link(link);
}
}
}
/* This is the equivalent of the I-Frame queued up path in Figure B.7 in MULTI_FRAME_ESTABLISHED */
static int q921_send_queued_iframes(struct q921_link *link)
{
@@ -736,7 +812,7 @@ static void q921_reject(struct q921_link *link, int pf)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.s.x0 = 0; /* Always 0 */
h.s.ss = 2; /* Reject */
h.s.ft = 1; /* Frametype (01) */
@@ -766,7 +842,7 @@ static void q921_rr(struct q921_link *link, int pbit, int cmd)
ctrl = link->ctrl;
Q921_INIT(link, h);
Q921_CLEAR_INIT(&h, link->sapi, link->tei);
h.s.x0 = 0; /* Always 0 */
h.s.ss = 0; /* Receive Ready */
h.s.ft = 1; /* Frametype (01) */
@@ -859,7 +935,7 @@ static void t200_expire(void *vlink)
q921_send_sabme(link);
start_t200(link);
} else {
q921_ptp_delay_restart(link);
q921_check_delay_restart(link);
q921_discard_iqueue(link);
q921_mdl_error(link, 'G');
q921_setstate(link, Q921_TEI_ASSIGNED);
@@ -873,7 +949,7 @@ static void t200_expire(void *vlink)
q921_send_disc(link, 1);
start_t200(link);
} else {
q921_ptp_delay_restart(link);
q921_check_delay_restart(link);
q921_mdl_error(link, 'H');
/* DL-RELEASE confirm */
q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
@@ -993,7 +1069,7 @@ int q921_transmit_iframe(struct q921_link *link, void *buf, int len, int cr)
f = calloc(1, sizeof(struct q921_frame) + len + 2);
if (f) {
Q921_INIT(link, f->h);
Q921_INIT(&f->h, link->sapi, link->tei);
switch (ctrl->localtype) {
case PRI_NETWORK:
if (cr)
@@ -1116,7 +1192,7 @@ static void q921_dump_iqueue_info(struct q921_link *link)
static void q921_dump_pri_by_h(struct pri *ctrl, char direction_tag, q921_h *h);
void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
void q921_dump(struct pri *ctrl, q921_h *h, int len, int debugflags, int txrx)
{
int x;
const char *type;
@@ -1125,9 +1201,11 @@ void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
direction_tag = txrx ? '>' : '<';
pri_message(ctrl, "\n");
q921_dump_pri_by_h(ctrl, direction_tag, h);
if (debugflags & PRI_DEBUG_Q921_DUMP) {
q921_dump_pri_by_h(ctrl, direction_tag, h);
}
if (showraw) {
if (debugflags & PRI_DEBUG_Q921_RAW) {
char *buf = malloc(len * 3 + 1);
int buflen = 0;
if (buf) {
@@ -1138,132 +1216,134 @@ void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
}
}
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
case 0:
case 2:
pri_message(ctrl, "%c Informational frame:\n", direction_tag);
break;
case 1:
pri_message(ctrl, "%c Supervisory frame:\n", direction_tag);
break;
case 3:
pri_message(ctrl, "%c Unnumbered frame:\n", direction_tag);
break;
}
pri_message(ctrl, "%c SAPI: %02d C/R: %d EA: %d\n",
direction_tag,
h->h.sapi,
h->h.c_r,
h->h.ea1);
pri_message(ctrl, "%c TEI: %03d EA: %d\n",
direction_tag,
h->h.tei,
h->h.ea2);
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
case 0:
case 2:
/* Informational frame */
pri_message(ctrl, "%c N(S): %03d 0: %d\n",
direction_tag,
h->i.n_s,
h->i.ft);
pri_message(ctrl, "%c N(R): %03d P: %d\n",
direction_tag,
h->i.n_r,
h->i.p_f);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 4);
break;
case 1:
/* Supervisory frame */
type = "???";
switch (h->s.ss) {
if (debugflags & PRI_DEBUG_Q921_DUMP) {
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
case 0:
type = "RR (receive ready)";
case 2:
pri_message(ctrl, "%c Informational frame:\n", direction_tag);
break;
case 1:
type = "RNR (receive not ready)";
pri_message(ctrl, "%c Supervisory frame:\n", direction_tag);
break;
case 2:
type = "REJ (reject)";
case 3:
pri_message(ctrl, "%c Unnumbered frame:\n", direction_tag);
break;
}
pri_message(ctrl, "%c Zero: %d S: %d 01: %d [ %s ]\n",
pri_message(ctrl, "%c SAPI: %02d C/R: %d EA: %d\n",
direction_tag,
h->s.x0,
h->s.ss,
h->s.ft,
type);
pri_message(ctrl, "%c N(R): %03d P/F: %d\n",
h->h.sapi,
h->h.c_r,
h->h.ea1);
pri_message(ctrl, "%c TEI: %03d EA: %d\n",
direction_tag,
h->s.n_r,
h->s.p_f);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 4);
break;
case 3:
/* Unnumbered frame */
type = "???";
if (h->u.ft == 3) {
switch (h->u.m3) {
h->h.tei,
h->h.ea2);
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
case 0:
case 2:
/* Informational frame */
pri_message(ctrl, "%c N(S): %03d 0: %d\n",
direction_tag,
h->i.n_s,
h->i.ft);
pri_message(ctrl, "%c N(R): %03d P: %d\n",
direction_tag,
h->i.n_r,
h->i.p_f);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 4);
break;
case 1:
/* Supervisory frame */
type = "???";
switch (h->s.ss) {
case 0:
if (h->u.m2 == 3)
type = "DM (disconnect mode)";
else if (h->u.m2 == 0)
type = "UI (unnumbered information)";
type = "RR (receive ready)";
break;
case 1:
type = "RNR (receive not ready)";
break;
case 2:
if (h->u.m2 == 0)
type = "DISC (disconnect)";
break;
case 3:
if (h->u.m2 == 3)
type = "SABME (set asynchronous balanced mode extended)";
else if (h->u.m2 == 0)
type = "UA (unnumbered acknowledgement)";
break;
case 4:
if (h->u.m2 == 1)
type = "FRMR (frame reject)";
break;
case 5:
if (h->u.m2 == 3)
type = "XID (exchange identification note)";
break;
default:
type = "REJ (reject)";
break;
}
pri_message(ctrl, "%c Zero: %d S: %d 01: %d [ %s ]\n",
direction_tag,
h->s.x0,
h->s.ss,
h->s.ft,
type);
pri_message(ctrl, "%c N(R): %03d P/F: %d\n",
direction_tag,
h->s.n_r,
h->s.p_f);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 4);
break;
case 3:
/* Unnumbered frame */
type = "???";
if (h->u.ft == 3) {
switch (h->u.m3) {
case 0:
if (h->u.m2 == 3)
type = "DM (disconnect mode)";
else if (h->u.m2 == 0)
type = "UI (unnumbered information)";
break;
case 2:
if (h->u.m2 == 0)
type = "DISC (disconnect)";
break;
case 3:
if (h->u.m2 == 3)
type = "SABME (set asynchronous balanced mode extended)";
else if (h->u.m2 == 0)
type = "UA (unnumbered acknowledgement)";
break;
case 4:
if (h->u.m2 == 1)
type = "FRMR (frame reject)";
break;
case 5:
if (h->u.m2 == 3)
type = "XID (exchange identification note)";
break;
default:
break;
}
}
pri_message(ctrl, "%c M3: %d P/F: %d M2: %d 11: %d [ %s ]\n",
direction_tag,
h->u.m3,
h->u.p_f,
h->u.m2,
h->u.ft,
type);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 3);
break;
}
pri_message(ctrl, "%c M3: %d P/F: %d M2: %d 11: %d [ %s ]\n",
direction_tag,
h->u.m3,
h->u.p_f,
h->u.m2,
h->u.ft,
type);
pri_message(ctrl, "%c %d bytes of data\n",
direction_tag,
len - 3);
break;
}
if ((h->u.ft == 3) && (h->u.m3 == 0) && (h->u.m2 == 0) && (h->u.data[0] == 0x0f)) {
int ri;
u_int8_t *action;
/* TEI management related */
type = q921_tei_mgmt2str(h->u.data[3]);
pri_message(ctrl, "%c MDL Message: %d(%s)\n", direction_tag, h->u.data[3], type);
ri = (h->u.data[1] << 8) | h->u.data[2];
pri_message(ctrl, "%c Ri: %d\n", direction_tag, ri);
action = &h->u.data[4];
for (x = len - (action - (u_int8_t *) h); 0 < x; --x, ++action) {
pri_message(ctrl, "%c Ai: %d E:%d\n",
direction_tag, (*action >> 1) & 0x7f, *action & 0x01);
if ((h->u.ft == 3) && (h->u.m3 == 0) && (h->u.m2 == 0) && (h->u.data[0] == 0x0f)) {
int ri;
u_int8_t *action;
/* TEI management related */
type = q921_tei_mgmt2str(h->u.data[3]);
pri_message(ctrl, "%c MDL Message: %d(%s)\n", direction_tag, h->u.data[3], type);
ri = (h->u.data[1] << 8) | h->u.data[2];
pri_message(ctrl, "%c Ri: %d\n", direction_tag, ri);
action = &h->u.data[4];
for (x = len - (action - (u_int8_t *) h); 0 < x; --x, ++action) {
pri_message(ctrl, "%c Ai: %d E:%d\n",
direction_tag, (*action >> 1) & 0x7f, *action & 0x01);
}
}
}
}
@@ -1319,12 +1399,6 @@ static void t201_expire(void *vctrl)
ctrl = vctrl;
if (!ctrl->link.next) {
/* No TEI links remain. */
ctrl->t201_timer = 0;
return;
}
/* Start the TEI check timer. */
ctrl->t201_timer =
pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T201], t201_expire, ctrl);
@@ -1385,7 +1459,7 @@ static void t201_expire(void *vctrl)
}
}
}
q921_send_tei(ctrl, Q921_TEI_IDENTITY_CHECK_REQUEST, 0, Q921_TEI_GROUP, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_CHECK_REQUEST, 0, Q921_TEI_GROUP, 1);
}
static void q921_tei_check(struct pri *ctrl)
@@ -1398,7 +1472,19 @@ static void q921_tei_check(struct pri *ctrl)
t201_expire(ctrl);
}
static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
static void q921_mdl_ignore(struct pri *ctrl, q921_u *h, const char *reason)
{
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
/*
* Send out this message in debug modes since it is possible the
* user has misconfigured their link for the wrong mode.
*/
pri_message(ctrl, "Ignoring MDL message: %d(%s) %s\n",
h->data[3], q921_tei_mgmt2str(h->data[3]), reason);
}
}
static pri_event *q921_mdl_receive(struct pri *ctrl, q921_u *h, int len)
{
int ri;
struct q921_link *sub;
@@ -1408,20 +1494,13 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
int count;
int tei;
if (!BRI_NT_PTMP(ctrl) && !BRI_TE_PTMP(ctrl)) {
return pri_mkerror(ctrl,
"Received MDL/TEI managemement message, but configured for mode other than PTMP!\n");
}
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Received MDL message\n");
}
if (len <= &h->data[0] - (u_int8_t *) h) {
pri_error(ctrl, "Received short frame\n");
pri_error(ctrl, "Received short MDL frame\n");
return NULL;
}
if (h->data[0] != 0x0f) {
pri_error(ctrl, "Received MDL with unsupported management entity %02x\n", h->data[0]);
pri_error(ctrl, "Received MDL with unsupported management entity %02x\n",
h->data[0]);
return NULL;
}
if (len <= &h->data[4] - (u_int8_t *) h) {
@@ -1430,8 +1509,20 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
}
if (h->data[3] != Q921_TEI_IDENTITY_CHECK_RESPONSE
&& !(h->data[4] & 0x01)) {
pri_error(ctrl, "Received %d(%s) with Ai E bit not set.\n", h->data[3],
q921_tei_mgmt2str(h->data[3]));
pri_error(ctrl, "Received MDL message: %d(%s) with Ai E bit not set.\n",
h->data[3], q921_tei_mgmt2str(h->data[3]));
return NULL;
}
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Received MDL message: %d(%s)\n",
h->data[3], q921_tei_mgmt2str(h->data[3]));
}
if (PTP_MODE(ctrl) && NT_MODE(ctrl)) {
/*
* We are not managing automatic TEI's in this mode so we can
* ignore MDL messages from the CPE.
*/
q921_mdl_ignore(ctrl, h, "We are in NT-PTP mode.");
return NULL;
}
ri = (h->data[1] << 8) | h->data[2];
@@ -1440,13 +1531,14 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
switch (h->data[3]) {
case Q921_TEI_IDENTITY_REQUEST:
if (!BRI_NT_PTMP(ctrl)) {
q921_mdl_ignore(ctrl, h, "We are not in NT-PTMP mode.");
return NULL;
}
if (tei != Q921_TEI_GROUP) {
pri_error(ctrl, "Received %s with invalid TEI %d\n",
q921_tei_mgmt2str(Q921_TEI_IDENTITY_REQUEST), tei);
q921_send_tei(ctrl, Q921_TEI_IDENTITY_DENIED, ri, tei, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_DENIED, ri, tei, 1);
return NULL;
}
@@ -1461,7 +1553,7 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
break;
}
pri_error(ctrl, "TEI pool exhausted. Reclaiming dead TEIs.\n");
q921_send_tei(ctrl, Q921_TEI_IDENTITY_DENIED, ri, Q921_TEI_GROUP, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_DENIED, ri, Q921_TEI_GROUP, 1);
q921_tei_check(ctrl);
return NULL;
}
@@ -1471,13 +1563,14 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Allocating new TEI %d\n", tei);
}
sub->next = pri_link_new(ctrl, Q921_SAPI_CALL_CTRL, tei);
if (!sub->next) {
link = pri_link_new(ctrl, Q921_SAPI_CALL_CTRL, tei);
if (!link) {
pri_error(ctrl, "Unable to allocate layer 2 link for new TEI %d\n", tei);
return NULL;
}
q921_setstate(sub->next, Q921_TEI_ASSIGNED);
q921_send_tei(ctrl, Q921_TEI_IDENTITY_ASSIGNED, ri, tei, 1);
sub->next = link;
q921_setstate(link, Q921_TEI_ASSIGNED);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_ASSIGNED, ri, tei, 1);
count = 0;
for (sub = ctrl->link.next; sub; sub = sub->next) {
@@ -1493,9 +1586,19 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
}
q921_tei_check(ctrl);
}
if (ctrl->l2_persistence == PRI_L2_PERSISTENCE_KEEP_UP) {
/*
* Layer 2 is persistent so give the peer some time to setup
* it's new TEI and bring the link up itself before we bring the
* link up.
*/
restart_timer_start(link);
}
break;
case Q921_TEI_IDENTITY_CHECK_RESPONSE:
if (!BRI_NT_PTMP(ctrl)) {
/* Silently ignore the message since we never asked for the check. */
return NULL;
}
@@ -1543,6 +1646,7 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
break;
case Q921_TEI_IDENTITY_VERIFY:
if (!BRI_NT_PTMP(ctrl)) {
q921_mdl_ignore(ctrl, h, "We are not in NT-PTMP mode.");
return NULL;
}
if (tei == Q921_TEI_GROUP) {
@@ -1553,16 +1657,30 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
q921_tei_check(ctrl);
break;
case Q921_TEI_IDENTITY_ASSIGNED:
if (NT_MODE(ctrl)) {
/* We should not be receiving this message. */
q921_mdl_ignore(ctrl, h, "We are the network.");
return NULL;
}
if (!BRI_TE_PTMP(ctrl)) {
/*
* Silently ignore the message. It must not be for us
* since we will never ask for one.
*/
return NULL;
}
/* Assuming we're operating on the specific TEI link here */
/* We're operating on the specific TEI link here */
link = ctrl->link.next;
switch (link->state) {
case Q921_TEI_UNASSIGNED:
/* We do not have a TEI and we are not asking for one. */
/*
* We do not have a TEI and we are not currently asking for one.
* Start asking for one.
*/
q921_setstate(link, Q921_ASSIGN_AWAITING_TEI);
q921_tei_request(link);
return NULL;
case Q921_ASSIGN_AWAITING_TEI:
case Q921_ESTABLISH_AWAITING_TEI:
@@ -1604,9 +1722,12 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
switch (link->state) {
case Q921_ASSIGN_AWAITING_TEI:
q921_setstate(link, Q921_TEI_ASSIGNED);
ctrl->ev.gen.e = PRI_EVENT_DCHAN_UP;
res = &ctrl->ev;
break;
if (ctrl->l2_persistence != PRI_L2_PERSISTENCE_KEEP_UP) {
ctrl->ev.gen.e = PRI_EVENT_DCHAN_UP;
res = &ctrl->ev;
break;
}
/* Fall through: Layer 2 is persistent so bring it up. */
case Q921_ESTABLISH_AWAITING_TEI:
q921_establish_data_link(link);
link->l3_initiated = 1;
@@ -1619,29 +1740,52 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
}
break;
case Q921_TEI_IDENTITY_CHECK_REQUEST:
if (!BRI_TE_PTMP(ctrl)) {
if (NT_MODE(ctrl)) {
/* We should not be receiving this message. */
q921_mdl_ignore(ctrl, h, "We are the network.");
return NULL;
}
/* Assuming we're operating on the specific TEI link here */
link = ctrl->link.next;
if (PTP_MODE(ctrl)) {
/*
* Some telco switches/devices get very unhappy if we don't
* respond to the TEI check request with our permanently
* assigned TEI.
*/
link = &ctrl->link;
} else if (BRI_TE_PTMP(ctrl)) {
/* We're operating on the specific TEI link here */
link = ctrl->link.next;
if (link->state < Q921_TEI_ASSIGNED) {
/* We do not have a TEI. */
if (link->state < Q921_TEI_ASSIGNED) {
/* We do not have a TEI. */
return NULL;
}
} else {
/* Should never get here. */
return NULL;
}
/* If it's addressed to the group TEI or to our TEI specifically, we respond */
if (tei == Q921_TEI_GROUP || tei == link->tei) {
q921_send_tei(ctrl, Q921_TEI_IDENTITY_CHECK_RESPONSE, random() % 65535, link->tei, 1);
q921_mdl_send(ctrl, Q921_TEI_IDENTITY_CHECK_RESPONSE, random() % 65535, link->tei, 1);
}
break;
case Q921_TEI_IDENTITY_REMOVE:
if (NT_MODE(ctrl)) {
/* We should not be receiving this message. */
q921_mdl_ignore(ctrl, h, "We are the network.");
return NULL;
}
if (!BRI_TE_PTMP(ctrl)) {
/*
* Silently ignore the message. If we are TE-PTP our
* TEI is permanently assigned and cannot be removed.
*/
return NULL;
}
/* Assuming we're operating on the specific TEI link here */
/* We're operating on the specific TEI link here */
link = ctrl->link.next;
if (link->state < Q921_TEI_ASSIGNED) {
@@ -1765,7 +1909,7 @@ static pri_event *q921_disc_rx(struct q921_link *link, q921_h *h)
break;
case Q921_MULTI_FRAME_ESTABLISHED:
case Q921_TIMER_RECOVERY:
res = q921_ptp_delay_restart(link);
res = q921_check_delay_restart(link);
q921_discard_iqueue(link);
q921_send_ua(link, h->u.p_f);
/* DL-RELEASE indication */
@@ -1806,7 +1950,9 @@ static void q921_mdl_remove(struct q921_link *link)
switch (link->state) {
case Q921_TEI_ASSIGNED:
restart_timer_stop(link);
if (mdl_free_me) {
restart_timer_stop(link);
}
/* XXX: deviation! Since we don't have a UI queue, we just discard our I-queue */
q921_discard_iqueue(link);
q921_setstate(link, Q921_TEI_UNASSIGNED);
@@ -2177,7 +2323,7 @@ static pri_event *q921_ua_rx(struct q921_link *link, q921_h *h)
if (!h->u.p_f) {
q921_mdl_error(link, 'D');
} else {
res = q921_ptp_delay_restart(link);
res = q921_check_delay_restart(link);
/* DL-RELEASE confirm */
q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
stop_t200(link);
@@ -2615,7 +2761,7 @@ static pri_event *q921_dm_rx(struct q921_link *link, q921_h *h)
if (!h->u.p_f)
break;
res = q921_ptp_delay_restart(link);
res = q921_check_delay_restart(link);
q921_discard_iqueue(link);
/* DL-RELEASE indication */
q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
@@ -2625,7 +2771,7 @@ static pri_event *q921_dm_rx(struct q921_link *link, q921_h *h)
case Q921_AWAITING_RELEASE:
if (!h->u.p_f)
break;
res = q921_ptp_delay_restart(link);
res = q921_check_delay_restart(link);
/* DL-RELEASE confirm */
q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_CONFIRM);
stop_t200(link);
@@ -2882,27 +3028,32 @@ static pri_event *__q921_receive_qualified(struct q921_link *link, q921_h *h, in
static pri_event *q921_handle_unmatched_frame(struct pri *ctrl, q921_h *h, int len)
{
if (h->h.tei < 64) {
pri_error(ctrl, "Do not support manual TEI range. Discarding\n");
if (!BRI_NT_PTMP(ctrl)) {
return NULL;
}
if (h->h.tei < Q921_TEI_AUTO_FIRST) {
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Manual TEI range is not supported in NT-PTMP mode. Discarding\n");
}
return NULL;
}
if (h->h.sapi != Q921_SAPI_CALL_CTRL) {
pri_error(ctrl, "Message with SAPI other than CALL CTRL is discarded\n");
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl, "Message with SAPI other than CALL CTRL is discarded\n");
}
return NULL;
}
/* If we're NT-PTMP, this means an unrecognized TEI that we'll kill */
if (BRI_NT_PTMP(ctrl)) {
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl,
"Could not find a layer 2 link for received frame with SAPI/TEI of %d/%d.\n",
h->h.sapi, h->h.tei);
pri_message(ctrl, "Sending TEI release, in order to re-establish TEI state\n");
}
q921_tei_remove(ctrl, h->h.tei);
/* This means an unrecognized TEI that we'll kill */
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
pri_message(ctrl,
"Could not find a layer 2 link for received frame with SAPI/TEI of %d/%d.\n",
h->h.sapi, h->h.tei);
pri_message(ctrl, "Sending TEI release, in order to re-establish TEI state\n");
}
q921_tei_remove(ctrl, h->h.tei);
return NULL;
}
@@ -2917,7 +3068,7 @@ static pri_event *__q921_receive(struct pri *ctrl, q921_h *h, int len)
len -= 2;
if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW)) {
q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 0);
q921_dump(ctrl, h, len, ctrl->debug, 0);
}
/* Check some reject conditions -- Start by rejecting improper ea's */
@@ -2926,7 +3077,7 @@ static pri_event *__q921_receive(struct pri *ctrl, q921_h *h, int len)
}
if (h->h.sapi == Q921_SAPI_LAYER2_MANAGEMENT) {
return q921_receive_MDL(ctrl, &h->u, len);
return q921_mdl_receive(ctrl, &h->u, len);
}
if (h->h.tei == Q921_TEI_GROUP && h->h.sapi != Q921_SAPI_CALL_CTRL) {

1303
q931.c

File diff suppressed because it is too large Load Diff

View File

@@ -48,13 +48,10 @@
#include <sys/time.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <zaptel/zaptel.h>
#ifndef SOLARIS
#include <zap.h>
#endif
#include <pthread.h>
#include <sys/select.h>
#include "libpri.h"
#include "pri_q921.h"
#include "pri_q931.h"
#ifndef AF_LOCAL
@@ -66,7 +63,7 @@
#define PRI_DEF_NODETYPE PRI_CPE
#define PRI_DEF_SWITCHTYPE PRI_SWITCH_NI2
static struct pri *first, *cur;
static struct pri *first;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
@@ -159,9 +156,9 @@ static void testmsg(struct pri *pri, char *s)
*c = '\0';
c++;
}
if (keeplast)
if (keeplast || !pri)
printf("%s", s);
else if (cur == first)
else if (pri == first)
printf("-1 %s", s);
else
printf("-2 %s", s);
@@ -185,9 +182,9 @@ static void testerr(struct pri *pri, char *s)
*c = '\0';
c++;
}
if (keeplast)
if (keeplast || !pri)
printf("%s", s);
else if (cur == first)
else if (pri == first)
printf("=1 %s", s);
else
printf("=2 %s", s);
@@ -207,7 +204,7 @@ static void *dchan(void *data)
/* Joint D-channel */
struct pri *pri = data;
struct timeval *next, tv;
pri_event *e;
pri_event *e = NULL;
fd_set fds;
int res;
for(;;) {
@@ -228,7 +225,6 @@ static void *dchan(void *data)
FD_SET(pri_fd(pri), &fds);
res = select(pri_fd(pri) + 1, &fds, NULL, NULL, next ? &tv : NULL);
pthread_mutex_lock(&lock);
cur = pri;
if (res < 0) {
perror("select");
} else if (!res) {
@@ -238,9 +234,9 @@ static void *dchan(void *data)
}
if (e) {
if (first == pri) {
event1(e->gen.pri, e);
event1(pri, e);
} else {
event2(e->gen.pri, e);
event2(pri, e);
}
}
pthread_mutex_unlock(&lock);