Compare commits

..

41 Commits
1.4.1 ... 1.2.8

Author SHA1 Message Date
Kevin P. Fleming
b13a9798dd Importing files for 1.2.8 release
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.2.8@613 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-08-05 22:34:18 +00:00
Kevin P. Fleming
82deae0414 Creating tag for the release of libpri-1.2.8
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.2.8@612 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-08-05 22:33:07 +00:00
Kevin P. Fleming
e044d2f545 clean up license headers, and explicitly grant additional permissions when used with Asterisk
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@610 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-08-05 22:16:58 +00:00
Dwayne M. Hubbard
e77a1054a2 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.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@561 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-06-04 16:59:04 +00:00
Matthew Fredrickson
c53f63e1c4 Don't send a status error when we receive connect acknowledge during an active state
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@527 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-02-20 21:36:04 +00:00
Matthew Fredrickson
268ce63ab8 Improve transmission, receiving, and dumping of bearer capability IE (#11593)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@523 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-02-18 20:31:02 +00:00
Matthew Fredrickson
a17ea8d6d5 Revert previous commit 521
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@522 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-02-18 20:28:07 +00:00
Matthew Fredrickson
0a095c88f1 Fix for bug #960. Better support for more exotic bearer capabilities
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@521 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-02-18 20:25:09 +00:00
Matthew Fredrickson
2e5dd8ec5d We should not be parsing further into the bearer capability IE if the length does not confirm that there actually is data present
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@513 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2008-01-11 16:33:52 +00:00
Kevin P. Fleming
6be94aed97 we need to include stddef.h for 'size_t'
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@478 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-10-22 15:09:27 +00:00
Matthew Fredrickson
0e75c28513 Fix user-user IE order in setup message (#10705)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@467 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-09-25 21:33:16 +00:00
Matthew Fredrickson
6fb4d0ee4a TBCT now works. It should work for NI2, 4E, and 5E. This code was tested on NI2.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@460 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-09-06 15:06:42 +00:00
Jason Parker
8c5e372f29 Make sure we build both the static and shared modules with -fPIC.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@445 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-08-27 19:20:23 +00:00
Matthew Fredrickson
2fa3049e19 Try to send pending facility messages if we receive alerting (for when we don't get proceeding) (#9651)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@426 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-06-19 18:22:33 +00:00
Matthew Fredrickson
165a1190f2 Oops, that should not be on one line
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@423 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-06-06 21:57:15 +00:00
Matthew Fredrickson
a3f9429129 Make sure we only send the NFE when we are talking QSIG
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@415 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-06-06 13:20:05 +00:00
Matthew Fredrickson
26260008d1 Make sure we send DISCONNECT if we reached the active state and a call is disconnected, regardless of cause code.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@389 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2007-01-22 22:20:59 +00:00
Joshua Colp
b5feb47e50 Specify full path to restorecon instead of assuming it will be available from what is in $PATH. (issue #8670 reported by djflux)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@385 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-12-30 19:16:17 +00:00
Matthew Fredrickson
7e04dfc279 Make sure we send any pending facilty APDUs after we get proceeding. (#7551)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@368 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-07-28 14:44:15 +00:00
Russell Bryant
0dcd4a1c1e ensure buffer is initialized (issue #7512, klaus3000)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@360 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-07-12 19:08:31 +00:00
Matthew Fredrickson
3963b924b2 Fix for #7378 (namespace collision)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@358 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-07-07 15:36:50 +00:00
Matthew Fredrickson
725b07229a Minor state fix. (#7269)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@347 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-06-02 16:05:55 +00:00
Matthew Fredrickson
f1bf41b9f3 Fix for 7115 (Don't call pri_message multiple times per line)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@345 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-06-02 14:33:50 +00:00
Matthew Fredrickson
7d1f278dbe Fixes to fill in non-filled fields in libpri. (Issue #7241) Thanks flefoll!
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@342 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-06-01 17:57:03 +00:00
Kevin P. Fleming
33e5d26221 set LDCONFIG_FLAGS for GNU/kFreeBSD as well
use the flags during installation


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@332 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-04-30 15:17:47 +00:00
Matthew Fredrickson
856498556b Make sure we pass the call back in the setup_ack
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@327 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-04-27 16:08:39 +00:00
Matthew Fredrickson
8bf694a4f5 Fix for #6566 (Makefile does not honor DESTDIR)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@323 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-04-04 15:36:04 +00:00
Matthew Fredrickson
ff8098285c Backport of 6480
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@316 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-02-17 18:55:05 +00:00
Matt O'Gorman
67d7e324a1 bug 6500 typo in README.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@311 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-02-15 17:59:38 +00:00
Kevin P. Fleming
7c66b22563 suppress annoying message about unsupported components in facility messages
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@306 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-02-13 23:06:02 +00:00
Russell Bryant
1626cd29b8 remove old ChangeLog ... it will now only be in the tags
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@296 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-01-18 04:53:47 +00:00
Kevin P. Fleming
cbd9c37c29 ensure that user-user info field in call is properly reset when not needed
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@291 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-01-17 13:43:18 +00:00
Matthew Fredrickson
c3854dede0 Backport of doing correct minor numbers to 1.2 (#6188)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@290 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2006-01-10 20:19:14 +00:00
Matthew Fredrickson
29d1983e4d Fix for issue #6039 backported to 1.2
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@284 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-12-27 14:01:34 +00:00
Matthew Fredrickson
8fc524e6e7 Send RR as command instead of response when T200 expires after receiving RNR.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@280 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-12-06 21:35:50 +00:00
Kevin P. Fleming
50e2d23352 Makefile 'update' target now supports Subversion repositories (issue #5875)
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@274 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-12-01 23:13:49 +00:00
Matthew Fredrickson
8c424cc4ff Backport of fix from trunk. Fix broken single digit keypad facility code.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@270 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-12-01 02:34:44 +00:00
Kevin P. Fleming
2f6aee20d9 remove extraneous svn:executable properties
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@266 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-29 18:39:18 +00:00
Kevin P. Fleming
1328ab60de remove CVS ignore list, update SVN ignore list
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@265 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-29 00:31:21 +00:00
Kevin P. Fleming
f826a6e4ad rename branches
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.2@261 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-27 04:14:49 +00:00
Admin Commit
4ec90f7435 This commit was manufactured by cvs2svn to create branch 'v1-2'.
git-svn-id: https://origsvn.digium.com/svn/libpri/branches/v1-2@256 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-10-25 16:59:59 +00:00
21 changed files with 1006 additions and 1219 deletions

View File

@@ -1 +1 @@
1.4.1
1.2.8

208
ChangeLog
View File

@@ -1,48 +1,186 @@
2007-07-09 Russell Bryant <russell@digium.com>
2008-08-05 Kevin P. Fleming <kpfleming@digium.com>
* libpri 1.4.1 released.
* libpri 1.2.8 Released
2007-06-19 18:23 +0000 [r427] Matthew Fredrickson <creslin@digium.com>
2008-08-05 22:16 +0000 [r610] Kevin P. Fleming <kpfleming@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) ........
* 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:
clean up license headers, and explicitly grant additional
permissions when used with Asterisk
2007-06-06 21:58 +0000 [r416-424] Matthew Fredrickson <creslin@digium.com>
2008-06-04 16:59 +0000 [r561] Dwayne M. Hubbard <dhubbard@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 ........
* 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.
* 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 ........
2008-02-20 21:36 +0000 [r527] Matthew Fredrickson <creslin@digium.com>
2007-01-22 22:29 +0000 [r390] Matthew Fredrickson <creslin@digium.com>
* q931.c: Don't send a status error when we receive connect
acknowledge during an active state
* 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. ........
2008-02-18 20:31 +0000 [r521-523] Matthew Fredrickson <creslin@digium.com>
2006-12-30 19:17 +0000 [r386] Joshua Colp <jcolp@digium.com>
* q931.c, libpri.h: Improve transmission, receiving, and dumping of
bearer capability IE (#11593)
* 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)
........
* q931.c, libpri.h: Revert previous commit 521
2006-12-23 Kevin P. Fleming <kpfleming@digium.com>
* q931.c, libpri.h: Fix for bug #960. Better support for more
exotic bearer capabilities
2008-01-11 16:33 +0000 [r513] Matthew Fredrickson <creslin@digium.com>
* q931.c: 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.2.7 Released
2007-10-22 15:09 +0000 [r478] Kevin P. Fleming <kpfleming@digium.com>
* pri_internal.h: we need to include stddef.h for 'size_t'
2007-10-16 Matthew Fredrickson <creslin@digium.com>
* libpri 1.2.6 Released
2007-09-25 21:33 +0000 [r467] Matthew Fredrickson <creslin@digium.com>
* q931.c: Fix user-user IE order in setup message (#10705)
2007-09-06 15:06 +0000 [r460] Matthew Fredrickson <creslin@digium.com>
* pri.c, pri_facility.c: TBCT now works. It should work for NI2,
4E, and 5E. This code was tested on NI2.
2007-08-27 19:20 +0000 [r445] Jason Parker <jparker@digium.com>
* Makefile: Make sure we build both the static and shared modules
with -fPIC.
2007-07-09 Russell Bryant <russell@digium.com>
* libpri 1.2.5 Released
2007-06-19 18:22 +0000 [r426] Matthew Fredrickson <creslin@digium.com>
* q931.c: Try to send pending facility messages if we receive
alerting (for when we don't get proceeding) (#9651)
2007-06-06 21:57 +0000 [r415-423] Matthew Fredrickson <creslin@digium.com>
* pri_facility.c: Oops, that should not be on one line
* pri_facility.c: Make sure we only send the NFE when we are
talking QSIG
2007-01-22 22:20 +0000 [r389] Matthew Fredrickson <creslin@digium.com>
* q931.c: Make sure we send DISCONNECT if we reached the active
state and a call is disconnected, regardless of cause code.
2006-12-30 19:16 +0000 [r385] Joshua Colp <jcolp@digium.com>
* Makefile: Specify full path to restorecon instead of assuming it
will be available from what is in $PATH. (issue #8670 reported by
djflux)
2006-10-17 Kevin P. Fleming <kpfleming@digium.com>
* libpri 1.2.4 Released
2006-07-28 14:44 +0000 [r368] Matt Frederickson <creslin@digium.com>
* q931.c: Make sure we send any pending facilty APDUs after we get
proceeding. (#7551)
2006-07-12 19:08 +0000 [r360] Russell Bryant <russell@digium.com>
* q931.c: ensure buffer is initialized (issue #7512, klaus3000)
2006-07-07 15:36 +0000 [r358] Matt Frederickson <creslin@digium.com>
* q931.c: Fix for #7378 (namespace collision)
2006-06-02 16:05 +0000 [r342-347] Matt Frederickson <creslin@digium.com>
* q931.c: Minor state fix. (#7269)
* q931.c: Fix for 7115 (Don't call pri_message multiple times per
line)
* q931.c: Fixes to fill in non-filled fields in libpri. (Issue
#7241) Thanks flefoll!
2006-05-30 Kevin P. Fleming <kpfleming@digium.com>
* libpri 1.2.3 Released
2006-04-30 15:17 +0000 [r332] Kevin P. Fleming <kpfleming@digium.com>
* Makefile: set LDCONFIG_FLAGS for GNU/kFreeBSD as well use the
flags during installation
2006-04-27 16:08 +0000 [r327] Matt Frederickson <creslin@digium.com>
* q931.c, libpri.h: Make sure we pass the call back in the
setup_ack
2006-04-04 15:36 +0000 [r323] Matt Frederickson <creslin@digium.com>
* Makefile: Fix for #6566 (Makefile does not honor DESTDIR)
2006-02-17 18:55 +0000 [r316] Matt Frederickson <creslin@digium.com>
* q931.c: Backport of 6480
2006-02-15 17:59 +0000 [r311] Matt O'Gorman <mogorman@digium.com>
* README: bug 6500 typo in README.
2006-02-13 23:06 +0000 [r306] Kevin P. Fleming <kpfleming@digium.com>
* pri_facility.c: suppress annoying message about unsupported
components in facility messages
2006-01-18 Russell Bryant <russell@digium.com>
* Libpri 1.2.2 Released
2006-01-17 13:43 +0000 [r291] Kevin P. Fleming <kpfleming@digium.com>
* q931.c: ensure that user-user info field in call is properly
reset when not needed
2006-01-10 20:19 +0000 [r290] Matt Frederickson <creslin@digium.com>
* Makefile: Backport of doing correct minor numbers to 1.2 (#6188)
2005-12-27 14:01 +0000 [r284] Matt Frederickson <creslin@digium.com>
* q931.c: Fix for issue #6039 backported to 1.2
2005-12-06 21:35 +0000 [r280] Matt Frederickson <creslin@digium.com>
* q921.c: Send RR as command instead of response when T200 expires
after receiving RNR.
2005-12-01 23:13 +0000 [r274] Kevin P. Fleming <kpfleming@digium.com>
* Makefile: Makefile 'update' target now supports Subversion
repositories (issue #5875)
2005-12-01 02:34 +0000 [r270] Matt Frederickson <creslin@digium.com>
* q931.c: Backport of fix from trunk. Fix broken single digit
keypad facility code.
* libpri 1.4.0 released.
2006-09-20 Kevin P. Fleming <kpfleming@digium.com>
* libpri 1.4.0-beta1 released.

View File

@@ -32,22 +32,23 @@ CC=gcc
OSARCH=$(shell uname -s)
PROC?=$(shell uname -m)
TOBJS=testpri.o
T2OBJS=testprilib.o
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
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS)
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS)
INSTALL_PREFIX=$(DESTDIR)
INSTALL_BASE=/usr
SOFLAGS = -Wl,-hlibpri.so.1.0
LDCONFIG = /sbin/ldconfig
ifneq (,$(findstring X$(OSARCH)X, XLinuxX XGNU/kFreeBSDX))
ifneq (,$(findstring $(OSARCH), Linux GNU/kFreeBSD))
LDCONFIG_FLAGS=-n
else
ifeq (${OSARCH},FreeBSD)
LDCONFIG_FLAGS=-m
CFLAGS += -I../zaptel -I../zapata
INSTALL_BASE=/usr/local
endif
endif
ifeq (${OSARCH},SunOS)
@@ -72,6 +73,9 @@ update:
@if [ -d .svn ]; then \
echo "Updating from Subversion..." ; \
svn update -q; \
elif [ -d CVS ]; then \
echo "Updating from CVS..." ; \
cvs -q -z3 update -Pd; \
else \
echo "Not under version control"; \
fi
@@ -118,7 +122,7 @@ include .depend
endif
%.lo : %.c
$(CC) -fPIC $(CFLAGS) -o $@ -c $<
$(CC) $(CFLAGS) -o $@ -c $<
$(STATIC_LIBRARY): $(STATIC_OBJS)
ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
@@ -133,7 +137,7 @@ $(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
clean:
rm -f *.o *.so *.lo *.so.1 *.so.1.0
rm -f testprilib $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
rm -f testpri testprilib $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
rm -f pritest pridump
rm -f .depend

4
TODO
View File

@@ -1,8 +1,10 @@
General:
-- D-Channel Backup
-- Test against 4e
Q.921:
-- Support unnumbered information frames
-- Get TEI codes working for BRI interfaces
Q.931:
-- Locking Shift IE
-- Implement the 11 missing Q.931 timers

View File

@@ -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

View File

@@ -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>

122
libpri.h
View File

@@ -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
@@ -142,10 +147,10 @@
/* Causes for disconnection */
#define PRI_CAUSE_UNALLOCATED 1
#define PRI_CAUSE_NO_ROUTE_TRANSIT_NET 2 /* !Q.SIG */
#define PRI_CAUSE_NO_ROUTE_TRANSIT_NET 2
#define PRI_CAUSE_NO_ROUTE_DESTINATION 3
#define PRI_CAUSE_CHANNEL_UNACCEPTABLE 6
#define PRI_CAUSE_CALL_AWARDED_DELIVERED 7 /* !Q.SIG */
#define PRI_CAUSE_CALL_AWARDED_DELIVERED 7
#define PRI_CAUSE_NORMAL_CLEARING 16
#define PRI_CAUSE_USER_BUSY 17
#define PRI_CAUSE_NO_USER_RESPONSE 18
@@ -154,29 +159,27 @@
#define PRI_CAUSE_NUMBER_CHANGED 22
#define PRI_CAUSE_DESTINATION_OUT_OF_ORDER 27
#define PRI_CAUSE_INVALID_NUMBER_FORMAT 28
#define PRI_CAUSE_FACILITY_REJECTED 29 /* !Q.SIG */
#define PRI_CAUSE_FACILITY_REJECTED 29
#define PRI_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30
#define PRI_CAUSE_NORMAL_UNSPECIFIED 31
#define PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION 34
#define PRI_CAUSE_NETWORK_OUT_OF_ORDER 38 /* !Q.SIG */
#define PRI_CAUSE_NETWORK_OUT_OF_ORDER 38
#define PRI_CAUSE_NORMAL_TEMPORARY_FAILURE 41
#define PRI_CAUSE_SWITCH_CONGESTION 42 /* !Q.SIG */
#define PRI_CAUSE_ACCESS_INFO_DISCARDED 43 /* !Q.SIG */
#define PRI_CAUSE_SWITCH_CONGESTION 42
#define PRI_CAUSE_ACCESS_INFO_DISCARDED 43
#define PRI_CAUSE_REQUESTED_CHAN_UNAVAIL 44
#define PRI_CAUSE_PRE_EMPTED 45 /* !Q.SIG */
#define PRI_CAUSE_FACILITY_NOT_SUBSCRIBED 50 /* !Q.SIG */
#define PRI_CAUSE_OUTGOING_CALL_BARRED 52 /* !Q.SIG */
#define PRI_CAUSE_INCOMING_CALL_BARRED 54 /* !Q.SIG */
#define PRI_CAUSE_PRE_EMPTED 45
#define PRI_CAUSE_FACILITY_NOT_SUBSCRIBED 50
#define PRI_CAUSE_OUTGOING_CALL_BARRED 52
#define PRI_CAUSE_INCOMING_CALL_BARRED 54
#define PRI_CAUSE_BEARERCAPABILITY_NOTAUTH 57
#define PRI_CAUSE_BEARERCAPABILITY_NOTAVAIL 58
#define PRI_CAUSE_SERVICEOROPTION_NOTAVAIL 63 /* Q.SIG */
#define PRI_CAUSE_BEARERCAPABILITY_NOTIMPL 65
#define PRI_CAUSE_CHAN_NOT_IMPLEMENTED 66 /* !Q.SIG */
#define PRI_CAUSE_FACILITY_NOT_IMPLEMENTED 69 /* !Q.SIG */
#define PRI_CAUSE_CHAN_NOT_IMPLEMENTED 66
#define PRI_CAUSE_FACILITY_NOT_IMPLEMENTED 69
#define PRI_CAUSE_INVALID_CALL_REFERENCE 81
#define PRI_CAUSE_IDENTIFIED_CHANNEL_NOTEXIST 82 /* Q.SIG */
#define PRI_CAUSE_INCOMPATIBLE_DESTINATION 88
#define PRI_CAUSE_INVALID_MSG_UNSPECIFIED 95 /* !Q.SIG */
#define PRI_CAUSE_INVALID_MSG_UNSPECIFIED 95
#define PRI_CAUSE_MANDATORY_IE_MISSING 96
#define PRI_CAUSE_MESSAGE_TYPE_NONEXIST 97
#define PRI_CAUSE_WRONG_MESSAGE 98
@@ -184,9 +187,9 @@
#define PRI_CAUSE_INVALID_IE_CONTENTS 100
#define PRI_CAUSE_WRONG_CALL_STATE 101
#define PRI_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102
#define PRI_CAUSE_MANDATORY_IE_LENGTH_ERROR 103 /* !Q.SIG */
#define PRI_CAUSE_MANDATORY_IE_LENGTH_ERROR 103
#define PRI_CAUSE_PROTOCOL_ERROR 111
#define PRI_CAUSE_INTERWORKING 127 /* !Q.SIG */
#define PRI_CAUSE_INTERWORKING 127
/* Transmit capabilities */
#define PRI_TRANS_CAP_SPEECH 0x0
@@ -207,6 +210,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 */
@@ -465,10 +514,6 @@ extern int pri_acknowledge(struct pri *pri, q931_call *call, int channel, int in
/* Send a digit in overlap mode */
extern 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);
/* 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);
@@ -516,6 +561,7 @@ extern 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 exclusive, int nonisdn, char *caller, int callerplan, char *callername, int callerpres,
@@ -531,9 +577,9 @@ extern int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername,
extern 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);
extern void pri_sr_set_useruser(struct pri_sr *sr, char *userchars);
extern void pri_call_set_useruser(q931_call *sr, const char *userchars);
extern void pri_call_set_useruser(q931_call *sr, char *userchars);
extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);

2
mkdep
View File

@@ -1,4 +1,4 @@
#!/bin/sh -
#!/bin/bash -
#
# $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 $

74
pri.c
View File

@@ -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>
@@ -247,13 +252,13 @@ static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *maste
return p;
}
void pri_call_set_useruser(q931_call *c, const char *userchars)
void pri_call_set_useruser(q931_call *c, char *userchars)
{
if (userchars)
libpri_copy_string(c->useruserinfo, userchars, sizeof(c->useruserinfo));
}
void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars)
void pri_sr_set_useruser(struct pri_sr *sr, char *userchars)
{
sr->useruserinfo = userchars;
}
@@ -471,14 +476,6 @@ int pri_information(struct pri *pri, q931_call *call, char digit)
return q931_information(pri, call, digit);
}
int pri_keypad_facility(struct pri *pri, q931_call *call, char *digits)
{
if (!pri || !call || !digits || !digits[0])
return -1;
return q931_keypad_facility(pri, call, digits);
}
int pri_notify(struct pri *pri, q931_call *call, int channel, int info)
{
if (!pri || !call)
@@ -529,22 +526,30 @@ int pri_channel_bridge(q931_call *call1, q931_call *call2)
if (!call1 || !call2)
return -1;
/* Make sure we have compatible switchtypes */
if (call1->pri->switchtype != call2->pri->switchtype)
return -1;
/* Check for bearer capability */
if (call1->transcapability != call2->transcapability)
return -1;
/* Check to see if calls are on the same PRI dchannel
* Currently only support calls on the same dchannel
*/
/* Check to see if we're on the same PRI */
if (call1->pri != call2->pri)
return -1;
if (call1->pri->switchtype == PRI_SWITCH_LUCENT5E)
return eect_initiate_transfer(call1->pri, call1, call2);
if (call1->pri->switchtype == PRI_SWITCH_DMS100)
return rlt_initiate_transfer(call1->pri, call1, call2);
return -1;
switch (call1->pri->switchtype) {
case PRI_SWITCH_NI2:
case PRI_SWITCH_LUCENT5E:
case PRI_SWITCH_ATT4ESS:
if (eect_initiate_transfer(call1->pri, call1, call2))
return -1;
else
return 0;
break;
default:
return -1;
}
}
int pri_hangup(struct pri *pri, q931_call *call, int cause)
@@ -781,7 +786,6 @@ char *pri_dump_info_str(struct pri *pri)
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]);
len += sprintf(buf + len, "T308 Timer: %d\n", pri->timers[PRI_TIMER_T308]);
len += sprintf(buf + len, "T309 Timer: %d\n", pri->timers[PRI_TIMER_T309]);
len += sprintf(buf + len, "T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
len += sprintf(buf + len, "N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);

View File

@@ -3,23 +3,28 @@
*
* Written by Matthew Fredrickson <creslin@digium.com>
*
* Copyright (C) 2004-2005, Digium
* Copyright (C) 2004-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"
@@ -32,132 +37,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
static char *asn1id2text(int id)
{
static char data[32];
static char *strings[] = {
"none",
"Boolean",
"Integer",
"Bit String",
"Octet String",
"NULL",
"Object Identifier",
"Object Descriptor",
"External Reference",
"Real Number",
"Enumerated",
"Embedded PDV",
"UTF-8 String",
"Relative Object ID",
"Reserved (0e)",
"Reserved (0f)",
"Sequence",
"Set",
"Numeric String",
"Printable String",
"Tele-Text String",
"IA-5 String",
"UTC Time",
"Generalized Time",
};
if (id > 0 && id <= 0x18) {
return strings[id];
} else {
sprintf(data, "Unknown (%02x)", id);
return data;
}
}
static int asn1_dumprecursive(struct pri *pri, void *comp_ptr, int len, int level)
{
unsigned char *vdata = (unsigned char *)comp_ptr;
struct rose_component *comp;
int i = 0;
int j, k, l;
int clen = 0;
while (len > 0) {
GET_COMPONENT(comp, i, vdata, len);
pri_message(pri, "%*s%02X %04X", 2 * level, "", comp->type, comp->len);
if ((comp->type == 0) && (comp->len == 0))
return clen + 2;
if ((comp->type & ASN1_PC_MASK) == ASN1_PRIMITIVE) {
for (j = 0; j < comp->len; ++j)
pri_message(pri, " %02X", comp->data[j]);
}
if ((comp->type & ASN1_CLAN_MASK) == ASN1_UNIVERSAL) {
switch (comp->type & ASN1_TYPE_MASK) {
case 0:
pri_message(pri, " (none)");
break;
case ASN1_BOOLEAN:
pri_message(pri, " (BOOLEAN: %d)", comp->data[0]);
break;
case ASN1_INTEGER:
for (k = l = 0; k < comp->len; ++k)
l = (l << 8) | comp->data[k];
pri_message(pri, " (INTEGER: %d)", l);
break;
case ASN1_BITSTRING:
pri_message(pri, " (BITSTRING:");
for (k = 0; k < comp->len; ++k)
pri_message(pri, " %02x", comp->data[k]);
pri_message(pri, ")");
break;
case ASN1_OCTETSTRING:
pri_message(pri, " (OCTETSTRING:");
for (k = 0; k < comp->len; ++k)
pri_message(pri, " %02x", comp->data[k]);
pri_message(pri, ")");
break;
case ASN1_NULL:
pri_message(pri, " (NULL)");
break;
case ASN1_OBJECTIDENTIFIER:
pri_message(pri, " (OBJECTIDENTIFIER:");
for (k = 0; k < comp->len; ++k)
pri_message(pri, " %02x", comp->data[k]);
pri_message(pri, ")");
break;
case ASN1_ENUMERATED:
for (k = l = 0; k < comp->len; ++k)
l = (l << 8) | comp->data[k];
pri_message(pri, " (ENUMERATED: %d)", l);
break;
case ASN1_SEQUENCE:
pri_message(pri, " (SEQUENCE)");
break;
default:
pri_message(pri, " (component %02x - %s)", comp->type, asn1id2text(comp->type & ASN1_TYPE_MASK));
break;
}
}
else if ((comp->type & ASN1_CLAN_MASK) == ASN1_CONTEXT_SPECIFIC) {
pri_message(pri, " (CONTEXT SPECIFIC [%d])", comp->type & ASN1_TYPE_MASK);
}
else {
pri_message(pri, " (component %02x)", comp->type);
}
pri_message(pri, "\n");
if ((comp->type & ASN1_PC_MASK) == ASN1_CONSTRUCTOR)
j = asn1_dumprecursive(pri, comp->data, (comp->len ? comp->len : INT_MAX), level+1);
else
j = comp->len;
j += 2;
len -= j;
vdata += j;
clen += j;
}
return clen;
}
int asn1_dump(struct pri *pri, void *comp, int len)
{
return asn1_dumprecursive(pri, comp, len, 0);
}
static unsigned char get_invokeid(struct pri *pri)
{
@@ -172,44 +51,28 @@ struct addressingdataelements_presentednumberunscreened {
int pres;
};
#define PRI_CHECKOVERFLOW(size) \
if (msgptr - message + (size) >= sizeof(message)) { \
*msgptr = '\0'; \
pri_message(pri, "%s", message); \
msgptr = message; \
}
static void dump_apdu(struct pri *pri, unsigned char *c, int len)
{
#define MAX_APDU_LENGTH 255
static char hexs[16] = "0123456789ABCDEF";
int i;
char message[(2 + MAX_APDU_LENGTH * 3 + 6 + MAX_APDU_LENGTH + 3)] = ""; /* please adjust here, if you make changes below! */
char *msgptr;
msgptr = message;
*msgptr++ = ' ';
*msgptr++ = '[';
if (len > MAX_APDU_LENGTH)
return;
snprintf(message, sizeof(message)-1, " [");
for (i=0; i<len; i++)
snprintf((char *)(message+strlen(message)), sizeof(message)-strlen(message)-1, " %02x", c[i]);
snprintf((char *)(message+strlen(message)), sizeof(message)-strlen(message)-1, " ] - [");
for (i=0; i<len; i++) {
PRI_CHECKOVERFLOW(3);
*msgptr++ = ' ';
*msgptr++ = hexs[(c[i] >> 4) & 0x0f];
*msgptr++ = hexs[(c[i]) & 0x0f];
if (c[i] < 20 || c[i] >= 128)
snprintf((char *)(message+strlen(message)), sizeof(message)-strlen(message)-1, "<EFBFBD>");
else
snprintf((char *)(message+strlen(message)), sizeof(message)-strlen(message)-1, "%c", c[i]);
}
PRI_CHECKOVERFLOW(6);
strcpy(msgptr, " ] - [");
msgptr += strlen(msgptr);
for (i=0; i<len; i++) {
PRI_CHECKOVERFLOW(1);
*msgptr++ = ((c[i] < ' ') || (c[i] > '~')) ? '.' : c[i];
}
PRI_CHECKOVERFLOW(2);
*msgptr++ = ']';
*msgptr++ = '\n';
*msgptr = '\0';
pri_message(pri, "%s", message);
snprintf((char *)(message+strlen(message)), sizeof(message)-strlen(message)-1, "]\n");
pri_message(pri, message);
}
#undef PRI_CHECKOVERFLOW
int redirectingreason_from_q931(struct pri *pri, int redirectingreason)
{
@@ -706,11 +569,9 @@ static int rose_diverting_leg_information2_encode(struct pri *pri, q931_call *ca
unsigned char buffer[256];
int len = 253;
#if 0 /* This is not required by specifications */
if (!strlen(call->callername)) {
return -1;
}
#endif
buffer[i] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
i++;
@@ -838,84 +699,6 @@ static int rose_diverting_leg_information2_encode(struct pri *pri, q931_call *ca
return 0;
}
/* Send the rltThirdParty: Invoke */
int rlt_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
{
int i = 0;
unsigned char buffer[256];
struct rose_component *comp = NULL, *compstk[10];
const unsigned char rlt_3rd_pty = RLT_THIRD_PARTY;
q931_call *callwithid = NULL, *apdubearer = NULL;
int compsp = 0;
if (c2->transferable) {
apdubearer = c1;
callwithid = c2;
} else if (c1->transferable) {
apdubearer = c2;
callwithid = c1;
} else
return -1;
buffer[i++] = (Q932_PROTOCOL_ROSE);
buffer[i++] = (0x80 | RLT_SERVICE_ID); /* Service Identifier octet */
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
ASN1_PUSH(compstk, compsp, comp);
/* Invoke ID is set to the operation ID */
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, rlt_3rd_pty);
/* Operation Tag */
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, rlt_3rd_pty);
/* Additional RLT invoke info - Octet 12 */
ASN1_ADD_SIMPLE(comp, (ASN1_CONSTRUCTOR | ASN1_SEQUENCE), buffer, i);
ASN1_PUSH(compstk, compsp, comp);
ASN1_ADD_WORDCOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, callwithid->rlt_call_id & 0xFFFFFF); /* Length is 3 octets */
/* Reason for redirect - unused, set to 129 */
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_1), buffer, i, 0);
ASN1_FIXUP(compstk, compsp, buffer, i);
ASN1_FIXUP(compstk, compsp, buffer, i);
if (pri_call_apdu_queue(apdubearer, Q931_FACILITY, buffer, i, NULL, NULL))
return -1;
if (q931_facility(apdubearer->pri, apdubearer)) {
pri_message(pri, "Could not schedule facility message for call %d\n", apdubearer->cr);
return -1;
}
return 0;
}
static int add_dms100_transfer_ability_apdu(struct pri *pri, q931_call *c)
{
int i = 0;
unsigned char buffer[256];
struct rose_component *comp = NULL, *compstk[10];
const unsigned char rlt_op_ind = RLT_OPERATION_IND;
int compsp = 0;
buffer[i++] = (Q932_PROTOCOL_ROSE); /* Note to self: DON'T set the EXT bit */
buffer[i++] = (0x80 | RLT_SERVICE_ID); /* Service Identifier octet */
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
ASN1_PUSH(compstk, compsp, comp);
/* Invoke ID is set to the operation ID */
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, rlt_op_ind);
/* Operation Tag - basically the same as the invoke ID tag */
ASN1_ADD_BYTECOMP(comp, ASN1_INTEGER, buffer, i, rlt_op_ind);
ASN1_FIXUP(compstk, compsp, buffer, i);
if (pri_call_apdu_queue(c, Q931_SETUP, buffer, i, NULL, NULL))
return -1;
else
return 0;
}
/* Sending callername information functions */
static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
{
@@ -973,7 +756,7 @@ static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
}
/* Now the APDU that contains the information that needs sent.
/* Now the ADPu that contains the information that needs sent.
* We can reuse the buffer since the queue function doesn't
* need it. */
@@ -1029,7 +812,7 @@ static void mwi_activate_encode_cb(void *data)
return;
}
int mwi_message_send(struct pri* pri, q931_call *call, struct pri_sr *req, int activate)
extern int mwi_message_send(struct pri* pri, q931_call *call, struct pri_sr *req, int activate)
{
int i = 0;
unsigned char buffer[255] = "";
@@ -1079,15 +862,12 @@ int mwi_message_send(struct pri* pri, q931_call *call, struct pri_sr *req, int a
/* End MWI */
/* EECT functions */
int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
extern int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
{
/* Did all the tests to see if we're on the same PRI and
* are on a compatible switchtype */
/* TODO */
int i = 0;
int res = 0;
unsigned char buffer[255] = "";
unsigned short call_reference = c2->cr;
short call_reference = c2->cr ^ 0x8000; /* Let's do the trickery to make sure the flag is correct */
struct rose_component *comp = NULL, *compstk[10];
int compsp = 0;
static unsigned char op_tag[] = {
@@ -1100,16 +880,7 @@ int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
0x08,
};
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
/* Interpretation component */
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
ASN1_PUSH(compstk, compsp, comp);
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0), buffer, i, 0);
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0);
ASN1_FIXUP(compstk, compsp, buffer, i);
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0);
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_ROSE);
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
ASN1_PUSH(compstk, compsp, comp);
@@ -1129,7 +900,7 @@ int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
res = pri_call_apdu_queue(c1, Q931_FACILITY, buffer, i, NULL, NULL);
if (res) {
pri_message(pri, "Could not queue APDU in facility message\n");
pri_message(pri, "Could not queue ADPU in facility message\n");
return -1;
}
@@ -1336,7 +1107,7 @@ static int aoc_aoce_charging_unit_encode(struct pri *pri, q931_call *c, long cha
/* code below is untested */
res = pri_call_apdu_queue(c, Q931_FACILITY, buffer, i, NULL, NULL);
if (res) {
pri_message(pri, "Could not queue APDU in facility message\n");
pri_message(pri, "Could not queue ADPU in facility message\n");
return -1;
}
@@ -1352,201 +1123,7 @@ static int aoc_aoce_charging_unit_encode(struct pri *pri, q931_call *c, long cha
}
/* End AOC */
int rose_reject_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
{
int i = 0;
int problemtag = -1;
int problem = -1;
int invokeidvalue = -1;
unsigned char *vdata = data;
struct rose_component *comp = NULL;
char *problemtagstr, *problemstr;
do {
/* Invoke ID stuff */
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n");
ASN1_GET_INTEGER(comp, invokeidvalue);
NEXT_COMPONENT(comp, i);
GET_COMPONENT(comp, i, vdata, len);
problemtag = comp->type;
problem = comp->data[0];
if (pri->switchtype == PRI_SWITCH_DMS100) {
switch (problemtag) {
case 0x80:
problemtagstr = "General problem";
break;
case 0x81:
problemtagstr = "Invoke problem";
break;
case 0x82:
problemtagstr = "Return result problem";
break;
case 0x83:
problemtagstr = "Return error problem";
break;
default:
problemtagstr = "Unknown";
}
switch (problem) {
case 0x00:
problemstr = "Unrecognized component";
break;
case 0x01:
problemstr = "Mistyped component";
break;
case 0x02:
problemstr = "Badly structured component";
break;
default:
problemstr = "Unknown";
}
pri_error(pri, "ROSE REJECT:\n");
pri_error(pri, "\tINVOKE ID: 0x%X\n", invokeidvalue);
pri_error(pri, "\tPROBLEM TYPE: %s (0x%x)\n", problemtagstr, problemtag);
pri_error(pri, "\tPROBLEM: %s (0x%x)\n", problemstr, problem);
return 0;
} else {
pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
return -1;
}
} while(0);
return -1;
}
int rose_return_error_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
{
int i = 0;
int errorvalue = -1;
int invokeidvalue = -1;
unsigned char *vdata = data;
struct rose_component *comp = NULL;
char *invokeidstr, *errorstr;
do {
/* Invoke ID stuff */
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n");
ASN1_GET_INTEGER(comp, invokeidvalue);
NEXT_COMPONENT(comp, i);
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second component in return error is 0x%x\n");
ASN1_GET_INTEGER(comp, errorvalue);
if (pri->switchtype == PRI_SWITCH_DMS100) {
switch (invokeidvalue) {
case RLT_OPERATION_IND:
invokeidstr = "RLT_OPERATION_IND";
break;
case RLT_THIRD_PARTY:
invokeidstr = "RLT_THIRD_PARTY";
break;
default:
invokeidstr = "Unknown";
}
switch (errorvalue) {
case 0x10:
errorstr = "RLT Bridge Fail";
break;
case 0x11:
errorstr = "RLT Call ID Not Found";
break;
case 0x12:
errorstr = "RLT Not Allowed";
break;
case 0x13:
errorstr = "RLT Switch Equip Congs";
break;
default:
errorstr = "Unknown";
}
pri_error(pri, "ROSE RETURN ERROR:\n");
pri_error(pri, "\tOPERATION: %s\n", invokeidstr);
pri_error(pri, "\tERROR: %s\n", errorstr);
return 0;
} else {
pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
return -1;
}
} while(0);
return -1;
}
int rose_return_result_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
{
int i = 0;
int operationidvalue = -1;
int invokeidvalue = -1;
unsigned char *vdata = data;
struct rose_component *comp = NULL;
do {
/* Invoke ID stuff */
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n");
ASN1_GET_INTEGER(comp, invokeidvalue);
NEXT_COMPONENT(comp, i);
if (pri->switchtype == PRI_SWITCH_DMS100) {
switch (invokeidvalue) {
case RLT_THIRD_PARTY:
if (pri->debug & PRI_DEBUG_APDU) pri_message(pri, "Successfully completed RLT transfer!\n");
return 0;
case RLT_OPERATION_IND:
if (pri->debug & PRI_DEBUG_APDU) pri_message(pri, "Received RLT_OPERATION_IND\n");
/* Have to take out the rlt_call_id */
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, ASN1_SEQUENCE, "Protocol error detected in parsing RLT_OPERATION_IND return result!\n");
/* Traverse the contents of this sequence */
/* First is the Operation Value */
SUB_COMPONENT(comp, i);
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, ASN1_INTEGER, "RLT_OPERATION_IND should be of type ASN1_INTEGER!\n");
ASN1_GET_INTEGER(comp, operationidvalue);
if (operationidvalue != RLT_OPERATION_IND) {
pri_message(pri, "Invalid Operation ID value (0x%x) in return result!\n", operationidvalue);
return -1;
}
/* Next is the Call ID */
NEXT_COMPONENT(comp, i);
GET_COMPONENT(comp, i, vdata, len);
CHECK_COMPONENT(comp, ASN1_TAG_0, "Error check failed on Call ID!\n");
ASN1_GET_INTEGER(comp, call->rlt_call_id);
/* We have enough data to transfer the call */
call->transferable = 1;
return 0;
default:
pri_message(pri, "Could not parse invoke of type 0x%x!\n", invokeidvalue);
return -1;
}
} else {
pri_message(pri, "Unable to handle return result on switchtype %d!\n", pri->switchtype);
return -1;
}
} while(0);
return -1;
}
int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
extern int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *data, int len)
{
int i = 0;
int operation_tag;
@@ -1665,7 +1242,7 @@ int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *data, in
return -1;
}
int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int apdu_len, void (*function)(void *data), void *data)
extern int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int apdu_len, void (*function)(void *data), void *data)
{
struct apdu_event *cur = NULL;
struct apdu_event *new_event = NULL;
@@ -1699,7 +1276,7 @@ int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int apdu_l
return 0;
}
int pri_call_apdu_queue_cleanup(q931_call *call)
extern int pri_call_apdu_queue_cleanup(q931_call *call)
{
struct apdu_event *cur_event = NULL, *free_event = NULL;
@@ -1717,7 +1294,7 @@ int pri_call_apdu_queue_cleanup(q931_call *call)
return 0;
}
int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
extern int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
{
if (!pri->sendfacility)
return 0;
@@ -1729,7 +1306,6 @@ int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
return 0;
}
#if 0
if (pri->localtype == PRI_NETWORK) {
switch (pri->switchtype) {
case PRI_SWITCH_NI2:
@@ -1749,16 +1325,6 @@ int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
}
return 0;
}
#else
if (pri->switchtype == PRI_SWITCH_NI2)
add_callername_facility_ies(pri, call, (pri->localtype == PRI_CPE));
#endif
if ((pri->switchtype == PRI_SWITCH_DMS100) && (pri->localtype == PRI_CPE)) {
add_dms100_transfer_ability_apdu(pri, call);
}
return 0;
}

View File

@@ -7,6 +7,26 @@
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
@@ -104,7 +124,7 @@
#define ASN1_CLAN_MASK 0xc0
#define ASN1_UNIVERSAL 0x00
#define ASN1_APPLICATION 0x40
#define ASN1_CONTEXT_SPECIFIC 0x80
#define ASN1_CONTEXT_SPECIFIC 0x80
#define ASN1_PRIVATE 0xc0
/* ASN.1 Length masks */
@@ -135,11 +155,6 @@
#define Q932_TON_SUBSCRIBER 0x04
#define Q932_TON_ABBREVIATED 0x06
/* RLT related Operations */
#define RLT_SERVICE_ID 0x3e
#define RLT_OPERATION_IND 0x01
#define RLT_THIRD_PARTY 0x02
struct rose_component {
u_int8_t type;
u_int8_t len;
@@ -151,7 +166,7 @@ struct rose_component {
break; \
(component) = (struct rose_component*)&((ptr)[idx]); \
if ((idx)+(component)->len+2 > (length)) { \
if ((component)->len != ASN1_LEN_INDEF) \
if ((component)->len != 128) \
pri_message(pri, "Length (%d) of 0x%X component is too long\n", (component)->len, (component)->type); \
}
/*
@@ -174,7 +189,6 @@ struct rose_component {
#define CHECK_COMPONENT(component, comptype, message) \
if ((component)->type && ((component)->type & ASN1_TYPE_MASK) != (comptype)) { \
pri_message(pri, (message), (component)->type); \
asn1_dump(pri, (component), (component)->len+2); \
break; \
}
@@ -235,48 +249,35 @@ struct rose_component {
(stack)[(stackpointer)]->len = (unsigned char *)&((data)[(idx)]) - (unsigned char *)(stack)[(stackpointer)] - 2; \
} while (0)
/* Decoder for the invoke ROSE component */
int rose_invoke_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len);
/* Decoder for the invoke part of a ROSE request */
extern int rose_invoke_decode(struct pri *pri, struct q931_call *call, 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);
extern int asn1_copy_string(char * buf, int buflen, struct rose_component *comp);
/* Decoder for the return error ROSE component */
int rose_return_error_decode(struct pri *pri, struct q931_call *call, 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 asn1_copy_string(char * buf, int buflen, struct rose_component *comp);
int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len);
extern int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len);
/* Get Name types from ASN.1 */
int asn1_name_decode(void * data, int len, char *namebuf, int buflen);
extern int asn1_name_decode(void * data, int len, char *namebuf, int buflen);
int typeofnumber_from_q931(struct pri *pri, int ton);
extern int typeofnumber_from_q931(struct pri *pri, int ton);
int redirectingreason_from_q931(struct pri *pri, int redirectingreason);
extern int redirectingreason_from_q931(struct pri *pri, int redirectingreason);
/* Queues an MWI apdu on a the given call */
int mwi_message_send(struct pri *pri, q931_call *call, struct pri_sr *req, int activate);
extern int mwi_message_send(struct pri *pri, q931_call *call, struct pri_sr *req, int activate);
/* starts a 2BCT */
int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2);
extern 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);
/* Use this function to queue a facility-IE born APDU onto a call
/* Use this function to queue a facility-IE born ADPU 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 */
int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int apdu_len, void (*function)(void *data), void *data);
extern int pri_call_apdu_queue(q931_call *call, int messagetype, void *apdu, int apdu_len, void (*function)(void *data), void *data);
/* Used by q931.c to cleanup the apdu queue upon destruction of a call */
int pri_call_apdu_queue_cleanup(q931_call *call);
extern int pri_call_apdu_queue_cleanup(q931_call *call);
/* Adds the "standard" APDUs to a call */
int pri_call_add_standard_apdus(struct pri *pri, q931_call *call);
int asn1_dump(struct pri *pri, void *comp, int len);
/* Adds the "standard" ADPUs to a call */
extern int pri_call_add_standard_apdus(struct pri *pri, q931_call *call);
#endif /* _PRI_FACILITY_H */

View File

@@ -1,35 +1,38 @@
/*
* 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
#define _PRI_INTERNAL_H
#include <stddef.h>
#include <sys/time.h>
#define DBGHEAD __FILE__ ":%d %s: "
#define DBGINFO __LINE__,__PRETTY_FUNCTION__
struct pri_sched {
struct timeval when;
void (*callback)(void *data);
@@ -132,8 +135,7 @@ struct pri_sr {
int redirectingpres;
int redirectingreason;
int justsignalling;
const char *useruserinfo;
int transferable;
char *useruserinfo;
};
/* Internal switch types */
@@ -210,7 +212,7 @@ struct q931_call {
char callernum[256];
char callername[256];
char keypad_digits[64]; /* Buffer for digits that come in KEYPAD_FACILITY */
char digitbuf[64]; /* Buffer for digits that come in KEYPAD_FACILITY */
int ani2; /* ANI II */
@@ -243,9 +245,6 @@ struct q931_call {
long aoc_units; /* Advice of Charge Units */
struct apdu_event *apdus; /* APDU queue for call */
int transferable;
unsigned int rlt_call_id; /* RLT call id */
};
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);

View File

@@ -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

View File

@@ -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
@@ -243,10 +248,6 @@ typedef struct q931_ie {
/* EuroISDN */
#define Q931_SENDING_COMPLETE 0xa1
/* Q.SIG specific */
#define QSIG_IE_TRANSIT_COUNT 0x31
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);
@@ -261,8 +262,6 @@ extern int q931_setup_ack(struct pri *pri, q931_call *call, int channel, int non
extern int q931_information(struct pri *pri, q931_call *call, char digit);
extern int q931_keypad_facility(struct pri *pri, q931_call *call, char *digits);
extern int q931_connect(struct pri *pri, q931_call *call, int channel, int nonisdn);
extern int q931_release(struct pri *pri, q931_call *call, int cause);
@@ -285,7 +284,5 @@ extern int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req);
extern void q931_dump(struct pri *pri, q931_h *h, int len, int txrx);
extern void __q931_destroycall(struct pri *pri, q931_call *c);
extern void q931_dl_indication(struct pri *pri, int event);
#endif

View File

@@ -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_TIMERS_H

View File

@@ -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.
*/
/*
@@ -37,7 +42,11 @@
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/types.h>
#include <zaptel/zaptel.h>
#if defined(__linux__)
#include <linux/zaptel.h>
#elif defined(__FreeBSD__)
#include <zaptel.h>
#endif
#include "libpri.h"
#include "pri_q921.h"
#include "pri_q931.h"

View File

@@ -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>

View File

@@ -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.
*/
/*
@@ -40,7 +45,11 @@
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <zaptel/zaptel.h>
#if defined(__linux__)
#include <linux/zaptel.h>
#elif defined(__FreeBSD__)
#include <zaptel.h>
#endif
#include <zap.h>
#include "libpri.h"

119
q921.c
View File

@@ -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>
@@ -80,7 +85,7 @@ static int q921_transmit(struct pri *pri, q921_h *h, int len)
pri->q921_txcount++;
#endif
/* Just send it raw */
if (pri->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
if (pri->debug & PRI_DEBUG_Q921_DUMP)
q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
/* Write an extra two bytes for the FCS */
res = pri->write_func ? pri->write_func(pri, h, len + 2) : 0;
@@ -111,7 +116,7 @@ static void q921_send_ua(struct pri *pri, int pfbit)
pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
return;
}
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Sending Unnumbered Acknowledgement\n");
q921_transmit(pri, &h, 3);
}
@@ -143,11 +148,9 @@ 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->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Sending Set Asynchronous Balanced Mode Extended\n");
q921_transmit(pri, &h, 3);
if (pri->debug & PRI_DEBUG_Q921_STATE && pri->q921_state != Q921_AWAITING_ESTABLISH)
pri_message(pri, DBGHEAD "q921_state now is Q921_AWAITING_ESTABLISH\n", DBGINFO);
pri->q921_state = Q921_AWAITING_ESTABLISH;
}
@@ -168,7 +171,7 @@ static int q921_ack_packet(struct pri *pri, int num)
prev->next = f->next;
else
pri->txqueue = f->next;
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- ACKing packet %d, new txqueue is %d (-1 means empty)\n", f->h.n_s, pri->txqueue ? pri->txqueue->h.n_s : -1);
/* Update v_a */
pri->v_a = num;
@@ -182,7 +185,7 @@ static int q921_ack_packet(struct pri *pri, int num)
while(f) {
if (!f->transmitted) {
/* Send it now... */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Finally transmitting %d, since window opened up\n", f->h.n_s);
f->transmitted++;
pri->windowlen++;
@@ -208,7 +211,7 @@ static void reschedule_t203(struct pri *pri)
{
if (pri->t203_timer) {
pri_schedule_del(pri, pri->t203_timer);
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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);
@@ -231,31 +234,31 @@ static pri_event *q921_ack_rx(struct pri *pri, int ack)
return ev;
}
/* Cancel each packet as necessary */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- ACKing all packets from %d to (but not including) %d\n", pri->v_a, ack);
for (x=pri->v_a; x != ack; Q921_INC(x))
cnt += q921_ack_packet(pri, x);
if (!pri->txqueue) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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->t203_timer) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Stopping T203 counter since we got an ACK\n");
pri_schedule_del(pri, pri->t203_timer);
pri->t203_timer = 0;
}
if (pri->txqueue) {
/* Something left to transmit, Start the T200 counter again if we stopped it */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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);
} else {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Nothing left, starting 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);
@@ -283,7 +286,7 @@ static void q921_reject(struct pri *pri, int pf)
pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
return;
}
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Sending Reject (%d)\n", pri->v_r);
pri->sentrej = 1;
q921_transmit(pri, &h, 4);
@@ -315,7 +318,7 @@ static void q921_rr(struct pri *pri, int pbit, int cmd) {
return;
}
pri->v_na = pri->v_r; /* Make a note that we've already acked this */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Sending Receiver Ready (%d)\n", pri->v_r);
q921_transmit(pri, &h, 4);
}
@@ -325,7 +328,7 @@ static void t200_expire(void *vpri)
struct pri *pri = vpri;
if (pri->txqueue) {
/* Retransmit first packet in the queue, setting the poll bit */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- T200 counter expired, What to do...\n");
/* Force Poll bit */
pri->txqueue->h.p_f = 1;
@@ -337,7 +340,7 @@ static void t200_expire(void *vpri)
/* Up to three retransmissions */
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
/* Reschedule t200_timer */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len);
if (pri->busy)
q921_rr(pri, 1, 1);
@@ -346,14 +349,12 @@ static void t200_expire(void *vpri)
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)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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)
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);
@@ -361,7 +362,7 @@ static void t200_expire(void *vpri)
pri->schedev = 1;
}
} else if (pri->solicitfbit) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Retrying poll with f-bit\n");
pri->retrans++;
if (pri->retrans < pri->timers[PRI_TIMER_N200]) {
@@ -369,10 +370,8 @@ static void t200_expire(void *vpri)
q921_rr(pri, 1, 1);
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
} else {
if (pri->debug & PRI_DEBUG_Q921_STATE)
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);
@@ -429,23 +428,23 @@ int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)
q921_transmit(pri, (q921_h *)(&f->h), f->len);
f->transmitted++;
} else {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Delaying transmission of %d, window is %d/%d long\n",
f->h.n_s, pri->windowlen, pri->window);
}
}
if (pri->t203_timer) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "Stopping T_203 timer\n");
pri_schedule_del(pri, pri->t203_timer);
pri->t203_timer = 0;
}
if (!pri->t200_timer) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "T_200 timer already going (%d)\n", pri->t200_timer);
} else {
@@ -459,7 +458,7 @@ static void t203_expire(void *vpri)
{
struct pri *pri = vpri;
if (pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "T203 counter expired, sending RR and scheduling T203 again\n");
/* Solicit an F-bit in the other's RR */
pri->solicitfbit = 1;
@@ -468,7 +467,7 @@ static void t203_expire(void *vpri)
/* Start timer T200 to resend our RR if we don't get it */
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
} else {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "T203 counter expired in weird state %d\n", pri->q921_state);
pri->t203_timer = 0;
}
@@ -660,16 +659,11 @@ static pri_event *q921_dchannel_up(struct pri *pri)
pri->sentrej = 0;
/* Go into connection established state */
if (pri->debug & PRI_DEBUG_Q921_STATE && pri->q921_state != Q921_LINK_CONNECTION_ESTABLISHED)
pri_message(pri, DBGHEAD "q921_state now is Q921_LINK_CONNECTION_ESTABLISHED\n", DBGINFO);
pri->q921_state = Q921_LINK_CONNECTION_ESTABLISHED;
/* Start the T203 timer */
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
/* Notify Layer 3 */
q931_dl_indication(pri, PRI_EVENT_DCHAN_UP);
/* Report event that D-Channel is now up */
pri->ev.gen.e = PRI_EVENT_DCHAN_UP;
return &pri->ev;
@@ -680,9 +674,6 @@ static pri_event *q921_dchannel_down(struct pri *pri)
/* Reset counters, reset sabme timer etc */
q921_reset(pri);
/* Notify Layer 3 */
q931_dl_indication(pri, PRI_EVENT_DCHAN_DOWN);
/* Report event that D-Channel is now up */
pri->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
return &pri->ev;
@@ -705,8 +696,6 @@ void q921_reset(struct pri *pri)
pri->t200_timer = 0;
pri->busy = 0;
pri->solicitfbit = 0;
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->retrans = 0;
pri->sentrej = 0;
@@ -755,10 +744,10 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
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 (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Got RR response to our frame\n");
} else {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Unsolicited RR with P/F bit, responding\n");
q921_rr(pri, 1, 0);
}
@@ -767,7 +756,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
break;
case 1:
/* Receiver not ready */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Got receiver not ready\n");
if(h->s.p_f) {
/* Send RR if poll bit set */
@@ -777,7 +766,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
break;
case 2:
/* Just retransmit */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
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 */
@@ -834,7 +823,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
if (h->u.p_f) {
/* Section 5.7.1 says we should restart on receiving a DM response with the f-bit set to
one, but we wait T200 first */
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Got DM Mode from peer.\n");
/* Disconnected mode, try again after T200 */
ev = q921_dchannel_down(pri);
@@ -842,7 +831,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
return ev;
} else {
if (pri->debug & PRI_DEBUG_Q921_DUMP)
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Ignoring unsolicited DM with p/f set to 0\n");
#if 0
/* Requesting that we start */
@@ -855,7 +844,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
}
break;
case 2:
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP))
if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Got Disconnect from peer.\n");
/* Acknowledge */
q921_send_ua(pri, h->u.p_f);
@@ -865,7 +854,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
case 3:
if (h->u.m2 == 3) {
/* SABME */
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP)) {
if (pri->debug & PRI_DEBUG_Q921_STATE) {
pri_message(pri, "-- Got SABME from %s peer.\n", h->h.c_r ? "network" : "cpe");
}
if (h->h.c_r) {
@@ -887,7 +876,7 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
} else if (h->u.m2 == 0) {
/* It's a UA */
if (pri->q921_state == Q921_AWAITING_ESTABLISH) {
if (pri->debug & (PRI_DEBUG_Q921_STATE | PRI_DEBUG_Q921_DUMP)) {
if (pri->debug & PRI_DEBUG_Q921_STATE) {
pri_message(pri, "-- Got UA from %s peer Link up.\n", h->h.c_r ? "cpe" : "network");
}
return q921_dchannel_up(pri);
@@ -917,7 +906,7 @@ static pri_event *__q921_receive(struct pri *pri, q921_h *h, int len)
/* Discard FCS */
len -= 2;
if (!pri->master && pri->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
if (!pri->master && pri->debug & PRI_DEBUG_Q921_DUMP)
q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
/* Check some reject conditions -- Start by rejecting improper ea's */

714
q931.c

File diff suppressed because it is too large Load Diff

View File

@@ -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
@@ -42,7 +48,11 @@
#include <sys/time.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <zaptel/zaptel.h>
#if defined(__linux__)
#include <linux/zaptel.h>
#elif defined(__FreeBSD__) || defined(SOLARIS)
#include <zaptel.h>
#endif
#ifndef SOLARIS
#include <zap.h>
#endif
@@ -143,7 +153,7 @@ static void event2(struct pri *pri, pri_event *e)
}
}
static void testmsg(struct pri *pri, char *s)
static void testmsg(char *s)
{
char *c;
static int keeplast = 0;
@@ -169,7 +179,7 @@ static void testmsg(struct pri *pri, char *s)
keeplast = 0;
}
static void testerr(struct pri *pri, char *s)
static void testerr(char *s)
{
char *c;
static int keeplast = 0;
@@ -260,7 +270,6 @@ int main(int argc, char *argv[])
}
first = pri;
pri_set_debug(pri, DEBUG_LEVEL);
pri_facility_enable(pri);
if (pthread_create(&tmp, NULL, dchan, pri)) {
perror("thread(0)");
exit(1);
@@ -270,7 +279,6 @@ int main(int argc, char *argv[])
exit(1);
}
pri_set_debug(pri, DEBUG_LEVEL);
pri_facility_enable(pri);
if (pthread_create(&tmp, NULL, dchan, pri)) {
perror("thread(1)");
exit(1);