This patch against 1.0.95-beta allows you to compile with DAHDI. I have not 
tested it.

Best regards,
-- 
Anders Baekgaard
Managing Director, Dicea ApS
Esromgade 15, 1110
DK-2200 Copenhagen N
Denmark
Tel: +45 46931411
Fax: +45 46931466
Mobile: +45 20771844

On Friday 14 November 2008 13:37:56 Hakan C wrote:
> Hello.
> Is there any patch for compiling and running chan_ss7 with DAHDI?
>
> Thanks.

diff -ur chan_ss7-1.0.95-beta/l4isup.c chan_ss7-1.0.96-beta/l4isup.c
--- chan_ss7-1.0.95-beta/l4isup.c	2008-09-08 11:55:31.000000000 +0200
+++ chan_ss7-1.0.96-beta/l4isup.c	2008-11-14 15:30:57.000000000 +0100
@@ -58,7 +58,18 @@
 #include "asterisk/alaw.h"
 #include "asterisk/ulaw.h"
 
-#include "kernel/zaptel.h"
+#ifdef DAHDI
+#include <dahdi/user.h>
+#else
+#include "zaptel.h"
+#define DAHDI_DIALING ZT_DIALING
+#define DAHDI_EVENT_DIALCOMPLETE ZT_EVENT_DIALCOMPLETE
+#define DAHDI_GETGAINS ZT_GETGAINS
+#define DAHDI_LAW_ALAW ZT_LAW_ALAW
+#define DAHDI_LAW_MULAW ZT_LAW_MULAW
+#define DAHDI_SETGAINS ZT_SETGAINS
+#define dahdi_gains zt_gains
+#endif
 
 #include "astversion.h"
 #include "config.h"
