mirror of
https://github.com/asterisk/asterisk.git
synced 2025-08-19 04:17:43 +00:00
Compare commits
250 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6e20552bca | ||
|
f09fbd398e | ||
|
517518809a | ||
|
b4cd946ef0 | ||
|
59286cfbc1 | ||
|
1700f24dd3 | ||
|
aa2e435d82 | ||
|
2fc5fed79e | ||
|
efd42d2d5c | ||
|
2ff6a84a16 | ||
|
01c0938ddf | ||
|
fda8fa2367 | ||
|
998ef5948c | ||
|
cbc39f7d71 | ||
|
802a44a15b | ||
|
efbb88225c | ||
|
30d264ebda | ||
|
bf4ca23372 | ||
|
9ecfd9f33e | ||
|
255ce93616 | ||
|
4ffa6c246f | ||
|
a9db074776 | ||
|
7b10240bc3 | ||
|
9812bcc03c | ||
|
fb6e840213 | ||
|
2a896e5d3c | ||
|
ab67420c37 | ||
|
07a6cd4592 | ||
|
762cd4621d | ||
|
a23534c4e2 | ||
|
1597114535 | ||
|
aea667c7c8 | ||
|
e0f335a4eb | ||
|
78531a0f32 | ||
|
a2297d6776 | ||
|
ef889d6672 | ||
|
291ce3e839 | ||
|
42806dc1ac | ||
|
45a157ec0e | ||
|
49389bd690 | ||
|
a638a19ea2 | ||
|
199ec4356a | ||
|
5dad6f4319 | ||
|
27e4a2ee57 | ||
|
d7fb7e9ed7 | ||
|
528cf89739 | ||
|
b96abb803c | ||
|
574d3785ab | ||
|
d1be79cce2 | ||
|
9d8c71ee86 | ||
|
877f1f64c2 | ||
|
a9f5393bfe | ||
|
038cd054ae | ||
|
e228c88d2a | ||
|
4824ee8b20 | ||
|
0da1f7593d | ||
|
8fae88d368 | ||
|
5c32080a0c | ||
|
610d52b054 | ||
|
0aa4c95a89 | ||
|
d2385517ac | ||
|
3fc2609468 | ||
|
0eec8c8318 | ||
|
bdc00dae0e | ||
|
a1442538b5 | ||
|
ce68497243 | ||
|
9a387e5a7a | ||
|
c4aa1dadbd | ||
|
556f27ecf1 | ||
|
ef2cd744cf | ||
|
f5b1c6c27e | ||
|
5f93d06cf8 | ||
|
952a5e6dd9 | ||
|
238b9d24c6 | ||
|
7457c51bc2 | ||
|
a4437b1362 | ||
|
45b91a90e1 | ||
|
3cb1d7843b | ||
|
4d6b943ea4 | ||
|
d8aff59a9e | ||
|
e9dbd238c8 | ||
|
89447a99ec | ||
|
e499028440 | ||
|
2f82498995 | ||
|
71df4d92da | ||
|
ac1e884328 | ||
|
e31d4ee777 | ||
|
cc30079edd | ||
|
b76252d68e | ||
|
ce868ed5f5 | ||
|
8283811633 | ||
|
00f227a684 | ||
|
a6e748e491 | ||
|
8a12240f73 | ||
|
815318b12f | ||
|
5e0b84633e | ||
|
aa2a8ed77c | ||
|
9e96cb612b | ||
|
f54c287c73 | ||
|
14e1fe4795 | ||
|
81df8343d3 | ||
|
388ca07547 | ||
|
b3fdacf9cc | ||
|
cb896da998 | ||
|
879c401544 | ||
|
c6025e41c6 | ||
|
52647db120 | ||
|
5adfdcba1e | ||
|
550e8e56ba | ||
|
8d457d07c4 | ||
|
b3333ebc2e | ||
|
3454b5927f | ||
|
54e81f5ca0 | ||
|
c1e14143fa | ||
|
97904aee06 | ||
|
24e902d2a4 | ||
|
0da197d593 | ||
|
6b2e3f29f9 | ||
|
64b9a563f2 | ||
|
a703e927b1 | ||
|
8d0d386970 | ||
|
dc542971df | ||
|
8fb1ddeb5d | ||
|
e94fa076cb | ||
|
f83715ce9c | ||
|
b0970b9e33 | ||
|
f4b60a5c65 | ||
|
e7908a50e8 | ||
|
789c4f4587 | ||
|
19be63c4c3 | ||
|
04a9441769 | ||
|
a2da1f08bd | ||
|
eb57ea95d6 | ||
|
1e2db0e885 | ||
|
d77ae42896 | ||
|
2a2d65541b | ||
|
fd7577eed2 | ||
|
93818c761b | ||
|
bc72d7584a | ||
|
b813a5f3fa | ||
|
d952c7ed71 | ||
|
07166e63a3 | ||
|
9888487f9c | ||
|
3c7ab1ca5e | ||
|
08a8632ac7 | ||
|
4b2877834e | ||
|
344ec00439 | ||
|
082f628401 | ||
|
3cf360ae44 | ||
|
0c39d6de8e | ||
|
53262335c8 | ||
|
380b9a40a3 | ||
|
f6109b7b94 | ||
|
1db964ad95 | ||
|
416079db61 | ||
|
49ca05642a | ||
|
7d88098555 | ||
|
82db278716 | ||
|
cfb711bf57 | ||
|
471df8f512 | ||
|
9f1562a599 | ||
|
e2fe8ef485 | ||
|
4a19a2644f | ||
|
066a53df8a | ||
|
2a108b9b06 | ||
|
6749f1b8b5 | ||
|
8ff9c0d1b9 | ||
|
b48987922c | ||
|
5259155e52 | ||
|
2f753040ef | ||
|
bd7ca6bb69 | ||
|
0f88c702df | ||
|
28e5320ab4 | ||
|
47f8883942 | ||
|
4c133e47da | ||
|
0cf6b2ba31 | ||
|
7fffa6e20a | ||
|
ccdd86775f | ||
|
91d2e58d1b | ||
|
1327846518 | ||
|
11b1e81197 | ||
|
616780b64e | ||
|
90a497c3b8 | ||
|
de1d9a90dd | ||
|
516cd1ba8d | ||
|
c7541bd672 | ||
|
c3c13114fb | ||
|
2863202bed | ||
|
cab4557006 | ||
|
f1be7d7ffc | ||
|
c22fdb7232 | ||
|
bd1c5ac3cf | ||
|
fa814abe05 | ||
|
03cd30b746 | ||
|
7ede296efd | ||
|
264fead207 | ||
|
e5ad308a2b | ||
|
f31a210cb2 | ||
|
b27c9f26fe | ||
|
0ffa958fc4 | ||
|
e8483c021b | ||
|
5596c6a5da | ||
|
0a6f41cdf2 | ||
|
4219bdc2b4 | ||
|
fa9c265ce7 | ||
|
6d447004ea | ||
|
091c6c36b9 | ||
|
1f34a1dab4 | ||
|
ba55e8ae64 | ||
|
461596d9b1 | ||
|
0e3fc6a4fe | ||
|
6a589d5630 | ||
|
b8c18d6176 | ||
|
4210fd6ad9 | ||
|
1ddd0afe36 | ||
|
230d4b38a3 | ||
|
1afd98d916 | ||
|
60707a4172 | ||
|
f2dcfca9c4 | ||
|
d8436708c0 | ||
|
de3528f0be | ||
|
d0ab0358aa | ||
|
4f9f6df42c | ||
|
ed20af4517 | ||
|
3ca96a1317 | ||
|
3bcff2d2f9 | ||
|
3e85e4b82c | ||
|
299b26ae4a | ||
|
bbbbcaf73f | ||
|
37e789fd79 | ||
|
27f3c530ed | ||
|
534e44c599 | ||
|
1587fd6b84 | ||
|
ce51451ca6 | ||
|
3385ecc112 | ||
|
5d589eb866 | ||
|
039aad9ff4 | ||
|
a0b8879af4 | ||
|
e1c9ebc5b9 | ||
|
02ffc0eec8 | ||
|
a560227ccb | ||
|
87a7a3aaff | ||
|
6723ea3afb | ||
|
3ff53cd50b | ||
|
94f18868f1 | ||
|
e85d440f88 | ||
|
6910fd79f2 | ||
|
c14b405974 | ||
|
0125ed120f | ||
|
be2d39a1a5 |
@@ -1,6 +0,0 @@
|
||||
asterisk
|
||||
build.h
|
||||
ast_expr.c
|
||||
.version
|
||||
.depend
|
||||
.applied
|
63
CHANGES
Executable file → Normal file
63
CHANGES
Executable file → Normal file
@@ -1,3 +1,66 @@
|
||||
NOTE: Corrections or additions to the ChangeLog may be submitted
|
||||
to http://bugs.digium.com. A complete listing of changes
|
||||
is available through the Asterisk-CVS mailing list hosted
|
||||
at http://lists.digium.com.
|
||||
|
||||
Asterisk 1.0.4
|
||||
-- general
|
||||
-- fix memory leak evident with extensive use of variables
|
||||
-- update IAXy firmware to version 22
|
||||
-- enable some special write protection
|
||||
-- enable outbound DTMF
|
||||
-- fix seg fault with incorrect usage of SetVar
|
||||
-- other minor fixes including typos and doc updates
|
||||
-- chan_sip
|
||||
-- fix codecs to not be case sensitive
|
||||
-- Re-use auth credentials
|
||||
-- fix MWI when using type=friend
|
||||
-- fix global NAT option
|
||||
-- chan_agent / chan_local
|
||||
-- fix incorrect use count
|
||||
-- chan_zap
|
||||
-- Allow CID rings to be configured in zapata.conf
|
||||
-- no more patching needed for UK CID
|
||||
-- app_macro
|
||||
-- allow Macros to exit with '*' or '#' like regular extension processing
|
||||
-- app_voicemail
|
||||
-- don't allow '#' as a password
|
||||
-- add option to save voicemail before going to the operator
|
||||
-- fix global operator=yes
|
||||
-- app_read
|
||||
-- return 0 instead of -1 if user enters nothing
|
||||
-- res_agi
|
||||
-- don't exit AGI when file not found to stream
|
||||
-- send script parameter when using FastAGI
|
||||
Asterisk 1.0.3
|
||||
-- chan_zap
|
||||
-- fix seg fault when doing *0 to flash a trunk
|
||||
-- rtp
|
||||
-- seg fault fix
|
||||
-- chan_sip
|
||||
-- fix to prevent seg fault when attempting a transfer
|
||||
-- fix bug with supervised transfers
|
||||
-- fix codec preferences
|
||||
-- chan_h323
|
||||
-- fix compilation problem
|
||||
-- chan_iax2
|
||||
-- avoid a deadlock related to a static config of a BUNCH of peers
|
||||
-- cdr_pgsql
|
||||
-- fix memory leak when reading config
|
||||
-- Numerous other minor bug fixes
|
||||
Asterisk 1.0.2
|
||||
-- Major bugfix release
|
||||
Asterisk 1.0.1
|
||||
-- Added AGI over TCP support
|
||||
-- Add ability to purge callers from queue if no agents are logged in
|
||||
-- Fix inband PRI indication detection
|
||||
-- Fix for MGCP - always request digits if no RTP stream
|
||||
-- Fixed seg fault for ast_control_streamfile
|
||||
-- Make pick-up extension configurable via features.conf
|
||||
-- Numerous other bug fixes
|
||||
Asterisk 1.0.0
|
||||
-- Use Q.931 standard cause codes for asterisk cause codes
|
||||
-- Bug fixes from the bug tracker
|
||||
Asterisk 1.0-RC2
|
||||
-- Additional CDR backends
|
||||
-- Allow muted to reconnect
|
||||
|
8
CREDITS
Executable file → Normal file
8
CREDITS
Executable file → Normal file
@@ -5,6 +5,8 @@ Asterisk:
|
||||
|
||||
Pilosoft, Inc. - for supporting ADSI development in Asterisk
|
||||
|
||||
Asterlink, Inc. - for supporting broad Asterisk development
|
||||
|
||||
GFS - for supporting ALSA development
|
||||
|
||||
Telesthetic - for supporting SIP development
|
||||
@@ -24,6 +26,8 @@ Wasim - Hangup detect
|
||||
PhoneJack and Linejack card to the project. (http://www.quicknet.net)
|
||||
|
||||
=== MISCELLANEOUS PATCHES ===
|
||||
Anthony Minessale - Countless big and small fixes, and relentless forward push
|
||||
anthmct@yahoo.com http://www.asterlink.com
|
||||
James Golovich - Innumerable contributions
|
||||
You can find him and asterisk-perl at http://asterisk.gnuinter.net
|
||||
Andre Bierwirth - Extension hints and status
|
||||
@@ -54,12 +58,14 @@ Thorsten Lockert - OpenBSD, FreeBSD ports, making MacOS X port run on 10.3,
|
||||
bugs. tholo@sigmasoft.com
|
||||
Brian West - ODBC support and Bug Marshaling
|
||||
William Waites - syslog support, SIP NAT traversal for SIP-UA. ww@styx.org
|
||||
Rich Murphey - Porting to FreeBSD, NetBSD, OpenBSD, and Darwin.
|
||||
rich@whiteoaklabs.com http://whiteoaklabs.com
|
||||
|
||||
=== OTHER CONTRIBUTIONS ===
|
||||
John Todd - Monkey sounds and associated teletorture prompt
|
||||
|
||||
=== HOLD MUSIC ===
|
||||
Music provided by www.freeplaymusic.com
|
||||
Music provided by www.opsound.org
|
||||
|
||||
=== OTHER SOURCE CODE IN ASTERISK ===
|
||||
|
||||
|
41
Makefile
Executable file → Normal file
41
Makefile
Executable file → Normal file
@@ -26,6 +26,18 @@ PROC=k8
|
||||
#PROC=athlon
|
||||
OPTIONS+=-m64
|
||||
endif
|
||||
ifeq ($(PROC),sparc64)
|
||||
#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
|
||||
#This works for even old (2.96) versions of gcc and provides a small boost either way.
|
||||
#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
|
||||
#So we go lowest common available by gcc and go a step down, still a step up from
|
||||
#the default as we now have a better instruction set to work with. - Belgarath
|
||||
PROC=ultrasparc
|
||||
OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
|
||||
OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
|
||||
OPTIONS+=-fomit-frame-pointer
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(findstring BSD,${OSARCH}),BSD)
|
||||
@@ -50,7 +62,7 @@ PWD=$(shell pwd)
|
||||
#K6OPT = -DK6OPT
|
||||
|
||||
#Tell gcc to optimize the asterisk's code
|
||||
OPTIMIZE=-O6
|
||||
OPTIMIZE+=-O6
|
||||
|
||||
#Include debug symbols in the executables (-g) and profiling info (-pg)
|
||||
DEBUG=-g #-pg
|
||||
@@ -116,18 +128,27 @@ AGI_DIR=$(ASTVARLIBDIR)/agi-bin
|
||||
INCLUDE=-Iinclude -I../include
|
||||
CFLAGS=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
|
||||
CFLAGS+=$(OPTIMIZE)
|
||||
|
||||
ifneq ($(PROC),ultrasparc)
|
||||
CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
|
||||
endif
|
||||
|
||||
CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
|
||||
CFLAGS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "-DOSP_SUPPORT -I/usr/include/osp" ; fi)
|
||||
|
||||
ifeq (${OSARCH},FreeBSD)
|
||||
OSVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
|
||||
CFLAGS+=$(if ${OSVERSION}<500016,-D_THREAD_SAFE)
|
||||
LIBS+=$(if ${OSVERSION}<502102,-lc_r,-pthread)
|
||||
CFLAGS+=$(shell if test ${OSVERSION} -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
|
||||
LIBS+=$(shell if test ${OSVERSION} -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
|
||||
INCLUDE+=-I/usr/local/include
|
||||
CFLAGS+=$(shell if [ -d /usr/local/include/spandsp ]; then echo "-I/usr/local/include/spandsp"; fi)
|
||||
endif # FreeBSD
|
||||
|
||||
ifeq (${OSARCH},NetBSD)
|
||||
CFLAGS+=-pthread
|
||||
INCLUDE+=-I/usr/local/include -I/usr/pkg/include
|
||||
endif
|
||||
|
||||
ifeq (${OSARCH},OpenBSD)
|
||||
CFLAGS+=-pthread
|
||||
endif
|
||||
@@ -175,6 +196,9 @@ endif
|
||||
ifeq (${OSARCH},FreeBSD)
|
||||
LIBS+=-lcrypto
|
||||
endif
|
||||
ifeq (${OSARCH},NetBSD)
|
||||
LIBS+=-lpthread -lcrypto -lm -L/usr/local/lib -L/usr/pkg/lib -lncurses
|
||||
endif
|
||||
ifeq (${OSARCH},OpenBSD)
|
||||
LIBS=-lcrypto -lpthread -lm -lncurses
|
||||
endif
|
||||
@@ -333,7 +357,7 @@ datafiles: all
|
||||
update:
|
||||
@if [ -d CVS ]; then \
|
||||
echo "Updating from CVS..." ; \
|
||||
cvs -q update -Pd; \
|
||||
cvs -q -z3 update -Pd; \
|
||||
rm -f .version; \
|
||||
else \
|
||||
echo "Not CVS"; \
|
||||
@@ -347,6 +371,7 @@ bininstall: all
|
||||
mkdir -p $(DESTDIR)$(ASTSBINDIR)
|
||||
mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
|
||||
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
|
||||
install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
|
||||
install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
|
||||
if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
|
||||
@@ -364,13 +389,6 @@ bininstall: all
|
||||
rm -f $(DESTDIR)$(ASTSPOOLDIR)/vm; \
|
||||
fi
|
||||
ln -s $(ASTSPOOLDIR)/voicemail/default $(DESTDIR)$(ASTSPOOLDIR)/vm
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/chan_ixj.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/chan_tor.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/cdr_mysql.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/cdr_unixodbc.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/codec_mp3_d.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/format_mp3.so
|
||||
rm -f $(DESTDIR)$(MODULES_DIR)/app_voicemail2.so
|
||||
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
|
||||
mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
|
||||
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
|
||||
@@ -501,7 +519,6 @@ mpg123:
|
||||
[ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
|
||||
[ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
|
||||
make -C mpg123-0.59r linux
|
||||
|
||||
|
||||
config:
|
||||
if [ -d /etc/rc.d/init.d ]; then \
|
||||
|
22
README.opsound
Normal file
22
README.opsound
Normal file
@@ -0,0 +1,22 @@
|
||||
About Hold Music
|
||||
================
|
||||
These files were obtained from http://opsound.org, where the authors placed them
|
||||
under the Creative Commons Attribution-Share Alike 2.5 license, a copy of which
|
||||
may be found at http://creativecommons.org.
|
||||
|
||||
Credits
|
||||
================
|
||||
macroform-cold_day - Paul Shuler (Macroform)
|
||||
paulshuler@gmail.com - http://macroform.bandcamp.com/
|
||||
|
||||
macroform-robot_dity - Paul Shuler (Macroform)
|
||||
paulshuler@gmail.com - http://macroform.bandcamp.com/
|
||||
|
||||
macroform-the_simplicity - Paul Shuler (Macroform)
|
||||
paulshuler@gmail.com - http://macroform.bandcamp.com/
|
||||
|
||||
manolo_camp-morning_coffee - Manolo Camp
|
||||
beatbastard@gmx.net - http://ccmixter.org/people/ManoloCamp
|
||||
|
||||
reno_project-system - Reno Project
|
||||
renoproject@hotmail.com - http://www.jamendo.com/en/album/23661
|
7
acl.c
Executable file → Normal file
7
acl.c
Executable file → Normal file
@@ -242,20 +242,19 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
|
||||
memset(&m_rtmsg, 0, sizeof(m_rtmsg));
|
||||
m_rtmsg.m_rtm.rtm_type = RTM_GET;
|
||||
m_rtmsg.m_rtm.rtm_flags = RTF_UP | RTF_HOST;
|
||||
m_rtmsg.m_rtm.rtm_version = RTM_VERSION;
|
||||
ast_mutex_lock(&routeseq_lock);
|
||||
seq = ++routeseq;
|
||||
ast_mutex_unlock(&routeseq_lock);
|
||||
m_rtmsg.m_rtm.rtm_seq = seq;
|
||||
m_rtmsg.m_rtm.rtm_addrs = RTA_IFA | RTA_DST;
|
||||
m_rtmsg.m_rtm.rtm_addrs = RTA_DST | RTA_IFA;
|
||||
m_rtmsg.m_rtm.rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
|
||||
sin = (struct sockaddr_in *)m_rtmsg.m_space;
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_len = sizeof(struct sockaddr_in);
|
||||
sin->sin_addr = *them;
|
||||
|
||||
if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
|
||||
if ((s = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) {
|
||||
ast_log(LOG_ERROR, "Error opening routing socket\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -268,7 +267,7 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
}
|
||||
do {
|
||||
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
|
||||
} while (l > 0 && (m_rtmsg.m_rtm.rtm_seq != 1 || m_rtmsg.m_rtm.rtm_pid != pid));
|
||||
} while (l > 0 && (m_rtmsg.m_rtm.rtm_seq != seq || m_rtmsg.m_rtm.rtm_pid != pid));
|
||||
if (l < 0) {
|
||||
if (errno != EAGAIN)
|
||||
ast_log(LOG_ERROR, "Error reading from routing socket\n");
|
||||
|
0
aescrypt.c
Executable file → Normal file
0
aescrypt.c
Executable file → Normal file
2
aesopt.h
Executable file → Normal file
2
aesopt.h
Executable file → Normal file
@@ -151,7 +151,7 @@
|
||||
#if defined( __OpenBSD__ )
|
||||
# include <machine/types.h>
|
||||
# include <sys/endian.h>
|
||||
#elif defined( __FreeBSD__ )
|
||||
#elif defined( __FreeBSD__ ) || defined( __NetBSD__ )
|
||||
# include <sys/types.h>
|
||||
# include <sys/endian.h>
|
||||
#elif defined( BSD ) && ( BSD >= 199103 ) || defined(__APPLE__)
|
||||
|
@@ -1,3 +0,0 @@
|
||||
eagi-test
|
||||
eagi-sphinx-test
|
||||
.depend
|
0
agi/DialAnMp3.agi
Executable file → Normal file
0
agi/DialAnMp3.agi
Executable file → Normal file
0
agi/Makefile
Executable file → Normal file
0
agi/Makefile
Executable file → Normal file
0
agi/agi-test.agi
Executable file → Normal file
0
agi/agi-test.agi
Executable file → Normal file
0
agi/eagi-sphinx-test.c
Executable file → Normal file
0
agi/eagi-sphinx-test.c
Executable file → Normal file
0
agi/eagi-test.c
Executable file → Normal file
0
agi/eagi-test.c
Executable file → Normal file
94
agi/fastagi-test
Normal file
94
agi/fastagi-test
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use Socket;
|
||||
use Carp;
|
||||
use IO::Handle;
|
||||
|
||||
my $port = 4573;
|
||||
|
||||
$|=1;
|
||||
|
||||
# Setup some variables
|
||||
my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
|
||||
socket(SERVER, PF_INET, SOCK_STREAM, 0);
|
||||
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1));
|
||||
bind(SERVER, sockaddr_in($port, INADDR_ANY)) || die("can't bind\n");
|
||||
listen(SERVER, SOMAXCONN);
|
||||
|
||||
for(;;) {
|
||||
my $raddr = accept(CLIENT, SERVER);
|
||||
my ($s, $p) = sockaddr_in($raddr);
|
||||
CLIENT->autoflush(1);
|
||||
while(<CLIENT>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if (/^agi_(\w+)\:\s+(.*)$/) {
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
print STDERR "AGI Environment Dump from $s:$p --\n";
|
||||
foreach my $i (sort keys %AGI) {
|
||||
print STDERR " -- $i = $AGI{$i}\n";
|
||||
}
|
||||
|
||||
print STDERR "1. Testing 'sendfile'...";
|
||||
print CLIENT "STREAM FILE beep \"\"\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "2. Testing 'sendtext'...";
|
||||
print CLIENT "SEND TEXT \"hello world\"\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "3. Testing 'sendimage'...";
|
||||
print CLIENT "SEND IMAGE asterisk-image\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "4. Testing 'saynumber'...";
|
||||
print CLIENT "SAY NUMBER 192837465 \"\"\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "5. Testing 'waitdtmf'...";
|
||||
print CLIENT "WAIT FOR DIGIT 1000\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "6. Testing 'record'...";
|
||||
print CLIENT "RECORD FILE testagi gsm 1234 3000\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
|
||||
print STDERR "6a. Testing 'record' playback...";
|
||||
print CLIENT "STREAM FILE testagi \"\"\n";
|
||||
my $result = <CLIENT>;
|
||||
&checkresult($result);
|
||||
close(CLIENT);
|
||||
print STDERR "================== Complete ======================\n";
|
||||
print STDERR "$tests tests completed, $pass passed, $fail failed\n";
|
||||
print STDERR "==================================================\n";
|
||||
}
|
||||
|
0
agi/numeralize
Executable file → Normal file
0
agi/numeralize
Executable file → Normal file
499
app.c
Executable file → Normal file
499
app.c
Executable file → Normal file
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Channel Management
|
||||
* Convenient Application Routines
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -31,12 +31,16 @@
|
||||
#include "asterisk.h"
|
||||
#include "astconf.h"
|
||||
|
||||
#define MAX_OTHER_FORMATS 10
|
||||
|
||||
/* set timeout to 0 for "standard" timeouts. Set timeout to -1 for
|
||||
"ludicrous time" (essentially never times out) */
|
||||
int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout)
|
||||
{
|
||||
int res,to,fto;
|
||||
/* XXX Merge with full version? XXX */
|
||||
if (maxlen)
|
||||
s[0] = '\0';
|
||||
if (prompt) {
|
||||
res = ast_streamfile(c, prompt, c->language);
|
||||
if (res < 0)
|
||||
@@ -411,7 +415,8 @@ int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char
|
||||
{
|
||||
struct timeval started, ended;
|
||||
long elapsed = 0,last_elapsed =0;
|
||||
char *breaks;
|
||||
char *breaks=NULL;
|
||||
char *end=NULL;
|
||||
int blen=2;
|
||||
int res=0;
|
||||
|
||||
@@ -420,17 +425,28 @@ int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char
|
||||
if (pause)
|
||||
blen += strlen(pause);
|
||||
|
||||
breaks = alloca(blen + 1);
|
||||
breaks[0] = '\0';
|
||||
strcat(breaks, stop);
|
||||
strcat(breaks, pause);
|
||||
|
||||
if (blen > 2) {
|
||||
breaks = alloca(blen + 1);
|
||||
breaks[0] = '\0';
|
||||
strcat(breaks, stop);
|
||||
strcat(breaks, pause);
|
||||
}
|
||||
if (chan->_state != AST_STATE_UP)
|
||||
res = ast_answer(chan);
|
||||
|
||||
if (chan)
|
||||
ast_stopstream(chan);
|
||||
|
||||
|
||||
if (file) {
|
||||
if ((end = strchr(file,':'))) {
|
||||
if (!strcasecmp(end, ":end")) {
|
||||
*end = '\0';
|
||||
end++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
gettimeofday(&started,NULL);
|
||||
|
||||
@@ -438,6 +454,10 @@ int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char
|
||||
ast_stopstream(chan);
|
||||
res = ast_streamfile(chan, file, chan->language);
|
||||
if (!res) {
|
||||
if (end) {
|
||||
ast_seekstream(chan->stream, 0, SEEK_END);
|
||||
end=NULL;
|
||||
}
|
||||
res = 1;
|
||||
if (elapsed) {
|
||||
ast_stream_fastforward(chan->stream, elapsed);
|
||||
@@ -459,9 +479,9 @@ int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char
|
||||
if (chan)
|
||||
ast_stopstream(chan);
|
||||
res = ast_waitfordigit(chan, 1000);
|
||||
if(res == 0)
|
||||
if (res == 0)
|
||||
continue;
|
||||
else if(res == -1 || strchr(pause, res) || (stop && strchr(stop, res)))
|
||||
else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res)))
|
||||
break;
|
||||
}
|
||||
if (res == *pause) {
|
||||
@@ -483,3 +503,460 @@ int ast_control_streamfile(struct ast_channel *chan, char *file, char *fwd, char
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ast_play_and_wait(struct ast_channel *chan, char *fn)
|
||||
{
|
||||
int d;
|
||||
d = ast_streamfile(chan, fn, chan->language);
|
||||
if (d)
|
||||
return d;
|
||||
d = ast_waitstream(chan, AST_DIGIT_ANY);
|
||||
ast_stopstream(chan);
|
||||
return d;
|
||||
}
|
||||
|
||||
static int global_silence_threshold = 128;
|
||||
static int global_maxsilence = 0;
|
||||
|
||||
int ast_play_and_record(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int silencethreshold, int maxsilence)
|
||||
{
|
||||
char d, *fmts;
|
||||
char comment[256];
|
||||
int x, fmtcnt=1, res=-1,outmsg=0;
|
||||
struct ast_frame *f;
|
||||
struct ast_filestream *others[MAX_OTHER_FORMATS];
|
||||
char *sfmt[MAX_OTHER_FORMATS];
|
||||
char *stringp=NULL;
|
||||
time_t start, end;
|
||||
struct ast_dsp *sildet; /* silence detector dsp */
|
||||
int totalsilence = 0;
|
||||
int dspsilence = 0;
|
||||
int gotsilence = 0; /* did we timeout for silence? */
|
||||
int rfmt=0;
|
||||
|
||||
if (silencethreshold < 0)
|
||||
silencethreshold = global_silence_threshold;
|
||||
|
||||
if (maxsilence < 0)
|
||||
maxsilence = global_maxsilence;
|
||||
|
||||
/* barf if no pointer passed to store duration in */
|
||||
if (duration == NULL) {
|
||||
ast_log(LOG_WARNING, "Error play_and_record called without duration pointer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
|
||||
snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
|
||||
|
||||
if (playfile) {
|
||||
d = ast_play_and_wait(chan, playfile);
|
||||
if (d > -1)
|
||||
d = ast_streamfile(chan, "beep",chan->language);
|
||||
if (!d)
|
||||
d = ast_waitstream(chan,"");
|
||||
if (d < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fmts = ast_strdupa(fmt);
|
||||
|
||||
stringp=fmts;
|
||||
strsep(&stringp, "|");
|
||||
ast_log(LOG_DEBUG,"Recording Formats: sfmts=%s\n", fmts);
|
||||
sfmt[0] = ast_strdupa(fmts);
|
||||
|
||||
while((fmt = strsep(&stringp, "|"))) {
|
||||
if (fmtcnt > MAX_OTHER_FORMATS - 1) {
|
||||
ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app_voicemail.c\n");
|
||||
break;
|
||||
}
|
||||
sfmt[fmtcnt++] = ast_strdupa(fmt);
|
||||
}
|
||||
|
||||
time(&start);
|
||||
end=start; /* pre-initialize end to be same as start in case we never get into loop */
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
others[x] = ast_writefile(recordfile, sfmt[x], comment, O_TRUNC, 0, 0700);
|
||||
ast_verbose( VERBOSE_PREFIX_3 "x=%i, open writing: %s format: %s, %p\n", x, recordfile, sfmt[x], others[x]);
|
||||
|
||||
if (!others[x]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sildet = ast_dsp_new(); /* Create the silence detector */
|
||||
if (!sildet) {
|
||||
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
|
||||
return -1;
|
||||
}
|
||||
ast_dsp_set_threshold(sildet, silencethreshold);
|
||||
|
||||
if (maxsilence > 0) {
|
||||
rfmt = chan->readformat;
|
||||
res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == fmtcnt) {
|
||||
/* Loop forever, writing the packets we read to the writer(s), until
|
||||
we read a # or get a hangup */
|
||||
f = NULL;
|
||||
for(;;) {
|
||||
res = ast_waitfor(chan, 2000);
|
||||
if (!res) {
|
||||
ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
|
||||
/* Try one more time in case of masq */
|
||||
res = ast_waitfor(chan, 2000);
|
||||
if (!res) {
|
||||
ast_log(LOG_WARNING, "No audio available on %s??\n", chan->name);
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
f = NULL;
|
||||
break;
|
||||
}
|
||||
f = ast_read(chan);
|
||||
if (!f)
|
||||
break;
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
/* write each format */
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
res = ast_writestream(others[x], f);
|
||||
}
|
||||
|
||||
/* Silence Detection */
|
||||
if (maxsilence > 0) {
|
||||
dspsilence = 0;
|
||||
ast_dsp_silence(sildet, f, &dspsilence);
|
||||
if (dspsilence)
|
||||
totalsilence = dspsilence;
|
||||
else
|
||||
totalsilence = 0;
|
||||
|
||||
if (totalsilence > maxsilence) {
|
||||
/* Ended happily with silence */
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds\n", totalsilence/1000);
|
||||
ast_frfree(f);
|
||||
gotsilence = 1;
|
||||
outmsg=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Exit on any error */
|
||||
if (res) {
|
||||
ast_log(LOG_WARNING, "Error writing frame\n");
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
} else if (f->frametype == AST_FRAME_VIDEO) {
|
||||
/* Write only once */
|
||||
ast_writestream(others[0], f);
|
||||
} else if (f->frametype == AST_FRAME_DTMF) {
|
||||
if (f->subclass == '#') {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "User ended message by pressing %c\n", f->subclass);
|
||||
res = '#';
|
||||
outmsg = 2;
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f->subclass == '0') {
|
||||
/* Check for a '0' during message recording also, in case caller wants operator */
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "User cancelled by pressing %c\n", f->subclass);
|
||||
res = '0';
|
||||
outmsg = 0;
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
if (maxtime) {
|
||||
time(&end);
|
||||
if (maxtime < (end - start)) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "Took too long, cutting it short...\n");
|
||||
outmsg = 2;
|
||||
res = 't';
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ast_frfree(f);
|
||||
}
|
||||
if (end == start) time(&end);
|
||||
if (!f) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "User hung up\n");
|
||||
res = -1;
|
||||
outmsg=1;
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Error creating writestream '%s', format '%s'\n", recordfile, sfmt[x]);
|
||||
}
|
||||
|
||||
*duration = end - start;
|
||||
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
if (!others[x])
|
||||
break;
|
||||
if (res > 0) {
|
||||
if (totalsilence)
|
||||
ast_stream_rewind(others[x], totalsilence-200);
|
||||
else
|
||||
ast_stream_rewind(others[x], 200);
|
||||
}
|
||||
ast_truncstream(others[x]);
|
||||
ast_closestream(others[x]);
|
||||
}
|
||||
if (rfmt) {
|
||||
if (ast_set_read_format(chan, rfmt)) {
|
||||
ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
|
||||
}
|
||||
}
|
||||
if (outmsg > 1) {
|
||||
/* Let them know recording is stopped */
|
||||
if(!ast_streamfile(chan, "auth-thankyou", chan->language))
|
||||
ast_waitstream(chan, "");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence)
|
||||
{
|
||||
char d = 0, *fmts;
|
||||
char comment[256];
|
||||
int x, fmtcnt=1, res=-1,outmsg=0;
|
||||
struct ast_frame *f;
|
||||
struct ast_filestream *others[MAX_OTHER_FORMATS];
|
||||
struct ast_filestream *realfiles[MAX_OTHER_FORMATS];
|
||||
char *sfmt[MAX_OTHER_FORMATS];
|
||||
char *stringp=NULL;
|
||||
time_t start, end;
|
||||
struct ast_dsp *sildet; /* silence detector dsp */
|
||||
int totalsilence = 0;
|
||||
int dspsilence = 0;
|
||||
int gotsilence = 0; /* did we timeout for silence? */
|
||||
int rfmt=0;
|
||||
char prependfile[80];
|
||||
|
||||
if (silencethreshold < 0)
|
||||
silencethreshold = global_silence_threshold;
|
||||
|
||||
if (maxsilence < 0)
|
||||
maxsilence = global_maxsilence;
|
||||
|
||||
/* barf if no pointer passed to store duration in */
|
||||
if (duration == NULL) {
|
||||
ast_log(LOG_WARNING, "Error play_and_prepend called without duration pointer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG,"play_and_prepend: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
|
||||
snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
|
||||
|
||||
if (playfile || beep) {
|
||||
if (!beep)
|
||||
d = ast_play_and_wait(chan, playfile);
|
||||
if (d > -1)
|
||||
d = ast_streamfile(chan, "beep",chan->language);
|
||||
if (!d)
|
||||
d = ast_waitstream(chan,"");
|
||||
if (d < 0)
|
||||
return -1;
|
||||
}
|
||||
strncpy(prependfile, recordfile, sizeof(prependfile) -1);
|
||||
strncat(prependfile, "-prepend", sizeof(prependfile) - strlen(prependfile) - 1);
|
||||
|
||||
fmts = ast_strdupa(fmt);
|
||||
|
||||
stringp=fmts;
|
||||
strsep(&stringp, "|");
|
||||
ast_log(LOG_DEBUG,"Recording Formats: sfmts=%s\n", fmts);
|
||||
sfmt[0] = ast_strdupa(fmts);
|
||||
|
||||
while((fmt = strsep(&stringp, "|"))) {
|
||||
if (fmtcnt > MAX_OTHER_FORMATS - 1) {
|
||||
ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app_voicemail.c\n");
|
||||
break;
|
||||
}
|
||||
sfmt[fmtcnt++] = ast_strdupa(fmt);
|
||||
}
|
||||
|
||||
time(&start);
|
||||
end=start; /* pre-initialize end to be same as start in case we never get into loop */
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
others[x] = ast_writefile(prependfile, sfmt[x], comment, O_TRUNC, 0, 0700);
|
||||
ast_verbose( VERBOSE_PREFIX_3 "x=%i, open writing: %s format: %s, %p\n", x, prependfile, sfmt[x], others[x]);
|
||||
if (!others[x]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sildet = ast_dsp_new(); /* Create the silence detector */
|
||||
if (!sildet) {
|
||||
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
|
||||
return -1;
|
||||
}
|
||||
ast_dsp_set_threshold(sildet, silencethreshold);
|
||||
|
||||
if (maxsilence > 0) {
|
||||
rfmt = chan->readformat;
|
||||
res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == fmtcnt) {
|
||||
/* Loop forever, writing the packets we read to the writer(s), until
|
||||
we read a # or get a hangup */
|
||||
f = NULL;
|
||||
for(;;) {
|
||||
res = ast_waitfor(chan, 2000);
|
||||
if (!res) {
|
||||
ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
|
||||
/* Try one more time in case of masq */
|
||||
res = ast_waitfor(chan, 2000);
|
||||
if (!res) {
|
||||
ast_log(LOG_WARNING, "No audio available on %s??\n", chan->name);
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
f = NULL;
|
||||
break;
|
||||
}
|
||||
f = ast_read(chan);
|
||||
if (!f)
|
||||
break;
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
/* write each format */
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
if (!others[x])
|
||||
break;
|
||||
res = ast_writestream(others[x], f);
|
||||
}
|
||||
|
||||
/* Silence Detection */
|
||||
if (maxsilence > 0) {
|
||||
dspsilence = 0;
|
||||
ast_dsp_silence(sildet, f, &dspsilence);
|
||||
if (dspsilence)
|
||||
totalsilence = dspsilence;
|
||||
else
|
||||
totalsilence = 0;
|
||||
|
||||
if (totalsilence > maxsilence) {
|
||||
/* Ended happily with silence */
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "Recording automatically stopped after a silence of %d seconds\n", totalsilence/1000);
|
||||
ast_frfree(f);
|
||||
gotsilence = 1;
|
||||
outmsg=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Exit on any error */
|
||||
if (res) {
|
||||
ast_log(LOG_WARNING, "Error writing frame\n");
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
} else if (f->frametype == AST_FRAME_VIDEO) {
|
||||
/* Write only once */
|
||||
ast_writestream(others[0], f);
|
||||
} else if (f->frametype == AST_FRAME_DTMF) {
|
||||
/* stop recording with any digit */
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "User ended message by pressing %c\n", f->subclass);
|
||||
res = 't';
|
||||
outmsg = 2;
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
if (maxtime) {
|
||||
time(&end);
|
||||
if (maxtime < (end - start)) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "Took too long, cutting it short...\n");
|
||||
res = 't';
|
||||
outmsg=2;
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ast_frfree(f);
|
||||
}
|
||||
if (end == start) time(&end);
|
||||
if (!f) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose( VERBOSE_PREFIX_3 "User hung up\n");
|
||||
res = -1;
|
||||
outmsg=1;
|
||||
#if 0
|
||||
/* delete all the prepend files */
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
if (!others[x])
|
||||
break;
|
||||
ast_closestream(others[x]);
|
||||
ast_filedelete(prependfile, sfmt[x]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Error creating writestream '%s', format '%s'\n", prependfile, sfmt[x]);
|
||||
}
|
||||
*duration = end - start;
|
||||
#if 0
|
||||
if (outmsg > 1) {
|
||||
#else
|
||||
if (outmsg) {
|
||||
#endif
|
||||
struct ast_frame *fr;
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
snprintf(comment, sizeof(comment), "Opening the real file %s.%s\n", recordfile, sfmt[x]);
|
||||
realfiles[x] = ast_readfile(recordfile, sfmt[x], comment, O_RDONLY, 0, 0);
|
||||
if (!others[x] || !realfiles[x])
|
||||
break;
|
||||
if (totalsilence)
|
||||
ast_stream_rewind(others[x], totalsilence-200);
|
||||
else
|
||||
ast_stream_rewind(others[x], 200);
|
||||
ast_truncstream(others[x]);
|
||||
/* add the original file too */
|
||||
while ((fr = ast_readframe(realfiles[x]))) {
|
||||
ast_writestream(others[x],fr);
|
||||
}
|
||||
ast_closestream(others[x]);
|
||||
ast_closestream(realfiles[x]);
|
||||
ast_filerename(prependfile, recordfile, sfmt[x]);
|
||||
#if 0
|
||||
ast_verbose("Recording Format: sfmts=%s, prependfile %s, recordfile %s\n", sfmt[x],prependfile,recordfile);
|
||||
#endif
|
||||
ast_filedelete(prependfile, sfmt[x]);
|
||||
}
|
||||
}
|
||||
if (rfmt) {
|
||||
if (ast_set_read_format(chan, rfmt)) {
|
||||
ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
|
||||
}
|
||||
}
|
||||
if (outmsg) {
|
||||
if (outmsg > 1) {
|
||||
/* Let them know it worked */
|
||||
ast_streamfile(chan, "auth-thankyou", chan->language);
|
||||
ast_waitstream(chan, "");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@@ -1 +0,0 @@
|
||||
.depend
|
5
apps/Makefile
Executable file → Normal file
5
apps/Makefile
Executable file → Normal file
@@ -28,7 +28,8 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
|
||||
app_setcdruserfield.so app_random.so app_ices.so app_eval.so \
|
||||
app_nbscat.so app_sendtext.so app_exec.so app_sms.so \
|
||||
app_groupcount.so app_txtcidname.so app_controlplayback.so \
|
||||
app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so
|
||||
app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so \
|
||||
app_test.so app_forkcdr.so
|
||||
|
||||
ifneq (${OSARCH},Darwin)
|
||||
APPS+=app_intercom.so
|
||||
@@ -88,7 +89,7 @@ app_sql_odbc.so: app_sql_odbc.o
|
||||
$(CC) $(SOLINK) -o $@ $< -lodbc
|
||||
|
||||
look: look.c
|
||||
gcc -pipe -O6 -g look.c -o look -lncurses
|
||||
$(CC) -pipe -O6 -g look.c -o look -lncurses
|
||||
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
|
0
apps/app_adsiprog.c
Executable file → Normal file
0
apps/app_adsiprog.c
Executable file → Normal file
4
apps/app_alarmreceiver.c
Executable file → Normal file
4
apps/app_alarmreceiver.c
Executable file → Normal file
@@ -55,7 +55,7 @@ static char *tdesc = "Alarm Receiver for Asterisk";
|
||||
|
||||
static char *app = "AlarmReceiver";
|
||||
|
||||
static char *synopsis = "Provide support for receving alarm reports from a burglar or fire alarm panel\n";
|
||||
static char *synopsis = "Provide support for receving alarm reports from a burglar or fire alarm panel";
|
||||
static char *descrip =
|
||||
"Alarm receiver application for Asterisk. Only 1 signalling format is supported at this time:\n"
|
||||
"Ademco Contact ID. This application should be called whenever there is an alarm panel calling in\n"
|
||||
@@ -817,7 +817,7 @@ static int load_config(void)
|
||||
strncpy(db_family, p, sizeof(db_family) - 1);
|
||||
db_family[sizeof(db_family) - 1] = '\0';
|
||||
}
|
||||
|
||||
ast_destroy(cfg);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
0
apps/app_authenticate.c
Executable file → Normal file
0
apps/app_authenticate.c
Executable file → Normal file
0
apps/app_cdr.c
Executable file → Normal file
0
apps/app_cdr.c
Executable file → Normal file
11
apps/app_chanisavail.c
Executable file → Normal file
11
apps/app_chanisavail.c
Executable file → Normal file
@@ -38,11 +38,12 @@ static char *descrip =
|
||||
"Checks is any of the requested channels are available. If none\n"
|
||||
"of the requested channels are available the new priority will be\n"
|
||||
"n+101 (unless such a priority does not exist or on error, in which\n"
|
||||
"case ChanIsAvail will return -1). If any of the requested channels\n"
|
||||
"are available, the next priority will be n+1, the channel variable\n"
|
||||
"${AVAILCHAN} will be set to the name of the available channel and\n"
|
||||
"the ChanIsAvail app will return 0. ${AVAILORIGCHAN} is\n"
|
||||
"the canonical channel name that was used to create the channel.\n";
|
||||
"case ChanIsAvail will return -1).\n"
|
||||
"If any of the requested channels are available, the next priority will be n+1,\n"
|
||||
"the channel variable ${AVAILCHAN} will be set to the name of the available channel\n"
|
||||
"and the ChanIsAvail app will return 0.\n"
|
||||
"${AVAILORIGCHAN} is the canonical channel name that was used to create the channel.\n"
|
||||
"${AVAILSTATUS} is the status code for the channel.\n";
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
|
0
apps/app_controlplayback.c
Executable file → Normal file
0
apps/app_controlplayback.c
Executable file → Normal file
0
apps/app_cut.c
Executable file → Normal file
0
apps/app_cut.c
Executable file → Normal file
0
apps/app_datetime.c
Executable file → Normal file
0
apps/app_datetime.c
Executable file → Normal file
0
apps/app_db.c
Executable file → Normal file
0
apps/app_db.c
Executable file → Normal file
83
apps/app_dial.c
Executable file → Normal file
83
apps/app_dial.c
Executable file → Normal file
@@ -3,9 +3,9 @@
|
||||
*
|
||||
* Trivial application to dial a channel and send an URL on answer
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -67,6 +67,7 @@ static char *descrip =
|
||||
" that are assigned to you.\n"
|
||||
" 'r' -- indicate ringing to the calling party, pass no audio until answered.\n"
|
||||
" 'm' -- provide hold music to the calling party until answered.\n"
|
||||
" 'M(x) -- Executes the macro (x) upon connect of the call\n"
|
||||
" 'h' -- allow callee to hang up by hitting *.\n"
|
||||
" 'H' -- allow caller to hang up by hitting *.\n"
|
||||
" 'C' -- reset call detail record for this call.\n"
|
||||
@@ -250,10 +251,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||
if (!o->chan->callerid)
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
} else {
|
||||
if (in->callerid)
|
||||
if (in->callerid) {
|
||||
o->chan->callerid = strdup(in->callerid);
|
||||
if (!o->chan->callerid)
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
if (!o->chan->callerid)
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
}
|
||||
strncpy(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode) - 1);
|
||||
o->chan->cdrflags = in->cdrflags;
|
||||
}
|
||||
@@ -279,6 +281,9 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||
ast_hangup(o->chan);
|
||||
o->chan = NULL;
|
||||
numnochan++;
|
||||
} else {
|
||||
/* After calling, set callerid to extension */
|
||||
ast_set_callerid(o->chan, ast_strlen_zero(in->macroexten) ? in->exten : in->macroexten, 0);
|
||||
}
|
||||
}
|
||||
/* Hangup the original channel now, in case we needed it */
|
||||
@@ -334,7 +339,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||
case AST_CONTROL_PROGRESS:
|
||||
if (option_verbose > 2)
|
||||
ast_verbose ( VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", o->chan->name,in->name);
|
||||
ast_indicate(in, AST_CONTROL_PROGRESS);
|
||||
if (!outgoing->ringbackonly)
|
||||
ast_indicate(in, AST_CONTROL_PROGRESS);
|
||||
break;
|
||||
case AST_CONTROL_OFFHOOK:
|
||||
/* Ignore going off hook */
|
||||
@@ -381,6 +387,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||
/* Got hung up */
|
||||
*to=-1;
|
||||
strncpy(status, "CANCEL", statussize - 1);
|
||||
if (f)
|
||||
ast_frfree(f);
|
||||
return NULL;
|
||||
}
|
||||
if (f && (f->frametype == AST_FRAME_DTMF) && *allowdisconnect_out &&
|
||||
@@ -389,6 +397,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
||||
ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass);
|
||||
*to=0;
|
||||
strcpy(status, "CANCEL");
|
||||
ast_frfree(f);
|
||||
return NULL;
|
||||
}
|
||||
if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF))) {
|
||||
@@ -409,7 +418,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=-1;
|
||||
struct localuser *u;
|
||||
char info[256], *peers, *timeout, *tech, *number, *rest, *cur;
|
||||
char *info, *peers, *timeout, *tech, *number, *rest, *cur;
|
||||
char privdb[256] = "", *s;
|
||||
char announcemsg[256] = "", *ann;
|
||||
struct localuser *outgoing=NULL, *tmp;
|
||||
@@ -419,6 +428,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
int allowredir_out=0;
|
||||
int allowdisconnect_in=0;
|
||||
int allowdisconnect_out=0;
|
||||
int hasmacro = 0;
|
||||
int privacy=0;
|
||||
int announce=0;
|
||||
int resetcdr=0;
|
||||
@@ -447,6 +457,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
char *sdtmfptr;
|
||||
char sdtmfdata[256] = "";
|
||||
char *stack,*var;
|
||||
char *mac = NULL, macroname[256] = "";
|
||||
char status[256]="";
|
||||
char toast[80];
|
||||
int play_to_caller=0,play_to_callee=0;
|
||||
@@ -458,10 +469,13 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (!(info = ast_strdupa(data))) {
|
||||
ast_log(LOG_WARNING, "Unable to dupe data :(\n");
|
||||
return -1;
|
||||
}
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
strncpy(info, (char *)data, sizeof(info) - 1);
|
||||
peers = info;
|
||||
if (peers) {
|
||||
|
||||
@@ -609,6 +623,27 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
announce = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the macroname from the dial option string */
|
||||
if ((mac = strstr(transfer, "M("))) {
|
||||
hasmacro = 1;
|
||||
strncpy(macroname, mac + 2, sizeof(macroname) - 1);
|
||||
while (*mac && (*mac != ')'))
|
||||
*(mac++) = 'X';
|
||||
if (*mac)
|
||||
*mac = 'X';
|
||||
else {
|
||||
ast_log(LOG_WARNING, "Could not find macro to which we should jump.\n");
|
||||
hasmacro = 0;
|
||||
}
|
||||
mac = strchr(macroname, ')');
|
||||
if (mac)
|
||||
*mac = '\0';
|
||||
else {
|
||||
ast_log(LOG_WARNING, "Macro flag set without trailing ')'\n");
|
||||
hasmacro = 0;
|
||||
}
|
||||
}
|
||||
/* Extract privacy info from transfer */
|
||||
if ((s = strstr(transfer, "P("))) {
|
||||
privacy = 1;
|
||||
@@ -813,9 +848,11 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
free(tmp);
|
||||
cur = rest;
|
||||
continue;
|
||||
} else
|
||||
} else {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst);
|
||||
ast_set_callerid(tmp->chan, ast_strlen_zero(chan->macroexten) ? chan->exten : chan->macroexten, 0);
|
||||
}
|
||||
/* Put them in the list of outgoing thingies... We're ready now.
|
||||
XXX If we're forcibly removed, these outgoing calls won't get
|
||||
hung up XXX */
|
||||
@@ -906,6 +943,32 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
||||
} else
|
||||
res = 0;
|
||||
|
||||
if (hasmacro && macroname) {
|
||||
void *app = NULL;
|
||||
|
||||
res = ast_autoservice_start(chan);
|
||||
if (res) {
|
||||
ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n");
|
||||
res = -1;
|
||||
}
|
||||
|
||||
app = pbx_findapp("Macro");
|
||||
|
||||
if (app && !res) {
|
||||
res = pbx_exec(peer, app, macroname, 1);
|
||||
ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
|
||||
res = 0;
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Could not find application Macro\n");
|
||||
res = -1;
|
||||
}
|
||||
|
||||
if (ast_autoservice_stop(chan) < 0) {
|
||||
ast_log(LOG_ERROR, "Could not stop autoservice on calling channel\n");
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
if (calldurationlimit > 0) {
|
||||
time(&now);
|
||||
|
2
apps/app_directory.c
Executable file → Normal file
2
apps/app_directory.c
Executable file → Normal file
@@ -184,7 +184,7 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
|
||||
ast_log(LOG_WARNING,
|
||||
"Can't find extension '%s' in context '%s'. "
|
||||
"Did you pass the wrong context to Directory?\n",
|
||||
ext, context);
|
||||
ext, dialcontext);
|
||||
res = -1;
|
||||
}
|
||||
break;
|
||||
|
126
apps/app_disa.c
Executable file → Normal file
126
apps/app_disa.c
Executable file → Normal file
@@ -17,6 +17,7 @@
|
||||
#include <asterisk/file.h>
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/indications.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <asterisk/translate.h>
|
||||
@@ -27,9 +28,6 @@
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/*
|
||||
#define TONE_BLOCK_SIZE 320
|
||||
*/
|
||||
|
||||
static char *tdesc = "DISA (Direct Inward System Access) Application";
|
||||
|
||||
@@ -82,27 +80,9 @@ STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static float loudness=4096.0;
|
||||
|
||||
static int firstdigittimeout = 20000; /* 20 seconds first digit timeout */
|
||||
static int digittimeout = 10000; /* 10 seconds subsequent digit timeout */
|
||||
|
||||
static void make_tone_block(unsigned char *data, float f1, float f2, int len, int *x)
|
||||
{
|
||||
int i;
|
||||
float val;
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
val = loudness * sin((f1 * 2.0 * M_PI * (*x))/8000.0);
|
||||
val += loudness * sin((f2 * 2.0 * M_PI * (*x)++)/8000.0);
|
||||
data[i] = AST_LIN2MU((int)val);
|
||||
}
|
||||
/* wrap back around from 8000 */
|
||||
if (*x >= 8000) *x = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static int ms_diff(struct timeval *tv1, struct timeval *tv2)
|
||||
{
|
||||
int ms;
|
||||
@@ -112,19 +92,26 @@ int ms;
|
||||
return(ms);
|
||||
}
|
||||
|
||||
static void play_dialtone(struct ast_channel *chan)
|
||||
{
|
||||
const struct tone_zone_sound *ts = NULL;
|
||||
ts = ast_get_indication_tone(chan->zone, "dial");
|
||||
if (ts)
|
||||
ast_playtones_start(chan, 0, ts->data, 0);
|
||||
else
|
||||
ast_tonepair_start(chan, 350, 440, 0, 0);
|
||||
}
|
||||
|
||||
static int disa_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int i,j,k,x;
|
||||
int i,j,k,x,did_ignore;
|
||||
struct localuser *u;
|
||||
char tmp[256],arg2[256]="",exten[AST_MAX_EXTENSION],acctcode[20]="";
|
||||
struct {
|
||||
unsigned char offset[AST_FRIENDLY_OFFSET];
|
||||
unsigned char buf[640];
|
||||
} tone_block;
|
||||
char *ourcontext,*ourcallerid;
|
||||
struct ast_frame *f,wf;
|
||||
struct ast_frame *f;
|
||||
struct timeval lastout, now, lastdigittime;
|
||||
int res;
|
||||
time_t rstart;
|
||||
FILE *fp;
|
||||
char *stringp=NULL;
|
||||
|
||||
@@ -165,15 +152,22 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
ast_answer(chan);
|
||||
}
|
||||
i = k = x = 0; /* k is 0 for pswd entry, 1 for ext entry */
|
||||
did_ignore = 0;
|
||||
exten[0] = 0;
|
||||
acctcode[0] = 0;
|
||||
/* can we access DISA without password? */
|
||||
|
||||
ast_log(LOG_DEBUG, "Context: %s\n",ourcontext);
|
||||
|
||||
if (!strcasecmp(tmp, "no-password"))
|
||||
{;
|
||||
k = 1;
|
||||
ast_log(LOG_DEBUG, "DISA no-password login success\n");
|
||||
}
|
||||
gettimeofday(&lastdigittime,NULL);
|
||||
|
||||
play_dialtone(chan);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
gettimeofday(&now,NULL);
|
||||
@@ -204,25 +198,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
return -1;
|
||||
}
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
if (!i || (ast_ignore_pattern(ourcontext, exten) && k)) {
|
||||
wf.frametype = AST_FRAME_VOICE;
|
||||
wf.subclass = AST_FORMAT_ULAW;
|
||||
wf.offset = AST_FRIENDLY_OFFSET;
|
||||
wf.mallocd = 0;
|
||||
wf.data = tone_block.buf;
|
||||
wf.datalen = f->datalen;
|
||||
wf.delivery.tv_sec = wf.delivery.tv_usec = 0;
|
||||
make_tone_block(tone_block.buf, 350, 440, f->datalen, &x);
|
||||
wf.samples = wf.datalen;
|
||||
ast_frfree(f);
|
||||
if (ast_write(chan, &wf))
|
||||
{
|
||||
ast_log(LOG_WARNING, "DISA Failed to write frame on %s\n",chan->name);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
ast_frfree(f);
|
||||
ast_frfree(f);
|
||||
continue;
|
||||
}
|
||||
/* if not DTMF, just do it again */
|
||||
@@ -234,7 +210,9 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
|
||||
j = f->subclass; /* save digit */
|
||||
ast_frfree(f);
|
||||
|
||||
if (i == 0)
|
||||
ast_playtones_stop(chan);
|
||||
|
||||
gettimeofday(&lastdigittime,NULL);
|
||||
/* got a DTMF tone */
|
||||
if (i < AST_MAX_EXTENSION) /* if still valid number of digits */
|
||||
@@ -287,7 +265,9 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
|
||||
}
|
||||
/* password good, set to dial state */
|
||||
ast_log(LOG_WARNING,"DISA on chan %s password is good\n",chan->name);
|
||||
ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
|
||||
play_dialtone(chan);
|
||||
|
||||
k = 1;
|
||||
i = 0; /* re-set buffer pointer */
|
||||
exten[sizeof(acctcode)] = 0;
|
||||
@@ -297,19 +277,31 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
exten[i++] = j; /* save digit */
|
||||
exten[i] = 0;
|
||||
if (!k) continue; /* if getting password, continue doing it */
|
||||
/* if this exists */
|
||||
|
||||
if (ast_ignore_pattern(ourcontext, exten)) {
|
||||
play_dialtone(chan);
|
||||
did_ignore = 1;
|
||||
} else
|
||||
if (did_ignore) {
|
||||
ast_playtones_stop(chan);
|
||||
did_ignore = 0;
|
||||
}
|
||||
|
||||
/* if can do some more, do it */
|
||||
if (!ast_matchmore_extension(chan,ourcontext,exten,1, chan->callerid))
|
||||
if (!ast_matchmore_extension(chan,ourcontext,exten,1, chan->callerid)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k && ast_exists_extension(chan,ourcontext,exten,1, chan->callerid))
|
||||
{
|
||||
ast_playtones_stop(chan);
|
||||
/* We're authenticated and have a valid extension */
|
||||
if (ourcallerid && *ourcallerid)
|
||||
{
|
||||
@@ -326,44 +318,20 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
||||
}
|
||||
|
||||
reorder:
|
||||
|
||||
/* something is invalid, give em reorder forever */
|
||||
x = 0;
|
||||
k = 0; /* k = 0 means busy tone, k = 1 means silence) */
|
||||
i = 0; /* Number of samples we've done */
|
||||
for(;;)
|
||||
|
||||
ast_indicate(chan,AST_CONTROL_CONGESTION);
|
||||
/* something is invalid, give em reorder for several seconds */
|
||||
time(&rstart);
|
||||
while(time(NULL) < rstart + 10)
|
||||
{
|
||||
if (ast_waitfor(chan, -1) < 0)
|
||||
break;
|
||||
f = ast_read(chan);
|
||||
if (!f)
|
||||
break;
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
wf.frametype = AST_FRAME_VOICE;
|
||||
wf.subclass = AST_FORMAT_ULAW;
|
||||
wf.offset = AST_FRIENDLY_OFFSET;
|
||||
wf.mallocd = 0;
|
||||
wf.data = tone_block.buf;
|
||||
wf.datalen = f->datalen;
|
||||
wf.samples = wf.datalen;
|
||||
if (k)
|
||||
memset(tone_block.buf, 0x7f, wf.datalen);
|
||||
else
|
||||
make_tone_block(tone_block.buf,480.0, 620.0,wf.datalen, &x);
|
||||
i += wf.datalen / 8;
|
||||
if (i > 250) {
|
||||
i = 0;
|
||||
k = !k;
|
||||
}
|
||||
if (ast_write(chan, &wf))
|
||||
{
|
||||
ast_log(LOG_WARNING, "DISA Failed to write frame on %s\n",chan->name);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ast_frfree(f);
|
||||
}
|
||||
ast_playtones_stop(chan);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return -1;
|
||||
}
|
||||
|
0
apps/app_echo.c
Executable file → Normal file
0
apps/app_echo.c
Executable file → Normal file
0
apps/app_enumlookup.c
Executable file → Normal file
0
apps/app_enumlookup.c
Executable file → Normal file
0
apps/app_eval.c
Executable file → Normal file
0
apps/app_eval.c
Executable file → Normal file
0
apps/app_exec.c
Executable file → Normal file
0
apps/app_exec.c
Executable file → Normal file
7
apps/app_festival.c
Executable file → Normal file
7
apps/app_festival.c
Executable file → Normal file
@@ -307,6 +307,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
}
|
||||
if (!vdata || ast_strlen_zero(vdata)) {
|
||||
ast_log(LOG_WARNING, "festival requires an argument (text)\n");
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
strncpy(data, vdata, sizeof(data) - 1);
|
||||
@@ -324,6 +325,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
|
||||
if (fd < 0) {
|
||||
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
memset(&serv_addr, 0, sizeof(serv_addr));
|
||||
@@ -332,6 +334,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
serverhost = ast_gethostbyname(host, &ahp);
|
||||
if (serverhost == (struct hostent *)0) {
|
||||
ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
|
||||
@@ -341,6 +344,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
|
||||
ast_log(LOG_WARNING,"festival_client: connect to server failed\n");
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -362,7 +366,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
|
||||
fdesc=open(cachefile,O_RDWR);
|
||||
if (fdesc==-1) {
|
||||
fdesc=open(cachefile,O_CREAT|O_RDWR,0);
|
||||
fdesc=open(cachefile,O_CREAT|O_RDWR,0777);
|
||||
if (fdesc!=-1) {
|
||||
writecache=1;
|
||||
strln=strlen((char *)data);
|
||||
@@ -443,6 +447,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
|
||||
}
|
||||
} while (strcmp(ack,"OK\n") != 0);
|
||||
close(fd);
|
||||
ast_destroy(cfg);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
|
||||
|
0
apps/app_flash.c
Executable file → Normal file
0
apps/app_flash.c
Executable file → Normal file
90
apps/app_forkcdr.c
Normal file
90
apps/app_forkcdr.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Fork CDR application
|
||||
* Copyright Anthony Minessale anthmct@yahoo.com
|
||||
* Development of this app Sponsered/Funded by TAAN Softworks Corp
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
*/
|
||||
|
||||
#include <asterisk/file.h>
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/cdr.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static char *tdesc = "Fork The CDR into 2 seperate entities.";
|
||||
static char *app = "ForkCDR";
|
||||
static char *synopsis =
|
||||
"Forks the Call Data Record";
|
||||
static char *descrip =
|
||||
" ForkCDR(): Causes the Call Data Record to fork an additional\n"
|
||||
"cdr record starting from the time of the fork call\n";
|
||||
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
|
||||
static void ast_cdr_clone(struct ast_cdr *cdr) {
|
||||
struct ast_cdr *newcdr = ast_cdr_alloc();
|
||||
memcpy(newcdr,cdr,sizeof(struct ast_cdr));
|
||||
ast_cdr_append(cdr,newcdr);
|
||||
gettimeofday(&newcdr->start, NULL);
|
||||
memset(&newcdr->answer, 0, sizeof(newcdr->answer));
|
||||
ast_cdr_add_flag(cdr,AST_CDR_FLAG_CHILD|AST_CDR_FLAG_LOCKED);
|
||||
}
|
||||
|
||||
static void ast_cdr_fork(struct ast_channel *chan) {
|
||||
if(chan && chan->cdr) {
|
||||
ast_cdr_clone(chan->cdr);
|
||||
}
|
||||
}
|
||||
|
||||
static int forkcdr_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=0;
|
||||
struct localuser *u;
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
ast_cdr_fork(chan);
|
||||
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
return ast_unregister_application(app);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_register_application(app, forkcdr_exec, synopsis, descrip);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
int res;
|
||||
STANDARD_USECOUNT(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *key()
|
||||
{
|
||||
return ASTERISK_GPL_KEY;
|
||||
}
|
10
apps/app_getcpeid.c
Executable file → Normal file
10
apps/app_getcpeid.c
Executable file → Normal file
@@ -3,9 +3,9 @@
|
||||
*
|
||||
* Execute arbitrary system commands
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2005, Digium
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -31,9 +31,9 @@ static char *app = "GetCPEID";
|
||||
static char *synopsis = "Get ADSI CPE ID";
|
||||
|
||||
static char *descrip =
|
||||
" GetCPEID: Obtains and displays CPE ID and other information in order to\n"
|
||||
"properly setup zapata.conf for on-hook operations. Returns -1 on hanup\n"
|
||||
"only.";
|
||||
" GetCPEID: Obtains and displays ADSI CPE ID and other information in order\n"
|
||||
"to properly setup zapata.conf for on-hook operations.\n"
|
||||
"Returns -1 on hangup only.\n";
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
|
0
apps/app_groupcount.c
Executable file → Normal file
0
apps/app_groupcount.c
Executable file → Normal file
30
apps/app_hasnewvoicemail.c
Executable file → Normal file
30
apps/app_hasnewvoicemail.c
Executable file → Normal file
@@ -38,6 +38,7 @@
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/utils.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
@@ -70,7 +71,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=0;
|
||||
struct localuser *u;
|
||||
char vmpath[256], *input, *varname = NULL, *vmbox, *vmfolder = "INBOX", *context = "default";
|
||||
char vmpath[256], *temps, *input, *varname = NULL, *vmbox, *vmfolder = "INBOX", *context = "default";
|
||||
DIR *vmdir;
|
||||
struct dirent *vment;
|
||||
int vmcount = 0;
|
||||
@@ -83,21 +84,22 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
||||
|
||||
input = ast_strdupa((char *)data);
|
||||
if (input) {
|
||||
if ((vmbox = strsep(&input,":")))
|
||||
if ((vmfolder = strsep(&input,"|")))
|
||||
temps = input;
|
||||
if ((temps = strsep(&input, "|"))) {
|
||||
if (input && !ast_strlen_zero(input))
|
||||
varname = input;
|
||||
else
|
||||
vmfolder = input;
|
||||
else
|
||||
if ((vmbox = strsep(&input,"|")))
|
||||
varname = input;
|
||||
else
|
||||
vmbox = input;
|
||||
|
||||
if (index(vmbox,'@')) {
|
||||
context = vmbox;
|
||||
vmbox = strsep(&context,"@");
|
||||
input = temps;
|
||||
}
|
||||
if ((temps = strsep(&input, ":"))) {
|
||||
if (input && !ast_strlen_zero(input))
|
||||
vmfolder = input;
|
||||
input = temps;
|
||||
}
|
||||
if ((vmbox = strsep(&input, "@")))
|
||||
if (input && !ast_strlen_zero(input))
|
||||
context = input;
|
||||
if (!vmbox)
|
||||
vmbox = input;
|
||||
|
||||
snprintf(vmpath,sizeof(vmpath), "%s/voicemail/%s/%s/%s", (char *)ast_config_AST_SPOOL_DIR, context, vmbox, vmfolder);
|
||||
if (!(vmdir = opendir(vmpath))) {
|
||||
|
0
apps/app_ices.c
Executable file → Normal file
0
apps/app_ices.c
Executable file → Normal file
0
apps/app_image.c
Executable file → Normal file
0
apps/app_image.c
Executable file → Normal file
0
apps/app_intercom.c
Executable file → Normal file
0
apps/app_intercom.c
Executable file → Normal file
0
apps/app_lookupblacklist.c
Executable file → Normal file
0
apps/app_lookupblacklist.c
Executable file → Normal file
0
apps/app_lookupcidname.c
Executable file → Normal file
0
apps/app_lookupcidname.c
Executable file → Normal file
3
apps/app_macro.c
Executable file → Normal file
3
apps/app_macro.c
Executable file → Normal file
@@ -140,7 +140,8 @@ static int macro_exec(struct ast_channel *chan, void *data)
|
||||
while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
|
||||
if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) {
|
||||
/* Something bad happened, or a hangup has been requested. */
|
||||
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
|
||||
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
|
||||
(res == '*') || (res == '#')) {
|
||||
/* Just return result as to the previous application as if it had been dialed */
|
||||
ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
|
||||
break;
|
||||
|
88
apps/app_meetme.c
Executable file → Normal file
88
apps/app_meetme.c
Executable file → Normal file
@@ -3,9 +3,9 @@
|
||||
*
|
||||
* Meet me conference bridge
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -69,13 +69,14 @@ static char *descrip =
|
||||
" 'v' -- video mode\n"
|
||||
" 'q' -- quiet mode (don't play enter/leave sounds)\n"
|
||||
" 'M' -- enable music on hold when the conference has a single caller\n"
|
||||
" 'x' -- close the conference when last user marked with 'x' exits\n"
|
||||
" 'w' -- wait until a user marked with the 'x' option enters the conference\n"
|
||||
" 'x' -- close the conference when last marked user exits\n"
|
||||
" 'w' -- wait until the marked user enters the conference\n"
|
||||
" 'b' -- run AGI script specified in ${MEETME_AGI_BACKGROUND}\n"
|
||||
" Default: conf-background.agi\n"
|
||||
" (Note: This does not work with non-Zap channels in the same conference)\n"
|
||||
" 's' -- Present menu (user or admin) when '*' is received ('send' to menu)\n"
|
||||
" 'a' -- set admin mode\n";
|
||||
" 'a' -- set admin mode\n"
|
||||
" 'A' -- set marked mode\n";
|
||||
|
||||
static char *descrip2 =
|
||||
" MeetMeCount(confno[|var]): Plays back the number of users in the specifiedi\n"
|
||||
@@ -149,9 +150,10 @@ static int admin_exec(struct ast_channel *chan, void *data);
|
||||
#define CONFFLAG_VIDEO (1 << 7) /* Set to enable video mode */
|
||||
#define CONFFLAG_AGI (1 << 8) /* Set to run AGI Script in Background */
|
||||
#define CONFFLAG_MOH (1 << 9) /* Set to have music on hold when user is alone in conference */
|
||||
#define CONFFLAG_ADMINEXIT (1 << 10) /* If set the MeetMe will return if all marked with this flag left */
|
||||
#define CONFFLAG_WAITMARKED (1 << 11) /* If set, the MeetMe will wait until a marked user enters */
|
||||
#define CONFFLAG_EXIT_CONTEXT (1 << 12) /* If set, the MeetMe will wait until a marked user enters */
|
||||
#define CONFFLAG_MARKEDEXIT (1 << 10) /* If set the MeetMe will return if all marked with this flag left */
|
||||
#define CONFFLAG_WAITMARKED (1 << 11) /* If set, the MeetMe will wait until a marked user enters */
|
||||
#define CONFFLAG_EXIT_CONTEXT (1 << 12) /* If set, the MeetMe will exit to the specified context */
|
||||
#define CONFFLAG_MARKEDUSER (1 << 13) /* If set, the user will be marked */
|
||||
|
||||
|
||||
static int careful_write(int fd, unsigned char *data, int len)
|
||||
@@ -217,7 +219,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, int make, int
|
||||
memset(cnf, 0, sizeof(struct ast_conference));
|
||||
strncpy(cnf->confno, confno, sizeof(cnf->confno) - 1);
|
||||
strncpy(cnf->pin, pin, sizeof(cnf->pin) - 1);
|
||||
cnf->markedusers = -1;
|
||||
cnf->markedusers = 0;
|
||||
cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo");
|
||||
if (cnf->chan) {
|
||||
cnf->fd = cnf->chan->fds[0]; /* for use by conf_play() */
|
||||
@@ -306,7 +308,7 @@ static int conf_cmd(int fd, int argc, char **argv) {
|
||||
}
|
||||
ast_cli(fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation");
|
||||
while(cnf) {
|
||||
if (cnf->markedusers < 0)
|
||||
if (cnf->markedusers == 0)
|
||||
strncpy(cmdline, "N/A ", sizeof(cmdline) - 1);
|
||||
else
|
||||
snprintf(cmdline, sizeof(cmdline), "%4.4d", cnf->markedusers);
|
||||
@@ -475,7 +477,7 @@ static int confnonzero(void *ptr)
|
||||
struct ast_conference *conf = ptr;
|
||||
int res;
|
||||
ast_mutex_lock(&conflock);
|
||||
res = (conf->markedusers < 0);
|
||||
res = (conf->markedusers == 0);
|
||||
ast_mutex_unlock(&conflock);
|
||||
return res;
|
||||
}
|
||||
@@ -509,6 +511,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
char *agifiledefault = "conf-background.agi";
|
||||
char meetmesecs[30] = "";
|
||||
char exitcontext[AST_MAX_EXTENSION] = "";
|
||||
int dtmf;
|
||||
|
||||
ZT_BUFFERINFO bi;
|
||||
char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
|
||||
@@ -521,7 +524,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
memset(user, 0, sizeof(struct ast_conf_user));
|
||||
|
||||
user->user_no = 0; /* User number 0 means starting up user! (dead - not in the list!) */
|
||||
|
||||
|
||||
time(&user->jointime);
|
||||
|
||||
if (conf->locked) {
|
||||
/* Sorry, but this confernce is locked! */
|
||||
if (!ast_streamfile(chan, "conf-locked", chan->language))
|
||||
@@ -529,13 +534,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
goto outrun;
|
||||
}
|
||||
conf->users++;
|
||||
if (confflags & CONFFLAG_ADMINEXIT) {
|
||||
if (conf->markedusers == -1) {
|
||||
conf->markedusers = 1;
|
||||
} else {
|
||||
conf->markedusers++;
|
||||
}
|
||||
}
|
||||
if (confflags & CONFFLAG_MARKEDUSER)
|
||||
conf->markedusers++;
|
||||
|
||||
ast_mutex_lock(&conflock);
|
||||
if (conf->firstuser == NULL) {
|
||||
@@ -559,7 +559,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
conf->lastuser = user;
|
||||
}
|
||||
}
|
||||
strncpy(user->usrvalue, "test", sizeof(user->usrvalue) - 1);
|
||||
user->chan = chan;
|
||||
user->userflags = confflags;
|
||||
user->adminflags = 0;
|
||||
@@ -573,7 +572,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
|
||||
else
|
||||
strncpy(exitcontext, chan->context, sizeof(exitcontext) - 1);
|
||||
}
|
||||
while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers < 0)) {
|
||||
while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers == 0)) {
|
||||
confflags &= ~CONFFLAG_QUIET;
|
||||
confflags |= origquiet;
|
||||
/* XXX Announce that we're waiting on the conference lead to join */
|
||||
@@ -765,7 +764,7 @@ zapretry:
|
||||
}
|
||||
|
||||
/* Leave if the last marked user left */
|
||||
if (conf->markedusers == 0) {
|
||||
if (conf->markedusers == 0 && confflags & CONFFLAG_MARKEDEXIT) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
@@ -843,10 +842,14 @@ zapretry:
|
||||
menu_active = 1;
|
||||
/* Record this sound! */
|
||||
if (!ast_streamfile(chan, "conf-adminmenu", chan->language))
|
||||
ast_waitstream(chan, "");
|
||||
} else {
|
||||
switch(f->subclass - 48) {
|
||||
case 1: /* Un/Mute */
|
||||
dtmf = ast_waitstream(chan, AST_DIGIT_ANY);
|
||||
else
|
||||
dtmf = 0;
|
||||
} else
|
||||
dtmf = f->subclass;
|
||||
if (dtmf) {
|
||||
switch(dtmf) {
|
||||
case '1': /* Un/Mute */
|
||||
menu_active = 0;
|
||||
if (ztc.confmode & ZT_CONF_TALKER) {
|
||||
ztc.confmode = ZT_CONF_CONF | ZT_CONF_LISTENER;
|
||||
@@ -868,7 +871,7 @@ zapretry:
|
||||
ast_waitstream(chan, "");
|
||||
}
|
||||
break;
|
||||
case 2: /* Un/Lock the Conference */
|
||||
case '2': /* Un/Lock the Conference */
|
||||
menu_active = 0;
|
||||
if (conf->locked) {
|
||||
conf->locked = 0;
|
||||
@@ -894,10 +897,14 @@ zapretry:
|
||||
menu_active = 1;
|
||||
/* Record this sound! */
|
||||
if (!ast_streamfile(chan, "conf-usermenu", chan->language))
|
||||
ast_waitstream(chan, "");
|
||||
} else {
|
||||
switch(f->subclass - 48) {
|
||||
case 1: /* Un/Mute */
|
||||
dtmf = ast_waitstream(chan, AST_DIGIT_ANY);
|
||||
else
|
||||
dtmf = 0;
|
||||
} else
|
||||
dtmf = f->subclass;
|
||||
if (dtmf) {
|
||||
switch(dtmf) {
|
||||
case '1': /* Un/Mute */
|
||||
menu_active = 0;
|
||||
if (ztc.confmode & ZT_CONF_TALKER) {
|
||||
ztc.confmode = ZT_CONF_CONF | ZT_CONF_LISTENER;
|
||||
@@ -986,7 +993,7 @@ outrun:
|
||||
chan->name, chan->uniqueid, conf->confno, user->user_no);
|
||||
prev = NULL;
|
||||
conf->users--;
|
||||
if (confflags & CONFFLAG_ADMINEXIT)
|
||||
if (confflags & CONFFLAG_MARKEDUSER)
|
||||
conf->markedusers--;
|
||||
cur = confs;
|
||||
if (!conf->users) {
|
||||
@@ -1037,10 +1044,10 @@ outrun:
|
||||
else
|
||||
ast_log(LOG_ERROR, "Bad! Bad! Bad! user->prevuser is NULL but we're not the beginning!\n");
|
||||
}
|
||||
/* Return the number of seconds the user was in the conf */
|
||||
snprintf(meetmesecs, sizeof(meetmesecs), "%i", (int) (user->jointime - time(NULL)));
|
||||
pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
|
||||
}
|
||||
/* Return the number of seconds the user was in the conf */
|
||||
snprintf(meetmesecs, sizeof(meetmesecs), "%i", (int) (time(NULL) - user->jointime));
|
||||
pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
|
||||
}
|
||||
free(user);
|
||||
ast_mutex_unlock(&conflock);
|
||||
@@ -1210,9 +1217,11 @@ static int conf_exec(struct ast_channel *chan, void *data)
|
||||
if (strchr(inflags, 'M'))
|
||||
confflags |= CONFFLAG_MOH;
|
||||
if (strchr(inflags, 'x'))
|
||||
confflags |= CONFFLAG_ADMINEXIT;
|
||||
confflags |= CONFFLAG_MARKEDEXIT;
|
||||
if (strchr(inflags, 'X'))
|
||||
confflags |= CONFFLAG_EXIT_CONTEXT;
|
||||
if (strchr(inflags, 'A'))
|
||||
confflags |= CONFFLAG_MARKEDUSER;
|
||||
if (strchr(inflags, 'b'))
|
||||
confflags |= CONFFLAG_AGI;
|
||||
if (strchr(inflags, 'w'))
|
||||
@@ -1446,14 +1455,17 @@ static int admin_exec(struct ast_channel *chan, void *data) {
|
||||
command = strsep(¶ms, "|");
|
||||
caller = strsep(¶ms, "|");
|
||||
|
||||
ast_mutex_lock(&conflock);
|
||||
if (!command) {
|
||||
ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n");
|
||||
ast_mutex_unlock(&conflock);
|
||||
return -1;
|
||||
}
|
||||
cnf = confs;
|
||||
while (cnf) {
|
||||
if (strcmp(cnf->confno, conf) == 0)
|
||||
break;
|
||||
cnf = cnf->next;
|
||||
}
|
||||
ast_mutex_unlock(&conflock);
|
||||
|
||||
if (caller)
|
||||
user = find_user(cnf, caller);
|
||||
|
0
apps/app_milliwatt.c
Executable file → Normal file
0
apps/app_milliwatt.c
Executable file → Normal file
19
apps/app_mp3.c
Executable file → Normal file
19
apps/app_mp3.c
Executable file → Normal file
@@ -3,9 +3,9 @@
|
||||
*
|
||||
* Silly application to play an MP3 file -- uses mpg123
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -60,7 +60,7 @@ static int mp3play(char *filename, int fd)
|
||||
close(x);
|
||||
}
|
||||
/* Execute mpg123, but buffer if it's a net connection */
|
||||
if (!strncmp(filename, "http://", 7)) {
|
||||
if (!strncasecmp(filename, "http://", 7)) {
|
||||
/* Most commonly installed in /usr/local/bin */
|
||||
execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
|
||||
/* But many places has it in /usr/bin */
|
||||
@@ -80,15 +80,15 @@ static int mp3play(char *filename, int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int timed_read(int fd, void *data, int datalen)
|
||||
static int timed_read(int fd, void *data, int datalen, int timeout)
|
||||
{
|
||||
int res;
|
||||
struct pollfd fds[1];
|
||||
fds[0].fd = fd;
|
||||
fds[0].events = POLLIN;
|
||||
res = poll(fds, 1, 2000);
|
||||
res = poll(fds, 1, timeout);
|
||||
if (res < 1) {
|
||||
ast_log(LOG_NOTICE, "Selected timed out/errored out with %d\n", res);
|
||||
ast_log(LOG_NOTICE, "Poll timed out/errored out with %d\n", res);
|
||||
return -1;
|
||||
}
|
||||
return read(fd, data, datalen);
|
||||
@@ -103,6 +103,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
||||
int ms = -1;
|
||||
int pid = -1;
|
||||
int owriteformat;
|
||||
int timeout = 2000;
|
||||
struct timeval now, next;
|
||||
struct ast_frame *f;
|
||||
struct myframe {
|
||||
@@ -110,7 +111,6 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
||||
char offset[AST_FRIENDLY_OFFSET];
|
||||
short frdata[160];
|
||||
} myf;
|
||||
|
||||
if (!data) {
|
||||
ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n");
|
||||
return -1;
|
||||
@@ -131,6 +131,9 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
res = mp3play((char *)data, fds[1]);
|
||||
if (!strncasecmp((char *)data, "http://", 7)) {
|
||||
timeout = 10000;
|
||||
}
|
||||
/* Wait 1000 ms first */
|
||||
next = now;
|
||||
next.tv_sec += 1;
|
||||
@@ -155,7 +158,7 @@ static int mp3_exec(struct ast_channel *chan, void *data)
|
||||
last = tv;
|
||||
}
|
||||
#endif
|
||||
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
|
||||
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout);
|
||||
if (res > 0) {
|
||||
myf.f.frametype = AST_FRAME_VOICE;
|
||||
myf.f.subclass = AST_FORMAT_SLINEAR;
|
||||
|
0
apps/app_nbscat.c
Executable file → Normal file
0
apps/app_nbscat.c
Executable file → Normal file
0
apps/app_osplookup.c
Executable file → Normal file
0
apps/app_osplookup.c
Executable file → Normal file
2
apps/app_parkandannounce.c
Executable file → Normal file
2
apps/app_parkandannounce.c
Executable file → Normal file
@@ -94,7 +94,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
|
||||
}
|
||||
dial=strsep(&s, "|");
|
||||
if(!dial) {
|
||||
ast_log(LOG_WARNING, "PARK: A dial resouce must be specified i.e: Console/dsp or Zap/g1/5551212\n");
|
||||
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n");
|
||||
free(orig_s);
|
||||
return -1;
|
||||
} else {
|
||||
|
0
apps/app_playback.c
Executable file → Normal file
0
apps/app_playback.c
Executable file → Normal file
0
apps/app_privacy.c
Executable file → Normal file
0
apps/app_privacy.c
Executable file → Normal file
0
apps/app_qcall.c
Executable file → Normal file
0
apps/app_qcall.c
Executable file → Normal file
35
apps/app_queue.c
Executable file → Normal file
35
apps/app_queue.c
Executable file → Normal file
@@ -208,6 +208,7 @@ struct ast_call_queue {
|
||||
char sound_calls[80]; /* Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting)*/
|
||||
char sound_holdtime[80]; /* Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */
|
||||
char sound_minutes[80]; /* Sound file: "minutes." (def. queue-minutes) */
|
||||
char sound_lessthan[80]; /* Sound file: "less-than" (def. queue-lessthan) */
|
||||
char sound_seconds[80]; /* Sound file: "seconds." (def. queue-seconds) */
|
||||
char sound_thanks[80]; /* Sound file: "Thank you for your patience." (def. queue-thankyou) */
|
||||
|
||||
@@ -225,6 +226,7 @@ struct ast_call_queue {
|
||||
int wrapped; /* Round Robin - wrapped around? */
|
||||
int joinempty; /* Do we care if the queue has no members? */
|
||||
int eventwhencalled; /* Generate an event when the agent is called (before pickup) */
|
||||
int leavewhenempty; /* If all agents leave the queue, remove callers from the queue */
|
||||
|
||||
struct member *members; /* Member channels to be tried */
|
||||
struct queue_ent *head; /* Start of the actual queue */
|
||||
@@ -434,7 +436,11 @@ static int say_position(struct queue_ent *qe)
|
||||
if ((avgholdmins+avgholdsecs) > 0 && (qe->parent->announceholdtime) && (!(qe->parent->announceholdtime==1 && qe->last_pos)) ) {
|
||||
res += play_file(qe->chan, qe->parent->sound_holdtime);
|
||||
if(avgholdmins>0) {
|
||||
res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
|
||||
if (avgholdmins < 2) {
|
||||
res += play_file(qe->chan, qe->parent->sound_lessthan);
|
||||
res += ast_say_number(qe->chan, 2, AST_DIGIT_ANY, qe->chan->language, (char *)NULL);
|
||||
} else
|
||||
res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
|
||||
res += play_file(qe->chan, qe->parent->sound_minutes);
|
||||
}
|
||||
if(avgholdsecs>0) {
|
||||
@@ -907,6 +913,12 @@ static int wait_our_turn(struct queue_ent *qe, int ringing)
|
||||
break;
|
||||
}
|
||||
|
||||
/* leave the queue if no agents, if enabled */
|
||||
if (!(qe->parent->members) && qe->parent->leavewhenempty) {
|
||||
leave_queue(qe);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make a position announcement, if enabled */
|
||||
if (qe->parent->announcefrequency && !ringing)
|
||||
say_position(qe);
|
||||
@@ -1621,7 +1633,7 @@ check_turns:
|
||||
/* This is the wait loop for the head caller*/
|
||||
/* To exit, they may get their call answered; */
|
||||
/* they may dial a digit from the queue context; */
|
||||
/* or, they may may timeout. */
|
||||
/* or, they may timeout. */
|
||||
|
||||
/* Leave if we have exceeded our queuetimeout */
|
||||
if (qe.queuetimeout && ( (time(NULL) - qe.start) >= qe.queuetimeout) ) {
|
||||
@@ -1629,6 +1641,12 @@ check_turns:
|
||||
break;
|
||||
}
|
||||
|
||||
/* leave the queue if no agents, if enabled */
|
||||
if (!((qe.parent)->members) && (qe.parent)->leavewhenempty) {
|
||||
leave_queue(&qe);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make a position announcement, if enabled */
|
||||
if (qe.parent->announcefrequency && !ringing)
|
||||
say_position(&qe);
|
||||
@@ -1686,7 +1704,7 @@ check_turns:
|
||||
}
|
||||
}
|
||||
/* Don't allow return code > 0 */
|
||||
if (res > 0 && res != AST_PBX_KEEPALIVE) {
|
||||
if ((res == 0) || (res > 0 && res != AST_PBX_KEEPALIVE)) {
|
||||
res = 0;
|
||||
if (ringing) {
|
||||
ast_indicate(chan, -1);
|
||||
@@ -1776,6 +1794,7 @@ static void reload_queues(void)
|
||||
strncpy(q->sound_minutes, "queue-minutes", sizeof(q->sound_minutes) - 1);
|
||||
strncpy(q->sound_seconds, "queue-seconds", sizeof(q->sound_seconds) - 1);
|
||||
strncpy(q->sound_thanks, "queue-thankyou", sizeof(q->sound_thanks) - 1);
|
||||
strncpy(q->sound_lessthan, "queue-less-than", sizeof(q->sound_lessthan) - 1);
|
||||
prev = q->members;
|
||||
if (prev) {
|
||||
/* find the end of any dynamic members */
|
||||
@@ -1812,7 +1831,7 @@ static void reload_queues(void)
|
||||
q->members = cur;
|
||||
prev = cur;
|
||||
}
|
||||
} else if (!strcasecmp(var->name, "music")) {
|
||||
} else if (!strcasecmp(var->name, "music") || !strcasecmp(var->name, "musiconhold")) {
|
||||
strncpy(q->moh, var->value, sizeof(q->moh) - 1);
|
||||
} else if (!strcasecmp(var->name, "announce")) {
|
||||
strncpy(q->announce, var->value, sizeof(q->announce) - 1);
|
||||
@@ -1836,6 +1855,8 @@ static void reload_queues(void)
|
||||
strncpy(q->sound_minutes, var->value, sizeof(q->sound_minutes) - 1);
|
||||
} else if (!strcasecmp(var->name, "queue-seconds")) {
|
||||
strncpy(q->sound_seconds, var->value, sizeof(q->sound_seconds) - 1);
|
||||
} else if (!strcasecmp(var->name, "queue-lessthan")) {
|
||||
strncpy(q->sound_lessthan, var->value, sizeof(q->sound_lessthan) - 1);
|
||||
} else if (!strcasecmp(var->name, "queue-thankyou")) {
|
||||
strncpy(q->sound_thanks, var->value, sizeof(q->sound_thanks) - 1);
|
||||
} else if (!strcasecmp(var->name, "announce-frequency")) {
|
||||
@@ -1864,6 +1885,8 @@ static void reload_queues(void)
|
||||
}
|
||||
} else if (!strcasecmp(var->name, "joinempty")) {
|
||||
q->joinempty = ast_true(var->value);
|
||||
} else if (!strcasecmp(var->name, "leavewhenempty")) {
|
||||
q->leavewhenempty = ast_true(var->value);
|
||||
} else if (!strcasecmp(var->name, "eventwhencalled")) {
|
||||
q->eventwhencalled = ast_true(var->value);
|
||||
} else {
|
||||
@@ -2047,6 +2070,7 @@ static int manager_queues_status( struct mansession *s, struct message *m )
|
||||
/* List queue properties */
|
||||
if(q->callscompleted > 0)
|
||||
sl = 100*((float)q->callscompletedinsl/(float)q->callscompleted);
|
||||
ast_mutex_lock(&s->lock);
|
||||
ast_cli(s->fd, "Event: QueueParams\r\n"
|
||||
"Queue: %s\r\n"
|
||||
"Max: %d\r\n"
|
||||
@@ -2088,6 +2112,7 @@ static int manager_queues_status( struct mansession *s, struct message *m )
|
||||
"%s"
|
||||
"\r\n",
|
||||
q->name, pos++, qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : ""), (long)(now - qe->start), idText);
|
||||
ast_mutex_unlock(&s->lock);
|
||||
ast_mutex_unlock(&q->lock);
|
||||
}
|
||||
ast_mutex_unlock(&qlock);
|
||||
@@ -2174,7 +2199,7 @@ static int handle_add_queue_member(int fd, int argc, char *argv[])
|
||||
return RESULT_SHOWUSAGE;
|
||||
} else if (strcmp(argv[4], "to")) {
|
||||
return RESULT_SHOWUSAGE;
|
||||
} else if ((argc == 8) && strcmp(argv[6], "priority")) {
|
||||
} else if ((argc == 8) && strcmp(argv[6], "penalty")) {
|
||||
return RESULT_SHOWUSAGE;
|
||||
}
|
||||
|
||||
|
0
apps/app_random.c
Executable file → Normal file
0
apps/app_random.c
Executable file → Normal file
8
apps/app_read.c
Executable file → Normal file
8
apps/app_read.c
Executable file → Normal file
@@ -103,9 +103,13 @@ static int read_exec(struct ast_channel *chan, void *data)
|
||||
if (!res) {
|
||||
ast_stopstream(chan);
|
||||
res = ast_app_getdata(chan, filename, tmp, maxdigits, 0);
|
||||
if (res > -1)
|
||||
if (res > -1) {
|
||||
pbx_builtin_setvar_helper(chan, varname, tmp);
|
||||
ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
|
||||
ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
|
||||
res = 0;
|
||||
} else {
|
||||
ast_verbose(VERBOSE_PREFIX_3 "User disconnected\n");
|
||||
}
|
||||
}
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
|
32
apps/app_record.c
Executable file → Normal file
32
apps/app_record.c
Executable file → Normal file
@@ -56,7 +56,7 @@ static int record_exec(struct ast_channel *chan, void *data)
|
||||
char fil[256];
|
||||
char tmp[256];
|
||||
char ext[10];
|
||||
char * vdata; /* Used so I don't have to typecast every use of *data */
|
||||
char *vdata;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
@@ -78,15 +78,32 @@ static int record_exec(struct ast_channel *chan, void *data)
|
||||
int option_skip = 0;
|
||||
int option_noanswer = 0;
|
||||
int rfmt = 0;
|
||||
int flags;
|
||||
char *end=NULL;
|
||||
char *p=NULL;
|
||||
|
||||
|
||||
vdata = data; /* explained above */
|
||||
|
||||
/* The next few lines of code parse out the filename and header from the input string */
|
||||
if (!vdata) { /* no data implies no filename or anything is present */
|
||||
if (!data) { /* no data implies no filename or anything is present */
|
||||
ast_log(LOG_WARNING, "Record requires an argument (filename)\n");
|
||||
return -1;
|
||||
}
|
||||
vdata = ast_strdupa(data);
|
||||
|
||||
p = vdata;
|
||||
while(p && (p=strchr(p,':'))) {
|
||||
end=p;
|
||||
if(!strcasecmp(end,":end")) {
|
||||
*end='\0';
|
||||
end++;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
end=NULL;
|
||||
}
|
||||
|
||||
|
||||
for (; vdata[i] && (vdata[i] != ':') && (vdata[i] != '|'); i++ ) {
|
||||
if ((vdata[i] == '%') && (vdata[i+1] == 'd')) {
|
||||
percentflag = 1; /* the wildcard is used */
|
||||
@@ -205,8 +222,11 @@ static int record_exec(struct ast_channel *chan, void *data)
|
||||
ast_dsp_set_threshold(sildet, 256);
|
||||
}
|
||||
|
||||
s = ast_writefile( tmp, ext, NULL, O_CREAT|O_TRUNC|O_WRONLY , 0, 0644);
|
||||
|
||||
|
||||
flags = end ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
|
||||
s = ast_writefile( tmp, ext, NULL, flags , 0, 0644);
|
||||
|
||||
|
||||
if (s) {
|
||||
if (maxduration > 0)
|
||||
timeout = time(NULL) + (time_t)maxduration;
|
||||
@@ -281,7 +301,7 @@ static int record_exec(struct ast_channel *chan, void *data)
|
||||
ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
|
||||
|
||||
LOCAL_USER_REMOVE(u);
|
||||
if (silence > 0) {
|
||||
if ((silence > 0) && rfmt) {
|
||||
res = ast_set_read_format(chan, rfmt);
|
||||
if (res)
|
||||
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
|
||||
|
294
apps/app_rpt.c
Executable file → Normal file
294
apps/app_rpt.c
Executable file → Normal file
@@ -3,7 +3,7 @@
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Radio Repeater / Remote Base program
|
||||
* version 0.13 7/12/04
|
||||
* version 0.17 9/13/04
|
||||
*
|
||||
* See http://www.zapatatelephony.org/app_rpt.html
|
||||
*
|
||||
@@ -103,6 +103,8 @@ enum {REM_LOWPWR,REM_MEDPWR,REM_HIPWR};
|
||||
enum {DC_INDETERMINATE, DC_REQ_FLUSH, DC_ERROR, DC_COMPLETE};
|
||||
enum {SOURCE_RPT, SOURCE_LNK, SOURCE_RMT};
|
||||
|
||||
enum {DLY_TELEM, DLY_ID, DLY_UNKEY, DLY_CALLTERM};
|
||||
|
||||
#include <asterisk/utils.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/file.h>
|
||||
@@ -114,7 +116,6 @@ enum {SOURCE_RPT, SOURCE_LNK, SOURCE_RMT};
|
||||
#include <asterisk/translate.h>
|
||||
#include <asterisk/options.h>
|
||||
#include <asterisk/config.h>
|
||||
#include <asterisk/utils.h>
|
||||
#include <asterisk/say.h>
|
||||
#include <asterisk/localtime.h>
|
||||
#include <stdio.h>
|
||||
@@ -136,7 +137,7 @@ enum {SOURCE_RPT, SOURCE_LNK, SOURCE_RMT};
|
||||
#include <tonezone.h>
|
||||
#include <linux/zaptel.h>
|
||||
|
||||
static char *tdesc = "Radio Repeater / Remote Base version 0.13 07/12/2004";
|
||||
static char *tdesc = "Radio Repeater / Remote Base version 0.17 09/13/2004";
|
||||
static char *app = "Rpt";
|
||||
|
||||
static char *synopsis = "Radio Repeater/Remote Base Control System";
|
||||
@@ -160,6 +161,7 @@ LOCAL_USER_DECL;
|
||||
#define IDTIME 300000
|
||||
#define MAXRPTS 20
|
||||
#define POLITEID 30000
|
||||
#define FUNCTDELAY 1500
|
||||
|
||||
static pthread_t rpt_master_thread;
|
||||
|
||||
@@ -237,7 +239,7 @@ static struct rpt
|
||||
char remotetx;
|
||||
char remoteon;
|
||||
char simple;
|
||||
char remote;
|
||||
char *remote;
|
||||
char tounkeyed;
|
||||
char tonotify;
|
||||
char enable;
|
||||
@@ -621,20 +623,34 @@ static int telem_any(struct ast_channel *chan, char *entry)
|
||||
* 4 types of telemtry are handled: Morse ID, Morse Message, Tone Sequence, and a File containing a recording.
|
||||
*/
|
||||
|
||||
static int telem_lookup(struct ast_channel *chan, char *name)
|
||||
static int telem_lookup(struct ast_channel *chan, char *node, char *name)
|
||||
{
|
||||
|
||||
int res;
|
||||
int i;
|
||||
char *entry;
|
||||
char *telemetry;
|
||||
char *telemetry_save;
|
||||
|
||||
res = 0;
|
||||
telemetry_save = NULL;
|
||||
entry = NULL;
|
||||
|
||||
|
||||
/* Retrieve the section name for telemetry from the node section */
|
||||
|
||||
telemetry = ast_variable_retrieve(cfg, node, TELEMETRY);
|
||||
if(telemetry){
|
||||
telemetry_save = ast_strdupa(telemetry);
|
||||
if(!telemetry_save){
|
||||
ast_log(LOG_WARNING,"ast_strdupa() failed in telem_lookup()\n");
|
||||
return res;
|
||||
}
|
||||
entry = ast_variable_retrieve(cfg, telemetry_save, name);
|
||||
}
|
||||
|
||||
/* Try to look up the telemetry name */
|
||||
|
||||
entry = ast_variable_retrieve(cfg, TELEMETRY, name);
|
||||
if(!entry){
|
||||
/* Telemetry name wasn't found in the config file, use the default */
|
||||
for(i = 0; i < sizeof(tele_defs)/sizeof(struct telem_defaults) ; i++){
|
||||
@@ -651,6 +667,67 @@ static int telem_lookup(struct ast_channel *chan, char *name)
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait a configurable interval of time
|
||||
*/
|
||||
|
||||
|
||||
static void wait_interval(struct rpt *myrpt, int type)
|
||||
{
|
||||
int interval;
|
||||
char *wait_times;
|
||||
char *wait_times_save;
|
||||
|
||||
wait_times_save = NULL;
|
||||
wait_times = ast_variable_retrieve(cfg, myrpt->name, "wait_times");
|
||||
|
||||
if(wait_times){
|
||||
wait_times_save = ast_strdupa(wait_times);
|
||||
if(!wait_times_save){
|
||||
ast_log(LOG_WARNING, "Out of memory in wait_interval()\n");
|
||||
wait_times = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
switch(type){
|
||||
case DLY_TELEM:
|
||||
if(wait_times)
|
||||
interval = retrieve_astcfgint(wait_times_save, "telemwait", 500, 5000, 1000);
|
||||
else
|
||||
interval = 1000;
|
||||
break;
|
||||
|
||||
case DLY_ID:
|
||||
if(wait_times)
|
||||
interval = retrieve_astcfgint(wait_times_save, "idwait",250,5000,500);
|
||||
else
|
||||
interval = 500;
|
||||
break;
|
||||
|
||||
case DLY_UNKEY:
|
||||
if(wait_times)
|
||||
interval = retrieve_astcfgint(wait_times_save, "unkeywait",500,5000,1000);
|
||||
else
|
||||
interval = 1000;
|
||||
break;
|
||||
|
||||
case DLY_CALLTERM:
|
||||
if(wait_times)
|
||||
interval = retrieve_astcfgint(wait_times_save, "calltermwait",500,5000,1500);
|
||||
else
|
||||
interval = 1500;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
usleep(1000 * interval);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void *rpt_tele_thread(void *this)
|
||||
{
|
||||
ZT_CONFINFO ci; /* conference info */
|
||||
@@ -713,8 +790,7 @@ struct tm localtm;
|
||||
case ID:
|
||||
case ID1:
|
||||
/* wait a bit */
|
||||
usleep(500000);
|
||||
|
||||
wait_interval(myrpt, (mytele->mode == ID) ? DLY_ID : DLY_TELEM);
|
||||
res = telem_any(mychannel, ident);
|
||||
imdone=1;
|
||||
|
||||
@@ -730,22 +806,22 @@ struct tm localtm;
|
||||
|
||||
case PROC:
|
||||
/* wait a little bit longer */
|
||||
usleep(1500000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/callproceeding", mychannel->language);
|
||||
break;
|
||||
case TERM:
|
||||
/* wait a little bit longer */
|
||||
usleep(1500000);
|
||||
wait_interval(myrpt, DLY_CALLTERM);
|
||||
res = ast_streamfile(mychannel, "rpt/callterminated", mychannel->language);
|
||||
break;
|
||||
case COMPLETE:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
res = telem_lookup(mychannel, "functcomplete");
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = telem_lookup(mychannel, myrpt->name, "functcomplete");
|
||||
break;
|
||||
case UNKEY:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_UNKEY);
|
||||
hastx = 0;
|
||||
|
||||
|
||||
@@ -760,7 +836,7 @@ struct tm localtm;
|
||||
}
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
|
||||
res = telem_lookup(mychannel,(!hastx) ? "remotemon" : "remotetx");
|
||||
res = telem_lookup(mychannel, myrpt->name, (!hastx) ? "remotemon" : "remotetx");
|
||||
if(res)
|
||||
ast_log(LOG_WARNING, "telem_lookup:remotexx failed on %s\n", mychannel->name);
|
||||
|
||||
@@ -769,7 +845,7 @@ struct tm localtm;
|
||||
if (myrpt->cmdnode[0])
|
||||
{
|
||||
ast_safe_sleep(mychannel,200);
|
||||
res = telem_lookup(mychannel, "cmdmode");
|
||||
res = telem_lookup(mychannel, myrpt->name, "cmdmode");
|
||||
if(res)
|
||||
ast_log(LOG_WARNING, "telem_lookup:cmdmode failed on %s\n", mychannel->name);
|
||||
ast_stopstream(mychannel);
|
||||
@@ -777,7 +853,7 @@ struct tm localtm;
|
||||
}
|
||||
else if((ct = ast_variable_retrieve(cfg, nodename, "unlinkedct"))){ /* Unlinked Courtesy Tone */
|
||||
ct_copy = ast_strdupa(ct);
|
||||
res = telem_lookup(mychannel, ct_copy);
|
||||
res = telem_lookup(mychannel, myrpt->name, ct_copy);
|
||||
if(res)
|
||||
ast_log(LOG_WARNING, "telem_lookup:ctx failed on %s\n", mychannel->name);
|
||||
}
|
||||
@@ -786,7 +862,7 @@ struct tm localtm;
|
||||
break;
|
||||
case REMDISC:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/node", mychannel->language);
|
||||
if (!res)
|
||||
res = ast_waitstream(mychannel, "");
|
||||
@@ -799,22 +875,22 @@ struct tm localtm;
|
||||
break;
|
||||
case REMALREADY:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/remote_already", mychannel->language);
|
||||
break;
|
||||
case REMNOTFOUND:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/remote_notfound", mychannel->language);
|
||||
break;
|
||||
case REMGO:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/remote_go", mychannel->language);
|
||||
break;
|
||||
case CONNECTED:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
res = ast_streamfile(mychannel, "rpt/node", mychannel->language);
|
||||
if (!res)
|
||||
res = ast_waitstream(mychannel, "");
|
||||
@@ -836,7 +912,7 @@ struct tm localtm;
|
||||
break;
|
||||
case STATUS:
|
||||
/* wait a little bit */
|
||||
usleep(1000000);
|
||||
wait_interval(myrpt, DLY_TELEM);
|
||||
hastx = 0;
|
||||
linkbase.next = &linkbase;
|
||||
linkbase.prev = &linkbase;
|
||||
@@ -936,9 +1012,9 @@ struct tm localtm;
|
||||
break;
|
||||
|
||||
case STATS_TIME:
|
||||
usleep(1000000); /* Wait a little bit */
|
||||
wait_interval(myrpt, DLY_TELEM); /* Wait a little bit */
|
||||
t = time(NULL);
|
||||
ast_localtime(&t, &localtm, NULL);
|
||||
localtime_r(&t, &localtm);
|
||||
/* Say the phase of the day is before the time */
|
||||
if((localtm.tm_hour >= 0) && (localtm.tm_hour < 12))
|
||||
p = "rpt/goodmorning";
|
||||
@@ -970,7 +1046,7 @@ struct tm localtm;
|
||||
break;
|
||||
if(sscanf(p, "version %d.%d", &vmajor, &vminor) != 2)
|
||||
break;
|
||||
usleep(1000000); /* Wait a little bit */
|
||||
wait_interval(myrpt, DLY_TELEM); /* Wait a little bit */
|
||||
/* Say "version" */
|
||||
if (sayfile(mychannel,"rpt/version") == -1)
|
||||
{
|
||||
@@ -998,7 +1074,7 @@ struct tm localtm;
|
||||
imdone = 1;
|
||||
break;
|
||||
case ARB_ALPHA:
|
||||
usleep(1000000); /* Wait a little bit */
|
||||
wait_interval(myrpt, DLY_TELEM); /* Wait a little bit */
|
||||
if(mytele->param)
|
||||
saycharstr(mychannel, mytele->param);
|
||||
imdone = 1;
|
||||
@@ -2469,7 +2545,10 @@ static int setrbi(struct rpt *myrpt)
|
||||
char tmp[MAXREMSTR] = "",rbicmd[5],*s;
|
||||
int band,txoffset = 0,txpower = 0,rxpl;
|
||||
|
||||
|
||||
/* must be a remote system */
|
||||
if (!myrpt->remote) return(0);
|
||||
/* must have rbi hardware */
|
||||
if (strncmp(myrpt->remote,"rbi",3)) return(0);
|
||||
strncpy(tmp, myrpt->freq, sizeof(tmp) - 1);
|
||||
s = strchr(tmp,'.');
|
||||
/* if no decimal, is invalid */
|
||||
@@ -2663,7 +2742,7 @@ int seq,res;
|
||||
ast_indicate(myrpt->remchannel,AST_CONTROL_RADIO_KEY);
|
||||
}
|
||||
if (ast_safe_sleep(myrpt->remchannel,1000) == -1) return -1;
|
||||
res = telem_lookup(myrpt->remchannel,"functcomplete");
|
||||
res = telem_lookup(myrpt->remchannel, myrpt->name, "functcomplete");
|
||||
if (!myrpt->remoterx)
|
||||
{
|
||||
ast_indicate(myrpt->remchannel,AST_CONTROL_RADIO_UNKEY);
|
||||
@@ -2683,21 +2762,32 @@ time_t dtmf_time,t;
|
||||
struct rpt_link *l,*m;
|
||||
struct rpt_tele *telem;
|
||||
pthread_attr_t attr;
|
||||
char tmpstr[300];
|
||||
char cmd[MAXDTMF+1] = "";
|
||||
|
||||
|
||||
ast_mutex_lock(&myrpt->lock);
|
||||
tele = strchr(myrpt->rxchanname,'/');
|
||||
strncpy(tmpstr,myrpt->rxchanname,sizeof(tmpstr) - 1);
|
||||
tele = strchr(tmpstr,'/');
|
||||
if (!tele)
|
||||
{
|
||||
fprintf(stderr,"rpt:Dial number (%s) must be in format tech/number\n",myrpt->rxchanname);
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
*tele++ = 0;
|
||||
myrpt->rxchannel = ast_request(myrpt->rxchanname,AST_FORMAT_SLINEAR,tele);
|
||||
myrpt->rxchannel = ast_request(tmpstr,AST_FORMAT_SLINEAR,tele);
|
||||
if (myrpt->rxchannel)
|
||||
{
|
||||
if (myrpt->rxchannel->_state == AST_STATE_BUSY)
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain Rx channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
|
||||
ast_set_write_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
|
||||
myrpt->rxchannel->whentohangup = 0;
|
||||
@@ -2705,28 +2795,47 @@ char cmd[MAXDTMF+1] = "";
|
||||
myrpt->rxchannel->data = "(Repeater Rx)";
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "rpt (Rx) initiating call to %s/%s on %s\n",
|
||||
myrpt->rxchanname,tele,myrpt->rxchannel->name);
|
||||
tmpstr,tele,myrpt->rxchannel->name);
|
||||
ast_call(myrpt->rxchannel,tele,999);
|
||||
if (myrpt->rxchannel->_state != AST_STATE_UP)
|
||||
{
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain Rx channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
if (myrpt->txchanname)
|
||||
{
|
||||
tele = strchr(myrpt->txchanname,'/');
|
||||
strncpy(tmpstr,myrpt->txchanname,sizeof(tmpstr) - 1);
|
||||
tele = strchr(tmpstr,'/');
|
||||
if (!tele)
|
||||
{
|
||||
fprintf(stderr,"rpt:Dial number (%s) must be in format tech/number\n",myrpt->txchanname);
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
*tele++ = 0;
|
||||
myrpt->txchannel = ast_request(myrpt->txchanname,AST_FORMAT_SLINEAR,tele);
|
||||
myrpt->txchannel = ast_request(tmpstr,AST_FORMAT_SLINEAR,tele);
|
||||
if (myrpt->txchannel)
|
||||
{
|
||||
if (myrpt->txchannel->_state == AST_STATE_BUSY)
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain Tx channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
|
||||
ast_set_write_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
|
||||
myrpt->txchannel->whentohangup = 0;
|
||||
@@ -2734,13 +2843,23 @@ char cmd[MAXDTMF+1] = "";
|
||||
myrpt->txchannel->data = "(Repeater Rx)";
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "rpt (Tx) initiating call to %s/%s on %s\n",
|
||||
myrpt->txchanname,tele,myrpt->txchannel->name);
|
||||
tmpstr,tele,myrpt->txchannel->name);
|
||||
ast_call(myrpt->txchannel,tele,999);
|
||||
if (myrpt->rxchannel->_state != AST_STATE_UP)
|
||||
{
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
ast_hangup(myrpt->txchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain Tx channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
@@ -2754,6 +2873,10 @@ char cmd[MAXDTMF+1] = "";
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
if (myrpt->txchannel != myrpt->rxchannel)
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
/* make a conference for the tx */
|
||||
@@ -2765,6 +2888,11 @@ char cmd[MAXDTMF+1] = "";
|
||||
{
|
||||
ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->pchannel);
|
||||
if (myrpt->txchannel != myrpt->rxchannel)
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
/* save tx conference number */
|
||||
@@ -2778,6 +2906,11 @@ char cmd[MAXDTMF+1] = "";
|
||||
{
|
||||
ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->pchannel);
|
||||
if (myrpt->txchannel != myrpt->rxchannel)
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
/* save pseudo channel conference number */
|
||||
@@ -2788,6 +2921,11 @@ char cmd[MAXDTMF+1] = "";
|
||||
{
|
||||
fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->pchannel);
|
||||
if (myrpt->txchannel != myrpt->rxchannel)
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
/* make a conference for the tx */
|
||||
@@ -2799,6 +2937,12 @@ char cmd[MAXDTMF+1] = "";
|
||||
{
|
||||
ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
ast_hangup(myrpt->txpchannel);
|
||||
ast_hangup(myrpt->pchannel);
|
||||
if (myrpt->txchannel != myrpt->rxchannel)
|
||||
ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
/* Now, the idea here is to copy from the physical rx channel buffer
|
||||
@@ -2840,6 +2984,9 @@ char cmd[MAXDTMF+1] = "";
|
||||
if (ast_check_hangup(myrpt->txpchannel)) break;
|
||||
ast_mutex_lock(&myrpt->lock);
|
||||
myrpt->localtx = keyed && (myrpt->dtmfidx == -1) && (!myrpt->cmdnode[0]);
|
||||
|
||||
/* If someone's connected, and they're transmitting from their end to us, set remrx true */
|
||||
|
||||
l = myrpt->links.next;
|
||||
remrx = 0;
|
||||
while(l != &myrpt->links)
|
||||
@@ -2921,8 +3068,8 @@ char cmd[MAXDTMF+1] = "";
|
||||
if (!myrpt->totimer) myrpt->tailtimer = 0;
|
||||
/* if not timed-out, add in tail */
|
||||
if (myrpt->totimer) totx = totx || myrpt->tailtimer;
|
||||
/* If user keys up or is keyed up over standard ID, switch to talkover ID, if one is defined */
|
||||
if (identqueued && keyed && idtalkover) {
|
||||
/* If user or links key up or are keyed up over standard ID, switch to talkover ID, if one is defined */
|
||||
if (identqueued && (keyed || remrx) && idtalkover) {
|
||||
int hasid = 0,hastalkover = 0;
|
||||
|
||||
telem = myrpt->tele.next;
|
||||
@@ -3381,8 +3528,8 @@ char cmd[MAXDTMF+1] = "";
|
||||
ast_mutex_lock(&myrpt->lock);
|
||||
ast_hangup(myrpt->pchannel);
|
||||
ast_hangup(myrpt->txpchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
if (myrpt->txchannel != myrpt->rxchannel) ast_hangup(myrpt->txchannel);
|
||||
ast_hangup(myrpt->rxchannel);
|
||||
l = myrpt->links.next;
|
||||
while(l != &myrpt->links)
|
||||
{
|
||||
@@ -3397,6 +3544,7 @@ char cmd[MAXDTMF+1] = "";
|
||||
}
|
||||
ast_mutex_unlock(&myrpt->lock);
|
||||
if (debug) printf("@@@@ rpt:Hung up channel\n");
|
||||
myrpt->rpt_thread = AST_PTHREADT_STOP;
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
@@ -3408,6 +3556,7 @@ static void *rpt_master(void *ignore)
|
||||
char *this,*val;
|
||||
struct ast_variable *vp;
|
||||
int i,j,n,longestnode;
|
||||
pthread_attr_t attr;
|
||||
|
||||
/* start with blank config */
|
||||
memset(&rpt_vars,0,sizeof(rpt_vars));
|
||||
@@ -3449,6 +3598,7 @@ int i,j,n,longestnode;
|
||||
ast_mutex_init(&rpt_vars[n].lock);
|
||||
rpt_vars[n].tele.next = &rpt_vars[n].tele;
|
||||
rpt_vars[n].tele.prev = &rpt_vars[n].tele;
|
||||
rpt_vars[n].rpt_thread = AST_PTHREADT_NULL;
|
||||
rpt_vars[n].name = this;
|
||||
rpt_vars[n].rxchanname = ast_variable_retrieve(cfg,this,"rxchannel");
|
||||
rpt_vars[n].txchanname = ast_variable_retrieve(cfg,this,"txchannel");
|
||||
@@ -3466,10 +3616,7 @@ int i,j,n,longestnode;
|
||||
|
||||
rpt_vars[n].idtime = retrieve_astcfgint( this, "idtime", 60000, 2400000, IDTIME); /* Enforce a min max */
|
||||
rpt_vars[n].politeid = retrieve_astcfgint( this, "politeid", 30000, 300000, POLITEID); /* Enforce a min max */
|
||||
|
||||
val = ast_variable_retrieve(cfg,this,"remote");
|
||||
if (val) rpt_vars[n].remote = ast_true(val);
|
||||
else rpt_vars[n].remote = 0;
|
||||
rpt_vars[n].remote = ast_variable_retrieve(cfg,this,"remote");
|
||||
rpt_vars[n].tonezone = ast_variable_retrieve(cfg,this,"tonezone");
|
||||
val = ast_variable_retrieve(cfg,this,"iobase");
|
||||
if (val) rpt_vars[n].iobase = atoi(val);
|
||||
@@ -3540,16 +3687,39 @@ int i,j,n,longestnode;
|
||||
ast_log(LOG_WARNING,"Did not specify ident for node %s\n",rpt_vars[i].name);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
ast_pthread_create(&rpt_vars[i].rpt_thread,NULL,rpt,(void *) &rpt_vars[i]);
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
|
||||
}
|
||||
usleep(500000);
|
||||
for(;;)
|
||||
{
|
||||
/* Now monitor each thread, and restart it if necessary */
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
int rv;
|
||||
if (rpt_vars[i].remote) continue;
|
||||
if (rpt_vars[i].rpt_thread == AST_PTHREADT_STOP)
|
||||
rv = -1;
|
||||
else
|
||||
rv = pthread_kill(rpt_vars[i].rpt_thread,0);
|
||||
if (rv)
|
||||
{
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
|
||||
ast_log(LOG_WARNING, "rpt_thread restarted on node %s\n", rpt_vars[i].name);
|
||||
}
|
||||
|
||||
}
|
||||
usleep(2000000);
|
||||
}
|
||||
/* wait for first one to die (should be never) */
|
||||
pthread_join(rpt_vars[0].rpt_thread,NULL);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
static int rpt_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=-1,i,keyed = 0,rem_totx;
|
||||
int res=-1,i,keyed = 0,rem_totx,n;
|
||||
struct localuser *u;
|
||||
char tmp[256];
|
||||
char *options,*stringp,*tele;
|
||||
@@ -3705,7 +3875,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
||||
ast_set_write_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
|
||||
myrpt->rxchannel->whentohangup = 0;
|
||||
myrpt->rxchannel->appl = "Apprpt";
|
||||
myrpt->rxchannel->data = "(Repeater Rx)";
|
||||
myrpt->rxchannel->data = "(Link Rx)";
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "rpt (Rx) initiating call to %s/%s on %s\n",
|
||||
myrpt->rxchanname,tele,myrpt->rxchannel->name);
|
||||
@@ -3737,7 +3907,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
||||
ast_set_write_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
|
||||
myrpt->txchannel->whentohangup = 0;
|
||||
myrpt->txchannel->appl = "Apprpt";
|
||||
myrpt->txchannel->data = "(Repeater Rx)";
|
||||
myrpt->txchannel->data = "(Link Tx)";
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "rpt (Tx) initiating call to %s/%s on %s\n",
|
||||
myrpt->txchanname,tele,myrpt->txchannel->name);
|
||||
@@ -3776,14 +3946,17 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
||||
if (chan->_state != AST_STATE_UP) {
|
||||
ast_answer(chan);
|
||||
}
|
||||
cs[0] = chan;
|
||||
cs[1] = myrpt->rxchannel;
|
||||
n = 0;
|
||||
cs[n++] = chan;
|
||||
cs[n++] = myrpt->rxchannel;
|
||||
if (myrpt->rxchannel != myrpt->txchannel)
|
||||
cs[n++] = myrpt->txchannel;
|
||||
for(;;)
|
||||
{
|
||||
if (ast_check_hangup(chan)) break;
|
||||
if (ast_check_hangup(myrpt->rxchannel)) break;
|
||||
ms = MSWAIT;
|
||||
who = ast_waitfor_n(cs,2,&ms);
|
||||
who = ast_waitfor_n(cs,n,&ms);
|
||||
if (who == NULL) ms = 0;
|
||||
elap = MSWAIT - ms;
|
||||
if (!ms) continue;
|
||||
@@ -3895,6 +4068,27 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
||||
ast_frfree(f);
|
||||
continue;
|
||||
}
|
||||
if ((myrpt->rxchannel != myrpt->txchannel) &&
|
||||
(who == myrpt->txchannel)) /* do this cuz you have to */
|
||||
{
|
||||
f = ast_read(myrpt->txchannel);
|
||||
if (!f)
|
||||
{
|
||||
if (debug) printf("@@@@ link:Hung Up\n");
|
||||
break;
|
||||
}
|
||||
if (f->frametype == AST_FRAME_CONTROL)
|
||||
{
|
||||
if (f->subclass == AST_CONTROL_HANGUP)
|
||||
{
|
||||
if (debug) printf("@@@@ rpt:Hung Up\n");
|
||||
ast_frfree(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ast_frfree(f);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
ast_mutex_lock(&myrpt->lock);
|
||||
|
0
apps/app_sayunixtime.c
Executable file → Normal file
0
apps/app_sayunixtime.c
Executable file → Normal file
0
apps/app_senddtmf.c
Executable file → Normal file
0
apps/app_senddtmf.c
Executable file → Normal file
0
apps/app_sendtext.c
Executable file → Normal file
0
apps/app_sendtext.c
Executable file → Normal file
0
apps/app_setcallerid.c
Executable file → Normal file
0
apps/app_setcallerid.c
Executable file → Normal file
0
apps/app_setcdruserfield.c
Executable file → Normal file
0
apps/app_setcdruserfield.c
Executable file → Normal file
0
apps/app_setcidname.c
Executable file → Normal file
0
apps/app_setcidname.c
Executable file → Normal file
0
apps/app_setcidnum.c
Executable file → Normal file
0
apps/app_setcidnum.c
Executable file → Normal file
0
apps/app_skel.c
Executable file → Normal file
0
apps/app_skel.c
Executable file → Normal file
19
apps/app_sms.c
Executable file → Normal file
19
apps/app_sms.c
Executable file → Normal file
@@ -26,6 +26,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include "../astconf.h"
|
||||
|
||||
/* ToDo */
|
||||
/* When acting as SC and answering, should check for messages and send instead of sending EST as first packet */
|
||||
@@ -36,6 +37,9 @@
|
||||
|
||||
static unsigned char message_ref; /* arbitary message ref */
|
||||
|
||||
static char log_file[255];
|
||||
static char spool_dir[255];
|
||||
|
||||
static char *tdesc = "SMS/PSTN handler";
|
||||
|
||||
static char *app = "SMS";
|
||||
@@ -203,7 +207,7 @@ static void
|
||||
packdate (unsigned char *o, time_t w)
|
||||
{
|
||||
struct tm *t = localtime (&w);
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
|
||||
int z = - t->tm_gmtoff / 3600 / 15;
|
||||
#else
|
||||
int z = timezone / 3600 / 15;
|
||||
@@ -315,7 +319,7 @@ sms_log (sms_t * h, char status)
|
||||
{ /* log the output, and remove file */
|
||||
if (*h->oa || *h->da)
|
||||
{
|
||||
int o = open ("/var/log/asterisk/sms", O_CREAT | O_APPEND | O_WRONLY, 0666);
|
||||
int o = open (log_file, O_CREAT | O_APPEND | O_WRONLY, 0666);
|
||||
if (o >= 0)
|
||||
{
|
||||
char line[1000], *p;
|
||||
@@ -517,7 +521,7 @@ sms_writefile (sms_t * h)
|
||||
char fn2[200] = "";
|
||||
FILE *o;
|
||||
|
||||
strncpy(fn, "/var/spool/asterisk/sms", sizeof(fn) - 1);
|
||||
strncpy(fn, spool_dir, sizeof(fn) - 1);
|
||||
mkdir (fn, 0777); /* ensure it exists */
|
||||
snprintf(fn + strlen(fn), sizeof(fn) - strlen(fn), "/%s.%s", h->smsc ? "me-sc" : "sc-me", h->queue);
|
||||
mkdir (fn, 0777); /* ensure it exists */
|
||||
@@ -689,7 +693,7 @@ sms_nextoutgoing (sms_t * h)
|
||||
DIR *d;
|
||||
char more = 0;
|
||||
|
||||
strncpy(fn, "/var/spool/asterisk/sms", sizeof(fn) - 1);
|
||||
strncpy(fn, spool_dir, sizeof(fn) - 1);
|
||||
mkdir(fn, 0777); /* ensure it exists */
|
||||
snprintf(fn + strlen (fn), sizeof(fn) - strlen(fn), "/%s.%s", h->smsc ? "sc-me" : "me-sc", h->queue);
|
||||
mkdir (fn, 0777); /* ensure it exists */
|
||||
@@ -769,6 +773,7 @@ sms_nextoutgoing (sms_t * h)
|
||||
{ /* no message */
|
||||
h->omsg[0] = 0x94; /* SMS_REL */
|
||||
h->omsg[1] = 0;
|
||||
h->hangup = 1;
|
||||
sms_messagetx (h);
|
||||
}
|
||||
}
|
||||
@@ -1069,11 +1074,11 @@ sms_exec(struct ast_channel *chan, void *data)
|
||||
return -1;
|
||||
}
|
||||
for (p = d; *p && *p != '|'; p++);
|
||||
if (p - d >= sizeof (h.queue)) {
|
||||
if (p - d + 1 >= sizeof (h.queue)) {
|
||||
ast_log (LOG_ERROR, "Queue name too long\n");
|
||||
return -1;
|
||||
}
|
||||
strncpy(h.queue, d, p - d - 1);
|
||||
strncpy(h.queue, d, p - d);
|
||||
if (*p == '|')
|
||||
p++;
|
||||
d = p;
|
||||
@@ -1204,6 +1209,8 @@ load_module (void)
|
||||
for (p = 0; p < 128; p++)
|
||||
sms8to7[sms7to8[p]] = p;
|
||||
}
|
||||
snprintf(log_file, sizeof(log_file), "%s/sms", ast_config_AST_LOG_DIR);
|
||||
snprintf(spool_dir, sizeof(spool_dir), "%s/sms", ast_config_AST_SPOOL_DIR);
|
||||
return ast_register_application (app, sms_exec, synopsis, descrip);
|
||||
}
|
||||
|
||||
|
0
apps/app_softhangup.c
Executable file → Normal file
0
apps/app_softhangup.c
Executable file → Normal file
0
apps/app_sql_postgres.c
Executable file → Normal file
0
apps/app_sql_postgres.c
Executable file → Normal file
0
apps/app_striplsd.c
Executable file → Normal file
0
apps/app_striplsd.c
Executable file → Normal file
0
apps/app_substring.c
Executable file → Normal file
0
apps/app_substring.c
Executable file → Normal file
35
apps/app_system.c
Executable file → Normal file
35
apps/app_system.c
Executable file → Normal file
@@ -3,9 +3,9 @@
|
||||
*
|
||||
* Execute arbitrary system commands
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
* Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
@@ -28,8 +28,12 @@ static char *tdesc = "Generic System() application";
|
||||
|
||||
static char *app = "System";
|
||||
|
||||
static char *app2 = "TrySystem";
|
||||
|
||||
static char *synopsis = "Execute a system command";
|
||||
|
||||
static char *synopsis2 = "Try executing a system command";
|
||||
|
||||
static char *descrip =
|
||||
" System(command): Executes a command by using system(). Returns -1 on\n"
|
||||
"failure to execute the specified command. If the command itself executes\n"
|
||||
@@ -37,27 +41,34 @@ static char *descrip =
|
||||
"priority of the current instance, then the channel will be setup to\n"
|
||||
"continue at that priority level. Otherwise, System returns 0.\n";
|
||||
|
||||
static char *descrip2 =
|
||||
" TrySystem(command): Executes a command by using system(). Returns 0\n"
|
||||
"on any situation. If the command itself executes but is in error, and if\n"
|
||||
"there exists a priority n + 101, where 'n' is the priority of the current\n"
|
||||
"instance, then the channel will be setup to continue at that\n"
|
||||
"priority level. Otherwise, System returns 0.\n";
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int system_exec(struct ast_channel *chan, void *data)
|
||||
static int system_exec_helper(struct ast_channel *chan, void *data, int failmode)
|
||||
{
|
||||
int res=0;
|
||||
struct localuser *u;
|
||||
if (!data) {
|
||||
ast_log(LOG_WARNING, "System requires an argument(command)\n");
|
||||
return -1;
|
||||
return failmode;
|
||||
}
|
||||
LOCAL_USER_ADD(u);
|
||||
/* Do our thing here */
|
||||
res = ast_safe_system((char *)data);
|
||||
if ((res < 0) && (errno != ECHILD)) {
|
||||
ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
|
||||
res = -1;
|
||||
res = failmode;
|
||||
} else if (res == 127) {
|
||||
ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
|
||||
res = -1;
|
||||
res = failmode;
|
||||
} else {
|
||||
if (res < 0)
|
||||
res = 0;
|
||||
@@ -69,14 +80,26 @@ static int system_exec(struct ast_channel *chan, void *data)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int system_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
return system_exec_helper(chan, data, -1);
|
||||
}
|
||||
|
||||
static int trysystem_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
return system_exec_helper(chan, data, 0);
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
ast_unregister_application(app2);
|
||||
return ast_unregister_application(app);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
ast_register_application(app2, trysystem_exec, synopsis2, descrip2);
|
||||
return ast_register_application(app, system_exec, synopsis, descrip);
|
||||
}
|
||||
|
||||
|
0
apps/app_talkdetect.c
Executable file → Normal file
0
apps/app_talkdetect.c
Executable file → Normal file
473
apps/app_test.c
Normal file
473
apps/app_test.c
Normal file
@@ -0,0 +1,473 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Applications to test connection and produce report in text file
|
||||
*
|
||||
* Copyright (C) 2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@digium.com>
|
||||
* Russell Bryant <russelb@clemson.edu>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/options.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/app.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/utils.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "../astconf.h"
|
||||
|
||||
|
||||
static char *tdesc = "Interface Test Application";
|
||||
|
||||
static char *tests_descrip =
|
||||
"TestServer(): Perform test server function and write call report.\n"
|
||||
"Results stored in /var/log/asterisk/testreports/<testid>-server.txt";
|
||||
static char *tests_app = "TestServer";
|
||||
static char *tests_synopsis = "Execute Interface Test Server";
|
||||
|
||||
static char *testc_descrip =
|
||||
"TestClient(testid): Executes test client with given testid.\n"
|
||||
"Results stored in /var/log/asterisk/testreports/<testid>-client.txt";
|
||||
|
||||
static char *testc_app = "TestClient";
|
||||
static char *testc_synopsis = "Execute Interface Test Client";
|
||||
|
||||
static int measurenoise(struct ast_channel *chan, int ms, char *who)
|
||||
{
|
||||
int res=0;
|
||||
int mssofar;
|
||||
int noise=0;
|
||||
int samples=0;
|
||||
int x;
|
||||
short *foo;
|
||||
struct timeval start, tv;
|
||||
struct ast_frame *f;
|
||||
int rformat;
|
||||
rformat = chan->readformat;
|
||||
if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
|
||||
ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
|
||||
return -1;
|
||||
}
|
||||
gettimeofday(&start, NULL);
|
||||
for(;;) {
|
||||
gettimeofday(&tv, NULL);
|
||||
mssofar = (tv.tv_sec - start.tv_sec) * 1000;
|
||||
mssofar += (tv.tv_usec - start.tv_usec) / 1000;
|
||||
if (mssofar > ms)
|
||||
break;
|
||||
res = ast_waitfor(chan, ms - mssofar);
|
||||
if (res < 1)
|
||||
break;
|
||||
f = ast_read(chan);
|
||||
if (!f) {
|
||||
res = -1;
|
||||
break;
|
||||
}
|
||||
if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
|
||||
foo = (short *)f->data;
|
||||
for (x=0;x<f->samples;x++) {
|
||||
noise += abs(foo[x]);
|
||||
samples++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rformat) {
|
||||
if (ast_set_read_format(chan, rformat)) {
|
||||
ast_log(LOG_NOTICE, "Unable to restore original format!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (!samples) {
|
||||
ast_log(LOG_NOTICE, "No samples were received from the other side!\n");
|
||||
return -1;
|
||||
}
|
||||
ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
|
||||
return (noise / samples);
|
||||
}
|
||||
|
||||
static int sendnoise(struct ast_channel *chan, int ms)
|
||||
{
|
||||
int res;
|
||||
res = ast_tonepair_start(chan, 1537, 2195, ms, 8192);
|
||||
if (!res) {
|
||||
res = ast_waitfordigit(chan, ms);
|
||||
ast_tonepair_stop(chan);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int testclient_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
struct localuser *u;
|
||||
int res = 0;
|
||||
char *testid=data;
|
||||
char fn[80];
|
||||
char serverver[80];
|
||||
FILE *f;
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
/* Check for test id */
|
||||
if (!testid || ast_strlen_zero(testid)) {
|
||||
ast_log(LOG_WARNING, "TestClient requires an argument - the test id\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (chan->_state != AST_STATE_UP)
|
||||
res = ast_answer(chan);
|
||||
|
||||
/* Wait a few just to be sure things get started */
|
||||
res = ast_safe_sleep(chan, 3000);
|
||||
/* Transmit client version */
|
||||
if (!res)
|
||||
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
|
||||
ast_log(LOG_DEBUG, "Transmit client version\n");
|
||||
|
||||
/* Read server version */
|
||||
ast_log(LOG_DEBUG, "Read server version\n");
|
||||
if (!res)
|
||||
res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
ast_log(LOG_DEBUG, "server version: %s\n", serverver);
|
||||
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
|
||||
if (!res)
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
/* Send test id */
|
||||
if (!res)
|
||||
res = ast_dtmf_stream(chan, NULL, testid, 0);
|
||||
if (!res)
|
||||
res = ast_dtmf_stream(chan, NULL, "#", 0);
|
||||
ast_log(LOG_DEBUG, "send test identifier: %s\n", testid);
|
||||
|
||||
if ((res >=0) && (!ast_strlen_zero(testid))) {
|
||||
/* Make the directory to hold the test results in case it's not there */
|
||||
snprintf(fn, sizeof(fn), "%s/testresults", ast_config_AST_LOG_DIR);
|
||||
mkdir(fn, 0777);
|
||||
snprintf(fn, sizeof(fn), "%s/testresults/%s-client.txt", ast_config_AST_LOG_DIR, testid);
|
||||
if ((f = fopen(fn, "w+"))) {
|
||||
setlinebuf(f);
|
||||
fprintf(f, "CLIENTCHAN: %s\n", chan->name);
|
||||
fprintf(f, "CLIENTTEST ID: %s\n", testid);
|
||||
fprintf(f, "ANSWER: PASS\n");
|
||||
res = 0;
|
||||
|
||||
if (!res) {
|
||||
/* Step 1: Wait for "1" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n");
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS");
|
||||
if (res == '1')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res)
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
if (!res) {
|
||||
/* Step 2: Send "2" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "2", 0);
|
||||
fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 3: Wait one second */
|
||||
ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n");
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 4: Measure noise */
|
||||
ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n");
|
||||
res = measurenoise(chan, 5000, "TestClient");
|
||||
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 5: Wait for "4" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n");
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS");
|
||||
if (res == '4')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 6: Transmit tone noise */
|
||||
ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n");
|
||||
res = sendnoise(chan, 6000);
|
||||
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
}
|
||||
if (!res || (res == '5')) {
|
||||
/* Step 7: Wait for "5" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n");
|
||||
if (!res)
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS");
|
||||
if (res == '5')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 8: Wait one second */
|
||||
ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n");
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 9: Measure noise */
|
||||
ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n");
|
||||
res = measurenoise(chan, 4000, "TestClient");
|
||||
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 10: Send "7" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "7", 0);
|
||||
fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res =0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 11: Wait for "8" */
|
||||
ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n");
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS");
|
||||
if (res == '8')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 12: Hangup! */
|
||||
ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n");
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n");
|
||||
fprintf(f, "-- END TEST--\n");
|
||||
fclose(f);
|
||||
res = -1;
|
||||
} else
|
||||
res = -1;
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
|
||||
res = -1;
|
||||
}
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int testserver_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
struct localuser *u;
|
||||
int res = 0;
|
||||
char testid[80]="";
|
||||
char fn[80];
|
||||
FILE *f;
|
||||
LOCAL_USER_ADD(u);
|
||||
if (chan->_state != AST_STATE_UP)
|
||||
res = ast_answer(chan);
|
||||
/* Read version */
|
||||
ast_log(LOG_DEBUG, "Read client version\n");
|
||||
if (!res)
|
||||
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
ast_log(LOG_DEBUG, "client version: %s\n", testid);
|
||||
ast_log(LOG_DEBUG, "Transmit server version\n");
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
if (!res)
|
||||
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
|
||||
if (!res)
|
||||
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
|
||||
ast_log(LOG_DEBUG, "read test identifier: %s\n", testid);
|
||||
/* Check for sneakyness */
|
||||
if (strchr(testid, '/'))
|
||||
res = -1;
|
||||
if ((res >=0) && (!ast_strlen_zero(testid))) {
|
||||
/* Got a Test ID! Whoo hoo! */
|
||||
/* Make the directory to hold the test results in case it's not there */
|
||||
snprintf(fn, sizeof(fn), "%s/testresults", ast_config_AST_LOG_DIR);
|
||||
mkdir(fn, 0777);
|
||||
snprintf(fn, sizeof(fn), "%s/testresults/%s-server.txt", ast_config_AST_LOG_DIR, testid);
|
||||
if ((f = fopen(fn, "w+"))) {
|
||||
setlinebuf(f);
|
||||
fprintf(f, "SERVERCHAN: %s\n", chan->name);
|
||||
fprintf(f, "SERVERTEST ID: %s\n", testid);
|
||||
fprintf(f, "ANSWER: PASS\n");
|
||||
ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
if (!res) {
|
||||
/* Step 1: Send "1" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "1", 0);
|
||||
fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 2: Wait for "2" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n");
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS");
|
||||
if (res == '2')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 3: Measure noise */
|
||||
ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n");
|
||||
res = measurenoise(chan, 6000, "TestServer");
|
||||
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 4: Send "4" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "4", 0);
|
||||
fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
/* Step 5: Wait one second */
|
||||
ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n");
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
/* Step 6: Measure noise */
|
||||
ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n");
|
||||
res = measurenoise(chan, 4000, "TestServer");
|
||||
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
/* Step 7: Send "5" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "5", 0);
|
||||
fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
/* Step 8: Transmit tone noise */
|
||||
ast_log(LOG_DEBUG, "TestServer: 8. Transmit tone\n");
|
||||
res = sendnoise(chan, 6000);
|
||||
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
}
|
||||
|
||||
if (!res || (res == '7')) {
|
||||
/* Step 9: Wait for "7" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n");
|
||||
if (!res)
|
||||
res = ast_waitfordigit(chan, 3000);
|
||||
fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS");
|
||||
if (res == '7')
|
||||
res = 0;
|
||||
else
|
||||
res = -1;
|
||||
}
|
||||
if (!res)
|
||||
res = ast_safe_sleep(chan, 1000);
|
||||
if (!res) {
|
||||
/* Step 10: Send "8" */
|
||||
ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n");
|
||||
res = ast_dtmf_stream(chan, NULL, "8", 0);
|
||||
fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS");
|
||||
if (res > 0)
|
||||
res = 0;
|
||||
}
|
||||
if (!res) {
|
||||
/* Step 11: Wait for hangup to arrive! */
|
||||
ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n");
|
||||
res = ast_safe_sleep(chan, 10000);
|
||||
fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL");
|
||||
}
|
||||
|
||||
ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n");
|
||||
fprintf(f, "-- END TEST--\n");
|
||||
fclose(f);
|
||||
res = -1;
|
||||
} else
|
||||
res = -1;
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
|
||||
res = -1;
|
||||
}
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
ast_unregister_application(testc_app);
|
||||
return ast_unregister_application(tests_app);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
ast_register_application(testc_app, testclient_exec, testc_synopsis, testc_descrip);
|
||||
return ast_register_application(tests_app, testserver_exec, tests_synopsis, tests_descrip);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
int res;
|
||||
STANDARD_USECOUNT(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *key(void)
|
||||
{
|
||||
return ASTERISK_GPL_KEY;
|
||||
}
|
0
apps/app_transfer.c
Executable file → Normal file
0
apps/app_transfer.c
Executable file → Normal file
0
apps/app_txtcidname.c
Executable file → Normal file
0
apps/app_txtcidname.c
Executable file → Normal file
0
apps/app_url.c
Executable file → Normal file
0
apps/app_url.c
Executable file → Normal file
2
apps/app_userevent.c
Executable file → Normal file
2
apps/app_userevent.c
Executable file → Normal file
@@ -54,12 +54,12 @@ static int userevent_exec(struct ast_channel *chan, void *data)
|
||||
}
|
||||
|
||||
strncpy(info, (char *)data, strlen((char *)data) + AST_MAX_EXTENSION-1);
|
||||
snprintf(eventname, sizeof(eventname), "UserEvent%s", info);
|
||||
eventbody = strchr(eventname, '|');
|
||||
if (eventbody) {
|
||||
*eventbody = '\0';
|
||||
eventbody++;
|
||||
}
|
||||
snprintf(eventname, sizeof(eventname), "UserEvent%s", info);
|
||||
LOCAL_USER_ADD(u);
|
||||
|
||||
if(eventbody) {
|
||||
|
0
apps/app_verbose.c
Executable file → Normal file
0
apps/app_verbose.c
Executable file → Normal file
1505
apps/app_voicemail.c
Executable file → Normal file
1505
apps/app_voicemail.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
0
apps/app_waitforring.c
Executable file → Normal file
0
apps/app_waitforring.c
Executable file → Normal file
0
apps/app_zapateller.c
Executable file → Normal file
0
apps/app_zapateller.c
Executable file → Normal file
0
apps/app_zapbarge.c
Executable file → Normal file
0
apps/app_zapbarge.c
Executable file → Normal file
0
apps/app_zapras.c
Executable file → Normal file
0
apps/app_zapras.c
Executable file → Normal file
0
apps/app_zapscan.c
Executable file → Normal file
0
apps/app_zapscan.c
Executable file → Normal file
0
apps/enter.h
Executable file → Normal file
0
apps/enter.h
Executable file → Normal file
0
apps/leave.h
Executable file → Normal file
0
apps/leave.h
Executable file → Normal file
0
apps/rpt_flow.pdf
Executable file → Normal file
0
apps/rpt_flow.pdf
Executable file → Normal file
68
ast_expr.y
Executable file → Normal file
68
ast_expr.y
Executable file → Normal file
@@ -215,6 +215,7 @@ struct val *vp;
|
||||
}
|
||||
if (vp->type == string || vp->type == numeric_string)
|
||||
free (vp->u.s);
|
||||
free (vp);
|
||||
}
|
||||
|
||||
|
||||
@@ -650,19 +651,24 @@ struct val *a, *b;
|
||||
{
|
||||
struct val *r;
|
||||
|
||||
if (!to_integer (a) || !to_integer (b)) {
|
||||
if (!to_integer (a)) {
|
||||
ast_log(LOG_WARNING,"non-numeric argument\n");
|
||||
free_value(a);
|
||||
if (!to_integer (b)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return make_integer(0);
|
||||
} else {
|
||||
free_value(a);
|
||||
return (b);
|
||||
}
|
||||
} else if (!to_integer(b)) {
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
return (a);
|
||||
}
|
||||
|
||||
r = make_integer (/*(quad_t)*/(a->u.i + b->u.i));
|
||||
if (chk_plus (a->u.i, b->u.i, r->u.i)) {
|
||||
ast_log(LOG_WARNING,"overflow\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
}
|
||||
free_value (a);
|
||||
free_value (b);
|
||||
@@ -690,19 +696,27 @@ struct val *a, *b;
|
||||
{
|
||||
struct val *r;
|
||||
|
||||
if (!to_integer (a) || !to_integer (b)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
if (!to_integer (a)) {
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
return(NULL);
|
||||
if (!to_integer (b)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return make_integer(0);
|
||||
} else {
|
||||
r = make_integer(0 - b->u.i);
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return (r);
|
||||
}
|
||||
} else if (!to_integer(b)) {
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
free_value(b);
|
||||
return (a);
|
||||
}
|
||||
|
||||
r = make_integer (/*(quad_t)*/(a->u.i - b->u.i));
|
||||
if (chk_minus (a->u.i, b->u.i, r->u.i)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
ast_log(LOG_WARNING, "overload\n");
|
||||
return(NULL);
|
||||
ast_log(LOG_WARNING, "overflow\n");
|
||||
}
|
||||
free_value (a);
|
||||
free_value (b);
|
||||
@@ -732,15 +746,12 @@ struct val *a, *b;
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
return(NULL);
|
||||
return(make_integer(0));
|
||||
}
|
||||
|
||||
r = make_integer (/*(quad_t)*/(a->u.i * b->u.i));
|
||||
if (chk_times (a->u.i, b->u.i, r->u.i)) {
|
||||
ast_log(LOG_WARNING, "overflow\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
}
|
||||
free_value (a);
|
||||
free_value (b);
|
||||
@@ -765,26 +776,28 @@ struct val *a, *b;
|
||||
{
|
||||
struct val *r;
|
||||
|
||||
if (!to_integer (a) || !to_integer (b)) {
|
||||
if (!to_integer (a)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
return(NULL);
|
||||
return make_integer(0);
|
||||
} else if (!to_integer (b)) {
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
return make_integer(INT_MAX);
|
||||
}
|
||||
|
||||
if (b->u.i == 0) {
|
||||
ast_log(LOG_WARNING, "division by zero\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
return make_integer(INT_MAX);
|
||||
}
|
||||
|
||||
r = make_integer (/*(quad_t)*/(a->u.i / b->u.i));
|
||||
if (chk_div (a->u.i, b->u.i)) {
|
||||
ast_log(LOG_WARNING, "overflow\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
}
|
||||
free_value (a);
|
||||
free_value (b);
|
||||
@@ -801,14 +814,13 @@ struct val *a, *b;
|
||||
ast_log(LOG_WARNING, "non-numeric argument\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
return make_integer(0);
|
||||
}
|
||||
|
||||
if (b->u.i == 0) {
|
||||
ast_log(LOG_WARNING, "div by zero\n");
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
return (b);
|
||||
}
|
||||
|
||||
r = make_integer (/*(quad_t)*/(a->u.i % b->u.i));
|
||||
@@ -838,7 +850,7 @@ struct val *a, *b;
|
||||
ast_log(LOG_WARNING,"regcomp() error : %s",errbuf);
|
||||
free_value(a);
|
||||
free_value(b);
|
||||
return(NULL);
|
||||
return make_str("");
|
||||
}
|
||||
|
||||
/* compare string against pattern */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user