[svn-commits] mattf: trunk r161 - in /trunk: libss7.h mtp2.c mtp2.h ss7.c ss7linktest.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 9 19:59:31 CDT 2008


Author: mattf
Date: Fri May  9 19:59:30 2008
New Revision: 161

URL: http://svn.digium.com/view/libss7?view=rev&rev=161
Log:
Add support for kernel MTP2 support

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

Modified: trunk/libss7.h
URL: http://svn.digium.com/view/libss7/trunk/libss7.h?view=diff&rev=161&r1=160&r2=161
==============================================================================
--- trunk/libss7.h (original)
+++ trunk/libss7.h Fri May  9 19:59:30 2008
@@ -312,6 +312,8 @@
 
 const char *ss7_get_version(void);
 
+int ss7_pollflags(struct ss7 *ss7, int fd);
+
 /* ISUP call related message functions */
 
 /* Send an IAM */

Modified: trunk/mtp2.c
URL: http://svn.digium.com/view/libss7/trunk/mtp2.c?view=diff&rev=161&r1=160&r2=161
==============================================================================
--- trunk/mtp2.c (original)
+++ trunk/mtp2.c Fri May  9 19:59:30 2008
@@ -217,6 +217,7 @@
 {
 	struct ss7_msg *m;
 
+	link->flags |= MTP2_FLAG_WRITE;
 	/* Have to invert the current fib */
 	link->curfib = !link->curfib;
 
@@ -291,6 +292,10 @@
 				add_txbuf(link, m);
 			}
 		}
+
+		if (h == buf) { /* We just sent a non MSU */
+			link->flags &= ~MTP2_FLAG_WRITE;
+		}
 	}
 
 	return res;
@@ -300,6 +305,8 @@
 {
 	int len = m->size - MTP2_SIZE;
 	struct mtp_su_head *h = (struct mtp_su_head *) m->buf;
+
+	link->flags |= MTP2_FLAG_WRITE;
 
 	init_mtp2_header(link, h, 1, 0);
 
@@ -318,12 +325,14 @@
 
 static int mtp2_lssu(struct mtp2 *link, int lssu_status)
 {
+	link->flags |= MTP2_FLAG_WRITE;
 	link->autotxsutype = lssu_status;
 	return 0;
 }
 
 static int mtp2_fisu(struct mtp2 *link, int nack)
 {
+	link->flags |= MTP2_FLAG_WRITE;
 	link->autotxsutype = FISU;
 	return 0;
 }

Modified: trunk/mtp2.h
URL: http://svn.digium.com/view/libss7/trunk/mtp2.h?view=diff&rev=161&r1=160&r2=161
==============================================================================
--- trunk/mtp2.h (original)
+++ trunk/mtp2.h Fri May  9 19:59:30 2008
@@ -90,6 +90,7 @@
 	unsigned char lastfsnacked:7;
 	unsigned char curbib:1;
 	int fd;
+	int flags;
 
 	/* Timers */
 	int t1;
@@ -118,6 +119,10 @@
 	struct ss7 *master;
 };
 
+/* Flags for the struct mtp2 flags parameter */
+#define MTP2_FLAG_ZAPMTP2 (1 << 0)
+#define MTP2_FLAG_WRITE (1 << 1)
+
 /* Initialize MTP link */
 int mtp2_start(struct mtp2 *link, int emergency);
 int mtp2_stop(struct mtp2 *link);

Modified: trunk/ss7.c
URL: http://svn.digium.com/view/libss7/trunk/ss7.c?view=diff&rev=161&r1=160&r2=161
==============================================================================
--- trunk/ss7.c (original)
+++ trunk/ss7.c Fri May  9 19:59:30 2008
@@ -17,6 +17,9 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <zaptel/zaptel.h>
+#include <sys/ioctl.h>
+#include <sys/poll.h>
 #include "libss7.h"
 #include "ss7_internal.h"
 #include "mtp2.h"
@@ -168,7 +171,25 @@
 	if (ss7->numlinks >= SS7_MAX_LINKS)
 		return -1;
 
+	if (transport == SS7_TRANSPORT_TCP) {
+	}
+
 	if (transport == SS7_TRANSPORT_ZAP) {
+		int zapmtp2 = 0;
+#ifdef ZT_SIG_MTP2
+		struct zt_params z;
+		int res;
+
+		res = ioctl(fd, ZT_GET_PARAMS, &z);
+		if (res)
+			return res;
+
+		if (z.sigtype == ZT_SIG_MTP2) {
+			printf("Found zapmtp2\n");
+			zapmtp2 = 1;
+		}
+
+#endif /* ZT_SIG_MTP2 */
 		m = mtp2_new(fd, ss7->switchtype);
 		
 		if (!m)
@@ -177,15 +198,38 @@
 		m->slc = ss7->numlinks;
 		ss7->numlinks += 1;
 		m->master = ss7;
+		if (zapmtp2)
+			m->flags |= MTP2_FLAG_ZAPMTP2;
 
 		ss7->links[ss7->numlinks - 1] = m;
 	}
 
-	if (transport == SS7_TRANSPORT_TCP) {
-		/* TODO */
-	}
-
-	return 0;
+	return 0;
+}
+
+int ss7_pollflags(struct ss7 *ss7, int fd)
+{
+	int i;
+	int winner = -1;
+	int flags = POLLPRI | POLLIN;
+
+	for (i = 0; i < ss7->numlinks; i++) {
+		if (ss7->links[i]->fd == fd) {
+			winner = i;
+			break;
+		}
+	}
+	
+	if (winner < 0)
+		return -1;
+
+	if (ss7->links[winner]->flags & MTP2_FLAG_ZAPMTP2) {
+		if (ss7->links[winner]->flags & MTP2_FLAG_WRITE)
+			flags |= POLLOUT;
+	} else
+		flags |= POLLOUT;
+
+	return flags;
 }
 
 /* TODO: Add entry to routing table instead */

Modified: trunk/ss7linktest.c
URL: http://svn.digium.com/view/libss7/trunk/ss7linktest.c?view=diff&rev=161&r1=160&r2=161
==============================================================================
--- trunk/ss7linktest.c (original)
+++ trunk/ss7linktest.c Fri May  9 19:59:30 2008
@@ -75,7 +75,7 @@
 			nextms += tv.tv_usec / 1000;
 		}
 		poller.fd = linkset->fd;
-		poller.events = POLLIN | POLLOUT | POLLPRI;
+		poller.events = ss7_pollflags(ss7, linkset->fd);
 		poller.revents = 0;
 
 		res = poll(&poller, 1, nextms);




More information about the svn-commits mailing list