summaryrefslogtreecommitdiff
path: root/ztdiag.c
blob: a1e476ca870ee36f840812f4d3e376adbb00107d (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
28
29
30
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef STANDALONE_ZAPATA
#include "zaptel.h"
#else
#include <linux/zaptel.h>
#endif

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/zap/ctl");
	if (fd < 0) {
		perror("open(/dev/zap/ctl");
		exit(1);
	}
	if (ioctl(fd, ZT_CHANDIAG, &chan)) {
		perror("ioctl(ZT_CHANDIAG)");
		exit(1);
	}
	exit(0);
}