[asterisk-commits] mattf: branch mattf/asterisk-ss7 r42112 - /team/mattf/asterisk-ss7/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Sep 6 10:26:02 MST 2006


Author: mattf
Date: Wed Sep  6 12:26:01 2006
New Revision: 42112

URL: http://svn.digium.com/view/asterisk?rev=42112&view=rev
Log:
Put in initial implementation of alarm state monitoring.

Modified:
    team/mattf/asterisk-ss7/channels/chan_zap.c

Modified: team/mattf/asterisk-ss7/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/mattf/asterisk-ss7/channels/chan_zap.c?rev=42112&r1=42111&r2=42112&view=diff
==============================================================================
--- team/mattf/asterisk-ss7/channels/chan_zap.c (original)
+++ team/mattf/asterisk-ss7/channels/chan_zap.c Wed Sep  6 12:26:01 2006
@@ -411,12 +411,18 @@
 static int ringt_base = DEFAULT_RINGT;
 
 #ifdef HAVE_SS7
+
+#define LINKSTATE_INALARM	(1 << 0)
+#define LINKSTATE_STARTING	(1 << 1)
+#define LINKSTATE_UP		(1 << 2)
+#define LINKSTATE_DOWN		(1 << 3)
+
 struct zt_ss7 {
 	pthread_t master;						/*!< Thread of master */
 	ast_mutex_t lock;
 	int fds[NUM_DCHANS];
 	int numsigchans;
-	int inalarm[NUM_DCHANS];
+	int linkstate[NUM_DCHANS];
 	int numchans;
 	struct ss7 *ss7;
 	struct zt_pvt *pvts[MAX_CHANNELS];				/*!< Member channel pvt structs */
@@ -8219,6 +8225,18 @@
 					break;
 				case ZT_EVENT_ABORT:
 					ast_log(LOG_ERROR, "HDLC Abort!\n");
+					break;
+				case ZT_EVENT_ALARM:
+					ast_log(LOG_ERROR, "Alarm on link!\n");
+					linkset->linkstate[i] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
+					linkset->linkstate[i] &= ~LINKSTATE_UP;
+					ss7_link_alarm(ss7, pollers[i].fd);
+					break;
+				case ZT_EVENT_NOALARM:
+					ast_log(LOG_ERROR, "Alarm cleared on link\n");
+					linkset->linkstate[i] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
+					linkset->linkstate[i] |= LINKSTATE_STARTING;
+					ss7_link_noalarm(ss7, pollers[i].fd);
 					break;
 				default:
 					ast_log(LOG_ERROR, "Got exception %d!\n", x);
@@ -10953,6 +10971,21 @@
 			return -1;
 		}
 
+		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
+		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+		bi.numbufs = 32;
+		bi.bufsize = 512;
+
+		if (ioctl(link->fds[curfd], ZT_SET_BUFINFO, &bi)) {
+			ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d\n", sigchan);
+			zt_close(link->fds[curfd]);
+			link->fds[curfd] = -1;
+			return -1;
+		}
+
+		ss7_add_link(link->ss7, link->fds[curfd]);
+		link->numsigchans++;
+
 		memset(&si, 0, sizeof(si));
 		res = ioctl(link->fds[curfd], ZT_SPANSTAT, &si);
 		if (res) {
@@ -10961,26 +10994,13 @@
 			ast_log(LOG_ERROR, "Unable to get span state for sigchan %d (%s)\n", sigchan, strerror(errno));
 		}
 
-		if (!si.alarms)
-			link->inalarm[curfd] = 0;
-		else
-			link->inalarm[curfd] = 1;
-
-		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
-		bi.numbufs = 32;
-		bi.bufsize = 512;
-
-		if (ioctl(link->fds[curfd], ZT_SET_BUFINFO, &bi)) {
-			ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d\n", sigchan);
-			zt_close(link->fds[curfd]);
-			link->fds[curfd] = -1;
-			return -1;
-		}
-
-		ss7_add_link(link->ss7, link->fds[curfd]);
-		
-		link->numsigchans++;
+		if (!si.alarms) {
+			link->linkstate[curfd] = LINKSTATE_DOWN;
+			ss7_link_noalarm(link->ss7, link->fds[curfd]);
+		} else {
+			link->linkstate[curfd] = LINKSTATE_DOWN | LINKSTATE_INALARM;
+			ss7_link_alarm(link->ss7, link->fds[curfd]);
+		}
 	}
 
 	if (cur_adjpointcode < 0) {
@@ -11048,6 +11068,31 @@
 	return RESULT_SUCCESS;
 }
 
+#if 0
+static int handle_ss7_show_linkset(int fd, int argc, char *argv[])
+{
+	int linkset;
+	struct zt_ss7 *ss7;
+	if (argc < 4)
+		return RESULT_SHOWUSAGE;
+	linkset = atoi(argv[3]);
+	if ((linkset < 1) || (linkset > NUM_SPANS)) {
+		ast_cli(fd, "Invalid linkset %s.  Should be a number %d to %d\n", argv[4], 1, NUM_SPANS);
+		return RESULT_SUCCESS;
+	}
+	if (!linksets[linkset-1].ss7) {
+		ast_cli(fd, "No SS7 running on linkset %d\n", linkset);
+		return RESULT_SUCCESS;
+	}
+	if (linksets[linkset-1].ss7)
+		ss7 = linksets[linkset-1];
+
+	if (
+
+	return RESULT_SUCCESS;
+}
+#endif
+
 static const char ss7_debug_help[] = 
 	"Usage: ss7 debug linkset <linkset>\n"
 	"       Enables debugging on a given SS7 linkset\n";
@@ -11056,11 +11101,21 @@
 	"Usage: ss7 no debug linkset <span>\n"
 	"       Disables debugging on a given SS7 linkset\n";
 
+#if 0
+static const char ss7_show_linkset_help[] = 
+	"Usage: ss7 show linkset <span>\n"
+	"       Disables debugging on a given SS7 linkset\n";
+#endif
+
 static struct ast_cli_entry zap_ss7_cli[] = {
 	{ { "ss7", "debug", "linkset", NULL }, handle_ss7_debug,
 	  "Enables SS7 debugging on a linkset", ss7_debug_help, NULL },
 	{ { "ss7", "no", "debug", "linkset", NULL }, handle_ss7_no_debug,
 	  "Disables SS7 debugging on a linkset", ss7_no_debug_help, NULL },
+#if 0
+	{ { "ss7", "show", "linkset", NULL }, handle_ss7_show_linkset,
+	  "Disables SS7 debugging on a linkset", ss7_show_linkset_help, NULL },
+#endif
 };
 #endif /* HAVE_SS7 */
 



More information about the asterisk-commits mailing list