summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Vroon <chainsaw@gentoo.org>2010-02-10 22:25:30 +0000
committerTony Vroon <chainsaw@gentoo.org>2010-02-10 22:25:30 +0000
commitf5753ec7cad4ef603727b21d737b6a6f083dcfb3 (patch)
tree243e0afb32e0b8044c14ee2580a524181a02d380 /net-misc
parentFix poppler depend. (diff)
downloadhistorical-f5753ec7cad4ef603727b21d737b6a6f083dcfb3.tar.gz
historical-f5753ec7cad4ef603727b21d737b6a6f083dcfb3.tar.bz2
historical-f5753ec7cad4ef603727b21d737b6a6f083dcfb3.zip
Add nv_faxdetect as scavenged by Cory Coager in bug #298328. Trim unnecessary parts from parallel make patch, upstream bug #16489. Stop segfaulting on a graceful restart, upstream bugs #16062 & #16470.
Package-Manager: portage-2.2_rc62/cvs/Linux x86_64
Diffstat (limited to 'net-misc')
-rw-r--r--net-misc/asterisk/ChangeLog12
-rw-r--r--net-misc/asterisk/Manifest12
-rw-r--r--net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild370
-rw-r--r--net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch75
-rw-r--r--net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch650
-rw-r--r--net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch21
6 files changed, 1135 insertions, 5 deletions
diff --git a/net-misc/asterisk/ChangeLog b/net-misc/asterisk/ChangeLog
index 364d0cf1167c..9dfc860d5a2a 100644
--- a/net-misc/asterisk/ChangeLog
+++ b/net-misc/asterisk/ChangeLog
@@ -1,6 +1,16 @@
# 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.246 2010/02/02 22:54:51 chainsaw Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.247 2010/02/10 22:25:29 chainsaw Exp $
+
+*asterisk-1.6.2.2-r1 (10 Feb 2010)
+
+ 10 Feb 2010; <chainsaw@gentoo.org> +asterisk-1.6.2.2-r1.ebuild,
+ +files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch,
+ +files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch,
+ +files/1.6.2/asterisk-1.6.2.2-parallel-make.patch:
+ Add nv_faxdetect as scavenged by Cory Coager in bug #298328. Trim
+ unnecessary parts from parallel make patch, upstream bug #16489. Stop
+ segfaulting on a graceful restart, upstream bugs #16062 & #16470.
*asterisk-1.6.1.14 (02 Feb 2010)
diff --git a/net-misc/asterisk/Manifest b/net-misc/asterisk/Manifest
index 525f6a662ca4..273de70a530c 100644
--- a/net-misc/asterisk/Manifest
+++ b/net-misc/asterisk/Manifest
@@ -28,6 +28,9 @@ AUX 1.6.1/asterisk.initd3 6534 RMD160 5d116a92346cc8da603d233d81da302647e8ecd2 S
AUX 1.6.1/asterisk.rc6 5896 RMD160 da94968d2dd315977a1ddfbac020ebe0ea2fbfeb SHA1 d65dd46e052066ea02bd613c8068b3a471ace157 SHA256 511da355d94afc6e81504f2f1a95f4c30346920d582ea9b00e27df8866c16515
AUX 1.6.2/asterisk-1.6.2.0-bt-line-test.patch 1754 RMD160 c63c9631da619932700c1a93b923fd88c5e9f6f1 SHA1 72bfa40709bc1e47370df228ab96c1a0c316190f SHA256 7ef5d976f41d26e6752bc3474be368ca7c67c601e581ad31bf50fc5cb066a21d
AUX 1.6.2/asterisk-1.6.2.1-parallel-make.patch 3797 RMD160 bb13234b020daa96a3b32baf38ebaa4bddd7f468 SHA1 561cfc994d36f346eee238ae4b2f8ebec6ae47bb SHA256 390f40a34f2c8deb0efbc7f84c4a52018f9ebdc6d431f2cf309d07d767c64506
+AUX 1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch 2723 RMD160 4589e724beebd959b7bc296526b8cf291c25aa4b SHA1 95c2eb7136a42690f3cf25405ad4ad2e36e2e533 SHA256 6f09cac44946a20e301f972e2c9f57fc3cba6324e0502fb0d7b1b9c3970f17cf
+AUX 1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch 21042 RMD160 fa31dbfa3828f60073d59d0262166436ef37c516 SHA1 50f6b7a917dac981df1adf0713b373410af4ec68 SHA256 9919af0de073fc6c68a926daf84164df3b506d8fe4687177e8f9d636111707af
+AUX 1.6.2/asterisk-1.6.2.2-parallel-make.patch 842 RMD160 e62c458de2508c8698502936f25605a51b3e93af SHA1 d780c5322c388fbc2742766b741f269ab6083d71 SHA256 8bf747832b7e090b31fdcb4de563e8529ad697af10e97e3a14378bbcad3b99d9
DIST asterisk-1.2.27-patches-1.0.tar.bz2 6653 RMD160 18f1d7fc4497466050ed4f517ff5732eb448ff2e SHA1 2aecd3e91cde38dbb0fd591e8a49db221f44b94e SHA256 a4da0570fca2df3c508f072be62722879956fe8c454027fbb8dafb7a6095384c
DIST asterisk-1.2.36.tar.gz 29897926 RMD160 47b8c0e58c43cac6aa415482182aea15b1489ccc SHA1 b6f60404ba0ca802cfa5cd43685a36b467441c5c SHA256 69f48a0e49f3a37196b65f11e8babf5c28e33700903b9f304e984def6c35dbf0
DIST asterisk-1.2.37.tar.gz 29899629 RMD160 1de7ff96d3b1fd8d89f3ef7b3bb9e35bedccfb33 SHA1 c9a3c4684e021f62b4d19f6e0c8fc11f64db19d6 SHA256 9f3ec67efe0e4d45434621cd358e8e7d64e1b05df04d66e2390c9420acd2aeaa
@@ -36,13 +39,14 @@ DIST asterisk-1.6.2.2.tar.gz 23177043 RMD160 fdba60d04307a503d9bf06583bf919d9f83
EBUILD asterisk-1.2.36.ebuild 10640 RMD160 de9118d48d7122200847783aec84e89724f33475 SHA1 8839099437bb0fa20ab7ba4c4aabeef33be353d5 SHA256 73421c18cf2aec1412ef1f86cb6a810765cf7c78fdb056b2e84224430368a1ca
EBUILD asterisk-1.2.37.ebuild 10640 RMD160 82f1d14082b607402146bd8f7950ea32ee2558f3 SHA1 5718e0411fff8bc14c4c57562a9df281c33abdc5 SHA256 2f2290922b09f9b71b06cb73e99fc7916b4a994960375e0e48b6bb39fd802e0c
EBUILD asterisk-1.6.1.14.ebuild 10778 RMD160 aae51df5ce123858674f587751a70b06d2386954 SHA1 c246fb8e8071f8fb6ed02d21c017c29500b3b890 SHA256 87a01836c6a816c5e62642c8f15ed2e865acae7bfa54a7a3f162677c16bc80ec
+EBUILD asterisk-1.6.2.2-r1.ebuild 9935 RMD160 d520da827decd03deecabdb5197409ea979ac08e SHA1 87c9184d9900e0bcb69addff013d031a4458d8f8 SHA256 cb3ce8009550f1f3840c72816f8740f2baadabd11682f208a8662824860ac11a
EBUILD asterisk-1.6.2.2.ebuild 9506 RMD160 a098a36262c8a265d74d5caf4af58ac738f616b9 SHA1 992368e60ac361834ac26f1e0ded664e353c1df3 SHA256 4745de18196315062b97b30eaca3845f3890d8c15fc7e6c8dfb4e945f497fd00
-MISC ChangeLog 54294 RMD160 2c3f4e9fd441d6f72a6eb3c32fdf13a61886dfef SHA1 09fccd914fda88037c8fd32621519401ea228e5b SHA256 216c4f2bf7d4ea50c0e896a01067a00b82bd9c2208d1aca6c1bb717b0dc62e86
+MISC ChangeLog 54775 RMD160 96694979b0617ce30152672f99d7e540a109952d SHA1 f4daf242ae5f655bb675600a00b368104ee831c9 SHA256 5b614cb18d24b84723eaa4635a57a2e47472c6a8a2bf07c106f471801e179dec
MISC metadata.xml 1103 RMD160 9be6c713684efa268e58cfc111fae4716e97f9dd SHA1 5af1f100c97f1bca1834867e06c3fb9111ed1fde SHA256 a83ca9d4cfd8da10b8dbb9583e1b6fa5fc0f30968a0681e4bc931673a00e1c99
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
-iEYEARECAAYFAktora4ACgkQp5vW4rUFj5qFrgCgpkWfuPOm19gqE9mDbA26m1CC
-3n4AoK4z+g8yiCR5/SSOA7fGOFkI3z/a
-=wDsO
+iEYEARECAAYFAktzMuYACgkQp5vW4rUFj5qitwCfYa/u7Yo53hT8cInDH3AF5kAg
+K8EAmQFM1GaRDSY7IDN6q0wq28yi0Tij
+=Fb+T
-----END PGP SIGNATURE-----
diff --git a/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild b/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild
new file mode 100644
index 000000000000..4deff5cd0b1a
--- /dev/null
+++ b/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild
@@ -0,0 +1,370 @@
+# 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.6.2.2-r1.ebuild,v 1.1 2010/02/10 22:25:29 chainsaw Exp $
+
+EAPI=1
+inherit eutils autotools linux-info
+
+MY_P="${PN}-${PV/_/-}"
+
+DESCRIPTION="Asterisk: A Modular Open Source PBX System"
+HOMEPAGE="http://www.asterisk.org/"
+SRC_URI="http://downloads.digium.com/pub/asterisk/releases/${MY_P}.tar.gz"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+IUSE="alsa +caps curl dahdi debug freetds iconv jabber ldap keepsrc misdn newt nosamples oss postgres radius snmp span speex ssl sqlite static vorbis"
+
+RDEPEND="sys-libs/ncurses
+ dev-libs/popt
+ sys-libs/zlib
+ alsa? ( media-libs/alsa-lib )
+ caps? ( sys-libs/libcap )
+ curl? ( net-misc/curl )
+ dahdi? ( >=net-libs/libpri-1.4.7
+ net-misc/dahdi-tools )
+ freetds? ( dev-db/freetds )
+ iconv? ( virtual/libiconv )
+ jabber? ( dev-libs/iksemel )
+ ldap? ( net-nds/openldap )
+ misdn? ( net-dialup/misdnuser )
+ newt? ( dev-libs/newt )
+ postgres? ( virtual/postgresql-base )
+ radius? ( net-dialup/radiusclient-ng )
+ snmp? ( net-analyzer/net-snmp )
+ span? ( media-libs/spandsp )
+ speex? ( media-libs/speex )
+ sqlite? ( dev-db/sqlite )
+ ssl? ( dev-libs/openssl )
+ vorbis? ( media-libs/libvorbis )"
+
+DEPEND="${RDEPEND}
+ !<net-misc/asterisk-addons-1.6
+ !net-misc/asterisk-chan_unistim
+ !net-misc/zaptel"
+
+S="${WORKDIR}/${MY_P}"
+
+get_available_modules() {
+ local modules mod x
+
+ # build list of available modules...
+ for x in app cdr codec format func pbx res; do
+
+ for mod in $(find "${S}" -type f -name "${x}_*.c*" -print)
+ do
+ modules="${modules} $(basename ${mod/%.c*})"
+ done
+ done
+
+ echo "${modules}"
+}
+
+pkg_setup() {
+ if [[ -n "${ASTERISK_MODULES}" ]] ; then
+ ewarn "You are overriding ASTERISK_MODULES. We will assume you know what you are doing. There is no support for this option, try without if you see breakage."
+ fi
+ CONFIG_CHECK="~!NF_CONNTRACK_SIP"
+ local WARNING_NF_CONNTRACK_SIP="SIP (NAT) connection tracking is a module written for a single SIP client talking to a
+ remote server. It is not able to track multiple remote SIP clients registering with
+ a local server. Critical SIP packets may be dropped."
+ check_extra_config
+}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ #
+ # fix gsm codec cflags (e.g. i586 core epias) and disable
+ # assembler optimizations
+ #
+ epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-gsm-pic.patch || die "patch failed"
+
+ #
+ # add missing LIBS for uclibc
+ #
+ epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-uclibc.patch || die "patch failed"
+
+ #
+ # make sure FXO ports are usable immediately, without requiring an inbound call first
+ # https://issues.asterisk.org/view.php?id=14577
+ #
+ epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1.6-fxsks-hookstate.patch || die "patch failed"
+
+ #
+ # do not ignore alarm-cleared event while V23 caller ID detection is in progress
+ # otherwise automated British Telecom line test causes permanent red alarm
+ # https://issues.asterisk.org/view.php?id=14163
+ #
+ epatch "${FILESDIR}"/1.6.2/${PN}-1.6.2.0-bt-line-test.patch || die "patch failed"
+
+ #
+ # sprinkle some plus signs in strategic locations for maximum parallel make happiness
+ # https://issues.asterisk.org/view.php?id=16489
+ #
+ epatch "${FILESDIR}"/1.6.2/${P}-parallel-make.patch || die "patch failed"
+
+ #
+ # do not segfault when asked to restart gracefully
+ # https://issues.asterisk.org/view.php?id=16062
+ # https://issues.asterisk.org/view.php?id=16470
+ #
+ epatch "${FILESDIR}"/1.6.2/${P}-graceful-restart-segfault.patch
+
+ #
+ # add special playback with fax detection
+ # Code by NewMan telecom, patch scavenged
+ # by Cory Coager
+ # http://bugs.gentoo.org/show_bug.cgi?id=298328
+ #
+ epatch "${FILESDIR}"/1.6.2/${P}-nv-faxdetect.patch
+
+ AT_M4DIR=autoconf eautoreconf
+
+ # parse modules list
+ if [[ -n "${ASTERISK_MODULES}" ]]; then
+ local x modules="$(get_available_modules)"
+
+ einfo "Custom list of modules specified, checking..."
+
+ use debug && {
+ einfo "Available modules: ${modules}"
+ einfo " Selected modules: ${ASTERISK_MODULES}"
+ }
+
+ for x in ${ASTERISK_MODULES}; do
+ if [[ "${x}" = "-*" ]]; then
+ MODULES_LIST=""
+ else
+ if has ${x} ${modules}
+ then
+ MODULES_LIST="${MODULES_LIST} ${x}"
+ else
+ eerror "Unknown module: ${x}"
+ fi
+ fi
+ done
+
+ export MODULES_LIST
+ fi
+}
+
+src_compile() {
+ #
+ # start with configure
+ #
+ econf \
+ --libdir="/usr/$(get_libdir)" \
+ --localstatedir="/var" \
+ --with-gsm=internal \
+ --with-popt \
+ --with-z \
+ $(use_with alsa asound) \
+ $(use_with caps cap) \
+ $(use_with curl) \
+ $(use_with dahdi pri) \
+ $(use_with dahdi tonezone) \
+ $(use_with dahdi) \
+ $(use_with freetds tds) \
+ $(use_with iconv) \
+ $(use_with jabber iksemel) \
+ $(use_with misdn isdnnet) \
+ $(use_with misdn suppserv) \
+ $(use_with misdn) \
+ $(use_with newt) \
+ $(use_with oss) \
+ $(use_with postgres) \
+ $(use_with radius) \
+ $(use_with snmp netsnmp) \
+ $(use_with span spandsp) \
+ $(use_with speex) \
+ $(use_with speex speexdsp) \
+ $(use_with sqlite sqlite3) \
+ $(use_with ssl crypto) \
+ $(use_with ssl) \
+ $(use_with vorbis ogg) \
+ $(use_with vorbis) || die "econf failed"
+
+ #
+ # custom module filter
+ # run menuselect to evaluate the list of modules
+ # and rewrite the list afterwards
+ #
+ if [[ -n "${MODULES_LIST}" ]]
+ then
+ local mod category tmp_list failed_list
+
+ ###
+ # run menuselect
+
+ emake menuselect.makeopts || die "emake menuselect.makeopts failed"
+
+ ###
+ # get list of modules with failed dependencies
+
+ failed_list="$(awk -F= '/^MENUSELECT_DEPSFAILED=/{ print $3 }' menuselect.makeopts)"
+
+ ###
+ # traverse our list of modules
+
+ for category in app cdr codec format func pbx res; do
+ tmp_list=""
+
+ # search list of modules for matching ones first...
+ for mod in ${MODULES_LIST}; do
+ # module is from current category?
+ if [[ "${mod/%_*}" = "${category}" ]]
+ then
+ # check menuselect thinks the dependencies are met
+ if has ${mod} ${failed_list}
+ then
+ eerror "${mod}: dependencies required to build this module are not met, NOT BUILDING!"
+ else
+ tmp_list="${tmp_list} ${mod}"
+ fi
+ fi
+ done
+
+ use debug && echo "${category} tmp: ${tmp_list}"
+
+ # replace the module list for $category with our custom one
+ if [[ -n "${tmp_list}" ]]
+ then
+ category="$(echo ${category} | tr '[:lower:]' '[:upper:]')"
+ sed -i -e "s:^\(MENUSELECT_${category}S?\):\1=${tmp_list}:" \
+ menuselect.makeopts || die "failed to set list of ${category} applications"
+ fi
+ done
+ fi
+
+ ASTLDFLAGS="${LDFLAGS}" emake || die "emake failed"
+}
+
+src_install() {
+ # setup directory structure
+ #
+ mkdir -p "${D}"usr/lib/pkgconfig
+
+ emake DESTDIR="${D}" install || die "emake install failed"
+ emake DESTDIR="${D}" samples || die "emake samples failed"
+
+ # remove installed sample files if nosamples flag is set
+ if use nosamples; then
+ 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/*
+ else
+ einfo "Sample files have been installed"
+ fi
+ rm -rf "${D}"var/spool/asterisk/voicemail/default
+
+ einfo "Configuration samples have been moved to: "${ROOT}"/usr/share/doc/${PF}/conf"
+ insinto /usr/share/doc/${PF}/conf
+ doins "${D}"etc/asterisk/*.conf*
+
+ cd "${D}"
+ for conffile in etc/asterisk/*.*
+ do
+ fowners asterisk:asterisk $conffile
+ fperms 0660 $conffile
+ done
+ cd "${S}"
+
+ # 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.6.1/asterisk.initd3 asterisk
+ newconfd "${FILESDIR}"/1.6.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 snmp mib files
+ #
+ if use snmp
+ then
+ insinto /usr/share/snmp/mibs/
+ doins doc/digium-mib.txt doc/asterisk-mib.txt
+ fi
+}
+
+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
+ elog "1.6.1 -> 1.6.2 changes that you may care about:"
+ elog "canreinvite -> directmedia (sip.conf)"
+ elog "extensive T.38 (fax) changes"
+ elog "http://svn.asterisk.org/svn/${PN}/tags/${PV}/UPGRADE.txt"
+ elog "or: bzless ${ROOT}usr/share/doc/${PF}/UPGRADE.txt.bz2"
+}
+
+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.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch
new file mode 100644
index 000000000000..2962cc6a023f
--- /dev/null
+++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch
@@ -0,0 +1,75 @@
+diff -uNr asterisk-1.6.2.2.ORIG/main/event.c asterisk-1.6.2.2/main/event.c
+--- asterisk-1.6.2.2.ORIG/main/event.c 2010-02-10 21:05:55.278139356 +0000
++++ asterisk-1.6.2.2/main/event.c 2010-02-10 21:06:58.008198202 +0000
+@@ -841,6 +841,11 @@
+ struct ast_event_iterator iterator;
+ int res = 0;
+
++ /* Event has no IEs allocated */
++ if (event->event_len < sizeof(*event) + sizeof(ie_type)) {
++ return NULL;
++ }
++
+ for (ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
+ if (ast_event_iterator_get_ie_type(&iterator) == ie_type)
+ return ast_event_iterator_get_ie_raw(&iterator);
+diff -uNr asterisk-1.6.2.2.ORIG/main/loader.c asterisk-1.6.2.2/main/loader.c
+--- asterisk-1.6.2.2.ORIG/main/loader.c 2010-02-10 21:05:55.273223462 +0000
++++ asterisk-1.6.2.2/main/loader.c 2010-02-10 21:06:58.006203410 +0000
+@@ -444,26 +444,39 @@
+ void ast_module_shutdown(void)
+ {
+ struct ast_module *mod;
+- AST_LIST_HEAD_NOLOCK_STATIC(local_module_list, ast_module);
+-
+- /* We have to call the unload() callbacks in reverse order that the modules
+- * exist in the module list so it is the reverse order of how they were
+- * loaded. */
++ int somethingchanged = 1, final = 0;
+
+ AST_LIST_LOCK(&module_list);
+- while ((mod = AST_LIST_REMOVE_HEAD(&module_list, entry)))
+- AST_LIST_INSERT_HEAD(&local_module_list, mod, entry);
+- AST_LIST_UNLOCK(&module_list);
+
+- while ((mod = AST_LIST_REMOVE_HEAD(&local_module_list, entry))) {
+- if (mod->info->unload)
+- mod->info->unload();
+- /* Since this should only be called when shutting down "gracefully",
+- * all channels should be down before we get to this point, meaning
+- * there will be no module users left. */
+- AST_LIST_HEAD_DESTROY(&mod->users);
+- free(mod);
+- }
++ /*!\note Some resources, like timers, are started up dynamically, and thus
++ * may be still in use, even if all channels are dead. We must therefore
++ * check the usecount before asking modules to unload. */
++ do {
++ if (!somethingchanged) {
++ /*!\note If we go through the entire list without changing
++ * anything, ignore the usecounts and unload, then exit. */
++ final = 1;
++ }
++
++ /* Reset flag before traversing the list */
++ somethingchanged = 0;
++
++ AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, mod, entry) {
++ if (!final && mod->usecount) {
++ continue;
++ }
++ AST_LIST_REMOVE_CURRENT(entry);
++ if (mod->info->unload) {
++ mod->info->unload();
++ }
++ AST_LIST_HEAD_DESTROY(&mod->users);
++ free(mod);
++ somethingchanged = 1;
++ }
++ AST_LIST_TRAVERSE_SAFE_END;
++ } while (somethingchanged && !final);
++
++ AST_LIST_UNLOCK(&module_list);
+ }
+
+ int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode force)
diff --git a/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch
new file mode 100644
index 000000000000..ee2ef4408cf6
--- /dev/null
+++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch
@@ -0,0 +1,650 @@
+diff -uNr apps/app_nv_backgrounddetect.c apps/app_nv_backgrounddetect.c
+--- apps/app_nv_backgrounddetect.c 1970-01-01 01:00:00.000000000 +0100
++++ apps/app_nv_backgrounddetect.c 2010-02-10 22:09:40.118390386 +0000
+@@ -0,0 +1,325 @@
++/*
++ * Asterisk -- A telephony toolkit for Linux.
++ *
++ * Playback a file with audio detect
++ *
++ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc.
++ *
++ * Justin Newman <jnewman@newmantelecom.com>
++ *
++ * We would like to thank Newman Ventures, Inc. for funding this
++ * Asterisk project.
++ *
++ * Newman Ventures <info@newmanventures.com>
++ *
++ * Portions Copyright:
++ * Copyright (C) 2001, Linux Support Services, Inc.
++ * Copyright (C) 2004, Digium, Inc.
++ *
++ * Matthew Fredrickson <creslin@linux-support.net>
++ * Mark Spencer <markster@digium.com>
++ *
++ * This program is free software, distributed under the terms of
++ * the GNU General Public License
++ */
++
++#include "asterisk.h"
++
++#include <asterisk/lock.h>
++#include <asterisk/file.h>
++#include <asterisk/logger.h>
++#include <asterisk/channel.h>
++#include <asterisk/pbx.h>
++#include <asterisk/module.h>
++#include <asterisk/translate.h>
++#include <asterisk/utils.h>
++#include <asterisk/dsp.h>
++
++static char *app = "NVBackgroundDetect";
++
++static char *synopsis = "Background a file with talk and fax detect (IAX and SIP too)";
++
++static char *descrip =
++" NVBackgroundDetect(filename[|options[|sildur[|mindur|[maxdur]]]]):\n"
++"Plays filename, waiting for interruption from fax tones (on IAX and SIP too),\n"
++"a digit, or non-silence. Audio is monitored in the receive direction. If\n"
++"digits interrupt, they must be the start of a valid extension unless the\n"
++"option is included to ignore. If fax is detected, it will jump to the\n"
++"'fax' extension. If a period of non-silence is greater than 'mindur' ms,\n"
++"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n"
++"then the app is aborted and processing jumps to the 'talk' extension.\n"
++"If all undetected, control will continue at the next priority.\n"
++" options:\n"
++" 'n': Attempt on-hook if unanswered (default=no)\n"
++" 'x': DTMF digits terminate without extension (default=no)\n"
++" 'd': Ignore DTMF digit detection (default=no)\n"
++" 'f': Ignore fax detection (default=no)\n"
++" 't': Ignore talk detection (default=no)\n"
++" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n"
++" mindur: Minimum non-silence ms needed (default=100)\n"
++" maxdur: Maximum non-silence ms allowed (default=0/forever)\n"
++"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n"
++"For questions or comments, please e-mail support@newmantelecom.com.\n";
++
++// Use the second one for recent Asterisk releases
++#define CALLERID_FIELD cid.cid_num
++//#define CALLERID_FIELD callerid
++
++static int nv_background_detect_exec(struct ast_channel *chan, void *data)
++{
++ int res = 0;
++ char tmp[256] = "\0";
++ char *p = NULL;
++ char *filename = NULL;
++ char *options = NULL;
++ char *silstr = NULL;
++ char *minstr = NULL;
++ char *maxstr = NULL;
++ struct ast_frame *fr = NULL;
++ struct ast_frame *fr2 = NULL;
++ int notsilent = 0;
++ struct timeval start = {0, 0}, end = {0, 0};
++ int sildur = 1000;
++ int mindur = 100;
++ int maxdur = -1;
++ int skipanswer = 0;
++ int noextneeded = 0;
++ int ignoredtmf = 0;
++ int ignorefax = 0;
++ int ignoretalk = 0;
++ int x = 0;
++ int origrformat = 0;
++ int features = 0;
++ struct ast_dsp *dsp = NULL;
++
++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "");
++ pbx_builtin_setvar_helper(chan, "FAXEXTEN", "");
++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "");
++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", "");
++
++ if (!data || ast_strlen_zero((char *)data)) {
++ ast_log(LOG_WARNING, "NVBackgroundDetect requires an argument (filename)\n");
++ return -1;
++ }
++
++ strncpy(tmp, (char *)data, sizeof(tmp)-1);
++ p = tmp;
++
++ filename = strsep(&p, "|");
++ options = strsep(&p, "|");
++ silstr = strsep(&p, "|");
++ minstr = strsep(&p, "|");
++ maxstr = strsep(&p, "|");
++
++ if (options) {
++ if (strchr(options, 'n'))
++ skipanswer = 1;
++ if (strchr(options, 'x'))
++ noextneeded = 1;
++ if (strchr(options, 'd'))
++ ignoredtmf = 1;
++ if (strchr(options, 'f'))
++ ignorefax = 1;
++ if (strchr(options, 't'))
++ ignoretalk = 1;
++ }
++
++ if (silstr) {
++ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0))
++ sildur = x;
++ }
++
++ if (minstr) {
++ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0))
++ mindur = x;
++ }
++
++ if (maxstr) {
++ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0))
++ maxdur = x;
++ }
++
++ ast_log(LOG_DEBUG, "Preparing detect of '%s' (sildur=%dms, mindur=%dms, maxdur=%dms)\n",
++ tmp, sildur, mindur, maxdur);
++
++ // LOCAL_USER_ADD(u);
++ if (chan->_state != AST_STATE_UP && !skipanswer) {
++ /* Otherwise answer unless we're supposed to send this while on-hook */
++ res = ast_answer(chan);
++ }
++ if (!res) {
++ origrformat = chan->readformat;
++ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)))
++ ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
++ }
++ if (!(dsp = ast_dsp_new())) {
++ ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
++ res = -1;
++ }
++
++ if (dsp) {
++ if (!ignoretalk)
++ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */
++ if (!ignorefax)
++ features |= DSP_FEATURE_FAX_DETECT;
++ //if (!ignoredtmf)
++ features |= DSP_FEATURE_DIGIT_DETECT;
++
++ ast_dsp_set_threshold(dsp, 256);
++ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF);
++ ast_dsp_set_digitmode(dsp, DSP_DIGITMODE_DTMF);
++ }
++
++ if (!res) {
++ ast_stopstream(chan);
++ res = ast_streamfile(chan, tmp, chan->language);
++ if (!res) {
++ while(chan->stream) {
++ res = ast_sched_wait(chan->sched);
++ if ((res < 0) && !chan->timingfunc) {
++ res = 0;
++ break;
++ }
++ if (res < 0)
++ res = 1000;
++ res = ast_waitfor(chan, res);
++ if (res < 0) {
++ ast_log(LOG_WARNING, "Waitfor failed on %s\n", chan->name);
++ break;
++ } else if (res > 0) {
++ fr = ast_read(chan);
++ if (!fr) {
++ ast_log(LOG_DEBUG, "Got hangup\n");
++ res = -1;
++ break;
++ }
++
++ fr2 = ast_dsp_process(chan, dsp, fr);
++ if (!fr2) {
++ ast_log(LOG_WARNING, "Bad DSP received (what happened!!)\n");
++ fr2 = fr;
++ }
++
++ if (fr2->frametype == AST_FRAME_DTMF) {
++ if (fr2->subclass == 'f' && !ignorefax) {
++ /* Fax tone -- Handle and return NULL */
++ ast_log(LOG_DEBUG, "Fax detected on %s\n", chan->name);
++ if (strcmp(chan->exten, "fax")) {
++ ast_log(LOG_NOTICE, "Redirecting %s to fax extension\n", chan->name);
++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "1");
++ pbx_builtin_setvar_helper(chan,"FAXEXTEN",chan->exten);
++ if (ast_exists_extension(chan, chan->context, "fax", 1, chan->CALLERID_FIELD)) {
++ /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
++ strncpy(chan->exten, "fax", sizeof(chan->exten)-1);
++ chan->priority = 0;
++ } else
++ ast_log(LOG_WARNING, "Fax detected, but no fax extension\n");
++ } else
++ ast_log(LOG_WARNING, "Already in a fax extension, not redirecting\n");
++
++ res = 0;
++ ast_frfree(fr);
++ break;
++ } else if (!ignoredtmf) {
++ ast_log(LOG_DEBUG, "DTMF detected on %s\n", chan->name);
++ char t[2];
++ t[0] = fr2->subclass;
++ t[1] = '\0';
++ if (noextneeded || ast_canmatch_extension(chan, chan->context, t, 1, chan->CALLERID_FIELD)) {
++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "1");
++ /* They entered a valid extension, or might be anyhow */
++ if (noextneeded) {
++ ast_log(LOG_NOTICE, "DTMF received (not matching to exten)\n");
++ res = 0;
++ } else {
++ ast_log(LOG_NOTICE, "DTMF received (matching to exten)\n");
++ res = fr2->subclass;
++ }
++ ast_frfree(fr);
++ break;
++ } else
++ ast_log(LOG_DEBUG, "Valid extension requested and DTMF did not match\n");
++ }
++ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR) && !ignoretalk) {
++ int totalsilence;
++ int ms;
++ res = ast_dsp_silence(dsp, fr, &totalsilence);
++ if (res && (totalsilence > sildur)) {
++ /* We've been quiet a little while */
++ if (notsilent) {
++ /* We had heard some talking */
++ gettimeofday(&end, NULL);
++ ms = (end.tv_sec - start.tv_sec) * 1000;
++ ms += (end.tv_usec - start.tv_usec) / 1000;
++ ms -= sildur;
++ if (ms < 0)
++ ms = 0;
++ if ((ms > mindur) && ((maxdur < 0) || (ms < maxdur))) {
++ char ms_str[10];
++ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
++ ast_log(LOG_NOTICE, "Redirecting %s to talk extension\n", chan->name);
++
++ /* Save detected talk time (in milliseconds) */
++ sprintf(ms_str, "%d", ms);
++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str);
++
++ if (ast_exists_extension(chan, chan->context, "talk", 1, chan->CALLERID_FIELD)) {
++ strncpy(chan->exten, "talk", sizeof(chan->exten) - 1);
++ chan->priority = 0;
++ } else
++ ast_log(LOG_WARNING, "Talk detected, but no talk extension\n");
++ res = 0;
++ ast_frfree(fr);
++ break;
++ } else
++ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
++ notsilent = 0;
++ }
++ } else {
++ if (!notsilent) {
++ /* Heard some audio, mark the begining of the token */
++ gettimeofday(&start, NULL);
++ ast_log(LOG_DEBUG, "Start of voice token!\n");
++ notsilent = 1;
++ }
++ }
++ }
++ ast_frfree(fr);
++ }
++ ast_sched_runq(chan->sched);
++ }
++ ast_stopstream(chan);
++ } else {
++ ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
++ res = 0;
++ }
++ } else
++ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
++
++ if (res > -1) {
++ if (origrformat && ast_set_read_format(chan, origrformat)) {
++ ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n",
++ chan->name, ast_getformatname(origrformat));
++ }
++ }
++
++ if (dsp)
++ ast_dsp_free(dsp);
++
++ // LOCAL_USER_REMOVE(u);
++
++ return res;
++}
++
++static int unload_module(void)
++{
++ // STANDARD_HANGUP_LOCALUSERS;
++ return ast_unregister_application(app);
++}
++
++static int load_module(void)
++{
++ return ast_register_application(app, nv_background_detect_exec, synopsis, descrip);
++}
++
++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax playing Background Music Detection Application");
+diff -uNr apps/app_nv_faxdetect.c apps/app_nv_faxdetect.c
+--- apps/app_nv_faxdetect.c 1970-01-01 01:00:00.000000000 +0100
++++ apps/app_nv_faxdetect.c 2010-02-10 22:09:40.119390638 +0000
+@@ -0,0 +1,317 @@
++/*
++ * Asterisk -- A telephony toolkit for Linux.
++ *
++ * Fax detection application for all channel types.
++ *
++ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc.
++ *
++ * Justin Newman <jnewman@newmantelecom.com>
++ *
++ * We would like to thank Newman Ventures, Inc. for funding this
++ * Asterisk project.
++ *
++ * Newman Ventures <info@newmanventures.com>
++ *
++ * Portions Copyright:
++ * Copyright (C) 2001, Linux Support Services, Inc.
++ * Copyright (C) 2004, Digium, Inc.
++ *
++ * Matthew Fredrickson <creslin@linux-support.net>
++ * Mark Spencer <markster@digium.com>
++ *
++ * This program is free software, distributed under the terms of
++ * the GNU General Public License
++ */
++
++#include "asterisk.h"
++
++#include <asterisk/lock.h>
++#include <asterisk/file.h>
++#include <asterisk/logger.h>
++#include <asterisk/channel.h>
++#include <asterisk/pbx.h>
++#include <asterisk/module.h>
++#include <asterisk/translate.h>
++#include <asterisk/dsp.h>
++#include <asterisk/utils.h>
++
++static char *app = "NVFaxDetect";
++
++static char *synopsis = "Detects fax sounds on all channel types (IAX and SIP too)";
++
++static char *descrip =
++" NVFaxDetect([waitdur[|options[|sildur[|mindur[|maxdur]]]]]):\n"
++"This application listens for fax tones (on IAX and SIP channels too)\n"
++"for waitdur seconds of time. In addition, it can be interrupted by digits,\n"
++"or non-silence. Audio is only monitored in the receive direction. If\n"
++"digits interrupt, they must be the start of a valid extension unless the\n"
++"option is included to ignore. If fax is detected, it will jump to the\n"
++"'fax' extension. If a period of non-silence greater than 'mindur' ms,\n"
++"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n"
++"then the app is aborted and processing jumps to the 'talk' extension.\n"
++"If all undetected, control will continue at the next priority.\n"
++" waitdur: Maximum number of seconds to wait (default=4)\n"
++" options:\n"
++" 'n': Attempt on-hook if unanswered (default=no)\n"
++" 'x': DTMF digits terminate without extension (default=no)\n"
++" 'd': Ignore DTMF digit detection (default=no)\n"
++" 'f': Ignore fax detection (default=no)\n"
++" 't': Ignore talk detection (default=no)\n"
++" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n"
++" mindur: Minimum non-silence ms needed (default=100)\n"
++" maxdur: Maximum non-silence ms allowed (default=0/forever)\n"
++"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n"
++"For questions or comments, please e-mail support@newmantelecom.com.\n";
++
++// Use the second one for recent Asterisk releases
++#define CALLERID_FIELD cid.cid_num
++//#define CALLERID_FIELD callerid
++
++static int nv_detectfax_exec(struct ast_channel *chan, void *data)
++{
++ int res = 0;
++ char tmp[256] = "\0";
++ char *p = NULL;
++ char *waitstr = NULL;
++ char *options = NULL;
++ char *silstr = NULL;
++ char *minstr = NULL;
++ char *maxstr = NULL;
++ struct ast_frame *fr = NULL;
++ struct ast_frame *fr2 = NULL;
++ int notsilent = 0;
++ struct timeval start = {0, 0}, end = {0, 0};
++ int waitdur = 4;
++ int sildur = 1000;
++ int mindur = 100;
++ int maxdur = -1;
++ int skipanswer = 0;
++ int noextneeded = 0;
++ int ignoredtmf = 0;
++ int ignorefax = 0;
++ int ignoretalk = 0;
++ int x = 0;
++ int origrformat = 0;
++ int features = 0;
++ time_t timeout = 0;
++ struct ast_dsp *dsp = NULL;
++
++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "");
++ pbx_builtin_setvar_helper(chan, "FAXEXTEN", "");
++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "");
++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", "");
++
++ if (data || !ast_strlen_zero((char *)data)) {
++ strncpy(tmp, (char *)data, sizeof(tmp)-1);
++ }
++
++ p = tmp;
++
++ waitstr = strsep(&p, "|");
++ options = strsep(&p, "|");
++ silstr = strsep(&p, "|");
++ minstr = strsep(&p, "|");
++ maxstr = strsep(&p, "|");
++
++ if (waitstr) {
++ if ((sscanf(waitstr, "%d", &x) == 1) && (x > 0))
++ waitdur = x;
++ }
++
++ if (options) {
++ if (strchr(options, 'n'))
++ skipanswer = 1;
++ if (strchr(options, 'x'))
++ noextneeded = 1;
++ if (strchr(options, 'd'))
++ ignoredtmf = 1;
++ if (strchr(options, 'f'))
++ ignorefax = 1;
++ if (strchr(options, 't'))
++ ignoretalk = 1;
++ }
++
++ if (silstr) {
++ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0))
++ sildur = x;
++ }
++
++ if (minstr) {
++ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0))
++ mindur = x;
++ }
++
++ if (maxstr) {
++ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0))
++ maxdur = x;
++ }
++
++ ast_log(LOG_DEBUG, "Preparing detect of fax (waitdur=%dms, sildur=%dms, mindur=%dms, maxdur=%dms)\n",
++ waitdur, sildur, mindur, maxdur);
++
++ // LOCAL_USER_ADD(u);
++ if (chan->_state != AST_STATE_UP && !skipanswer) {
++ /* Otherwise answer unless we're supposed to send this while on-hook */
++ res = ast_answer(chan);
++ }
++ if (!res) {
++ origrformat = chan->readformat;
++ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)))
++ ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
++ }
++ if (!(dsp = ast_dsp_new())) {
++ ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
++ res = -1;
++ }
++
++ if (dsp) {
++ if (!ignoretalk)
++ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */
++ if (!ignorefax)
++ features |= DSP_FEATURE_FAX_DETECT;
++ //if (!ignoredtmf)
++ features |= DSP_FEATURE_DIGIT_DETECT;
++
++ ast_dsp_set_threshold(dsp, 256);
++ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF);
++ ast_dsp_set_digitmode(dsp, DSP_DIGITMODE_DTMF);
++ }
++
++ if (!res) {
++ if (waitdur > 0)
++ timeout = time(NULL) + (time_t)waitdur;
++
++ while(ast_waitfor(chan, -1) > -1) {
++ if (waitdur > 0 && time(NULL) > timeout) {
++ res = 0;
++ break;
++ }
++
++ fr = ast_read(chan);
++ if (!fr) {
++ ast_log(LOG_DEBUG, "Got hangup\n");
++ res = -1;
++ break;
++ }
++
++ fr2 = ast_dsp_process(chan, dsp, fr);
++ if (!fr2) {
++ ast_log(LOG_WARNING, "Bad DSP received (what happened?)\n");
++ fr2 = fr;
++ }
++
++ if (fr2->frametype == AST_FRAME_DTMF) {
++ if (fr2->subclass == 'f' && !ignorefax) {
++ /* Fax tone -- Handle and return NULL */
++ ast_log(LOG_DEBUG, "Fax detected on %s\n", chan->name);
++ if (strcmp(chan->exten, "fax")) {
++ ast_log(LOG_NOTICE, "Redirecting %s to fax extension\n", chan->name);
++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "1");
++ pbx_builtin_setvar_helper(chan,"FAXEXTEN",chan->exten);
++ if (ast_exists_extension(chan, chan->context, "fax", 1, chan->CALLERID_FIELD)) {
++ /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
++ strncpy(chan->exten, "fax", sizeof(chan->exten)-1);
++ chan->priority = 0;
++ } else
++ ast_log(LOG_WARNING, "Fax detected, but no fax extension\n");
++ } else
++ ast_log(LOG_WARNING, "Already in a fax extension, not redirecting\n");
++
++ res = 0;
++ ast_frfree(fr);
++ break;
++ } else if (!ignoredtmf) {
++ ast_log(LOG_DEBUG, "DTMF detected on %s\n", chan->name);
++ char t[2];
++ t[0] = fr2->subclass;
++ t[1] = '\0';
++ if (noextneeded || ast_canmatch_extension(chan, chan->context, t, 1, chan->CALLERID_FIELD)) {
++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "1");
++ /* They entered a valid extension, or might be anyhow */
++ if (noextneeded) {
++ ast_log(LOG_NOTICE, "DTMF received (not matching to exten)\n");
++ res = 0;
++ } else {
++ ast_log(LOG_NOTICE, "DTMF received (matching to exten)\n");
++ res = fr2->subclass;
++ }
++ ast_frfree(fr);
++ break;
++ } else
++ ast_log(LOG_DEBUG, "Valid extension requested and DTMF did not match\n");
++ }
++ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR) && !ignoretalk) {
++ int totalsilence;
++ int ms;
++ res = ast_dsp_silence(dsp, fr, &totalsilence);
++ if (res && (totalsilence > sildur)) {
++ /* We've been quiet a little while */
++ if (notsilent) {
++ /* We had heard some talking */
++ gettimeofday(&end, NULL);
++ ms = (end.tv_sec - start.tv_sec) * 1000;
++ ms += (end.tv_usec - start.tv_usec) / 1000;
++ ms -= sildur;
++ if (ms < 0)
++ ms = 0;
++ if ((ms > mindur) && ((maxdur < 0) || (ms < maxdur))) {
++ char ms_str[10];
++ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
++ ast_log(LOG_NOTICE, "Redirecting %s to talk extension\n", chan->name);
++
++ /* Save detected talk time (in milliseconds) */
++ sprintf(ms_str, "%d", ms);
++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str);
++
++ if (ast_exists_extension(chan, chan->context, "talk", 1, chan->CALLERID_FIELD)) {
++ strncpy(chan->exten, "talk", sizeof(chan->exten) - 1);
++ chan->priority = 0;
++ } else
++ ast_log(LOG_WARNING, "Talk detected, but no talk extension\n");
++ res = 0;
++ ast_frfree(fr);
++ break;
++ } else
++ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
++ notsilent = 0;
++ }
++ } else {
++ if (!notsilent) {
++ /* Heard some audio, mark the begining of the token */
++ gettimeofday(&start, NULL);
++ ast_log(LOG_DEBUG, "Start of voice token!\n");
++ notsilent = 1;
++ }
++ }
++ }
++ ast_frfree(fr);
++ }
++ } else
++ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
++
++ if (res > -1) {
++ if (origrformat && ast_set_read_format(chan, origrformat)) {
++ ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n",
++ chan->name, ast_getformatname(origrformat));
++ }
++ }
++
++ if (dsp)
++ ast_dsp_free(dsp);
++
++ // LOCAL_USER_REMOVE(u);
++
++ return res;
++}
++
++static int unload_module(void)
++{
++ return ast_unregister_application(app);
++}
++
++static int load_module(void)
++{
++ return ast_register_application(app, nv_detectfax_exec, synopsis, descrip);
++}
++
++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax Detection Application");
diff --git a/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch
new file mode 100644
index 000000000000..122dc1d2f78f
--- /dev/null
+++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch
@@ -0,0 +1,21 @@
+diff -uNr asterisk-1.6.2.1.ORIG/Makefile asterisk-1.6.2.1/Makefile
+--- asterisk-1.6.2.1.ORIG/Makefile 2010-01-19 17:06:47.000000000 +0000
++++ asterisk-1.6.2.1/Makefile 2010-01-19 17:08:15.000000000 +0000
+@@ -590,7 +590,7 @@
+ fi
+
+ $(SUBDIRS_INSTALL):
+- @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
++ +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
+
+ NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
+ OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
+@@ -852,7 +852,7 @@
+ @cmp -s .cleancount .lastclean || $(MAKE) clean
+
+ $(SUBDIRS_UNINSTALL):
+- @$(SUBMAKE) -C $(@:-uninstall=) uninstall
++ +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
+
+ _uninstall: $(SUBDIRS_UNINSTALL)
+ rm -f $(DESTDIR)$(MODULES_DIR)/*