[libss7-commits] mattf: trunk r5 - in /trunk: mtp2.c mtp2.h ss7.c

libss7-commits at lists.digium.com libss7-commits at lists.digium.com
Thu Aug 3 11:12:14 MST 2006


Author: mattf
Date: Thu Aug  3 13:12:13 2006
New Revision: 5

URL: http://svn.digium.com/view/libss7?rev=5&view=rev
Log:
Implement ANSI MTP2 timers.

Modified:
    trunk/mtp2.c
    trunk/mtp2.h
    trunk/ss7.c

Modified: trunk/mtp2.c
URL: http://svn.digium.com/view/libss7/trunk/mtp2.c?rev=5&r1=4&r2=5&view=diff
==============================================================================
--- trunk/mtp2.c (original)
+++ trunk/mtp2.c Thu Aug  3 13:12:13 2006
@@ -404,7 +404,7 @@
 #endif
 	switch (link->state) {
 		case MTP_IDLE:
-			link->t2 = ss7_schedule_event(link->master, TIMER_T2, t2_expiry, link);
+			link->t2 = ss7_schedule_event(link->master, link->timers.t2, t2_expiry, link);
 			if (mtp2_lssu(link, LSSU_SIO)) {
 				mtp_error(link->master, "Unable to transmit initial LSSU\n");
 				return -1;
@@ -421,7 +421,7 @@
 				case MTP_ALIGNED:
 				case MTP_PROVING:
 					if (newstate == MTP_ALIGNED)
-						link->t3 = ss7_schedule_event(link->master, TIMER_T3, t3_expiry, link);
+						link->t3 = ss7_schedule_event(link->master, link->timers.t3, t3_expiry, link);
 					else
 						link->t4 = ss7_schedule_event(link->master, link->provingperiod, t4_expiry, link);
 					if (link->emergency) {
@@ -477,7 +477,7 @@
 					}
 					break;
 				case MTP_ALIGNEDREADY:
-					link->t1 = ss7_schedule_event(link->master, TIMER_T1, t1_expiry, link);
+					link->t1 = ss7_schedule_event(link->master, link->timers.t1, t1_expiry, link);
 					if (mtp2_fisu(link, 0)) {
 						mtp_error(link->master, "Could not transmit FISU\n");
 						return -1;
@@ -495,7 +495,7 @@
 						return -1;
 					break;
 				case MTP_ALIGNEDREADY:
-					link->t1 = ss7_schedule_event(link->master, TIMER_T1, t1_expiry, link);
+					link->t1 = ss7_schedule_event(link->master, link->timers.t1, t1_expiry, link);
 					if (mtp2_fisu(link, 0)) {
 						mtp_error(link->master, "Could not transmit FISU\n");
 						return -1;
@@ -551,9 +551,9 @@
 				return mtp2_setstate(link, MTP_NOTALIGNED);
 
 			if ((link->emergency) || (lssutype == LSSU_SIE))
-				link->provingperiod = TIMER_T4_EMERGENCY;
+				link->provingperiod = link->timers.t4e;
 			else
-				link->provingperiod = TIMER_T4_NORMAL;
+				link->provingperiod = link->timers.t4;
 
 			if ((lssutype == LSSU_SIE) || (lssutype == LSSU_SIN))
 				return mtp2_setstate(link, MTP_PROVING);
@@ -564,12 +564,12 @@
 				return mtp2_setstate(link, MTP_IDLE);
 
 			if ((link->emergency) || (lssutype == LSSU_SIE))
-				link->provingperiod = TIMER_T4_EMERGENCY;
+				link->provingperiod = link->timers.t4e;
 			else
-				link->provingperiod = TIMER_T4_NORMAL;
-
-			if ((link->provingperiod == TIMER_T4_NORMAL) && ((link->emergency) || (lssutype == LSSU_SIE)))
-				link->provingperiod = TIMER_T4_EMERGENCY;
+				link->provingperiod = link->timers.t4;
+
+			if ((link->provingperiod == link->timers.t4) && ((link->emergency) || (lssutype == LSSU_SIE)))
+				link->provingperiod = link->timers.t4e;
 
 			return mtp2_setstate(link, MTP_PROVING);
 		case MTP_PROVING:
@@ -641,7 +641,7 @@
 	return mtp2_setstate(link, MTP_IDLE);
 }
 
-struct mtp2 * mtp2_new(int fd)
+struct mtp2 * mtp2_new(int fd, unsigned int switchtype)
 {
 	struct mtp2 * new = calloc(1, sizeof(struct mtp2));
 
@@ -653,6 +653,20 @@
 	new->fd = fd;
 	new->autotxsutype = LSSU_SIOS;
 	new->lastsurxd = -1;
+
+	if (switchtype == SS7_ITU) {
+		new->timers.t1 = ITU_TIMER_T1;
+		new->timers.t2 = ITU_TIMER_T2;
+		new->timers.t3 = ITU_TIMER_T3;
+		new->timers.t4 = ITU_TIMER_T4_NORMAL;
+		new->timers.t4e = ITU_TIMER_T4_EMERGENCY;
+	} else if (switchtype == SS7_ANSI) {
+		new->timers.t1 = ANSI_TIMER_T1;
+		new->timers.t2 = ANSI_TIMER_T2;
+		new->timers.t3 = ANSI_TIMER_T3;
+		new->timers.t4 = ANSI_TIMER_T4_NORMAL;
+		new->timers.t4e = ANSI_TIMER_T4_EMERGENCY;
+	}
 
 	return new;
 }

Modified: trunk/mtp2.h
URL: http://svn.digium.com/view/libss7/trunk/mtp2.h?rev=5&r1=4&r2=5&view=diff
==============================================================================
--- trunk/mtp2.h (original)
+++ trunk/mtp2.h Thu Aug  3 13:12:13 2006
@@ -25,11 +25,18 @@
 
 /* MTP2 Timers */
 /* 	For ITU 64kbps links */
-#define TIMER_T1		45000
-#define TIMER_T2		50000
-#define TIMER_T3		1500
-#define TIMER_T4_NORMAL		8500
-#define TIMER_T4_EMERGENCY	500
+#define ITU_TIMER_T1		45000
+#define ITU_TIMER_T2		50000
+#define ITU_TIMER_T3		1500
+#define ITU_TIMER_T4_NORMAL	8500
+#define ITU_TIMER_T4_EMERGENCY	500
+
+/* ANSI links */
+#define ANSI_TIMER_T1		16000
+#define ANSI_TIMER_T2		11500
+#define ANSI_TIMER_T3		11500
+#define ANSI_TIMER_T4_NORMAL	2300
+#define ANSI_TIMER_T4_EMERGENCY	600
 
 /* Bottom 3 bits in LSSU status field */
 #define LSSU_SIO	0	/* Out of alignment */
@@ -68,6 +75,14 @@
 
 struct ss7;
 
+struct mtp2_timers {
+	int t1;
+	int t2;
+	int t3;
+	int t4;
+	int t4e;
+};
+
 struct mtp2 {
 	int state;
 	unsigned char curfsn:7;
@@ -89,6 +104,7 @@
 	int autotxsutype;
 	int lastsurxd;
 	int lastsutxd;
+	struct mtp2_timers timers;
 
 	struct ss7_msg *tx_buf;
 	struct ss7_msg *tx_q;
@@ -99,7 +115,7 @@
 int mtp2_start(struct mtp2 *link);
 int mtp2_stop(struct mtp2 *link);
 int mtp2_setstate(struct mtp2 *link, int state);
-struct mtp2 * mtp2_new(int fd);
+struct mtp2 * mtp2_new(int fd, unsigned int switchtype);
 int mtp2_transmit(struct mtp2 *link);
 int mtp2_receive(struct mtp2 *link, unsigned char *buf, int len);
 int mtp2_msu(struct mtp2 *link, struct ss7_msg *m);

Modified: trunk/ss7.c
URL: http://svn.digium.com/view/libss7/trunk/ss7.c?rev=5&r1=4&r2=5&view=diff
==============================================================================
--- trunk/ss7.c (original)
+++ trunk/ss7.c Thu Aug  3 13:12:13 2006
@@ -147,7 +147,7 @@
 	if (ss7->numlinks >= SS7_MAX_LINKS)
 		return -1;
 
-	m = mtp2_new(fd);
+	m = mtp2_new(fd, ss7->switchtype);
 	
 	if (!m)
 		return -1;



More information about the libss7-commits mailing list