summaryrefslogtreecommitdiff
path: root/dahdi_diag.c
blob: 2fd56d7650da6b05e6160d3c7c3e10f8c4be911f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <dahdi/user.h>

int main(int argc, char *argv[])
{
	int fd;
	int chan;
	if ((argc < 2) || (sscanf(argv[1], "%d", &chan) != 1)) {
		fprintf(stderr, "Usage: ztdiag <channel>\n");
		exit(1);
	}
	fd = open("/dev/dahdi/ctl", O_RDWR);
	if (fd < 0) {
		perror("open(/dev/dahdi/ctl");
		exit(1);
	}
	if (ioctl(fd, DAHDI_CHANDIAG, &chan)) {
		perror("ioctl(DAHDI_CHANDIAG)");
		exit(1);
	}
	exit(0);
}