@@ -2080,12 +2091,12 @@
   int res, doing_dtmf;
 
   switch(event) {
-  case ZT_EVENT_DIALCOMPLETE:
+  case DAHDI_EVENT_DIALCOMPLETE:
     /* Chech if still doing DTMF sending. If not, set flag to start
        outputting audio again. */
-    res = ioctl(pvt->zaptel_fd, ZT_DIALING, &doing_dtmf);
+    res = ioctl(pvt->zaptel_fd, DAHDI_DIALING, &doing_dtmf);
     if(res < 0) {
-      ast_log(LOG_WARNING, "Error querying zaptel for ZT_DIALING on cic=%d: %s.\n",
+      ast_log(LOG_WARNING, "Error querying zaptel for DAHDI_DIALING on cic=%d: %s.\n",
 	      pvt->cic, strerror(errno));
       /* Better start the audio, don't want to permanently disable it. */
       pvt->sending_dtmf = 0;
@@ -4197,14 +4208,14 @@
 
 static int set_gain(struct ss7_chan *pvt, float rx_gain, float tx_gain) {
 
-  struct zt_gains gain;
+  struct dahdi_gains gain;
   float rx_linear_gain, tx_linear_gain;
   int res, i;
 
   memset(&gain, 0, sizeof(gain));
   gain.chan = 0;
 
-  res = ioctl(pvt->zaptel_fd, ZT_GETGAINS, &gain);
+  res = ioctl(pvt->zaptel_fd, DAHDI_GETGAINS, &gain);
   if (res) {
     ast_log(LOG_WARNING, "Failed to read gains: %s\n", strerror(errno));
     return -1;
@@ -4214,7 +4225,7 @@
   tx_linear_gain = pow(10.0, tx_gain / 20.0);
 
   switch (pvt->law) {
-      case ZT_LAW_ALAW:
+      case DAHDI_LAW_ALAW:
           /* Calculate receive-gain alaw-values */
           for (i = 0; i < (sizeof(gain.rxgain) / sizeof(gain.rxgain[0])); i++) {
               gain.rxgain[i] = fill_gain_alaw(rx_gain, rx_linear_gain, i);
@@ -4227,7 +4238,7 @@
 
           break;
 
-      case ZT_LAW_MULAW:
+      case DAHDI_LAW_MULAW:
           /* Calculate receive-gain ulaw-values */
           for (i = 0; i < (sizeof(gain.rxgain) / sizeof(gain.rxgain[0])); i++) {
               gain.rxgain[i] = fill_gain_ulaw(rx_gain, rx_linear_gain, i);
@@ -4245,7 +4256,7 @@
                     pvt->cic, pvt->link->name, rx_gain, tx_gain);
 
   /* Set gain-config on one timeslot */
-  res = ioctl(pvt->zaptel_fd, ZT_SETGAINS, &gain);
+  res = ioctl(pvt->zaptel_fd, DAHDI_SETGAINS, &gain);
   if (res) {
     ast_log(LOG_WARNING, "Failed to set gains: %s\n", strerror(errno));
   }
@@ -4303,7 +4314,7 @@
   pvt->is_digital = 0;
   pvt->grs_count = -1;
   pvt->cgb_mask = 0;
-  pvt->law = ZT_LAW_ALAW;
+  pvt->law = DAHDI_LAW_ALAW;
   memset(pvt->context, 0, sizeof(pvt->context));
   memset(pvt->language, 0, sizeof(pvt->language));
 };
diff -ur chan_ss7-1.0.95-beta/Makefile chan_ss7-1.0.96-beta/Makefile
--- chan_ss7-1.0.95-beta/Makefile	2008-09-08 12:35:41.000000000 +0200
+++ chan_ss7-1.0.96-beta/Makefile	2008-11-14 15:32:51.000000000 +0100
@@ -1,11 +1,13 @@
 # INSTALL_PREFIX may be overridden to install elsewhere from /usr.
 INSTALL_PREFIX = /usr/local/ss7
 
-VERSION=1.0.95-beta
+VERSION=1.0.96-beta
 
 # INCLUDE may be overridden to find asterisk and zaptel includes in
 # non-standard places.
-INCLUDE+=-I../source/telephony/zaptel -I../source/telephony/asterisk/include
+#INCLUDE+=-I../source/telephony/zaptel/kernel
+INCLUDE+=-I../source/telephony/dahdi/include
+INCLUDE+=-I../source/telephony/asterisk/include
 
 CC=gcc
 CFLAGS=$(INCLUDE) -g -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -D_REENTRANT -D_GNU_SOURCE -DPIC -fpic  -finline-functions
@@ -17,6 +19,8 @@
 
 # -DMODULETEST
 
+CFLAGS+=-DDAHDI
+
 SOLINK=-shared
 
 ifneq (${MODULETEST},)
diff -ur chan_ss7-1.0.95-beta/mtp.c chan_ss7-1.0.96-beta/mtp.c
--- chan_ss7-1.0.95-beta/mtp.c	2008-09-08 11:39:22.000000000 +0200
+++ chan_ss7-1.0.96-beta/mtp.c	2008-11-14 15:28:04.000000000 +0100
@@ -38,9 +38,22 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 
-#include "kernel/zaptel.h"
+#ifdef DAHDI
+#include <dahdi/user.h>
 #define FAST_HDLC_NEED_TABLES
-#include "kernel/fasthdlc.h"
+#include <dahdi/fasthdlc.h>
+#else
+#include "zaptel.h"
+#define FAST_HDLC_NEED_TABLES
+#include "fasthdlc.h"
+#define DAHDI_SIG_MTP2 ZT_SIG_MTP2
+#define DAHDI_EVENT_DIALCOMPLETE ZT_EVENT_DIALCOMPLETE
+#define DAHDI_DIALING ZT_DIALING
+#define DAHDI_GETGAINS ZT_GETGAINS
+#define DAHDI_SETGAINS ZT_SETGAINS
+#define DAHDI_LAW_ALAW ZT_LAW_ALAW
+#define DAHDI_LAW_MULAW ZT_LAW_MULAW
+#endif
 
 #include "config.h"
 #include "mtp.h"
@@ -2167,8 +2180,13 @@
   m->subservice = link->linkset->subservice;
   m->name = link->name;
   fasthdlc_precalc();
-  fasthdlc_init(&m->h_rx);
-  fasthdlc_init(&m->h_tx);
+#ifdef DAHDI
+    fasthdlc_init(&m->h_rx, FASTHDLC_MODE_64);
+    fasthdlc_init(&m->h_tx, FASTHDLC_MODE_64);
+#else
+    fasthdlc_init(&m->h_rx);
+    fasthdlc_init(&m->h_tx);
+#endif
   /* Fill in the fasthdlc transmit buffer with the opening flag. */
   fasthdlc_tx_frame_nocheck(&m->h_tx);
   memset(m->backbuf, 0, sizeof(m->backbuf));
diff -ur chan_ss7-1.0.95-beta/transport.c chan_ss7-1.0.96-beta/transport.c
--- chan_ss7-1.0.95-beta/transport.c	2008-09-01 11:31:40.000000000 +0200
+++ chan_ss7-1.0.96-beta/transport.c	2008-11-14 15:30:22.000000000 +0100
@@ -40,7 +40,36 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 
-#include "kernel/zaptel.h"
+#ifdef DAHDI
+#include <dahdi/user.h>
+#define FAST_HDLC_NEED_TABLES
+#include <dahdi/fasthdlc.h>
+#else
+#include "zaptel.h"
+#define FAST_HDLC_NEED_TABLES
+#include "fasthdlc.h"
+#define DAHDI_AUDIOMODE ZT_AUDIOMODE
+#define DAHDI_AUDIOMODE ZT_AUDIOMODE
+#define DAHDI_BUFFERINFO ZT_BUFFERINFO
+#define DAHDI_DIAL ZT_DIAL
+#define DAHDI_DIAL_OPERATION ZT_DIAL_OPERATION
+#define DAHDI_DIAL_OP_APPEND ZT_DIAL_OP_APPEND
+#define DAHDI_ECHOCANCEL ZT_ECHOCANCEL
+#define DAHDI_ECHOTRAIN ZT_ECHOTRAIN
+#define DAHDI_FLUSH ZT_FLUSH
+#define DAHDI_FLUSH_ALL ZT_FLUSH_ALL
+#define DAHDI_GETEVENT ZT_GETEVENT
+#define DAHDI_GET_BUFINFO ZT_GET_BUFINFO
+#define DAHDI_LAW_ALAW ZT_LAW_ALAW
+#define DAHDI_POLICY_IMMEDIATE ZT_POLICY_IMMEDIATE
+#define DAHDI_SETLAW ZT_SETLAW
+#define DAHDI_SET_BLOCKSIZE ZT_SET_BLOCKSIZE
+#define DAHDI_SET_BUFINFO ZT_SET_BUFINFO
+#define DAHDI_SPECIFY ZT_SPECIFY
+#define dahdi_bufferinfo zt_bufferinfo
+#define dahdi_dialoperation zt_dialoperation
+#endif
+
 
 #ifdef MTP_STANDALONE
 #include "aststubs.h"
@@ -78,14 +107,14 @@
 #ifndef MTP_OVER_UDP
 static void set_buffer_info(int fd, int cic, int numbufs)
 {
-  ZT_BUFFERINFO bi;
+  struct dahdi_bufferinfo bi;
   int res;
 
-  bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-  bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+  bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+  bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
   bi.numbufs = numbufs;
   bi.bufsize = AUDIO_READSIZE;
-  res = ioctl(fd, ZT_SET_BUFINFO, &bi);
+  res = ioctl(fd, DAHDI_SET_BUFINFO, &bi);
   if(res) {
     ast_log(LOG_WARNING, "Failure to set buffer policy for circuit %d: %s.\n", cic, strerror(errno));
   }
@@ -93,10 +122,10 @@
 
 int adjust_buffers(int fd, int cic)
 {
-  ZT_BUFFERINFO bi;
+  struct dahdi_bufferinfo bi;
   int res;
 
-  res = ioctl(fd, ZT_GET_BUFINFO, &bi);
+  res = ioctl(fd, DAHDI_GET_BUFINFO, &bi);
   if(res) {
     ast_log(LOG_WARNING, "Failure to get buffer policy for circuit %d: %s.\n", cic, strerror(errno));
     return 0;
@@ -122,7 +151,7 @@
   int res;
   int z = 1;
 
-  res = ioctl(fd, ZT_AUDIOMODE, &z);
+  res = ioctl(fd, DAHDI_AUDIOMODE, &z);
   if (res)
     ast_log(LOG_WARNING, "Unable to set fd %d to audiomode\n", fd);
 }
@@ -133,7 +162,7 @@
   int res;
   int z = 0;
 
-  res = ioctl(fd, ZT_AUDIOMODE, &z);
+  res = ioctl(fd, DAHDI_AUDIOMODE, &z);
   if (res)
     ast_log(LOG_WARNING, "Unable to clear audiomode on fd %d\n", fd);
 }
@@ -151,20 +180,20 @@
     ast_log(LOG_ERROR, "Unable to open /dev/zap/channel: %s.\n", strerror(errno));
     return -1;
   }
-  res = ioctl(fd, ZT_SPECIFY, &zapid);
+  res = ioctl(fd, DAHDI_SPECIFY, &zapid);
   if(res) {
-    ast_log(LOG_WARNING, "Failure in ZT_SPECIFY for circuit %d: %s.\n", cic, strerror(errno));
+    ast_log(LOG_WARNING, "Failure in DAHDI_SPECIFY for circuit %d: %s.\n", cic, strerror(errno));
     return -1;
   }
-  parm = ZT_LAW_ALAW;
-  res = ioctl(fd, ZT_SETLAW, &parm);
+  parm = DAHDI_LAW_ALAW;
+  res = ioctl(fd, DAHDI_SETLAW, &parm);
   if(res) {
     ast_log(LOG_DEBUG, "Failure to set circuit   %d to ALAW: %s.\n", cic, strerror(errno));
     return -1;
   }
   set_buffer_info(fd, cic, 4);
   parm = AUDIO_READSIZE;
-  res = ioctl(fd, ZT_SET_BLOCKSIZE, &parm);
+  res = ioctl(fd, DAHDI_SET_BLOCKSIZE, &parm);
   if(res) {
     ast_log(LOG_WARNING, "Failure to set blocksize for circuit %d: %s.\n", cic, strerror(errno));
     return -1;
@@ -182,8 +211,8 @@
   int parm, res;
 
   /* Flush timeslot of old data. */
-  parm = ZT_FLUSH_ALL;
-  res = ioctl(fd, ZT_FLUSH, &parm);
+  parm = DAHDI_FLUSH_ALL;
+  res = ioctl(fd, DAHDI_FLUSH, &parm);
   if (res) {
     ast_log(LOG_WARNING, "Unable to flush input on circuit %d\n", cic);
   }
@@ -193,7 +222,7 @@
 
 int openschannel(struct link* link)
 {
-  ZT_BUFFERINFO bi;
+  struct dahdi_bufferinfo bi;
   char devname[100];
   int fd, res;
   int zapid = link->schannel + link->first_zapid;
@@ -214,17 +243,17 @@
     goto fail;
   }
 
-  if (ioctl(fd, ZT_SPECIFY, &zapid)) {
+  if (ioctl(fd, DAHDI_SPECIFY, &zapid)) {
     ast_log(LOG_WARNING, "Unable to specify channel %d: %s\n", zapid, strerror(errno));
     goto fail;
   }
 #endif
 
-  bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-  bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+  bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+  bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
   bi.numbufs = NUM_ZAP_BUF;
   bi.bufsize = ZAP_BUF_SIZE;
-  if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+  if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
     ast_log(LOG_WARNING, "Unable to set buffering policy on signalling link "
             "zaptel device: %s\n", strerror(errno));
     goto fail;
@@ -243,7 +272,7 @@
 
 int io_get_zaptel_event(int fd, int* e)
 {
-  return ioctl(fd, ZT_GETEVENT, e);
+  return ioctl(fd, DAHDI_GETEVENT, e);
 }
 
 
@@ -251,17 +280,17 @@
 {
   int res, parm = 1;
 
-  res = ioctl(fd, ZT_AUDIOMODE, &parm);
+  res = ioctl(fd, DAHDI_AUDIOMODE, &parm);
   if (res)
     ast_log(LOG_WARNING, "Unable to set fd %d to audiomode\n", fd);
 
-  res = ioctl(fd, ZT_ECHOCANCEL, &echocan_taps);
+  res = ioctl(fd, DAHDI_ECHOCANCEL, &echocan_taps);
   if (res) {
     ast_log(LOG_WARNING, "Unable to enable echo cancellation on cic %d\n", cic);
     return res;
   } else {
     ast_log(LOG_DEBUG, "Enabled echo cancellation on cic %d\n", cic);
-    res = ioctl(fd, ZT_ECHOTRAIN, &echocan_train);
+    res = ioctl(fd, DAHDI_ECHOTRAIN, &echocan_train);
     if (res) {
       ast_log(LOG_WARNING, "Unable to request echo training on cic %d\n", cic);
       return res;
@@ -277,7 +306,7 @@
   int res;
   int x = 0;
 
-  res = ioctl(fd, ZT_ECHOCANCEL, &x);
+  res = ioctl(fd, DAHDI_ECHOCANCEL, &x);
   if (res) 
     ast_log(LOG_WARNING, "Unable to disable echo cancellation on cic %d\n", cic);
   else
@@ -287,14 +316,14 @@
 
 int io_send_dtmf(int fd, int cic, char digit)
 {
-  ZT_DIAL_OPERATION zo;
+  struct dahdi_dialoperation zo;
   int res;
 
-  zo.op = ZT_DIAL_OP_APPEND;
+  zo.op = DAHDI_DIAL_OP_APPEND;
   zo.dialstr[0] = 'T';
   zo.dialstr[1] = digit;
   zo.dialstr[2] = 0;
-  res = ioctl(fd, ZT_DIAL, &zo);
+  res = ioctl(fd, DAHDI_DIAL, &zo);
   if(res) {
     ast_log(LOG_WARNING, "DTMF generation of %c failed on CIC=%d.\n", digit, cic);
     return res;
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-ss7 mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-ss7

Reply via email to