Horacio J. Peña postou na lista de desenvolvimento do Asterisk um pequeno programa que permite sniffar E1 utilizando o DAHDI.


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "dahdi-user.h"

main()
{
int fds[62];
char fn[1024];
int i;
int BS=160;
char buf[BS];

for (i=0;i<62;++i) {
int c = i+1;
if( (fds[i] = open("/dev/dahdi/channel", O_RDWR)) < 0) {
printf("Error abriendo %s: %sn", fn, strerror(errno));
exit(1);
}
if (ioctl(fds[i], DAHDI_SPECIFY, &amp;amp;c) == -1) {
printf("Error ioctl SPE %d: %sn", i, strerror(errno));
exit(1);
}
if (ioctl(fds[i], DAHDI_SET_BLOCKSIZE, &amp;amp;BS) == -1) {
printf("Error ioctl BS %d: %sn", i, strerror(errno));
exit(1);
}
}

while (read (fds[0], buf, BS)) {
write (fds[31], buf, BS);
for (i=1;i<62;++i) {
read (fds[i], buf, BS);
write (fds[(i+31)%62], buf, BS);
}
}
}
Related Posts with Thumbnails

Deixe um comentario