Compare commits

..

4 Commits

Author SHA1 Message Date
Kevin P. Fleming
7dcf8a8906 remove CVS ignore lists
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.2.0-beta1@267 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-29 18:40:06 +00:00
Kevin P. Fleming
a468a4ea77 remove extraneous svn:executable properties
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.2.0-beta1@266 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-29 18:39:18 +00:00
Kevin P. Fleming
ef415db74a manual tag renames
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.2.0-beta1@262 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-11-27 04:16:28 +00:00
Admin Commit
44f6938952 This commit was manufactured by cvs2svn to create tag 'v1-2-0-beta1'.
git-svn-id: https://origsvn.digium.com/svn/libpri/tags/v1-2-0-beta1@244 2fbb986a-6c06-0410-b554-c9c1f0a7f128
2005-07-27 13:14:05 +00:00
20 changed files with 363 additions and 979 deletions

View File

@@ -1 +0,0 @@
1.2.8

200
ChangeLog
View File

@@ -1,186 +1,16 @@
2008-08-05 Kevin P. Fleming <kpfleming@digium.com> libpri 0.3.0
-- Fix talking to switch
* libpri 1.2.8 Released -- Add pri dump
-- Add test application
2008-08-05 22:16 +0000 [r610] Kevin P. Fleming <kpfleming@digium.com> -- Fix strncpy stuff
libpri 0.1.2
* pritest.c, pri.c, pri_internal.h, q921.c, q931.c, copy_string.c, -- Added PRI_EVENT_HANGUP_ACK so you can know when the disconnect was
prisched.c, pri_q921.h, pri_q931.h, pri_facility.c, compiler.h, acknowledged
pridump.c, testprilib.c, pri_timers.h, pri_facility.h, libpri.h:
clean up license headers, and explicitly grant additional libpri 0.1.1
permissions when used with Asterisk -- Added PRI_DEBUG_Q931_ANOMALY flag so that certain non-error-related
messages would not be output unless specifically desired.
2008-06-04 16:59 +0000 [r561] Dwayne M. Hubbard <dhubbard@digium.com>
libpri 0.1.0
* q931.c: While working on issue 3450 I noticed that the -- Initial release
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-02-20 21:36 +0000 [r527] Matthew Fredrickson <creslin@digium.com>
* q931.c: Don't send a status error when we receive connect
acknowledge during an active state
2008-02-18 20:31 +0000 [r521-523] Matthew Fredrickson <creslin@digium.com>
* q931.c, libpri.h: Improve transmission, receiving, and dumping of
bearer capability IE (#11593)
* q931.c, libpri.h: Revert previous commit 521
* 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.

View File

@@ -30,7 +30,7 @@
CC=gcc CC=gcc
OSARCH=$(shell uname -s) OSARCH=$(shell uname -s)
PROC?=$(shell uname -m) PROC=$(shell uname -m)
TOBJS=testpri.o TOBJS=testpri.o
T2OBJS=testprilib.o T2OBJS=testprilib.o
@@ -38,12 +38,10 @@ STATIC_LIBRARY=libpri.a
DYNAMIC_LIBRARY=libpri.so.1.0 DYNAMIC_LIBRARY=libpri.so.1.0
STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o 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_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS) CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS)
INSTALL_PREFIX=$(DESTDIR) INSTALL_PREFIX=
INSTALL_BASE=/usr INSTALL_BASE=/usr
SOFLAGS = -Wl,-hlibpri.so.1.0 ifeq (${OSARCH},Linux)
LDCONFIG = /sbin/ldconfig
ifneq (,$(findstring $(OSARCH), Linux GNU/kFreeBSD))
LDCONFIG_FLAGS=-n LDCONFIG_FLAGS=-n
else else
ifeq (${OSARCH},FreeBSD) ifeq (${OSARCH},FreeBSD)
@@ -52,11 +50,13 @@ CFLAGS += -I../zaptel -I../zapata
endif endif
endif endif
ifeq (${OSARCH},SunOS) ifeq (${OSARCH},SunOS)
CFLAGS += -DSOLARIS -I../zaptel-solaris CFLAGS += -DSOLARIS -I../zaptel-solaris -lsocket -lnsl
LDCONFIG = SOFLAGS =
LDCONFIG_FLAGS = \# # Trick to comment out the period in the command below LDCONFIG = echo
SOSLINK = ln -sf libpri.so.1.0 libpri.so.1 INSTALL_BASE = /usr/local
#INSTALL_PREFIX = /opt/asterisk # Uncomment out to install in standard Solaris location for 3rd party code else
SOFLAGS = -Wl,-soname,libpri.so.1
LDCONFIG = /sbin/ldconfig
endif endif
#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only. #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
@@ -70,40 +70,29 @@ endif
all: depend $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY) all: depend $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
update: update:
@if [ -d .svn ]; then \ @if [ -d CVS ]; then \
echo "Updating from Subversion..." ; \
svn update -q; \
elif [ -d CVS ]; then \
echo "Updating from CVS..." ; \ echo "Updating from CVS..." ; \
cvs -q -z3 update -Pd; \ cvs -q -z3 update -Pd; \
else \ else \
echo "Not under version control"; \ echo "Not CVS"; \
fi fi
install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY) install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/lib mkdir -p $(INSTALL_PREFIX)/$(INSTALL_BASE)/lib
mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/include mkdir -p $(INSTALL_PREFIX)/$(INSTALL_BASE)/include
ifneq (${OSARCH},SunOS) install -m 644 libpri.h $(INSTALL_PREFIX)/$(INSTALL_BASE)/include
install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)/$(INSTALL_BASE)/lib
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 restorecon -v $(INSTALL_PREFIX)/$(INSTALL_BASE)/lib/$(DYNAMIC_LIBRARY); fi
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 libpri.so )
( 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
install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(INSTALL_BASE)/lib $(LDCONFIG)
if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(INSTALL_BASE)/lib; 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)
endif
uninstall: uninstall:
@echo "Removing Libpri" @echo "Removing Libpri"
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.so.1.0 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.so rm -f $(INSTALL_PREFIX)/$(INSTALL_BASE)/lib/libpri.a
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/lib/libpri.a rm -f $(INSTALL_PREFIX)/$(INSTALL_BASE)/include/libpri.h
rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include/libpri.h
pritest: pritest.o pritest: pritest.o
$(CC) -o pritest pritest.o -L. -lpri -lzap $(CFLAGS) $(CC) -o pritest pritest.o -L. -lpri -lzap $(CFLAGS)
@@ -122,7 +111,7 @@ include .depend
endif endif
%.lo : %.c %.lo : %.c
$(CC) $(CFLAGS) -o $@ -c $< $(CC) -fPIC $(CFLAGS) -o $@ -c $<
$(STATIC_LIBRARY): $(STATIC_OBJS) $(STATIC_LIBRARY): $(STATIC_OBJS)
ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS) ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
@@ -131,9 +120,7 @@ $(STATIC_LIBRARY): $(STATIC_OBJS)
$(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS) $(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
$(CC) -shared $(SOFLAGS) -o $@ $(DYNAMIC_OBJS) $(CC) -shared $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
$(LDCONFIG) $(LDCONFIG_FLAGS) . $(LDCONFIG) $(LDCONFIG_FLAGS) .
ln -sf libpri.so.1.0 libpri.so ln -sf libpri.so.1 libpri.so
ln -sf libpri.so.1.0 libpri.so.1
$(SOSLINK)
clean: clean:
rm -f *.o *.so *.lo *.so.1 *.so.1.0 rm -f *.o *.so *.lo *.so.1 *.so.1.0
@@ -144,4 +131,4 @@ clean:
depend: .depend depend: .depend
.depend: .depend:
CC=$(CC) ./mkdep ${CFLAGS} `ls *.c` ./mkdep ${CFLAGS} `ls *.c`

2
README
View File

@@ -1,4 +1,4 @@
libpri: An implementation of Primary Rate ISDN libpri: An implementation of Primate Rate ISDN
Written by Mark Spencer <markster@digium.com> Written by Mark Spencer <markster@digium.com>

View File

@@ -4,26 +4,9 @@
* Compiler-specific macros and other items * Compiler-specific macros and other items
* *
* Copyright (C) 2005, Digium, Inc. * 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 * This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the * the GNU General Public License
* 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 #ifndef _ASTERISK_COMPILER_H

View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2005, Digium, Inc. * Copyright (C) 2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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> #include <string.h>

View File

@@ -1,30 +1,25 @@
/* /*
* libpri: An implementation of Primary Rate ISDN * libpri: An implementation of Primary Rate ISDN
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@linux-support.net>
* *
* Copyright (C) 2001, Digium, Inc. * Copyright (C) 2001, Linux Support Services, Inc.
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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 #ifndef _LIBPRI_H
@@ -210,52 +205,6 @@
#define PRI_LAYER_1_V120_RATE_ADAPT 0x28 #define PRI_LAYER_1_V120_RATE_ADAPT 0x28
#define PRI_LAYER_1_X31_RATE_ADAPT 0x29 #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 */ /* Notifications */
#define PRI_NOTIFY_USER_SUSPENDED 0x00 /* User suspended */ #define PRI_NOTIFY_USER_SUSPENDED 0x00 /* User suspended */
#define PRI_NOTIFY_USER_RESUMED 0x01 /* User resumed */ #define PRI_NOTIFY_USER_RESUMED 0x01 /* User resumed */
@@ -325,7 +274,6 @@ typedef struct pri_event_ringing {
int progress; int progress;
int progressmask; int progressmask;
q931_call *call; q931_call *call;
char useruserinfo[260]; /* User->User info */
} pri_event_ringing; } pri_event_ringing;
typedef struct pri_event_answer { typedef struct pri_event_answer {
@@ -335,7 +283,6 @@ typedef struct pri_event_answer {
int progress; int progress;
int progressmask; int progressmask;
q931_call *call; q931_call *call;
char useruserinfo[260]; /* User->User info */
} pri_event_answer; } pri_event_answer;
typedef struct pri_event_facname { typedef struct pri_event_facname {
@@ -348,7 +295,6 @@ typedef struct pri_event_facname {
} pri_event_facname; } pri_event_facname;
#define PRI_CALLINGPLANANI #define PRI_CALLINGPLANANI
#define PRI_CALLINGPLANRDNIS
typedef struct pri_event_ring { typedef struct pri_event_ring {
int e; int e;
int channel; /* Channel requested */ int channel; /* Channel requested */
@@ -364,8 +310,7 @@ typedef struct pri_event_ring {
char redirectingnum[256]; /* Redirecting number */ char redirectingnum[256]; /* Redirecting number */
char redirectingname[256]; /* Redirecting name */ char redirectingname[256]; /* Redirecting name */
int redirectingreason; /* Reason for redirect */ int redirectingreason; /* Reason for redirect */
int callingplanrdnis; /* Dialing plan of Redirecting Number */ char useruserinfo[256]; /* User->User info */
char useruserinfo[260]; /* User->User info */
int flexible; /* Are we flexible with our channel selection? */ int flexible; /* Are we flexible with our channel selection? */
int cref; /* Call Reference Number */ int cref; /* Call Reference Number */
int ctype; /* Call type (see PRI_TRANS_CAP_* */ int ctype; /* Call type (see PRI_TRANS_CAP_* */
@@ -377,7 +322,6 @@ typedef struct pri_event_ring {
int progressmask; int progressmask;
char origcalledname[256]; char origcalledname[256];
char origcallednum[256]; char origcallednum[256];
int callingplanorigcalled; /* Dialing plan of Originally Called Number */
int origredirectingreason; int origredirectingreason;
} pri_event_ring; } pri_event_ring;
@@ -388,7 +332,6 @@ typedef struct pri_event_hangup {
int cref; int cref;
q931_call *call; /* Opaque call pointer */ q931_call *call; /* Opaque call pointer */
long aoc_units; /* Advise of Charge number of charged units */ long aoc_units; /* Advise of Charge number of charged units */
char useruserinfo[260]; /* User->User info */
} pri_event_hangup; } pri_event_hangup;
typedef struct pri_event_restart_ack { typedef struct pri_event_restart_ack {
@@ -410,7 +353,6 @@ typedef struct pri_event_proceeding {
typedef struct pri_event_setup_ack { typedef struct pri_event_setup_ack {
int e; int e;
int channel; int channel;
q931_call *call;
} pri_event_setup_ack; } pri_event_setup_ack;
typedef struct pri_event_notify { typedef struct pri_event_notify {
@@ -542,9 +484,6 @@ extern int pri_hangup(struct pri *pri, q931_call *call, int cause);
#define PRI_DESTROYCALL #define PRI_DESTROYCALL
extern void pri_destroycall(struct pri *pri, q931_call *call); extern void pri_destroycall(struct pri *pri, q931_call *call);
#define PRI_RESTART
extern int pri_restart(struct pri *pri);
extern int pri_reset(struct pri *pri, int channel); extern int pri_reset(struct pri *pri, int channel);
/* Create a new call */ /* Create a new call */
@@ -561,7 +500,6 @@ extern struct timeval *pri_schedule_next(struct pri *pri);
/* Run any pending schedule events */ /* Run any pending schedule events */
extern pri_event *pri_schedule_run(struct pri *pri); 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, 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, int exclusive, int nonisdn, char *caller, int callerplan, char *callername, int callerpres,
@@ -575,11 +513,6 @@ 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_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_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); 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, 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); extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);

74
pri.c
View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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> #include <unistd.h>
@@ -252,27 +247,6 @@ static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *maste
return p; return p;
} }
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, char *userchars)
{
sr->useruserinfo = userchars;
}
int pri_restart(struct pri *pri)
{
/* Restart Q.921 layer */
if (pri) {
q921_reset(pri);
q921_start(pri, pri->localtype == PRI_CPE);
}
return 0;
}
struct pri *pri_new(int fd, int nodetype, int switchtype) 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(fd, nodetype, switchtype, NULL, __pri_read, __pri_write, NULL);
@@ -526,30 +500,24 @@ int pri_channel_bridge(q931_call *call1, q931_call *call2)
if (!call1 || !call2) if (!call1 || !call2)
return -1; return -1;
/* Make sure we have compatible switchtypes */ /* Check switchtype compatibility */
if (call1->pri->switchtype != call2->pri->switchtype) if (call1->pri->switchtype != PRI_SWITCH_LUCENT5E ||
call2->pri->switchtype != PRI_SWITCH_LUCENT5E)
return -1; return -1;
/* Check for bearer capability */ /* Check for bearer capability */
if (call1->transcapability != call2->transcapability) if (call1->transcapability != call2->transcapability)
return -1; return -1;
/* Check to see if calls are on the same PRI dchannel
/* Check to see if we're on the same PRI */ * Currently only support calls on the same dchannel
*/
if (call1->pri != call2->pri) if (call1->pri != call2->pri)
return -1; 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)) if (eect_initiate_transfer(call1->pri, call1, call2))
return -1; return -1;
else
return 0; return 0;
break;
default:
return -1;
}
} }
int pri_hangup(struct pri *pri, q931_call *call, int cause) int pri_hangup(struct pri *pri, q931_call *call, int cause)

