aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_dahdi.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-20 19:35:59 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-20 19:35:59 +0000
commit892056dbc69137f78a8036fcda23ec6fcf1808b2 (patch)
tree884204c3d034ed74e2e06101cb1af869b925c391 /channels/chan_dahdi.c
parent1643fa63cf953401a1d7dc6f5117e6cddbe6724a (diff)
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
Diffstat (limited to 'channels/chan_dahdi.c')
-rw-r--r--channels/chan_dahdi.c25
1 files changed, 22 insertions, 3 deletions
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, &params)) >= 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)