Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26d06c939a | ||
|
|
add4571039 | ||
|
|
10a6efc3ae | ||
|
|
85838caabd | ||
|
|
07c4195876 | ||
|
|
40ae2a030a | ||
|
|
2c104c4dbd | ||
|
|
e1bfec4b1e | ||
|
|
aeb5a6d284 | ||
|
|
64eaca5bfa | ||
|
|
67bc1003ab | ||
|
|
419282d399 | ||
|
|
9e6df1092c | ||
|
|
1c7588ead5 | ||
|
|
16df54e01a | ||
|
|
16719a5f74 | ||
|
|
8c5da8a278 | ||
|
|
aad7c3e8f1 | ||
|
|
95ccc0e03c | ||
|
|
b9a6ab0c69 | ||
|
|
dee4c9ae0f | ||
|
|
b9bd97cdb7 | ||
|
|
c93dfbae5f | ||
|
|
160be09f76 | ||
|
|
ba46c5ca03 |
382
ChangeLog
Normal file
382
ChangeLog
Normal file
@@ -0,0 +1,382 @@
|
||||
2009-01-09 Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* libpri 1.4.9 released.
|
||||
|
||||
2009-01-09 17:58 +0000 [r656] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Add additional case where T200 expires greater than N200
|
||||
times and we need to release and reacquire the TEI.
|
||||
|
||||
2008-12-23 21:38 +0000 [r653] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c, q931.c: Add some additional debug for Q.921 MDL messages
|
||||
as well as fix a bug in RESTART messages on BRI
|
||||
|
||||
2008-11-22 Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* libpri 1.4.8 released.
|
||||
|
||||
2008-11-22 00:34 +0000 [r645] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Fix a number of Q.921 bugs, found doing TBR4 compliance
|
||||
testing, thanks to Tzafrir, Xorcom, and co. (#12861). Thanks!
|
||||
|
||||
2008-10-17 16:13 +0000 [r636] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* pri.c, pri_internal.h, pri_q931.h, q931.c, pri_facility.c,
|
||||
pri_facility.h, libpri.h: Merging in additional Q.SIG features in
|
||||
#13454. Includes Q.SIG physical/logical channel mapping support,
|
||||
extended coding of Q.SIG name operations (calling name), and call
|
||||
rerouting support via added dialplan application.
|
||||
|
||||
2008-08-06 18:20 +0000 [r616] Jason Parker <jparker@digium.com>
|
||||
|
||||
* Makefile: Make install paths use libdir, like libss7
|
||||
|
||||
2008-08-05 Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* libpri 1.4.7 released.
|
||||
|
||||
2008-08-05 22:18 +0000 [r611] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* pritest.c, pri.c, pri_internal.h, q921.c, q931.c, copy_string.c,
|
||||
prisched.c, pri_q921.h, pri_q931.h, pri_facility.c, /,
|
||||
compiler.h, pridump.c, testprilib.c, pri_timers.h,
|
||||
pri_facility.h, libpri.h: Merged revisions 610 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r610
|
||||
| kpfleming | 2008-08-05 17:16:58 -0500 (Tue, 05 Aug 2008) | 2
|
||||
lines clean up license headers, and explicitly grant additional
|
||||
permissions when used with Asterisk ........
|
||||
|
||||
2008-07-30 15:43 +0000 [r606-607] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* /: update ignore list
|
||||
|
||||
* Makefile, mkdep (removed): use better version.c creation process,
|
||||
and better dependency tracking process too
|
||||
|
||||
2008-07-29 22:47 +0000 [r598-602] Jason Parker <jparker@digium.com>
|
||||
|
||||
* build_tools/make_version: I believe this is what was meant. (it
|
||||
matches how Asterisk does it)
|
||||
|
||||
* build_tools/make_version: libpri is not libss7 :D
|
||||
|
||||
2008-07-22 22:36 +0000 [r594] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* pri_internal.h, libpri.h: correct comments to match code
|
||||
|
||||
2008-07-22 Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* Libpri 1.4.6 released.
|
||||
|
||||
2008-07-22 19:43 +0000 [r589] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* pri.c, pri_internal.h, q931.c, libpri.h: rename API call and
|
||||
option (nothing has been released to use it yet so this should be
|
||||
safe) to be more accurate in describing what it does (closes
|
||||
issue #13042)
|
||||
|
||||
2008-07-11 Jason Parker <jparker@digium.com>
|
||||
|
||||
* Libpri 1.4.5 released.
|
||||
|
||||
2008-07-11 16:44 +0000 [r574-579] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* /: ignore generated files
|
||||
|
||||
* pri.c, pri_internal.h, q931.c, libpri.h: modify work done for
|
||||
issue #10552, making the support of inband audio after RELEASE a
|
||||
configurable option, since it is causing problems for a number of
|
||||
users (closes issue #13042)
|
||||
|
||||
2008-06-04 17:02 +0000 [r562] Dwayne M. Hubbard <dhubbard@digium.com>
|
||||
|
||||
* q931.c: While working on issue 3450 I noticed that the
|
||||
information channel selection field in the channel identification
|
||||
IE was displayed incorrectly when using 'pri intense debug'. I
|
||||
wanted another pair of eyes to look at the code because
|
||||
everything looked correct until Shaun Ruffell noticed the missing
|
||||
comma in the msg_chan_sel array.
|
||||
|
||||
2008-05-07 19:51 +0000 [r557] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* pri.c, pritest.c, pri_internal.h, pri_q921.h, Makefile, q921.c,
|
||||
q931.c, pri_facility.c, prisched.c, testprilib.c, pri_timers.h,
|
||||
pri_facility.h, libpri.h: Moving trunk changes back into 1.4
|
||||
|
||||
2008-05-07 Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* Libpri 1.4.4 released.
|
||||
|
||||
2008-05-06 16:43 +0000 [r553-555] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c, pri.c: Remove some unnecessary debug messages
|
||||
|
||||
* q931.c: We passed TBR3 layer 2 and layer 3 testing with this
|
||||
commit in for BRI-TE PTMP.
|
||||
|
||||
* q931.c: Final patch to pass certification
|
||||
|
||||
2008-04-22 15:30 +0000 [r546] Russell Bryant <russell@digium.com>
|
||||
|
||||
* Makefile: All versions of libpri have been installed as
|
||||
libpri.so.1.0, even though the API and ABI have changed over
|
||||
time. This patch changes the Makefile to install the library as
|
||||
libpri.so.1.4 to indicate that this is not compatible with
|
||||
previous versions. In the future, this should be changed as we
|
||||
make ABI changes. (closes issue #10376) Reported by: tzafrir
|
||||
Patches: libpri-soname.diff uploaded by tzafrir (license 46) --
|
||||
with very minor changes by me
|
||||
|
||||
2008-03-15 19:57 +0000 [r541-543] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* libpri.h, pri.c: Remove some useless event items
|
||||
|
||||
* q921.c, pri_internal.h: Make sure if we're a bri and in PTMP mode
|
||||
that we release the TEI and try to get a new one with the other
|
||||
end when we lose activity in multiframe mode
|
||||
|
||||
* q921.c, pri.c, pri_q921.h: When we recieve a UA in any TEI
|
||||
established state other than awaiting establishement make sure we
|
||||
drop the TEI and get a new one. For passing tests PC37.2 - PC41.2
|
||||
in Q.921
|
||||
|
||||
2008-03-06 23:43 +0000 [r538-539] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Make sure we are sending as command not as response
|
||||
|
||||
* q921.c: Make sure C/R bit is correct
|
||||
|
||||
2008-03-01 23:30 +0000 [r531-535] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Remove some (currently) useless code
|
||||
|
||||
* q921.c, pri.c, pri_internal.h: Some more updates to add code for
|
||||
passing PC 27.1 in Q.921
|
||||
|
||||
* q921.c, pri.c: Various coding style cleanups as well as a bug fix
|
||||
for TEI removal
|
||||
|
||||
* q921.c, q931.c, pri.c, pri_internal.h: Initial checkin of code to
|
||||
pass Q.921 PC25 and PC26
|
||||
|
||||
* q921.c: Add support for responding to TEI requests (Q.921 PC23.x)
|
||||
|
||||
2008-02-18 20:31 +0000 [r525] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, libpri.h: Improve transmission, receiving, and dumping of
|
||||
bearer capability IE (#11593)
|
||||
|
||||
2008-01-16 18:06 +0000 [r518] Jason Parker <jparker@digium.com>
|
||||
|
||||
* Makefile, /: Add logging for 'make update' command (also fixes
|
||||
updates in some places). Issue #11766, initial patch by jmls.
|
||||
|
||||
2007-12-26 17:35 +0000 [r505] Russell Bryant <russell@digium.com>
|
||||
|
||||
* libpri.h: Remove unnecessary usage of the extern keyword.
|
||||
|
||||
2007-12-06 22:16 +0000 [r494-496] Russell Bryant <russell@digium.com>
|
||||
|
||||
* q921.c, q931.c, pri_facility.c, pri.c: Change malloc+memset to
|
||||
calloc. Also, handle allocation failures early to reduce
|
||||
indentation. (closes issue #11469) Reported by: eliel Patches:
|
||||
pri.c.patch uploaded by eliel (license 64) q931.c.patch uploaded
|
||||
by eliel (license 64) q921.c.patch uploaded by eliel (license 64)
|
||||
pri_facility.c.patch uploaded by eliel (license 64)
|
||||
|
||||
* pri.c: Change a use of malloc+memset to calloc. Also, reduce
|
||||
indentation of a function by doing the check for memory
|
||||
allocation failure at the beginning.
|
||||
|
||||
* pri.c: Change the table used to hold the default timers to be
|
||||
global and const, instead of allocating it on the stack each time
|
||||
the function is called.
|
||||
|
||||
2007-12-05 00:20 +0000 [r491-493] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c: Improve the parameter name to better reflect its use
|
||||
|
||||
* q921.c, q931.c: More PTMP fixes. Stand by, more changes to come
|
||||
|
||||
* q921.c, q931.c, testprilib.c: More magic to make BRI CPE PTMP
|
||||
work
|
||||
|
||||
2007-11-21 22:30 +0000 [r486-487] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c: Make sure we loop BRI call references for one byte CREFs
|
||||
instead of two
|
||||
|
||||
* q921.c, q931.c, libpri.h, pri.c, pritest.c, pri_internal.h: Add
|
||||
BRI support to libpri
|
||||
|
||||
2007-10-13 16:00 +0000 [r473] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Make sure that we only output the message handling debug
|
||||
when we're actually debugging
|
||||
|
||||
2007-09-25 21:56 +0000 [r469] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c: Fix user-user IE order in setup message (#10705)
|
||||
|
||||
2007-06-20 15:18 +0000 [r428-430] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* Makefile: Revert that back to how it was
|
||||
|
||||
* Makefile, q921.c, q931.c, prisched.c, testprilib.c, pri_timers.h,
|
||||
libpri.h, pri.c, pri_internal.h, pri_q921.h: Patch to add PTMP
|
||||
mode (BRI support)
|
||||
|
||||
2007-06-06 21:59 +0000 [r417-425] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, pri_facility.c, pri_facility.h, pri.c, pri_internal.h:
|
||||
Preliminary patch plus mods for Q.SIG Path Replacement (Q.SIG
|
||||
version of 2BCT) #7778
|
||||
|
||||
2007-05-25 17:36 +0000 [r413] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, pri_facility.c, pri_facility.h, libpri.h: Commit path for
|
||||
ROSE-12 and ROSE-13 support (#9076)
|
||||
|
||||
2006-11-03 18:16 +0000 [r382] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q921.c: Remove pointless recursion. (#8281)
|
||||
|
||||
2008-05-07 19:51 +0000 [r557] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* pri.c, pritest.c, pri_internal.h, pri_q921.h, Makefile, q921.c,
|
||||
q931.c, pri_facility.c, prisched.c, testprilib.c, pri_timers.h,
|
||||
pri_facility.h, libpri.h: Moving trunk changes back into 1.4
|
||||
|
||||
2008-05-02 20:21 +0000 [r552] Brett Bryant <bbryant@digium.com>
|
||||
|
||||
* Makefile, build_tools (added), build_tools/make_version (added),
|
||||
build_tools/make_version_c (added), libpri.h: Add new API call
|
||||
(pri_get_version) to show the current version of the branch for
|
||||
support purposes.
|
||||
|
||||
2008-04-16 00:21 +0000 [r544] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* q921.c: fix the indentation in this function so that it is
|
||||
actually possible to read it and understand the logic and flow
|
||||
|
||||
2008-02-21 16:38 +0000 [r528] Joshua Colp <jcolp@digium.com>
|
||||
|
||||
* q931.c: If inband audio is being provided with a disconnect
|
||||
message let the audio be heard before releasing the channel.
|
||||
(closes issue #10552) Reported by: paravoid Patches:
|
||||
disconnect-audio.diff uploaded by paravoid (license 200)
|
||||
|
||||
2008-02-18 20:31 +0000 [r524] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, libpri.h: Improve transmission, receiving, and dumping of
|
||||
bearer capability IE (#11593)
|
||||
|
||||
2008-01-11 16:34 +0000 [r514] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, /: Merged revisions 513 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r513
|
||||
| mattf | 2008-01-11 10:33:52 -0600 (Fri, 11 Jan 2008) | 1 line
|
||||
We should not be parsing further into the bearer capability IE if
|
||||
the length does not confirm that there actually is data present
|
||||
........
|
||||
|
||||
2007-12-13 Russell Bryant <russell@digium.com>
|
||||
|
||||
* libpri 1.4.3 released.
|
||||
|
||||
2007-10-22 15:10 +0000 [r479] Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* pri_internal.h, /: Merged revisions 478 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r478
|
||||
| kpfleming | 2007-10-22 10:09:27 -0500 (Mon, 22 Oct 2007) | 3
|
||||
lines we need to include stddef.h for 'size_t' ........
|
||||
|
||||
2007-10-16 Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* libpri 1.4.2 released.
|
||||
|
||||
2007-10-05 16:45 +0000 [r470] Jason Parker <jparker@digium.com>
|
||||
|
||||
* libpri.h: Fix an incorrect pri_event structure definition. Issue
|
||||
10832, patch by flefoll
|
||||
|
||||
2007-09-25 21:37 +0000 [r468] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c: Fix user-user IE order in setup message (#10705)
|
||||
|
||||
2007-09-14 21:32 +0000 [r465] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, libpri.h: Fix for #10189. Make sure we properly report
|
||||
the user layer 1 for H.223 and H.245
|
||||
|
||||
2007-09-06 15:11 +0000 [r462] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* pri.c, pri_facility.c, /: Merged revisions 460 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r460
|
||||
| mattf | 2007-09-06 10:06:42 -0500 (Thu, 06 Sep 2007) | 1 line
|
||||
TBCT now works. It should work for NI2, 4E, and 5E. This code was
|
||||
tested on NI2. ........
|
||||
|
||||
2007-08-27 19:21 +0000 [r446] Jason Parker <jparker@digium.com>
|
||||
|
||||
* Makefile, /: Merged revisions 445 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r445
|
||||
| qwell | 2007-08-27 14:20:23 -0500 (Mon, 27 Aug 2007) | 2 lines
|
||||
Make sure we build both the static and shared modules with -fPIC.
|
||||
........
|
||||
|
||||
2007-08-06 19:58 +0000 [r441] Jason Parker <jparker@digium.com>
|
||||
|
||||
* Makefile: Allow setting CC to something with a space, such as
|
||||
`make CC="gcc -m32"` Issue 10253.
|
||||
|
||||
2007-07-09 Russell Bryant <russell@digium.com>
|
||||
|
||||
* libpri 1.4.1 released.
|
||||
|
||||
2007-06-19 18:23 +0000 [r427] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, /: Merged revisions 426 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r426
|
||||
| mattf | 2007-06-19 13:22:33 -0500 (Tue, 19 Jun 2007) | 1 line
|
||||
Try to send pending facility messages if we receive alerting (for
|
||||
when we don't get proceeding) (#9651) ........
|
||||
|
||||
2007-06-06 21:58 +0000 [r416-424] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* pri_facility.c, /: Merged revisions 423 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r423
|
||||
| mattf | 2007-06-06 16:57:15 -0500 (Wed, 06 Jun 2007) | 1 line
|
||||
Oops, that should not be on one line ........
|
||||
|
||||
* pri_facility.c, /: Merged revisions 415 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r415
|
||||
| mattf | 2007-06-06 08:20:05 -0500 (Wed, 06 Jun 2007) | 2 lines
|
||||
Make sure we only send the NFE when we are talking QSIG ........
|
||||
|
||||
2007-01-22 22:29 +0000 [r390] Matthew Fredrickson <creslin@digium.com>
|
||||
|
||||
* q931.c, /: Merged revisions 389 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r389
|
||||
| mattf | 2007-01-22 16:20:59 -0600 (Mon, 22 Jan 2007) | 2 lines
|
||||
Make sure we send DISCONNECT if we reached the active state and a
|
||||
call is disconnected, regardless of cause code. ........
|
||||
|
||||
2006-12-30 19:17 +0000 [r386] Joshua Colp <jcolp@digium.com>
|
||||
|
||||
* Makefile, /: Merged revisions 385 via svnmerge from
|
||||
https://origsvn.digium.com/svn/libpri/branches/1.2 ........ r385
|
||||
| file | 2006-12-30 14:16:17 -0500 (Sat, 30 Dec 2006) | 2 lines
|
||||
Specify full path to restorecon instead of assuming it will be
|
||||
available from what is in $PATH. (issue #8670 reported by djflux)
|
||||
........
|
||||
|
||||
2006-12-23 Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* libpri 1.4.0 released.
|
||||
|
||||
2006-09-20 Kevin P. Fleming <kpfleming@digium.com>
|
||||
|
||||
* libpri 1.4.0-beta1 released.
|
||||
92
Makefile
92
Makefile
@@ -28,18 +28,26 @@
|
||||
#LIBPRI_COUNTERS=-DLIBPRI_COUNTERS
|
||||
|
||||
CC=gcc
|
||||
GREP=grep
|
||||
AWK=awk
|
||||
|
||||
OSARCH=$(shell uname -s)
|
||||
PROC?=$(shell uname -m)
|
||||
|
||||
# SONAME version; should be changed on every ABI change
|
||||
# please don't change it needlessly; it's perfectly fine to have a SONAME
|
||||
# of 1.2 and a version of 1.4.x
|
||||
SONAME:=1.4
|
||||
|
||||
STATIC_LIBRARY=libpri.a
|
||||
DYNAMIC_LIBRARY=libpri.so.1.0
|
||||
STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o
|
||||
DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo
|
||||
DYNAMIC_LIBRARY:=libpri.so.$(SONAME)
|
||||
STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o version.o
|
||||
DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo version.lo
|
||||
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS)
|
||||
INSTALL_PREFIX=$(DESTDIR)
|
||||
INSTALL_BASE=/usr
|
||||
SOFLAGS = -Wl,-hlibpri.so.1.0
|
||||
libdir?=$(INSTALL_BASE)/lib
|
||||
SOFLAGS:=-Wl,-h$(DYNAMIC_LIBRARY)
|
||||
LDCONFIG = /sbin/ldconfig
|
||||
ifneq (,$(findstring X$(OSARCH)X, XLinuxX XGNU/kFreeBSDX))
|
||||
LDCONFIG_FLAGS=-n
|
||||
@@ -54,10 +62,13 @@ ifeq (${OSARCH},SunOS)
|
||||
CFLAGS += -DSOLARIS -I../zaptel-solaris
|
||||
LDCONFIG =
|
||||
LDCONFIG_FLAGS = \# # Trick to comment out the period in the command below
|
||||
SOSLINK = ln -sf libpri.so.1.0 libpri.so.1
|
||||
#INSTALL_PREFIX = /opt/asterisk # Uncomment out to install in standard Solaris location for 3rd party code
|
||||
endif
|
||||
|
||||
export PRIVERSION
|
||||
|
||||
PRIVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
|
||||
|
||||
#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
|
||||
#This works for even old (2.96) versions of gcc and provides a small boost either way.
|
||||
#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesnt support it.
|
||||
@@ -66,39 +77,47 @@ PROC=ultrasparc
|
||||
CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
|
||||
endif
|
||||
|
||||
all: depend $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
|
||||
all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
|
||||
|
||||
update:
|
||||
@if [ -d .svn ]; then \
|
||||
echo "Updating from Subversion..." ; \
|
||||
svn update -q; \
|
||||
fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
|
||||
svn update | tee update.out; \
|
||||
torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
|
||||
echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
|
||||
rm -f .version; \
|
||||
if [ `grep -c ^C update.out` -gt 0 ]; then \
|
||||
echo ; echo "The following files have conflicts:" ; \
|
||||
grep ^C update.out | cut -b4- ; \
|
||||
fi ; \
|
||||
rm -f update.out; \
|
||||
else \
|
||||
echo "Not under version control"; \
|
||||
fi
|
||||
|
||||
install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
|
||||
mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/lib
|
||||
mkdir -p $(INSTALL_PREFIX)$(libdir)
|
||||
mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/include
|
||||
ifneq (${OSARCH},SunOS)
|
||||
install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
|
||||
install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(INSTALL_BASE)/lib
|
||||
if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/$(DYNAMIC_LIBRARY); fi
|
||||
( cd $(INSTALL_PREFIX)$(INSTALL_BASE)/lib ; ln -sf libpri.so.1.0 libpri.so ; ln -sf libpri.so.1.0 libpri.so.1 )
|
||||
install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(INSTALL_BASE)/lib
|
||||
if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(INSTALL_BASE)/lib; fi
|
||||
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)
|
||||
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)$(INSTALL_BASE)/lib -m 755 $(DYNAMIC_LIBRARY)
|
||||
( cd $(INSTALL_PREFIX)$(INSTALL_BASE)/lib ; ln -sf libpri.so.1.0 libpri.so ; $(SOSLINK) )
|
||||
install -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib -m 644 $(STATIC_LIBRARY)
|
||||
install -f $(INSTALL_PREFIX)$(libdir) -m 755 $(DYNAMIC_LIBRARY)
|
||||
( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
|
||||
install -f $(INSTALL_PREFIX)$(libdir) -m 644 $(STATIC_LIBRARY)
|
||||
endif
|
||||
|
||||
uninstall:
|
||||
@echo "Removing Libpri"
|
||||
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.so.1.0
|
||||
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.so.1
|
||||
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.so
|
||||
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.a
|
||||
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so.$(SONAME)
|
||||
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so
|
||||
rm -f $(INSTALL_PREFIX)$(libdir)/libpri.a
|
||||
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include/libpri.h
|
||||
|
||||
pritest: pritest.o
|
||||
@@ -113,12 +132,13 @@ testprilib: testprilib.o
|
||||
pridump: pridump.o
|
||||
$(CC) -o pridump pridump.o -L. -lpri $(CFLAGS)
|
||||
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
endif
|
||||
MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
|
||||
|
||||
%.lo : %.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
%.lo: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
$(STATIC_LIBRARY): $(STATIC_OBJS)
|
||||
ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
|
||||
@@ -127,17 +147,23 @@ $(STATIC_LIBRARY): $(STATIC_OBJS)
|
||||
$(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
|
||||
$(CC) -shared $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
|
||||
$(LDCONFIG) $(LDCONFIG_FLAGS) .
|
||||
ln -sf libpri.so.1.0 libpri.so
|
||||
ln -sf libpri.so.1.0 libpri.so.1
|
||||
$(SOSLINK)
|
||||
ln -sf libpri.so.$(SONAME) libpri.so
|
||||
|
||||
version.c: FORCE
|
||||
@build_tools/make_version_c > $@.tmp
|
||||
@cmp -s $@.tmp $@ || mv $@.tmp $@
|
||||
@rm -f $@.tmp
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.lo *.so.1 *.so.1.0
|
||||
rm -f *.o *.so *.lo *.so.$(SONAME)
|
||||
rm -f testprilib $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
|
||||
rm -f pritest pridump
|
||||
rm -f .depend
|
||||
rm -f .*.d
|
||||
|
||||
depend: .depend
|
||||
.PHONY:
|
||||
|
||||
.depend:
|
||||
CC="$(CC)" ./mkdep ${CFLAGS} `ls *.c`
|
||||
FORCE:
|
||||
|
||||
ifneq ($(wildcard .*.d),)
|
||||
include .*.d
|
||||
endif
|
||||
|
||||
72
build_tools/make_version
Executable file
72
build_tools/make_version
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f ${1}/.version ]; then
|
||||
cat ${1}/.version
|
||||
elif [ -d .svn ]; then
|
||||
PARTS=`LANG=C svn info ${1} | ${GREP} URL | ${AWK} '{print $2;}' | sed -e 's:^.*/svn/libpri/::' | sed -e 's:/: :g'`
|
||||
BRANCH=0
|
||||
TEAM=0
|
||||
TAG=0
|
||||
|
||||
REV=`svnversion -c ${1} | cut -d: -f2`
|
||||
|
||||
BASE=`LANG=C svn pg svnmerge-integrated ${1} | cut -d: -f1`
|
||||
|
||||
if [ "${PARTS}" = "trunk" ] ; then
|
||||
echo SVN-trunk-r${REV}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for PART in $PARTS ; do
|
||||
if [ ${TAG} != 0 ] ; then
|
||||
if [ "${PART}" = "autotag_for_be" ] ; then
|
||||
continue
|
||||
fi
|
||||
if [ "${PART}" = "autotag_for_sx00i" ] ; then
|
||||
continue
|
||||
fi
|
||||
RESULT="${PART}"
|
||||
break
|
||||
fi
|
||||
|
||||
if [ ${BRANCH} != 0 ] ; then
|
||||
if [ -z ${RESULT} ] ; then
|
||||
RESULT="${PART}"
|
||||
else
|
||||
RESULT="${RESULT}-${PART}"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
|
||||
if [ ${TEAM} != 0 ] ; then
|
||||
if [ -z ${RESULT} ] ; then
|
||||
RESULT="${PART}"
|
||||
else
|
||||
RESULT="${RESULT}-${PART}"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "branches" ] ; then
|
||||
BRANCH=1
|
||||
RESULT="branch"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "tags" ] ; then
|
||||
TAG=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "team" ] ; then
|
||||
TEAM=1
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${TAG} != 0 ] ; then
|
||||
echo ${RESULT}
|
||||
else
|
||||
echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
|
||||
fi
|
||||
fi
|
||||
24
build_tools/make_version_c
Executable file
24
build_tools/make_version_c
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
if [ ! -f ../.flavor ]; then
|
||||
EXTRA=""
|
||||
else
|
||||
aadkver=`cat ../.version`
|
||||
aadkflavor=`cat ../.flavor`
|
||||
EXTRA=" (${aadkflavor} ${aadkver})"
|
||||
fi
|
||||
cat << END
|
||||
/*
|
||||
* version.c
|
||||
* Automatically generated
|
||||
*/
|
||||
|
||||
#include "libpri.h"
|
||||
|
||||
static const char pri_version[] = "${PRIVERSION}${EXTRA}";
|
||||
|
||||
const char *pri_get_version(void)
|
||||
{
|
||||
return pri_version;
|
||||
}
|
||||
|
||||
END
|
||||
19
compiler.h
19
compiler.h
@@ -4,9 +4,26 @@
|
||||
* Compiler-specific macros and other items
|
||||
*
|
||||
* Copyright (C) 2005, Digium, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _ASTERISK_COMPILER_H
|
||||
|
||||
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2005, Digium
|
||||
* Copyright (C) 2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
217
libpri.h
217
libpri.h
@@ -1,25 +1,30 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* Copyright (C) 2001, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _LIBPRI_H
|
||||
@@ -207,6 +212,52 @@
|
||||
#define PRI_LAYER_1_V120_RATE_ADAPT 0x28
|
||||
#define PRI_LAYER_1_X31_RATE_ADAPT 0x29
|
||||
|
||||
|
||||
/* Intermediate rates for V.110 */
|
||||
#define PRI_INT_RATE_8K 1
|
||||
#define PRI_INT_RATE_16K 2
|
||||
#define PRI_INT_RATE_32K 3
|
||||
|
||||
|
||||
/* Rate adaption for bottom 5 bits of rateadaption */
|
||||
#define PRI_RATE_USER_RATE_MASK 0x1F
|
||||
#define PRI_RATE_ADAPT_UNSPEC 0x00
|
||||
#define PRI_RATE_ADAPT_0K6 0x01
|
||||
#define PRI_RATE_ADAPT_1K2 0x02
|
||||
#define PRI_RATE_ADAPT_2K4 0x03
|
||||
#define PRI_RATE_ADAPT_3K6 0x04
|
||||
#define PRI_RATE_ADAPT_4K8 0x05
|
||||
#define PRI_RATE_ADAPT_7K2 0x06
|
||||
#define PRI_RATE_ADAPT_8K 0x07
|
||||
#define PRI_RATE_ADAPT_9K6 0x08
|
||||
#define PRI_RATE_ADAPT_14K4 0x09
|
||||
#define PRI_RATE_ADAPT_16K 0x0A
|
||||
#define PRI_RATE_ADAPT_19K2 0x0B
|
||||
#define PRI_RATE_ADAPT_32K 0x0C
|
||||
#define PRI_RATE_ADAPT_38K4 0x0D
|
||||
#define PRI_RATE_ADAPT_48K 0x0E
|
||||
#define PRI_RATE_ADAPT_56K 0x0F
|
||||
#define PRI_RATE_ADAPT_57K6 0x12
|
||||
#define PRI_RATE_ADAPT_28K8 0x13
|
||||
#define PRI_RATE_ADAPT_24K 0x14
|
||||
#define PRI_RATE_ADAPT_0K1345 0x15
|
||||
#define PRI_RATE_ADAPT_0K1 0x16
|
||||
#define PRI_RATE_ADAPT_0K075_1K2 0x17
|
||||
#define PRI_RATE_ADAPT_1K2_0K075 0x18
|
||||
#define PRI_RATE_ADAPT_0K05 0x19
|
||||
#define PRI_RATE_ADAPT_0K075 0x1A
|
||||
#define PRI_RATE_ADAPT_0K110 0x1B
|
||||
#define PRI_RATE_ADAPT_0K150 0x1C
|
||||
#define PRI_RATE_ADAPT_0K200 0x1D
|
||||
#define PRI_RATE_ADAPT_0K300 0x1E
|
||||
#define PRI_RATE_ADAPT_12K 0x1F
|
||||
|
||||
/* in-band negotiation flag for rateadaption bit 5 */
|
||||
#define PRI_RATE_ADAPT_NEGOTIATION_POSS 0x20
|
||||
|
||||
/* async flag for rateadaption bit 6 */
|
||||
#define PRI_RATE_ADAPT_ASYNC 0x40
|
||||
|
||||
/* Notifications */
|
||||
#define PRI_NOTIFY_USER_SUSPENDED 0x00 /* User suspended */
|
||||
#define PRI_NOTIFY_USER_RESUMED 0x01 /* User resumed */
|
||||
@@ -296,6 +347,8 @@ typedef struct pri_event_facname {
|
||||
int channel;
|
||||
int cref;
|
||||
q931_call *call;
|
||||
int callingpres; /* Presentation of Calling CallerID */
|
||||
int callingplan; /* Dialing plan of Calling entity */
|
||||
} pri_event_facname;
|
||||
|
||||
#define PRI_CALLINGPLANANI
|
||||
@@ -405,77 +458,78 @@ typedef int (*pri_io_cb)(struct pri *pri, void *buf, int buflen);
|
||||
channel operating in HDLC mode with FCS computed by the fd's driver. Also it
|
||||
must be NON-BLOCKING! Frames received on the fd should include FCS. Nodetype
|
||||
must be one of PRI_NETWORK or PRI_CPE. switchtype should be PRI_SWITCH_* */
|
||||
extern struct pri *pri_new(int fd, int nodetype, int switchtype);
|
||||
struct pri *pri_new(int fd, int nodetype, int switchtype);
|
||||
struct pri *pri_new_bri(int fd, int ptpmode, int nodetype, int switchtype);
|
||||
|
||||
/* Create D-channel just as above with user defined I/O callbacks and data */
|
||||
extern struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
|
||||
struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata);
|
||||
|
||||
/* Retrieve the user data associated with the D channel */
|
||||
extern void *pri_get_userdata(struct pri *pri);
|
||||
void *pri_get_userdata(struct pri *pri);
|
||||
|
||||
/* Set the user data associated with the D channel */
|
||||
extern void pri_set_userdata(struct pri *pri, void *userdata);
|
||||
void pri_set_userdata(struct pri *pri, void *userdata);
|
||||
|
||||
/* Set Network Specific Facility for PRI */
|
||||
extern void pri_set_nsf(struct pri *pri, int nsf);
|
||||
void pri_set_nsf(struct pri *pri, int nsf);
|
||||
|
||||
/* Set debug parameters on PRI -- see above debug definitions */
|
||||
extern void pri_set_debug(struct pri *pri, int debug);
|
||||
void pri_set_debug(struct pri *pri, int debug);
|
||||
|
||||
/* Get debug parameters on PRI -- see above debug definitions */
|
||||
extern int pri_get_debug(struct pri *pri);
|
||||
int pri_get_debug(struct pri *pri);
|
||||
|
||||
#define PRI_FACILITY_ENABLE
|
||||
/* Enable transmission support of Facility IEs on the pri */
|
||||
extern void pri_facility_enable(struct pri *pri);
|
||||
void pri_facility_enable(struct pri *pri);
|
||||
|
||||
/* Run PRI on the given D-channel, taking care of any events that
|
||||
need to be handled. If block is set, it will block until an event
|
||||
occurs which needs to be handled */
|
||||
extern pri_event *pri_dchannel_run(struct pri *pri, int block);
|
||||
pri_event *pri_dchannel_run(struct pri *pri, int block);
|
||||
|
||||
/* Check for an outstanding event on the PRI */
|
||||
pri_event *pri_check_event(struct pri *pri);
|
||||
|
||||
/* Give a name to a given event ID */
|
||||
extern char *pri_event2str(int id);
|
||||
char *pri_event2str(int id);
|
||||
|
||||
/* Give a name to a node type */
|
||||
extern char *pri_node2str(int id);
|
||||
char *pri_node2str(int id);
|
||||
|
||||
/* Give a name to a switch type */
|
||||
extern char *pri_switch2str(int id);
|
||||
char *pri_switch2str(int id);
|
||||
|
||||
/* Print an event */
|
||||
extern void pri_dump_event(struct pri *pri, pri_event *e);
|
||||
void pri_dump_event(struct pri *pri, pri_event *e);
|
||||
|
||||
/* Turn presentation into a string */
|
||||
extern char *pri_pres2str(int pres);
|
||||
char *pri_pres2str(int pres);
|
||||
|
||||
/* Turn numbering plan into a string */
|
||||
extern char *pri_plan2str(int plan);
|
||||
char *pri_plan2str(int plan);
|
||||
|
||||
/* Turn cause into a string */
|
||||
extern char *pri_cause2str(int cause);
|
||||
char *pri_cause2str(int cause);
|
||||
|
||||
/* 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 */
|
||||
extern int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info);
|
||||
int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int info);
|
||||
|
||||
/* Send a digit in overlap mode */
|
||||
extern int pri_information(struct pri *pri, q931_call *call, char digit);
|
||||
int pri_information(struct pri *pri, q931_call *call, char digit);
|
||||
|
||||
#define PRI_KEYPAD_FACILITY_TX
|
||||
/* Send a keypad facility string of digits */
|
||||
extern int pri_keypad_facility(struct pri *pri, q931_call *call, char *digits);
|
||||
int pri_keypad_facility(struct pri *pri, q931_call *call, 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 */
|
||||
extern int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
|
||||
int pri_need_more_info(struct pri *pri, q931_call *call, int channel, int nonisdn);
|
||||
|
||||
/* Answer the call on the given channel (ignored if you called acknowledge already).
|
||||
Set non-isdn to non-zero if you are not connecting to ISDN equipment */
|
||||
extern int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
|
||||
int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn);
|
||||
|
||||
/* Set CRV reference for GR-303 calls */
|
||||
|
||||
@@ -492,59 +546,60 @@ extern int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn
|
||||
|
||||
/* Hangup a call */
|
||||
#define PRI_HANGUP
|
||||
extern int pri_hangup(struct pri *pri, q931_call *call, int cause);
|
||||
int pri_hangup(struct pri *pri, q931_call *call, int cause);
|
||||
|
||||
#define PRI_DESTROYCALL
|
||||
extern void pri_destroycall(struct pri *pri, q931_call *call);
|
||||
void pri_destroycall(struct pri *pri, q931_call *call);
|
||||
|
||||
#define PRI_RESTART
|
||||
extern int pri_restart(struct pri *pri);
|
||||
int pri_restart(struct pri *pri);
|
||||
|
||||
extern int pri_reset(struct pri *pri, int channel);
|
||||
int pri_reset(struct pri *pri, int channel);
|
||||
|
||||
/* Create a new call */
|
||||
extern q931_call *pri_new_call(struct pri *pri);
|
||||
q931_call *pri_new_call(struct pri *pri);
|
||||
|
||||
/* Retrieve CRV reference for GR-303 calls. Returns >0 on success. */
|
||||
extern int pri_get_crv(struct pri *pri, q931_call *call, int *callmode);
|
||||
int pri_get_crv(struct pri *pri, q931_call *call, int *callmode);
|
||||
|
||||
/* Retrieve CRV reference for GR-303 calls. CRV must be >0, call mode should be 0 */
|
||||
extern int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode);
|
||||
int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode);
|
||||
|
||||
/* How long until you need to poll for a new event */
|
||||
extern struct timeval *pri_schedule_next(struct pri *pri);
|
||||
struct timeval *pri_schedule_next(struct pri *pri);
|
||||
|
||||
/* Run any pending schedule events */
|
||||
extern pri_event *pri_schedule_run(struct pri *pri);
|
||||
extern pri_event *pri_schedule_run_tv(struct pri *pri, const struct timeval *now);
|
||||
|
||||
extern int pri_call(struct pri *pri, q931_call *c, int transmode, int channel,
|
||||
int pri_call(struct pri *pri, q931_call *c, int transmode, int channel,
|
||||
int exclusive, int nonisdn, char *caller, int callerplan, char *callername, int callerpres,
|
||||
char *called,int calledplan, int ulayer1);
|
||||
|
||||
extern struct pri_sr *pri_sr_new(void);
|
||||
extern void pri_sr_free(struct pri_sr *sr);
|
||||
struct pri_sr *pri_sr_new(void);
|
||||
void pri_sr_free(struct pri_sr *sr);
|
||||
|
||||
extern int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
|
||||
extern int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1);
|
||||
extern int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
|
||||
extern int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
|
||||
extern int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
|
||||
int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn);
|
||||
int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1);
|
||||
int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete);
|
||||
int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres);
|
||||
int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason);
|
||||
#define PRI_USER_USER_TX
|
||||
/* Set the user user field. Warning! don't send binary data accross this field */
|
||||
extern void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
|
||||
void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
|
||||
|
||||
extern void pri_call_set_useruser(q931_call *sr, const char *userchars);
|
||||
void pri_call_set_useruser(q931_call *sr, const char *userchars);
|
||||
|
||||
extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
|
||||
int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
|
||||
|
||||
/* Set a call has a call indpendent signalling connection (i.e. no bchan) */
|
||||
extern int pri_sr_set_connection_call_independent(struct pri_sr *req);
|
||||
int pri_sr_set_connection_call_independent(struct pri_sr *req);
|
||||
|
||||
/* Send an MWI indication to a remote location. If activate is non zero, activates, if zero, decativates */
|
||||
extern int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
|
||||
int pri_mwi_activate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
|
||||
|
||||
/* Send an MWI deactivate request to a remote location */
|
||||
extern int pri_mwi_deactivate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
|
||||
int pri_mwi_deactivate(struct pri *pri, q931_call *c, char *caller, int callerplan, char *callername, int callerpres, char *called, int calledplan);
|
||||
|
||||
#define PRI_2BCT
|
||||
/* Attempt to pass the channels back to the NET side if compatable and
|
||||
@@ -553,30 +608,40 @@ int pri_channel_bridge(q931_call *call1, q931_call *call2);
|
||||
|
||||
/* Override message and error stuff */
|
||||
#define PRI_NEW_SET_API
|
||||
extern void pri_set_message(void (*__pri_error)(struct pri *pri, char *));
|
||||
extern void pri_set_error(void (*__pri_error)(struct pri *pri, char *));
|
||||
void pri_set_message(void (*__pri_error)(struct pri *pri, char *));
|
||||
void pri_set_error(void (*__pri_error)(struct pri *pri, char *));
|
||||
|
||||
/* Set overlap mode */
|
||||
#define PRI_SET_OVERLAPDIAL
|
||||
extern void pri_set_overlapdial(struct pri *pri,int state);
|
||||
void pri_set_overlapdial(struct pri *pri,int state);
|
||||
|
||||
/* QSIG logical channel mapping option, do not skip channel 16 */
|
||||
#define PRI_SET_CHAN_MAPPING_LOGICAL
|
||||
void pri_set_chan_mapping_logical(struct pri *pri, int state);
|
||||
|
||||
#define PRI_DUMP_INFO_STR
|
||||
extern char *pri_dump_info_str(struct pri *pri);
|
||||
char *pri_dump_info_str(struct pri *pri);
|
||||
|
||||
/* Get file descriptor */
|
||||
extern int pri_fd(struct pri *pri);
|
||||
int pri_fd(struct pri *pri);
|
||||
|
||||
#define PRI_PROGRESS
|
||||
/* Send call proceeding */
|
||||
extern int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
|
||||
/* Send progress */
|
||||
int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
|
||||
|
||||
/* Send progress with cause IE */
|
||||
int pri_progress_with_cause(struct pri *pri, q931_call *c, int channel, int info, int cause);
|
||||
|
||||
#define PRI_PROCEEDING_FULL
|
||||
/* Send call proceeding */
|
||||
extern int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
|
||||
int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
|
||||
|
||||
/* Enable inband progress when a DISCONNECT is received */
|
||||
void pri_set_inbanddisconnect(struct pri *pri, unsigned int enable);
|
||||
|
||||
/* Enslave a PRI to another, so they share the same call list
|
||||
(and maybe some timers) */
|
||||
extern void pri_enslave(struct pri *master, struct pri *slave);
|
||||
void pri_enslave(struct pri *master, struct pri *slave);
|
||||
|
||||
#define PRI_GR303_SUPPORT
|
||||
#define PRI_ENSLAVE_SUPPORT
|
||||
@@ -587,20 +652,22 @@ extern void pri_enslave(struct pri *master, struct pri *slave);
|
||||
#define PRI_ANI
|
||||
|
||||
/* Send notification */
|
||||
extern int pri_notify(struct pri *pri, q931_call *c, int channel, int info);
|
||||
int pri_notify(struct pri *pri, q931_call *c, int channel, int info);
|
||||
|
||||
int pri_callrerouting_facility(struct pri *pri, q931_call *call, const char *dest, const char* original, const char* reason);
|
||||
|
||||
/* Get/Set PRI Timers */
|
||||
#define PRI_GETSET_TIMERS
|
||||
extern int pri_set_timer(struct pri *pri, int timer, int value);
|
||||
extern int pri_get_timer(struct pri *pri, int timer);
|
||||
extern int pri_timer2idx(char *timer);
|
||||
int pri_set_timer(struct pri *pri, int timer, int value);
|
||||
int pri_get_timer(struct pri *pri, int timer);
|
||||
int pri_timer2idx(char *timer);
|
||||
|
||||
#define PRI_MAX_TIMERS 32
|
||||
|
||||
#define PRI_TIMER_N200 0 /* Maximum numer of q921 retransmissions */
|
||||
#define PRI_TIMER_N201 1 /* Maximum numer of octets in an information field */
|
||||
#define PRI_TIMER_N202 2 /* Maximum numer of transmissions of the TEI identity request message */
|
||||
#define PRI_TIMER_K 3 /* Maximum number of outstanding I-frames */
|
||||
#define PRI_TIMER_K 3 /* Maximum number of outstanding I-frames */
|
||||
|
||||
#define PRI_TIMER_T200 4 /* time between SABME's */
|
||||
#define PRI_TIMER_T201 5 /* minimum time between retransmissions of the TEI Identity check messages */
|
||||
@@ -628,4 +695,10 @@ extern int pri_timer2idx(char *timer);
|
||||
#define PRI_TIMER_T321 26
|
||||
#define PRI_TIMER_T322 27
|
||||
|
||||
#define PRI_TIMER_TM20 28 /* maximum time avaiting XID response */
|
||||
#define PRI_TIMER_NM20 29 /* number of XID retransmits */
|
||||
|
||||
/* Get PRI version */
|
||||
const char *pri_get_version(void);
|
||||
|
||||
#endif
|
||||
|
||||
125
mkdep
125
mkdep
@@ -1,125 +0,0 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# $OpenBSD: mkdep.gcc.sh,v 1.8 1998/09/02 06:40:07 deraadt Exp $
|
||||
# $NetBSD: mkdep.gcc.sh,v 1.9 1994/12/23 07:34:59 jtc Exp $
|
||||
#
|
||||
# Copyright (c) 1991, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the University of
|
||||
# California, Berkeley and its contributors.
|
||||
# 4. Neither the name of the University nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# @(#)mkdep.gcc.sh 8.1 (Berkeley) 6/6/93
|
||||
#
|
||||
|
||||
D=.depend # default dependency file is .depend
|
||||
append=0
|
||||
pflag=
|
||||
|
||||
while :
|
||||
do case "$1" in
|
||||
# -a appends to the depend file
|
||||
-a)
|
||||
append=1
|
||||
shift ;;
|
||||
|
||||
# -f allows you to select a makefile name
|
||||
-f)
|
||||
D=$2
|
||||
shift; shift ;;
|
||||
|
||||
# the -p flag produces "program: program.c" style dependencies
|
||||
# so .o's don't get produced
|
||||
-p)
|
||||
pflag=p
|
||||
shift ;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DTMP=/tmp/mkdep$$
|
||||
TMP=$DTMP/mkdep
|
||||
|
||||
um=`umask`
|
||||
umask 022
|
||||
if ! mkdir $DTMP ; then
|
||||
echo failed to create tmp dir $DTMP
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask $um
|
||||
trap 'rm -rf $DTMP ; trap 2 ; kill -2 $$' 1 2 3 13 15
|
||||
|
||||
if [ x$pflag = x ]; then
|
||||
${CC:-cc} -M "$@" 2>/dev/null | sed -e 's; \./; ;g' > $TMP
|
||||
else
|
||||
${CC:-cc} -M "$@" 2>/dev/null | sed -e 's;\.o :; :;' -e 's; \./; ;g' > $TMP
|
||||
fi
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: compile failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $append = 1 ]; then
|
||||
cat $TMP >> $D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: append failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
cat $TMP | sed -e 's/\.o:/.lo:/g' >>$D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: append failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
cat $TMP > $D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: overwrite failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
cat $TMP | sed -e 's/\.o:/.lo:/g' >>$D
|
||||
if [ $? != 0 ]; then
|
||||
echo 'mkdep: append failed.'
|
||||
rm -rf $DTMP
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf $DTMP
|
||||
exit 0
|
||||
208
pri.c
208
pri.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -81,7 +86,7 @@ char *pri_switch2str(int sw)
|
||||
|
||||
static void pri_default_timers(struct pri *pri, int switchtype)
|
||||
{
|
||||
int defaulttimers[20][PRI_MAX_TIMERS] = PRI_TIMERS_ALL;
|
||||
static const int defaulttimers[20][PRI_MAX_TIMERS] = PRI_TIMERS_ALL;
|
||||
int x;
|
||||
|
||||
for (x = 0; x<PRI_MAX_TIMERS; x++) {
|
||||
@@ -187,63 +192,76 @@ static int __pri_write(struct pri *pri, void *buf, int buflen)
|
||||
return res;
|
||||
}
|
||||
|
||||
static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata)
|
||||
/* Pass in the master for this function */
|
||||
void __pri_free_tei(struct pri * p)
|
||||
{
|
||||
free (p);
|
||||
}
|
||||
|
||||
struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri)
|
||||
{
|
||||
struct pri *p;
|
||||
p = malloc(sizeof(struct pri));
|
||||
if (p) {
|
||||
memset(p, 0, sizeof(struct pri));
|
||||
p->fd = fd;
|
||||
p->read_func = rd;
|
||||
p->write_func = wr;
|
||||
p->userdata = userdata;
|
||||
p->localtype = node;
|
||||
p->switchtype = switchtype;
|
||||
p->cref = 1;
|
||||
p->sapi = Q921_SAPI_CALL_CTRL;
|
||||
p->tei = 0;
|
||||
p->nsf = PRI_NSF_NONE;
|
||||
p->protodisc = Q931_PROTOCOL_DISCRIMINATOR;
|
||||
p->master = master;
|
||||
p->callpool = &p->localpool;
|
||||
pri_default_timers(p, switchtype);
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
p->q921_rxcount = 0;
|
||||
p->q921_txcount = 0;
|
||||
p->q931_rxcount = 0;
|
||||
p->q931_txcount = 0;
|
||||
#endif
|
||||
if (switchtype == PRI_SWITCH_GR303_EOC) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_EOC;
|
||||
p->tei = Q921_TEI_GR303_EOC_OPS;
|
||||
p->subchannel = __pri_new(-1, node, PRI_SWITCH_GR303_EOC_PATH, p, NULL, NULL, NULL);
|
||||
if (!p->subchannel) {
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
} else if (switchtype == PRI_SWITCH_GR303_TMC) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_TMC_CALLPROC;
|
||||
p->tei = Q921_TEI_GR303_TMC_CALLPROC;
|
||||
p->subchannel = __pri_new(-1, node, PRI_SWITCH_GR303_TMC_SWITCHING, p, NULL, NULL, NULL);
|
||||
if (!p->subchannel) {
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
} else if (switchtype == PRI_SWITCH_GR303_TMC_SWITCHING) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_TMC_SWITCHING;
|
||||
p->tei = Q921_TEI_GR303_TMC_SWITCHING;
|
||||
} else if (switchtype == PRI_SWITCH_GR303_EOC_PATH) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_EOC;
|
||||
p->tei = Q921_TEI_GR303_EOC_PATH;
|
||||
}
|
||||
/* Start Q.921 layer, Wait if we're the network */
|
||||
if (p)
|
||||
q921_start(p, p->localtype == PRI_CPE);
|
||||
|
||||
if (!(p = calloc(1, sizeof(*p))))
|
||||
return NULL;
|
||||
|
||||
p->bri = bri;
|
||||
p->fd = fd;
|
||||
p->read_func = rd;
|
||||
p->write_func = wr;
|
||||
p->userdata = userdata;
|
||||
p->localtype = node;
|
||||
p->switchtype = switchtype;
|
||||
p->cref = 1;
|
||||
p->sapi = (tei == Q921_TEI_GROUP) ? Q921_SAPI_LAYER2_MANAGEMENT : Q921_SAPI_CALL_CTRL;
|
||||
p->tei = tei;
|
||||
p->nsf = PRI_NSF_NONE;
|
||||
p->protodisc = Q931_PROTOCOL_DISCRIMINATOR;
|
||||
p->master = master;
|
||||
p->callpool = &p->localpool;
|
||||
pri_default_timers(p, switchtype);
|
||||
if (master) {
|
||||
pri_set_debug(p, master->debug);
|
||||
if (master->sendfacility)
|
||||
pri_facility_enable(p);
|
||||
}
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
p->q921_rxcount = 0;
|
||||
p->q921_txcount = 0;
|
||||
p->q931_rxcount = 0;
|
||||
p->q931_txcount = 0;
|
||||
#endif
|
||||
if (switchtype == PRI_SWITCH_GR303_EOC) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_EOC;
|
||||
p->tei = Q921_TEI_GR303_EOC_OPS;
|
||||
p->subchannel = __pri_new_tei(-1, node, PRI_SWITCH_GR303_EOC_PATH, p, NULL, NULL, NULL, Q921_TEI_GR303_EOC_PATH, 0);
|
||||
if (!p->subchannel) {
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
} else if (switchtype == PRI_SWITCH_GR303_TMC) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_TMC_CALLPROC;
|
||||
p->tei = Q921_TEI_GR303_TMC_CALLPROC;
|
||||
p->subchannel = __pri_new_tei(-1, node, PRI_SWITCH_GR303_TMC_SWITCHING, p, NULL, NULL, NULL, Q921_TEI_GR303_TMC_SWITCHING, 0);
|
||||
if (!p->subchannel) {
|
||||
free(p);
|
||||
p = NULL;
|
||||
}
|
||||
} else if (switchtype == PRI_SWITCH_GR303_TMC_SWITCHING) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_TMC_SWITCHING;
|
||||
p->tei = Q921_TEI_GR303_TMC_SWITCHING;
|
||||
} else if (switchtype == PRI_SWITCH_GR303_EOC_PATH) {
|
||||
p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
|
||||
p->sapi = Q921_SAPI_GR303_EOC;
|
||||
p->tei = Q921_TEI_GR303_EOC_PATH;
|
||||
}
|
||||
/* Start Q.921 layer, Wait if we're the network */
|
||||
if (p)
|
||||
q921_start(p, p->localtype == PRI_CPE);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -270,7 +288,15 @@ int pri_restart(struct pri *pri)
|
||||
|
||||
struct pri *pri_new(int fd, int nodetype, int switchtype)
|
||||
{
|
||||
return __pri_new(fd, nodetype, switchtype, NULL, __pri_read, __pri_write, NULL);
|
||||
return __pri_new_tei(fd, nodetype, switchtype, NULL, __pri_read, __pri_write, NULL, Q921_TEI_PRI, 0);
|
||||
}
|
||||
|
||||
struct pri *pri_new_bri(int fd, int ptpmode, int nodetype, int switchtype)
|
||||
{
|
||||
if (ptpmode)
|
||||
return __pri_new_tei(fd, nodetype, switchtype, NULL, __pri_read, __pri_write, NULL, Q921_TEI_PRI, 1);
|
||||
else
|
||||
return __pri_new_tei(fd, nodetype, switchtype, NULL, __pri_read, __pri_write, NULL, Q921_TEI_GROUP, 1);
|
||||
}
|
||||
|
||||
struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read, pri_io_cb io_write, void *userdata)
|
||||
@@ -279,7 +305,7 @@ struct pri *pri_new_cb(int fd, int nodetype, int switchtype, pri_io_cb io_read,
|
||||
io_read = __pri_read;
|
||||
if (!io_write)
|
||||
io_write = __pri_write;
|
||||
return __pri_new(fd, nodetype, switchtype, NULL, io_read, io_write, userdata);
|
||||
return __pri_new_tei(fd, nodetype, switchtype, NULL, io_read, io_write, userdata, Q921_TEI_PRI, 0);
|
||||
}
|
||||
|
||||
void *pri_get_userdata(struct pri *pri)
|
||||
@@ -457,10 +483,19 @@ int pri_proceeding(struct pri *pri, q931_call *call, int channel, int info)
|
||||
return q931_call_proceeding(pri, call, channel, info);
|
||||
}
|
||||
|
||||
int pri_progress_with_cause(struct pri *pri, q931_call *call, int channel, int info, int cause)
|
||||
{
|
||||
if (!pri || !call)
|
||||
return -1;
|
||||
|
||||
return q931_call_progress_with_cause(pri, call, channel, info, cause);
|
||||
}
|
||||
|
||||
int pri_progress(struct pri *pri, q931_call *call, int channel, int info)
|
||||
{
|
||||
if (!pri || !call)
|
||||
return -1;
|
||||
|
||||
return q931_call_progress(pri, call, channel, info);
|
||||
}
|
||||
|
||||
@@ -479,6 +514,15 @@ int pri_keypad_facility(struct pri *pri, q931_call *call, char *digits)
|
||||
return q931_keypad_facility(pri, call, digits);
|
||||
}
|
||||
|
||||
|
||||
int pri_callrerouting_facility(struct pri *pri, q931_call *call, const char *dest, const char* original, const char* reason)
|
||||
{
|
||||
if (!pri || !call)
|
||||
return -1;
|
||||
|
||||
return qsig_cf_callrerouting(pri, call, dest, original, reason);
|
||||
}
|
||||
|
||||
int pri_notify(struct pri *pri, q931_call *call, int channel, int info)
|
||||
{
|
||||
if (!pri || !call)
|
||||
@@ -556,6 +600,14 @@ int pri_channel_bridge(q931_call *call1, q931_call *call2)
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
case PRI_SWITCH_QSIG:
|
||||
call1->bridged_call = call2;
|
||||
call2->bridged_call = call1;
|
||||
if (anfpr_initiate_transfer(call1->pri, call1, call2))
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -753,6 +805,17 @@ void pri_set_overlapdial(struct pri *pri,int state)
|
||||
pri->overlapdial = state;
|
||||
}
|
||||
|
||||
void pri_set_chan_mapping_logical(struct pri *pri, int state)
|
||||
{
|
||||
if (pri->switchtype == PRI_SWITCH_QSIG)
|
||||
pri->chan_mapping_logical = state;
|
||||
}
|
||||
|
||||
void pri_set_inbanddisconnect(struct pri *pri, unsigned int enable)
|
||||
{
|
||||
pri->acceptinbanddisconnect = (enable != 0);
|
||||
}
|
||||
|
||||
int pri_fd(struct pri *pri)
|
||||
{
|
||||
return pri->fd;
|
||||
@@ -791,6 +854,7 @@ char *pri_dump_info_str(struct pri *pri)
|
||||
len += sprintf(buf + len, "Retrans: %d\n", pri->retrans);
|
||||
len += sprintf(buf + len, "Busy: %d\n", pri->busy);
|
||||
len += sprintf(buf + len, "Overlap Dial: %d\n", pri->overlapdial);
|
||||
len += sprintf(buf + len, "Logical Channel Mapping: %d\n", pri->chan_mapping_logical);
|
||||
len += sprintf(buf + len, "T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]);
|
||||
len += sprintf(buf + len, "T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]);
|
||||
len += sprintf(buf + len, "T305 Timer: %d\n", pri->timers[PRI_TIMER_T305]);
|
||||
@@ -821,7 +885,7 @@ void pri_enslave(struct pri *master, struct pri *slave)
|
||||
struct pri_sr *pri_sr_new(void)
|
||||
{
|
||||
struct pri_sr *req;
|
||||
req = malloc(sizeof(struct pri_sr));
|
||||
req = malloc(sizeof(*req));
|
||||
if (req)
|
||||
pri_sr_init(req);
|
||||
return req;
|
||||
|
||||
1010
pri_facility.c
1010
pri_facility.c
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,29 @@
|
||||
Copyright (C) Digium, Inc. 2004-2005
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _PRI_FACILITY_H
|
||||
#define _PRI_FACILITY_H
|
||||
#include "pri_q931.h"
|
||||
|
||||
/* Protocol Profile field */
|
||||
#define Q932_PROTOCOL_ROSE 0x11 /* X.219 & X.229 */
|
||||
@@ -20,7 +41,10 @@
|
||||
/* Argument values */
|
||||
#define ROSE_NAME_PRESENTATION_ALLOWED_SIMPLE 0x80
|
||||
#define ROSE_NAME_PRESENTATION_RESTRICTED_NULL 0x87
|
||||
#define ROSE_NAME_NOT_AVAIL 0x84
|
||||
#define ROSE_NAME_PRESENTATION_ALLOWED_EXTENDED 0xA1
|
||||
#define ROSE_NAME_PRESENTATION_RESTRICTED_SIMPLE 0xA2
|
||||
#define ROSE_NAME_PRESENTATION_RESTRICTED_EXTENDED 0xA3
|
||||
#define ROSE_NAME_NOT_AVAIL 0x84
|
||||
|
||||
/* Component types */
|
||||
#define COMP_TYPE_INTERPRETATION 0x8B
|
||||
@@ -32,6 +56,15 @@
|
||||
#define COMP_TYPE_NFE 0xAA
|
||||
|
||||
/* Operation ID values */
|
||||
/* Q.952.7 (ECMA-178) ROSE operations (Transfer) */
|
||||
#define ROSE_CALL_TRANSFER_IDENTIFY 7
|
||||
#define ROSE_CALL_TRANSFER_ABANDON 8
|
||||
#define ROSE_CALL_TRANSFER_INITIATE 9
|
||||
#define ROSE_CALL_TRANSFER_SETUP 10
|
||||
#define ROSE_CALL_TRANSFER_ACTIVE 11
|
||||
#define ROSE_CALL_TRANSFER_COMPLETE 12
|
||||
#define ROSE_CALL_TRANSFER_UPDATE 13
|
||||
#define ROSE_SUBADDRESS_TRANSFER 14
|
||||
/* Q.952 ROSE operations (Diverting) */
|
||||
#define ROSE_DIVERTING_LEG_INFORMATION1 18
|
||||
#define ROSE_DIVERTING_LEG_INFORMATION2 0x15
|
||||
@@ -48,6 +81,7 @@
|
||||
#define ROSE_AOC_IDENTIFICATION_OF_CHARGE 37
|
||||
/* Q.SIG operations */
|
||||
#define SS_CNID_CALLINGNAME 0
|
||||
#define SS_ANFPR_PATHREPLACEMENT 4
|
||||
#define SS_DIVERTING_LEG_INFORMATION2 21
|
||||
#define SS_MWI_ACTIVATE 80
|
||||
#define SS_MWI_DEACTIVATE 81
|
||||
@@ -146,7 +180,8 @@ struct rose_component {
|
||||
u_int8_t data[0];
|
||||
};
|
||||
|
||||
#define GET_COMPONENT(component, idx, ptr, length) \
|
||||
#if 1
|
||||
#define GET_COMPONENT(component, idx, ptr, length) \
|
||||
if ((idx)+2 > (length)) \
|
||||
break; \
|
||||
(component) = (struct rose_component*)&((ptr)[idx]); \
|
||||
@@ -154,16 +189,24 @@ struct rose_component {
|
||||
if ((component)->len != ASN1_LEN_INDEF) \
|
||||
pri_message(pri, "Length (%d) of 0x%X component is too long\n", (component)->len, (component)->type); \
|
||||
}
|
||||
/*
|
||||
pri_message("XX Got component %d (0x%02X), length %d\n", (component)->type, (component)->type, (component)->len); \
|
||||
#else /* Debugging */
|
||||
#define GET_COMPONENT(component, idx, ptr, length) \
|
||||
if ((idx)+2 > (length)) \
|
||||
break; \
|
||||
(component) = (struct rose_component*)&((ptr)[idx]); \
|
||||
if ((idx)+(component)->len+2 > (length)) { \
|
||||
if ((component)->len != 128) \
|
||||
pri_message(pri, "Length (%d) of 0x%X component is too long\n", (component)->len, (component)->type); \
|
||||
} \
|
||||
pri_message(pri, "XX %s:%d Got component %d (0x%02X), length %d\n", __FUNCTION__, __LINE__, (component)->type, (component)->type, (component)->len); \
|
||||
if ((component)->len > 0) { \
|
||||
int zzz; \
|
||||
pri_message("XX Data:"); \
|
||||
pri_message(pri, "XX Data:"); \
|
||||
for (zzz = 0; zzz < (component)->len; ++zzz) \
|
||||
pri_message(" %02X", (component)->data[zzz]); \
|
||||
pri_message("\n"); \
|
||||
pri_message(pri, " %02X", (component)->data[zzz]); \
|
||||
pri_message(pri, "\n"); \
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define NEXT_COMPONENT(component, idx) \
|
||||
(idx) += (component)->len + 2
|
||||
@@ -236,16 +279,16 @@ struct rose_component {
|
||||
} while (0)
|
||||
|
||||
/* Decoder for the invoke ROSE component */
|
||||
int rose_invoke_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
|
||||
int rose_invoke_decode(struct pri *pri, struct q931_call *call, q931_ie *ie, unsigned char *data, int len);
|
||||
|
||||
/* Decoder for the return result ROSE component */
|
||||
int rose_return_result_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
|
||||
int rose_return_result_decode(struct pri *pri, struct q931_call *call, q931_ie *ie, unsigned char *data, int len);
|
||||
|
||||
/* Decoder for the return error ROSE component */
|
||||
int rose_return_error_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
|
||||
int rose_return_error_decode(struct pri *pri, struct q931_call *call, q931_ie *ie, unsigned char *data, int len);
|
||||
|
||||
/* Decoder for the reject ROSE component */
|
||||
int rose_reject_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
|
||||
int rose_reject_decode(struct pri *pri, struct q931_call *call, q931_ie *ie, unsigned char *data, int len);
|
||||
|
||||
int asn1_copy_string(char * buf, int buflen, struct rose_component *comp);
|
||||
|
||||
@@ -266,6 +309,11 @@ int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2);
|
||||
|
||||
int rlt_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2);
|
||||
|
||||
int qsig_cf_callrerouting(struct pri *pri, q931_call *c, const char* dest, const char* original, const char* reason);
|
||||
|
||||
/* starts a QSIG Path Replacement */
|
||||
int anfpr_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2);
|
||||
|
||||
/* Use this function to queue a facility-IE born APDU onto a call
|
||||
* call is the call to use, messagetype is any one of the Q931 messages,
|
||||
* apdu is the apdu data, apdu_len is the length of the apdu data */
|
||||
|
||||
@@ -1,25 +1,30 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* Copyright (C) 2001, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _PRI_INTERNAL_H
|
||||
@@ -64,6 +69,8 @@ struct pri {
|
||||
int sapi;
|
||||
int tei;
|
||||
int protodisc;
|
||||
unsigned int bri:1;
|
||||
unsigned int acceptinbanddisconnect:1; /* Should we allow inband progress after DISCONNECT? */
|
||||
|
||||
/* Q.921 State */
|
||||
int q921_state;
|
||||
@@ -83,7 +90,11 @@ struct pri {
|
||||
|
||||
/* Various timers */
|
||||
int sabme_timer; /* SABME retransmit */
|
||||
int sabme_count; /* SABME retransmit counter for BRI */
|
||||
int t203_timer; /* Max idle time */
|
||||
int t202_timer;
|
||||
int n202_counter;
|
||||
int ri;
|
||||
int t200_timer; /* T-200 retransmission timer */
|
||||
/* All ISDN Timer values */
|
||||
int timers[MAX_TIMERS];
|
||||
@@ -103,6 +114,9 @@ struct pri {
|
||||
/* do we do overlap dialing */
|
||||
int overlapdial;
|
||||
|
||||
/* do not skip channel 16 */
|
||||
int chan_mapping_logical;
|
||||
|
||||
#ifdef LIBPRI_COUNTERS
|
||||
/* q921/q931 packet counters */
|
||||
unsigned int q921_txcount;
|
||||
@@ -247,6 +261,9 @@ struct q931_call {
|
||||
|
||||
int transferable;
|
||||
unsigned int rlt_call_id; /* RLT call id */
|
||||
|
||||
/* Bridged call info */
|
||||
q931_call *bridged_call; /* Pointer to other leg of bridged call */
|
||||
};
|
||||
|
||||
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
|
||||
@@ -263,4 +280,8 @@ extern void pri_error(struct pri *pri, char *fmt, ...);
|
||||
|
||||
void libpri_copy_string(char *dst, const char *src, size_t size);
|
||||
|
||||
struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri);
|
||||
|
||||
void __pri_free_tei(struct pri *p);
|
||||
|
||||
#endif
|
||||
|
||||
54
pri_q921.h
54
pri_q921.h
@@ -1,25 +1,30 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* Copyright (C) 2001, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _PRI_Q921_H
|
||||
@@ -46,10 +51,11 @@
|
||||
#define Q921_FRAMETYPE_I 0x0
|
||||
#define Q921_FRAMETYPE_S 0x1
|
||||
|
||||
#define Q921_TEI_GROUP 127
|
||||
#define Q921_TEI_GROUP 127
|
||||
#define Q921_TEI_PRI 0
|
||||
#define Q921_TEI_GR303_EOC_PATH 0
|
||||
#define Q921_TEI_GR303_EOC_OPS 4
|
||||
#define Q921_TEI_GR303_TMC_SWITCHING 0
|
||||
#define Q921_TEI_GR303_TMC_SWITCHING 0
|
||||
#define Q921_TEI_GR303_TMC_CALLPROC 0
|
||||
|
||||
#define Q921_SAPI_CALL_CTRL 0
|
||||
@@ -63,6 +69,14 @@
|
||||
#define Q921_SAPI_LAYER2_MANAGEMENT 63
|
||||
|
||||
|
||||
#define Q921_TEI_IDENTITY_REQUEST 1
|
||||
#define Q921_TEI_IDENTITY_ASSIGNED 2
|
||||
#define Q921_TEI_IDENTITY_DENIED 3
|
||||
#define Q921_TEI_IDENTITY_CHECK_REQUEST 4
|
||||
#define Q921_TEI_IDENTITY_CHECK_RESPONSE 5
|
||||
#define Q921_TEI_IDENTITY_REMOVE 6
|
||||
#define Q921_TEI_IDENTITY_VERIFY 7
|
||||
|
||||
typedef struct q921_header {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
u_int8_t sapi:6; /* Service Access Point Indentifier (always 0 for PRI) (0) */
|
||||
@@ -154,6 +168,12 @@ typedef struct q921_frame {
|
||||
#define Q921_INC(j) (j) = (((j) + 1) % 128)
|
||||
|
||||
typedef enum q921_state {
|
||||
Q921_DOWN = 0,
|
||||
Q921_TEI_UNASSIGNED,
|
||||
Q921_TEI_AWAITING_ESTABLISH,
|
||||
Q921_TEI_AWAITING_ASSIGN,
|
||||
Q921_TEI_ASSIGNED,
|
||||
Q921_NEGOTIATION,
|
||||
Q921_LINK_CONNECTION_RELEASED, /* Also known as TEI_ASSIGNED */
|
||||
Q921_LINK_CONNECTION_ESTABLISHED,
|
||||
Q921_AWAITING_ESTABLISH,
|
||||
|
||||
37
pri_q931.h
37
pri_q931.h
@@ -1,25 +1,30 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* Copyright (C) 2001, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _PRI_Q931_H
|
||||
@@ -251,6 +256,8 @@ extern int q931_receive(struct pri *pri, q931_h *h, int len);
|
||||
|
||||
extern int q931_alerting(struct pri *pri, q931_call *call, int channel, int info);
|
||||
|
||||
extern int q931_call_progress_with_cause(struct pri *pri, q931_call *call, int channel, int info, int cause);
|
||||
|
||||
extern int q931_call_progress(struct pri *pri, q931_call *call, int channel, int info);
|
||||
|
||||
extern int q931_notify(struct pri *pri, q931_call *call, int channel, int info);
|
||||
|
||||
84
pri_timers.h
84
pri_timers.h
@@ -1,59 +1,67 @@
|
||||
/*
|
||||
* libpri: An implementation of Primary Rate ISDN
|
||||
*
|
||||
* Written by Mark Spencer <markster@linux-support.net>
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001, Linux Support Services, Inc.
|
||||
* Copyright (C) 2001, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _PRI_TIMERS_H
|
||||
#define _PRI_TIMERS_H
|
||||
|
||||
/* -1 means we dont currently support the timer/counter */
|
||||
#define PRI_TIMERS_DEFAULT { 3, /* N200 */ \
|
||||
-1, /* N201 */ \
|
||||
-1, /* N202 */ \
|
||||
7, /* K */ \
|
||||
#define PRI_TIMERS_DEFAULT { \
|
||||
3, /* N200 */ \
|
||||
-1, /* N201 */ \
|
||||
3, /* N202 */ \
|
||||
7, /* K */ \
|
||||
1000, /* T200 */ \
|
||||
-1, /* T201 */ \
|
||||
-1, /* T202 */ \
|
||||
-1, /* T201 */ \
|
||||
10000, /* T202 */ \
|
||||
10000, /* T203 */ \
|
||||
-1, /* T300 */ \
|
||||
-1, /* T301 */ \
|
||||
-1, /* T302 */ \
|
||||
-1, /* T303 */ \
|
||||
-1, /* T304 */ \
|
||||
-1, /* T300 */ \
|
||||
-1, /* T301 */ \
|
||||
-1, /* T302 */ \
|
||||
-1, /* T303 */ \
|
||||
-1, /* T304 */ \
|
||||
30000, /* T305 */ \
|
||||
-1, /* T306 */ \
|
||||
-1, /* T307 */ \
|
||||
-1, /* T306 */ \
|
||||
-1, /* T307 */ \
|
||||
4000, /* T308 */ \
|
||||
-1, /* T309 */ \
|
||||
-1, /* T310 */ \
|
||||
-1, /* T309 */ \
|
||||
-1, /* T310 */ \
|
||||
4000, /* T313 */ \
|
||||
-1, /* T314 */ \
|
||||
-1, /* T316 */ \
|
||||
-1, /* T317 */ \
|
||||
-1, /* T318 */ \
|
||||
-1, /* T319 */ \
|
||||
-1, /* T320 */ \
|
||||
-1, /* T321 */ \
|
||||
-1 /* T322 */ \
|
||||
-1, /* T314 */ \
|
||||
-1, /* T316 */ \
|
||||
-1, /* T317 */ \
|
||||
-1, /* T318 */ \
|
||||
-1, /* T319 */ \
|
||||
-1, /* T320 */ \
|
||||
-1, /* T321 */ \
|
||||
-1, /* T322 */ \
|
||||
2500, /* TM20 - Q.921 Appendix IV */ \
|
||||
3, /* NM20 - Q.921 Appendix IV */ \
|
||||
}
|
||||
|
||||
/* XXX Only our default timers are setup now XXX */
|
||||
|
||||
33
pridump.c
33
pridump.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
38
prisched.c
38
prisched.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -35,6 +40,9 @@ int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), vo
|
||||
{
|
||||
int x;
|
||||
struct timeval tv;
|
||||
/* Scheduling runs on master channels only */
|
||||
while (pri->master)
|
||||
pri = pri->master;
|
||||
for (x=1;x<MAX_SCHED;x++)
|
||||
if (!pri->pri_sched[x].callback)
|
||||
break;
|
||||
@@ -113,6 +121,8 @@ pri_event *pri_schedule_run(struct pri *pri)
|
||||
|
||||
void pri_schedule_del(struct pri *pri,int id)
|
||||
{
|
||||
while (pri->master)
|
||||
pri = pri->master;
|
||||
if ((id >= MAX_SCHED) || (id < 0))
|
||||
pri_error(pri, "Asked to delete sched id %d???\n", id);
|
||||
pri->pri_sched[id].callback = NULL;
|
||||
|
||||
35
pritest.c
35
pritest.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -294,7 +299,7 @@ static int run_pri(int dfd, int swtype, int node)
|
||||
fd_set rfds, efds;
|
||||
int res,x;
|
||||
|
||||
pri = pri_new(dfd, node, swtype);
|
||||
pri = pri_new_bri(dfd, 1, node, swtype);
|
||||
if (!pri) {
|
||||
fprintf(stderr, "Unable to create PRI\n");
|
||||
return -1;
|
||||
|
||||
639
q921.c
639
q921.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -51,6 +56,9 @@
|
||||
} while(0)
|
||||
|
||||
static void reschedule_t203(struct pri *pri);
|
||||
static void reschedule_t200(struct pri *pri);
|
||||
static void q921_restart(struct pri *pri, int now);
|
||||
static void q921_tei_release_and_reacquire(struct pri *master);
|
||||
|
||||
static void q921_discard_retransmissions(struct pri *pri)
|
||||
{
|
||||
@@ -68,8 +76,10 @@ static void q921_discard_retransmissions(struct pri *pri)
|
||||
static int q921_transmit(struct pri *pri, q921_h *h, int len)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (pri->master)
|
||||
return q921_transmit(pri->master, h, len);
|
||||
pri = pri->master;
|
||||
|
||||
#ifdef RANDOM_DROPS
|
||||
if (!(random() % 3)) {
|
||||
pri_message(pri, " === Dropping Packet ===\n");
|
||||
@@ -88,10 +98,52 @@ static int q921_transmit(struct pri *pri, q921_h *h, int len)
|
||||
pri_error(pri, "Short write: %d/%d (%s)\n", res, len + 2, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
reschedule_t203(pri);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void q921_send_tei(struct pri *pri, int message, int ri, int ai, int iscommand)
|
||||
{
|
||||
q921_u *f;
|
||||
|
||||
if (!(f = calloc(1, sizeof(*f) + 5)))
|
||||
return;
|
||||
|
||||
Q921_INIT(pri, *f);
|
||||
f->h.c_r = (pri->localtype == PRI_NETWORK) ? iscommand : !iscommand;
|
||||
f->ft = Q921_FRAMETYPE_U;
|
||||
f->data[0] = 0x0f; /* Management entity */
|
||||
f->data[1] = (ri >> 8) & 0xff;
|
||||
f->data[2] = ri & 0xff;
|
||||
f->data[3] = message;
|
||||
f->data[4] = (ai << 1) | 1;
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "Sending TEI management message %d, TEI=%d\n", message, ai);
|
||||
q921_transmit(pri, (q921_h *)f, 8);
|
||||
free(f);
|
||||
}
|
||||
|
||||
static void q921_tei_request(void *vpri)
|
||||
{
|
||||
struct pri *pri = (struct pri *)vpri;
|
||||
|
||||
if (pri->subchannel) {
|
||||
pri_error(pri, "Cannot request TEI while its already assigned\n");
|
||||
return;
|
||||
}
|
||||
pri->n202_counter++;
|
||||
#if 0
|
||||
if (pri->n202_counter > pri->timers[PRI_TIMER_N202]) {
|
||||
pri_error(pri, "Unable to assign TEI from network\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
pri->ri = random() % 65535;
|
||||
q921_send_tei(pri, Q921_TEI_IDENTITY_REQUEST, pri->ri, Q921_TEI_GROUP, 1);
|
||||
if (pri->t202_timer)
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri->t202_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T202], q921_tei_request, pri);
|
||||
}
|
||||
|
||||
static void q921_send_ua(struct pri *pri, int pfbit)
|
||||
{
|
||||
q921_h h;
|
||||
@@ -143,6 +195,15 @@ static void q921_send_sabme(void *vpri, int now)
|
||||
pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
|
||||
return;
|
||||
}
|
||||
if (pri->bri && (pri->state == Q921_AWAITING_ESTABLISH)) {
|
||||
if (pri->sabme_count >= pri->timers[PRI_TIMER_N200]) {
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
q921_tei_release_and_reacquire(pri->master);
|
||||
} else {
|
||||
pri->sabme_count++;
|
||||
}
|
||||
}
|
||||
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
|
||||
pri_message(pri, "Sending Set Asynchronous Balanced Mode Extended\n");
|
||||
q921_transmit(pri, &h, 3);
|
||||
@@ -177,21 +238,6 @@ static int q921_ack_packet(struct pri *pri, int num)
|
||||
pri->retrans = 0;
|
||||
/* Decrement window size */
|
||||
pri->windowlen--;
|
||||
/* Search for something to send */
|
||||
f = pri->txqueue;
|
||||
while(f) {
|
||||
if (!f->transmitted) {
|
||||
/* Send it now... */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Finally transmitting %d, since window opened up\n", f->h.n_s);
|
||||
f->transmitted++;
|
||||
pri->windowlen++;
|
||||
f->h.n_r = pri->v_r;
|
||||
q921_transmit(pri, (q921_h *)(&f->h), f->len);
|
||||
break;
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
prev = f;
|
||||
@@ -204,22 +250,30 @@ static void t203_expire(void *);
|
||||
static void t200_expire(void *);
|
||||
static pri_event *q921_dchannel_down(struct pri *pri);
|
||||
|
||||
static void reschedule_t203(struct pri *pri)
|
||||
static void reschedule_t200(struct pri *pri)
|
||||
{
|
||||
if (pri->t203_timer) {
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Restarting T203 counter\n");
|
||||
/* Nothing to transmit, start the T203 counter instead */
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Restarting T200 timer\n");
|
||||
if (pri->t200_timer)
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
}
|
||||
|
||||
static pri_event *q921_ack_rx(struct pri *pri, int ack)
|
||||
static void reschedule_t203(struct pri *pri)
|
||||
{
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Restarting T203 timer\n");
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
}
|
||||
|
||||
static pri_event *q921_ack_rx(struct pri *pri, int ack, int send_untransmitted_frames)
|
||||
{
|
||||
int x;
|
||||
int cnt=0;
|
||||
pri_event *ev;
|
||||
struct q921_frame *f;
|
||||
/* Make sure the ACK was within our window */
|
||||
for (x=pri->v_a; (x != pri->v_s) && (x != ack); Q921_INC(x));
|
||||
if (x != ack) {
|
||||
@@ -239,8 +293,10 @@ static pri_event *q921_ack_rx(struct pri *pri, int ack)
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Since there was nothing left, stopping T200 counter\n");
|
||||
/* Something was ACK'd. Stop T200 counter */
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
if (pri->t200_timer) {
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
}
|
||||
if (pri->t203_timer) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
@@ -250,10 +306,27 @@ static pri_event *q921_ack_rx(struct pri *pri, int ack)
|
||||
}
|
||||
if (pri->txqueue) {
|
||||
/* Something left to transmit, Start the T200 counter again if we stopped it */
|
||||
if (!pri->busy && send_untransmitted_frames) {
|
||||
pri->retrans = 0;
|
||||
/* Search for something to send */
|
||||
f = pri->txqueue;
|
||||
while(f && (pri->windowlen < pri->window)) {
|
||||
if (!f->transmitted) {
|
||||
/* Send it now... */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Finally transmitting %d, since window opened up (%d)\n", f->h.n_s, pri->windowlen);
|
||||
f->transmitted++;
|
||||
pri->windowlen++;
|
||||
f->h.n_r = pri->v_r;
|
||||
f->h.p_f = 0;
|
||||
q921_transmit(pri, (q921_h *)(&f->h), f->len);
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue->h.n_s);
|
||||
if (!pri->t200_timer)
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
pri_message(pri, "-- Waiting for acknowledge, restarting T200 counter\n");
|
||||
reschedule_t200(pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Nothing left, starting T203 counter\n");
|
||||
@@ -323,48 +396,62 @@ static void q921_rr(struct pri *pri, int pbit, int cmd) {
|
||||
static void t200_expire(void *vpri)
|
||||
{
|
||||
struct pri *pri = vpri;
|
||||
q921_frame *f, *lastframe=NULL;
|
||||
|
||||
if (pri->txqueue) {
|
||||
/* Retransmit first packet in the queue, setting the poll bit */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- T200 counter expired, What to do...\n");
|
||||
/* Force Poll bit */
|
||||
pri->txqueue->h.p_f = 1;
|
||||
/* Update nr */
|
||||
pri->txqueue->h.n_r = pri->v_r;
|
||||
pri->v_na = pri->v_r;
|
||||
pri->solicitfbit = 1;
|
||||
pri->retrans++;
|
||||
/* Up to three retransmissions */
|
||||
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
|
||||
/* Reschedule t200_timer */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len);
|
||||
if (pri->busy)
|
||||
q921_rr(pri, 1, 1);
|
||||
else {
|
||||
if (!pri->txqueue->transmitted)
|
||||
pri_error(pri, "!! Not good - head of queue has not been transmitted yet\n");
|
||||
q921_transmit(pri, (q921_h *)&pri->txqueue->h, pri->txqueue->len);
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Rescheduling retransmission (%d)\n", pri->retrans);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "-- Timeout occured, restarting PRI\n");
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE && pri->q921_state != Q921_LINK_CONNECTION_RELEASED)
|
||||
pri_message(pri, DBGHEAD "q921_state now is Q921_LINK_CONNECTION_RELEASED\n",DBGINFO);
|
||||
pri->q921_state = Q921_LINK_CONNECTION_RELEASED;
|
||||
pri->t200_timer = 0;
|
||||
q921_dchannel_down(pri);
|
||||
q921_start(pri, 1);
|
||||
pri->schedev = 1;
|
||||
}
|
||||
} else if (pri->solicitfbit) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Retrying poll with f-bit\n");
|
||||
pri->retrans++;
|
||||
/* Up to three retransmissions */
|
||||
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
|
||||
pri->retrans++;
|
||||
/* Reschedule t200_timer */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len);
|
||||
if (pri->busy)
|
||||
q921_rr(pri, 1, 1);
|
||||
else {
|
||||
if (!pri->txqueue->transmitted)
|
||||
pri_error(pri, "!! Not good - head of queue has not been transmitted yet\n");
|
||||
/*Actually we need to retransmit the last transmitted packet, setting the poll bit */
|
||||
for (f=pri->txqueue; f; f = f->next) {
|
||||
if (f->transmitted)
|
||||
lastframe = f;
|
||||
}
|
||||
if (lastframe) {
|
||||
/* Force Poll bit */
|
||||
lastframe->h.p_f = 1;
|
||||
/* Update nr */
|
||||
lastframe->h.n_r = pri->v_r;
|
||||
pri->v_na = pri->v_r;
|
||||
q921_transmit(pri, (q921_h *)&lastframe->h, lastframe->len);
|
||||
}
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Rescheduling retransmission (%d)\n", pri->retrans);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "-- Timeout occured, restarting PRI\n");
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE && pri->q921_state != Q921_LINK_CONNECTION_RELEASED)
|
||||
pri_message(pri, DBGHEAD "q921_state now is Q921_LINK_CONNECTION_RELEASED\n",DBGINFO);
|
||||
pri->q921_state = Q921_LINK_CONNECTION_RELEASED;
|
||||
pri->t200_timer = 0;
|
||||
if (pri->bri && pri->master) {
|
||||
q921_tei_release_and_reacquire(pri->master);
|
||||
return;
|
||||
} else {
|
||||
q921_dchannel_down(pri);
|
||||
q921_start(pri, 1);
|
||||
pri->schedev = 1;
|
||||
}
|
||||
}
|
||||
} else if (pri->solicitfbit) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Retrying poll with f-bit\n");
|
||||
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
|
||||
pri->retrans++;
|
||||
pri->solicitfbit = 1;
|
||||
q921_rr(pri, 1, 1);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
@@ -375,9 +462,14 @@ static void t200_expire(void *vpri)
|
||||
pri_message(pri, DBGHEAD "q921_state now is Q921_LINK_CONNECTION_RELEASED\n", DBGINFO);
|
||||
pri->q921_state = Q921_LINK_CONNECTION_RELEASED;
|
||||
pri->t200_timer = 0;
|
||||
q921_dchannel_down(pri);
|
||||
q921_start(pri, 1);
|
||||
pri->schedev = 1;
|
||||
if (pri->bri && pri->master) {
|
||||
q921_tei_release_and_reacquire(pri->master);
|
||||
return;
|
||||
} else {
|
||||
q921_dchannel_down(pri);
|
||||
q921_start(pri, 1);
|
||||
pri->schedev = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pri_error(pri, "T200 counter expired, nothing to send...\n");
|
||||
@@ -388,10 +480,10 @@ static void t200_expire(void *vpri)
|
||||
int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)
|
||||
{
|
||||
q921_frame *f, *prev=NULL;
|
||||
|
||||
for (f=pri->txqueue; f; f = f->next) prev = f;
|
||||
f = malloc(sizeof(q921_frame) + len + 2);
|
||||
f = calloc(1, sizeof(q921_frame) + len + 2);
|
||||
if (f) {
|
||||
memset(f,0,sizeof(q921_frame) + len + 2);
|
||||
Q921_INIT(pri, f->h);
|
||||
switch(pri->localtype) {
|
||||
case PRI_NETWORK:
|
||||
@@ -440,14 +532,9 @@ int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = 0;
|
||||
}
|
||||
if (!pri->t200_timer) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "Starting T_200 timer\n");
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
} else
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "T_200 timer already going (%d)\n", pri->t200_timer);
|
||||
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "Starting T_200 timer\n");
|
||||
reschedule_t200(pri);
|
||||
} else {
|
||||
pri_error(pri, "!! Out of memory for Q.921 transmit\n");
|
||||
return -1;
|
||||
@@ -473,25 +560,26 @@ static void t203_expire(void *vpri)
|
||||
pri->t203_timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static pri_event *q921_handle_iframe(struct pri *pri, q921_i *i, int len)
|
||||
{
|
||||
int res;
|
||||
pri_event *ev;
|
||||
|
||||
pri->solicitfbit = 0;
|
||||
/* Make sure this is a valid packet */
|
||||
if (i->n_s == pri->v_r) {
|
||||
/* Increment next expected I-frame */
|
||||
Q921_INC(pri->v_r);
|
||||
/* Handle their ACK */
|
||||
pri->sentrej = 0;
|
||||
ev = q921_ack_rx(pri, i->n_r);
|
||||
ev = q921_ack_rx(pri, i->n_r, 0);
|
||||
if (ev)
|
||||
return ev;
|
||||
if (i->p_f) {
|
||||
/* If the Poll/Final bit is set, immediate send the RR */
|
||||
q921_rr(pri, 1, 0);
|
||||
} else if (pri->busy) {
|
||||
q921_rr(pri, 0, 0);
|
||||
} else if (pri->busy || pri->retrans) {
|
||||
q921_rr(pri, 0, 0);
|
||||
}
|
||||
/* Receive Q.931 data */
|
||||
res = q931_receive(pri, (q931_h *)i->data, len - 4);
|
||||
@@ -555,6 +643,7 @@ void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
|
||||
direction_tag,
|
||||
h->h.tei,
|
||||
h->h.ea2);
|
||||
|
||||
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
|
||||
case 0:
|
||||
case 2:
|
||||
@@ -645,6 +734,44 @@ void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
|
||||
len - 3);
|
||||
break;
|
||||
};
|
||||
|
||||
if ((h->u.ft == 3) && (h->u.m3 == 0) && (h->u.m2 == 0) && (h->u.data[0] == 0x0f)) {
|
||||
int ri;
|
||||
int tei;
|
||||
|
||||
ri = (h->u.data[1] << 8) | h->u.data[2];
|
||||
tei = (h->u.data[4] >> 1);
|
||||
/* TEI assignment related */
|
||||
switch (h->u.data[3]) {
|
||||
case Q921_TEI_IDENTITY_REQUEST:
|
||||
type = "TEI Identity Request";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_ASSIGNED:
|
||||
type = "TEI Identity Assigned";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_CHECK_REQUEST:
|
||||
type = "TEI Identity Check Request";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_REMOVE:
|
||||
type = "TEI Identity Remove";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_DENIED:
|
||||
type = "TEI Identity Denied";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_CHECK_RESPONSE:
|
||||
type = "TEI Identity Check Response";
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_VERIFY:
|
||||
type = "TEI Identity Verify";
|
||||
break;
|
||||
default:
|
||||
type = "Unknown";
|
||||
break;
|
||||
}
|
||||
pri_message(pri, "%c MDL Message: %s (%d)\n", direction_tag, type, h->u.data[3]);
|
||||
pri_message(pri, "%c RI: %d\n", direction_tag, ri);
|
||||
pri_message(pri, "%c Ai: %d E:%d\n", direction_tag, (h->u.data[4] >> 1) & 0x7f, h->u.data[4] & 1);
|
||||
}
|
||||
}
|
||||
|
||||
static pri_event *q921_dchannel_up(struct pri *pri)
|
||||
@@ -653,8 +780,10 @@ static pri_event *q921_dchannel_up(struct pri *pri)
|
||||
q921_reset(pri);
|
||||
|
||||
/* Stop any SABME retransmissions */
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
if (pri->sabme_timer) {
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
}
|
||||
|
||||
/* Reset any rejects */
|
||||
pri->sentrej = 0;
|
||||
@@ -697,10 +826,14 @@ void q921_reset(struct pri *pri)
|
||||
pri->v_na = 0;
|
||||
pri->window = pri->timers[PRI_TIMER_K];
|
||||
pri->windowlen = 0;
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
if (pri->sabme_timer)
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
if (pri->t200_timer)
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->sabme_timer = 0;
|
||||
pri->sabme_count = 0;
|
||||
pri->t203_timer = 0;
|
||||
pri->t200_timer = 0;
|
||||
pri->busy = 0;
|
||||
@@ -715,6 +848,113 @@ void q921_reset(struct pri *pri)
|
||||
q921_discard_retransmissions(pri);
|
||||
}
|
||||
|
||||
static void q921_tei_release_and_reacquire(struct pri *master)
|
||||
{
|
||||
/* Make sure the master is passed into this function */
|
||||
q921_dchannel_down(master->subchannel);
|
||||
__pri_free_tei(master->subchannel);
|
||||
master->subchannel = NULL;
|
||||
master->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
|
||||
master->schedev = 1;
|
||||
q921_start(master, master->localtype == PRI_CPE);
|
||||
}
|
||||
|
||||
static pri_event *q921_receive_MDL(struct pri *pri, q921_u *h, int len)
|
||||
{
|
||||
int ri;
|
||||
struct pri *sub;
|
||||
int tei;
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "Received MDL message\n");
|
||||
if (h->data[0] != 0x0f) {
|
||||
pri_error(pri, "Received MDL with unsupported management entity %02x\n", h->data[0]);
|
||||
return NULL;
|
||||
}
|
||||
if (!(h->data[4] & 0x01)) {
|
||||
pri_error(pri, "Received MDL with multibyte TEI identifier\n");
|
||||
return NULL;
|
||||
}
|
||||
ri = (h->data[1] << 8) | h->data[2];
|
||||
tei = (h->data[4] >> 1);
|
||||
switch(h->data[3]) {
|
||||
case Q921_TEI_IDENTITY_REQUEST:
|
||||
if (tei != 127) {
|
||||
pri_error(pri, "Received TEI identity request with invalid TEI %d\n", tei);
|
||||
q921_send_tei(pri, Q921_TEI_IDENTITY_DENIED, ri, tei, 1);
|
||||
}
|
||||
/* Go to master */
|
||||
for (sub = pri; sub->master; sub = sub->master);
|
||||
tei = 64;
|
||||
while(sub->subchannel) {
|
||||
if(sub->subchannel->tei == tei)
|
||||
++tei;
|
||||
}
|
||||
sub->subchannel = __pri_new_tei(-1, pri->localtype, pri->switchtype, pri, NULL, NULL, NULL, tei, 1);
|
||||
if (!sub->subchannel) {
|
||||
pri_error(pri, "Unable to allocate D-channel for new TEI %d\n", tei);
|
||||
return NULL;
|
||||
}
|
||||
q921_send_tei(pri, Q921_TEI_IDENTITY_ASSIGNED, ri, tei, 1);
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_ASSIGNED:
|
||||
if (ri != pri->ri) {
|
||||
pri_message(pri, "TEI assignment received for invalid Ri %02x (our is %02x)\n", ri, pri->ri);
|
||||
return NULL;
|
||||
}
|
||||
if (pri->t202_timer) {
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri->t202_timer = 0;
|
||||
}
|
||||
if (pri->subchannel && (pri->subchannel->tei == tei)) {
|
||||
pri_error(pri, "TEI already assigned (new is %d, current is %d)\n", tei, pri->subchannel->tei);
|
||||
q921_tei_release_and_reacquire(pri);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pri_message(pri, "TEI assiged to %d\n", tei);
|
||||
pri->subchannel = __pri_new_tei(-1, pri->localtype, pri->switchtype, pri, NULL, NULL, NULL, tei, 1);
|
||||
if (!pri->subchannel) {
|
||||
pri_error(pri, "Unable to allocate D-channel for new TEI %d\n", tei);
|
||||
return NULL;
|
||||
}
|
||||
pri->q921_state = Q921_TEI_ASSIGNED;
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_CHECK_REQUEST:
|
||||
/* We're assuming one TEI per PRI in TE PTMP mode */
|
||||
|
||||
/* If no subchannel (TEI) ignore */
|
||||
if (!pri->subchannel)
|
||||
return NULL;
|
||||
|
||||
/* If it's addressed to the group TEI or to our TEI specifically, we respond */
|
||||
if ((tei == Q921_TEI_GROUP) || (tei == pri->subchannel->tei))
|
||||
q921_send_tei(pri, Q921_TEI_IDENTITY_CHECK_RESPONSE, random() % 65535, pri->subchannel->tei, 1);
|
||||
|
||||
break;
|
||||
case Q921_TEI_IDENTITY_REMOVE:
|
||||
/* XXX: Assuming multiframe mode has been disconnected already */
|
||||
if (!pri->subchannel)
|
||||
return NULL;
|
||||
|
||||
if ((tei == Q921_TEI_GROUP) || (tei == pri->subchannel->tei)) {
|
||||
q921_tei_release_and_reacquire(pri);
|
||||
}
|
||||
}
|
||||
return NULL; /* Do we need to return something??? */
|
||||
}
|
||||
|
||||
static int is_command(struct pri *pri, q921_h *h)
|
||||
{
|
||||
int command =0;
|
||||
int c_r = h->s.h.c_r;
|
||||
|
||||
if ((pri->localtype == PRI_NETWORK && c_r == 0) ||
|
||||
(pri->localtype == PRI_CPE && c_r == 1))
|
||||
command = 1;
|
||||
|
||||
return( command );
|
||||
}
|
||||
|
||||
static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
{
|
||||
q921_frame *f;
|
||||
@@ -749,75 +989,99 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
/* Receiver Ready */
|
||||
pri->busy = 0;
|
||||
/* Acknowledge frames as necessary */
|
||||
ev = q921_ack_rx(pri, h->s.n_r);
|
||||
ev = q921_ack_rx(pri, h->s.n_r, 1);
|
||||
if (ev)
|
||||
return ev;
|
||||
if (is_command(pri, h))
|
||||
pri->solicitfbit = 0;
|
||||
if (h->s.p_f) {
|
||||
/* If it's a p/f one then send back a RR in return with the p/f bit set */
|
||||
if (pri->solicitfbit) {
|
||||
if (!is_command(pri, h)) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Got RR response to our frame\n");
|
||||
pri->retrans = 0;
|
||||
} else {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Unsolicited RR with P/F bit, responding\n");
|
||||
q921_rr(pri, 1, 0);
|
||||
}
|
||||
pri->solicitfbit = 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Receiver not ready */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Got receiver not ready\n");
|
||||
if(h->s.p_f) {
|
||||
/* Send RR if poll bit set */
|
||||
q921_rr(pri, h->s.p_f, 0);
|
||||
}
|
||||
pri->busy = 1;
|
||||
break;
|
||||
case 2:
|
||||
/* Just retransmit */
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Got reject requesting packet %d... Retransmitting.\n", h->s.n_r);
|
||||
if (h->s.p_f) {
|
||||
/* If it has the poll bit set, send an appropriate supervisory response */
|
||||
q921_rr(pri, 1, 0);
|
||||
}
|
||||
sendnow = 0;
|
||||
/* Resend the proper I-frame */
|
||||
for(f=pri->txqueue;f;f=f->next) {
|
||||
if ((sendnow || (f->h.n_s == h->s.n_r)) && f->transmitted) {
|
||||
/* Matches the request, or follows in our window, and has
|
||||
already been transmitted. */
|
||||
sendnow = 1;
|
||||
pri_error(pri, "!! Got reject for frame %d, retransmitting frame %d now, updating n_r!\n", h->s.n_r, f->h.n_s);
|
||||
f->h.n_r = pri->v_r;
|
||||
q921_transmit(pri, (q921_h *)(&f->h), f->len);
|
||||
}
|
||||
}
|
||||
if (!sendnow) {
|
||||
if (pri->txqueue) {
|
||||
/* This should never happen */
|
||||
if (!h->s.p_f || h->s.n_r) {
|
||||
pri_error(pri, "!! Got reject for frame %d, but we only have others!\n", h->s.n_r);
|
||||
}
|
||||
} else {
|
||||
/* Hrm, we have nothing to send, but have been REJ'd. Reset v_a, v_s, etc */
|
||||
pri_error(pri, "!! Got reject for frame %d, but we have nothing -- resetting!\n", h->s.n_r);
|
||||
pri->v_a = h->s.n_r;
|
||||
pri->v_s = h->s.n_r;
|
||||
/* Reset t200 timer if it was somehow going */
|
||||
if (pri->t200_timer) {
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
/* Reset and restart t203 timer */
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Receiver not ready */
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "-- Got receiver not ready\n");
|
||||
pri->busy = 1;
|
||||
ev = q921_ack_rx(pri, h->s.n_r, 0);
|
||||
if (ev)
|
||||
return ev;
|
||||
if (h->s.p_f && is_command(pri, h))
|
||||
q921_rr(pri, 1, 0);
|
||||
pri->solicitfbit = 1;
|
||||
pri->retrans = 0;
|
||||
if (pri->t203_timer) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "Stopping T_203 timer\n");
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = 0;
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "Restarting T_200 timer\n");
|
||||
reschedule_t200(pri);
|
||||
break;
|
||||
case 2:
|
||||
/* Just retransmit */
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_message(pri, "-- Got reject requesting packet %d... Retransmitting.\n", h->s.n_r);
|
||||
if (pri->busy && !is_command(pri, h))
|
||||
pri->solicitfbit = 0;
|
||||
pri->busy = 0;
|
||||
if (is_command(pri, h) && h->s.p_f)
|
||||
q921_rr(pri, 1, 0);
|
||||
q921_ack_rx(pri, h->s.n_r, 0);
|
||||
/*Resend only if we are in the Multiple Frame Established state or when
|
||||
we are in the Time Recovery state and received responce with bit F=1*/
|
||||
if ((pri->solicitfbit == 0) || (pri->solicitfbit && !is_command(pri, h) && h->s.p_f)) {
|
||||
pri->solicitfbit = 0;
|
||||
pri->retrans = 0;
|
||||
sendnow = 0;
|
||||
/* Resend I-frames starting from frame where f->h.n_s == h->s.n_r */
|
||||
for (f = pri->txqueue; f && (f->h.n_s != h->s.n_r); f = f->next);
|
||||
while (f) {
|
||||
sendnow = 1;
|
||||
if (f->transmitted || (!f->transmitted && (pri->windowlen < pri->window))) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_STATE)
|
||||
pri_error(pri, "!! Got reject for frame %d, retransmitting frame %d now, updating n_r!\n", h->s.n_r, f->h.n_s);
|
||||
f->h.n_r = pri->v_r;
|
||||
f->h.p_f = 0;
|
||||
if (!f->transmitted && (pri->windowlen < pri->window))
|
||||
pri->windowlen++;
|
||||
q921_transmit(pri, (q921_h *)(&f->h), f->len);
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
if (!sendnow) {
|
||||
if (pri->txqueue) {
|
||||
/* This should never happen */
|
||||
if (!h->s.p_f || h->s.n_r) {
|
||||
pri_error(pri, "!! Got reject for frame %d, but we only have others!\n", h->s.n_r);
|
||||
}
|
||||
} else {
|
||||
/* Hrm, we have nothing to send, but have been REJ'd. Reset v_a, v_s, etc */
|
||||
pri_error(pri, "!! Got reject for frame %d, but we have nothing -- resetting!\n", h->s.n_r);
|
||||
pri->v_a = h->s.n_r;
|
||||
pri->v_s = h->s.n_r;
|
||||
}
|
||||
}
|
||||
/* Reset t200 timer if it was somehow going */
|
||||
if (pri->t200_timer) {
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
/* Reset and restart t203 timer */
|
||||
reschedule_t203(pri);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pri_error(pri, "!! XXX Unknown Supervisory frame ss=0x%02x,pf=%02xnr=%02x vs=%02x, va=%02x XXX\n", h->s.ss, h->s.p_f, h->s.n_r,
|
||||
pri->v_s, pri->v_a);
|
||||
@@ -838,7 +1102,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
pri_message(pri, "-- Got DM Mode from peer.\n");
|
||||
/* Disconnected mode, try again after T200 */
|
||||
ev = q921_dchannel_down(pri);
|
||||
q921_start(pri, 0);
|
||||
q921_restart(pri, 0);
|
||||
return ev;
|
||||
|
||||
} else {
|
||||
@@ -846,12 +1110,23 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
|
||||
#if 0
|
||||
/* Requesting that we start */
|
||||
q921_start(pri, 0);
|
||||
q921_restart(pri, 0);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
} else if (!h->u.m2) {
|
||||
pri_message(pri, "XXX Unnumbered Information not implemented XXX\n");
|
||||
if ((pri->sapi == Q921_SAPI_LAYER2_MANAGEMENT) && (pri->tei == Q921_TEI_GROUP))
|
||||
q921_receive_MDL(pri, (q921_u *)h, len);
|
||||
else {
|
||||
int res;
|
||||
|
||||
res = q931_receive(pri, (q931_h *) h->u.data, len - 3);
|
||||
if (res == -1) {
|
||||
return NULL;
|
||||
}
|
||||
if (res & Q931_RES_HAVEEVENT)
|
||||
return &pri->ev;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@@ -860,7 +1135,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
/* Acknowledge */
|
||||
q921_send_ua(pri, h->u.p_f);
|
||||
ev = q921_dchannel_down(pri);
|
||||
q921_start(pri, 0);
|
||||
q921_restart(pri, 0);
|
||||
return ev;
|
||||
case 3:
|
||||
if (h->u.m2 == 3) {
|
||||
@@ -891,8 +1166,17 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
pri_message(pri, "-- Got UA from %s peer Link up.\n", h->h.c_r ? "cpe" : "network");
|
||||
}
|
||||
return q921_dchannel_up(pri);
|
||||
} else
|
||||
} else if ((pri->q921_state >= Q921_TEI_ASSIGNED) && pri->bri) {
|
||||
/* Possible duplicate TEI assignment */
|
||||
if (pri->master)
|
||||
q921_tei_release_and_reacquire(pri->master);
|
||||
else
|
||||
pri_error(pri, "Huh!? no master found\n");
|
||||
} else {
|
||||
/* Since we're not in the AWAITING_ESTABLISH STATE, it's unsolicited */
|
||||
pri_error(pri, "!! Got a UA, but i'm in state %d\n", pri->q921_state);
|
||||
|
||||
}
|
||||
} else
|
||||
pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
|
||||
break;
|
||||
@@ -924,21 +1208,24 @@ static pri_event *__q921_receive(struct pri *pri, q921_h *h, int len)
|
||||
if (h->h.ea1 || !(h->h.ea2))
|
||||
return NULL;
|
||||
|
||||
#if 0 /* Will be rejected by subchannel analyzis */
|
||||
/* Check for broadcasts - not yet handled */
|
||||
if (h->h.tei == Q921_TEI_GROUP)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
/* Check for SAPIs we don't yet handle */
|
||||
if ((h->h.sapi != pri->sapi) || (h->h.tei != pri->tei)) {
|
||||
#ifdef PROCESS_SUBCHANNELS
|
||||
if (!((h->h.sapi == pri->sapi) && ((h->h.tei == pri->tei) || (h->h.tei == Q921_TEI_GROUP)))) {
|
||||
/* Check for SAPIs we don't yet handle */
|
||||
/* If it's not us, try any subchannels we have */
|
||||
if (pri->subchannel)
|
||||
return q921_receive(pri->subchannel, h, len + 2);
|
||||
else
|
||||
#endif
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "Handling message for SAPI/TEI=%d/%d\n", h->h.sapi, h->h.tei);
|
||||
ev = __q921_receive_qualified(pri, h, len);
|
||||
reschedule_t203(pri);
|
||||
return ev;
|
||||
@@ -954,7 +1241,7 @@ pri_event *q921_receive(struct pri *pri, q921_h *h, int len)
|
||||
return e;
|
||||
}
|
||||
|
||||
void q921_start(struct pri *pri, int now)
|
||||
static void q921_restart(struct pri *pri, int now)
|
||||
{
|
||||
if (pri->q921_state != Q921_LINK_CONNECTION_RELEASED) {
|
||||
pri_error(pri, "!! q921_start: Not in 'Link Connection Released' state\n");
|
||||
@@ -965,3 +1252,15 @@ void q921_start(struct pri *pri, int now)
|
||||
/* Do the SABME XXX Maybe we should implement T_WAIT? XXX */
|
||||
q921_send_sabme(pri, now);
|
||||
}
|
||||
|
||||
void q921_start(struct pri *pri, int isCPE)
|
||||
{
|
||||
q921_reset(pri);
|
||||
if ((pri->sapi == Q921_SAPI_LAYER2_MANAGEMENT) && (pri->tei == Q921_TEI_GROUP)) {
|
||||
pri->q921_state = Q921_DOWN;
|
||||
if (isCPE)
|
||||
q921_tei_request(pri);
|
||||
} else {
|
||||
q921_send_sabme(pri, isCPE);
|
||||
}
|
||||
}
|
||||
|
||||
495
q931.c
495
q931.c
@@ -3,23 +3,28 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include "compat.h"
|
||||
@@ -255,18 +260,10 @@ static char *code2str(int code, struct msgtype *codes, int max)
|
||||
|
||||
static void call_init(struct q931_call *c)
|
||||
{
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->alive = 0;
|
||||
c->sendhangupack = 0;
|
||||
c->forceinvert = -1;
|
||||
c->cr = -1;
|
||||
c->slotmap = -1;
|
||||
c->channelno = -1;
|
||||
c->ds1no = 0;
|
||||
c->ds1explicit = 0;
|
||||
c->chanflags = 0;
|
||||
c->next = NULL;
|
||||
c->sentchannel = 0;
|
||||
c->newcall = 1;
|
||||
c->ourcallstate = Q931_CALL_STATE_NULL;
|
||||
c->peercallstate = Q931_CALL_STATE_NULL;
|
||||
@@ -294,15 +291,22 @@ static FUNC_RECV(receive_channel_id)
|
||||
}
|
||||
#endif
|
||||
#ifndef NOAUTO_CHANNEL_SELECTION_SUPPORT
|
||||
switch (ie->data[0] & 3) {
|
||||
case 0:
|
||||
if (pri->bri) {
|
||||
if (!(ie->data[0] & 3))
|
||||
call->justsignalling = 1;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
pri_error(pri, "!! Unexpected Channel selection %d\n", ie->data[0] & 3);
|
||||
return -1;
|
||||
else
|
||||
call->channelno = ie->data[0] & 3;
|
||||
} else {
|
||||
switch (ie->data[0] & 3) {
|
||||
case 0:
|
||||
call->justsignalling = 1;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
pri_error(pri, "!! Unexpected Channel selection %d\n", ie->data[0] & 3);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ie->data[0] & 0x08)
|
||||
@@ -341,6 +345,8 @@ static FUNC_RECV(receive_channel_id)
|
||||
pos++;
|
||||
/* Only expect a particular channel */
|
||||
call->channelno = ie->data[pos] & 0x7f;
|
||||
if (pri->chan_mapping_logical && call->channelno > 15)
|
||||
call->channelno++;
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
@@ -366,7 +372,11 @@ static FUNC_SEND(transmit_channel_id)
|
||||
/* Start with standard stuff */
|
||||
if (pri->switchtype == PRI_SWITCH_GR303_TMC)
|
||||
ie->data[pos] = 0x69;
|
||||
else
|
||||
else if (pri->bri) {
|
||||
ie->data[pos] = 0x80;
|
||||
if (call->channelno > -1)
|
||||
ie->data[pos] |= (call->channelno & 0x3);
|
||||
} else
|
||||
ie->data[pos] = 0xa1;
|
||||
/* Add exclusive flag if necessary */
|
||||
if (call->chanflags & FLAG_EXCLUSIVE)
|
||||
@@ -383,12 +393,19 @@ static FUNC_SEND(transmit_channel_id)
|
||||
ie->data[pos++] = 0x80 | call->ds1no;
|
||||
} else
|
||||
pos++;
|
||||
|
||||
if (pri->bri)
|
||||
return pos + 2;
|
||||
|
||||
if ((call->channelno > -1) || (call->slotmap != -1)) {
|
||||
/* We'll have the octet 8.2 and 8.3's present */
|
||||
ie->data[pos++] = 0x83;
|
||||
if (call->channelno > -1) {
|
||||
/* Channel number specified */
|
||||
ie->data[pos++] = 0x80 | call->channelno;
|
||||
if (pri->chan_mapping_logical && call->channelno > 16)
|
||||
ie->data[pos++] = 0x80 | (call->channelno - 1);
|
||||
else
|
||||
ie->data[pos++] = 0x80 | call->channelno;
|
||||
return pos + 2;
|
||||
}
|
||||
/* We have to send a channel map */
|
||||
@@ -414,7 +431,7 @@ static FUNC_DUMP(dump_channel_id)
|
||||
int x;
|
||||
int res = 0;
|
||||
static const char* msg_chan_sel[] = {
|
||||
"No channel selected", "B1 channel", "B2 channel","Any channel selected"
|
||||
"No channel selected", "B1 channel", "B2 channel","Any channel selected",
|
||||
"No channel selected", "As indicated in following octets", "Reserved","Any channel selected"
|
||||
};
|
||||
|
||||
@@ -543,12 +560,12 @@ static char *mode2str(int mode)
|
||||
static char *l12str(int proto)
|
||||
{
|
||||
static struct msgtype protos[] = {
|
||||
{ PRI_LAYER_1_ITU_RATE_ADAPT, "ITU Rate Adaption" },
|
||||
{ PRI_LAYER_1_ITU_RATE_ADAPT, "V.110 Rate Adaption" },
|
||||
{ PRI_LAYER_1_ULAW, "u-Law" },
|
||||
{ PRI_LAYER_1_ALAW, "A-Law" },
|
||||
{ PRI_LAYER_1_G721, "G.721 ADPCM" },
|
||||
{ PRI_LAYER_1_G722_G725, "G.722/G.725 7kHz Audio" },
|
||||
{ PRI_LAYER_1_H223_H245, "H.223 and H.245" }, /* Recommendation Q.931(05/98) page 60) */
|
||||
{ PRI_LAYER_1_H223_H245, "H.223/H.245 Multimedia" },
|
||||
{ PRI_LAYER_1_NON_ITU_ADAPT, "Non-ITU Rate Adaption" },
|
||||
{ PRI_LAYER_1_V120_RATE_ADAPT, "V.120 Rate Adaption" },
|
||||
{ PRI_LAYER_1_X31_RATE_ADAPT, "X.31 Rate Adaption" },
|
||||
@@ -559,7 +576,7 @@ static char *l12str(int proto)
|
||||
static char *ra2str(int proto)
|
||||
{
|
||||
static struct msgtype protos[] = {
|
||||
{ RATE_ADAPT_56K, "from 56kbps" },
|
||||
{ PRI_RATE_ADAPT_9K6, "9.6 kbit/s" },
|
||||
};
|
||||
return code2str(proto, protos, sizeof(protos) / sizeof(protos[0]));
|
||||
}
|
||||
@@ -580,31 +597,143 @@ static char *l32str(int proto)
|
||||
return code2str(proto, protos, sizeof(protos) / sizeof(protos[0]));
|
||||
}
|
||||
|
||||
static char *int_rate2str(int proto)
|
||||
{
|
||||
static struct msgtype protos[] = {
|
||||
{ PRI_INT_RATE_8K, "8 kbit/s" },
|
||||
{ PRI_INT_RATE_16K, "16 kbit/s" },
|
||||
{ PRI_INT_RATE_32K, "32 kbit/s" },
|
||||
};
|
||||
return code2str(proto, protos, sizeof(protos) / sizeof(protos[0]));
|
||||
}
|
||||
|
||||
static FUNC_DUMP(dump_bearer_capability)
|
||||
{
|
||||
int pos=2;
|
||||
pri_message(pri, "%c Bearer Capability (len=%2d) [ Ext: %d Q.931 Std: %d Info transfer capability: %s (%d)\n",
|
||||
prefix, len, (ie->data[0] & 0x80 ) >> 7, (ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f), (ie->data[0] & 0x1f));
|
||||
pri_message(pri, "%c Ext: %d Trans mode/rate: %s (%d)\n", prefix, (ie->data[1] & 0x80) >> 7, mode2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
|
||||
|
||||
/* octet 4.1 exists iff mode/rate is multirate */
|
||||
if ((ie->data[1] & 0x7f) == 0x18) {
|
||||
pri_message(pri, "%c Ext: %d Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
|
||||
pos++;
|
||||
}
|
||||
/* Stop here if no more */
|
||||
if (pos >= len)
|
||||
return;
|
||||
if ((ie->data[1] & 0x7f) != TRANS_MODE_PACKET) {
|
||||
/* Look for octets 5 and 5.a if present */
|
||||
pri_message(pri, "%c Ext: %d User information layer 1: %s (%d)\n", prefix, (ie->data[pos] >> 7), l12str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
|
||||
if ((ie->data[pos] & 0x7f) == PRI_LAYER_1_ITU_RATE_ADAPT)
|
||||
pri_message(pri, "%c Ext: %d Rate adaptatation: %s (%d)\n", prefix, ie->data[pos] >> 7, ra2str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
|
||||
|
||||
/* don't count the IE num and length as part of the data */
|
||||
len -= 2;
|
||||
|
||||
/* Look for octet 5; this is identified by bits 5,6 == 01 */
|
||||
if (pos < len &&
|
||||
(ie->data[pos] & 0x60) == 0x20) {
|
||||
|
||||
/* although the layer1 is only the bottom 5 bits of the byte,
|
||||
previous versions of this library passed bits 5&6 through
|
||||
too, so we have to do the same for binary compatability */
|
||||
u_int8_t layer1 = ie->data[pos] & 0x7f;
|
||||
|
||||
pri_message(pri, "%c User information layer 1: %s (%d)\n",
|
||||
prefix, l12str(layer1), layer1);
|
||||
pos++;
|
||||
} else {
|
||||
/* Look for octets 6 and 7 but not 5 and 5.a */
|
||||
pri_message(pri, "%c Ext: %d User information layer 2: %s (%d)\n", prefix, ie->data[pos] >> 7, l22str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
|
||||
|
||||
/* octet 5a? */
|
||||
if (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
int ra = ie->data[pos] & 0x7f;
|
||||
|
||||
pri_message(pri, "%c Async: %d, Negotiation: %d, "
|
||||
"User rate: %s (%#x)\n",
|
||||
prefix,
|
||||
ra & PRI_RATE_ADAPT_ASYNC ? 1 : 0,
|
||||
ra & PRI_RATE_ADAPT_NEGOTIATION_POSS ? 1 : 0,
|
||||
ra2str(ra & PRI_RATE_USER_RATE_MASK),
|
||||
ra & PRI_RATE_USER_RATE_MASK);
|
||||
pos++;
|
||||
}
|
||||
|
||||
/* octet 5b? */
|
||||
if (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
u_int8_t data = ie->data[pos];
|
||||
if (layer1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
|
||||
pri_message(pri, "%c Intermediate rate: %s (%d), "
|
||||
"NIC on Tx: %d, NIC on Rx: %d, "
|
||||
"Flow control on Tx: %d, "
|
||||
"Flow control on Rx: %d\n",
|
||||
prefix, int_rate2str((data & 0x60)>>5),
|
||||
(data & 0x60)>>5,
|
||||
(data & 0x10)?1:0,
|
||||
(data & 0x08)?1:0,
|
||||
(data & 0x04)?1:0,
|
||||
(data & 0x02)?1:0);
|
||||
} else if (layer1 == PRI_LAYER_1_V120_RATE_ADAPT) {
|
||||
pri_message(pri, "%c Hdr: %d, Multiframe: %d, Mode: %d, "
|
||||
"LLI negot: %d, Assignor: %d, "
|
||||
"In-band neg: %d\n", prefix,
|
||||
(data & 0x40)?1:0,
|
||||
(data & 0x20)?1:0,
|
||||
(data & 0x10)?1:0,
|
||||
(data & 0x08)?1:0,
|
||||
(data & 0x04)?1:0,
|
||||
(data & 0x02)?1:0);
|
||||
} else {
|
||||
pri_message(pri, "%c Unknown octet 5b: 0x%x\n", data );
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
/* octet 5c? */
|
||||
if (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
u_int8_t data = ie->data[pos];
|
||||
const char *stop_bits[] = {"?","1","1.5","2"};
|
||||
const char *data_bits[] = {"?","5","7","8"};
|
||||
const char *parity[] = {"Odd","?","Even","None",
|
||||
"zero","one","?","?"};
|
||||
|
||||
pri_message(pri, "%c Stop bits: %s, data bits: %s, "
|
||||
"parity: %s\n", prefix,
|
||||
stop_bits[(data & 0x60) >> 5],
|
||||
data_bits[(data & 0x18) >> 3],
|
||||
parity[(data & 0x7)]);
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
/* octet 5d? */
|
||||
if (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
u_int8_t data = ie->data[pos];
|
||||
pri_message(pri, "%c Duplex mode: %d, modem type: %d\n",
|
||||
prefix, (data & 0x40) ? 1 : 0,data & 0x3F);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Look for octet 6; this is identified by bits 5,6 == 10 */
|
||||
if (pos < len &&
|
||||
(ie->data[pos] & 0x60) == 0x40) {
|
||||
pri_message(pri, "%c User information layer 2: %s (%d)\n",
|
||||
prefix, l22str(ie->data[pos] & 0x1f),
|
||||
ie->data[pos] & 0x1f);
|
||||
pos++;
|
||||
pri_message(pri, "%c Ext: %d User information layer 3: %s (%d)\n", prefix, ie->data[pos] >> 7, l32str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
|
||||
}
|
||||
|
||||
/* Look for octet 7; this is identified by bits 5,6 == 11 */
|
||||
if (pos < len && (ie->data[pos] & 0x60) == 0x60) {
|
||||
pri_message(pri, "%c User information layer 3: %s (%d)\n",
|
||||
prefix, l32str(ie->data[pos] & 0x1f),
|
||||
ie->data[pos] & 0x1f);
|
||||
pos++;
|
||||
|
||||
/* octets 7a and 7b? */
|
||||
if (pos + 1 < len && !(ie->data[pos-1] & 0x80) &&
|
||||
!(ie->data[pos] & 0x80)) {
|
||||
unsigned int proto;
|
||||
proto = ((ie->data[pos] & 0xF) << 4 ) |
|
||||
(ie->data[pos+1] & 0xF);
|
||||
|
||||
pri_message(pri, "%c Network layer: 0x%x\n", prefix,
|
||||
proto );
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,18 +746,44 @@ static FUNC_RECV(receive_bearer_capability)
|
||||
}
|
||||
call->transcapability = ie->data[0] & 0x1f;
|
||||
call->transmoderate = ie->data[1] & 0x7f;
|
||||
if (call->transmoderate == PRI_TRANS_CAP_AUDIO_4ESS)
|
||||
call->transmoderate = PRI_TRANS_CAP_3_1K_AUDIO;
|
||||
if (call->transmoderate != TRANS_MODE_PACKET) {
|
||||
|
||||
/* octet 4.1 exists iff mode/rate is multirate */
|
||||
if (call->transmoderate == TRANS_MODE_MULTIRATE) {
|
||||
call->transmultiple = ie->data[pos++] & 0x7f;
|
||||
}
|
||||
|
||||
/* Look for octet 5; this is identified by bits 5,6 == 01 */
|
||||
if (pos < len &&
|
||||
(ie->data[pos] & 0x60) == 0x20 ) {
|
||||
/* although the layer1 is only the bottom 5 bits of the byte,
|
||||
previous versions of this library passed bits 5&6 through
|
||||
too, so we have to do the same for binary compatability */
|
||||
call->userl1 = ie->data[pos] & 0x7f;
|
||||
if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
|
||||
call->rateadaption = ie->data[++pos] & 0x7f;
|
||||
}
|
||||
pos++;
|
||||
} else {
|
||||
/* Get 6 and 7 */
|
||||
call->userl2 = ie->data[pos++] & 0x7f;
|
||||
call->userl3 = ie->data[pos] & 0x7f;
|
||||
|
||||
/* octet 5a? */
|
||||
if (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
call->rateadaption = ie->data[pos] & 0x7f;
|
||||
pos++;
|
||||
}
|
||||
|
||||
/* octets 5b through 5d? */
|
||||
while (pos < len && !(ie->data[pos-1] & 0x80)) {
|
||||
pos++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Look for octet 6; this is identified by bits 5,6 == 10 */
|
||||
if (pos < len &&
|
||||
(ie->data[pos] & 0x60) == 0x40) {
|
||||
call->userl2 = ie->data[pos++] & 0x1f;
|
||||
}
|
||||
|
||||
/* Look for octet 7; this is identified by bits 5,6 == 11 */
|
||||
if (pos < len &&
|
||||
(ie->data[pos] & 0x60) == 0x60) {
|
||||
call->userl3 = ie->data[pos++] & 0x1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -636,13 +791,14 @@ static FUNC_RECV(receive_bearer_capability)
|
||||
static FUNC_SEND(transmit_bearer_capability)
|
||||
{
|
||||
int tc;
|
||||
int pos;
|
||||
|
||||
/* We are ready to transmit single IE only */
|
||||
if(order > 1)
|
||||
return 0;
|
||||
|
||||
tc = call->transcapability;
|
||||
if (pri->subchannel) {
|
||||
if (pri->subchannel && !pri->bri) {
|
||||
/* Bearer capability is *hard coded* in GR-303 */
|
||||
ie->data[0] = 0x88;
|
||||
ie->data[1] = 0x90;
|
||||
@@ -655,34 +811,46 @@ static FUNC_SEND(transmit_bearer_capability)
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (pri->switchtype == PRI_SWITCH_ATT4ESS) {
|
||||
/* 4ESS uses a different trans capability for 3.1khz audio */
|
||||
if (tc == PRI_TRANS_CAP_3_1K_AUDIO)
|
||||
tc = PRI_TRANS_CAP_AUDIO_4ESS;
|
||||
}
|
||||
ie->data[0] = 0x80 | tc;
|
||||
ie->data[1] = call->transmoderate | 0x80;
|
||||
if ( (tc & PRI_TRANS_CAP_DIGITAL) && (pri->switchtype == PRI_SWITCH_EUROISDN_E1) &&
|
||||
(call->transmoderate == TRANS_MODE_PACKET) ) {
|
||||
|
||||
pos = 2;
|
||||
/* octet 4.1 exists iff mode/rate is multirate */
|
||||
if (call->transmoderate == TRANS_MODE_MULTIRATE ) {
|
||||
ie->data[pos++] = call->transmultiple | 0x80;
|
||||
}
|
||||
|
||||
if ((tc & PRI_TRANS_CAP_DIGITAL) && (pri->switchtype == PRI_SWITCH_EUROISDN_E1) &&
|
||||
(call->transmoderate == TRANS_MODE_PACKET)) {
|
||||
/* Apparently EuroISDN switches don't seem to like user layer 2/3 */
|
||||
return 4;
|
||||
}
|
||||
if (call->transmoderate != TRANS_MODE_PACKET) {
|
||||
/* If you have an AT&T 4ESS, you don't send any more info */
|
||||
if ((pri->switchtype != PRI_SWITCH_ATT4ESS) && (call->userl1 > -1)) {
|
||||
ie->data[2] = call->userl1 | 0x80; /* XXX Ext bit? XXX */
|
||||
ie->data[pos++] = call->userl1 | 0x80; /* XXX Ext bit? XXX */
|
||||
if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
|
||||
ie->data[3] = call->rateadaption | 0x80;
|
||||
return 6;
|
||||
ie->data[pos++] = call->rateadaption | 0x80;
|
||||
}
|
||||
return 5;
|
||||
} else
|
||||
return 4;
|
||||
} else {
|
||||
ie->data[2] = 0x80 | call->userl2;
|
||||
ie->data[3] = 0x80 | call->userl3;
|
||||
return 6;
|
||||
}
|
||||
return pos + 2;
|
||||
}
|
||||
|
||||
ie->data[pos++] = 0xa0 | (call->userl1 & 0x1f);
|
||||
|
||||
if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
|
||||
ie->data[pos-1] &= ~0x80; /* clear EXT bit in octet 5 */
|
||||
ie->data[pos++] = call->rateadaption | 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (call->userl2 != -1)
|
||||
ie->data[pos++] = 0xc0 | (call->userl2 & 0x1f);
|
||||
|
||||
if (call->userl3 != -1)
|
||||
ie->data[pos++] = 0xe0 | (call->userl3 & 0x1f);
|
||||
|
||||
return pos + 2;
|
||||
}
|
||||
|
||||
char *pri_plan2str(int plan)
|
||||
@@ -1175,7 +1343,7 @@ static FUNC_RECV(receive_facility)
|
||||
state = my_state; \
|
||||
if (pri->debug) \
|
||||
pri_message(pri, "Handle Q.932 %s component\n", name); \
|
||||
(handler)(pri, call, comp->data, comp->len); \
|
||||
(handler)(pri, call, ie, comp->data, comp->len); \
|
||||
break;
|
||||
#define Q932_HANDLE_NULL(component, my_state, name, handle) \
|
||||
case component: \
|
||||
@@ -1270,7 +1438,7 @@ static FUNC_SEND(transmit_progress_indicator)
|
||||
{
|
||||
int code, mask;
|
||||
/* Can't send progress indicator on GR-303 -- EVER! */
|
||||
if (pri->subchannel)
|
||||
if (pri->subchannel && !pri->bri)
|
||||
return 0;
|
||||
if (call->progressmask > 0) {
|
||||
if (call->progressmask & (mask = PRI_PROG_CALL_NOT_E2E_ISDN))
|
||||
@@ -2162,10 +2330,18 @@ static inline void q931_dumpie(struct pri *pri, int codeset, q931_ie *ie, char p
|
||||
pri_error(pri, "!! %c Unknown IE %d (cs%d, len = %d)\n", prefix, Q931_IE_IE(base_ie), Q931_IE_CODESET(base_ie), ielen(ie));
|
||||
}
|
||||
|
||||
static q931_call *q931_getcall(struct pri *pri, int cr)
|
||||
static q931_call *q931_getcall(struct pri *pri, int cr, int outboundnew)
|
||||
{
|
||||
q931_call *cur, *prev;
|
||||
cur = *pri->callpool;
|
||||
struct pri *master;
|
||||
|
||||
/* Find the master - He has the call pool */
|
||||
if (pri->master)
|
||||
master = pri->master;
|
||||
else
|
||||
master = pri;
|
||||
|
||||
cur = *master->callpool;
|
||||
prev = NULL;
|
||||
while(cur) {
|
||||
if (cur->cr == cr)
|
||||
@@ -2176,41 +2352,59 @@ static q931_call *q931_getcall(struct pri *pri, int cr)
|
||||
/* No call exists, make a new one */
|
||||
if (pri->debug & PRI_DEBUG_Q931_STATE)
|
||||
pri_message(pri, "-- Making new call for cr %d\n", cr);
|
||||
cur = malloc(sizeof(struct q931_call));
|
||||
if (cur) {
|
||||
call_init(cur);
|
||||
/* Call reference */
|
||||
cur->cr = cr;
|
||||
|
||||
if (!(cur = calloc(1, sizeof(*cur))))
|
||||
return NULL;
|
||||
|
||||
call_init(cur);
|
||||
/* Call reference */
|
||||
cur->cr = cr;
|
||||
/* PRI is set to whoever called us */
|
||||
if (pri->bri && (pri->localtype == PRI_CPE) && pri->subchannel && outboundnew)
|
||||
cur->pri = pri->subchannel;
|
||||
else
|
||||
cur->pri = pri;
|
||||
/* Append to end of list */
|
||||
if (prev)
|
||||
prev->next = cur;
|
||||
else
|
||||
*pri->callpool = cur;
|
||||
}
|
||||
|
||||
/* Append to end of list */
|
||||
if (prev)
|
||||
prev->next = cur;
|
||||
else
|
||||
*master->callpool = cur;
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
q931_call *q931_new_call(struct pri *pri)
|
||||
{
|
||||
q931_call *cur;
|
||||
|
||||
do {
|
||||
cur = *pri->callpool;
|
||||
pri->cref++;
|
||||
if (pri->cref > 32767)
|
||||
pri->cref = 1;
|
||||
if (!pri->bri) {
|
||||
if (pri->cref > 32767)
|
||||
pri->cref = 1;
|
||||
} else {
|
||||
if (pri->cref > 127)
|
||||
pri->cref = 1;
|
||||
}
|
||||
while(cur) {
|
||||
if (cur->cr == (0x8000 | pri->cref))
|
||||
break;
|
||||
cur = cur->next;
|
||||
}
|
||||
} while(cur);
|
||||
return q931_getcall(pri, pri->cref | 0x8000);
|
||||
|
||||
return q931_getcall(pri, pri->cref | 0x8000, 1);
|
||||
}
|
||||
|
||||
static void q931_destroy(struct pri *pri, int cr, q931_call *c)
|
||||
{
|
||||
q931_call *cur, *prev;
|
||||
|
||||
/* For destroying, make sure we are using the master span, since it maintains the call pool */
|
||||
for (;pri->master; pri = pri->master);
|
||||
|
||||
prev = NULL;
|
||||
cur = *pri->callpool;
|
||||
while(cur) {
|
||||
@@ -2375,26 +2569,40 @@ static void init_header(struct pri *pri, q931_call *call, unsigned char *buf, q9
|
||||
{
|
||||
/* Returns header and message header and modifies length in place */
|
||||
q931_h *h = (q931_h *)buf;
|
||||
q931_mh * mh = (q931_mh *)(h->contents + 2);
|
||||
q931_mh * mh;
|
||||
h->pd = pri->protodisc;
|
||||
h->x0 = 0; /* Reserved 0 */
|
||||
h->crlen = 2; /* Two bytes of Call Reference. Invert the top bit to make it from our sense */
|
||||
if (call->cr || call->forceinvert) {
|
||||
h->crv[0] = ((call->cr ^ 0x8000) & 0xff00) >> 8;
|
||||
h->crv[1] = (call->cr & 0xff);
|
||||
if (!pri->bri) {
|
||||
h->crlen = 2; /* Two bytes of Call Reference. Invert the top bit to make it from our sense */
|
||||
if (call->cr || call->forceinvert) {
|
||||
h->crv[0] = ((call->cr ^ 0x8000) & 0xff00) >> 8;
|
||||
h->crv[1] = (call->cr & 0xff);
|
||||
} else {
|
||||
/* Unless of course this has no call reference */
|
||||
h->crv[0] = 0;
|
||||
h->crv[1] = 0;
|
||||
}
|
||||
if (pri->subchannel && !pri->bri) {
|
||||
/* On GR-303, top bit is always 0 */
|
||||
h->crv[0] &= 0x7f;
|
||||
}
|
||||
} else {
|
||||
/* Unless of course this has no call reference */
|
||||
h->crv[0] = 0;
|
||||
h->crv[1] = 0;
|
||||
}
|
||||
if (pri->subchannel) {
|
||||
/* On GR-303, top bit is always 0 */
|
||||
h->crv[0] &= 0x7f;
|
||||
h->crlen = 1;
|
||||
if (call->cr || call->forceinvert) {
|
||||
h->crv[0] = (((call->cr ^ 0x8000) & 0x8000) >> 8) | (call->cr & 0x7f);
|
||||
} else {
|
||||
/* Unless of course this has no call reference */
|
||||
h->crv[0] = 0;
|
||||
}
|
||||
}
|
||||
mh = (q931_mh *)(h->contents + h->crlen);
|
||||
mh->f = 0;
|
||||
*hb = h;
|
||||
*mhb = mh;
|
||||
*len -= 5;
|
||||
if (h->crlen == 2)
|
||||
*len -= 5;
|
||||
else
|
||||
*len -= 4;
|
||||
|
||||
}
|
||||
|
||||
@@ -2443,7 +2651,7 @@ static int send_message(struct pri *pri, q931_call *c, int msgtype, int ies[])
|
||||
}
|
||||
/* Invert the logic */
|
||||
len = sizeof(buf) - len;
|
||||
q931_xmit(pri, h, len, 1);
|
||||
q931_xmit(c->pri, h, len, 1);
|
||||
c->acked = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -2528,6 +2736,8 @@ int q931_notify(struct pri *pri, q931_call *c, int channel, int info)
|
||||
#ifdef ALERTING_NO_PROGRESS
|
||||
static int call_progress_ies[] = { -1 };
|
||||
#else
|
||||
static int call_progress_with_cause_ies[] = { Q931_PROGRESS_INDICATOR, Q931_CAUSE, -1 };
|
||||
|
||||
static int call_progress_ies[] = { Q931_PROGRESS_INDICATOR, -1 };
|
||||
#endif
|
||||
|
||||
@@ -2539,6 +2749,7 @@ int q931_call_progress(struct pri *pri, q931_call *c, int channel, int info)
|
||||
channel &= 0xff;
|
||||
c->channelno = channel;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
c->progloc = LOC_PRIV_NET_LOCAL_USER;
|
||||
c->progcode = CODE_CCITT;
|
||||
@@ -2548,10 +2759,38 @@ int q931_call_progress(struct pri *pri, q931_call *c, int channel, int info)
|
||||
pri_error(pri, "XXX Progress message requested but no information is provided\n");
|
||||
c->progressmask = 0;
|
||||
}
|
||||
|
||||
c->alive = 1;
|
||||
return send_message(pri, c, Q931_PROGRESS, call_progress_ies);
|
||||
}
|
||||
|
||||
int q931_call_progress_with_cause(struct pri *pri, q931_call *c, int channel, int info, int cause)
|
||||
{
|
||||
if (channel) {
|
||||
c->ds1no = (channel & 0xff00) >> 8;
|
||||
c->ds1explicit = (channel & 0x10000) >> 16;
|
||||
channel &= 0xff;
|
||||
c->channelno = channel;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
c->progloc = LOC_PRIV_NET_LOCAL_USER;
|
||||
c->progcode = CODE_CCITT;
|
||||
c->progressmask = PRI_PROG_INBAND_AVAILABLE;
|
||||
} else {
|
||||
/* PI is mandatory IE for PROGRESS message - Q.931 3.1.8 */
|
||||
pri_error(pri, "XXX Progress message requested but no information is provided\n");
|
||||
c->progressmask = 0;
|
||||
}
|
||||
|
||||
c->cause = cause;
|
||||
c->causecode = CODE_CCITT;
|
||||
c->causeloc = LOC_PRIV_NET_LOCAL_USER;
|
||||
|
||||
c->alive = 1;
|
||||
return send_message(pri, c, Q931_PROGRESS, call_progress_with_cause_ies);
|
||||
}
|
||||
|
||||
#ifdef ALERTING_NO_PROGRESS
|
||||
static int call_proceeding_ies[] = { Q931_CHANNEL_IDENT, -1 };
|
||||
#else
|
||||
@@ -2626,6 +2865,7 @@ int q931_setup_ack(struct pri *pri, q931_call *c, int channel, int nonisdn)
|
||||
return send_message(pri, c, Q931_SETUP_ACKNOWLEDGE, connect_ies);
|
||||
}
|
||||
|
||||
/* T313 expiry, first time */
|
||||
static void pri_connect_timeout(void *data)
|
||||
{
|
||||
struct q931_call *c = data;
|
||||
@@ -2636,6 +2876,7 @@ static void pri_connect_timeout(void *data)
|
||||
|
||||
}
|
||||
|
||||
/* T308 expiry, first time */
|
||||
static void pri_release_timeout(void *data)
|
||||
{
|
||||
struct q931_call *c = data;
|
||||
@@ -2644,9 +2885,12 @@ static void pri_release_timeout(void *data)
|
||||
pri_message(pri, "Timed out looking for release complete\n");
|
||||
c->t308_timedout++;
|
||||
c->alive = 1;
|
||||
q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
|
||||
|
||||
/* The call to q931_release will re-schedule T308 */
|
||||
q931_release(pri, c, c->cause);
|
||||
}
|
||||
|
||||
/* T308 expiry, second time */
|
||||
static void pri_release_finaltimeout(void *data)
|
||||
{
|
||||
struct q931_call *c = data;
|
||||
@@ -2668,6 +2912,7 @@ static void pri_release_finaltimeout(void *data)
|
||||
q931_hangup(pri, c, c->cause);
|
||||
}
|
||||
|
||||
/* T305 expiry, first time */
|
||||
static void pri_disconnect_timeout(void *data)
|
||||
{
|
||||
struct q931_call *c = data;
|
||||
@@ -2704,7 +2949,7 @@ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(pri, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (!pri->subchannel))
|
||||
if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (pri->bri || (!pri->subchannel)))
|
||||
c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T313], pri_connect_timeout, c);
|
||||
return send_message(pri, c, Q931_CONNECT, connect_ies);
|
||||
}
|
||||
@@ -2740,7 +2985,7 @@ static int restart_ies[] = { Q931_CHANNEL_IDENT, Q931_RESTART_INDICATOR, -1 };
|
||||
int q931_restart(struct pri *pri, int channel)
|
||||
{
|
||||
struct q931_call *c;
|
||||
c = q931_getcall(pri, 0 | 0x8000);
|
||||
c = q931_getcall(pri, 0 | 0x8000, 1);
|
||||
if (!c)
|
||||
return -1;
|
||||
if (!channel)
|
||||
@@ -2795,10 +3040,12 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
|
||||
if (!req->userl1)
|
||||
req->userl1 = PRI_LAYER_1_ULAW;
|
||||
c->userl1 = req->userl1;
|
||||
c->userl2 = -1;
|
||||
c->userl3 = -1;
|
||||
c->ds1no = (req->channel & 0xff00) >> 8;
|
||||
c->ds1explicit = (req->channel & 0x10000) >> 16;
|
||||
req->channel &= 0xff;
|
||||
if ((pri->localtype == PRI_CPE) && pri->subchannel) {
|
||||
if ((pri->localtype == PRI_CPE) && pri->subchannel && !pri->bri) {
|
||||
req->channel = 0;
|
||||
req->exclusive = 0;
|
||||
}
|
||||
@@ -2868,7 +3115,7 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
|
||||
|
||||
pri_call_add_standard_apdus(pri, c);
|
||||
|
||||
if (pri->subchannel)
|
||||
if (pri->subchannel && !pri->bri)
|
||||
res = send_message(pri, c, Q931_SETUP, gr303_setup_ies);
|
||||
else if (c->justsignalling)
|
||||
res = send_message(pri, c, Q931_SETUP, cis_setup_ies);
|
||||
@@ -2912,7 +3159,7 @@ static int gr303_connect_acknowledge_ies[] = { Q931_CHANNEL_IDENT, -1 };
|
||||
|
||||
static int q931_connect_acknowledge(struct pri *pri, q931_call *c)
|
||||
{
|
||||
if (pri->subchannel) {
|
||||
if (pri->subchannel && !pri->bri) {
|
||||
if (pri->localtype == PRI_CPE)
|
||||
return send_message(pri, c, Q931_CONNECT_ACKNOWLEDGE, gr303_connect_acknowledge_ies);
|
||||
} else
|
||||
@@ -3046,7 +3293,7 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
|
||||
pri_error(pri, "Warning: unknown/inappropriate protocol discriminator received (%02x/%d)\n", h->pd, h->pd);
|
||||
return 0;
|
||||
}
|
||||
c = q931_getcall(pri, q931_cr(h));
|
||||
c = q931_getcall(pri, q931_cr(h), 0);
|
||||
if (!c) {
|
||||
pri_error(pri, "Unable to locate call %d\n", q931_cr(h));
|
||||
return -1;
|
||||
@@ -3395,6 +3642,8 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
|
||||
libpri_copy_string(pri->ev.facname.callingname, c->callername, sizeof(pri->ev.facname.callingname));
|
||||
libpri_copy_string(pri->ev.facname.callingnum, c->callernum, sizeof(pri->ev.facname.callingnum));
|
||||
pri->ev.facname.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
|
||||
pri->ev.facname.callingpres = c->callerpres;
|
||||
pri->ev.facname.callingplan = c->callerplan;
|
||||
pri->ev.facname.cref = c->cr;
|
||||
pri->ev.facname.call = c;
|
||||
#if 0
|
||||
@@ -3473,7 +3722,15 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
|
||||
(c->cause != PRI_CAUSE_INTERWORKING))
|
||||
pri_error(pri, "Received unsolicited status: %s\n", pri_cause2str(c->cause));
|
||||
/* Workaround for S-12 ver 7.3 - it responds for invalid/non-implemented IEs at SETUP with null call state */
|
||||
#if 0
|
||||
if (!c->sugcallstate && (c->ourcallstate != Q931_CALL_STATE_CALL_INITIATED)) {
|
||||
#else
|
||||
/* Remove "workaround" since it breaks certification testing. If we receive a STATUS message of call state
|
||||
* NULL and we are not in the call state NULL we must clear resources and return to the call state to pass
|
||||
* testing. See section 5.8.11 of Q.931 */
|
||||
|
||||
if (!c->sugcallstate) {
|
||||
#endif
|
||||
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
|
||||
pri->ev.hangup.cause = c->cause;
|
||||
pri->ev.hangup.cref = c->cr;
|
||||
@@ -3563,6 +3820,12 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
|
||||
UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_DISCONNECT_INDICATION);
|
||||
c->peercallstate = Q931_CALL_STATE_DISCONNECT_REQUEST;
|
||||
c->sendhangupack = 1;
|
||||
|
||||
/* wait for a RELEASE so that sufficient time has passed
|
||||
for the inband audio to be heard */
|
||||
if (pri->acceptinbanddisconnect && (c->progressmask & PRI_PROG_INBAND_AVAILABLE))
|
||||
break;
|
||||
|
||||
/* Return such an event */
|
||||
pri->ev.e = PRI_EVENT_HANGUP_REQ;
|
||||
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
|
||||
|
||||
48
testprilib.c
48
testprilib.c
@@ -3,25 +3,31 @@
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* Copyright (C) 2001-2005, Digium
|
||||
* Copyright (C) 2001-2005, Digium, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This program tests libpri call reception using a zaptel interface.
|
||||
* Its state machines are setup for RECEIVING CALLS ONLY, so if you
|
||||
@@ -64,7 +70,7 @@ static struct pri *first, *cur;
|
||||
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
#define TEST_CALLS 32
|
||||
#define TEST_CALLS 1
|
||||
|
||||
static void event1(struct pri *pri, pri_event *e)
|
||||
{
|
||||
@@ -232,9 +238,9 @@ static void *dchan(void *data)
|
||||
}
|
||||
if (e) {
|
||||
if (first == pri) {
|
||||
event1(pri, e);
|
||||
event1(e->gen.pri, e);
|
||||
} else {
|
||||
event2(pri, e);
|
||||
event2(e->gen.pri, e);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
@@ -254,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
perror("socketpair");
|
||||
exit(1);
|
||||
}
|
||||
if (!(pri = pri_new(pair[0], PRI_NETWORK, PRI_DEF_SWITCHTYPE))) {
|
||||
if (!(pri = pri_new_bri(pair[0], 0, PRI_NETWORK, PRI_DEF_SWITCHTYPE))) {
|
||||
perror("pri(0)");
|
||||
exit(1);
|
||||
}
|
||||
@@ -265,7 +271,7 @@ int main(int argc, char *argv[])
|
||||
perror("thread(0)");
|
||||
exit(1);
|
||||
}
|
||||
if (!(pri = pri_new(pair[1], PRI_CPE, PRI_DEF_SWITCHTYPE))) {
|
||||
if (!(pri = pri_new_bri(pair[1], 0, PRI_CPE, PRI_DEF_SWITCHTYPE))) {
|
||||
perror("pri(1)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user