How to send data from a c programme with dahdi card to another dahdi card which use asterisk dahdi and chan_ss7

Hello everyone i’m trying to customize the chan_ss7 code so i extract a piece of the code of chan_ss7 that i tried to customize in order to send somme data to the other serveur running on asterisk and using another dahdi card but the writig is completing well and on the other server i don’t notice a message in asterisk console concerning what i sent. i think that my data is not sent .

can you help me

here is my code
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <pthread.h>
#include <errno.h>
#include <sys/time.h>
#include <dahdi/user.h>
#include <poll.h>

#define NUM_BUFS 32
#define ZAP_BUF_SIZE 16
int main()
{
int fd;
int devnum=16;
int ret=0;
unsigned char buf[512];
unsigned char buff[ZAP_BUF_SIZE];
unsigned int len, j;
int even, res;
struct pollfd fds[1];
int timeout_msecs = 500;
int x=1;
int i;
struct dahdi_bufferinfo bi;

    fd = open("/dev/dahdi/channel", O_RDWR|O_NONBLOCK);
    if ((fd < 0) || (ioctl(fd, DAHDI_SPECIFY, &devnum) == -1)) {
    printf("Could not open device %d: %s\n", fd,strerror(errno));
            return -1;
     }
    bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
    bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
    bi.numbufs = NUM_BUFS;
    bi.bufsize = 512;
    if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
     printf("Unable to set buffering policy on signalling link dahdi device: %s\n", strerror(errno));
            close(fd);
            return -1;
    }
  len = ZAP_BUF_SIZE;
  memset(buff, 1, len);

fds[0].fd=fd;
ret = poll(fds, 2, timeout_msecs);
 printf("merci poll \n");

if (ret > 0) {

 if(fds[0].revents & POLLOUT) {

  for(i=0; i<16; i++) {

for(;:wink: {
res = write(fds[0].fd, buff, len);
printf( “merci writing dahdi device \n”);

        if(res == 0) {
          /* EOF. */
          break;
        } else if(res < 0) {
          if(errno == EAGAIN || errno == EWOULDBLOCK) {
            /* Done until next successful poll(). */
           printf( "Error EAGAIN writing dahdi device , errno=%d: %s.\n", errno, strerror(errno));
            break;
        } else if(errno == EINTR) {
            /* Try again. */
             printf( "Error EINTR writing dahdi device , errno=%d: %s.\n", errno, strerror(errno));
          } else if(errno == ELAST) {
            //mtp2_fetch_zap_event(m);
             //  printf( " Error writing dahdi device , errno=%d: %s.\n", errno, strerror(errno));
             even=ioctl(fds[0].fd, DAHDI_GETEVENT, &x);
            printf("Got event on link : %d %d ,%d .\n", x, even, errno);

          } else {
            /* Some unexpected error. */
          printf( "Unexpected Error writing dahdi device , errno=%d: %s.\n", errno, strerror(errno));

            break;
          }
        }

else {
      /* Successful write. */
           printf( "merci writing dahdi device  \n");

              break;
          }

     }
     }
   }
   }
   else {
   printf( "ouff!!!  Error writing dahdi device , errno=%d: %s.\n", errno, strerror(errno));
     }
close(fds[0].fd);

   return 0;

}

This is not a developer forum. The mailing list at http://lists.digium.com/mailman/listinfo/asterisk-ss7 is likely to be a better choice.

Also, you need to use preformatted text for code to survive inclusion in the forum.

1 Like