summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net-misc/asterisk/ChangeLog14
-rw-r--r--net-misc/asterisk/asterisk-1.4.37.ebuild304
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk-1.4.0-uclibc.patch13
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk-1.4.0-var_rundir.patch11
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk-1.4.33-gsm-pic.patch59
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk-1.4.33-inband-indications.patch20
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk-1.4.37-imap-libs.patch11
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk.confd98
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk.initd273
-rw-r--r--net-misc/asterisk/files/1.4.0/asterisk.logrotate25
-rw-r--r--net-misc/asterisk/files/1.4.0/func_devstate-r6.c228
-rw-r--r--net-misc/asterisk/files/1.4.0/func_volume.c160
12 files changed, 1215 insertions, 1 deletions
diff --git a/net-misc/asterisk/ChangeLog b/net-misc/asterisk/ChangeLog
index 18dfc042bd1a..2129701dfbbd 100644
--- a/net-misc/asterisk/ChangeLog
+++ b/net-misc/asterisk/ChangeLog
@@ -1,6 +1,18 @@
# ChangeLog for net-misc/asterisk
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.274 2010/10/27 22:57:59 chainsaw Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.275 2010/12/01 17:54:28 chainsaw Exp $
+
+*asterisk-1.4.37 (01 Dec 2010)
+
+ 01 Dec 2010; <chainsaw@gentoo.org> +files/1.4.0/asterisk-1.4.0-uclibc.patch,
+ +files/1.4.0/asterisk-1.4.0-var_rundir.patch,
+ +files/1.4.0/asterisk-1.4.33-inband-indications.patch,
+ +files/1.4.0/asterisk-1.4.37-imap-libs.patch, +files/1.4.0/asterisk.confd,
+ +files/1.4.0/asterisk.initd, +files/1.4.0/asterisk-1.4.33-gsm-pic.patch,
+ +files/1.4.0/asterisk.logrotate, +asterisk-1.4.37.ebuild,
+ +files/1.4.0/func_devstate-r6.c, +files/1.4.0/func_volume.c:
+ Add 1.4 branch ebuild & patchset by Kerin Millar, who will be proxy
+ maintaining.
27 Oct 2010; <chainsaw@gentoo.org> asterisk-1.8.0.ebuild:
Apparently production releases can now depend on beta code. Notch up
diff --git a/net-misc/asterisk/asterisk-1.4.37.ebuild b/net-misc/asterisk/asterisk-1.4.37.ebuild
new file mode 100644
index 000000000000..3a1bfbbb1291
--- /dev/null
+++ b/net-misc/asterisk/asterisk-1.4.37.ebuild
@@ -0,0 +1,304 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.4.37.ebuild,v 1.1 2010/12/01 17:54:28 chainsaw Exp $
+
+EAPI=3
+inherit autotools base eutils flag-o-matic linux-info multilib
+
+MY_P="${PN}-${PV/_/-}"
+
+DESCRIPTION="Asterisk: A Modular Open Source PBX System"
+HOMEPAGE="http://www.asterisk.org/"
+SRC_URI="http://downloads.asterisk.org/pub/telephony/asterisk/releases/${MY_P}.tar.gz"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64"
+
+IUSE="alsa +caps dahdi debug doc freetds imap jabber keepsrc misdn newt +samples odbc oss postgres radius snmp speex ssl sqlite static vanilla vorbis"
+
+RDEPEND="sys-libs/ncurses
+ dev-libs/popt
+ sys-libs/zlib
+ alsa? ( media-libs/alsa-lib )
+ caps? ( sys-libs/libcap )
+ dahdi? ( >=net-libs/libpri-1.4.7
+ net-misc/dahdi-tools )
+ freetds? ( dev-db/freetds )
+ imap? ( >=net-libs/c-client-2007[ssl=] )
+ jabber? ( dev-libs/iksemel )
+ misdn? ( net-dialup/misdnuser )
+ newt? ( dev-libs/newt )
+ odbc? ( dev-db/unixODBC )
+ postgres? ( dev-db/postgresql-base )
+ radius? ( net-dialup/radiusclient-ng )
+ snmp? ( net-analyzer/net-snmp )
+ speex? ( media-libs/speex )
+ sqlite? ( dev-db/sqlite )
+ ssl? ( dev-libs/openssl )
+ vorbis? ( media-libs/libvorbis )"
+
+DEPEND="${RDEPEND}
+ !<net-misc/asterisk-addons-1.4
+ !>=net-misc/asterisk-addons-1.6
+ !net-misc/zaptel"
+
+PDEPEND="net-misc/asterisk-core-sounds
+ net-misc/asterisk-extra-sounds
+ net-misc/asterisk-moh-opsound"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+ "${FILESDIR}/1.4.0/${PN}-1.4.0-var_rundir.patch"
+ "${FILESDIR}/1.4.0/${PN}-1.4.33-gsm-pic.patch"
+ "${FILESDIR}/1.4.0/${PN}-1.4.0-uclibc.patch"
+ "${FILESDIR}/1.4.0/${PN}-1.4.33-inband-indications.patch"
+ "${FILESDIR}/1.4.0/${P}-imap-libs.patch"
+)
+
+pkg_setup() {
+ CONFIG_CHECK="~!NF_CONNTRACK_SIP"
+ local WARNING_NF_CONNTRACK_SIP="SIP (NAT) connection tracking is enabled. Some users
+ have reported that this module dropped critical SIP packets in their deployments. You
+ may want to disable it if you see such problems."
+ check_extra_config
+}
+
+src_prepare() {
+ base_src_prepare
+ AT_M4DIR=autoconf eautoreconf
+
+ # add custom device state function (func_devstate)
+ #
+ # http://asterisk.org/node/48360
+ # http://svncommunity.digium.com/svn/russell/func_devstate-1.4/README.txt
+ #
+ cp "${FILESDIR}"/1.4.0/func_devstate-r6.c "${S}"/funcs/func_devstate.c
+
+ # Add technology-independent volume control function
+ #
+ cp "${FILESDIR}"/1.4.0/func_volume.c "${S}"/funcs/func_volume.c
+
+ # Custom menuselect options are defined in this file (it may remain empty)
+ #
+ >"${S}"/gentoo.makeopts
+
+ # Enable various debugging options if requested
+ #
+ if use debug; then
+ local debug_opts="DEBUG_CHANNEL_LOCKS DEBUG_THREADS DEBUG_FD_LEAKS"
+ einfo "Enabling debugging options: ${debug_opts}"
+ echo "MENUSELECT_CFLAGS=${debug_opts}" >> "${S}"/gentoo.makeopts
+ fi
+
+ # Enable IMAP storage in app_voicemail if requested
+ #
+ use imap && echo "MENUSELECT_OPTS_app_voicemail=IMAP_STORAGE" >> "${S}"/gentoo.makeopts
+}
+
+src_configure() {
+ if use debug; then
+ # Tone down the compiler flags somewhat. This should be less aggressive
+ # than the DONT_OPTIMIZE option whilst still producing useful results.
+ #
+ strip-flags
+ replace-flags -O? -O0
+ fi
+
+ if use imap; then
+ local imap_libs
+ has_version net-libs/c-client[pam] && imap_libs="-lpam"
+ has_version net-libs/c-client[ssl] && imap_libs="${imap_libs} -lssl"
+ export IMAP_LIBS="${imap_libs}"
+ fi
+
+ econf \
+ --libdir="/usr/$(get_libdir)" \
+ --localstatedir="/var" \
+ --with-gsm=internal \
+ --with-ncurses \
+ --with-popt \
+ --with-z \
+ --without-curses \
+ --without-h323 \
+ --without-nbs \
+ --without-osptk \
+ --without-pwlib \
+ --without-kde \
+ --without-usb \
+ --without-vpb \
+ --without-zaptel \
+ $(use_with alsa asound) \
+ $(use_with caps cap) \
+ $(use_with dahdi pri) \
+ $(use_with dahdi tonezone) \
+ $(use_with dahdi) \
+ $(use_with freetds tds) \
+ $(use_with imap imap system) \
+ $(use_with jabber iksemel) \
+ $(use_with misdn isdnnet) \
+ $(use_with misdn suppserv) \
+ $(use_with misdn) \
+ $(use_with newt) \
+ $(use_with odbc) \
+ $(use_with oss) \
+ $(use_with postgres) \
+ $(use_with radius) \
+ $(use_with snmp netsnmp) \
+ $(use_with speex) \
+ $(use_with speex speexdsp) \
+ $(use_with sqlite) \
+ $(use_with ssl) \
+ $(use_with vorbis ogg) \
+ $(use_with vorbis) || die "econf failed"
+
+ #
+ # blank out sounds/sounds.xml file to prevent
+ # asterisk from installing sounds files (we pull them in via
+ # asterisk-{core,extra}-sounds and asterisk-moh-opsound.
+ #
+ >"${S}"/sounds/sounds.xml
+}
+
+src_compile() {
+ ASTLDFLAGS="${LDFLAGS}" emake USER_MAKEOPTS="${S}"/gentoo.makeopts || die "emake failed"
+}
+
+src_install() {
+ # setup directory structure
+ #
+ mkdir -p "${D}"usr/$(get_libdir)/pkgconfig
+
+ emake DESTDIR="${D}" install || die "emake install failed"
+
+ if use samples; then
+ emake DESTDIR="${D}" samples || die "emake samples failed"
+ for conffile in "${D}"etc/asterisk/*.*
+ do
+ chown asterisk:asterisk $conffile
+ chmod 0660 $conffile
+ done
+ einfo "Sample files have been installed"
+ else
+ einfo "Skipping installation of sample files..."
+ rm -f "${D}"var/lib/asterisk/mohmp3/*
+ rm -f "${D}"var/lib/asterisk/sounds/demo-*
+ rm -f "${D}"var/lib/asterisk/agi-bin/*
+ rm -f "${D}"etc/asterisk/*
+ fi
+ rm -rf "${D}"var/spool/asterisk/voicemail/default
+
+ # keep directories
+ diropts -m 0770 -o asterisk -g asterisk
+ keepdir /etc/asterisk
+ keepdir /var/lib/asterisk
+ keepdir /var/run/asterisk
+ keepdir /var/spool/asterisk
+ keepdir /var/spool/asterisk/{system,tmp,meetme,monitor,dictate,voicemail}
+ diropts -m 0750 -o asterisk -g asterisk
+ keepdir /var/log/asterisk/{cdr-csv,cdr-custom}
+
+ newinitd "${FILESDIR}"/1.4.0/asterisk.initd asterisk
+ newconfd "${FILESDIR}"/1.4.0/asterisk.confd asterisk
+
+ # some people like to keep the sources around for custom patching
+ # copy the whole source tree to /usr/src/asterisk-${PVF} and run make clean there
+ if use keepsrc
+ then
+ dodir /usr/src
+
+ ebegin "Copying sources into /usr/src"
+ cp -dPR "${S}" "${D}"/usr/src/${PF} || die "Unable to copy sources"
+ eend $?
+
+ ebegin "Cleaning source tree"
+ emake -C "${D}"/usr/src/${PF} clean &>/dev/null || die "Unable to clean sources"
+ eend $?
+
+ einfo "Clean sources are available in "${ROOT}"usr/src/${PF}"
+ fi
+
+ # install the upgrade documentation
+ #
+ dodoc README UPGRADE* BUGS CREDITS
+
+ # install extra documentation
+ #
+ if use doc
+ then
+ dodoc doc/*.txt
+ dodoc doc/*.pdf
+ dodoc doc/PEERING
+ dodoc doc/CODING-GUIDELINES
+ dodoc doc/tex/*.pdf
+ fi
+
+ # install snmp mib files
+ #
+ if use snmp
+ then
+ insinto /usr/share/snmp/mibs/
+ doins doc/digium-mib.txt doc/asterisk-mib.txt
+ fi
+
+ # install SIP scripts; bug #300832
+ #
+ dodoc "${FILESDIR}/1.6.2/sip_calc_auth"
+ dodoc "${FILESDIR}/1.6.2/find_call_sip_trace.sh"
+ dodoc "${FILESDIR}/1.6.2/find_call_ids.sh"
+ dodoc "${FILESDIR}/1.6.2/call_data.txt"
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}/1.4.0/asterisk.logrotate" asterisk
+}
+
+pkg_preinst() {
+ enewgroup asterisk
+ enewuser asterisk -1 -1 /var/lib/asterisk "asterisk,dialout"
+}
+
+pkg_postinst() {
+ #
+ # Announcements, warnings, reminders...
+ #
+ einfo "Asterisk has been installed"
+ echo
+ elog "If you want to know more about asterisk, visit these sites:"
+ elog "http://www.asteriskdocs.org/"
+ elog "http://www.voip-info.org/wiki-Asterisk"
+ echo
+ elog "http://www.automated.it/guidetoasterisk.htm"
+ echo
+ elog "Gentoo VoIP IRC Channel:"
+ elog "#gentoo-voip @ irc.freenode.net"
+ echo
+ echo
+ if has_version "=net-misc/asterisk-1.2*"; then
+ ewarn "Please read "${ROOT}"usr/share/doc/${PF}/UPGRADE.txt.bz2 before continuing"
+ fi
+}
+
+pkg_config() {
+ einfo "Do you want to reset file permissions and ownerships (y/N)?"
+
+ read tmp
+ tmp="$(echo $tmp | tr '[:upper:]' '[:lower:]')"
+
+ if [[ "$tmp" = "y" ]] ||\
+ [[ "$tmp" = "yes" ]]
+ then
+ einfo "Resetting permissions to defaults..."
+
+ for x in spool run lib log; do
+ chown -R asterisk:asterisk "${ROOT}"var/${x}/asterisk
+ chmod -R u=rwX,g=rwX,o= "${ROOT}"var/${x}/asterisk
+ done
+
+ chown -R root:asterisk "${ROOT}"etc/asterisk
+ chmod -R u=rwX,g=rwX,o= "${ROOT}"etc/asterisk
+
+ einfo "done"
+ else
+ einfo "skipping"
+ fi
+}
diff --git a/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-uclibc.patch b/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-uclibc.patch
new file mode 100644
index 000000000000..476fcf90c198
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-uclibc.patch
@@ -0,0 +1,13 @@
+--- Makefile.old 2007-01-05 10:12:48 +0000
++++ Makefile 2007-01-05 10:21:52 +0000
+@@ -216,6 +216,10 @@
+ ASTCFLAGS+=-pthread
+ endif
+
++ifeq ($(OSARCH),linux-uclibc)
++ AST_LIBS+=-lpthread -ldl
++endif
++
+ ifeq ($(OSARCH),SunOS)
+ ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include
+ endif
diff --git a/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-var_rundir.patch b/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-var_rundir.patch
new file mode 100644
index 000000000000..367dc7163f54
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk-1.4.0-var_rundir.patch
@@ -0,0 +1,11 @@
+--- asterisk-1.4.0/Makefile.orig 2006-12-24 03:07:19.000000000 +0000
++++ asterisk-1.4.0/Makefile 2006-12-24 03:07:57.000000000 +0000
+@@ -109,7 +109,7 @@
+ ASTSBINDIR=$(sbindir)
+ ASTSPOOLDIR=$(localstatedir)/spool/asterisk
+ ASTLOGDIR=$(localstatedir)/log/asterisk
+- ASTVARRUNDIR=$(localstatedir)/run
++ ASTVARRUNDIR=$(localstatedir)/run/asterisk
+ ASTMANDIR=$(mandir)
+ ifeq ($(OSARCH),FreeBSD)
+ ASTVARLIBDIR=$(prefix)/share/asterisk
diff --git a/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-gsm-pic.patch b/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-gsm-pic.patch
new file mode 100644
index 000000000000..208eb125d7b0
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-gsm-pic.patch
@@ -0,0 +1,59 @@
+--- asterisk-1.4.33.orig/codecs/gsm/Makefile 2010-03-16 20:47:15.000000000 +0000
++++ asterisk-1.4.33/codecs/gsm/Makefile 2010-06-20 18:21:56.576515592 +0100
+@@ -37,30 +37,6 @@
+ ######### ppro's, etc, as well as the AMD K6 and K7. The compile will
+ ######### probably require gcc.
+
+-ifeq (,$(findstring $(shell uname -s),Darwin SunOS))
+- ifeq (,$(findstring $(PROC),x86_64 amd64 ultrasparc sparc64 arm armv5b armeb hppa2.0 ppc powerpc ppc64 ia64 s390 bfin mipsel mips))
+- ifeq (,$(findstring $(shell uname -m),ppc ppc64 alpha armv4l s390))
+- OPTIMIZE+=-march=$(PROC)
+- endif
+- endif
+-else
+- ifneq (,$(findstring $(OSARCH),Darwin))
+- ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
+- # Snow Leopard reports i386, even though it's really x86_64
+- OPTIMIZE+=-mtune=native
+- endif
+- endif
+-endif
+-
+-#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
+-ifeq ($(PROC),ultrasparc)
+-OPTIMIZE+=-mcpu=v8 -mtune=$(PROC) -O3
+-endif
+-
+ PG =
+ #PG = -g -pg
+ ######### Profiling flags. If you don't know what that means, leave it blank.
+@@ -217,10 +193,12 @@
+ ifeq ($(OSARCH),linux-gnu)
+ ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc s390 ))
+ ifeq (,$(findstring $(PROC) , arm armv5b armeb powerpc ia64 s390 bfin mipsel mips ))
++ifneq ($(K6OPT),)
+ GSM_SOURCES+= $(SRC)/k6opt.s
+ endif
+ endif
+ endif
++endif
+
+ TOAST_SOURCES = $(SRC)/toast.c \
+ $(SRC)/toast_lin.c \
+@@ -269,10 +247,12 @@
+ ifeq ($(OSARCH),linux-gnu)
+ ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc ))
+ ifeq (,$(findstring $(PROC) , arm armv5b armeb powerpc ia64 bfin mipsel mips ))
++ifneq ($(K6OPT),)
+ GSM_OBJECTS+= $(SRC)/k6opt.o
+ endif
+ endif
+ endif
++endif
+
+ TOAST_OBJECTS = $(SRC)/toast.o \
+ $(SRC)/toast_lin.o \
diff --git a/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-inband-indications.patch b/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-inband-indications.patch
new file mode 100644
index 000000000000..60b3ead00cce
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk-1.4.33-inband-indications.patch
@@ -0,0 +1,20 @@
+--- asterisk-1.4.33.orig/main/channel.c 2010-05-24 20:37:55.000000000 +0100
++++ asterisk-1.4.33/main/channel.c 2010-06-23 15:06:44.949805705 +0100
+@@ -1767,6 +1767,8 @@ int ast_activate_generator(struct ast_ch
+ chan->generator->release(chan, chan->generatordata);
+ chan->generatordata = NULL;
+ }
++
++ ast_prod(chan);
+ if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
+ res = -1;
+ }
+@@ -1776,8 +1778,6 @@ int ast_activate_generator(struct ast_ch
+ }
+ ast_channel_unlock(chan);
+
+- ast_prod(chan);
+-
+ return res;
+ }
+
diff --git a/net-misc/asterisk/files/1.4.0/asterisk-1.4.37-imap-libs.patch b/net-misc/asterisk/files/1.4.0/asterisk-1.4.37-imap-libs.patch
new file mode 100644
index 000000000000..ede088579b41
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk-1.4.37-imap-libs.patch
@@ -0,0 +1,11 @@
+--- asterisk-1.4.37.orig/configure.ac 2010-09-10 01:13:45.000000000 +0100
++++ asterisk-1.4.37/configure.ac 2010-11-27 14:37:29.379718734 +0000
+@@ -1032,7 +1032,7 @@
+ CPPFLAGS="${saved_cppflags}"
+ LIBS="${saved_libs}"
+ imap_ldflags=""
+- imap_libs="-lc-client"
++ imap_libs="-lc-client ${IMAP_LIBS}"
+ imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first
+ CPPFLAGS="${CPPFLAGS} ${imap_include}"
+ LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
diff --git a/net-misc/asterisk/files/1.4.0/asterisk.confd b/net-misc/asterisk/files/1.4.0/asterisk.confd
new file mode 100644
index 000000000000..4a4ef3f554ce
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk.confd
@@ -0,0 +1,98 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.4.0/asterisk.confd,v 1.1 2010/12/01 17:54:28 chainsaw Exp $
+
+#
+# Additional options for asterisk
+#
+# see "asterisk -h" for a list of options
+#
+ASTERISK_OPTS=""
+
+#
+# User and group to run asterisk as
+#
+# Value: double-colon separated list of user and group, or empty to run as root:
+#
+#
+# "asterisk:asterisk" to run as user "asterisk" and group "asterisk"
+#
+# "asterisk" to run as user "asterisk" and all groups that user "asterisk" is a member of
+#
+# ":asterisk" to run as user "root" and group "asterisk"
+#
+# "" to run as user "root" and group "root"
+#
+ASTERISK_USER="asterisk"
+
+#
+# Nicelevel
+#
+# Set the priority of the asterisk process
+#
+# Value: (highest) -20..19 (lowest)
+#
+#ASTERISK_NICE="19"
+
+#
+# Wrapper script
+#
+# Value: yes or no/empty
+#
+ASTERISK_WRAPPER="no"
+
+############# Wrapper script settings #############
+
+#
+# Send crash notifications emails to this address
+# (needs a working mail service and /usr/sbin/sendmail to do so (e.g. ssmtp))
+#
+# Value: Email address or empty to disable
+#
+#ASTERISK_NOTIFY_EMAIL="root"
+
+#
+# Send asterisk's output to this terminal
+#
+# Value: Full path to device node or a number
+#
+#ASTERISK_TTY="/dev/tty9"
+
+#
+# Start an asterisk console on the terminal specified by ASTERISK_TTY
+#
+# Warning! Use only for debugging, this is a potential security issue!
+#
+# Value: yes or no/empty
+#
+ASTERISK_CONSOLE="no"
+
+#
+# Maximum size of core files.
+#
+# Value: Size in bytes, unlimited for no limit or empty to disable.
+#
+#ASTERISK_CORE_SIZE="unlimited"
+
+#
+# ASTERISK_CORE_DIR
+#
+# Value: Directory (will be created if non-existant), default is /tmp
+#
+ASTERISK_CORE_DIR="/var/lib/asterisk/coredump"
+
+#
+# Max number of filedescriptors
+#
+# Value: Number of descriptors
+#
+#ASTERISK_MAX_FD="1024"
+
+#
+# Kill these tasks after asterisk crashed (ASTERISK_WRAPPER=yes only!)
+#
+# Warning! This will kill _ALL_ tasks with the specified names!
+#
+# Value: Space separated list of names in double quotes (e.g. "mpg123 mad")
+#
+#ASTERISK_CLEANUP_ON_CRASH="mpg123 asterisk-mpg123 mad"
diff --git a/net-misc/asterisk/files/1.4.0/asterisk.initd b/net-misc/asterisk/files/1.4.0/asterisk.initd
new file mode 100644
index 000000000000..ab1f017ef362
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk.initd
@@ -0,0 +1,273 @@
+#!/sbin/runscript
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.4.0/asterisk.initd,v 1.1 2010/12/01 17:54:28 chainsaw Exp $
+
+opts="${opts} forcestop reload"
+
+depend() {
+ need net
+ use nscd dns dahdi mysql postgresql slapd capi
+}
+
+is_running() {
+ if [ -z "`pidof asterisk`" ]; then
+ return 1
+ else
+ PID="`cat /var/run/asterisk/asterisk.pid`"
+ for x in `pidof asterisk`; do
+ if [ "${x}" = "${PID}" ]; then
+ return 0
+ fi
+ done
+ fi
+
+ return 1
+}
+
+asterisk_run_loop() {
+ logger -t asterisk_wrapper "Initializing asterisk wrapper"
+
+ local OPTS ARGS MSG NICE=""
+ local result=0 signal=0
+
+ # default options
+ OPTS="-f" # don't fork / detach breaks wrapper script...
+
+ # filter (redundant) arguments
+ ARGS="`echo "${@}" | sed -e "s:-c\|-f::g"`"
+
+ # mangle yes/no options
+ ASTERISK_CONSOLE="`echo ${ASTERISK_CONSOLE} | tr '[:lower:]' '[:upper:]'`"
+
+ if [ -n "${ASTERISK_CORE_SIZE}" ] &&
+ [ "${ASTERISK_CORE_SIZE}" != "0" ]; then
+ ulimit -c ${ASTERISK_CORE_SIZE}
+
+ if [ -n "${ASTERISK_CORE_DIR}" ] && \
+ [ ! -d "${ASTERISK_CORE_DIR}" ]
+ then
+ mkdir -m750 -p "${ASTERISK_CORE_DIR}"
+
+ if [ -n "${ASTERISK_USER}" ]; then
+ chown -R "${ASTERISK_USER}" "${ASTERISK_CORE_DIR}"
+ fi
+ fi
+ ASTERISK_CORE_DIR="${ASTERISK_CORE_DIR:-/tmp}"
+
+ cd "${ASTERISK_CORE_DIR}"
+ echo " Core dump size : ${ASTERISK_CORE_SIZE}"
+ echo " Core dump location : ${ASTERISK_CORE_DIR}"
+ fi
+
+ if [ -n "${ASTERISK_MAX_FD}" ]; then
+ ulimit -n ${ASTERISK_MAX_FD}
+ echo " Max open filedescriptors : ${ASTERISK_MAX_FD}"
+ fi
+
+ if [ -n "${ASTERISK_NICE}" ]; then
+ echo " Nice level : ${ASTERISK_NICE}"
+ NICE="nice -n ${ASTERISK_NICE} --"
+ fi
+
+ if [ -n "${ASTERISK_NOTIFY_EMAIL}" ]; then
+ if [ -x /usr/sbin/sendmail ]; then
+ echo " Email notifications go to : ${ASTERISK_NOTIFY_EMAIL}"
+ else
+ echo " Notifications disabled, /usr/sbin/sendmail doesn't exist or is not executable!"
+ unset ASTERISK_NOTIFY_EMAIL
+ fi
+ fi
+
+ if [ -n "${ASTERISK_TTY}" ]; then
+ for x in ${ASTERISK_TTY} \
+ /dev/tty${ASTERISK_TTY} \
+ /dev/vc/${ASTERISK_TTY}
+ do
+ if [ -c "${x}" ]; then
+ TTY="${x}"
+ fi
+ done
+ [ -n "${TTY}" ] && \
+ echo " Messages are sent to : ${TTY}"
+ fi
+
+ if [ "${ASTERISK_CONSOLE}" = "YES" ] && [ -n "${TTY}" ]; then
+ echo " Starting Asterisk console : ${ASTERISK_CONSOLE}"
+ OPTS="${OPTS} -c"
+ fi
+
+ OPTS="${OPTS} ${ARGS}"
+
+ trap "rm /var/run/asterisk/wrapper_loop.pid" EXIT
+ cut -f4 -d' ' < /proc/self/stat > /var/run/asterisk/wrapper_loop.pid
+
+ while :; do
+ if [ -n "${TTY}" ]; then
+ /usr/bin/stty -F ${TTY} sane
+ ${NICE} /usr/sbin/asterisk ${OPTS} >${TTY} 2>&1 <${TTY}
+ result=$?
+ else
+ set -o pipefail
+ ${NICE} /usr/sbin/asterisk ${OPTS} 2>&1 >/dev/null | logger -t asterisk_wrapper
+ result=$?
+ set +o pipefail
+ fi
+
+ if [ $result -eq 0 ]; then
+ logger -t asterisk_wrapper "Asterisk terminated normally"
+ break
+ else
+ if [ $result -gt 128 ]; then
+ signal=`expr $signal - 128`
+ MSG="Asterisk terminated with Signal: $signal"
+
+ CORE_TARGET="core-`date +%Y%m%d-%H%M%S`"
+
+ local CORE_DUMPED=0
+ if [ -f "${ASTERISK_CORE_DIR}/core" ]; then
+ mv "${ASTERISK_CORE_DIR}/core" \
+ "${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ CORE_DUMPED=1
+
+ elif [ -f "${ASTERISK_CORE_DIR}/core.${PID}" ]; then
+ mv "${ASTERISK_CORE_DIR}/core.${PID}" \
+ "${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ CORE_DUMPED=1
+
+ fi
+
+ [ $CORE_DUMPED -eq 1 ] && \
+ MSG="${MSG}\n\rCore dumped: ${ASTERISK_CORE_DIR}/${CORE_TARGET}"
+ else
+ MSG="Asterisk terminated with return code: $result"
+ fi
+
+ # kill left-over tasks
+ for X in ${ASTERISK_CLEANUP_ON_CRASH}; do
+ kill -9 `pidof ${X}`;
+ done
+ fi
+
+ [ -n "${TTY}" ] \
+ && echo "${MSG}" >${TTY} \
+ || logger -t asterisk_wrapper "${MSG}"
+
+
+ if [ -n "${ASTERISK_NOTIFY_EMAIL}" ] && \
+ [ -x /usr/sbin/sendmail ]; then
+ echo -e -n "Subject: Asterisk crashed\n\r${MSG}\n\r" |\
+ /usr/sbin/sendmail "${ASTERISK_NOTIFY_EMAIL}"
+ fi
+ sleep 5
+ logger -t asterisk_wrapper "Restarting Asterisk..."
+ done
+ return 0
+}
+
+start() {
+ local OPTS USER GROUP PID
+ local tmp x
+
+ if [ -n "${ASTERISK_NICE}" ]; then
+ if [ ${ASTERISK_NICE} -ge -20 ] && \
+ [ ${ASTERISK_NICE} -le 19 ]; then
+ OPTS="--nicelevel ${ASTERISK_NICE}"
+ else
+ eerror "Nice value must be between -20 and 19"
+ return 1
+ fi
+ fi
+
+ if [ -n "${ASTERISK_USER}" ]; then
+ USER=`echo $ASTERISK_USER | sed 's/:.*//'`
+ GROUP=`echo $ASTERISK_USER | awk -F: '/.*:.*/ { print $2 }'`
+ if [ -n "${USER}" ]; then
+ ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}"
+ fi
+ if [ -n "${GROUP}" ]; then
+ ASTERISK_OPTS="${ASTERISK_OPTS} -G ${GROUP}"
+ GROUP=":${GROUP}" # make it look nice...
+ fi
+ for element in `find /var/{log,run}/asterisk`; do
+ if [ `stat -c %U $element` != "${USER}" ]; then
+ ewarn "${USER} is not the owner of $element, fixing."
+ chown -R ${USER} /var/{log,run}/asterisk
+ chmod -R u+r /var/{log,run}/asterisk
+ chmod u+x /var/{log,run}/asterisk
+ fi;
+ done;
+ ebegin "Starting asterisk PBX (as ${USER}${GROUP})"
+ else
+ ebegin "Starting asterisk PBX (as root)"
+ fi
+
+ if [ "`echo ${ASTERISK_WRAPPER} | tr '[:upper:]' '[:lower:]'`" != "yes" ]; then
+ start-stop-daemon --start --exec /usr/sbin/asterisk \
+ ${OPTS} -- ${ASTERISK_OPTS}
+ result=$?
+ else
+ asterisk_run_loop ${ASTERISK_OPTS} 2>/dev/null &
+ result=$?
+ fi
+
+ if [ $result -eq 0 ]; then
+ # 2 seconds should be enough for asterisk to start
+ sleep 2
+ is_running
+ result=$?
+ fi
+
+ eend $result
+}
+
+forcestop() {
+ ebegin "Stopping asterisk PBX"
+ start-stop-daemon --stop --pidfile /var/run/asterisk/asterisk.pid
+ eend $?
+}
+
+stop() {
+ if ! is_running; then
+ eerror "Asterisk is not running!"
+ return 0
+ fi
+
+ if [ -r /var/run/asterisk/wrapper_loop.pid ]; then
+ ebegin "Killing wrapper script"
+ kill `cat /var/run/asterisk/wrapper_loop.pid`
+ eend $?
+ fi
+
+ ebegin "Stopping asterisk PBX gracefully"
+ /usr/sbin/asterisk -r -x "stop gracefully" &>/dev/null
+ # Now we have to wait until asterisk has _really_ stopped.
+ sleep 1
+ if is_running; then
+ einfon "Waiting for asterisk to shutdown ."
+ local cnt=0
+ while is_running; do
+ cnt=`expr $cnt + 1`
+ if [ $cnt -gt 60 ] ; then
+ # Waited 120 seconds now. Fail.
+ echo
+ eend 1 "Failed."
+ return
+ fi
+ sleep 2
+ echo -n "."
+ done
+ echo
+ fi
+ eend 0
+}
+
+reload() {
+ if is_running; then
+ ebegin "Forcing asterisk to reload configuration"
+ /usr/sbin/asterisk -r -x "reload" &>/dev/null
+ eend $?
+ else
+ eerror "Asterisk is not running!"
+ fi
+}
diff --git a/net-misc/asterisk/files/1.4.0/asterisk.logrotate b/net-misc/asterisk/files/1.4.0/asterisk.logrotate
new file mode 100644
index 000000000000..69296c99e66d
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/asterisk.logrotate
@@ -0,0 +1,25 @@
+/var/log/asterisk/messages /var/log/asterisk/queue_log {
+ missingok
+ notifempty
+
+ postrotate
+ /usr/sbin/asterisk -rnx "logger reload" || /bin/true
+ endscript
+}
+
+/var/log/asterisk/debug /var/log/asterisk/full {
+ missingok
+ notifempty
+ daily
+
+ postrotate
+ /usr/sbin/asterisk -rnx "logger reload" || /bin/true
+ endscript
+}
+
+/var/log/asterisk/cdr-csv/*.csv /var/log/asterisk/cdr-custom/*.csv {
+ missingok
+ notifempty
+ weekly
+ rotate 52
+}
diff --git a/net-misc/asterisk/files/1.4.0/func_devstate-r6.c b/net-misc/asterisk/files/1.4.0/func_devstate-r6.c
new file mode 100644
index 000000000000..bee18aa0eea5
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/func_devstate-r6.c
@@ -0,0 +1,228 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007, Digium, Inc.
+ *
+ * Russell Bryant <russell@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Manually controlled blinky lights
+ *
+ * \author Russell Bryant <russell@digium.com>
+ *
+ * \ingroup functions
+ *
+ * \note Props go out to Ahrimanes in #asterisk for requesting this at 4:30 AM
+ * when I couldn't sleep. :)
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.1 $")
+
+#include <stdlib.h>
+
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/utils.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/devicestate.h"
+#include "asterisk/cli.h"
+#include "asterisk/astdb.h"
+
+static const char astdb_family[] = "CustomDevstate";
+
+static const char *ast_devstate_str(int state)
+{
+ const char *res = "UNKNOWN";
+
+ switch (state) {
+ case AST_DEVICE_UNKNOWN:
+ break;
+ case AST_DEVICE_NOT_INUSE:
+ res = "NOT_INUSE";
+ break;
+ case AST_DEVICE_INUSE:
+ res = "INUSE";
+ break;
+ case AST_DEVICE_BUSY:
+ res = "BUSY";
+ break;
+ case AST_DEVICE_INVALID:
+ res = "INVALID";
+ break;
+ case AST_DEVICE_UNAVAILABLE:
+ res = "UNAVAILABLE";
+ break;
+ case AST_DEVICE_RINGING:
+ res = "RINGING";
+ break;
+ case AST_DEVICE_RINGINUSE:
+ res = "RINGINUSE";
+ break;
+ case AST_DEVICE_ONHOLD:
+ res = "ONHOLD";
+ break;
+ }
+
+ return res;
+}
+
+static int ast_devstate_val(const char *val)
+{
+ if (!strcasecmp(val, "NOT_INUSE"))
+ return AST_DEVICE_NOT_INUSE;
+ else if (!strcasecmp(val, "INUSE"))
+ return AST_DEVICE_INUSE;
+ else if (!strcasecmp(val, "BUSY"))
+ return AST_DEVICE_BUSY;
+ else if (!strcasecmp(val, "INVALID"))
+ return AST_DEVICE_INVALID;
+ else if (!strcasecmp(val, "UNAVAILABLE"))
+ return AST_DEVICE_UNAVAILABLE;
+ else if (!strcasecmp(val, "RINGING"))
+ return AST_DEVICE_RINGING;
+ else if (!strcasecmp(val, "RINGINUSE"))
+ return AST_DEVICE_RINGINUSE;
+ else if (!strcasecmp(val, "ONHOLD"))
+ return AST_DEVICE_ONHOLD;
+
+ return AST_DEVICE_UNKNOWN;
+}
+
+static int devstate_read(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
+{
+ ast_copy_string(buf, ast_devstate_str(ast_device_state(data)), len);
+
+ return 0;
+}
+
+static int devstate_write(struct ast_channel *chan, char *function,
+ char *data, const char *value)
+{
+ size_t len = strlen("Custom:");
+
+ if (strncasecmp(data, "Custom:", len)) {
+ ast_log(LOG_WARNING, "The DEVSTATE function can only be used to set 'Custom:' device state!\n");
+ return -1;
+ }
+ data += len;
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_WARNING, "DEVSTATE function called with no custom device name!\n");
+ return -1;
+ }
+
+ ast_db_put(astdb_family, data, (char *) value);
+
+ ast_device_state_changed("Custom:%s", data);
+
+ return 0;
+}
+
+static int custom_devstate_callback(const char *data)
+{
+ char buf[256] = "";
+
+ ast_db_get(astdb_family, data, buf, sizeof(buf));
+
+ return ast_devstate_val(buf);
+}
+
+static int cli_funcdevstate_list(int fd, int argc, char *argv[])
+{
+ struct ast_db_entry *db_entry, *db_tree;
+
+ if (argc != 2)
+ return RESULT_SHOWUSAGE;
+
+ ast_cli(fd, "\n"
+ "---------------------------------------------------------------------\n"
+ "--- Custom Device States --------------------------------------------\n"
+ "---------------------------------------------------------------------\n"
+ "---\n");
+
+ db_entry = db_tree = ast_db_gettree(astdb_family, NULL);
+ for (; db_entry; db_entry = db_entry->next) {
+ const char *dev_name = strrchr(db_entry->key, '/') + 1;
+ if (dev_name <= (const char *) 1)
+ continue;
+ ast_cli(fd, "--- name: 'custom:%s' state: '%s'\n"
+ "---\n", dev_name, db_entry->data);
+ }
+ ast_db_freetree(db_tree);
+ db_tree = NULL;
+
+ ast_cli(fd,
+ "---------------------------------------------------------------------\n"
+ "---------------------------------------------------------------------\n"
+ "\n");
+
+ return RESULT_SUCCESS;
+}
+
+static struct ast_cli_entry cli_funcdevstate[] = {
+ { { "funcdevstate", "list", }, cli_funcdevstate_list, NULL, NULL },
+};
+
+static struct ast_custom_function devstate_function = {
+ .name = "DEVSTATE",
+ .synopsis = "Get or Set a device state",
+ .syntax = "DEVSTATE(device)",
+ .desc =
+ " The DEVSTATE function can be used to retrieve the device state from any\n"
+ "device state provider. For example:\n"
+ " NoOp(SIP/mypeer has state ${DEVSTATE(SIP/mypeer)})\n"
+ " NoOp(Conference number 1234 has state ${DEVSTATE(MeetMe:1234)})\n"
+ "\n"
+ " The DEVSTATE function can also be used to set custom device state from\n"
+ "the dialplan. The \"Custom:\" prefix must be used. For example:\n"
+ " Set(DEVSTATE(Custom:lamp1)=BUSY)\n"
+ " Set(DEVSTATE(Custom:lamp2)=NOT_INUSE)\n"
+ "You can subscribe to the status of a custom device state using a hint in\n"
+ "the dialplan:\n"
+ " exten => 1234,hint,Custom:lamp1\n"
+ "\n"
+ " The possible values for both uses of this function are:\n"
+ "UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING\n"
+ "RINGINUSE | ONHOLD\n",
+ .read = devstate_read,
+ .write = devstate_write,
+};
+
+static int unload_module(void)
+{
+ int res = 0;
+
+ res |= ast_custom_function_unregister(&devstate_function);
+ ast_devstate_prov_del("Custom");
+ ast_cli_unregister_multiple(cli_funcdevstate, ARRAY_LEN(cli_funcdevstate));
+
+ return res;
+}
+
+static int load_module(void)
+{
+ int res = 0;
+
+ res |= ast_custom_function_register(&devstate_function);
+ res |= ast_devstate_prov_add("Custom", custom_devstate_callback);
+ ast_cli_register_multiple(cli_funcdevstate, ARRAY_LEN(cli_funcdevstate));
+
+ return res;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Gets or sets a device state in the dialplan");
diff --git a/net-misc/asterisk/files/1.4.0/func_volume.c b/net-misc/asterisk/files/1.4.0/func_volume.c
new file mode 100644
index 000000000000..4591e62f24e5
--- /dev/null
+++ b/net-misc/asterisk/files/1.4.0/func_volume.c
@@ -0,0 +1,160 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007, Digium, Inc.
+ *
+ * Joshua Colp <jcolp@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Technology independent volume control
+ *
+ * \author Joshua Colp <jcolp@digium.com>
+ *
+ * \ingroup functions
+ *
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.1 $")
+
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/utils.h"
+#include "asterisk/audiohook.h"
+
+struct volume_information {
+ struct ast_audiohook audiohook;
+ int tx_gain;
+ int rx_gain;
+};
+
+static void destroy_callback(void *data)
+{
+ struct volume_information *vi = data;
+
+ /* Destroy the audiohook, and destroy ourselves */
+ ast_audiohook_destroy(&vi->audiohook);
+ free(vi);
+
+ return;
+}
+
+/*! \brief Static structure for datastore information */
+static const struct ast_datastore_info volume_datastore = {
+ .type = "volume",
+ .destroy = destroy_callback
+};
+
+static int volume_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
+{
+ struct ast_datastore *datastore = NULL;
+ struct volume_information *vi = NULL;
+ int *gain = NULL;
+
+ /* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
+ if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE)
+ return 0;
+
+ /* Grab datastore which contains our gain information */
+ if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL)))
+ return 0;
+
+ vi = datastore->data;
+
+ /* If this is DTMF then allow them to increase/decrease the gains */
+ if (frame->frametype == AST_FRAME_DTMF) {
+ /* Only use DTMF coming from the source... not going to it */
+ if (direction != AST_AUDIOHOOK_DIRECTION_READ)
+ return 0;
+ if (frame->subclass == '*') {
+ vi->tx_gain += 1;
+ vi->rx_gain += 1;
+ } else if (frame->subclass == '#') {
+ vi->tx_gain -= 1;
+ vi->rx_gain -= 1;
+ }
+ } else if (frame->frametype == AST_FRAME_VOICE) {
+ /* Based on direction of frame grab the gain, and confirm it is applicable */
+ if (!(gain = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? &vi->rx_gain : &vi->tx_gain) || !*gain)
+ return 0;
+ /* Apply gain to frame... easy as pi */
+ ast_frame_adjust_volume(frame, *gain);
+ }
+
+ return 0;
+}
+
+static int volume_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
+{
+ struct ast_datastore *datastore = NULL;
+ struct volume_information *vi = NULL;
+ int is_new = 0;
+
+ if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL))) {
+ /* Allocate a new datastore to hold the reference to this volume and audiohook information */
+ if (!(datastore = ast_channel_datastore_alloc(&volume_datastore, NULL)))
+ return 0;
+ if (!(vi = ast_calloc(1, sizeof(*vi)))) {
+ ast_channel_datastore_free(datastore);
+ return 0;
+ }
+ ast_audiohook_init(&vi->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "Volume");
+ vi->audiohook.manipulate_callback = volume_callback;
+ ast_set_flag(&vi->audiohook, AST_AUDIOHOOK_WANTS_DTMF);
+ is_new = 1;
+ } else {
+ vi = datastore->data;
+ }
+
+ /* Adjust gain on volume information structure */
+ if (!strcasecmp(data, "tx"))
+ vi->tx_gain = atoi(value);
+ else if (!strcasecmp(data, "rx"))
+ vi->rx_gain = atoi(value);
+
+ if (is_new) {
+ datastore->data = vi;
+ ast_channel_datastore_add(chan, datastore);
+ ast_audiohook_attach(chan, &vi->audiohook);
+ }
+
+ return 0;
+}
+
+static struct ast_custom_function volume_function = {
+ .name = "VOLUME",
+ .synopsis = "Set the TX or RX volume of a channel",
+ .syntax = "VOLUME(TX|RX)",
+ .desc =
+ " The VOLUME function can be used to increase or decrease the tx or\n"
+ "rx gain of any channel. For example:\n"
+ " Set(VOLUME(TX)=3)\n"
+ " Set(VOLUME(RX)=2)\n",
+ .write = volume_write,
+};
+
+static int unload_module(void)
+{
+ return ast_custom_function_unregister(&volume_function);
+}
+
+static int load_module(void)
+{
+ return ast_custom_function_register(&volume_function);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Technology independent volume control");