change VMWI to use new DAHDI_VMWI ioctl call.

Change configure script to detect the new ioctl call data structure.    
(issue #14104)
Reported by: alecdavis
Patches:
      mwiioctl_structure_asterisk.diff4.txt uploaded by dbailey (license )
Tested by: alecdavis, dbailey


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@170112 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Doug Bailey
2009-01-22 15:49:24 +00:00
parent 49785e775e
commit 9a28a07739
4 changed files with 126 additions and 48 deletions

View File

@@ -264,7 +264,7 @@ static char parkinglot[AST_MAX_EXTENSION] = ""; /*!< Default parking lot for th
/*! Run this script when the MWI state changes on an FXO line, if mwimonitor is enabled */
static char mwimonitornotify[PATH_MAX] = "";
#ifndef DAHDI_VMWI_FSK
#ifndef HAVE_DAHDI_LINEREVERSE_VMWI
static int mwisend_rpas = 0;
#endif
@@ -732,7 +732,11 @@ static struct dahdi_pvt {
int onhooktime;
int fxsoffhookstate;
int msgstate;
int mwisendtype; /*!< Which VMWI methods to use */
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
struct dahdi_vmwi_info mwisend_setting; /*!< Which VMWI methods to use */
unsigned int mwisend_fsk: 1; /*! Variable for enabling FSK MWI handling in chan_dahdi */
unsigned int mwisend_rpas:1; /*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
#endif
int distinctivering; /*!< Which distinctivering to use */
int cidrings; /*!< Which ring to deliver CID on */
int dtmfrelax; /*!< whether to run in relaxed DTMF mode */
@@ -872,8 +876,8 @@ static struct dahdi_chan_conf dahdi_chan_conf_default(void)
.mailbox = "",
#ifdef DAHDI_VMWI_FSK
.mwisendtype = DAHDI_VMWI_FSK,
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
.mwisend_fsk = 1,
#endif
.polarityonanswerdelay = 600,
@@ -7714,12 +7718,12 @@ static int mwi_send_init(struct dahdi_pvt * pvt)
{
int x, res;
#ifdef DAHDI_VMWI_FSK
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
/* Determine how this spill is to be sent */
if (pvt->mwisendtype & DAHDI_VMWI_RPAS) {
if (pvt->mwisend_rpas) {
pvt->mwisend_data.mwisend_current = MWI_SEND_SA;
pvt->mwisendactive = 1;
} else if (pvt->mwisendtype & DAHDI_VMWI_FSK) {
} else if (pvt->mwisend_fsk) {
pvt->mwisend_data.mwisend_current = MWI_SEND_SPILL;
pvt->mwisendactive = 1;
} else {
@@ -7751,13 +7755,13 @@ static int mwi_send_init(struct dahdi_pvt * pvt)
res = ioctl(pvt->subs[SUB_REAL].dfd, DAHDI_FLUSH, &x);
x = 3000;
ioctl(pvt->subs[SUB_REAL].dfd, DAHDI_ONHOOKTRANSFER, &x);
#ifdef DAHDI_VMWI_FSK
if (pvt->mwisendtype & DAHDI_VMWI_FSK) {
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
if (pvt->mwisend_fsk) {
#endif
pvt->cidlen = vmwi_generate(pvt->cidspill, has_voicemail(pvt), CID_MWI_TYPE_MDMF_FULL,
AST_LAW(pvt), pvt->cid_name, pvt->cid_num, 0);
pvt->cidpos = 0;
#ifdef DAHDI_VMWI_FSK
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
}
#endif
return 0;
@@ -7789,14 +7793,14 @@ static int mwi_send_process_buffer(struct dahdi_pvt * pvt, int num_read)
case MWI_SEND_SA_WAIT: /* do nothing until I get RINGEROFF event */
break;
case MWI_SEND_PAUSE: /* Wait between alert and spill - min of 500 mS*/
#ifdef DAHDI_VMWI_FSK
if (pvt->mwisendtype & DAHDI_VMWI_FSK) {
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
if (pvt->mwisend_fsk) {
#endif
gettimeofday(&now, NULL);
if ((int)(now.tv_sec - pvt->mwisend_data.pause.tv_sec) * 1000000 + (int)now.tv_usec - (int)pvt->mwisend_data.pause.tv_usec > 500000) {
pvt->mwisend_data.mwisend_current = MWI_SEND_SPILL;
}
#ifdef DAHDI_VMWI_FSK
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
} else { /* support for mwisendtype=nofsk */
pvt->mwisend_data.mwisend_current = MWI_SEND_CLEANUP;
}
@@ -8245,7 +8249,7 @@ static void *do_monitor(void *data)
!ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3)) {
res = has_voicemail(last);
if (last->msgstate != res) {
#ifndef DAHDI_VMWI_FSK
#ifndef HAVE_DAHDI_LINEREVERSE_VMWI
/* Set driver resources for signalling VMWI */
res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_VMWI, &res);
if (res2) {
@@ -8253,13 +8257,8 @@ static void *do_monitor(void *data)
ast_debug(3, "Unable to control message waiting led on channel %d: %s\n", last->channel, strerror(errno));
}
#else
/* New DAHDI_VMWI ioctl supports upto 65535 messages*/
if (res > DAHDI_VMWI_NUMBER_MASK) {
res2 = (last->mwisendtype | DAHDI_VMWI_NUMBER_MASK);
} else {
res2 = (last->mwisendtype | (res & DAHDI_VMWI_NUMBER_MASK));
}
res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_VMWI, &res2);
last->mwisend_setting.messages = res;
res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_VMWI, &last->mwisend_setting);
if (res2) {
/* TODO: This message will ALWAYS be generated on some cards; any way to restrict it to those cards where it is interesting? */
ast_debug(3, "Unable to control MWI on channel %d: %s\n", last->channel, strerror(errno));
@@ -9021,7 +9020,11 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
AST_EVENT_IE_END);
}
tmp->msgstate = -1;
tmp->mwisendtype = conf->chan.mwisendtype;
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
tmp->mwisend_setting = conf->chan.mwisend_setting;
tmp->mwisend_fsk = conf->chan.mwisend_fsk;
tmp->mwisend_rpas = conf->chan.mwisend_rpas;
#endif
if (chan_sig & __DAHDI_SIG_FXO) {
memset(&p, 0, sizeof(p));
res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p);
@@ -14243,7 +14246,7 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
} else if (!strcasecmp(v->name, "mwimonitornotify")) {
ast_copy_string(mwimonitornotify, v->value, sizeof(mwimonitornotify));
} else if (!strcasecmp(v->name, "mwisendtype")) {
#ifndef DAHDI_VMWI_FSK /* backward compatibility for older dahdi VMWI implementation */
#ifndef HAVE_DAHDI_LINEREVERSE_VMWI /* backward compatibility for older dahdi VMWI implementation */
if (!strcasecmp(v->value, "rpas")) { /* Ring Pulse Alert Signal */
mwisend_rpas = 1;
} else {
@@ -14251,22 +14254,25 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
}
#else
/* Default is fsk, to turn it off you must specify nofsk */
memset(&confp->chan.mwisend_setting, 0, sizeof(confp->chan.mwisend_setting));
if (strcasestr(v->value, "nofsk")) { /* NoFSK */
confp->chan.mwisendtype = 0;
confp->chan.mwisend_fsk = 0;
} else { /* Default FSK */
confp->chan.mwisendtype = DAHDI_VMWI_FSK;
confp->chan.mwisend_fsk = 1;
}
if (strcasestr(v->value, "rpas")) { /* Ring Pulse Alert Signal, normally followed by FSK */
confp->chan.mwisendtype |= DAHDI_VMWI_RPAS;
confp->chan.mwisend_rpas = 1;
} else {
confp->chan.mwisend_rpas = 0;
}
if (strcasestr(v->value, "lrev")) { /* Line Reversal */
confp->chan.mwisendtype |= DAHDI_VMWI_LREV;
confp->chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_LREV;
}
if (strcasestr(v->value, "hvdc")) { /* HV 90VDC */
confp->chan.mwisendtype |= DAHDI_VMWI_HVDC;
confp->chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_HVDC;
}
if ( (strcasestr(v->value, "neon")) || (strcasestr(v->value, "hvac")) ){ /* 90V DC pulses */
confp->chan.mwisendtype |= DAHDI_VMWI_HVAC;
confp->chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_HVAC;
}
#endif
} else if (reload != 1) {

102
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 168522 .
# From configure.ac Revision: 168734 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.
#
@@ -990,7 +990,6 @@ CONFIG_LIBXML2
PBX_MISDN_FAC_RESULT
PBX_MISDN_FAC_ERROR
CONFIG_NETSNMP
PBX_ODBC
PG_CONFIG
PTLIB_CONFIG
PWLIBDIR
@@ -13333,13 +13332,11 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h> /* for off_t */
#include <stdio.h>
#include <stdio.h>
int
main ()
{
int (*fp) (FILE *, off_t, int) = fseeko;
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
;
return 0;
}
@@ -13379,13 +13376,11 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _LARGEFILE_SOURCE 1
#include <sys/types.h> /* for off_t */
#include <stdio.h>
#include <stdio.h>
int
main ()
{
int (*fp) (FILE *, off_t, int) = fseeko;
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
;
return 0;
}
@@ -20401,6 +20396,82 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "x${PBX_DAHDI_LINEREVERSE_VMWI}" != "x1" -a "${USE_DAHDI_LINEREVERSE_VMWI}" != "no"; then
if test "xenhanced dahdi vmwi support" != "x"; then
{ echo "$as_me:$LINENO: checking for enhanced dahdi vmwi support" >&5
echo $ECHO_N "checking for enhanced dahdi vmwi support... $ECHO_C" >&6; }
else
{ echo "$as_me:$LINENO: checking if \"struct dahdi_vmwi_info booger\" compiles using dahdi/user.h" >&5
echo $ECHO_N "checking if \"struct dahdi_vmwi_info booger\" compiles using dahdi/user.h... $ECHO_C" >&6; }
fi
saved_cppflags="${CPPFLAGS}"
if test "x${DAHDI_LINEREVERSE_VMWI_DIR}" != "x"; then
DAHDI_LINEREVERSE_VMWI_INCLUDE="-I${DAHDI_LINEREVERSE_VMWI_DIR}/include"
fi
CPPFLAGS="${CPPFLAGS} ${DAHDI_LINEREVERSE_VMWI_INCLUDE}"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <dahdi/user.h>
int
main ()
{
struct dahdi_vmwi_info booger;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
PBX_DAHDI_LINEREVERSE_VMWI=1
cat >>confdefs.h <<\_ACEOF
#define HAVE_DAHDI_LINEREVERSE_VMWI 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_DAHDI_LINEREVERSE_VMWI_VERSION
_ACEOF
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CPPFLAGS="${saved_cppflags}"
fi
# BSD might not have exp2, and/or log2
if test "x${PBX_EXP2L}" != "x1" -a "${USE_EXP2L}" != "no"; then
@@ -38183,12 +38254,6 @@ _ACEOF
fi
PBX_ODBC=0
if test "$PBX_IODBC" = "1" -o "$PBX_UNIXODBC" = "1"; then
PBX_ODBC=1
fi
if test "x${PBX_OGG}" != "x1" -a "${USE_OGG}" != "no"; then
pbxlibdir=""
@@ -53664,7 +53729,6 @@ CONFIG_LIBXML2!$CONFIG_LIBXML2$ac_delim
PBX_MISDN_FAC_RESULT!$PBX_MISDN_FAC_RESULT$ac_delim
PBX_MISDN_FAC_ERROR!$PBX_MISDN_FAC_ERROR$ac_delim
CONFIG_NETSNMP!$CONFIG_NETSNMP$ac_delim
PBX_ODBC!$PBX_ODBC$ac_delim
PG_CONFIG!$PG_CONFIG$ac_delim
PTLIB_CONFIG!$PTLIB_CONFIG$ac_delim
PWLIBDIR!$PWLIBDIR$ac_delim
@@ -53681,6 +53745,7 @@ AIS_INCLUDE!$AIS_INCLUDE$ac_delim
AIS_LIB!$AIS_LIB$ac_delim
CONFIG_GMIME!$CONFIG_GMIME$ac_delim
EDITLINE_LIB!$EDITLINE_LIB$ac_delim
PBX_H323!$PBX_H323$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -53722,7 +53787,6 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
PBX_H323!$PBX_H323$ac_delim
PBX_IXJUSER!$PBX_IXJUSER$ac_delim
CONFIG_SDL!$CONFIG_SDL$ac_delim
CONFIG_GTK!$CONFIG_GTK$ac_delim
@@ -53734,7 +53798,7 @@ PBX_GENERIC_ODBC!$PBX_GENERIC_ODBC$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 10; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@@ -617,6 +617,8 @@ AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
AST_C_DEFINE_CHECK([DAHDI_HALF_FULL], [DAHDI_POLICY_HALF_FULL], [dahdi/user.h])
AST_C_COMPILE_CHECK([DAHDI_LINEREVERSE_VMWI], [struct dahdi_vmwi_info booger], [dahdi/user.h], , [enhanced dahdi vmwi support])
# BSD might not have exp2, and/or log2
AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])

View File

@@ -192,6 +192,12 @@
/* Define DAHDI_HALF_FULL headers version */
#undef HAVE_DAHDI_HALF_FULL_VERSION
/* Define if your system has the DAHDI_LINEREVERSE_VMWI headers. */
#undef HAVE_DAHDI_LINEREVERSE_VMWI
/* Define DAHDI_LINEREVERSE_VMWI headers version */
#undef HAVE_DAHDI_LINEREVERSE_VMWI_VERSION
/* Define DAHDI headers version */
#undef HAVE_DAHDI_VERSION