add tool to send continuous sequence of SABM frames into a D-channel
This commit is contained in:
parent
05a2641780
commit
02ddcf9d90
|
@ -0,0 +1,58 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* this program wants to be called with 'strace -s1024 -x' so you see the data
|
||||
* betewen DAHDI and it */
|
||||
|
||||
const uint8_t sabme_frame_nonraw[] = { 0xFA, 0x7D, 0x7F };
|
||||
|
||||
static int fd;
|
||||
static uint8_t dummy_buf[8192];
|
||||
|
||||
static void dummy_read(int fd, unsigned int len)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (len > sizeof(dummy_buf))
|
||||
len = sizeof(dummy_buf);
|
||||
|
||||
rc = read(fd, dummy_buf, len);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (argc < 2)
|
||||
exit(2);
|
||||
|
||||
fd = open(argv[1], O_RDWR|O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
perror("open");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
fd_set read_fd;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&read_fd);
|
||||
FD_SET(fd, &read_fd);
|
||||
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
rc = select(fd+1, &read_fd, NULL, NULL, &timeout);
|
||||
if (rc < 0) {
|
||||
perror("Select");
|
||||
exit(1);
|
||||
} else if (rc) {
|
||||
dummy_read(fd, 16);
|
||||
} else {
|
||||
write(fd, sabme_frame_nonraw, sizeof(sabme_frame_nonraw));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue