41
41
#include "dahdi_tools_version.h"
43
43
#define BLOCK_SIZE 2039
44
#define DEVICE "/dev/dahdi/channel"
46
static const char rcsid[] = "$Id: pattest.c 7658 2009-12-02 19:45:45Z tzafrir $";
49
static void usage(void)
51
fprintf(stderr, "Usage: %s <dahdi_chan>\n", prog_name);
52
fprintf(stderr, " e.g.: %s /dev/dahdi/55\n", prog_name);
53
fprintf(stderr, " %s 455\n", prog_name);
54
fprintf(stderr, "%s version %s\n", prog_name, rcsid);
45
58
void print_packet(unsigned char *buf, int len)
67
int channel_open(char *name, int *bs)
71
struct dahdi_params tp;
75
/* channo==0: The user passed a file name to be opened. */
76
dev = channo ? DEVICE : name;
78
fd = open(dev, O_RDWR, 0600);
85
/* If we got a channel number, get it from /dev/dahdi/channel: */
86
if(channo && ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
90
if(ioctl(fd, DAHDI_SET_BLOCKSIZE, bs) < 0) {
91
perror("SET_BLOCKSIZE");
95
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
96
fprintf(stderr, "Unable to get channel parameters\n");
54
103
int main(int argc, char *argv[])
58
struct dahdi_params tp;
59
107
int bs = BLOCK_SIZE;
60
108
unsigned char c=0;
61
109
unsigned char outbuf[BLOCK_SIZE];
66
fprintf(stderr, "Usage: %s <DAHDI device>\n", argv[0]);
69
fd = open(argv[1], O_RDWR, 0600);
71
fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
74
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs)) {
75
fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
78
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
79
fprintf(stderr, "Unable to get channel parameters\n");
120
fd = channel_open(argv[1], &bs);
82
124
ioctl(fd, DAHDI_GETEVENT);