1 /* $NetBSD: main.c,v 1.8 2003/11/12 13:31:07 grant Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Martin Husemann <martin@NetBSD.org>.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/ioctl.h>
38 #include <netisdn/i4b_ioctl.h>
41 static void usage(void);
42 static void listall(int);
45 main(int argc
, char **argv
)
51 int lflag
, dflag
, xflag
, iflag
, sflag
, vflag
, pthrou
, ch
;
54 pthrou
= lflag
= dflag
= xflag
= iflag
= sflag
= vflag
= 0;
55 while ((ch
= getopt(argc
, argv
, "d:xsvlp")) != -1)
88 controller
= (int)strtol(*argv
, NULL
, 10);
91 isdndev
= open(PATH_ISDN_DEV
, O_RDWR
|O_EXLOCK
, 0);
93 isdndev
= open(PATH_ISDN_DEV
, O_RDWR
, 0);
96 perror(PATH_ISDN_DEV
);
103 if (controller
< 0) {
104 if (dflag
|| vflag
|| xflag
|| sflag
|| pthrou
)
105 fprintf(stderr
, "\nYou must specify the controller number!\n");
108 download(isdndev
, controller
, dnload
);
110 xversion(isdndev
, controller
);
112 xlog(isdndev
, controller
);
114 istat(isdndev
, controller
);
116 passthrough(isdndev
, controller
);
125 fprintf(stderr
, "usage: daicctl [-d (file)] [-xsie] controller\n"
126 " -l list available controllers\n"
127 " -d (file) download microcode from (file) to the card\n"
128 " -x xlog utility: show on card log\n"
129 " -s statistics (istat utility): show controller statistics\n"
130 " -v show version of microcode running on controller\n");
138 msg_ctrl_info_req_t info
;
140 memset(&info
, 0, sizeof info
);
141 ioctl(fd
, I4B_CTRL_INFO_REQ
, &info
);
142 num
= info
.max_isdnif
;
143 printf("There are %d controllers available:\n", info
.ncontroller
);
144 for (i
= 0; i
<= num
; i
++) {
146 if (ioctl(fd
, I4B_CTRL_INFO_REQ
, &info
) == 0) {
147 printf("BRI %d: %s\n", i
, info
.devname
);
148 printf("\t%s\n", info
.cardname
);
153 void passthrough(int fd
, int controller
)
155 static u_int8_t in_data
[] = {
157 '9', '8', '9', '0', '2', '0',
160 u_int8_t out_data
[16];
162 struct isdn_diagnostic_request req
;
164 printf("passing through: hardcoded dial request\n");
165 memset(&req
, 0, sizeof(req
));
166 req
.controller
= controller
;
168 req
.in_param_len
= sizeof in_data
;
169 req
.in_param
= &in_data
;
170 req
.out_param_len
= sizeof out_data
;
171 req
.out_param
= &out_data
;
173 if (ioctl(fd
, I4B_ACTIVE_DIAGNOSTIC
, &req
) == -1) {
174 perror("ioctl(I4B_ACTIVE_DIAGNOSTIC)");
177 printf("Return code: 0x%02x\n", out_data
[0]);