From 892056dbc69137f78a8036fcda23ec6fcf1808b2 Mon Sep 17 00:00:00 2001 From: kpfleming Date: Wed, 20 Aug 2008 19:35:59 +0000 Subject: Backport support for Zaptel/DAHDI channel-level alarms from trunk/1.6, because not doing so just makes it difficult for people with channels that are in alarm when Asterisk starts up to get them going once the alarm is cleared (closes issue #12160) Reported by: tzafrir Patches: asterisk-chanalarms_14.patch uploaded by tzafrir (license 46) Tested by: tzafrir git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@139145 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_dahdi.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'channels/chan_dahdi.c') diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 07b6e9ef9..125a971e1 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -3666,14 +3666,33 @@ static int get_alarms(struct dahdi_pvt *p) { int res; struct dahdi_spaninfo zi; +#if defined(HAVE_DAHDI) || defined(HAVE_ZAPTEL_CHANALARMS) + /* + * The conditional compilation is needed only in asterisk-1.4 for + * backward compatibility with old zaptel drivers that don't have + * a DAHDI_PARAMS.chan_alarms field. + */ + struct dahdi_params params; +#endif + memset(&zi, 0, sizeof(zi)); zi.spanno = p->span; - res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SPANSTAT, &zi); - if (res < 0) { + + /* First check for span alarms */ + if((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SPANSTAT, &zi)) < 0) { ast_log(LOG_WARNING, "Unable to determine alarm on channel %d: %s\n", p->channel, strerror(errno)); return 0; } - return zi.alarms; + if (zi.alarms != DAHDI_ALARM_NONE) + return zi.alarms; +#if defined(HAVE_DAHDI) || defined(HAVE_ZAPTEL_CHANALARMS) + /* No alarms on the span. Check for channel alarms. */ + if ((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, ¶ms)) >= 0) + return params.chan_alarms; + /* ioctl failed */ + ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel); +#endif + return DAHDI_ALARM_NONE; } static void dahdi_handle_dtmfup(struct ast_channel *ast, int index, struct ast_frame **dest) -- cgit v1.2.3