[asterisk-commits] rmudgett: branch rmudgett/sig_ss7 r261910 - /team/rmudgett/sig_ss7/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 7 11:40:51 CDT 2010


Author: rmudgett
Date: Fri May  7 11:40:47 2010
New Revision: 261910

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261910
Log:
Separate SS7 signaling link exception handling.

Modified:
    team/rmudgett/sig_ss7/channels/chan_dahdi.c
    team/rmudgett/sig_ss7/channels/sig_ss7.h

Modified: team/rmudgett/sig_ss7/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/sig_ss7/channels/chan_dahdi.c?view=diff&rev=261910&r1=261909&r2=261910
==============================================================================
--- team/rmudgett/sig_ss7/channels/chan_dahdi.c (original)
+++ team/rmudgett/sig_ss7/channels/chan_dahdi.c Fri May  7 11:40:47 2010
@@ -681,6 +681,13 @@
 	}
 
 	return ast;
+}
+
+static void sig_ss7_handle_link_exception(struct sig_ss7_linkset *linkset, int which)
+{
+	if (linkset->calls->handle_link_exception) {
+		linkset->calls->handle_link_exception(linkset, which);
+	}
 }
 
 /* BUGBUG sig_ss7 callback functions ----^*/
@@ -3168,6 +3175,47 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_SS7)
+/*!
+ * \internal
+ * \brief Handle the SS7 link exception.
+ * \since 1.8
+ *
+ * \param linkset Controlling linkset for the channel.
+ * \param which Link index of the signaling channel.
+ *
+ * \return Nothing
+ */
+static void my_handle_link_exception(struct sig_ss7_linkset *linkset, int which)
+{
+	int event;
+
+	if (ioctl(linkset->fds[which], DAHDI_GETEVENT, &event)) {
+		ast_log(LOG_ERROR, "SS7: Error in exception retrieval on span %d/%d!\n",
+			linkset->span, which);
+		return;
+	}
+	switch (event) {
+	case DAHDI_EVENT_NONE:
+		break;
+	case DAHDI_EVENT_ALARM:
+		ast_log(LOG_ERROR, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		sig_ss7_link_alarm(linkset, which);
+		break;
+	case DAHDI_EVENT_NOALARM:
+		ast_log(LOG_ERROR, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		sig_ss7_link_noalarm(linkset, which);
+		break;
+	default:
+		ast_log(LOG_NOTICE, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		break;
+	}
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
 static void my_ss7_set_loopback(void *pvt, int enable)
 {
 	struct dahdi_pvt *p = pvt;
@@ -3274,6 +3322,7 @@
 	.new_ast_channel = my_new_ss7_ast_channel,
 	.play_tone = my_ss7_play_tone,
 
+	.handle_link_exception = my_handle_link_exception,
 	.set_alarm = my_set_alarm,
 	.set_dialing = my_set_dialing,
 	.set_digital = my_set_digital,
@@ -13488,63 +13537,11 @@
 		ast_mutex_lock(&linkset->lock);
 		for (i = 0; i < linkset->numsigchans; i++) {
 			if (pollers[i].revents & POLLPRI) {
-#if 1
-/* BUGBUG what to do about this DAHDI exception loop?  How did sig_pri handle it? */
-				int x;
-				if (ioctl(pollers[i].fd, DAHDI_GETEVENT, &x)) {
-					ast_log(LOG_ERROR, "Error in exception retrieval!\n");
-				}
-				switch (x) {
-				case DAHDI_EVENT_OVERRUN:
-					ast_debug(1, "Overrun detected!\n");
-					break;
-				case DAHDI_EVENT_BADFCS:
-					ast_debug(1, "Bad FCS\n");
-					break;
-				case DAHDI_EVENT_ABORT:
-					ast_debug(1, "HDLC Abort\n");
-					break;
-				case DAHDI_EVENT_ALARM:
-					ast_log(LOG_ERROR, "Alarm on link!\n");
-#if 1
-					linkset->linkstate[i] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
-					linkset->linkstate[i] &= ~LINKSTATE_UP;
-					ss7_link_alarm(ss7, pollers[i].fd);
-#else
-					/* The other conditional clause should be the contents of this function. */
-					sig_ss7_link_alarm(linkset, fd);
-#endif
-					break;
-				case DAHDI_EVENT_NOALARM:
-					ast_log(LOG_ERROR, "Alarm cleared on link\n");
-#if 1
-					linkset->linkstate[i] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
-					linkset->linkstate[i] |= LINKSTATE_STARTING;
-					ss7_link_noalarm(ss7, pollers[i].fd);
-#else
-					/* The other conditional clause should be the contents of this function. */
-					sig_ss7_link_noalarm(linkset, fd);
-#endif
-					break;
-				default:
-					ast_log(LOG_ERROR, "Got exception %d!\n", x);
-					break;
-				}
-#else
-/*
-* sig_pri did callback to sig_pri_handle_dchan_excepton(). 
-* The callback read DAHDI_GET_EVENT and really only handles link up/down 
-* in my_handle_dchan_exception().  my_handle_dchan_exception() in turn calls 
-* the equivalent of sig_ss7_link_alarm() and sig_ss7_link_noalarm(). 
-*/
 				sig_ss7_handle_link_exception(linkset, i);
-#endif
-			}
-
+			}
 			if (pollers[i].revents & POLLIN) {
 				res = ss7_read(ss7, pollers[i].fd);
 			}
-
 			if (pollers[i].revents & POLLOUT) {
 				res = ss7_write(ss7, pollers[i].fd);
 				if (res < 0) {
@@ -16053,6 +16050,7 @@
 }
 
 #if defined(HAVE_SS7)
+/* BUGBUG need to convert for sig_ss7 similar to prepare_pri() */
 static int linkset_addsigchan(int sigchan)
 {
 	struct dahdi_ss7 *link;
@@ -18326,6 +18324,38 @@
 /* BUGBUG sig_ss7 API functions ----v*/
 
 /*!
+ * \brief Notify the SS7 layer that the link is in alarm.
+ * \since 1.8
+ *
+ * \param linkset Controlling linkset for the channel.
+ * \param which Link index of the signaling channel.
+ *
+ * \return Nothing
+ */
+void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which)
+{
+	linkset->linkstate[which] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
+	linkset->linkstate[which] &= ~LINKSTATE_UP;
+	ss7_link_alarm(linkset->ss7, linkset->fds[which]);
+}
+
+/*!
+ * \brief Notify the SS7 layer that the link is no longer in alarm.
+ * \since 1.8
+ *
+ * \param linkset Controlling linkset for the channel.
+ * \param which Link index of the signaling channel.
+ *
+ * \return Nothing
+ */
+void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which)
+{
+	linkset->linkstate[which] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
+	linkset->linkstate[which] |= LINKSTATE_STARTING;
+	ss7_link_noalarm(linkset->ss7, linkset->fds[which]);
+}
+
+/*!
  * \brief Determine if the specified channel is available for an outgoing call.
  * \since 1.8
  *

Modified: team/rmudgett/sig_ss7/channels/sig_ss7.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/sig_ss7/channels/sig_ss7.h?view=diff&rev=261910&r1=261909&r2=261910
==============================================================================
--- team/rmudgett/sig_ss7/channels/sig_ss7.h (original)
+++ team/rmudgett/sig_ss7/channels/sig_ss7.h Fri May  7 11:40:47 2010
@@ -97,6 +97,7 @@
 	struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor);
 	int (* const play_tone)(void *pvt, enum sig_ss7_tone tone);
 
+	void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which);
 	void (* const set_alarm)(void *pvt, int in_alarm);
 	void (* const set_dialing)(void *pvt, int is_dialing);
 	void (* const set_digital)(void *pvt, int is_digital);
@@ -227,6 +228,8 @@
 };
 
 void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm);
+void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which);
+void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which);
 int sig_ss7_available(struct sig_ss7_chan *p);
 int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest);
 int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast);




More information about the asterisk-commits mailing list