diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-02-09 00:14:59 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-02-09 00:14:59 +0100 |
commit | 02ddcf9d90354237e521b523c6841a74208d3dd2 (patch) | |
tree | ce8b3e93e6d9fc7e4dfd6d2198d49ba7d4942c77 | |
parent | 05a26417806a65d3743c674e185bd206d2b15ff7 (diff) |
add tool to send continuous sequence of SABM frames into a D-channel
-rw-r--r-- | rbs_lapd/rbs_sabm.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/rbs_lapd/rbs_sabm.c b/rbs_lapd/rbs_sabm.c new file mode 100644 index 0000000..d71ef49 --- /dev/null +++ b/rbs_lapd/rbs_sabm.c @@ -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)); + } + } +} |