[svn-commits] mattf: branch mattf/libpri-1.4-ntptmp r938 - /team/mattf/libpri-1.4-ntptmp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 9 15:32:33 CDT 2009


Author: mattf
Date: Thu Jul  9 15:32:29 2009
New Revision: 938

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=938
Log:
Add initial support for PTMP in NT mode.

Modified:
    team/mattf/libpri-1.4-ntptmp/Makefile
    team/mattf/libpri-1.4-ntptmp/pri_q921.h
    team/mattf/libpri-1.4-ntptmp/q921.c
    team/mattf/libpri-1.4-ntptmp/q931.c

Modified: team/mattf/libpri-1.4-ntptmp/Makefile
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/Makefile?view=diff&rev=938&r1=937&r2=938
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/Makefile (original)
+++ team/mattf/libpri-1.4-ntptmp/Makefile Thu Jul  9 15:32:29 2009
@@ -138,7 +138,7 @@
 ifneq (${OSARCH},SunOS)
 	install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
 	install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
-	if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
+#	if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
 	( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
 	install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
 	if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi

Modified: team/mattf/libpri-1.4-ntptmp/pri_q921.h
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_q921.h?view=diff&rev=938&r1=937&r2=938
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/pri_q921.h (original)
+++ team/mattf/libpri-1.4-ntptmp/pri_q921.h Thu Jul  9 15:32:29 2009
@@ -192,6 +192,8 @@
 
 extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr);
 
+extern int q921_transmit_uiframe(struct pri *pri, void *buf, int len);
+
 extern pri_event *q921_dchannel_up(struct pri *pri);
 
 extern pri_event *q921_dchannel_down(struct pri *pri);

Modified: team/mattf/libpri-1.4-ntptmp/q921.c
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=938&r1=937&r2=938
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/q921.c (original)
+++ team/mattf/libpri-1.4-ntptmp/q921.c Thu Jul  9 15:32:29 2009
@@ -27,6 +27,7 @@
  * terms granted here.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -480,6 +481,45 @@
 		pri_error(pri, "T200 counter expired, nothing to send...\n");
 	   	pri->t200_timer = 0;
 	}
+}
+
+int q921_transmit_uiframe(struct pri *pri, void *buf, int len)
+{
+	uint8_t ubuf[512];
+	q921_h *h = (void *)&ubuf[0];
+
+	if (len >= 512) {
+		pri_error(pri, "Requested to send UI frame larger than 512 bytes!\n");
+		return -1;
+	}
+
+	memset(ubuf, 0, sizeof(ubuf));
+	h->h.sapi = 0;
+	h->h.ea1 = 0;
+	h->h.ea2 = 1;
+	h->h.tei = pri->tei;
+	h->u.m3 = 0;
+	h->u.m2 = 0;
+	h->u.p_f = 0;	/* Poll bit set */
+	h->u.ft = Q921_FRAMETYPE_U;
+
+	switch(pri->localtype) {
+	case PRI_NETWORK:
+		h->h.c_r = 1;
+		break;
+	case PRI_CPE:
+		h->h.c_r = 0;
+		break;
+	default:
+		pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype);
+		return -1;
+	}
+
+	memcpy(h->u.data, buf, len);
+
+	q921_transmit(pri, h, len + 3);
+
+	return 0;
 }
 
 int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)

Modified: team/mattf/libpri-1.4-ntptmp/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=938&r1=937&r2=938
==============================================================================
--- team/mattf/libpri-1.4-ntptmp/q931.c (original)
+++ team/mattf/libpri-1.4-ntptmp/q931.c Thu Jul  9 15:32:29 2009
@@ -2675,9 +2675,25 @@
 	*mhb = mh;
 }
 
+static int inline PRI_NT_PTMP(struct pri *ctrl)
+{
+	return (((ctrl)->localtype == PRI_NETWORK) && ((ctrl)->tei == Q921_TEI_GROUP));
+}
+
 static int q931_xmit(struct pri *ctrl, q931_h *h, int len, int cr)
 {
-	q921_transmit_iframe(ctrl, h, len, cr);
+	/* 
+	 * For NT-PTMP mode, we need to check the following:
+	 * MODE = NT-PTMP
+	 * MESSAGE = SETUP
+	 *
+	 * If those are true, we need to send the SETUP in a UI frame
+	 * instead of an I-frame.
+	 */
+	if (PRI_NT_PTMP(ctrl))
+		q921_transmit_uiframe(ctrl, h, len);
+	else
+		q921_transmit_iframe(ctrl, h, len, cr);
 	/* The transmit operation might dump the q921 header, so logging the q931
 	   message body after the transmit puts the sections of the message in the
 	   right order in the log */




More information about the svn-commits mailing list