View File

@@ -3,28 +3,23 @@
* *
* Written by Matthew Fredrickson <creslin@digium.com> * Written by Matthew Fredrickson <creslin@digium.com>
* *
* Copyright (C) 2004-2005, Digium, Inc. * Copyright (C) 2004-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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" #include "compat.h"
@@ -726,13 +721,11 @@ static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS); buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
/* Interpretation component */ /* Interpretation component */
if (pri->switchtype == PRI_SWITCH_QSIG) {
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i); ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
ASN1_PUSH(compstk, compsp, comp); 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_0), buffer, i, 0);
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0);
ASN1_FIXUP(compstk, compsp, buffer, i); ASN1_FIXUP(compstk, compsp, buffer, i);
}
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0);
@@ -769,13 +762,11 @@ static int add_callername_facility_ies(struct pri *pri, q931_call *c, int cpe)
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS); buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_EXTENSIONS);
/* Interpretation component */ /* Interpretation component */
if (pri->switchtype == PRI_SWITCH_QSIG) {
ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i); ASN1_ADD_SIMPLE(comp, COMP_TYPE_NFE, buffer, i);
ASN1_PUSH(compstk, compsp, comp); 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_0), buffer, i, 0);
ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0); ASN1_ADD_BYTECOMP(comp, (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_2), buffer, i, 0);
ASN1_FIXUP(compstk, compsp, buffer, i); ASN1_FIXUP(compstk, compsp, buffer, i);
}
ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0); ASN1_ADD_BYTECOMP(comp, COMP_TYPE_INTERPRETATION, buffer, i, 0);
@@ -864,10 +855,13 @@ extern int mwi_message_send(struct pri* pri, q931_call *call, struct pri_sr *req
/* EECT functions */ /* EECT functions */
extern 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 i = 0;
int res = 0; int res = 0;
unsigned char buffer[255] = ""; unsigned char buffer[255] = "";
short call_reference = c2->cr ^ 0x8000; /* Let's do the trickery to make sure the flag is correct */ unsigned short call_reference = c2->cr;
struct rose_component *comp = NULL, *compstk[10]; struct rose_component *comp = NULL, *compstk[10];
int compsp = 0; int compsp = 0;
static unsigned char op_tag[] = { static unsigned char op_tag[] = {
@@ -880,7 +874,16 @@ extern int eect_initiate_transfer(struct pri *pri, q931_call *c1, q931_call *c2)
0x08, 0x08,
}; };
buffer[i++] = (ASN1_CONTEXT_SPECIFIC | Q932_PROTOCOL_ROSE); 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);
ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i); ASN1_ADD_SIMPLE(comp, COMP_TYPE_INVOKE, buffer, i);
ASN1_PUSH(compstk, compsp, comp); ASN1_PUSH(compstk, compsp, comp);
@@ -1133,17 +1136,13 @@ extern int rose_invoke_decode(struct pri *pri, q931_call *call, unsigned char *d
do { do {
/* Invoke ID stuff */ /* Invoke ID stuff */
GET_COMPONENT(comp, i, vdata, len); GET_COMPONENT(comp, i, vdata, len);
#if 0
CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n"); CHECK_COMPONENT(comp, INVOKE_IDENTIFIER, "Don't know what to do if first ROSE component is of type 0x%x\n");
#endif
invokeid = comp; invokeid = comp;
NEXT_COMPONENT(comp, i); NEXT_COMPONENT(comp, i);
/* Operation Tag */ /* Operation Tag */
GET_COMPONENT(comp, i, vdata, len); GET_COMPONENT(comp, i, vdata, len);
#if 0
CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second ROSE component is of type 0x%x\n"); CHECK_COMPONENT(comp, ASN1_INTEGER, "Don't know what to do if second ROSE component is of type 0x%x\n");
#endif
operationid = comp; operationid = comp;
ASN1_GET_INTEGER(comp, operation_tag); ASN1_GET_INTEGER(comp, operation_tag);
NEXT_COMPONENT(comp, i); NEXT_COMPONENT(comp, i);
@@ -1300,10 +1299,9 @@ extern int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
return 0; return 0;
if (pri->switchtype == PRI_SWITCH_QSIG) { /* For Q.SIG it does network and cpe operations */ if (pri->switchtype == PRI_SWITCH_QSIG) { /* For Q.SIG it does network and cpe operations */
if (call->redirectingnum[0]) /* FIXME: Presumably, it should only send on a redirect */
rose_diverting_leg_information2_encode(pri, call); rose_diverting_leg_information2_encode(pri, call);
add_callername_facility_ies(pri, call, 1); add_callername_facility_ies(pri, call, 1);
return 0;
} }
if (pri->localtype == PRI_NETWORK) { if (pri->localtype == PRI_NETWORK) {
@@ -1314,7 +1312,6 @@ extern int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
default: default:
break; break;
} }
return 0;
} else if (pri->localtype == PRI_CPE) { } else if (pri->localtype == PRI_CPE) {
switch (pri->switchtype) { switch (pri->switchtype) {
case PRI_SWITCH_NI2: case PRI_SWITCH_NI2:
@@ -1323,7 +1320,6 @@ extern int pri_call_add_standard_apdus(struct pri *pri, q931_call *call)
default: default:
break; break;
} }
return 0;
} }
return 0; return 0;

View File

@@ -7,26 +7,6 @@
Copyright (C) Digium, Inc. 2004-2005 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 #ifndef _PRI_FACILITY_H
#define _PRI_FACILITY_H #define _PRI_FACILITY_H

View File

@@ -1,36 +1,30 @@
/* /*
* libpri: An implementation of Primary Rate ISDN * libpri: An implementation of Primary Rate ISDN
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@linux-support.net>
* *
* Copyright (C) 2001, Digium, Inc. * Copyright (C) 2001, Linux Support Services, Inc.
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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 #ifndef _PRI_INTERNAL_H
#define _PRI_INTERNAL_H #define _PRI_INTERNAL_H
#include <stddef.h>
#include <sys/time.h> #include <sys/time.h>
struct pri_sched { struct pri_sched {
@@ -135,7 +129,6 @@ struct pri_sr {
int redirectingpres; int redirectingpres;
int redirectingreason; int redirectingreason;
int justsignalling; int justsignalling;
char *useruserinfo;
}; };
/* Internal switch types */ /* Internal switch types */

View File

@@ -1,30 +1,25 @@
/* /*
* libpri: An implementation of Primary Rate ISDN * libpri: An implementation of Primary Rate ISDN
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@linux-support.net>
* *
* Copyright (C) 2001, Digium, Inc. * Copyright (C) 2001, Linux Support Services, Inc.
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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 #ifndef _PRI_Q921_H

View File

@@ -1,30 +1,25 @@
/* /*
* libpri: An implementation of Primary Rate ISDN * libpri: An implementation of Primary Rate ISDN
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@linux-support.net>
* *
* Copyright (C) 2001, Digium, Inc. * Copyright (C) 2001, Linux Support Services, Inc.
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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 #ifndef _PRI_Q931_H

View File

@@ -1,30 +1,25 @@
/* /*
* libpri: An implementation of Primary Rate ISDN * libpri: An implementation of Primary Rate ISDN
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@linux-support.net>
* *
* Copyright (C) 2001, Digium, Inc. * Copyright (C) 2001, Linux Support Services, Inc.
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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 #ifndef _PRI_TIMERS_H

View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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.
*/ */
/* /*

View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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> #include <stdio.h>

View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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.
*/ */
/* /*

35
q921.c
View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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> #include <stdio.h>
@@ -343,7 +338,7 @@ static void t200_expire(void *vpri)
if (pri->debug & PRI_DEBUG_Q921_STATE) if (pri->debug & PRI_DEBUG_Q921_STATE)
pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len); pri_message(pri, "-- Retransmitting %d bytes\n", pri->txqueue->len);
if (pri->busy) if (pri->busy)
q921_rr(pri, 1, 1); q921_rr(pri, 1, 0);
else { else {
if (!pri->txqueue->transmitted) if (!pri->txqueue->transmitted)
pri_error(pri, "!! Not good - head of queue has not been transmitted yet\n"); pri_error(pri, "!! Not good - head of queue has not been transmitted yet\n");

407
q931.c
View File

@@ -3,28 +3,23 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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" #include "compat.h"
@@ -48,7 +43,7 @@ struct msgtype {
int mandies[MAX_MAND_IES]; int mandies[MAX_MAND_IES];
}; };
static struct msgtype msgs[] = { struct msgtype msgs[] = {
/* Call establishment messages */ /* Call establishment messages */
{ Q931_ALERTING, "ALERTING" }, { Q931_ALERTING, "ALERTING" },
{ Q931_CALL_PROCEEDING, "CALL PROCEEDING" }, { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
@@ -94,7 +89,7 @@ static struct msgtype msgs[] = {
{ NATIONAL_SERVICE_ACKNOWLEDGE, "SERVICE ACKNOWLEDGE" }, { NATIONAL_SERVICE_ACKNOWLEDGE, "SERVICE ACKNOWLEDGE" },
}; };
static struct msgtype causes[] = { struct msgtype causes[] = {
{ PRI_CAUSE_UNALLOCATED, "Unallocated (unassigned) number" }, { PRI_CAUSE_UNALLOCATED, "Unallocated (unassigned) number" },
{ PRI_CAUSE_NO_ROUTE_TRANSIT_NET, "No route to specified transmit network" }, { PRI_CAUSE_NO_ROUTE_TRANSIT_NET, "No route to specified transmit network" },
{ PRI_CAUSE_NO_ROUTE_DESTINATION, "No route to destination" }, { PRI_CAUSE_NO_ROUTE_DESTINATION, "No route to destination" },
@@ -141,7 +136,7 @@ static struct msgtype causes[] = {
{ PRI_CAUSE_INTERWORKING, "Interworking, unspecified" }, { PRI_CAUSE_INTERWORKING, "Interworking, unspecified" },
}; };
static struct msgtype facilities[] = { struct msgtype facilities[] = {
{ PRI_NSF_SID_PREFERRED, "CPN (SID) preferred" }, { PRI_NSF_SID_PREFERRED, "CPN (SID) preferred" },
{ PRI_NSF_ANI_PREFERRED, "BN (ANI) preferred" }, { PRI_NSF_ANI_PREFERRED, "BN (ANI) preferred" },
{ PRI_NSF_SID_ONLY, "CPN (SID) only" }, { PRI_NSF_SID_ONLY, "CPN (SID) only" },
@@ -366,7 +361,7 @@ static FUNC_SEND(transmit_channel_id)
return 0; return 0;
} }
if (((pri->switchtype != PRI_SWITCH_QSIG) && (call->ds1no > 0)) || call->ds1explicit) { if ((call->ds1no > 0) || call->ds1explicit) {
/* Note that we are specifying the identifier */ /* Note that we are specifying the identifier */
ie->data[pos++] |= 0x40; ie->data[pos++] |= 0x40;
/* We need to use the Channel Identifier Present thingy. Just specify it and we're done */ /* We need to use the Channel Identifier Present thingy. Just specify it and we're done */
@@ -404,7 +399,7 @@ static FUNC_DUMP(dump_channel_id)
int x; int x;
int res = 0; int res = 0;
static const char* msg_chan_sel[] = { 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" "No channel selected", "As indicated in following octets", "Reserved","Any channel selected"
}; };
@@ -533,12 +528,12 @@ static char *mode2str(int mode)
static char *l12str(int proto) static char *l12str(int proto)
{ {
static struct msgtype protos[] = { static struct msgtype protos[] = {
{ PRI_LAYER_1_ITU_RATE_ADAPT, "V.110 Rate Adaption" }, { PRI_LAYER_1_ITU_RATE_ADAPT, "ITU Rate Adaption" },
{ PRI_LAYER_1_ULAW, "u-Law" }, { PRI_LAYER_1_ULAW, "u-Law" },
{ PRI_LAYER_1_ALAW, "A-Law" }, { PRI_LAYER_1_ALAW, "A-Law" },
{ PRI_LAYER_1_G721, "G.721 ADPCM" }, { PRI_LAYER_1_G721, "G.721 ADPCM" },
{ PRI_LAYER_1_G722_G725, "G.722/G.725 7kHz Audio" }, { PRI_LAYER_1_G722_G725, "G.722/G.725 7kHz Audio" },
{ PRI_LAYER_1_G7XX_384K, "H.223/H.245 Multimedia" }, { PRI_LAYER_1_G7XX_384K, "G.7xx 384k Video" },
{ PRI_LAYER_1_NON_ITU_ADAPT, "Non-ITU Rate Adaption" }, { PRI_LAYER_1_NON_ITU_ADAPT, "Non-ITU Rate Adaption" },
{ PRI_LAYER_1_V120_RATE_ADAPT, "V.120 Rate Adaption" }, { PRI_LAYER_1_V120_RATE_ADAPT, "V.120 Rate Adaption" },
{ PRI_LAYER_1_X31_RATE_ADAPT, "X.31 Rate Adaption" }, { PRI_LAYER_1_X31_RATE_ADAPT, "X.31 Rate Adaption" },
@@ -549,7 +544,7 @@ static char *l12str(int proto)
static char *ra2str(int proto) static char *ra2str(int proto)
{ {
static struct msgtype protos[] = { static struct msgtype protos[] = {
{ PRI_RATE_ADAPT_9K6, "9.6 kbit/s" }, { RATE_ADAPT_56K, "from 56kbps" },
}; };
return code2str(proto, protos, sizeof(protos) / sizeof(protos[0])); return code2str(proto, protos, sizeof(protos) / sizeof(protos[0]));
} }
@@ -570,144 +565,32 @@ static char *l32str(int proto)
return code2str(proto, protos, sizeof(protos) / sizeof(protos[0])); 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) static FUNC_DUMP(dump_bearer_capability)
{ {
int pos=2; int pos=2;
pri_message(pri, "%c Bearer Capability (len=%2d) [ Ext: %d Q.931 Std: %d Info transfer capability: %s (%d)\n", 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)); 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); 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) { 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); pri_message(pri, "%c Ext: %d Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
pos++; pos++;
} }
/* Stop here if no more */
/* don't count the IE num and length as part of the data */ if (pos >= len)
len -= 2; return;
if ((ie->data[1] & 0x7f) != TRANS_MODE_PACKET) {
/* Look for octet 5; this is identified by bits 5,6 == 01 */ /* Look for octets 5 and 5.a if present */
if (pos < len && 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);
(ie->data[pos] & 0x60) == 0x20) { 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);
/* 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++; pos++;
/* 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 { } else {
pri_message(pri, "%c Unknown octet 5b: 0x%x\n", data ); /* 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);
pos++; 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);
/* 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++; 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++;
}
/* 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;
}
}
} }
static FUNC_RECV(receive_bearer_capability) static FUNC_RECV(receive_bearer_capability)
@@ -719,44 +602,18 @@ static FUNC_RECV(receive_bearer_capability)
} }
call->transcapability = ie->data[0] & 0x1f; call->transcapability = ie->data[0] & 0x1f;
call->transmoderate = ie->data[1] & 0x7f; call->transmoderate = ie->data[1] & 0x7f;
if (call->transmoderate == PRI_TRANS_CAP_AUDIO_4ESS)
/* octet 4.1 exists iff mode/rate is multirate */ call->transmoderate = PRI_TRANS_CAP_3_1K_AUDIO;
if (call->transmoderate == TRANS_MODE_MULTIRATE) { if (call->transmoderate != TRANS_MODE_PACKET) {
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; call->userl1 = ie->data[pos] & 0x7f;
if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
call->rateadaption = ie->data[++pos] & 0x7f;
}
pos++; pos++;
} else {
/* octet 5a? */ /* Get 6 and 7 */
if (pos < len && !(ie->data[pos-1] & 0x80)) { call->userl2 = ie->data[pos++] & 0x7f;
call->rateadaption = ie->data[pos] & 0x7f; call->userl3 = 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; return 0;
} }
@@ -764,7 +621,6 @@ static FUNC_RECV(receive_bearer_capability)
static FUNC_SEND(transmit_bearer_capability) static FUNC_SEND(transmit_bearer_capability)
{ {
int tc; int tc;
int pos;
/* We are ready to transmit single IE only */ /* We are ready to transmit single IE only */
if(order > 1) if(order > 1)
@@ -791,39 +647,26 @@ static FUNC_SEND(transmit_bearer_capability)
} }
ie->data[0] = 0x80 | tc; ie->data[0] = 0x80 | tc;
ie->data[1] = call->transmoderate | 0x80; ie->data[1] = call->transmoderate | 0x80;
if ((tc & PRI_TRANS_CAP_DIGITAL)&&(pri->switchtype == PRI_SWITCH_EUROISDN_E1)) {
pos = 2; /* Apparently EuroISDN switches don't seem to like user layer 2/3 */
/* octet 4.1 exists iff mode/rate is multirate */ return 4;
if (call->transmoderate == TRANS_MODE_MULTIRATE ) {
ie->data[pos++] = call->transmultiple | 0x80;
} }
if (call->transmoderate != TRANS_MODE_PACKET) { if (call->transmoderate != TRANS_MODE_PACKET) {
/* If you have an AT&T 4ESS, you don't send any more info */ /* If you have an AT&T 4ESS, you don't send any more info */
if ((pri->switchtype != PRI_SWITCH_ATT4ESS) && (call->userl1 > -1)) { if ((pri->switchtype != PRI_SWITCH_ATT4ESS) && (call->userl1 > -1)) {
ie->data[pos++] = call->userl1 | 0x80; /* XXX Ext bit? XXX */ ie->data[2] = call->userl1 | 0x80; /* XXX Ext bit? XXX */
if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) { if (call->userl1 == PRI_LAYER_1_ITU_RATE_ADAPT) {
ie->data[pos++] = call->rateadaption | 0x80; ie->data[3] = call->rateadaption | 0x80;
return 6;
} }
return pos + 2; return 5;
} else
return 4;
} else {
ie->data[2] = 0x80 | call->userl2;
ie->data[3] = 0x80 | call->userl3;
return 6;
} }
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) char *pri_plan2str(int plan)
@@ -893,7 +736,7 @@ char *pri_pres2str(int pres)
static void q931_get_number(unsigned char *num, int maxlen, unsigned char *src, int len) static void q931_get_number(unsigned char *num, int maxlen, unsigned char *src, int len)
{ {
if ((len < 0) || (len > maxlen - 1)) { if (len > maxlen - 1) {
num[0] = 0; num[0] = 0;
return; return;
} }
@@ -937,7 +780,7 @@ static FUNC_DUMP(dump_calling_party_number)
static FUNC_DUMP(dump_calling_party_subaddr) static FUNC_DUMP(dump_calling_party_subaddr)
{ {
unsigned char cnum[256]; unsigned char cnum[256];
q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3); q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d Type: %s (%d) O: %d '%s' ]\n", pri_message(pri, "%c Calling Sub-Address (len=%2d) [ Ext: %d Type: %s (%d) O: %d '%s' ]\n",
prefix, len, ie->data[0] >> 7, prefix, len, ie->data[0] >> 7,
subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4, subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
@@ -1046,7 +889,7 @@ static FUNC_DUMP(dump_redirecting_subaddr)
static FUNC_RECV(receive_calling_party_subaddr) static FUNC_RECV(receive_calling_party_subaddr)
{ {
/* copy digits to call->callingsubaddr */ /* copy digits to call->callingsubaddr */
q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 1, len - 3); q931_get_number((unsigned char *) call->callingsubaddr, sizeof(call->callingsubaddr), ie->data + 2, len - 4);
return 0; return 0;
} }
@@ -1126,27 +969,6 @@ static FUNC_RECV(receive_user_user)
return 0; return 0;
} }
static FUNC_SEND(transmit_user_user)
{
int datalen = strlen(call->useruserinfo);
if (datalen > 0) {
/* Restricted to 35 characters */
if (msgtype == Q931_USER_INFORMATION) {
if (datalen > 260)
datalen = 260;
} else {
if (datalen > 35)
datalen = 35;
}
ie->data[0] = 4; /* IA5 characters */
memcpy(&ie->data[1], call->useruserinfo, datalen);
call->useruserinfo[0] = '\0';
return datalen + 3;
}
return 0;
}
static char *prog2str(int prog) static char *prog2str(int prog)
{ {
static struct msgtype progs[] = { static struct msgtype progs[] = {
@@ -1214,8 +1036,7 @@ static FUNC_RECV(receive_display)
static FUNC_SEND(transmit_display) static FUNC_SEND(transmit_display)
{ {
int i; int i;
if ((pri->switchtype != PRI_SWITCH_NI1) && (pri->switchtype != PRI_SWITCH_QSIG) if ((pri->switchtype != PRI_SWITCH_NI1) && *call->callername) {
&& *call->callername) {
i = 0; i = 0;
if(pri->switchtype != PRI_SWITCH_EUROISDN_E1) { if(pri->switchtype != PRI_SWITCH_EUROISDN_E1) {
ie->data[0] = 0xb1; ie->data[0] = 0xb1;
@@ -1539,14 +1360,12 @@ static FUNC_RECV(receive_keypad_facility)
if (ie->len == 0) if (ie->len == 0)
return -1; return -1;
if (ie->len > (sizeof(call->digitbuf) - 1)) if (ie->len > sizeof(call->digitbuf))
mylen = (sizeof(call->digitbuf) - 1); mylen = sizeof(call->digitbuf);
else else
mylen = ie->len; mylen = ie->len;
memcpy(call->digitbuf, ie->data, mylen); libpri_copy_string(call->digitbuf, (char *) ie->data, mylen);
call->digitbuf[mylen] = 0;
return 0; return 0;
} }
@@ -1555,7 +1374,7 @@ static FUNC_DUMP(dump_display)
{ {
int x, y; int x, y;
char *buf = malloc(len + 1); char *buf = malloc(len + 1);
char tmp[80] = ""; char tmp[80];
if (buf) { if (buf) {
x=y=0; x=y=0;
if ((x < ie->len) && (ie->data[x] & 0x80)) { if ((x < ie->len) && (ie->data[x] & 0x80)) {
@@ -2064,7 +1883,7 @@ static FUNC_DUMP(dump_signal)
} }
static struct ie ies[] = { struct ie ies[] = {
/* Codeset 0 - Common */ /* Codeset 0 - Common */
{ 1, NATIONAL_CHANGE_STATUS, "Change Status" }, { 1, NATIONAL_CHANGE_STATUS, "Change Status" },
{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift }, { 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
@@ -2107,7 +1926,7 @@ static struct ie ies[] = {
{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility }, { 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility },
{ 0, Q931_IE_SIGNAL, "Signal", dump_signal }, { 0, Q931_IE_SIGNAL, "Signal", dump_signal },
{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" }, { 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
{ 1, Q931_IE_USER_USER, "User-User", dump_user_user, receive_user_user, transmit_user_user }, { 1, Q931_IE_USER_USER, "User-User", dump_user_user, receive_user_user },
{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" }, { 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
{ 1, Q931_IE_CALL_STATUS, "Call Status" }, { 1, Q931_IE_CALL_STATUS, "Call Status" },
{ 1, Q931_IE_CHANGE_STATUS, "Change Status" }, { 1, Q931_IE_CHANGE_STATUS, "Change Status" },
@@ -2227,17 +2046,15 @@ static inline void q931_dumpie(struct pri *pri, int codeset, q931_ie *ie, char p
unsigned int x; unsigned int x;
int full_ie = Q931_FULL_IE(codeset, ie->ie); int full_ie = Q931_FULL_IE(codeset, ie->ie);
int base_ie; int base_ie;
char *buf = malloc(ielen(ie) * 3 + 1);
int buflen = 0;
buf[0] = '\0'; pri_message(NULL, "%c [", prefix);
pri_message(NULL, "%02x", ie->ie);
if (!(ie->ie & 0x80)) { if (!(ie->ie & 0x80)) {
buflen += sprintf(buf, " %02x", ielen(ie)-2); pri_message(NULL, " %02x", ielen(ie)-2);
for (x = 0; x + 2 < ielen(ie); ++x) for (x = 0; x + 2 < ielen(ie); ++x)
buflen += sprintf(buf + buflen, " %02x", ie->data[x]); pri_message(NULL, " %02x", ie->data[x]);
} }
pri_message(pri, "%c [%02x%s]\n", prefix, ie->ie, buf); pri_message(NULL, "]\n");
free(buf);
/* Special treatment for shifts */ /* Special treatment for shifts */
if((full_ie & 0xf0) == Q931_LOCKING_SHIFT) if((full_ie & 0xf0) == Q931_LOCKING_SHIFT)
@@ -2686,7 +2503,7 @@ int q931_call_proceeding(struct pri *pri, q931_call *c, int channel, int info)
return send_message(pri, c, Q931_CALL_PROCEEDING, call_proceeding_ies); return send_message(pri, c, Q931_CALL_PROCEEDING, call_proceeding_ies);
} }
#ifndef ALERTING_NO_PROGRESS #ifndef ALERTING_NO_PROGRESS
static int alerting_ies[] = { Q931_PROGRESS_INDICATOR, Q931_IE_USER_USER, -1 }; static int alerting_ies[] = { Q931_PROGRESS_INDICATOR, -1 };
#else #else
static int alerting_ies[] = { -1 }; static int alerting_ies[] = { -1 };
#endif #endif
@@ -2765,11 +2582,9 @@ static void pri_release_finaltimeout(void *data)
pri->schedev = 1; pri->schedev = 1;
pri->ev.e = PRI_EVENT_HANGUP_ACK; pri->ev.e = PRI_EVENT_HANGUP_ACK;
pri->ev.hangup.channel = c->channelno; pri->ev.hangup.channel = c->channelno;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.cref = c->cr; pri->ev.hangup.cref = c->cr;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.call = c; pri->ev.hangup.call = c;
pri->ev.hangup.aoc_units = c->aoc_units;
libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
q931_hangup(pri, c, c->cause); q931_hangup(pri, c, c->cause);
} }
@@ -2799,10 +2614,7 @@ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
c->progressmask = PRI_PROG_CALLED_NOT_ISDN; c->progressmask = PRI_PROG_CALLED_NOT_ISDN;
} else } else
c->progressmask = 0; c->progressmask = 0;
if (pri->localtype == PRI_CPE)
c->ourcallstate = Q931_CALL_STATE_CONNECT_REQUEST; c->ourcallstate = Q931_CALL_STATE_CONNECT_REQUEST;
else
c->ourcallstate = Q931_CALL_STATE_ACTIVE;
c->peercallstate = Q931_CALL_STATE_ACTIVE; c->peercallstate = Q931_CALL_STATE_ACTIVE;
c->alive = 1; c->alive = 1;
/* Setup timer */ /* Setup timer */
@@ -2814,7 +2626,7 @@ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn)
return send_message(pri, c, Q931_CONNECT, connect_ies); return send_message(pri, c, Q931_CONNECT, connect_ies);
} }
static int release_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, -1 }; static int release_ies[] = { Q931_CAUSE, -1 };
int q931_release(struct pri *pri, q931_call *c, int cause) int q931_release(struct pri *pri, q931_call *c, int cause)
{ {
@@ -2862,7 +2674,7 @@ int q931_restart(struct pri *pri, int channel)
return send_message(pri, c, Q931_RESTART, restart_ies); return send_message(pri, c, Q931_RESTART, restart_ies);
} }
static int disconnect_ies[] = { Q931_CAUSE, Q931_IE_USER_USER, -1 }; static int disconnect_ies[] = { Q931_CAUSE, -1 };
int q931_disconnect(struct pri *pri, q931_call *c, int cause) int q931_disconnect(struct pri *pri, q931_call *c, int cause)
{ {
@@ -2883,8 +2695,7 @@ int q931_disconnect(struct pri *pri, q931_call *c, int cause)
} }
static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY, static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY,
Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER, Q931_SENDING_COMPLETE, Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 };
Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 };
static int gr303_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 }; static int gr303_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 };
@@ -2900,8 +2711,6 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
if (!req->userl1) if (!req->userl1)
req->userl1 = PRI_LAYER_1_ULAW; req->userl1 = PRI_LAYER_1_ULAW;
c->userl1 = req->userl1; c->userl1 = req->userl1;
c->userl2 = -1;
c->userl3 = -1;
c->ds1no = (req->channel & 0xff00) >> 8; c->ds1no = (req->channel & 0xff00) >> 8;
c->ds1explicit = (req->channel & 0x10000) >> 16; c->ds1explicit = (req->channel & 0x10000) >> 16;
req->channel &= 0xff; req->channel &= 0xff;
@@ -2963,11 +2772,6 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
} else } else
return -1; return -1;
if (req->useruserinfo)
libpri_copy_string(c->useruserinfo, req->useruserinfo, sizeof(c->useruserinfo));
else
c->useruserinfo[0] = '\0';
if (req->nonisdn && (pri->switchtype == PRI_SWITCH_NI2)) if (req->nonisdn && (pri->switchtype == PRI_SWITCH_NI2))
c->progressmask = PRI_PROG_CALLER_NOT_ISDN; c->progressmask = PRI_PROG_CALLER_NOT_ISDN;
else else
@@ -2992,7 +2796,7 @@ int q931_setup(struct pri *pri, q931_call *c, struct pri_sr *req)
} }
static int release_complete_ies[] = { Q931_IE_USER_USER, -1 }; static int release_complete_ies[] = { -1 };
static int q931_release_complete(struct pri *pri, q931_call *c, int cause) static int q931_release_complete(struct pri *pri, q931_call *c, int cause)
{ {
@@ -3072,6 +2876,8 @@ int q931_hangup(struct pri *pri, q931_call *c, int cause)
/* sent CONNECT */ /* sent CONNECT */
case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING: case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
/* we sent CALL_PROCEEDING */ /* we sent CALL_PROCEEDING */
case Q931_CALL_STATE_ACTIVE:
/* received CONNECT */
case Q931_CALL_STATE_OVERLAP_RECEIVING: case Q931_CALL_STATE_OVERLAP_RECEIVING:
/* received SETUP_ACKNOWLEDGE */ /* received SETUP_ACKNOWLEDGE */
/* send DISCONNECT in general */ /* send DISCONNECT in general */
@@ -3085,10 +2891,6 @@ int q931_hangup(struct pri *pri, q931_call *c, int cause)
} else } else
pri_error(pri, "Wierd, doing nothing but this shouldn't happen, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate)); pri_error(pri, "Wierd, doing nothing but this shouldn't happen, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
break; break;
case Q931_CALL_STATE_ACTIVE:
/* received CONNECT */
q931_disconnect(pri,c,cause);
break;
case Q931_CALL_STATE_DISCONNECT_REQUEST: case Q931_CALL_STATE_DISCONNECT_REQUEST:
/* sent DISCONNECT */ /* sent DISCONNECT */
q931_release(pri,c,cause); q931_release(pri,c,cause);
@@ -3215,7 +3017,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
case Q931_CONNECT: case Q931_CONNECT:
case Q931_ALERTING: case Q931_ALERTING:
case Q931_PROGRESS: case Q931_PROGRESS:
c->useruserinfo[0] = '\0';
c->cause = -1; c->cause = -1;
case Q931_CALL_PROCEEDING: case Q931_CALL_PROCEEDING:
c->progress = -1; c->progress = -1;
@@ -3235,13 +3036,11 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
if (c->retranstimer) if (c->retranstimer)
pri_schedule_del(pri, c->retranstimer); pri_schedule_del(pri, c->retranstimer);
c->retranstimer = 0; c->retranstimer = 0;
c->useruserinfo[0] = '\0';
break; break;
case Q931_RELEASE_COMPLETE: case Q931_RELEASE_COMPLETE:
if (c->retranstimer) if (c->retranstimer)
pri_schedule_del(pri, c->retranstimer); pri_schedule_del(pri, c->retranstimer);
c->retranstimer = 0; c->retranstimer = 0;
c->useruserinfo[0] = '\0';
case Q931_STATUS: case Q931_STATUS:
c->cause = -1; c->cause = -1;
c->causecode = -1; c->causecode = -1;
@@ -3253,7 +3052,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
c->channelno = -1; c->channelno = -1;
break; break;
case Q931_INFORMATION: case Q931_INFORMATION:
c->callednum[0] = '\0';
break; break;
case Q931_STATUS_ENQUIRY: case Q931_STATUS_ENQUIRY:
break; break;
@@ -3412,8 +3210,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
pri->ev.ring.callingpres = c->callerpres; pri->ev.ring.callingpres = c->callerpres;
pri->ev.ring.callingplan = c->callerplan; pri->ev.ring.callingplan = c->callerplan;
pri->ev.ring.callingplanani = c->callerplanani; pri->ev.ring.callingplanani = c->callerplanani;
pri->ev.ring.callingplanrdnis = c->redirectingplan;
pri->ev.ring.callingplanorigcalled = c->origcalledplan;
pri->ev.ring.ani2 = c->ani2; pri->ev.ring.ani2 = c->ani2;
libpri_copy_string(pri->ev.ring.callingani, c->callerani, sizeof(pri->ev.ring.callingani)); libpri_copy_string(pri->ev.ring.callingani, c->callerani, sizeof(pri->ev.ring.callingani));
libpri_copy_string(pri->ev.ring.callingnum, c->callernum, sizeof(pri->ev.ring.callingnum)); libpri_copy_string(pri->ev.ring.callingnum, c->callernum, sizeof(pri->ev.ring.callingnum));
@@ -3426,7 +3222,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
libpri_copy_string(pri->ev.ring.redirectingnum, c->redirectingnum, sizeof(pri->ev.ring.redirectingnum)); libpri_copy_string(pri->ev.ring.redirectingnum, c->redirectingnum, sizeof(pri->ev.ring.redirectingnum));
libpri_copy_string(pri->ev.ring.redirectingname, c->redirectingname, sizeof(pri->ev.ring.redirectingname)); libpri_copy_string(pri->ev.ring.redirectingname, c->redirectingname, sizeof(pri->ev.ring.redirectingname));
libpri_copy_string(pri->ev.ring.useruserinfo, c->useruserinfo, sizeof(pri->ev.ring.useruserinfo)); libpri_copy_string(pri->ev.ring.useruserinfo, c->useruserinfo, sizeof(pri->ev.ring.useruserinfo));
c->useruserinfo[0] = '\0';
pri->ev.ring.redirectingreason = c->redirectingreason; pri->ev.ring.redirectingreason = c->redirectingreason;
pri->ev.ring.origredirectingreason = c->origredirectingreason; pri->ev.ring.origredirectingreason = c->origredirectingreason;
pri->ev.ring.flexible = ! (c->chanflags & FLAG_EXCLUSIVE); pri->ev.ring.flexible = ! (c->chanflags & FLAG_EXCLUSIVE);
@@ -3452,18 +3247,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
pri->ev.ringing.call = c; pri->ev.ringing.call = c;
pri->ev.ringing.progress = c->progress; pri->ev.ringing.progress = c->progress;
pri->ev.ringing.progressmask = c->progressmask; pri->ev.ringing.progressmask = c->progressmask;
libpri_copy_string(pri->ev.ringing.useruserinfo, c->useruserinfo, sizeof(pri->ev.ringing.useruserinfo));
c->useruserinfo[0] = '\0';
cur = c->apdus;
while (cur) {
if (!cur->sent && cur->message == Q931_FACILITY) {
q931_facility(pri, c);
break;
}
cur = cur->next;
}
return Q931_RES_HAVEEVENT; return Q931_RES_HAVEEVENT;
case Q931_CONNECT: case Q931_CONNECT:
if (c->newcall) { if (c->newcall) {
@@ -3482,8 +3265,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
pri->ev.answer.call = c; pri->ev.answer.call = c;
pri->ev.answer.progress = c->progress; pri->ev.answer.progress = c->progress;
pri->ev.answer.progressmask = c->progressmask; pri->ev.answer.progressmask = c->progressmask;
libpri_copy_string(pri->ev.answer.useruserinfo, c->useruserinfo, sizeof(pri->ev.answer.useruserinfo));
c->useruserinfo[0] = '\0';
q931_connect_acknowledge(pri, c); q931_connect_acknowledge(pri, c);
if (c->justsignalling) { /* Make sure WE release when we initiatie a signalling only connection */ if (c->justsignalling) { /* Make sure WE release when we initiatie a signalling only connection */
q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING); q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
@@ -3536,23 +3317,13 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
pri->ev.proceeding.progressmask = c->progressmask; pri->ev.proceeding.progressmask = c->progressmask;
pri->ev.proceeding.cref = c->cr; pri->ev.proceeding.cref = c->cr;
pri->ev.proceeding.call = c; pri->ev.proceeding.call = c;
cur = c->apdus;
while (cur) {
if (!cur->sent && cur->message == Q931_FACILITY) {
q931_facility(pri, c);
break;
}
cur = cur->next;
}
return Q931_RES_HAVEEVENT; return Q931_RES_HAVEEVENT;
case Q931_CONNECT_ACKNOWLEDGE: case Q931_CONNECT_ACKNOWLEDGE:
if (c->newcall) { if (c->newcall) {
q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE); q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
break; break;
} }
if ((c->ourcallstate != Q931_CALL_STATE_CONNECT_REQUEST) && (c->ourcallstate != Q931_CALL_STATE_ACTIVE)) { if (c->ourcallstate != Q931_CALL_STATE_CONNECT_REQUEST) {
q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE); q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE);
break; break;
} }
@@ -3578,11 +3349,9 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
/* Workaround for S-12 ver 7.3 - it responds for invalid/non-implemented IEs at SETUP with null call state */ /* Workaround for S-12 ver 7.3 - it responds for invalid/non-implemented IEs at SETUP with null call state */
if (!c->sugcallstate && (c->ourcallstate != Q931_CALL_STATE_CALL_INITIATED)) { if (!c->sugcallstate && (c->ourcallstate != Q931_CALL_STATE_CALL_INITIATED)) {
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.cref = c->cr; pri->ev.hangup.cref = c->cr;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.call = c; pri->ev.hangup.call = c;
pri->ev.hangup.aoc_units = c->aoc_units;
libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
/* Free resources */ /* Free resources */
c->ourcallstate = Q931_CALL_STATE_NULL; c->ourcallstate = Q931_CALL_STATE_NULL;
c->peercallstate = Q931_CALL_STATE_NULL; c->peercallstate = Q931_CALL_STATE_NULL;
@@ -3606,12 +3375,9 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
c->ourcallstate = Q931_CALL_STATE_NULL; c->ourcallstate = Q931_CALL_STATE_NULL;
c->peercallstate = Q931_CALL_STATE_NULL; c->peercallstate = Q931_CALL_STATE_NULL;
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.cref = c->cr; pri->ev.hangup.cref = c->cr;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.call = c; pri->ev.hangup.call = c;
pri->ev.hangup.aoc_units = c->aoc_units;
libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
c->useruserinfo[0] = '\0';
/* Free resources */ /* Free resources */
if (c->alive) { if (c->alive) {
pri->ev.e = PRI_EVENT_HANGUP; pri->ev.e = PRI_EVENT_HANGUP;
@@ -3641,12 +3407,10 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
c->ourcallstate = Q931_CALL_STATE_NULL; c->ourcallstate = Q931_CALL_STATE_NULL;
pri->ev.e = PRI_EVENT_HANGUP; pri->ev.e = PRI_EVENT_HANGUP;
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.cref = c->cr; pri->ev.hangup.cref = c->cr;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.call = c; pri->ev.hangup.call = c;
pri->ev.hangup.aoc_units = c->aoc_units; pri->ev.hangup.aoc_units = c->aoc_units;
libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
c->useruserinfo[0] = '\0';
/* Don't send release complete if they send us release /* Don't send release complete if they send us release
while we sent it, assume a NULL state */ while we sent it, assume a NULL state */
if (c->newcall) if (c->newcall)
@@ -3669,12 +3433,10 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
/* Return such an event */ /* Return such an event */
pri->ev.e = PRI_EVENT_HANGUP_REQ; pri->ev.e = PRI_EVENT_HANGUP_REQ;
pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.cref = c->cr; pri->ev.hangup.cref = c->cr;
pri->ev.hangup.cause = c->cause;
pri->ev.hangup.call = c; pri->ev.hangup.call = c;
pri->ev.hangup.aoc_units = c->aoc_units; pri->ev.hangup.aoc_units = c->aoc_units;
libpri_copy_string(pri->ev.hangup.useruserinfo, c->useruserinfo, sizeof(pri->ev.hangup.useruserinfo));
c->useruserinfo[0] = '\0';
if (c->alive) if (c->alive)
return Q931_RES_HAVEEVENT; return Q931_RES_HAVEEVENT;
else else
@@ -3724,7 +3486,6 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING; c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
pri->ev.e = PRI_EVENT_SETUP_ACK; pri->ev.e = PRI_EVENT_SETUP_ACK;
pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16); pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
pri->ev.setup_ack.call = c;
cur = c->apdus; cur = c->apdus;
while (cur) { while (cur) {

View File

@@ -3,31 +3,25 @@
* *
* Written by Mark Spencer <markster@digium.com> * Written by Mark Spencer <markster@digium.com>
* *
* Copyright (C) 2001-2005, Digium, Inc. * Copyright (C) 2001-2005, Digium
* All Rights Reserved. * 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, distributed under the terms of * This program is free software; you can redistribute it and/or modify
* the GNU General Public License Version 2 as published by the * it under the terms of the GNU General Public License as published by
* Free Software Foundation. See the LICENSE file included with * the Free Software Foundation; either version 2 of the License, or
* this program for more details. * (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.
* *
* 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. * This program tests libpri call reception using a zaptel interface.
* Its state machines are setup for RECEIVING CALLS ONLY, so if you * Its state machines are setup for RECEIVING CALLS ONLY, so if you